Remove all $Id$ from top of file
[metze/wireshark/wip.git] / epan / dissectors / packet-infiniband.c
1 /* packet-infiniband.c
2  * Routines for Infiniband/ERF Dissection
3  * Copyright 2008 Endace Technology Limited
4  *
5  * Wireshark - Network traffic analyzer
6  * By Gerald Combs <gerald@wireshark.org>
7  * Copyright 1998 Gerald Combs
8  *
9  * Modified 2010 by Mellanox Technologies Ltd.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25
26 #include "config.h"
27
28 #include <string.h>
29
30 #include <glib.h>
31
32 #include <epan/packet.h>
33 #include <epan/exceptions.h>
34 #include <epan/wmem/wmem.h>
35 #include <epan/conversation.h>
36 #include <epan/prefs.h>
37 #include <wiretap/wtap.h>
38 #include <epan/etypes.h>
39 #include <epan/show_exception.h>
40 #include <epan/to_str.h>
41
42 #include "packet-infiniband.h"
43
44 void proto_register_infiniband(void);
45 void proto_reg_handoff_infiniband(void);
46
47 #define PROTO_TAG_INFINIBAND    "Infiniband"
48
49 /* Wireshark ID */
50 static int proto_infiniband = -1;
51 static int proto_infiniband_link = -1;
52
53 /* Variables to hold expansion values between packets */
54 /* static gint ett_infiniband = -1;                */
55 static gint ett_all_headers = -1;
56 static gint ett_lrh = -1;
57 static gint ett_grh = -1;
58 static gint ett_bth = -1;
59 static gint ett_rwh = -1;
60 static gint ett_rdeth = -1;
61 static gint ett_deth = -1;
62 static gint ett_reth = -1;
63 static gint ett_atomiceth = -1;
64 static gint ett_aeth = -1;
65 static gint ett_atomicacketh = -1;
66 static gint ett_immdt = -1;
67 static gint ett_ieth = -1;
68 static gint ett_payload = -1;
69 static gint ett_vendor = -1;
70 static gint ett_subn_lid_routed = -1;
71 static gint ett_subn_directed_route = -1;
72 static gint ett_subnadmin = -1;
73 static gint ett_mad = -1;
74 static gint ett_cm = -1;
75 static gint ett_rmpp = -1;
76 static gint ett_subm_attribute = -1;
77 static gint ett_suba_attribute = -1;
78 static gint ett_datadetails = -1;
79 static gint ett_noticestraps = -1;
80 /* static gint ett_nodedesc = -1;                  */
81 /* static gint ett_nodeinfo = -1;                  */
82 /* static gint ett_switchinfo = -1;                */
83 /* static gint ett_guidinfo = -1;                  */
84 /* static gint ett_portinfo = -1;                  */
85 static gint ett_portinfo_capmask = -1;
86 static gint ett_pkeytable = -1;
87 static gint ett_sltovlmapping = -1;
88 static gint ett_vlarbitrationtable = -1;
89 static gint ett_linearforwardingtable = -1;
90 static gint ett_randomforwardingtable = -1;
91 static gint ett_multicastforwardingtable = -1;
92 static gint ett_sminfo = -1;
93 static gint ett_vendordiag = -1;
94 static gint ett_ledinfo = -1;
95 static gint ett_linkspeedwidthpairs = -1;
96 static gint ett_informinfo = -1;
97 static gint ett_linkrecord = -1;
98 static gint ett_servicerecord = -1;
99 static gint ett_pathrecord = -1;
100 static gint ett_mcmemberrecord = -1;
101 static gint ett_tracerecord = -1;
102 static gint ett_multipathrecord = -1;
103 static gint ett_serviceassocrecord = -1;
104 static gint ett_perfclass = -1;
105 static gint ett_eoib = -1;
106 static gint ett_link = -1;
107
108 /* Global ref to highest level tree should we find other protocols encapsulated in IB */
109 static proto_tree *top_tree = NULL;
110
111 /* Dissector Declaration */
112 static dissector_handle_t ib_handle;
113
114 /* Subdissectors Declarations */
115 static dissector_handle_t ipv6_handle;
116 static dissector_handle_t data_handle;
117 static dissector_handle_t eth_handle;
118 static dissector_table_t ethertype_dissector_table;
119
120 /* MAD_Data
121 * Structure to hold information from the common MAD header.
122 * This is necessary because the MAD header contains information which significantly changes the dissection algorithm. */
123 typedef struct {
124     guint8 managementClass;
125     guint8 classVersion;
126     guint8 method;
127     guint8 status;
128     guint16 classSpecific;
129     guint64 transactionID;
130     guint16 attributeID;
131     guint32 attributeModifier;
132     char data[232];
133 } MAD_Data;
134
135 /* Forward-declarations */
136
137 static void dissect_roce(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
138 static void dissect_infiniband(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
139 static void dissect_infiniband_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean starts_with_grh);
140 static void dissect_infiniband_link(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
141 static gint32 find_next_header_sequence(guint32 OpCode);
142 static gboolean contains(guint32 value, guint32* arr, int length);
143 static void dissect_general_info(tvbuff_t *tvb, gint offset, packet_info *pinfo, gboolean starts_with_grh);
144
145 /* Parsing Methods for specific IB headers. */
146
147 static void parse_VENDOR(proto_tree *, tvbuff_t *, gint *);
148 static void parse_PAYLOAD(proto_tree *, packet_info *, struct infinibandinfo *, tvbuff_t *, gint *, gint length);
149 static void parse_IETH(proto_tree *, tvbuff_t *, gint *);
150 static void parse_IMMDT(proto_tree *, tvbuff_t *, gint *offset);
151 static void parse_ATOMICACKETH(proto_tree *, tvbuff_t *, gint *offset);
152 static void parse_AETH(proto_tree *, tvbuff_t *, gint *offset);
153 static void parse_ATOMICETH(proto_tree *, tvbuff_t *, gint *offset);
154 static void parse_RETH(proto_tree *, tvbuff_t *, gint *offset);
155 static void parse_DETH(proto_tree *, packet_info *, tvbuff_t *, gint *offset);
156 static void parse_RDETH(proto_tree *, tvbuff_t *, gint *offset);
157 static void parse_IPvSix(proto_tree *, tvbuff_t *, gint *offset, packet_info *);
158 static void parse_RWH(proto_tree *, tvbuff_t *, gint *offset, packet_info *);
159 static gboolean parse_EoIB(proto_tree *, tvbuff_t *, gint offset, packet_info *);
160
161 static void parse_SUBN_LID_ROUTED(proto_tree *, packet_info *, tvbuff_t *, gint *offset);
162 static void parse_SUBN_DIRECTED_ROUTE(proto_tree *, packet_info *, tvbuff_t *, gint *offset);
163 static void parse_SUBNADMN(proto_tree *, packet_info *, tvbuff_t *, gint *offset);
164 static void parse_PERF(proto_tree *, tvbuff_t *, packet_info *, gint *offset);
165 static void parse_BM(proto_tree *, tvbuff_t *, gint *offset);
166 static void parse_DEV_MGT(proto_tree *, tvbuff_t *, gint *offset);
167 static void parse_COM_MGT(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset);
168 static void parse_SNMP(proto_tree *, tvbuff_t *, gint *offset);
169 static void parse_VENDOR_MANAGEMENT(proto_tree *, tvbuff_t *, gint *offset);
170 static void parse_APPLICATION_MANAGEMENT(proto_tree *, tvbuff_t *, gint *offset);
171 static void parse_RESERVED_MANAGEMENT(proto_tree *, tvbuff_t *, gint *offset);
172
173 static gboolean parse_MAD_Common(proto_tree*, tvbuff_t*, gint *offset, MAD_Data*);
174 static gboolean parse_RMPP(proto_tree* , tvbuff_t* , gint *offset);
175 static void label_SUBM_Method(proto_item*, MAD_Data*, packet_info*);
176 static void label_SUBM_Attribute(proto_item*, MAD_Data*, packet_info*);
177 static void label_SUBA_Method(proto_item*, MAD_Data*, packet_info*);
178 static void label_SUBA_Attribute(proto_item*, MAD_Data*, packet_info*);
179
180 /* Class Attribute Parsing Routines */
181 static gboolean parse_SUBM_Attribute(proto_tree*, tvbuff_t*, gint *offset, MAD_Data*);
182 static gboolean parse_SUBA_Attribute(proto_tree*, tvbuff_t*, gint *offset, MAD_Data*);
183
184 /* These methods parse individual attributes
185 * Naming convention FunctionHandle = "parse_" + [Attribute Name];
186 * Where [Attribute Name] is the attribute identifier from chapter 14 of the IB Specification
187 * Subnet Management */
188 static void parse_NoticesAndTraps(proto_tree*, tvbuff_t*, gint *offset);
189 static void parse_NodeDescription(proto_tree*, tvbuff_t*, gint *offset);
190 static int parse_NodeInfo(proto_tree*, tvbuff_t*, gint *offset);
191 static int parse_SwitchInfo(proto_tree*, tvbuff_t*, gint *offset);
192 static int parse_GUIDInfo(proto_tree*, tvbuff_t*, gint *offset);
193 static int parse_PortInfo(proto_tree*, tvbuff_t*, gint *offset);
194 static void parse_P_KeyTable(proto_tree*, tvbuff_t*, gint *offset);
195 static void parse_SLtoVLMappingTable(proto_tree*, tvbuff_t*, gint *offset);
196 static void parse_VLArbitrationTable(proto_tree*, tvbuff_t*, gint *offset);
197 static void parse_LinearForwardingTable(proto_tree*, tvbuff_t*, gint *offset);
198 static void parse_RandomForwardingTable(proto_tree*, tvbuff_t*, gint *offset);
199 static void parse_MulticastForwardingTable(proto_tree*, tvbuff_t*, gint *offset);
200 static int parse_SMInfo(proto_tree*, tvbuff_t*, gint *offset);
201 static int parse_VendorDiag(proto_tree*, tvbuff_t*, gint *offset);
202 static void parse_LedInfo(proto_tree*, tvbuff_t*, gint *offset);
203 static int parse_LinkSpeedWidthPairsTable(proto_tree*, tvbuff_t*, gint *offset);
204
205 /* These methods parse individual attributes for specific MAD management classes.
206 * Naming convention FunctionHandle = "parse_" + [Management Class] + "_" + [Attribute Name];
207 * Where [Management Class] is the shorthand name for the management class as defined
208 * in the MAD Management Classes section below in this file, and [Attribute Name] is the
209 * attribute identifier from the corresponding chapter of the IB Specification */
210 static int parse_PERF_PortCounters(proto_tree* parentTree, tvbuff_t* tvb, packet_info *pinfo, gint *offset);
211 static int parse_PERF_PortCountersExtended(proto_tree* parentTree, tvbuff_t* tvb, packet_info *pinfo, gint *offset);
212
213 /* Subnet Administration */
214 static int parse_InformInfo(proto_tree*, tvbuff_t*, gint *offset);
215 static int parse_LinkRecord(proto_tree*, tvbuff_t*, gint *offset);
216 static int parse_ServiceRecord(proto_tree*, tvbuff_t*, gint *offset);
217 static int parse_PathRecord(proto_tree*, tvbuff_t*, gint *offset);
218 static int parse_MCMemberRecord(proto_tree*, tvbuff_t*, gint *offset);
219 static int parse_TraceRecord(proto_tree*, tvbuff_t*, gint *offset);
220 static int parse_MultiPathRecord(proto_tree*, tvbuff_t*, gint *offset);
221 static int parse_ServiceAssociationRecord(proto_tree*, tvbuff_t*, gint *offset);
222
223 /* Subnet Administration */
224 static void parse_RID(proto_tree*, tvbuff_t*, gint *offset, MAD_Data*);
225
226 /* SM Methods */
227 static const value_string SUBM_Methods[] = {
228     { 0x01, "SubnGet("},
229     { 0x02, "SubnSet("},
230     { 0x81, "SubnGetResp("},
231     { 0x05, "SubnTrap("},
232     { 0x07, "SubnTrapResp("},
233     { 0, NULL}
234 };
235 /* SM Attributes */
236 static const value_string SUBM_Attributes[] = {
237     { 0x0001, "Attribute (ClassPortInfo)"},
238     { 0x0002, "Attribute (Notice)"},
239     { 0x0003, "Attribute (InformInfo)"},
240     { 0x0010, "Attribute (NodeDescription)"},
241     { 0x0011, "Attribute (NodeInfo)"},
242     { 0x0012, "Attribute (SwitchInfo)"},
243     { 0x0014, "Attribute (GUIDInfo)"},
244     { 0x0015, "Attribute (PortInfo)"},
245     { 0x0016, "Attribute (P_KeyTable)"},
246     { 0x0017, "Attribute (SLtoVLMapptingTable)"},
247     { 0x0018, "Attribute (VLArbitrationTable)"},
248     { 0x0019, "Attribute (LinearForwardingTable)"},
249     { 0x001A, "Attribute (RandomForwardingTable)"},
250     { 0x001B, "Attribute (MulticastForwardingTable)"},
251     { 0x001C, "Attribute (LinkSpeedWidthPairsTable)"},
252     { 0x0020, "Attribute (SMInfo)"},
253     { 0x0030, "Attribute (VendorDiag)"},
254     { 0x0031, "Attribute (LedInfo)"},
255     { 0, NULL}
256 };
257
258 /* SA Methods */
259 static const value_string SUBA_Methods[] = {
260     { 0x01, "SubnAdmGet("},
261     { 0x81, "SubnAdmGetResp("},
262     { 0x02, "SubnAdmSet("},
263     { 0x06, "SubnAdmReport("},
264     { 0x86, "SubnAdmReportResp("},
265     { 0x12, "SubnAdmGetTable("},
266     { 0x92, "SubnAdmGetTableResp("},
267     { 0x13, "SubnAdmGetTraceTable("},
268     { 0x14, "SubnAdmGetMulti("},
269     { 0x94, "SubnAdmGetMultiResp("},
270     { 0x15, "SubnAdmDelete("},
271     { 0x95, "SubnAdmDeleteResp("},
272     { 0, NULL}
273 };
274 /* SA Attributes */
275 static const value_string SUBA_Attributes[] = {
276     { 0x0001, "Attribute (ClassPortInfo)"},
277     { 0x0002, "Attribute (Notice)"},
278     { 0x0003, "Attribute (InformInfo)"},
279     { 0x0011, "Attribute (NodeRecord)"},
280     { 0x0012, "Attribute (PortInfoRecord)"},
281     { 0x0013, "Attribute (SLtoVLMappingTableRecord)"},
282     { 0x0014, "Attribute (SwitchInfoRecord)"},
283     { 0x0015, "Attribute (LinearForwardingTableRecord)"},
284     { 0x0016, "Attribute (RandomForwardingTableRecord)"},
285     { 0x0017, "Attribute (MulticastForwardingTableRecord)"},
286     { 0x0018, "Attribute (SMInfoRecord)"},
287     { 0x0019, "Attribute (LinkSpeedWidthPairsTableRecord)"},
288     { 0x00F3, "Attribute (InformInfoRecord)"},
289     { 0x0020, "Attribute (LinkRecord)"},
290     { 0x0030, "Attribute (GuidInfoRecord)"},
291     { 0x0031, "Attribute (ServiceRecord)"},
292     { 0x0033, "Attribute (P_KeyTableRecord)"},
293     { 0x0035, "Attribute (PathRecord)"},
294     { 0x0036, "Attribute (VLArbitrationTableRecord)"},
295     { 0x0038, "Attribute (MCMembersRecord)"},
296     { 0x0039, "Attribute (TraceRecord)"},
297     { 0x003A, "Attribute (MultiPathRecord)"},
298     { 0x003B, "Attribute (ServiceAssociationRecord)"},
299     { 0, NULL}
300 };
301
302 /* CM Attributes */
303 static const value_string CM_Attributes[] = {
304     { 0x0001, "ClassPortInfo"},
305     { 0x0010, "ConnectRequest"},
306     { 0x0011, "MsgRcptAck"},
307     { 0x0012, "ConnectReject"},
308     { 0x0013, "ConnectReply"},
309     { 0x0014, "ReadyToUse"},
310     { 0x0015, "DisconnectRequest"},
311     { 0x0016, "DisconnectReply"},
312     { 0x0017, "ServiceIDResReq"},
313     { 0x0018, "ServiceIDResReqResp"},
314     { 0x0019, "LoadAlternatePath"},
315     { 0x001A, "AlternatePathResponse"},
316     { 0, NULL}
317 };
318
319
320 /* RMPP Types */
321 #define RMPP_ILLEGAL 0
322 #define RMPP_DATA   1
323 #define RMPP_ACK    2
324 #define RMPP_STOP   3
325 #define RMPP_ABORT  4
326
327 static const value_string RMPP_Packet_Types[] = {
328     { RMPP_ILLEGAL, " Illegal RMPP Type (0)! " },
329     { RMPP_DATA,    "RMPP (DATA)" },
330     { RMPP_ACK,     "RMPP (ACK)" },
331     { RMPP_STOP,    "RMPP (STOP)" },
332     { RMPP_ABORT,   "RMPP (ABORT)" },
333     { 0, NULL}
334 };
335
336 static const value_string RMPP_Flags[] = {
337     { 3, " (Transmission Sequence - First Packet)"},
338     { 5, " (Transmission Sequence - Last Packet)"},
339     { 1, " (Transmission Sequence) " },
340     { 0, NULL}
341 };
342
343 static const value_string RMPP_Status[]= {
344     {   0, " (Normal)"},
345     {   1, " (Resources Exhausted)"},
346     { 118, " (Total Time Too Long)"},
347     { 119, " (Inconsistent Last and PayloadLength)"},
348     { 120, " (Inconsistent First and Segment Number)"},
349     { 121, " (Bad RMPPType)"},
350     { 122, " (NewWindowLast Too Small)"},
351     { 123, " (SegmentNumber Too Big)"},
352     { 124, " (Illegal Status)"},
353     { 125, " (Unsupported Version)"},
354     { 126, " (Too Many Retries)"},
355     { 127, " (Unspecified - Unknown Error Code on ABORT)"},
356     { 0, NULL}
357 };
358
359 static const value_string DiagCode[]= {
360     {0x0000, "Function Ready"},
361     {0x0001, "Performing Self Test"},
362     {0x0002, "Initializing"},
363     {0x0003, "Soft Error - Function has non-fatal error"},
364     {0x0004, "Hard Error - Function has fatal error"},
365     { 0, NULL}
366 };
367 static const value_string LinkWidthEnabled[]= {
368     {0x0000, "No State Change"},
369     {0x0001, "1x"},
370     {0x0002, "4x"},
371     {0x0003, "1x or 4x"},
372     {0x0004, "8x"},
373     {0x0005, "1x or 8x"},
374     {0x0006, "4x or 8x"},
375     {0x0007, "1x or 4x or 8x"},
376     {0x0008, "12x"},
377     {0x0009, "1x or 12x"},
378     {0x000A, "4x or 12x"},
379     {0x000B, "1x or 4x or 12x"},
380     {0x000C, "8x or 12x"},
381     {0x000D, "1x or 8x or 12x"},
382     {0x000E, "4x or 8x or 12x"},
383     {0x000E, "1x or 4x or 8x or 12x"},
384     {0x00FF, "Set to LinkWidthSupported Value - Response contains actual LinkWidthSupported"},
385     { 0, NULL}
386 };
387
388 static const value_string LinkWidthSupported[]= {
389     {0x0001, "1x"},
390     {0x0003, "1x or 4x"},
391     {0x0007, "1x or 4x or 8x"},
392     {0x000B, "1x or 4x or 12x"},
393     {0x000F, "1x or 4x or 8x or 12x"},
394     { 0, NULL}
395 };
396 static const value_string LinkWidthActive[]= {
397     {0x0001, "1x"},
398     {0x0002, "4x"},
399     {0x0004, "8x"},
400     {0x0008, "12x"},
401     { 0, NULL}
402 };
403 static const value_string LinkSpeedSupported[]= {
404     {0x0001, "2.5 Gbps"},
405     {0x0003, "2.5 or 5.0 Gbps"},
406     {0x0005, "2.5 or 10.0 Gbps"},
407     {0x0007, "2.5 or 5.0 or 10.0 Gbps"},
408     { 0, NULL}
409 };
410 static const value_string PortState[]= {
411     {0x0000, "No State Change"},
412     {0x0001, "Down (includes failed links)"},
413     {0x0002, "Initialized"},
414     {0x0003, "Armed"},
415     {0x0004, "Active"},
416     { 0, NULL}
417 };
418 static const value_string PortPhysicalState[]= {
419     {0x0000, "No State Change"},
420     {0x0001, "Sleep"},
421     {0x0002, "Polling"},
422     {0x0003, "Disabled"},
423     {0x0004, "PortConfigurationTraining"},
424     {0x0005, "LinkUp"},
425     {0x0006, "LinkErrorRecovery"},
426     {0x0007, "Phy Test"},
427     { 0, NULL}
428 };
429 static const value_string LinkDownDefaultState[]= {
430     {0x0000, "No State Change"},
431     {0x0001, "Sleep"},
432     {0x0002, "Polling"},
433     { 0, NULL}
434 };
435 static const value_string LinkSpeedActive[]= {
436     {0x0001, "2.5 Gbps"},
437     {0x0002, "5.0 Gbps"},
438     {0x0004, "10.0 Gbps"},
439     { 0, NULL}
440 };
441 static const value_string LinkSpeedEnabled[]= {
442     {0x0000, "No State Change"},
443     {0x0001, "2.5 Gbps"},
444     {0x0003, "2.5 or 5.0 Gbps"},
445     {0x0005, "2.5 or 10.0 Gbps"},
446     {0x0007, "2.5 or 5.0 or 10.0 Gbps"},
447     {0x000F, "Set to LinkSpeedSupported value - response contains actual LinkSpeedSupported"},
448     { 0, NULL}
449 };
450 static const value_string NeighborMTU[]= {
451     {0x0001, "256"},
452     {0x0002, "512"},
453     {0x0003, "1024"},
454     {0x0004, "2048"},
455     {0x0005, "4096"},
456     { 0, NULL}
457 };
458 static const value_string VLCap[]= {
459     {0x0001, "VL0"},
460     {0x0002, "VL0, VL1"},
461     {0x0003, "VL0 - VL3"},
462     {0x0004, "VL0 - VL7"},
463     {0x0005, "VL0 - VL14"},
464     { 0, NULL}
465 };
466 static const value_string MTUCap[]= {
467     {0x0001, "256"},
468     {0x0002, "512"},
469     {0x0003, "1024"},
470     {0x0004, "2048"},
471     {0x0005, "4096"},
472     { 0, NULL}
473 };
474 static const value_string OperationalVLs[]= {
475     {0x0000, "No State Change"},
476     {0x0001, "VL0"},
477     {0x0002, "VL0, VL1"},
478     {0x0003, "VL0 - VL3"},
479     {0x0004, "VL0 - VL7"},
480     {0x0005, "VL0 - VL14"},
481     { 0, NULL}
482 };
483
484 /* Local Route Header (LRH) */
485 static int hf_infiniband_LRH = -1;
486 static int hf_infiniband_virtual_lane = -1;
487 static int hf_infiniband_link_version = -1;
488 static int hf_infiniband_service_level = -1;
489 static int hf_infiniband_reserved2 = -1;
490 static int hf_infiniband_link_next_header = -1;
491 static int hf_infiniband_destination_local_id = -1;
492 static int hf_infiniband_reserved5 = -1;
493 static int hf_infiniband_packet_length = -1;
494 static int hf_infiniband_source_local_id = -1;
495 /* Global Route Header (GRH) */
496 static int hf_infiniband_GRH = -1;
497 static int hf_infiniband_ip_version = -1;
498 static int hf_infiniband_traffic_class = -1;
499 static int hf_infiniband_flow_label = -1;
500 static int hf_infiniband_payload_length = -1;
501 static int hf_infiniband_next_header = -1;
502 static int hf_infiniband_hop_limit = -1;
503 static int hf_infiniband_source_gid = -1;
504 static int hf_infiniband_destination_gid = -1;
505 /* Base Transport Header (BTH) */
506 static int hf_infiniband_BTH = -1;
507 static int hf_infiniband_opcode = -1;
508 static int hf_infiniband_solicited_event = -1;
509 static int hf_infiniband_migreq = -1;
510 static int hf_infiniband_pad_count = -1;
511 static int hf_infiniband_transport_header_version = -1;
512 static int hf_infiniband_partition_key = -1;
513 static int hf_infiniband_reserved8 = -1;
514 static int hf_infiniband_destination_qp = -1;
515 static int hf_infiniband_acknowledge_request = -1;
516 static int hf_infiniband_reserved7 = -1;
517 static int hf_infiniband_packet_sequence_number = -1;
518 /* Raw Header (RWH) */
519 static int hf_infiniband_RWH = -1;
520 static int hf_infiniband_reserved16_RWH = -1;
521 static int hf_infiniband_etype = -1;
522 /* Reliable Datagram Extended Transport Header (RDETH) */
523 static int hf_infiniband_RDETH = -1;
524 static int hf_infiniband_reserved8_RDETH = -1;
525 static int hf_infiniband_ee_context = -1;
526 /* Datagram Extended Transport Header (DETH) */
527 static int hf_infiniband_DETH = -1;
528 static int hf_infiniband_queue_key = -1;
529 static int hf_infiniband_reserved8_DETH = -1;
530 static int hf_infiniband_source_qp = -1;
531 /* RDMA Extended Transport Header (RETH) */
532 static int hf_infiniband_RETH = -1;
533 static int hf_infiniband_virtual_address = -1;
534 static int hf_infiniband_remote_key = -1;
535 static int hf_infiniband_dma_length = -1;
536 /* Atomic Extended Transport Header (AtomicETH) */
537 static int hf_infiniband_AtomicETH = -1;
538 /* static int hf_infiniband_virtual_address_AtomicETH = -1;                  */
539 /* static int hf_infiniband_remote_key_AtomicETH = -1;                       */
540 static int hf_infiniband_swap_or_add_data = -1;
541 static int hf_infiniband_compare_data = -1;
542 /* ACK Extended Transport Header (AETH) */
543 static int hf_infiniband_AETH = -1;
544 static int hf_infiniband_syndrome = -1;
545 static int hf_infiniband_message_sequence_number = -1;
546 /* Atomic ACK Extended Transport Header (AtomicAckETH) */
547 static int hf_infiniband_AtomicAckETH = -1;
548 static int hf_infiniband_original_remote_data = -1;
549 /* Immediate Extended Transport Header (ImmDt) */
550 static int hf_infiniband_IMMDT = -1;
551 /* Invalidate Extended Transport Header (IETH) */
552 static int hf_infiniband_IETH = -1;
553 /* Payload */
554 static int hf_infiniband_payload = -1;
555 static int hf_infiniband_invariant_crc = -1;
556 static int hf_infiniband_variant_crc = -1;
557 /* Unknown or Vendor Specific */
558 static int hf_infiniband_raw_data = -1;
559 static int hf_infiniband_vendor = -1;
560 /* CM REQ Header */
561 static int hf_cm_req_local_comm_id = -1;
562 static int hf_cm_req_service_id = -1;
563 static int hf_cm_req_local_ca_guid = -1;
564 static int hf_cm_req_local_qkey = -1;
565 static int hf_cm_req_local_qpn = -1;
566 static int hf_cm_req_respo_res = -1;
567 static int hf_cm_req_local_eecn = -1;
568 static int hf_cm_req_init_depth = -1;
569 static int hf_cm_req_remote_eecn = -1;
570 static int hf_cm_req_remote_cm_resp_to = -1;
571 static int hf_cm_req_transp_serv_type = -1;
572 static int hf_cm_req_e2e_flow_ctrl = -1;
573 static int hf_cm_req_start_psn = -1;
574 static int hf_cm_req_local_cm_resp_to = -1;
575 static int hf_cm_req_retry_count = -1;
576 static int hf_cm_req_pkey = -1;
577 static int hf_cm_req_path_pp_mtu = -1;
578 static int hf_cm_req_rdc_exists = -1;
579 static int hf_cm_req_rnr_retry_count = -1;
580 static int hf_cm_req_max_cm_retries = -1;
581 static int hf_cm_req_srq = -1;
582 static int hf_cm_req_primary_local_lid = -1;
583 static int hf_cm_req_primary_remote_lid = -1;
584 static int hf_cm_req_primary_local_gid = -1;
585 static int hf_cm_req_primary_remote_gid = -1;
586 static int hf_cm_req_primary_flow_label = -1;
587 static int hf_cm_req_primary_packet_rate = -1;
588 static int hf_cm_req_primary_traffic_class = -1;
589 static int hf_cm_req_primary_hop_limit = -1;
590 static int hf_cm_req_primary_sl = -1;
591 static int hf_cm_req_primary_subnet_local = -1;
592 static int hf_cm_req_primary_local_ack_to = -1;
593 static int hf_cm_req_alt_local_lid = -1;
594 static int hf_cm_req_alt_remote_lid = -1;
595 static int hf_cm_req_alt_local_gid = -1;
596 static int hf_cm_req_alt_remote_gid = -1;
597 static int hf_cm_req_flow_label = -1;
598 static int hf_cm_req_packet_rate = -1;
599 static int hf_cm_req_alt_traffic_class = -1;
600 static int hf_cm_req_alt_hop_limit = -1;
601 static int hf_cm_req_SL = -1;
602 static int hf_cm_req_subnet_local = -1;
603 static int hf_cm_req_local_ACK_timeout = -1;
604 static int hf_cm_req_private_data = -1;
605 /* CM REP Header */
606 static int hf_cm_rep_localcommid = -1;
607 static int hf_cm_rep_remotecommid = -1;
608 static int hf_cm_rep_localqkey = -1;
609 static int hf_cm_rep_localqpn = -1;
610 static int hf_cm_rep_localeecontnum = -1;
611 static int hf_cm_rep_startingpsn = -1;
612 static int hf_cm_rep_responderres = -1;
613 static int hf_cm_rep_initiatordepth = -1;
614 static int hf_cm_rep_tgtackdelay = -1;
615 static int hf_cm_rep_failoveracc = -1;
616 static int hf_cm_rep_e2eflowctl = -1;
617 static int hf_cm_rep_rnrretrycount = -1;
618 static int hf_cm_rep_srq = -1;
619 static int hf_cm_rep_localcaguid = -1;
620 static int hf_cm_rep_privatedata = -1;
621 /* CM RTU Header */
622 static int hf_cm_rtu_localcommid = -1;
623 static int hf_cm_rtu_remotecommid = -1;
624 static int hf_cm_rtu_privatedata = -1;
625 /* CM REJ Header */
626 static int hf_cm_rej_local_commid = -1;
627 static int hf_cm_rej_remote_commid = -1;
628 static int hf_cm_rej_msg_rej = -1;
629 static int hf_cm_rej_rej_info_len = -1;
630 static int hf_cm_rej_reason = -1;
631 static int hf_cm_rej_add_rej_info = -1;
632 static int hf_cm_rej_private_data = -1;
633 /* MAD Base Header */
634 static int hf_infiniband_MAD = -1;
635 static int hf_infiniband_base_version = -1;
636 static int hf_infiniband_mgmt_class = -1;
637 static int hf_infiniband_class_version = -1;
638 /* static int hf_infiniband_reserved1 = -1;                                  */
639 static int hf_infiniband_method = -1;
640 static int hf_infiniband_status = -1;
641 static int hf_infiniband_class_specific = -1;
642 static int hf_infiniband_transaction_id = -1;
643 static int hf_infiniband_attribute_id = -1;
644 static int hf_infiniband_reserved16 = -1;
645 static int hf_infiniband_attribute_modifier = -1;
646 static int hf_infiniband_data = -1;
647 /* RMPP Header */
648 static int hf_infiniband_RMPP = -1;
649 static int hf_infiniband_rmpp_version = -1;
650 static int hf_infiniband_rmpp_type = -1;
651 static int hf_infiniband_r_resp_time = -1;
652 static int hf_infiniband_rmpp_flags = -1;
653 static int hf_infiniband_rmpp_status = -1;
654 static int hf_infiniband_rmpp_data1 = -1;
655 static int hf_infiniband_rmpp_data2 = -1;
656 /* RMPP Data */
657 /* static int hf_infiniband_RMPP_DATA = -1;                                  */
658 static int hf_infiniband_segment_number = -1;
659 static int hf_infiniband_payload_length32 = -1;
660 static int hf_infiniband_transferred_data = -1;
661 /* RMPP ACK */
662 static int hf_infiniband_new_window_last = -1;
663 static int hf_infiniband_reserved220 = -1;
664 /* RMPP ABORT and STOP */
665 static int hf_infiniband_reserved32 = -1;
666 static int hf_infiniband_optional_extended_error_data = -1;
667 /* SMP Data LID Routed */
668 static int hf_infiniband_SMP_LID = -1;
669 static int hf_infiniband_m_key = -1;
670 static int hf_infiniband_smp_data = -1;
671 static int hf_infiniband_reserved1024 = -1;
672 static int hf_infiniband_reserved256 = -1;
673 /* SMP Data Directed Route */
674 static int hf_infiniband_SMP_DIRECTED = -1;
675 static int hf_infiniband_smp_status = -1;
676 static int hf_infiniband_hop_pointer = -1;
677 static int hf_infiniband_hop_count = -1;
678 static int hf_infiniband_dr_slid = -1;
679 static int hf_infiniband_dr_dlid = -1;
680 static int hf_infiniband_reserved28 = -1;
681 static int hf_infiniband_d = -1;
682 static int hf_infiniband_initial_path = -1;
683 static int hf_infiniband_return_path = -1;
684 /* SA MAD Header */
685 static int hf_infiniband_SA = -1;
686 static int hf_infiniband_sm_key = -1;
687 static int hf_infiniband_attribute_offset = -1;
688 static int hf_infiniband_component_mask = -1;
689 static int hf_infiniband_subnet_admin_data = -1;
690 /* Mellanox EoIB encapsulation header */
691 static int hf_infiniband_EOIB = -1;
692 static int hf_infiniband_ver = -1;
693 static int hf_infiniband_tcp_chk = -1;
694 static int hf_infiniband_ip_chk = -1;
695 static int hf_infiniband_fcs = -1;
696 static int hf_infiniband_ms = -1;
697 static int hf_infiniband_seg_off = -1;
698 static int hf_infiniband_seg_id = -1;
699
700 /* Attributes
701 * Additional Structures for individuala attribute decoding.
702 * Since they are not headers the naming convention is slightly modified
703 * Convention: hf_infiniband_[attribute name]_[field]
704 * This was not entirely necessary but I felt the previous convention
705 * did not provide adequate readability for the granularity of attribute/attribute fields. */
706
707 /* NodeDescription */
708 static int hf_infiniband_NodeDescription_NodeString = -1;
709 /* NodeInfo */
710 static int hf_infiniband_NodeInfo_BaseVersion = -1;
711 static int hf_infiniband_NodeInfo_ClassVersion = -1;
712 static int hf_infiniband_NodeInfo_NodeType = -1;
713 static int hf_infiniband_NodeInfo_NumPorts = -1;
714 static int hf_infiniband_NodeInfo_SystemImageGUID = -1;
715 static int hf_infiniband_NodeInfo_NodeGUID = -1;
716 static int hf_infiniband_NodeInfo_PortGUID = -1;
717 static int hf_infiniband_NodeInfo_PartitionCap = -1;
718 static int hf_infiniband_NodeInfo_DeviceID = -1;
719 static int hf_infiniband_NodeInfo_Revision = -1;
720 static int hf_infiniband_NodeInfo_LocalPortNum = -1;
721 static int hf_infiniband_NodeInfo_VendorID = -1;
722 /* SwitchInfo */
723 static int hf_infiniband_SwitchInfo_LinearFDBCap = -1;
724 static int hf_infiniband_SwitchInfo_RandomFDBCap = -1;
725 static int hf_infiniband_SwitchInfo_MulticastFDBCap = -1;
726 static int hf_infiniband_SwitchInfo_LinearFDBTop = -1;
727 static int hf_infiniband_SwitchInfo_DefaultPort = -1;
728 static int hf_infiniband_SwitchInfo_DefaultMulticastPrimaryPort = -1;
729 static int hf_infiniband_SwitchInfo_DefaultMulticastNotPrimaryPort = -1;
730 static int hf_infiniband_SwitchInfo_LifeTimeValue = -1;
731 static int hf_infiniband_SwitchInfo_PortStateChange = -1;
732 static int hf_infiniband_SwitchInfo_OptimizedSLtoVLMappingProgramming = -1;
733 static int hf_infiniband_SwitchInfo_LIDsPerPort = -1;
734 static int hf_infiniband_SwitchInfo_PartitionEnforcementCap = -1;
735 static int hf_infiniband_SwitchInfo_InboundEnforcementCap = -1;
736 static int hf_infiniband_SwitchInfo_OutboundEnforcementCap = -1;
737 static int hf_infiniband_SwitchInfo_FilterRawInboundCap = -1;
738 static int hf_infiniband_SwitchInfo_FilterRawOutboundCap = -1;
739 static int hf_infiniband_SwitchInfo_EnhancedPortZero = -1;
740 /* GUIDInfo */
741 /* static int hf_infiniband_GUIDInfo_GUIDBlock = -1;                         */
742 static int hf_infiniband_GUIDInfo_GUID = -1;
743 /* PortInfo */
744 static int hf_infiniband_PortInfo_GidPrefix = -1;
745 static int hf_infiniband_PortInfo_LID = -1;
746 static int hf_infiniband_PortInfo_MasterSMLID = -1;
747 static int hf_infiniband_PortInfo_CapabilityMask = -1;
748
749 /* Capability Mask Flags */
750 static int hf_infiniband_PortInfo_CapabilityMask_SM = -1;
751 static int hf_infiniband_PortInfo_CapabilityMask_NoticeSupported = -1;
752 static int hf_infiniband_PortInfo_CapabilityMask_TrapSupported = -1;
753 static int hf_infiniband_PortInfo_CapabilityMask_OptionalPDSupported = -1;
754 static int hf_infiniband_PortInfo_CapabilityMask_AutomaticMigrationSupported = -1;
755 static int hf_infiniband_PortInfo_CapabilityMask_SLMappingSupported = -1;
756 static int hf_infiniband_PortInfo_CapabilityMask_MKeyNVRAM = -1;
757 static int hf_infiniband_PortInfo_CapabilityMask_PKeyNVRAM = -1;
758 static int hf_infiniband_PortInfo_CapabilityMask_LEDInfoSupported = -1;
759 static int hf_infiniband_PortInfo_CapabilityMask_SMdisabled = -1;
760 static int hf_infiniband_PortInfo_CapabilityMask_SystemImageGUIDSupported = -1;
761 static int hf_infiniband_PortInfo_CapabilityMask_PKeySwitchExternalPortTrapSupported = -1;
762 static int hf_infiniband_PortInfo_CapabilityMask_CommunicationsManagementSupported = -1;
763 static int hf_infiniband_PortInfo_CapabilityMask_SNMPTunnelingSupported = -1;
764 static int hf_infiniband_PortInfo_CapabilityMask_ReinitSupported = -1;
765 static int hf_infiniband_PortInfo_CapabilityMask_DeviceManagementSupported = -1;
766 static int hf_infiniband_PortInfo_CapabilityMask_VendorClassSupported = -1;
767 static int hf_infiniband_PortInfo_CapabilityMask_DRNoticeSupported = -1;
768 static int hf_infiniband_PortInfo_CapabilityMask_CapabilityMaskNoticeSupported = -1;
769 static int hf_infiniband_PortInfo_CapabilityMask_BootManagementSupported = -1;
770 static int hf_infiniband_PortInfo_CapabilityMask_LinkRoundTripLatencySupported = -1;
771 static int hf_infiniband_PortInfo_CapabilityMask_ClientRegistrationSupported = -1;
772 static int hf_infiniband_PortInfo_CapabilityMask_OtherLocalChangesNoticeSupported = -1;
773 static int hf_infiniband_PortInfo_CapabilityMask_LinkSpeedWIdthPairsTableSupported = -1;
774 /* End Capability Mask Flags */
775
776
777 static int hf_infiniband_PortInfo_DiagCode = -1;
778 static int hf_infiniband_PortInfo_M_KeyLeasePeriod = -1;
779 static int hf_infiniband_PortInfo_LocalPortNum = -1;
780 static int hf_infiniband_PortInfo_LinkWidthEnabled = -1;
781 static int hf_infiniband_PortInfo_LinkWidthSupported = -1;
782 static int hf_infiniband_PortInfo_LinkWidthActive = -1;
783 static int hf_infiniband_PortInfo_LinkSpeedSupported = -1;
784 static int hf_infiniband_PortInfo_PortState = -1;
785 static int hf_infiniband_PortInfo_PortPhysicalState = -1;
786 static int hf_infiniband_PortInfo_LinkDownDefaultState = -1;
787 static int hf_infiniband_PortInfo_M_KeyProtectBits = -1;
788 static int hf_infiniband_PortInfo_LMC = -1;
789 static int hf_infiniband_PortInfo_LinkSpeedActive = -1;
790 static int hf_infiniband_PortInfo_LinkSpeedEnabled = -1;
791 static int hf_infiniband_PortInfo_NeighborMTU = -1;
792 static int hf_infiniband_PortInfo_MasterSMSL = -1;
793 static int hf_infiniband_PortInfo_VLCap = -1;
794 static int hf_infiniband_PortInfo_M_Key = -1;
795 static int hf_infiniband_PortInfo_InitType = -1;
796 static int hf_infiniband_PortInfo_VLHighLimit = -1;
797 static int hf_infiniband_PortInfo_VLArbitrationHighCap = -1;
798 static int hf_infiniband_PortInfo_VLArbitrationLowCap = -1;
799 static int hf_infiniband_PortInfo_InitTypeReply = -1;
800 static int hf_infiniband_PortInfo_MTUCap = -1;
801 static int hf_infiniband_PortInfo_VLStallCount = -1;
802 static int hf_infiniband_PortInfo_HOQLife = -1;
803 static int hf_infiniband_PortInfo_OperationalVLs = -1;
804 static int hf_infiniband_PortInfo_PartitionEnforcementInbound = -1;
805 static int hf_infiniband_PortInfo_PartitionEnforcementOutbound = -1;
806 static int hf_infiniband_PortInfo_FilterRawInbound = -1;
807 static int hf_infiniband_PortInfo_FilterRawOutbound = -1;
808 static int hf_infiniband_PortInfo_M_KeyViolations = -1;
809 static int hf_infiniband_PortInfo_P_KeyViolations = -1;
810 static int hf_infiniband_PortInfo_Q_KeyViolations = -1;
811 static int hf_infiniband_PortInfo_GUIDCap = -1;
812 static int hf_infiniband_PortInfo_ClientReregister = -1;
813 static int hf_infiniband_PortInfo_SubnetTimeOut = -1;
814 static int hf_infiniband_PortInfo_RespTimeValue = -1;
815 static int hf_infiniband_PortInfo_LocalPhyErrors = -1;
816 static int hf_infiniband_PortInfo_OverrunErrors = -1;
817 static int hf_infiniband_PortInfo_MaxCreditHint = -1;
818 static int hf_infiniband_PortInfo_LinkRoundTripLatency = -1;
819
820 /* P_KeyTable */
821 static int hf_infiniband_P_KeyTable_P_KeyTableBlock = -1;
822 static int hf_infiniband_P_KeyTable_MembershipType = -1;
823 static int hf_infiniband_P_KeyTable_P_KeyBase = -1;
824
825 /* SLtoVLMappingTable */
826 static int hf_infiniband_SLtoVLMappingTable_SLtoVL_HighBits = -1;
827 static int hf_infiniband_SLtoVLMappingTable_SLtoVL_LowBits = -1;
828
829 /* VLArbitrationTable */
830 /* static int hf_infiniband_VLArbitrationTable_VLWeightPairs = -1;           */
831 static int hf_infiniband_VLArbitrationTable_VL = -1;
832 static int hf_infiniband_VLArbitrationTable_Weight = -1;
833
834 /* LinearForwardingTable */
835 /* static int hf_infiniband_LinearForwardingTable_LinearForwardingTableBlock = -1;  */
836 static int hf_infiniband_LinearForwardingTable_Port = -1;
837
838 /* RandomForwardingTable */
839 /* static int hf_infiniband_RandomForwardingTable_RandomForwardingTableBlock = -1;  */
840 static int hf_infiniband_RandomForwardingTable_LID = -1;
841 static int hf_infiniband_RandomForwardingTable_Valid = -1;
842 static int hf_infiniband_RandomForwardingTable_LMC = -1;
843 static int hf_infiniband_RandomForwardingTable_Port = -1;
844
845 /* MulticastForwardingTable */
846 /* static int hf_infiniband_MulticastForwardingTable_MulticastForwardingTableBlock = -1;    */
847 static int hf_infiniband_MulticastForwardingTable_PortMask = -1;
848
849 /* SMInfo */
850 static int hf_infiniband_SMInfo_GUID = -1;
851 static int hf_infiniband_SMInfo_SM_Key = -1;
852 static int hf_infiniband_SMInfo_ActCount = -1;
853 static int hf_infiniband_SMInfo_Priority = -1;
854 static int hf_infiniband_SMInfo_SMState = -1;
855
856 /* VendorDiag */
857 static int hf_infiniband_VendorDiag_NextIndex = -1;
858 static int hf_infiniband_VendorDiag_DiagData = -1;
859
860 /* LedInfo */
861 static int hf_infiniband_LedInfo_LedMask = -1;
862
863 /* LinkSpeedWidthPairsTable */
864 static int hf_infiniband_LinkSpeedWidthPairsTable_NumTables = -1;
865 static int hf_infiniband_LinkSpeedWidthPairsTable_PortMask = -1;
866 static int hf_infiniband_LinkSpeedWidthPairsTable_SpeedTwoFive = -1;
867 static int hf_infiniband_LinkSpeedWidthPairsTable_SpeedFive = -1;
868 static int hf_infiniband_LinkSpeedWidthPairsTable_SpeedTen = -1;
869
870 /* Attributes for Subnet Administration.
871 * Mostly we have "Records" here which are just structures of SM attributes.
872 * There are some unique attributes though that we will want to have a structure for. */
873
874 /* NodeRecord */
875 /* PortInfoRecord */
876 /* SLtoVLMappingTableRecord */
877 /* SwitchInfoRecord */
878 /* LinearForwardingTableRecord */
879 /* RandomForwardingTableRecord */
880 /* MulticastForwardingTableRecord */
881 /* VLArbitrationTableRecord */
882
883 static int hf_infiniband_SA_LID = -1;
884 static int hf_infiniband_SA_EndportLID = -1;
885 static int hf_infiniband_SA_PortNum = -1;
886 static int hf_infiniband_SA_InputPortNum = -1;
887 static int hf_infiniband_SA_OutputPortNum = -1;
888 static int hf_infiniband_SA_BlockNum_EightBit = -1;
889 static int hf_infiniband_SA_BlockNum_NineBit = -1;
890 static int hf_infiniband_SA_BlockNum_SixteenBit = -1;
891 static int hf_infiniband_SA_Position = -1;
892 /* static int hf_infiniband_SA_Index = -1;                                   */
893
894 /* InformInfoRecord */
895 static int hf_infiniband_InformInfoRecord_SubscriberGID = -1;
896 static int hf_infiniband_InformInfoRecord_Enum = -1;
897
898 /* InformInfo */
899 static int hf_infiniband_InformInfo_GID = -1;
900 static int hf_infiniband_InformInfo_LIDRangeBegin = -1;
901 static int hf_infiniband_InformInfo_LIDRangeEnd = -1;
902 static int hf_infiniband_InformInfo_IsGeneric = -1;
903 static int hf_infiniband_InformInfo_Subscribe = -1;
904 static int hf_infiniband_InformInfo_Type = -1;
905 static int hf_infiniband_InformInfo_TrapNumberDeviceID = -1;
906 static int hf_infiniband_InformInfo_QPN = -1;
907 static int hf_infiniband_InformInfo_RespTimeValue = -1;
908 static int hf_infiniband_InformInfo_ProducerTypeVendorID = -1;
909
910 /* LinkRecord */
911 static int hf_infiniband_LinkRecord_FromLID = -1;
912 static int hf_infiniband_LinkRecord_FromPort = -1;
913 static int hf_infiniband_LinkRecord_ToPort = -1;
914 static int hf_infiniband_LinkRecord_ToLID = -1;
915
916 /* ServiceRecord */
917 static int hf_infiniband_ServiceRecord_ServiceID = -1;
918 static int hf_infiniband_ServiceRecord_ServiceGID = -1;
919 static int hf_infiniband_ServiceRecord_ServiceP_Key = -1;
920 static int hf_infiniband_ServiceRecord_ServiceLease = -1;
921 static int hf_infiniband_ServiceRecord_ServiceKey = -1;
922 static int hf_infiniband_ServiceRecord_ServiceName = -1;
923 static int hf_infiniband_ServiceRecord_ServiceData = -1;
924
925 /* ServiceAssociationRecord */
926 static int hf_infiniband_ServiceAssociationRecord_ServiceKey = -1;
927 static int hf_infiniband_ServiceAssociationRecord_ServiceName = -1;
928
929 /* PathRecord */
930 static int hf_infiniband_PathRecord_DGID = -1;
931 static int hf_infiniband_PathRecord_SGID = -1;
932 static int hf_infiniband_PathRecord_DLID = -1;
933 static int hf_infiniband_PathRecord_SLID = -1;
934 static int hf_infiniband_PathRecord_RawTraffic = -1;
935 static int hf_infiniband_PathRecord_FlowLabel = -1;
936 static int hf_infiniband_PathRecord_HopLimit = -1;
937 static int hf_infiniband_PathRecord_TClass = -1;
938 static int hf_infiniband_PathRecord_Reversible = -1;
939 static int hf_infiniband_PathRecord_NumbPath = -1;
940 static int hf_infiniband_PathRecord_P_Key = -1;
941 static int hf_infiniband_PathRecord_SL = -1;
942 static int hf_infiniband_PathRecord_MTUSelector = -1;
943 static int hf_infiniband_PathRecord_MTU = -1;
944 static int hf_infiniband_PathRecord_RateSelector = -1;
945 static int hf_infiniband_PathRecord_Rate = -1;
946 static int hf_infiniband_PathRecord_PacketLifeTimeSelector = -1;
947 static int hf_infiniband_PathRecord_PacketLifeTime = -1;
948 static int hf_infiniband_PathRecord_Preference = -1;
949
950 /* MCMemberRecord */
951 static int hf_infiniband_MCMemberRecord_MGID = -1;
952 static int hf_infiniband_MCMemberRecord_PortGID = -1;
953 static int hf_infiniband_MCMemberRecord_Q_Key = -1;
954 static int hf_infiniband_MCMemberRecord_MLID = -1;
955 static int hf_infiniband_MCMemberRecord_MTUSelector = -1;
956 static int hf_infiniband_MCMemberRecord_MTU = -1;
957 static int hf_infiniband_MCMemberRecord_TClass = -1;
958 static int hf_infiniband_MCMemberRecord_P_Key = -1;
959 static int hf_infiniband_MCMemberRecord_RateSelector = -1;
960 static int hf_infiniband_MCMemberRecord_Rate = -1;
961 static int hf_infiniband_MCMemberRecord_PacketLifeTimeSelector = -1;
962 static int hf_infiniband_MCMemberRecord_PacketLifeTime = -1;
963 static int hf_infiniband_MCMemberRecord_SL = -1;
964 static int hf_infiniband_MCMemberRecord_FlowLabel = -1;
965 static int hf_infiniband_MCMemberRecord_HopLimit = -1;
966 static int hf_infiniband_MCMemberRecord_Scope = -1;
967 static int hf_infiniband_MCMemberRecord_JoinState = -1;
968 static int hf_infiniband_MCMemberRecord_ProxyJoin = -1;
969
970 /* TraceRecord */
971 static int hf_infiniband_TraceRecord_GIDPrefix = -1;
972 static int hf_infiniband_TraceRecord_IDGeneration = -1;
973 static int hf_infiniband_TraceRecord_NodeType = -1;
974 static int hf_infiniband_TraceRecord_NodeID = -1;
975 static int hf_infiniband_TraceRecord_ChassisID = -1;
976 static int hf_infiniband_TraceRecord_EntryPortID = -1;
977 static int hf_infiniband_TraceRecord_ExitPortID = -1;
978 static int hf_infiniband_TraceRecord_EntryPort = -1;
979 static int hf_infiniband_TraceRecord_ExitPort = -1;
980
981 /* MultiPathRecord */
982 static int hf_infiniband_MultiPathRecord_RawTraffic = -1;
983 static int hf_infiniband_MultiPathRecord_FlowLabel = -1;
984 static int hf_infiniband_MultiPathRecord_HopLimit = -1;
985 static int hf_infiniband_MultiPathRecord_TClass = -1;
986 static int hf_infiniband_MultiPathRecord_Reversible = -1;
987 static int hf_infiniband_MultiPathRecord_NumbPath = -1;
988 static int hf_infiniband_MultiPathRecord_P_Key = -1;
989 static int hf_infiniband_MultiPathRecord_SL = -1;
990 static int hf_infiniband_MultiPathRecord_MTUSelector = -1;
991 static int hf_infiniband_MultiPathRecord_MTU = -1;
992 static int hf_infiniband_MultiPathRecord_RateSelector = -1;
993 static int hf_infiniband_MultiPathRecord_Rate = -1;
994 static int hf_infiniband_MultiPathRecord_PacketLifeTimeSelector = -1;
995 static int hf_infiniband_MultiPathRecord_PacketLifeTime = -1;
996 static int hf_infiniband_MultiPathRecord_IndependenceSelector = -1;
997 static int hf_infiniband_MultiPathRecord_GIDScope = -1;
998 static int hf_infiniband_MultiPathRecord_SGIDCount = -1;
999 static int hf_infiniband_MultiPathRecord_DGIDCount = -1;
1000 static int hf_infiniband_MultiPathRecord_SDGID = -1;
1001
1002 /* Notice */
1003 static int hf_infiniband_Notice_IsGeneric = -1;
1004 static int hf_infiniband_Notice_Type = -1;
1005 static int hf_infiniband_Notice_ProducerTypeVendorID = -1;
1006 static int hf_infiniband_Notice_TrapNumberDeviceID = -1;
1007 static int hf_infiniband_Notice_IssuerLID = -1;
1008 static int hf_infiniband_Notice_NoticeToggle = -1;
1009 static int hf_infiniband_Notice_NoticeCount = -1;
1010 static int hf_infiniband_Notice_DataDetails = -1;
1011 /* static int hf_infiniband_Notice_IssuerGID = -1;             */
1012 /* static int hf_infiniband_Notice_ClassTrapSpecificData = -1; */
1013
1014 /* PortCounters attribute in Performance class */
1015 static int hf_infiniband_PortCounters = -1;
1016 static int hf_infiniband_PortCounters_PortSelect = -1;
1017 static int hf_infiniband_PortCounters_CounterSelect = -1;
1018 static int hf_infiniband_PortCounters_SymbolErrorCounter = -1;
1019 static int hf_infiniband_PortCounters_LinkErrorRecoveryCounter = -1;
1020 static int hf_infiniband_PortCounters_LinkDownedCounter = -1;
1021 static int hf_infiniband_PortCounters_PortRcvErrors = -1;
1022 static int hf_infiniband_PortCounters_PortRcvRemotePhysicalErrors = -1;
1023 static int hf_infiniband_PortCounters_PortRcvSwitchRelayErrors = -1;
1024 static int hf_infiniband_PortCounters_PortXmitDiscards = -1;
1025 static int hf_infiniband_PortCounters_PortXmitConstraintErrors = -1;
1026 static int hf_infiniband_PortCounters_PortRcvConstraintErrors = -1;
1027 static int hf_infiniband_PortCounters_LocalLinkIntegrityErrors = -1;
1028 static int hf_infiniband_PortCounters_ExcessiveBufferOverrunErrors = -1;
1029 static int hf_infiniband_PortCounters_VL15Dropped = -1;
1030 static int hf_infiniband_PortCounters_PortXmitData = -1;
1031 static int hf_infiniband_PortCounters_PortRcvData = -1;
1032 static int hf_infiniband_PortCounters_PortXmitPkts = -1;
1033 static int hf_infiniband_PortCounters_PortRcvPkts = -1;
1034
1035 /* Extended PortCounters attribute in Performance class */
1036 static int hf_infiniband_PortCountersExt = -1;
1037 static int hf_infiniband_PortCountersExt_PortSelect = -1;
1038 static int hf_infiniband_PortCountersExt_CounterSelect = -1;
1039 static int hf_infiniband_PortCountersExt_PortXmitData = -1;
1040 static int hf_infiniband_PortCountersExt_PortRcvData = -1;
1041 static int hf_infiniband_PortCountersExt_PortXmitPkts = -1;
1042 static int hf_infiniband_PortCountersExt_PortRcvPkts = -1;
1043 static int hf_infiniband_PortCountersExt_PortUnicastXmitPkts = -1;
1044 static int hf_infiniband_PortCountersExt_PortUnicastRcvPkts = -1;
1045 static int hf_infiniband_PortCountersExt_PortMulticastXmitPkts = -1;
1046 static int hf_infiniband_PortCountersExt_PortMulticastRcvPkts = -1;
1047
1048 /* Notice DataDetails and ClassTrapSpecific Data for certain traps
1049 * Note that traps reuse many fields, so they are only declared once under the first trap that they appear.
1050 * There is no need to redeclare them for specific Traps (as with other SA Attributes) because they are uniform between Traps. */
1051
1052 /* Parse DataDetails for a given Trap */
1053 static gint parse_NoticeDataDetails(proto_tree*, tvbuff_t*, gint *offset, guint16 trapNumber);
1054
1055 /* Traps 64,65,66,67 */
1056 static int hf_infiniband_Trap_GIDADDR = -1;
1057
1058 /* Traps 68,69 */
1059 /* DataDetails */
1060 static int hf_infiniband_Trap_COMP_MASK = -1;
1061 static int hf_infiniband_Trap_WAIT_FOR_REPATH = -1;
1062 /* ClassTrapSpecificData */
1063 /* static int hf_infiniband_Trap_PATH_REC = -1;                              */
1064
1065 /* Trap 128 */
1066 static int hf_infiniband_Trap_LIDADDR = -1;
1067
1068 /* Trap 129, 130, 131 */
1069 static int hf_infiniband_Trap_PORTNO = -1;
1070
1071 /* Trap 144 */
1072 static int hf_infiniband_Trap_OtherLocalChanges = -1;
1073 static int hf_infiniband_Trap_CAPABILITYMASK = -1;
1074 static int hf_infiniband_Trap_LinkSpeecEnabledChange = -1;
1075 static int hf_infiniband_Trap_LinkWidthEnabledChange = -1;
1076 static int hf_infiniband_Trap_NodeDescriptionChange = -1;
1077
1078 /* Trap 145 */
1079 static int hf_infiniband_Trap_SYSTEMIMAGEGUID = -1;
1080
1081 /* Trap 256 */
1082 static int hf_infiniband_Trap_DRSLID = -1;
1083 static int hf_infiniband_Trap_METHOD = -1;
1084 static int hf_infiniband_Trap_ATTRIBUTEID = -1;
1085 static int hf_infiniband_Trap_ATTRIBUTEMODIFIER = -1;
1086 static int hf_infiniband_Trap_MKEY = -1;
1087 static int hf_infiniband_Trap_DRNotice = -1;
1088 static int hf_infiniband_Trap_DRPathTruncated = -1;
1089 static int hf_infiniband_Trap_DRHopCount = -1;
1090 static int hf_infiniband_Trap_DRNoticeReturnPath = -1;
1091
1092 /* Trap 257, 258 */
1093 static int hf_infiniband_Trap_LIDADDR1 = -1;
1094 static int hf_infiniband_Trap_LIDADDR2 = -1;
1095 static int hf_infiniband_Trap_KEY = -1;
1096 static int hf_infiniband_Trap_SL = -1;
1097 static int hf_infiniband_Trap_QP1 = -1;
1098 static int hf_infiniband_Trap_QP2 = -1;
1099 static int hf_infiniband_Trap_GIDADDR1 = -1;
1100 static int hf_infiniband_Trap_GIDADDR2 = -1;
1101
1102 /* Trap 259 */
1103 static int hf_infiniband_Trap_DataValid = -1;
1104 static int hf_infiniband_Trap_PKEY = -1;
1105 static int hf_infiniband_Trap_SWLIDADDR = -1;
1106
1107 /* Infiniband Link */
1108 static int hf_infiniband_link_op = -1;
1109 static int hf_infiniband_link_fctbs = -1;
1110 static int hf_infiniband_link_vl = -1;
1111 static int hf_infiniband_link_fccl = -1;
1112 static int hf_infiniband_link_lpcrc = -1;
1113
1114 /* Trap Type/Descriptions for dissection */
1115 static const value_string Operand_Description[]= {
1116     { 0, " Normal Flow Control"},
1117     { 1, " Flow Control Init"},
1118     { 0, NULL}
1119 };
1120
1121 /* Trap Type/Descriptions for dissection */
1122 static const value_string Trap_Description[]= {
1123     { 64, " (Informational) <GIDADDR> is now in service"},
1124     { 65, " (Informational) <GIDADDR> is out of service"},
1125     { 66, " (Informational) New Multicast Group with multicast address <GIDADDR> is now created"},
1126     { 67, " (Informational) Multicast Group with multicast address <GIDADDR> is now deleted"},
1127     { 68, " (Informational) Paths indicated by <PATH_REC> and <COMP_MASK> are no longer valid"},
1128     { 69, " (Informational) Paths indicated by <PATH_REC> and <COMP_MASK> have been recomputed"},
1129     { 128, " (Urgent) Link State of at least one port of switch at <LIDADDR> has changed"},
1130     { 129, " (Urgent) Local Link Integrity threshold reached at <LIDADDR><PORTNO>"},
1131     { 130, " (Urgent) Excessive Buffer OVerrun threshold reached at <LIDADDR><PORTNO>"},
1132     { 131, " (Urgent) Flow Control Update watchdog timer expired at <LIDADDR><PORTNO>"},
1133     { 144, " (Informational) CapMask, NodeDesc, LinkWidthEnabled or LinkSpeedEnabled at <LIDADDR> has been modified"},
1134     { 145, " (Informational) SystemImageGUID at <LIDADDR> has been modified.  New value is <SYSTEMIMAGEGUID>"},
1135     { 256, " (Security) Bad M_Key, <M_KEY> from <LIDADDR> attempted <METHOD> with <ATTRIBUTEID> and <ATTRIBUTEMODIFIER>"},
1136     { 257, " (Security) Bad P_Key, <KEY> from <LIDADDR1><GIDADDR1><QP1> to <LIDADDR2><GIDADDR2><QP2> on <SL>"},
1137     { 258, " (Security) Bad Q_Key, <KEY> from <LIDADDR1><GIDADDR1><QP1> to <LIDADDR2><GIDADDR2><QP2> on <SL>"},
1138     { 259, " (Security) Bad P_Key, <KEY> from <LIDADDR1><GIDADDR1><QP1> to <LIDADDR2><GIDADDR2><QP2> on <SL> at switch <LIDADDR><PORTNO>"},
1139     { 0, NULL}
1140 };
1141
1142
1143
1144
1145 /* MAD Management Classes
1146 * Classes from the Common MAD Header
1147 *
1148 *      Management Class Name        Class Description
1149 * ------------------------------------------------------------------------------------------------------------ */
1150 #define SUBN_LID_ROUTED 0x01        /* Subnet Management LID Route */
1151 #define SUBN_DIRECTED_ROUTE 0x81    /* Subnet Management Directed Route */
1152 #define SUBNADMN 0x03               /* Subnet Administration */
1153 #define PERF 0x04                   /* Performance Management */
1154 #define BM 0x05                     /* Baseboard Management (Tunneling of IB-ML commands through the IBA subnet) */
1155 #define DEV_MGT 0x06                /* Device Management */
1156 #define COM_MGT 0x07                /* Communications Management */
1157 #define SNMP 0x08                   /* SNMP Tunneling (tunneling of the SNMP protocol through the IBA fabric) */
1158 #define VENDOR_1_START 0x09         /* Start of first Vendor Specific Range */
1159 #define VENDOR_1_END 0x0F           /* End of first Vendor Specific Range */
1160 #define VENDOR_2_START 0x30         /* Start of second Vendor Specific Range */
1161 #define VENDOR_2_END 0x4F           /* End of the second Vendor Specific Range */
1162 #define APPLICATION_START 0x10      /* Start of Application Specific Range */
1163 #define APPLICATION_END 0x2F        /* End of Application Specific Range */
1164
1165 /* Performance class Attributes */
1166 #define ATTR_PORT_COUNTERS      0x0012
1167 #define ATTR_PORT_COUNTERS_EXT  0x001D
1168
1169 /* ComMgt class Attributes*/
1170 #define ATTR_CM_REQ             0x0010
1171 #define ATTR_CM_REP             0x0013
1172 #define ATTR_CM_RTU             0x0014
1173 #define ATTR_CM_REJ             0x0012
1174
1175 /* Link Next Header Values */
1176 #define IBA_GLOBAL 3
1177 #define IBA_LOCAL  2
1178 #define IP_NON_IBA 1
1179 #define RAW        0
1180
1181 static const value_string OpCodeMap[] =
1182 {
1183     { RC_SEND_FIRST,                "RC Send First " },
1184     { RC_SEND_MIDDLE,               "RC Send Middle "},
1185     { RC_SEND_LAST,                 "RC Send Last " },
1186     { RC_SEND_LAST_IMM,             "RC Send Last Immediate "},
1187     { RC_SEND_ONLY,                 "RC Send Only "},
1188     { RC_SEND_ONLY_IMM,             "RC Send Only Immediate "},
1189     { RC_RDMA_WRITE_FIRST,          "RC RDMA Write First " },
1190     { RC_RDMA_WRITE_MIDDLE,         "RC RDMA Write Middle "},
1191     { RC_RDMA_WRITE_LAST,           "RC RDMA Write Last "},
1192     { RC_RDMA_WRITE_LAST_IMM,       "RC RDMA Write Last Immediate " },
1193     { RC_RDMA_WRITE_ONLY,           "RC RDMA Write Only " },
1194     { RC_RDMA_WRITE_ONLY_IMM,       "RC RDMA Write Only Immediate "},
1195     { RC_RDMA_READ_REQUEST,         "RC RDMA Read Request " },
1196     { RC_RDMA_READ_RESPONSE_FIRST,  "RC RDMA Read Response First " },
1197     { RC_RDMA_READ_RESPONSE_MIDDLE, "RC RDMA Read Response Middle "},
1198     { RC_RDMA_READ_RESPONSE_LAST,   "RC RDMA Read Response Last " },
1199     { RC_RDMA_READ_RESPONSE_ONLY,   "RC RDMA Read Response Only "},
1200     { RC_ACKNOWLEDGE,               "RC Acknowledge " },
1201     { RC_ATOMIC_ACKNOWLEDGE,        "RC Atomic Acknowledge " },
1202     { RC_CMP_SWAP,                  "RC Compare Swap " },
1203     { RC_FETCH_ADD,                 "RC Fetch Add "},
1204     { RC_SEND_LAST_INVAL,           "RC Send Last Invalidate "},
1205     { RC_SEND_ONLY_INVAL,           "RC Send Only Invalidate " },
1206
1207
1208     { RD_SEND_FIRST,                "RD Send First "},
1209     { RD_SEND_MIDDLE,               "RD Send Middle " },
1210     { RD_SEND_LAST,                 "RD Send Last "},
1211     { RD_SEND_LAST_IMM,             "RD Last Immediate " },
1212     { RD_SEND_ONLY,                 "RD Send Only "},
1213     { RD_SEND_ONLY_IMM,             "RD Send Only Immediate "},
1214     { RD_RDMA_WRITE_FIRST,          "RD RDMA Write First "},
1215     { RD_RDMA_WRITE_MIDDLE,         "RD RDMA Write Middle "},
1216     { RD_RDMA_WRITE_LAST,           "RD RDMA Write Last "},
1217     { RD_RDMA_WRITE_LAST_IMM,       "RD RDMA Write Last Immediate "},
1218     { RD_RDMA_WRITE_ONLY,           "RD RDMA Write Only "},
1219     { RD_RDMA_WRITE_ONLY_IMM,       "RD RDMA Write Only Immediate "},
1220     { RD_RDMA_READ_REQUEST,         "RD RDMA Read Request "},
1221     { RD_RDMA_READ_RESPONSE_FIRST,  "RD RDMA Read Response First "},
1222     { RD_RDMA_READ_RESPONSE_MIDDLE, "RD RDMA Read Response Middle "},
1223     { RD_RDMA_READ_RESPONSE_LAST,   "RD RDMA Read Response Last "},
1224     { RD_RDMA_READ_RESPONSE_ONLY,   "RD RDMA Read Response Only "},
1225     { RD_ACKNOWLEDGE,               "RD Acknowledge "},
1226     { RD_ATOMIC_ACKNOWLEDGE,        "RD Atomic Acknowledge "},
1227     { RD_CMP_SWAP,                  "RD Compare Swap "},
1228     { RD_FETCH_ADD,                 "RD Fetch Add "},
1229     { RD_RESYNC,                    "RD RESYNC "},
1230
1231
1232     { UD_SEND_ONLY,                 "UD Send Only "},
1233     { UD_SEND_ONLY_IMM,             "UD Send Only Immediate "},
1234
1235
1236     { UC_SEND_FIRST,                "UC Send First "},
1237     { UC_SEND_MIDDLE,               "UC Send Middle "},
1238     { UC_SEND_LAST,                 "UC Send Last "},
1239     { UC_SEND_LAST_IMM,             "UC Send Last Immediate "},
1240     { UC_SEND_ONLY,                 "UC Send Only "},
1241     { UC_SEND_ONLY_IMM,             "UC Send Only Immediate "},
1242     { UC_RDMA_WRITE_FIRST,          "UC RDMA Write First"},
1243     { UC_RDMA_WRITE_MIDDLE,         "Unreliable Connection RDMA Write Middle "},
1244     { UC_RDMA_WRITE_LAST,           "UC RDMA Write Last "},
1245     { UC_RDMA_WRITE_LAST_IMM,       "UC RDMA Write Last Immediate "},
1246     { UC_RDMA_WRITE_ONLY,           "UC RDMA Write Only "},
1247     { UC_RDMA_WRITE_ONLY_IMM,       "UC RDMA Write Only Immediate "},
1248     { 0, NULL}
1249
1250 };
1251
1252
1253
1254 /* Header Ordering Based on OPCODES
1255 * These are simply an enumeration of the possible header combinations defined by the IB Spec.
1256 * These enumerations
1257 * #DEFINE [HEADER_ORDER]         [ENUM]
1258 * __________________________________ */
1259 #define RDETH_DETH_PAYLD            0
1260 /* __________________________________ */
1261 #define RDETH_DETH_RETH_PAYLD       1
1262 /* __________________________________ */
1263 #define RDETH_DETH_IMMDT_PAYLD      2
1264 /* __________________________________ */
1265 #define RDETH_DETH_RETH_IMMDT_PAYLD 3
1266 /* __________________________________ */
1267 #define RDETH_DETH_RETH             4
1268 /* __________________________________ */
1269 #define RDETH_AETH_PAYLD            5
1270 /* __________________________________ */
1271 #define RDETH_PAYLD                 6
1272 /* __________________________________ */
1273 #define RDETH_AETH                  7
1274 /* __________________________________ */
1275 #define RDETH_AETH_ATOMICACKETH     8
1276 /* __________________________________ */
1277 #define RDETH_DETH_ATOMICETH        9
1278 /* ___________________________________ */
1279 #define RDETH_DETH                  10
1280 /* ___________________________________ */
1281 #define DETH_PAYLD                  11
1282 /* ___________________________________ */
1283 #define DETH_IMMDT_PAYLD            12
1284 /* ___________________________________ */
1285 #define PAYLD                       13
1286 /* ___________________________________ */
1287 #define IMMDT_PAYLD                 14
1288 /* ___________________________________ */
1289 #define RETH_PAYLD                  15
1290 /* ___________________________________ */
1291 #define RETH_IMMDT_PAYLD            16
1292 /* ___________________________________ */
1293 #define RETH                        17
1294 /* ___________________________________ */
1295 #define AETH_PAYLD                  18
1296 /* ___________________________________ */
1297 #define AETH                        19
1298 /* ___________________________________ */
1299 #define AETH_ATOMICACKETH           20
1300 /* ___________________________________ */
1301 #define ATOMICETH                   21
1302 /* ___________________________________ */
1303 #define IETH_PAYLD                  22
1304 /* ___________________________________ */
1305
1306
1307 /* Infiniband transport services
1308    These are an enumeration of the transport services over which an IB packet
1309    might be sent. The values match the corresponding 3 bits of the opCode field
1310    in the BTH  */
1311 #define TRANSPORT_RC    0
1312 #define TRANSPORT_UC    1
1313 #define TRANSPORT_RD    2
1314 #define TRANSPORT_UD    3
1315
1316
1317 /* Array of all availavle OpCodes to make matching a bit easier.
1318 * The OpCodes dictate the header sequence following in the packet.
1319 * These arrays tell the dissector which headers must be decoded for the given OpCode. */
1320 static guint32 opCode_RDETH_DETH_ATOMICETH[] = {
1321  RD_CMP_SWAP,
1322  RD_FETCH_ADD
1323 };
1324 static guint32 opCode_IETH_PAYLD[] = {
1325  RC_SEND_LAST_INVAL,
1326  RC_SEND_ONLY_INVAL
1327 };
1328 static guint32 opCode_ATOMICETH[] = {
1329  RC_CMP_SWAP,
1330  RC_FETCH_ADD
1331 };
1332 static guint32 opCode_RDETH_DETH_RETH_PAYLD[] = {
1333  RD_RDMA_WRITE_FIRST,
1334  RD_RDMA_WRITE_ONLY
1335 };
1336 static guint32 opCode_RETH_IMMDT_PAYLD[] = {
1337  RC_RDMA_WRITE_ONLY_IMM,
1338  UC_RDMA_WRITE_ONLY_IMM
1339 };
1340 static guint32 opCode_RDETH_DETH_IMMDT_PAYLD[] = {
1341  RD_SEND_LAST_IMM,
1342  RD_SEND_ONLY_IMM,
1343  RD_RDMA_WRITE_LAST_IMM
1344 };
1345
1346 static guint32 opCode_RDETH_AETH_PAYLD[] = {
1347  RD_RDMA_READ_RESPONSE_FIRST,
1348  RD_RDMA_READ_RESPONSE_LAST,
1349  RD_RDMA_READ_RESPONSE_ONLY
1350 };
1351 static guint32 opCode_AETH_PAYLD[] = {
1352  RC_RDMA_READ_RESPONSE_FIRST,
1353  RC_RDMA_READ_RESPONSE_LAST,
1354  RC_RDMA_READ_RESPONSE_ONLY
1355 };
1356 static guint32 opCode_RETH_PAYLD[] = {
1357  RC_RDMA_WRITE_FIRST,
1358  RC_RDMA_WRITE_ONLY,
1359  UC_RDMA_WRITE_FIRST,
1360  UC_RDMA_WRITE_ONLY
1361 };
1362
1363 static guint32 opCode_RDETH_DETH_PAYLD[] = {
1364  RD_SEND_FIRST,
1365  RD_SEND_MIDDLE,
1366  RD_SEND_LAST,
1367  RD_SEND_ONLY,
1368  RD_RDMA_WRITE_MIDDLE,
1369  RD_RDMA_WRITE_LAST
1370 };
1371
1372 static guint32 opCode_IMMDT_PAYLD[] = {
1373  RC_SEND_LAST_IMM,
1374  RC_SEND_ONLY_IMM,
1375  RC_RDMA_WRITE_LAST_IMM,
1376  UC_SEND_LAST_IMM,
1377  UC_SEND_ONLY_IMM,
1378  UC_RDMA_WRITE_LAST_IMM
1379 };
1380
1381 static guint32 opCode_PAYLD[] = {
1382  RC_SEND_FIRST,
1383  RC_SEND_MIDDLE,
1384  RC_SEND_LAST,
1385  RC_SEND_ONLY,
1386  RC_RDMA_WRITE_MIDDLE,
1387  RC_RDMA_WRITE_LAST,
1388  RC_RDMA_READ_RESPONSE_MIDDLE,
1389  UC_SEND_FIRST,
1390  UC_SEND_MIDDLE,
1391  UC_SEND_LAST,
1392  UC_SEND_ONLY,
1393  UC_RDMA_WRITE_MIDDLE,
1394  UC_RDMA_WRITE_LAST
1395 };
1396
1397 /* It is not necessary to create arrays for these OpCodes since they indicate only one further header.
1398 *  We can just decode it directly
1399
1400 * static guint32 opCode_DETH_IMMDT_PAYLD[] = {
1401 * UD_SEND_ONLY_IMM
1402 * };
1403 * static guint32 opCode_DETH_PAYLD[] = {
1404 * UD_SEND_ONLY
1405 * };
1406 * static guint32 opCode_RDETH_DETH[] = {
1407 * RD_RESYNC
1408 * };
1409 * static guint32 opCode_RDETH_DETH_RETH[] = {
1410 * RD_RDMA_READ_REQUEST
1411 * };
1412 * static guint32 opCode_RDETH_DETH_RETH_IMMDT_PAYLD[] = {
1413 * RD_RDMA_WRITE_ONLY_IMM
1414 * };
1415 * static guint32 opCode_RDETH_AETH_ATOMICACKETH[] = {
1416 * RD_ATOMIC_ACKNOWLEDGE
1417 * };
1418 * static guint32 opCode_RDETH_AETH[] = {
1419 * RD_ACKNOWLEDGE
1420 * };
1421 * static guint32 opCode_RDETH_PAYLD[] = {
1422 * RD_RDMA_READ_RESPONSE_MIDDLE
1423 * };
1424 * static guint32 opCode_AETH_ATOMICACKETH[] = {
1425 * RC_ATOMIC_ACKNOWLEDGE
1426 * };
1427 * static guint32 opCode_RETH[] = {
1428 * RC_RDMA_READ_REQUEST
1429 * };
1430 * static guint32 opCode_AETH[] = {
1431 * RC_ACKNOWLEDGE
1432 * }; */
1433
1434 static void *src_addr = NULL,     /* the address to be displayed in the source/destination columns */
1435             *dst_addr = NULL;     /* (lid/gid number) will be stored here */
1436
1437 #define ADDR_MAX_LEN  sizeof("IPv6 over IB Packet")      /* maximum length of src_addr and dst_addr is for IPoIB
1438                                                             where we print an explanation string */
1439
1440 static gint8 transport_type = -1;      /* reflects the transport type of the packet being parsed.
1441                                           only use one of the TRANSPORT_* values for this field */
1442
1443 /* settings to be set by the user via the preferences dialog */
1444 static gboolean pref_dissect_eoib = TRUE;
1445 static gboolean pref_identify_iba_payload = TRUE;
1446
1447 /* saves information about connections that have been/are in the process of being
1448    negotiated via ConnectionManagement packets */
1449 typedef struct {
1450     guint8 req_gid[GID_SIZE],
1451            resp_gid[GID_SIZE];  /* GID of requester/responder, respectively */
1452     guint16 req_lid,
1453             resp_lid;           /* LID of requester/responder, respectively */
1454     guint32 req_qp,
1455             resp_qp;            /* QP number of requester/responder, respectively */
1456     guint64 service_id;         /* service id for this connection */
1457 } connection_context;
1458
1459 /* holds a table of connection contexts being negotiated by CM. the key is a obtained
1460    using add_address_to_hash64(initiator address, TransactionID) */
1461 static GHashTable *CM_context_table = NULL;
1462
1463 /* heuristics sub-dissectors list for dissecting the data payload of IB packets */
1464 static heur_dissector_list_t heur_dissectors_payload;
1465 /* heuristics sub-dissectors list for dissecting the PrivateData of CM packets */
1466 static heur_dissector_list_t heur_dissectors_cm_private;
1467
1468 /* ----- This sections contains various utility functions indirectly related to Infiniband dissection ---- */
1469
1470 /* g_int64_hash, g_int64_equal are defined starting glib 2.22 - otherwise, we'll have to
1471    provide them ourselves! */
1472 #if !GLIB_CHECK_VERSION(2,22,0)
1473 guint
1474 g_int64_hash (gconstpointer v)
1475 {
1476   return (guint) *(const gint64*) v;
1477 }
1478
1479 gboolean
1480 g_int64_equal (gconstpointer v1,
1481                gconstpointer v2)
1482 {
1483   return *((const gint64*) v1) == *((const gint64*) v2);
1484 }
1485 #endif
1486
1487 static void table_destroy_notify(gpointer data) {
1488     g_free(data);
1489 }
1490
1491 /* --------------------------------------------------------------------------------------------------------*/
1492
1493 /* Helper dissector for correctly dissecting RoCE packets (encapsulated within an Ethernet */
1494 /* frame). The only difference from regular IB packets is that RoCE packets do not contain */
1495 /* a LRH, and always start with a GRH.                                                      */
1496 static void
1497 dissect_roce(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1498 {
1499     /* this is a RoCE packet, so signal the IB dissector not to look for LRH */
1500     dissect_infiniband_common(tvb, pinfo, tree, TRUE);
1501 }
1502
1503 static void
1504 dissect_infiniband(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1505 {
1506     dissect_infiniband_common(tvb, pinfo, tree, FALSE);
1507 }
1508
1509 /* Common Dissector for both InfiniBand and RoCE packets
1510  * IN:
1511  *       tvb - The tvbbuff of packet data
1512  *       pinfo - The packet info structure with column information
1513  *       tree - The tree structure under which field nodes are to be added
1514  *       starts_with_grh - If true this packets start with a GRH header (RoCE), otherwise with LRH as usual
1515  * Notes:
1516  * 1.) Floating "offset+=" statements should probably be "functionized" but they are inline
1517  * Offset is only passed by reference in specific places, so do not be confused when following code
1518  * In any code path, adding up "offset+=" statements will tell you what byte you are at */
1519 static void
1520 dissect_infiniband_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean starts_with_grh)
1521 {
1522     /* Top Level Item */
1523     proto_item *infiniband_packet;
1524
1525     /* The Headers Subtree */
1526     proto_tree *all_headers_tree;
1527
1528     /* LRH - Local Route Header */
1529     proto_item *local_route_header_item;
1530     proto_tree *local_route_header_tree;
1531
1532     /* Raw Data */
1533     proto_item *RAWDATA_header_item;
1534     guint8 lnh_val;                 /* Link Next Header Value */
1535     gint offset = 0;                /* Current Offset */
1536
1537     /* General Variables */
1538     gboolean bthFollows = FALSE;    /* Tracks if we are parsing a BTH.  This is a significant decision point */
1539     struct infinibandinfo info = { 0, };
1540     gint32 nextHeaderSequence = -1; /* defined by this dissector. #define which indicates the upcoming header sequence from OpCode */
1541     guint8 nxtHdr = 0;              /* Keyed off for header dissection order */
1542     guint16 packetLength = 0;       /* Packet Length.  We track this as tvb_length - offset.   */
1543                                     /*  It provides the parsing methods a known size            */
1544                                     /*   that must be available for that header.                */
1545     struct e_in6_addr SRCgid;       /* Structures to hold GIDs should we need them */
1546     struct e_in6_addr DSTgid;
1547     gint crc_length = 0;
1548
1549     /* allocate space for source/destination addresses if not allocated already. we will fill them in later */
1550     if (!src_addr)
1551         src_addr = wmem_alloc(wmem_file_scope(), ADDR_MAX_LEN);
1552
1553     if (!dst_addr)
1554         dst_addr = wmem_alloc(wmem_file_scope(), ADDR_MAX_LEN);
1555
1556     pinfo->srcport = pinfo->destport = 0xffffffff;  /* set the src/dest QPN to something impossible instead of the default 0,
1557                                                        so we don't mistake it for a MAD. (QP is only 24bit, so can't be 0xffffffff)*/
1558
1559     /* add any code that should only run the first time the packet is dissected here: */
1560     if (!pinfo->fd->flags.visited)
1561     {
1562         pinfo->ptype = PT_IBQP;     /* set the port-type for this packet to be Infiniband QP number */
1563     }
1564
1565     /* Mark the Packet type as Infiniband in the wireshark UI */
1566     /* Clear other columns */
1567     col_set_str(pinfo->cinfo, COL_PROTOCOL, "InfiniBand");
1568     col_clear(pinfo->cinfo, COL_INFO);
1569
1570     /* Get the parent tree from the ERF dissector.  We don't want to nest under ERF */
1571     if (tree && tree->parent)
1572     {
1573         /* Set the normal tree outside of ERF */
1574         tree = tree->parent;
1575         /* Set a global reference for nested protocols */
1576         top_tree = tree;
1577     }
1578
1579     /* The "quick-dissection" code in dissect_general_info skips lots of the recently-added code
1580        for saving context etc. It is no longer viable to maintain two code branches, so we have
1581        (temporarily?) disabled the second one. All dissection now goes through the full branch,
1582        using a NULL tree pointer if this is not a full dissection call. Take care not to dereference
1583        the tree pointer or any subtree pointers you create using it and you'll be fine. */
1584     if (0 && !tree)
1585     {
1586         /* If no packet details are being dissected, extract some high level info for the packet view */
1587         /* Assigns column values rather than full tree population */
1588         dissect_general_info(tvb, offset, pinfo, starts_with_grh);
1589         return;
1590     }
1591
1592     /* Top Level Packet */
1593     infiniband_packet = proto_tree_add_item(tree, proto_infiniband, tvb, offset, -1, ENC_NA);
1594
1595     /* Headers Level Tree */
1596     all_headers_tree = proto_item_add_subtree(infiniband_packet, ett_all_headers);
1597
1598     if (starts_with_grh) {
1599         /* this is a RoCE packet, skip LRH parsing */
1600         lnh_val = IBA_GLOBAL;
1601         packetLength = tvb_get_ntohs(tvb, 4);   /* since we have no LRH to get PktLen from, use that of the GRH */
1602         goto skip_lrh;
1603     }
1604
1605     /* Local Route Header Subtree */
1606     local_route_header_item = proto_tree_add_item(all_headers_tree, hf_infiniband_LRH, tvb, offset, 8, ENC_NA);
1607     proto_item_set_text(local_route_header_item, "%s", "Local Route Header");
1608     local_route_header_tree = proto_item_add_subtree(local_route_header_item, ett_lrh);
1609
1610     proto_tree_add_item(local_route_header_tree, hf_infiniband_virtual_lane,            tvb, offset, 1, ENC_BIG_ENDIAN);
1611
1612     proto_tree_add_item(local_route_header_tree, hf_infiniband_link_version,            tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1;
1613     proto_tree_add_item(local_route_header_tree, hf_infiniband_service_level,           tvb, offset, 1, ENC_BIG_ENDIAN);
1614
1615     proto_tree_add_item(local_route_header_tree, hf_infiniband_reserved2,               tvb, offset, 1, ENC_BIG_ENDIAN);
1616     proto_tree_add_item(local_route_header_tree, hf_infiniband_link_next_header,        tvb, offset, 1, ENC_BIG_ENDIAN);
1617
1618
1619     /* Save Link Next Header... This tells us what the next header is. */
1620     lnh_val =  tvb_get_guint8(tvb, offset);
1621     lnh_val = lnh_val & 0x03;
1622     offset += 1;
1623
1624
1625     proto_tree_add_item(local_route_header_tree, hf_infiniband_destination_local_id,    tvb, offset, 2, ENC_BIG_ENDIAN);
1626
1627
1628     /* Set destination in packet view. */
1629     *((guint16*) dst_addr) = tvb_get_ntohs(tvb, offset);
1630     SET_ADDRESS(&pinfo->dst, AT_IB, sizeof(guint16), dst_addr);
1631
1632     offset += 2;
1633
1634     proto_tree_add_item(local_route_header_tree, hf_infiniband_reserved5,               tvb, offset, 2, ENC_BIG_ENDIAN);
1635
1636     packetLength = tvb_get_ntohs(tvb, offset); /* Get the Packet Length. This will determine payload size later on. */
1637     packetLength = packetLength & 0x07FF;      /* Mask off top 5 bits, they are reserved */
1638     packetLength = packetLength * 4;           /* Multiply by 4 to get true byte length. This is by specification.  */
1639                                                /*   PktLen is size in 4 byte words (byteSize /4). */
1640
1641     proto_tree_add_item(local_route_header_tree, hf_infiniband_packet_length,           tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
1642     proto_tree_add_item(local_route_header_tree, hf_infiniband_source_local_id,         tvb, offset, 2, ENC_BIG_ENDIAN);
1643
1644     /* Set Source in packet view. */
1645     *((guint16*) src_addr) = tvb_get_ntohs(tvb, offset);
1646     SET_ADDRESS(&pinfo->src, AT_IB, sizeof(guint16), src_addr);
1647
1648     offset += 2;
1649     packetLength -= 8; /* Shave 8 bytes for the LRH. */
1650
1651 skip_lrh:
1652
1653     /* Key off Link Next Header.  This tells us what High Level Data Format we have */
1654     switch (lnh_val)
1655     {
1656         case IBA_GLOBAL: {
1657             proto_item *global_route_header_item;
1658             proto_tree *global_route_header_tree;
1659
1660             global_route_header_item = proto_tree_add_item(all_headers_tree, hf_infiniband_GRH, tvb, offset, 40, ENC_NA);
1661             proto_item_set_text(global_route_header_item, "%s", "Global Route Header");
1662             global_route_header_tree = proto_item_add_subtree(global_route_header_item, ett_grh);
1663
1664             proto_tree_add_item(global_route_header_tree, hf_infiniband_ip_version,         tvb, offset, 1, ENC_BIG_ENDIAN);
1665             proto_tree_add_item(global_route_header_tree, hf_infiniband_traffic_class,      tvb, offset, 2, ENC_BIG_ENDIAN);
1666             proto_tree_add_item(global_route_header_tree, hf_infiniband_flow_label,         tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4;
1667
1668             proto_tree_add_item(global_route_header_tree, hf_infiniband_payload_length,     tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
1669
1670             nxtHdr = tvb_get_guint8(tvb, offset);
1671
1672             proto_tree_add_item(global_route_header_tree, hf_infiniband_next_header,        tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1;
1673             proto_tree_add_item(global_route_header_tree, hf_infiniband_hop_limit,          tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1;
1674             proto_tree_add_item(global_route_header_tree, hf_infiniband_source_gid,         tvb, offset, 16, ENC_NA);
1675
1676             tvb_get_ipv6(tvb, offset, &SRCgid);
1677
1678             /* set source GID in packet view*/
1679             memcpy(src_addr, &SRCgid, GID_SIZE);
1680             SET_ADDRESS(&pinfo->src, AT_IB, GID_SIZE, src_addr);
1681
1682             offset += 16;
1683
1684             proto_tree_add_item(global_route_header_tree, hf_infiniband_destination_gid,    tvb, offset, 16, ENC_NA);
1685
1686             tvb_get_ipv6(tvb, offset, &DSTgid);
1687
1688             /* set destination GID in packet view*/
1689             memcpy(dst_addr, &DSTgid, GID_SIZE);
1690             SET_ADDRESS(&pinfo->dst, AT_IB, GID_SIZE, dst_addr);
1691
1692             offset += 16;
1693             packetLength -= 40; /* Shave 40 bytes for GRH */
1694
1695             if (nxtHdr != 0x1B)
1696             {
1697                 /* Some kind of packet being transported globally with IBA, but locally it is not IBA - no BTH following. */
1698                 break;
1699             }
1700         }
1701             /* otherwise fall through and start parsing BTH */
1702         case IBA_LOCAL: {
1703             proto_item *base_transport_header_item;
1704             proto_tree *base_transport_header_tree;
1705             bthFollows = TRUE;
1706             base_transport_header_item = proto_tree_add_item(all_headers_tree, hf_infiniband_BTH, tvb, offset, 12, ENC_NA);
1707             proto_item_set_text(base_transport_header_item, "%s", "Base Transport Header");
1708             base_transport_header_tree = proto_item_add_subtree(base_transport_header_item, ett_bth);
1709             proto_tree_add_item(base_transport_header_tree, hf_infiniband_opcode,                       tvb, offset, 1, ENC_BIG_ENDIAN);
1710
1711             /* Get the OpCode - this tells us what headers are following */
1712             info.opCode = tvb_get_guint8(tvb, offset);
1713             col_append_str(pinfo->cinfo, COL_INFO, val_to_str_const((guint32)info.opCode, OpCodeMap, "Unknown OpCode"));
1714             offset += 1;
1715
1716             proto_tree_add_item(base_transport_header_tree, hf_infiniband_solicited_event,              tvb, offset, 1, ENC_BIG_ENDIAN);
1717             proto_tree_add_item(base_transport_header_tree, hf_infiniband_migreq,                       tvb, offset, 1, ENC_BIG_ENDIAN);
1718             proto_tree_add_item(base_transport_header_tree, hf_infiniband_pad_count,                    tvb, offset, 1, ENC_BIG_ENDIAN);
1719             proto_tree_add_item(base_transport_header_tree, hf_infiniband_transport_header_version,     tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1;
1720             proto_tree_add_item(base_transport_header_tree, hf_infiniband_partition_key,                tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
1721             proto_tree_add_item(base_transport_header_tree, hf_infiniband_reserved8,                    tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1;
1722             proto_tree_add_item(base_transport_header_tree, hf_infiniband_destination_qp,               tvb, offset, 3, ENC_BIG_ENDIAN);
1723             pinfo->destport = tvb_get_ntoh24(tvb, offset); offset += 3;
1724             proto_tree_add_item(base_transport_header_tree, hf_infiniband_acknowledge_request,          tvb, offset, 1, ENC_BIG_ENDIAN);
1725             proto_tree_add_item(base_transport_header_tree, hf_infiniband_reserved7,                    tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1;
1726             proto_tree_add_item(base_transport_header_tree, hf_infiniband_packet_sequence_number,       tvb, offset, 3, ENC_BIG_ENDIAN); offset += 3;
1727
1728
1729             packetLength -= 12; /* Shave 12 for Base Transport Header */
1730         }
1731             break;
1732         case IP_NON_IBA:
1733             /* Raw IPv6 Packet */
1734             g_snprintf((gchar *)dst_addr,  ADDR_MAX_LEN, "IPv6 over IB Packet");
1735             SET_ADDRESS(&pinfo->dst,  AT_STRINGZ, (int)strlen((char *)dst_addr)+1, dst_addr);
1736
1737             parse_IPvSix(all_headers_tree, tvb, &offset, pinfo);
1738             break;
1739         case RAW:
1740             parse_RWH(all_headers_tree, tvb, &offset, pinfo);
1741             break;
1742         default:
1743             /* Unknown Packet */
1744             RAWDATA_header_item = proto_tree_add_item(all_headers_tree, hf_infiniband_raw_data, tvb, offset, -1, ENC_NA);
1745             proto_item_set_text(RAWDATA_header_item, "%s", "Unknown Raw Data - IB Encapsulated");
1746             break;
1747     }
1748
1749     /* Base Transport header is hit quite often, however it is alone since it is the exception not the rule */
1750     /* Only IBA Local packets use it */
1751     if (bthFollows)
1752     {
1753         /* Find our next header sequence based on the Opcode
1754         * Each case decrements the packetLength by the amount of bytes consumed by each header.
1755         * The find_next_header_sequence method could be used to automate this.
1756         * We need to keep track of this so we know much data to mark as payload/ICRC/VCRC values. */
1757
1758         transport_type = (info.opCode & 0xE0) >> 5;   /* save transport type for identifying EoIB payloads later... */
1759         nextHeaderSequence = find_next_header_sequence((guint32) info.opCode);
1760
1761         /* find_next_header_sequence gives us the DEFINE value corresponding to the header order following */
1762         /* Enumerations are named intuitively, e.g. RDETH DETH PAYLOAD means there is an RDETH Header, DETH Header, and a packet payload */
1763         switch (nextHeaderSequence)
1764         {
1765             case RDETH_DETH_PAYLD:
1766                 parse_RDETH(all_headers_tree, tvb, &offset);
1767                 parse_DETH(all_headers_tree, pinfo, tvb, &offset);
1768
1769                 packetLength -= 4; /* RDETH */
1770                 packetLength -= 8; /* DETH */
1771
1772                 parse_PAYLOAD(all_headers_tree, pinfo, &info, tvb, &offset, packetLength);
1773                 break;
1774             case RDETH_DETH_RETH_PAYLD:
1775                 parse_RDETH(all_headers_tree, tvb, &offset);
1776                 parse_DETH(all_headers_tree, pinfo, tvb, &offset);
1777                 parse_RETH(all_headers_tree, tvb, &offset);
1778
1779                 packetLength -= 4; /* RDETH */
1780                 packetLength -= 8; /* DETH */
1781                 packetLength -= 16; /* RETH */
1782
1783                 parse_PAYLOAD(all_headers_tree, pinfo, &info, tvb, &offset, packetLength);
1784                 break;
1785             case RDETH_DETH_IMMDT_PAYLD:
1786                 parse_RDETH(all_headers_tree, tvb, &offset);
1787                 parse_DETH(all_headers_tree, pinfo, tvb, &offset);
1788                 parse_IMMDT(all_headers_tree, tvb, &offset);
1789
1790                 packetLength -= 4; /* RDETH */
1791                 packetLength -= 8; /* DETH */
1792                 packetLength -= 4; /* IMMDT */
1793
1794                 parse_PAYLOAD(all_headers_tree, pinfo, &info, tvb, &offset, packetLength);
1795                 break;
1796             case RDETH_DETH_RETH_IMMDT_PAYLD:
1797                 parse_RDETH(all_headers_tree, tvb, &offset);
1798                 parse_DETH(all_headers_tree, pinfo, tvb, &offset);
1799                 parse_RETH(all_headers_tree, tvb, &offset);
1800                 parse_IMMDT(all_headers_tree, tvb, &offset);
1801
1802                 packetLength -= 4;  /* RDETH */
1803                 packetLength -= 8;  /* DETH */
1804                 packetLength -= 16; /* RETH */
1805                 packetLength -= 4;  /* IMMDT */
1806
1807                 parse_PAYLOAD(all_headers_tree, pinfo, &info, tvb, &offset, packetLength);
1808                 break;
1809             case RDETH_DETH_RETH:
1810                 parse_RDETH(all_headers_tree, tvb, &offset);
1811                 parse_DETH(all_headers_tree, pinfo, tvb, &offset);
1812                 parse_RETH(all_headers_tree, tvb, &offset);
1813
1814                 /*packetLength -= 4;*/  /* RDETH */
1815                 /*packetLength -= 8;*/  /* DETH */
1816                 /*packetLength -= 16;*/ /* RETH */
1817
1818                 break;
1819             case RDETH_AETH_PAYLD:
1820                 parse_RDETH(all_headers_tree, tvb, &offset);
1821                 parse_AETH(all_headers_tree, tvb, &offset);
1822
1823                 packetLength -= 4; /* RDETH */
1824                 packetLength -= 4; /* AETH */
1825
1826                 parse_PAYLOAD(all_headers_tree, pinfo, &info, tvb, &offset, packetLength);
1827                 break;
1828             case RDETH_PAYLD:
1829                 parse_RDETH(all_headers_tree, tvb, &offset);
1830
1831                 packetLength -= 4; /* RDETH */
1832
1833                 parse_PAYLOAD(all_headers_tree, pinfo, &info, tvb, &offset, packetLength);
1834                 break;
1835             case RDETH_AETH:
1836                 parse_AETH(all_headers_tree, tvb, &offset);
1837
1838                 /*packetLength -= 4;*/ /* RDETH */
1839                 /*packetLength -= 4;*/ /* AETH */
1840
1841
1842                 break;
1843             case RDETH_AETH_ATOMICACKETH:
1844                 parse_RDETH(all_headers_tree, tvb, &offset);
1845                 parse_AETH(all_headers_tree, tvb, &offset);
1846                 parse_ATOMICACKETH(all_headers_tree, tvb, &offset);
1847
1848                 /*packetLength -= 4;*/ /* RDETH */
1849                 /*packetLength -= 4;*/ /* AETH */
1850                 /*packetLength -= 8;*/ /* AtomicAckETH */
1851
1852
1853                 break;
1854             case RDETH_DETH_ATOMICETH:
1855                 parse_RDETH(all_headers_tree, tvb, &offset);
1856                 parse_DETH(all_headers_tree, pinfo, tvb, &offset);
1857                 parse_ATOMICETH(all_headers_tree, tvb, &offset);
1858
1859                 /*packetLength -= 4;*/  /* RDETH */
1860                 /*packetLength -= 8;*/  /* DETH */
1861                 /*packetLength -= 28;*/ /* AtomicETH */
1862
1863                 break;
1864             case RDETH_DETH:
1865                 parse_RDETH(all_headers_tree, tvb, &offset);
1866                 parse_DETH(all_headers_tree, pinfo, tvb, &offset);
1867
1868                 /*packetLength -= 4;*/ /* RDETH */
1869                 /*packetLength -= 8;*/ /* DETH */
1870
1871                 break;
1872             case DETH_PAYLD:
1873                 parse_DETH(all_headers_tree, pinfo, tvb, &offset);
1874
1875                 packetLength -= 8; /* DETH */
1876
1877                 parse_PAYLOAD(all_headers_tree, pinfo, &info, tvb, &offset, packetLength);
1878                 break;
1879             case PAYLD:
1880
1881                 parse_PAYLOAD(all_headers_tree, pinfo, &info, tvb, &offset, packetLength);
1882                 break;
1883             case IMMDT_PAYLD:
1884                 parse_IMMDT(all_headers_tree, tvb, &offset);
1885
1886                 packetLength -= 4; /* IMMDT */
1887
1888                 parse_PAYLOAD(all_headers_tree, pinfo, &info, tvb, &offset, packetLength);
1889                 break;
1890             case RETH_PAYLD:
1891                 parse_RETH(all_headers_tree, tvb, &offset);
1892
1893                 packetLength -= 16; /* RETH */
1894
1895                 parse_PAYLOAD(all_headers_tree, pinfo, &info, tvb, &offset, packetLength);
1896                 break;
1897             case RETH:
1898                 parse_RETH(all_headers_tree, tvb, &offset);
1899
1900                 /*packetLength -= 16;*/ /* RETH */
1901
1902                 break;
1903             case AETH_PAYLD:
1904                 parse_AETH(all_headers_tree, tvb, &offset);
1905
1906                 packetLength -= 4; /* AETH */
1907
1908                 parse_PAYLOAD(all_headers_tree, pinfo, &info, tvb, &offset, packetLength);
1909                 break;
1910             case AETH:
1911                 parse_AETH(all_headers_tree, tvb, &offset);
1912
1913                 /*packetLength -= 4;*/ /* AETH */
1914
1915                 break;
1916             case AETH_ATOMICACKETH:
1917                 parse_AETH(all_headers_tree, tvb, &offset);
1918                 parse_ATOMICACKETH(all_headers_tree, tvb, &offset);
1919
1920                 /*packetLength -= 4;*/ /* AETH */
1921                 /*packetLength -= 8;*/ /* AtomicAckETH */
1922
1923                 break;
1924             case ATOMICETH:
1925                 parse_ATOMICETH(all_headers_tree, tvb, &offset);
1926
1927                 /*packetLength -= 28;*/ /* AtomicETH */
1928
1929                 break;
1930             case IETH_PAYLD:
1931                 parse_IETH(all_headers_tree, tvb, &offset);
1932
1933                 packetLength -= 4; /* IETH */
1934
1935                 parse_PAYLOAD(all_headers_tree, pinfo, &info, tvb, &offset, packetLength);
1936                 break;
1937             case DETH_IMMDT_PAYLD:
1938                 parse_DETH(all_headers_tree, pinfo, tvb, &offset);
1939                 parse_IMMDT(all_headers_tree, tvb, &offset);
1940
1941                 packetLength -= 8; /* DETH */
1942                 packetLength -= 4; /* IMMDT */
1943
1944                 parse_PAYLOAD(all_headers_tree, pinfo, &info, tvb, &offset, packetLength);
1945                 break;
1946             default:
1947                 parse_VENDOR(all_headers_tree, tvb, &offset);
1948                 break;
1949
1950         }
1951
1952     }
1953     /* Display the ICRC/VCRC */
1954     /* Doing it this way rather than in a variety of places according to the specific packet */
1955     /* If we've already displayed it crc_length comes out 0 */
1956     crc_length = tvb_reported_length_remaining(tvb, offset);
1957     if (crc_length == 6)
1958     {
1959         proto_tree_add_item(all_headers_tree, hf_infiniband_invariant_crc, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4;
1960         proto_tree_add_item(all_headers_tree, hf_infiniband_variant_crc,   tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
1961     }
1962     else if (crc_length == 4)
1963     {
1964         proto_tree_add_item(all_headers_tree, hf_infiniband_invariant_crc, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4;
1965     }
1966     else if (crc_length == 2)
1967     {
1968         proto_tree_add_item(all_headers_tree, hf_infiniband_variant_crc,   tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
1969     }
1970
1971 }
1972
1973 static void
1974 dissect_infiniband_link(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1975 {
1976     /* Top Level Item */
1977     proto_item *infiniband_link_packet;
1978
1979     /* The Link Subtree */
1980     proto_tree *link_tree;
1981
1982     proto_item *operand_item;
1983     gint        offset = 0;     /* Current Offset */
1984     guint8      operand;        /* Link packet Operand */
1985
1986     /* allocate space for source/destination addresses if not allocated already. we will fill them in later */
1987     if (!src_addr)
1988         src_addr = wmem_alloc(wmem_file_scope(), ADDR_MAX_LEN);
1989
1990     if (!dst_addr)
1991         dst_addr = wmem_alloc(wmem_file_scope(), ADDR_MAX_LEN);
1992
1993     operand =  tvb_get_guint8(tvb, offset);
1994     operand = (operand & 0xF0) >> 4;
1995
1996     /* Mark the Packet type as Infiniband in the wireshark UI */
1997     /* Clear other columns */
1998     col_set_str(pinfo->cinfo, COL_PROTOCOL, "InfiniBand Link");
1999     col_add_fstr(pinfo->cinfo, COL_INFO, "%s",
2000              val_to_str(operand, Operand_Description, "Unknown (0x%1x)"));
2001
2002     /* Get the parent tree from the ERF dissector.  We don't want to nest under ERF */
2003     if (tree && tree->parent)
2004     {
2005         /* Set the normal tree outside of ERF */
2006         tree = tree->parent;
2007         /* Set a global reference for nested protocols */
2008         top_tree = tree;
2009     }
2010
2011     if (!tree)
2012     {
2013         /* If no packet details are being dissected, extract some high level info for the packet view */
2014         /* Assigns column values rather than full tree population */
2015         dissect_general_info(tvb, offset, pinfo, FALSE);
2016         return;
2017     }
2018
2019     /* Top Level Packet */
2020     infiniband_link_packet = proto_tree_add_item(tree, proto_infiniband_link, tvb, offset, -1, ENC_NA);
2021
2022     /* Headers Level Tree */
2023     link_tree = proto_item_add_subtree(infiniband_link_packet, ett_link);
2024
2025     operand_item = proto_tree_add_item(link_tree, hf_infiniband_link_op, tvb, offset, 2, ENC_BIG_ENDIAN);
2026
2027     if (operand > 1) {
2028         proto_item_set_text(operand_item, "%s", "Reserved");
2029         call_dissector(data_handle, tvb, pinfo, link_tree);
2030     } else {
2031         proto_tree_add_item(link_tree, hf_infiniband_link_fctbs, tvb, offset, 2, ENC_BIG_ENDIAN);
2032         offset += 2;
2033
2034         proto_tree_add_item(link_tree, hf_infiniband_link_vl, tvb, offset, 2, ENC_BIG_ENDIAN);
2035         proto_tree_add_item(link_tree, hf_infiniband_link_fccl, tvb, offset, 2, ENC_BIG_ENDIAN);
2036         offset += 2;
2037
2038         proto_tree_add_item(link_tree, hf_infiniband_link_lpcrc, tvb, offset, 2, ENC_BIG_ENDIAN);
2039     }
2040
2041 }
2042
2043
2044 /* Description: Finds the header sequence that follows the Base Transport Header.
2045 * Somwhat inefficient (should be using a single key,value pair data structure)
2046 * But uses pure probablity to take a stab at better efficiency.
2047 * Searches largest header sequence groups first, and then finally resorts to single matches for unique header sequences
2048 * IN: OpCode: The OpCode from the Base Transport Header.
2049 * OUT: The Header Sequence enumeration.  See Declarations for #defines from (0-22) */
2050 static gint32
2051 find_next_header_sequence(guint32 OpCode)
2052 {
2053     if (contains(OpCode, &opCode_PAYLD[0], (gint32)array_length(opCode_PAYLD)))
2054         return PAYLD;
2055
2056     if (contains(OpCode, &opCode_IMMDT_PAYLD[0], (gint32)array_length(opCode_IMMDT_PAYLD)))
2057         return IMMDT_PAYLD;
2058
2059     if (contains(OpCode, &opCode_RDETH_DETH_PAYLD[0], (gint32)array_length(opCode_RDETH_DETH_PAYLD)))
2060         return RDETH_DETH_PAYLD;
2061
2062     if (contains(OpCode, &opCode_RETH_PAYLD[0], (gint32)array_length(opCode_RETH_PAYLD)))
2063         return RETH_PAYLD;
2064
2065     if (contains(OpCode, &opCode_RDETH_AETH_PAYLD[0], (gint32)array_length(opCode_RDETH_AETH_PAYLD)))
2066         return RDETH_AETH_PAYLD;
2067
2068     if (contains(OpCode, &opCode_AETH_PAYLD[0], (gint32)array_length(opCode_AETH_PAYLD)))
2069         return AETH_PAYLD;
2070
2071     if (contains(OpCode, &opCode_RDETH_DETH_IMMDT_PAYLD[0], (gint32)array_length(opCode_RDETH_DETH_IMMDT_PAYLD)))
2072         return RDETH_DETH_IMMDT_PAYLD;
2073
2074     if (contains(OpCode, &opCode_RETH_IMMDT_PAYLD[0], (gint32)array_length(opCode_RETH_IMMDT_PAYLD)))
2075         return RETH_IMMDT_PAYLD;
2076
2077     if (contains(OpCode, &opCode_RDETH_DETH_RETH_PAYLD[0], (gint32)array_length(opCode_RDETH_DETH_RETH_PAYLD)))
2078         return RDETH_DETH_RETH_PAYLD;
2079
2080     if (contains(OpCode, &opCode_ATOMICETH[0], (gint32)array_length(opCode_ATOMICETH)))
2081         return ATOMICETH;
2082
2083     if (contains(OpCode, &opCode_IETH_PAYLD[0], (gint32)array_length(opCode_IETH_PAYLD)))
2084         return IETH_PAYLD;
2085
2086     if (contains(OpCode, &opCode_RDETH_DETH_ATOMICETH[0], (gint32)array_length(opCode_RDETH_DETH_ATOMICETH)))
2087         return RDETH_DETH_ATOMICETH;
2088
2089     if ((OpCode ^ RC_ACKNOWLEDGE) == 0)
2090         return AETH;
2091
2092     if ((OpCode ^ RC_RDMA_READ_REQUEST) == 0)
2093         return RETH;
2094
2095     if ((OpCode ^ RC_ATOMIC_ACKNOWLEDGE) == 0)
2096         return AETH_ATOMICACKETH;
2097
2098     if ((OpCode ^ RD_RDMA_READ_RESPONSE_MIDDLE) == 0)
2099         return RDETH_PAYLD;
2100
2101     if ((OpCode ^ RD_ACKNOWLEDGE) == 0)
2102         return RDETH_AETH;
2103
2104     if ((OpCode ^ RD_ATOMIC_ACKNOWLEDGE) == 0)
2105         return RDETH_AETH_ATOMICACKETH;
2106
2107     if ((OpCode ^ RD_RDMA_WRITE_ONLY_IMM) == 0)
2108         return RDETH_DETH_RETH_IMMDT_PAYLD;
2109
2110     if ((OpCode ^ RD_RDMA_READ_REQUEST) == 0)
2111         return RDETH_DETH_RETH;
2112
2113     if ((OpCode ^ RD_RESYNC) == 0)
2114         return RDETH_DETH;
2115
2116     if ((OpCode ^ UD_SEND_ONLY) == 0)
2117         return DETH_PAYLD;
2118
2119     if ((OpCode ^ UD_SEND_ONLY_IMM) == 0)
2120         return DETH_IMMDT_PAYLD;
2121
2122     return -1;
2123 }
2124
2125 /* Description: Finds if a given value is present in an array. This is probably in a standard library somewhere,
2126 * But I'd rather define my own.
2127 * IN: OpCode: The OpCode you are looking for
2128 * IN: Codes: The organized array of OpCodes to look through
2129 * IN: Array length, because we're in C++...
2130 * OUT: Boolean indicating if that OpCode was found in OpCodes */
2131 static gboolean
2132 contains(guint32 OpCode, guint32* Codes, gint32 length)
2133 {
2134     gint32 i;
2135     for (i = 0; i < length; i++)
2136     {
2137         if ((OpCode ^ Codes[i]) == 0)
2138             return TRUE;
2139     }
2140     return FALSE;
2141 }
2142
2143 /* Parse RDETH - Reliable Datagram Extended Transport Header
2144 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2145 * IN: tvb - the data buffer from wireshark
2146 * IN/OUT: The current and updated offset */
2147 static void
2148 parse_RDETH(proto_tree * parentTree, tvbuff_t *tvb, gint *offset)
2149 {
2150     gint        local_offset = *offset;
2151     /* RDETH - Reliable Datagram Extended Transport Header */
2152     proto_item *RDETH_header_item;
2153     proto_tree *RDETH_header_tree;
2154
2155     RDETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_RDETH, tvb, local_offset, 4, ENC_NA);
2156     proto_item_set_text(RDETH_header_item, "%s", "RDETH - Reliable Datagram Extended Transport Header");
2157     RDETH_header_tree = proto_item_add_subtree(RDETH_header_item, ett_rdeth);
2158
2159     proto_tree_add_item(RDETH_header_tree, hf_infiniband_reserved8_RDETH,   tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
2160     proto_tree_add_item(RDETH_header_tree, hf_infiniband_ee_context,        tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
2161     *offset = local_offset;
2162 }
2163
2164 /* Parse DETH - Datagram Extended Transport Header
2165 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2166 * IN: tvb - the data buffer from wireshark
2167 * IN/OUT: The current and updated offset  */
2168 static void
2169 parse_DETH(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset)
2170 {
2171     gint        local_offset = *offset;
2172     /* DETH - Datagram Extended Transport Header */
2173     proto_item *DETH_header_item;
2174     proto_tree *DETH_header_tree;
2175
2176     DETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_DETH, tvb, local_offset, 8, ENC_NA);
2177     proto_item_set_text(DETH_header_item, "%s", "DETH - Datagram Extended Transport Header");
2178     DETH_header_tree = proto_item_add_subtree(DETH_header_item, ett_deth);
2179
2180     proto_tree_add_item(DETH_header_tree, hf_infiniband_queue_key,                  tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
2181     proto_tree_add_item(DETH_header_tree, hf_infiniband_reserved8_DETH,             tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
2182     proto_tree_add_item(DETH_header_tree, hf_infiniband_source_qp,                  tvb, local_offset, 3, ENC_BIG_ENDIAN);
2183     pinfo->srcport = tvb_get_ntoh24(tvb, local_offset); local_offset += 3;
2184
2185     *offset = local_offset;
2186 }
2187
2188 /* Parse RETH - RDMA Extended Transport Header
2189 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2190 * IN: tvb - the data buffer from wireshark
2191 * IN/OUT: The current and updated offset */
2192 static void
2193 parse_RETH(proto_tree * parentTree, tvbuff_t *tvb, gint *offset)
2194 {
2195     gint        local_offset = *offset;
2196     /* RETH - RDMA Extended Transport Header */
2197     proto_item *RETH_header_item;
2198     proto_tree *RETH_header_tree;
2199
2200     RETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_RETH, tvb, local_offset, 16, ENC_NA);
2201     proto_item_set_text(RETH_header_item, "%s", "RETH - RDMA Extended Transport Header");
2202     RETH_header_tree = proto_item_add_subtree(RETH_header_item, ett_reth);
2203
2204     proto_tree_add_item(RETH_header_tree, hf_infiniband_virtual_address,                tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
2205     proto_tree_add_item(RETH_header_tree, hf_infiniband_remote_key,                     tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
2206     proto_tree_add_item(RETH_header_tree, hf_infiniband_dma_length,                     tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
2207
2208     *offset = local_offset;
2209 }
2210
2211 /* Parse AtomicETH - Atomic Extended Transport Header
2212 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2213 * IN: tvb - the data buffer from wireshark
2214 * IN/OUT: The current and updated offset */
2215 static void
2216 parse_ATOMICETH(proto_tree * parentTree, tvbuff_t *tvb, gint *offset)
2217 {
2218     gint        local_offset = *offset;
2219     /* AtomicETH - Atomic Extended Transport Header */
2220     proto_item *ATOMICETH_header_item;
2221     proto_tree *ATOMICETH_header_tree;
2222
2223     ATOMICETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_AtomicETH, tvb, local_offset, 28, ENC_NA);
2224     proto_item_set_text(ATOMICETH_header_item, "%s", "AtomicETH - Atomic Extended Transport Header");
2225     ATOMICETH_header_tree = proto_item_add_subtree(ATOMICETH_header_item, ett_atomiceth);
2226
2227     proto_tree_add_item(ATOMICETH_header_tree, hf_infiniband_virtual_address,               tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
2228     proto_tree_add_item(ATOMICETH_header_tree, hf_infiniband_remote_key,                    tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
2229     proto_tree_add_item(ATOMICETH_header_tree, hf_infiniband_swap_or_add_data,              tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
2230     proto_tree_add_item(ATOMICETH_header_tree, hf_infiniband_compare_data,                  tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
2231     *offset = local_offset;
2232 }
2233
2234 /* Parse AETH - ACK Extended Transport Header
2235 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2236 * IN: tvb - the data buffer from wireshark
2237 * IN/OUT: The current and updated offset */
2238 static void
2239 parse_AETH(proto_tree * parentTree, tvbuff_t *tvb, gint *offset)
2240 {
2241     gint        local_offset = *offset;
2242     /* AETH - ACK Extended Transport Header */
2243     proto_item *AETH_header_item;
2244     proto_tree *AETH_header_tree;
2245
2246     AETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_AETH, tvb, local_offset, 4, ENC_NA);
2247     proto_item_set_text(AETH_header_item, "%s", "AETH - ACK Extended Transport Header");
2248     AETH_header_tree = proto_item_add_subtree(AETH_header_item, ett_aeth);
2249
2250     proto_tree_add_item(AETH_header_tree, hf_infiniband_syndrome,                       tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
2251     proto_tree_add_item(AETH_header_tree, hf_infiniband_message_sequence_number,        tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
2252
2253     *offset = local_offset;
2254 }
2255
2256 /* Parse AtomicAckEth - Atomic ACK Extended Transport Header
2257 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2258 * IN: tvb - the data buffer from wireshark
2259 * IN/OUT: The current and updated offset */
2260 static void
2261 parse_ATOMICACKETH(proto_tree * parentTree, tvbuff_t *tvb, gint *offset)
2262 {
2263     gint        local_offset = *offset;
2264     /* AtomicAckEth - Atomic ACK Extended Transport Header */
2265     proto_item *ATOMICACKETH_header_item;
2266     proto_tree *ATOMICACKETH_header_tree;
2267
2268     ATOMICACKETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_AtomicAckETH, tvb, local_offset, 8, ENC_NA);
2269     proto_item_set_text(ATOMICACKETH_header_item, "%s", "ATOMICACKETH - Atomic ACK Extended Transport Header");
2270     ATOMICACKETH_header_tree = proto_item_add_subtree(ATOMICACKETH_header_item, ett_atomicacketh);
2271     proto_tree_add_item(ATOMICACKETH_header_tree, hf_infiniband_original_remote_data,   tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
2272     *offset = local_offset;
2273 }
2274
2275 /* Parse IMMDT - Immediate Data Extended Transport Header
2276 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2277 * IN: tvb - the data buffer from wireshark
2278 * IN/OUT: The current and updated offset */
2279 static void
2280 parse_IMMDT(proto_tree * parentTree, tvbuff_t *tvb, gint *offset)
2281 {
2282     gint        local_offset = *offset;
2283     /* IMMDT - Immediate Data Extended Transport Header */
2284     proto_item *IMMDT_header_item;
2285     proto_tree *IMMDT_header_tree;
2286
2287     IMMDT_header_item = proto_tree_add_item(parentTree, hf_infiniband_IMMDT, tvb, local_offset, 4, ENC_NA);
2288     proto_item_set_text(IMMDT_header_item, "%s", "IMMDT - Immediate Data Extended Transport Header");
2289     IMMDT_header_tree = proto_item_add_subtree(IMMDT_header_item, ett_immdt);
2290     proto_tree_add_item(IMMDT_header_tree, hf_infiniband_IMMDT, tvb, local_offset, 4, ENC_NA); local_offset += 4;
2291     *offset = local_offset;
2292 }
2293
2294 /* Parse IETH - Invalidate Extended Transport Header
2295 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2296 * IN: tvb - the data buffer from wireshark
2297 * IN/OUT: The current and updated offset */
2298 static void
2299 parse_IETH(proto_tree * parentTree, tvbuff_t *tvb, gint *offset)
2300 {
2301     gint        local_offset = *offset;
2302     /* IETH - Invalidate Extended Transport Header */
2303     proto_item *IETH_header_item;
2304     proto_tree *IETH_header_tree;
2305
2306     IETH_header_item = proto_tree_add_item(parentTree, hf_infiniband_IETH, tvb, local_offset, 4, ENC_NA);
2307     proto_item_set_text(IETH_header_item, "%s", "IETH - Invalidate Extended Transport Header");
2308     IETH_header_tree = proto_item_add_subtree(IETH_header_item, ett_ieth);
2309
2310     proto_tree_add_item(IETH_header_tree, hf_infiniband_IETH,   tvb, local_offset, 4, ENC_NA); local_offset += 4;
2311
2312     *offset = local_offset;
2313 }
2314
2315 /* Parse Payload - Packet Payload / Invariant CRC / Variant CRC
2316 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2317 * IN: pinfo - packet info from wireshark
2318 * IN: info - infiniband info passed to subdissectors
2319 * IN: tvb - the data buffer from wireshark
2320 * IN/OUT: offset - The current and updated offset
2321 * IN: length - Length of Payload */
2322 static void parse_PAYLOAD(proto_tree *parentTree,
2323                           packet_info *pinfo, struct infinibandinfo *info,
2324                           tvbuff_t *tvb, gint *offset, gint length)
2325 {
2326     gint                local_offset    = *offset;
2327     /* Payload - Packet Payload */
2328     guint8              management_class;
2329     tvbuff_t *volatile  next_tvb;
2330     gint                captured_length, reported_length;
2331     guint16             etype, reserved;
2332     const char         *saved_proto;
2333     volatile gboolean   dissector_found = FALSE;
2334
2335     if (!tvb_bytes_exist(tvb, *offset, length)) /* previously consumed bytes + offset was all the data - none or corrupt payload */
2336     {
2337         col_set_str(pinfo->cinfo, COL_INFO, "Invalid Packet Length from LRH! [Malformed Packet]");
2338         col_set_fence(pinfo->cinfo, COL_INFO);
2339         return;
2340     }
2341
2342     /* management datagrams are determined by the source/destination QPs */
2343     if (pinfo->srcport == 0 || pinfo->srcport == 1 || pinfo->destport == 0 || pinfo->destport == 1)    /* management datagram */
2344     {
2345         management_class =  tvb_get_guint8(tvb, (*offset) + 1);
2346
2347         if (((management_class >= (guint8)VENDOR_1_START) && (management_class <= (guint8)VENDOR_1_END))
2348             || ((management_class >= (guint8)VENDOR_2_START) && (management_class <= (guint8)VENDOR_2_END)))
2349         {
2350             /* parse vendor specific */
2351             parse_VENDOR_MANAGEMENT(parentTree, tvb, offset);
2352         }
2353         else if ((management_class >= (guint8)APPLICATION_START) && (management_class <= (guint8)APPLICATION_END))
2354         {
2355             /* parse application specific */
2356             parse_APPLICATION_MANAGEMENT(parentTree, tvb, offset);
2357         }
2358         else if (((management_class == (guint8)0x00) || (management_class == (guint8)0x02))
2359                  || ((management_class >= (guint8)0x50) && (management_class <= (guint8)0x80))
2360                  || ((management_class >= (guint8)0x82)))
2361         {
2362             /* parse reserved classes */
2363             parse_RESERVED_MANAGEMENT(parentTree, tvb, offset);
2364         }
2365         else /* we have a normal management_class */
2366         {
2367             switch (management_class)
2368             {
2369                 case SUBN_LID_ROUTED:
2370                     /* parse subn man lid routed */
2371                     parse_SUBN_LID_ROUTED(parentTree, pinfo, tvb, &local_offset);
2372                 break;
2373                 case SUBN_DIRECTED_ROUTE:
2374                     /* parse subn directed route */
2375                     parse_SUBN_DIRECTED_ROUTE(parentTree, pinfo, tvb, &local_offset);
2376                 break;
2377                 case SUBNADMN:
2378                     /* parse sub admin */
2379                     parse_SUBNADMN(parentTree, pinfo, tvb, &local_offset);
2380                 break;
2381                 case PERF:
2382                     /* parse performance */
2383                     parse_PERF(parentTree, tvb, pinfo, &local_offset);
2384                 break;
2385                 case BM:
2386                     /* parse baseboard mgmt */
2387                     parse_BM(parentTree, tvb, &local_offset);
2388                 break;
2389                 case DEV_MGT:
2390                     /* parse device management */
2391                     parse_DEV_MGT(parentTree, tvb, &local_offset);
2392                 break;
2393                 case COM_MGT:
2394                     /* parse communication management */
2395                     parse_COM_MGT(parentTree, pinfo, tvb, &local_offset);
2396                 break;
2397                 case SNMP:
2398                     /* parse snmp tunneling */
2399                     parse_SNMP(parentTree, tvb, &local_offset);
2400                 break;
2401                 default:
2402                     break;
2403             }
2404         }
2405     }
2406     else /* Normal Data Packet - Parse as such */
2407     {
2408
2409         /* Calculation for Payload:
2410         * (tvb_length) Length of entire packet - (local_offset) Starting byte of Payload Data
2411         * offset addition is more complex for the payload.
2412         * We need the total length of the packet, - length of previous headers, + offset where payload started.
2413         * We also need  to reserve 6 bytes for the CRCs which are not actually part of the payload.  */
2414
2415         etype    = tvb_get_ntohs(tvb, local_offset);
2416         reserved = tvb_get_ntohs(tvb, local_offset + 2);
2417
2418         /* try to recognize whether or not this is a Mellanox EoIB packet by the
2419            transport type and the 4 first bits of the payload */
2420         if (pref_dissect_eoib &&
2421             (transport_type == TRANSPORT_UD) &&
2422             (tvb_get_bits8(tvb, local_offset*8, 4) == 0xC)) {
2423             dissector_found = parse_EoIB(parentTree, tvb, local_offset, pinfo);
2424         }
2425
2426         /* IBA packet data could be anything in principle, however it is common
2427          * practice to carry non-IBA data encapsulated with an EtherType header,
2428          * similar to the RWH header. There is no way to identify these frames
2429          * positively.
2430          *
2431          * If the appropriate option is set in protocol preferences,
2432          * We see if the first few bytes look like an EtherType header, and if so
2433          * call the appropriate dissector. If not we call the "data" dissector.
2434          */
2435         if (!dissector_found && pref_identify_iba_payload && (reserved == 0)) {
2436             void *pd_save;
2437
2438             /* Get the captured length and reported length of the data
2439                after the Ethernet type. */
2440             captured_length = tvb_length_remaining(tvb, local_offset+4);
2441             reported_length = tvb_reported_length_remaining(tvb, local_offset+4);
2442
2443             next_tvb = tvb_new_subset(tvb, local_offset+4, captured_length, reported_length);
2444
2445             /* Look for sub-dissector, and call it if found.
2446                Catch exceptions, so that if the reported length of "next_tvb"
2447                was reduced by some dissector before an exception was thrown,
2448                we can still put in an item for the trailer. */
2449             saved_proto = pinfo->current_proto;
2450             pd_save = pinfo->private_data;
2451
2452             TRY {
2453                 dissector_found = dissector_try_uint(ethertype_dissector_table,
2454                                      etype, next_tvb, pinfo, top_tree);
2455             }
2456             CATCH_NONFATAL_ERRORS {
2457                 /* Somebody threw an exception that means that there
2458                    was a problem dissecting the payload; that means
2459                    that a dissector was found, so we don't need to
2460                    dissect the payload as data or update the protocol
2461                    or info columns.
2462
2463                    Just show the exception and then drive on to show
2464                    the trailer, after noting that a dissector was found
2465                    and restoring the protocol value that was in effect
2466                    before we called the subdissector.
2467
2468                    Restore the private_data structure in case one of the
2469                    called dissectors modified it (and, due to the exception,
2470                    was unable to restore it). */
2471                 pinfo->private_data = pd_save;
2472
2473                 show_exception(next_tvb, pinfo, top_tree, EXCEPT_CODE, GET_MESSAGE);
2474                 dissector_found = TRUE;
2475                 pinfo->current_proto = saved_proto;
2476             }
2477             ENDTRY;
2478
2479             if (dissector_found) {
2480                 proto_item *PAYLOAD_header_item;
2481                 proto_tree *PAYLOAD_header_tree;
2482                 /* now create payload entry to show Ethertype */
2483                 PAYLOAD_header_item = proto_tree_add_item(parentTree, hf_infiniband_payload, tvb, local_offset, tvb_reported_length_remaining(tvb, local_offset)-6, ENC_NA);
2484                 proto_item_set_text(PAYLOAD_header_item, "%s", "IBA Payload - appears to be EtherType encapsulated");
2485                 PAYLOAD_header_tree = proto_item_add_subtree(PAYLOAD_header_item, ett_payload);
2486                 proto_tree_add_uint(PAYLOAD_header_tree, hf_infiniband_etype, tvb,
2487                             local_offset, 2,  tvb_get_ntohs(tvb, local_offset));
2488
2489                 local_offset += 2;
2490
2491                 proto_tree_add_uint(PAYLOAD_header_tree, hf_infiniband_reserved16_RWH, tvb,
2492                             local_offset, 2, tvb_get_ntohs(tvb, local_offset));
2493
2494             }
2495
2496         }
2497
2498         captured_length = tvb_length_remaining(tvb, local_offset);
2499         reported_length = tvb_reported_length_remaining(tvb,
2500                                 local_offset);
2501
2502         if (reported_length >= 6)
2503             reported_length -= 6;
2504         if (captured_length > reported_length)
2505             captured_length = reported_length;
2506
2507         next_tvb = tvb_new_subset(tvb, local_offset,
2508                       captured_length,
2509                       reported_length);
2510
2511         /* Try any heuristic dissectors that requested a chance to try and dissect IB payloads */
2512         if (!dissector_found) {
2513             dissector_found = dissector_try_heuristic(heur_dissectors_payload, next_tvb, pinfo, parentTree, info);
2514         }
2515
2516         if (!dissector_found) {
2517             /* No sub-dissector found.
2518                Label rest of packet as "Data" */
2519             call_dissector(data_handle, next_tvb, pinfo, top_tree);
2520
2521         }
2522
2523
2524         /*parse_RWH(parentTree, tvb, &local_offset, pinfo);*/
2525
2526         /* Will contain ICRC and VCRC = 4+2 */
2527         local_offset = tvb_reported_length(tvb) - 6;
2528     }
2529
2530     *offset = local_offset;
2531 }
2532
2533 /* Parse VENDOR - Parse a vendor specific or unknown header sequence
2534 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2535 * IN: tvb - the data buffer from wireshark
2536 * IN/OUT: The current and updated offset */
2537 static void parse_VENDOR(proto_tree * parentTree, tvbuff_t *tvb, gint *offset)
2538 {
2539     gint        local_offset = *offset;
2540     proto_item *VENDOR_header_item;
2541     proto_tree *VENDOR_header_tree;
2542
2543     VENDOR_header_item = proto_tree_add_item(parentTree, hf_infiniband_vendor, tvb, local_offset, 4, ENC_NA);
2544     proto_item_set_text(VENDOR_header_item, "%s", "Vendor Specific or Unknown Header Sequence");
2545     VENDOR_header_tree = proto_item_add_subtree(VENDOR_header_item, ett_vendor);
2546     proto_tree_add_item(VENDOR_header_tree, hf_infiniband_vendor,   tvb, local_offset, -1, ENC_NA);
2547     *offset = local_offset;
2548 }
2549
2550 /* Parse IPv6 - Parse an IPv6 Packet
2551 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2552 * IN: tvb - the data buffer from wireshark
2553 * IN/OUT: The current and updated offset
2554 * IN: pinfo - packet info from wireshark */
2555 static void parse_IPvSix(proto_tree *parentTree, tvbuff_t *tvb, gint *offset, packet_info *pinfo)
2556 {
2557     tvbuff_t *ipv6_tvb;
2558
2559     /* (- 2) for VCRC which lives at the end of the packet   */
2560     ipv6_tvb = tvb_new_subset(tvb, *offset,
2561                   tvb_length_remaining(tvb, *offset) - 2,
2562                   tvb_reported_length_remaining(tvb, *offset) - 2);
2563     call_dissector(ipv6_handle, ipv6_tvb, pinfo, parentTree);
2564     *offset = tvb_reported_length(tvb) - 2;
2565
2566     /* Display the VCRC */
2567     proto_tree_add_item(parentTree, hf_infiniband_variant_crc,  tvb, *offset, 2, ENC_BIG_ENDIAN);
2568 }
2569
2570 /* Parse EtherType - Parse a generic IP packaet with an EtherType of IP or ARP
2571 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2572 * IN: tvb - the data buffer from wireshark
2573 * IN/OUT: The current and updated offset
2574 * IN: pinfo - packet info from wireshark */
2575 static void parse_RWH(proto_tree *ah_tree, tvbuff_t *tvb, gint *offset, packet_info *pinfo)
2576 {
2577     guint16   ether_type;
2578     tvbuff_t *next_tvb;
2579
2580     /* RWH - Raw Header */
2581     proto_item *RWH_header_item;
2582     proto_tree *RWH_header_tree;
2583
2584     gint captured_length, reported_length;
2585
2586     RWH_header_item = proto_tree_add_item(ah_tree, hf_infiniband_RWH, tvb, *offset, 4, ENC_NA);
2587     proto_item_set_text(RWH_header_item, "%s", "RWH - Raw Header");
2588     RWH_header_tree = proto_item_add_subtree(RWH_header_item, ett_rwh);
2589
2590     proto_tree_add_item(RWH_header_tree, hf_infiniband_reserved16_RWH, tvb,
2591             *offset, 2, ENC_BIG_ENDIAN);
2592
2593     *offset += 2;
2594
2595     ether_type = tvb_get_ntohs(tvb, *offset);
2596     proto_tree_add_uint(RWH_header_tree, hf_infiniband_etype, tvb, *offset, 2,
2597                         ether_type);
2598     *offset += 2;
2599
2600     /* Get the captured length and reported length of the data
2601      * after the Ethernet type. */
2602     captured_length = tvb_length_remaining(tvb, *offset);
2603     reported_length = tvb_reported_length_remaining(tvb, *offset);
2604
2605     /* Construct a tvbuff for the payload after the Ethernet type,
2606      * not including the FCS. */
2607     if ((captured_length >= 0) && (reported_length >= 0)) {
2608         if (reported_length >= 2)
2609             reported_length -= 2;
2610         if (captured_length > reported_length)
2611             captured_length = reported_length;
2612     }
2613
2614     next_tvb = tvb_new_subset(tvb, *offset, captured_length, reported_length);
2615     if (!dissector_try_uint(ethertype_dissector_table, ether_type,
2616             next_tvb, pinfo, top_tree))
2617        call_dissector(data_handle, next_tvb, pinfo, top_tree);
2618
2619     *offset = tvb_reported_length(tvb) - 2;
2620     /* Display the VCRC */
2621     proto_tree_add_item(ah_tree, hf_infiniband_variant_crc, tvb, *offset, 2, ENC_BIG_ENDIAN);
2622 }
2623
2624
2625 /* Parse a Mellanox EoIB Encapsulation Header and the associated Ethernet frame
2626 * IN: parentTree to add the dissection to - in this code the all_headers_tree
2627 * IN: tvb - the data buffer from wireshark
2628 * IN: The current offset
2629 * IN: pinfo - packet info from wireshark */
2630 static gboolean parse_EoIB(proto_tree *tree, tvbuff_t *tvb, gint offset, packet_info *pinfo)
2631 {
2632     proto_item *header_item;
2633     proto_tree *header_subtree;
2634     gboolean    ms;
2635     gint8       seg_offset;
2636     tvbuff_t   *encap_tvb;
2637     /* the encapsulated eoib size (including the header!) is remaining length-6 bytes of CRC */
2638     int         encap_size = tvb_reported_length_remaining(tvb, offset) - 6;
2639
2640     if (encap_size < 4) {
2641         /* not even large enough to contain the eoib encap header. error! */
2642         return FALSE;
2643     }
2644
2645     encap_tvb = tvb_new_subset(tvb, offset + 4, tvb_length_remaining(tvb, offset + 4), encap_size - 4);
2646
2647     header_item = proto_tree_add_item(tree, hf_infiniband_EOIB, tvb, offset, 4, ENC_NA);
2648     header_subtree = proto_item_add_subtree(header_item, ett_eoib);
2649
2650     proto_tree_add_item(header_subtree, hf_infiniband_ver, tvb, offset, 2, ENC_BIG_ENDIAN);
2651     proto_tree_add_item(header_subtree, hf_infiniband_tcp_chk, tvb, offset, 2, ENC_BIG_ENDIAN);
2652     proto_tree_add_item(header_subtree, hf_infiniband_ip_chk, tvb, offset, 2, ENC_BIG_ENDIAN);
2653     proto_tree_add_item(header_subtree, hf_infiniband_fcs, tvb, offset, 2, ENC_BIG_ENDIAN);
2654
2655     ms = tvb_get_bits8(tvb, (offset + 1)*8 + 2, 1);
2656     seg_offset = tvb_get_bits8(tvb, (offset + 1)*8 + 3, 5);
2657
2658     proto_tree_add_item(header_subtree, hf_infiniband_ms, tvb, offset, 2, ENC_BIG_ENDIAN);
2659     proto_tree_add_item(header_subtree, hf_infiniband_seg_off, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
2660     proto_tree_add_item(header_subtree, hf_infiniband_seg_id, tvb, offset, 2, ENC_BIG_ENDIAN);
2661
2662     if (seg_offset || ms) {
2663         /* this is a fragment of an encapsulated Ethernet jumbo frame, parse as data */
2664         call_dissector(data_handle, encap_tvb, pinfo, top_tree);
2665     } else {
2666         /* non-fragmented frames can be fully parsed */
2667         call_dissector(eth_handle, encap_tvb, pinfo, top_tree);
2668     }
2669
2670     return TRUE;
2671 }
2672
2673
2674 /* Parse Subnet Management (LID Routed)
2675 * IN: parentTree to add the dissection to
2676 * IN: pinfo - packet info from wireshark
2677 * IN: tvb - the data buffer from wireshark
2678 * IN/OUT: The current and updated offset */
2679 static void parse_SUBN_LID_ROUTED(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset)
2680 {
2681     /* Parse the Common MAD Header */
2682     MAD_Data    MadData;
2683     gint        local_offset;
2684     proto_item *SUBN_LID_ROUTED_header_item;
2685     proto_tree *SUBN_LID_ROUTED_header_tree;
2686
2687     if (!parse_MAD_Common(parentTree, tvb, offset, &MadData))
2688     {
2689         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
2690         return;
2691     }
2692
2693     local_offset = *offset;
2694
2695     /* local_offset - 24 here because when we come out of parse_MAD_Common, the offset it sitting at the data section. */
2696     SUBN_LID_ROUTED_header_item = proto_tree_add_item(parentTree, hf_infiniband_SMP_LID, tvb, local_offset - 24, 256, ENC_NA);
2697     proto_item_set_text(SUBN_LID_ROUTED_header_item, "%s", "SMP (LID Routed) ");
2698     SUBN_LID_ROUTED_header_tree = proto_item_add_subtree(SUBN_LID_ROUTED_header_item, ett_subn_lid_routed);
2699     proto_tree_add_item(SUBN_LID_ROUTED_header_tree, hf_infiniband_m_key,           tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
2700     proto_tree_add_item(SUBN_LID_ROUTED_header_tree, hf_infiniband_reserved256,     tvb, local_offset, 32, ENC_NA); local_offset += 32;
2701
2702     label_SUBM_Method(SUBN_LID_ROUTED_header_item, &MadData, pinfo);
2703     label_SUBM_Attribute(SUBN_LID_ROUTED_header_item, &MadData, pinfo);
2704
2705     /* Try to do the detail parse of the attribute.  If there is an error, or the attribute is unknown, we'll just highlight the generic data. */
2706     if (!parse_SUBM_Attribute(SUBN_LID_ROUTED_header_tree, tvb, &local_offset, &MadData))
2707     {
2708         proto_tree_add_item(SUBN_LID_ROUTED_header_tree, hf_infiniband_smp_data,    tvb, local_offset, 64, ENC_NA); local_offset += 64;
2709     }
2710
2711     proto_tree_add_item(SUBN_LID_ROUTED_header_tree, hf_infiniband_reserved1024,    tvb, local_offset, 128, ENC_NA); local_offset += 128;
2712     *offset = local_offset;
2713 }
2714
2715 /* Parse Subnet Management (Directed Route)
2716 * IN: parentTree to add the dissection to
2717 * IN: tvb - the data buffer from wireshark
2718 * IN/OUT: The current and updated offset */
2719 static void parse_SUBN_DIRECTED_ROUTE(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset)
2720 {
2721     /* Parse the Common MAD Header */
2722     MAD_Data    MadData;
2723     gint        local_offset;
2724     proto_item *SUBN_DIRECTED_ROUTE_header_item;
2725     proto_tree *SUBN_DIRECTED_ROUTE_header_tree;
2726
2727     if (!parse_MAD_Common(parentTree, tvb, offset, &MadData))
2728     {
2729         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
2730         return;
2731     }
2732
2733     local_offset = *offset;
2734
2735     /* local_offset - 24 here because when we come out of parse_MAD_Common, the offset it sitting at the data section.
2736     * We need to go backwards because this particular SMP uses the class specific portion of the Common MAD Header */
2737     SUBN_DIRECTED_ROUTE_header_item = proto_tree_add_item(parentTree, hf_infiniband_SMP_DIRECTED, tvb, local_offset - 24, 256, ENC_NA);
2738     proto_item_set_text(SUBN_DIRECTED_ROUTE_header_item, "%s", "SMP (Directed Route) ");
2739     SUBN_DIRECTED_ROUTE_header_tree = proto_item_add_subtree(SUBN_DIRECTED_ROUTE_header_item, ett_subn_directed_route);
2740
2741     label_SUBM_Method(SUBN_DIRECTED_ROUTE_header_item, &MadData, pinfo);
2742     label_SUBM_Attribute(SUBN_DIRECTED_ROUTE_header_item, &MadData, pinfo);
2743
2744     /* Place us at offset 4, the "D" Bit (Direction bit for Directed Route SMPs) */
2745     local_offset -= 20;
2746     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_d,               tvb, local_offset, 1, ENC_BIG_ENDIAN);
2747     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_smp_status,      tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
2748     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_hop_pointer,     tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
2749     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_hop_count,       tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
2750     local_offset += 16; /* Skip over the rest of the Common MAD Header... It's already dissected by parse_MAD_Common */
2751     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_m_key,           tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
2752     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_dr_slid,         tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
2753     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_dr_dlid,         tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
2754     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_reserved28,      tvb, local_offset, 28, ENC_NA); local_offset += 28;
2755
2756     /* Try to do the detail parse of the attribute.  If there is an error, or the attribute is unknown, we'll just highlight the generic data. */
2757     if (!parse_SUBM_Attribute(SUBN_DIRECTED_ROUTE_header_tree, tvb, &local_offset, &MadData))
2758     {
2759         proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_smp_data,    tvb, local_offset, 64, ENC_NA); local_offset += 64;
2760     }
2761
2762     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_initial_path,        tvb, local_offset, 64, ENC_NA); local_offset += 64;
2763     proto_tree_add_item(SUBN_DIRECTED_ROUTE_header_tree, hf_infiniband_return_path,     tvb, local_offset, 64, ENC_NA); local_offset += 64;
2764     *offset = local_offset;
2765 }
2766
2767 /* Parse Subnet Administration
2768 * IN: parentTree to add the dissection to
2769 * IN: pinfo - packet info from wireshark
2770 * IN: tvb - the data buffer from wireshark
2771 * IN/OUT: The current and updated offset */
2772 static void parse_SUBNADMN(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset)
2773 {
2774     /* Parse the Common MAD Header */
2775     MAD_Data    MadData;
2776     gint        local_offset;
2777     proto_item *SUBNADMN_header_item;
2778     proto_tree *SUBNADMN_header_tree;
2779
2780     if (!parse_MAD_Common(parentTree, tvb, offset, &MadData))
2781     {
2782         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
2783         return;
2784     }
2785     if (!parse_RMPP(parentTree, tvb, offset))
2786     {
2787         /* TODO: Mark Corrupt Packet */
2788         return;
2789     }
2790     local_offset = *offset;
2791
2792     SUBNADMN_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset - 36, 256, ENC_NA);
2793     proto_item_set_text(SUBNADMN_header_item, "%s", "SMA");
2794     SUBNADMN_header_tree = proto_item_add_subtree(SUBNADMN_header_item, ett_subnadmin);
2795
2796     proto_tree_add_item(SUBNADMN_header_tree, hf_infiniband_sm_key,             tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
2797     proto_tree_add_item(SUBNADMN_header_tree, hf_infiniband_attribute_offset,   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 4;
2798     proto_tree_add_item(SUBNADMN_header_tree, hf_infiniband_reserved16,         tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 4;
2799     proto_tree_add_item(SUBNADMN_header_tree, hf_infiniband_component_mask,     tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
2800
2801     label_SUBA_Method(SUBNADMN_header_item, &MadData, pinfo);
2802     label_SUBA_Attribute(SUBNADMN_header_item, &MadData, pinfo);
2803
2804     if (!parse_SUBA_Attribute(SUBNADMN_header_tree, tvb, &local_offset, &MadData))
2805     {
2806         proto_tree_add_item(SUBNADMN_header_tree, hf_infiniband_subnet_admin_data,  tvb, local_offset, 200, ENC_NA); local_offset += 200;
2807     }
2808     *offset = local_offset;
2809 }
2810
2811 /* Parse Performance Management
2812 * IN: parentTree to add the dissection to
2813 * IN: tvb - the data buffer from wireshark
2814 * IN: pinfo - the pinfo struct from wireshark
2815 * IN/OUT: The current and updated offset */
2816 static void parse_PERF(proto_tree *parentTree, tvbuff_t *tvb, packet_info *pinfo, gint *offset)
2817 {
2818     /* Parse the Common MAD Header */
2819     MAD_Data    MadData;
2820     gint        local_offset;
2821     proto_item *PERF_header_item;
2822
2823     if (!parse_MAD_Common(parentTree, tvb, offset, &MadData))
2824     {
2825         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
2826         return;
2827     }
2828
2829     local_offset = *offset; /* offset now points to the start of the MAD data field */
2830
2831     switch (MadData.attributeID) {
2832         case ATTR_PORT_COUNTERS:
2833             parse_PERF_PortCounters(parentTree, tvb, pinfo, &local_offset);
2834             break;
2835         case ATTR_PORT_COUNTERS_EXT:
2836             parse_PERF_PortCountersExtended(parentTree, tvb, pinfo, &local_offset);
2837             break;
2838         default:
2839             PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, MAD_DATA_SIZE, ENC_NA); local_offset += MAD_DATA_SIZE;
2840             proto_item_set_text(PERF_header_item, "%s", "PERF - Performance Management MAD (Dissector Not Implemented)");
2841             break;
2842     }
2843
2844     *offset = local_offset;
2845 }
2846
2847 /* Parse Baseboard Management
2848 * IN: parentTree to add the dissection to
2849 * IN: tvb - the data buffer from wireshark
2850 * IN/OUT: The current and updated offset */
2851 static void parse_BM(proto_tree *parentTree, tvbuff_t *tvb, gint *offset)
2852 {
2853     /* Parse the Common MAD Header */
2854     MAD_Data    MadData;
2855     gint        local_offset;
2856     proto_item *PERF_header_item;
2857
2858     if (!parse_MAD_Common(parentTree, tvb, offset, &MadData))
2859     {
2860         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
2861         return;
2862     }
2863     local_offset = *offset;
2864
2865     PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, MAD_DATA_SIZE, ENC_NA); local_offset += MAD_DATA_SIZE;
2866     proto_item_set_text(PERF_header_item, "%s", "BM - Baseboard Management MAD (Dissector Not Implemented)");
2867     *offset = local_offset;
2868 }
2869
2870 /* Parse Device Management
2871 * IN: parentTree to add the dissection to
2872 * IN: tvb - the data buffer from wireshark
2873 * IN/OUT: The current and updated offset */
2874 static void parse_DEV_MGT(proto_tree *parentTree, tvbuff_t *tvb, gint *offset)
2875 {
2876     /* Parse the Common MAD Header */
2877     MAD_Data    MadData;
2878     gint        local_offset;
2879     proto_item *PERF_header_item;
2880
2881     if (!parse_MAD_Common(parentTree, tvb, offset, &MadData))
2882     {
2883         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
2884         return;
2885     }
2886     local_offset = *offset;
2887     PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, MAD_DATA_SIZE, ENC_NA); local_offset += MAD_DATA_SIZE;
2888     proto_item_set_text(PERF_header_item, "%s", "DEV_MGT - Device Management MAD (Dissector Not Implemented)");
2889     *offset = local_offset;
2890 }
2891
2892 /* Parse Communications Management
2893 * IN: parentTree to add the dissection to
2894 * IN: tvb - the data buffer from wireshark
2895 * IN/OUT: The current and updated offset */
2896 static void parse_COM_MGT(proto_tree *parentTree, packet_info *pinfo, tvbuff_t *tvb, gint *offset)
2897 {
2898     MAD_Data    MadData;
2899     gint        local_offset;
2900     guint8     *local_gid, *remote_gid;
2901     const char *label;
2902     proto_item *CM_header_item;
2903     proto_tree *CM_header_tree;
2904     tvbuff_t   *next_tvb;
2905
2906     local_gid  = (guint8 *)wmem_alloc(wmem_packet_scope(), GID_SIZE);
2907     remote_gid = (guint8 *)wmem_alloc(wmem_packet_scope(), GID_SIZE);
2908
2909     if (!parse_MAD_Common(parentTree, tvb, offset, &MadData))
2910     {
2911         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
2912         return;
2913     }
2914     local_offset = *offset;
2915
2916     CM_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 140, ENC_NA);
2917
2918     label = val_to_str_const(MadData.attributeID, CM_Attributes, "(Unknown CM Attribute)");
2919
2920     proto_item_set_text(CM_header_item, "CM %s", label);
2921     col_add_fstr(pinfo->cinfo, COL_INFO, "CM: %s", label);
2922
2923     CM_header_tree = proto_item_add_subtree(CM_header_item, ett_cm);
2924
2925     switch (MadData.attributeID) {
2926         case ATTR_CM_REQ: {
2927             guint32 local_qpn;
2928             guint32 local_lid;
2929             guint32 remote_lid;
2930             guint64 serviceid;
2931             proto_tree_add_item(CM_header_tree, hf_cm_req_local_comm_id, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
2932             local_offset += 4;  /* skip reserved */
2933             proto_tree_add_item(CM_header_tree, hf_cm_req_service_id, tvb, local_offset, 8, ENC_BIG_ENDIAN);
2934             serviceid = tvb_get_ntoh64(tvb, local_offset); local_offset += 8;
2935             proto_tree_add_item(CM_header_tree, hf_cm_req_local_ca_guid, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
2936             local_offset += 4;  /* skip reserved */
2937             proto_tree_add_item(CM_header_tree, hf_cm_req_local_qkey, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
2938             proto_tree_add_item(CM_header_tree, hf_cm_req_local_qpn, tvb, local_offset, 3, ENC_BIG_ENDIAN);
2939             local_qpn = tvb_get_ntoh24(tvb, local_offset); local_offset += 3;
2940             proto_tree_add_item(CM_header_tree, hf_cm_req_respo_res, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
2941             proto_tree_add_item(CM_header_tree, hf_cm_req_local_eecn, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
2942             proto_tree_add_item(CM_header_tree, hf_cm_req_init_depth, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
2943             proto_tree_add_item(CM_header_tree, hf_cm_req_remote_eecn, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
2944             proto_tree_add_item(CM_header_tree, hf_cm_req_remote_cm_resp_to, tvb, local_offset, 1, ENC_BIG_ENDIAN);
2945             proto_tree_add_item(CM_header_tree, hf_cm_req_transp_serv_type, tvb, local_offset, 1, ENC_BIG_ENDIAN);
2946             proto_tree_add_item(CM_header_tree, hf_cm_req_e2e_flow_ctrl, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
2947             proto_tree_add_item(CM_header_tree, hf_cm_req_start_psn, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
2948             proto_tree_add_item(CM_header_tree, hf_cm_req_local_cm_resp_to, tvb, local_offset, 1, ENC_BIG_ENDIAN);
2949             proto_tree_add_item(CM_header_tree, hf_cm_req_retry_count, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
2950             proto_tree_add_item(CM_header_tree, hf_cm_req_pkey, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
2951             proto_tree_add_item(CM_header_tree, hf_cm_req_path_pp_mtu, tvb, local_offset, 1, ENC_BIG_ENDIAN);
2952             proto_tree_add_item(CM_header_tree, hf_cm_req_rdc_exists, tvb, local_offset, 1, ENC_BIG_ENDIAN);
2953             proto_tree_add_item(CM_header_tree, hf_cm_req_rnr_retry_count, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
2954             proto_tree_add_item(CM_header_tree, hf_cm_req_max_cm_retries, tvb, local_offset, 1, ENC_BIG_ENDIAN);
2955             proto_tree_add_item(CM_header_tree, hf_cm_req_srq, tvb, local_offset, 1, ENC_BIG_ENDIAN);
2956             local_offset += 1;  /* skip reserved */
2957             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_local_lid, tvb, local_offset, 2, ENC_BIG_ENDIAN);
2958             local_lid = tvb_get_ntohs(tvb, local_offset); local_offset += 2;
2959             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_remote_lid, tvb, local_offset, 2, ENC_BIG_ENDIAN);
2960             remote_lid = tvb_get_ntohs(tvb, local_offset); local_offset += 2;
2961             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_local_gid, tvb, local_offset, 16, ENC_NA);
2962             tvb_get_ipv6(tvb, local_offset, (struct e_in6_addr*)local_gid); local_offset += 16;
2963             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_remote_gid, tvb, local_offset, 16, ENC_NA);
2964             tvb_get_ipv6(tvb, local_offset, (struct e_in6_addr*)remote_gid); local_offset += 16;
2965             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_flow_label, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
2966             local_offset += 1;  /* skip reserved */
2967             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_packet_rate, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
2968             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_traffic_class, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
2969             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_hop_limit, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
2970             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_sl, tvb, local_offset, 1, ENC_BIG_ENDIAN);
2971             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_subnet_local, tvb, local_offset, 1, ENC_BIG_ENDIAN);
2972             local_offset += 1;  /* skip reserved */
2973             proto_tree_add_item(CM_header_tree, hf_cm_req_primary_local_ack_to, tvb, local_offset, 1, ENC_BIG_ENDIAN);
2974             local_offset += 1;  /* skip reserved */
2975             proto_tree_add_item(CM_header_tree, hf_cm_req_alt_local_lid, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
2976             proto_tree_add_item(CM_header_tree, hf_cm_req_alt_remote_lid, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
2977             proto_tree_add_item(CM_header_tree, hf_cm_req_alt_local_gid, tvb, local_offset, 16, ENC_NA); local_offset += 16;
2978             proto_tree_add_item(CM_header_tree, hf_cm_req_alt_remote_gid, tvb, local_offset, 16, ENC_NA); local_offset += 16;
2979             proto_tree_add_item(CM_header_tree, hf_cm_req_flow_label, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
2980             local_offset += 1;  /* skip reserved */
2981             proto_tree_add_item(CM_header_tree, hf_cm_req_packet_rate, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
2982             proto_tree_add_item(CM_header_tree, hf_cm_req_alt_traffic_class, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
2983             proto_tree_add_item(CM_header_tree, hf_cm_req_alt_hop_limit, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
2984             proto_tree_add_item(CM_header_tree, hf_cm_req_SL, tvb, local_offset, 1, ENC_BIG_ENDIAN);
2985             proto_tree_add_item(CM_header_tree, hf_cm_req_subnet_local, tvb, local_offset, 1, ENC_BIG_ENDIAN);
2986             local_offset += 1;  /* skip reserved */
2987             proto_tree_add_item(CM_header_tree, hf_cm_req_local_ACK_timeout, tvb, local_offset, 1, ENC_BIG_ENDIAN);
2988             local_offset += 1;  /* skip reserved */
2989
2990             /* the following saves information about the conversation this packet defines,
2991                so there's no point in doing it more than once per packet */
2992             if (!pinfo->fd->flags.visited)
2993             {
2994                 connection_context *connection;
2995                 conversation_infiniband_data *proto_data;
2996                 conversation_t *conv;
2997                 guint64 *hash_key = (guint64 *)g_malloc(sizeof(guint64));
2998
2999                 /* create a new connection context and store it in the hash table */
3000                 connection = (connection_context *)g_malloc(sizeof(connection_context));
3001                 memcpy(&(connection->req_gid), local_gid, GID_SIZE);
3002                 memcpy(&(connection->resp_gid), remote_gid, GID_SIZE);
3003                 connection->req_lid = local_lid;
3004                 connection->resp_lid = remote_lid;
3005                 connection->req_qp = local_qpn;
3006                 connection->resp_qp = 0;   /* not currently known. we'll fill this in later */
3007                 connection->service_id = serviceid;
3008
3009                 /* save the context to the context hash table, for retrieval when the corresponding
3010                    CM REP message arrives*/
3011                 *hash_key = MadData.transactionID;
3012                 *hash_key = add_address_to_hash64(*hash_key, &pinfo->src);
3013                 g_hash_table_replace(CM_context_table, hash_key, connection);
3014
3015                 /* Now we create a conversation for the CM exchange. This uses both
3016                    sides of the conversation since CM packets also include the source
3017                    QPN */
3018                 proto_data = wmem_new(wmem_file_scope(), conversation_infiniband_data);
3019                 proto_data->service_id = connection->service_id;
3020
3021                 conv = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst,
3022                                         PT_IBQP, pinfo->srcport, pinfo->destport, 0);
3023                 conversation_add_proto_data(conv, proto_infiniband, proto_data);
3024             }
3025
3026             /* give a chance for subdissectors to analyze the private data */
3027             next_tvb = tvb_new_subset(tvb, local_offset, 92, -1);
3028             if (! dissector_try_heuristic(heur_dissectors_cm_private, next_tvb, pinfo, parentTree, NULL) )
3029                 /* if none reported success, add this as raw "data" */
3030                 proto_tree_add_item(CM_header_tree, hf_cm_req_private_data, tvb, local_offset, 92, ENC_NA);
3031
3032             local_offset += 92;
3033         }
3034             break;
3035         case ATTR_CM_REP: {
3036             guint32 remote_qpn;
3037             proto_tree_add_item(CM_header_tree, hf_cm_rep_localcommid, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3038             proto_tree_add_item(CM_header_tree, hf_cm_rep_remotecommid, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3039             proto_tree_add_item(CM_header_tree, hf_cm_rep_localqkey, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3040             proto_tree_add_item(CM_header_tree, hf_cm_rep_localqpn, tvb, local_offset, 3, ENC_BIG_ENDIAN);
3041             remote_qpn = tvb_get_ntoh24(tvb, local_offset); local_offset += 3;
3042             local_offset += 1;  /* skip reserved */
3043             proto_tree_add_item(CM_header_tree, hf_cm_rep_localeecontnum, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
3044             local_offset += 1;  /* skip reserved */
3045             proto_tree_add_item(CM_header_tree, hf_cm_rep_startingpsn, tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
3046             local_offset += 1;  /* skip reserved */
3047             proto_tree_add_item(CM_header_tree, hf_cm_rep_responderres, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3048             proto_tree_add_item(CM_header_tree, hf_cm_rep_initiatordepth, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3049             proto_tree_add_item(CM_header_tree, hf_cm_rep_tgtackdelay, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3050             proto_tree_add_item(CM_header_tree, hf_cm_rep_failoveracc, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3051             proto_tree_add_item(CM_header_tree, hf_cm_rep_e2eflowctl, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3052             proto_tree_add_item(CM_header_tree, hf_cm_rep_rnrretrycount, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3053             proto_tree_add_item(CM_header_tree, hf_cm_rep_srq, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3054             local_offset += 1;  /* skip reserved */
3055             proto_tree_add_item(CM_header_tree, hf_cm_rep_localcaguid, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
3056
3057             /* the following saves information about the conversation this packet defines,
3058                so there's no point in doing it more than once per packet */
3059             if (!pinfo->fd->flags.visited)
3060             {
3061                 /* get the previously saved context for this connection */
3062                 connection_context *connection;
3063                 guint64 hash_key;
3064                 hash_key = MadData.transactionID;
3065                 hash_key = add_address_to_hash64(hash_key, &pinfo->dst);
3066                 connection = (connection_context *)g_hash_table_lookup(CM_context_table, &hash_key);
3067
3068                 /* if an appropriate connection was not found there's something wrong, but nothing we can
3069                    do about it here - so just skip saving the context */
3070                 if (connection)
3071                 {
3072                     address req_addr,
3073                             resp_addr;  /* we'll fill these in and pass them to conversation_new */
3074                     conversation_t *conv;
3075                     conversation_infiniband_data *proto_data = NULL;
3076
3077                     connection->resp_qp = remote_qpn;
3078
3079                     proto_data = wmem_new(wmem_file_scope(), conversation_infiniband_data);
3080                     proto_data->service_id = connection->service_id;
3081
3082                     /* RC traffic never(?) includes a field indicating the source QPN, so
3083                        the destination host knows it only from previous context (a single
3084                        QPN on the host that is part of an RC can only receive traffic from
3085                        that RC). For this reason we do not register conversations with both
3086                        sides, but rather we register the same conversation twice - once for
3087                        each side of the Reliable Connection. */
3088
3089                     /* first register the conversation using the GIDs */
3090                     SET_ADDRESS(&req_addr, AT_IB, GID_SIZE, connection->req_gid);
3091                     SET_ADDRESS(&resp_addr, AT_IB, GID_SIZE, connection->resp_gid);
3092
3093                     conv = conversation_new(pinfo->fd->num, &req_addr, &req_addr,
3094                                             PT_IBQP, connection->req_qp, connection->req_qp, NO_ADDR2|NO_PORT2);
3095                     conversation_add_proto_data(conv, proto_infiniband, proto_data);
3096                     conv = conversation_new(pinfo->fd->num, &resp_addr, &resp_addr,
3097                                             PT_IBQP, connection->resp_qp, connection->resp_qp, NO_ADDR2|NO_PORT2);
3098                     conversation_add_proto_data(conv, proto_infiniband, proto_data);
3099
3100                     /* next, register the conversation using the LIDs */
3101                     SET_ADDRESS(&req_addr, AT_IB, sizeof(guint16), &(connection->req_lid));
3102                     SET_ADDRESS(&resp_addr, AT_IB, sizeof(guint16), &(connection->resp_lid));
3103
3104                     conv = conversation_new(pinfo->fd->num, &req_addr, &req_addr,
3105                                             PT_IBQP, connection->req_qp, connection->req_qp, NO_ADDR2|NO_PORT2);
3106                     conversation_add_proto_data(conv, proto_infiniband, proto_data);
3107                     conv = conversation_new(pinfo->fd->num, &resp_addr, &resp_addr,
3108                                             PT_IBQP, connection->resp_qp, connection->resp_qp, NO_ADDR2|NO_PORT2);
3109                     conversation_add_proto_data(conv, proto_infiniband, proto_data);
3110
3111                     g_hash_table_remove(CM_context_table, &hash_key);
3112                 }
3113             }
3114
3115             /* give a chance for subdissectors to get the private data */
3116             next_tvb = tvb_new_subset(tvb, local_offset, 196, -1);
3117             if (! dissector_try_heuristic(heur_dissectors_cm_private, next_tvb, pinfo, parentTree, NULL) )
3118                 /* if none reported success, add this as raw "data" */
3119                 proto_tree_add_item(CM_header_tree, hf_cm_rep_privatedata, tvb, local_offset, 196, ENC_NA);
3120
3121             local_offset += 196;
3122         }
3123             break;
3124         case ATTR_CM_RTU:
3125             proto_tree_add_item(CM_header_tree, hf_cm_rtu_localcommid, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3126             proto_tree_add_item(CM_header_tree, hf_cm_rtu_remotecommid, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3127             /* currently only REQ/REP call subdissectors for the private data */
3128             proto_tree_add_item(CM_header_tree, hf_cm_rtu_privatedata, tvb, local_offset, 224, ENC_NA); local_offset += 224;
3129             break;
3130         case ATTR_CM_REJ:
3131             proto_tree_add_item(CM_header_tree, hf_cm_rej_local_commid, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3132             proto_tree_add_item(CM_header_tree, hf_cm_rej_remote_commid, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3133             proto_tree_add_item(CM_header_tree, hf_cm_rej_msg_rej, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3134             local_offset += 1;  /* skip reserved */
3135             proto_tree_add_item(CM_header_tree, hf_cm_rej_rej_info_len, tvb, local_offset, 1, ENC_BIG_ENDIAN);
3136             local_offset += 1;  /* skip reserved */
3137             proto_tree_add_item(CM_header_tree, hf_cm_rej_reason, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3138             proto_tree_add_item(CM_header_tree, hf_cm_rej_add_rej_info, tvb, local_offset, 72, ENC_NA); local_offset += 72;
3139             /* currently only REQ/REP call subdissectors for the private data */
3140             proto_tree_add_item(CM_header_tree, hf_cm_rej_private_data, tvb, local_offset, 148, ENC_NA); local_offset += 148;
3141             break;
3142         default:
3143             proto_item_append_text(CM_header_item, " (Dissector Not Implemented)"); local_offset += MAD_DATA_SIZE;
3144             break;
3145     }
3146
3147     *offset = local_offset;
3148 }
3149
3150 /* Parse SNMP Tunneling
3151 * IN: parentTree to add the dissection to
3152 * IN: tvb - the data buffer from wireshark
3153 * IN/OUT: The current and updated offset */
3154 static void parse_SNMP(proto_tree *parentTree, tvbuff_t *tvb, gint *offset)
3155 {
3156     /* Parse the Common MAD Header */
3157     MAD_Data    MadData;
3158     gint        local_offset;
3159     proto_item *PERF_header_item;
3160
3161     if (!parse_MAD_Common(parentTree, tvb, offset, &MadData))
3162     {
3163         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
3164         return;
3165     }
3166     local_offset = *offset;
3167
3168     PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, MAD_DATA_SIZE, ENC_NA); local_offset += MAD_DATA_SIZE;
3169     proto_item_set_text(PERF_header_item, "%s", "SNMP - SNMP Tunneling MAD (Dissector Not Implemented)");
3170     *offset = local_offset;
3171 }
3172
3173 /* Parse Vendor Specific Management Packets
3174 * IN: parentTree to add the dissection to
3175 * IN: tvb - the data buffer from wireshark
3176 * IN/OUT: The current and updated offset */
3177 static void parse_VENDOR_MANAGEMENT(proto_tree *parentTree, tvbuff_t *tvb, gint *offset)
3178 {
3179     /* Parse the Common MAD Header */
3180     MAD_Data    MadData;
3181     gint        local_offset;
3182     proto_item *PERF_header_item;
3183
3184     if (!parse_MAD_Common(parentTree, tvb, offset, &MadData))
3185     {
3186         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
3187         return;
3188     }
3189     local_offset = *offset;
3190
3191     PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, MAD_DATA_SIZE, ENC_NA); local_offset += MAD_DATA_SIZE;
3192     proto_item_set_text(PERF_header_item, "%s", "VENDOR - Vendor Specific Management MAD (Dissector Not Implemented)");
3193     *offset = local_offset;
3194 }
3195
3196 /* Parse Application Specific Management Packets
3197 * IN: parentTree to add the dissection to
3198 * IN: tvb - the data buffer from wireshark
3199 * IN/OUT: The current and updated offset */
3200 static void parse_APPLICATION_MANAGEMENT(proto_tree *parentTree, tvbuff_t *tvb, gint *offset)
3201 {
3202     /* Parse the Common MAD Header */
3203     MAD_Data    MadData;
3204     gint        local_offset;
3205     proto_item *PERF_header_item;
3206
3207     if (!parse_MAD_Common(parentTree, tvb, offset, &MadData))
3208     {
3209         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
3210         return;
3211     }
3212     local_offset = *offset;
3213     PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, MAD_DATA_SIZE, ENC_NA); local_offset += MAD_DATA_SIZE;
3214     proto_item_set_text(PERF_header_item, "%s", "APP - Application Specific MAD (Dissector Not Implemented)");
3215     *offset = local_offset;
3216 }
3217
3218 /* Parse Reserved Management Packets.
3219
3220 * This is an !ERROR CONDITION!
3221 * It means that the Management Class value used was defined as a reserved value for furture use.
3222 * This method is here since we will want to report this information directly to the UI without blowing up Wireshark.
3223
3224 * IN: parentTree to add the dissection to
3225 * IN: tvb - the data buffer from wireshark
3226 * IN/OUT: The current and updated offset */
3227 static void parse_RESERVED_MANAGEMENT(proto_tree *parentTree, tvbuff_t *tvb, gint *offset)
3228 {
3229     /* Parse the Common MAD Header */
3230     MAD_Data    MadData;
3231     gint        local_offset;
3232     proto_item *PERF_header_item;
3233
3234     if (!parse_MAD_Common(parentTree, tvb, offset, &MadData))
3235     {
3236         /* TODO: Mark Corrupt Packet - Not enough bytes exist for at least the Common MAD header which is present in all MAD packets */
3237         return;
3238     }
3239     local_offset = *offset;
3240     PERF_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 256, ENC_NA); local_offset += 256;
3241     proto_item_set_text(PERF_header_item, "%s", "RESERVED - Reserved MAD Type (Possible Device Error)");
3242     *offset = local_offset;
3243 }
3244
3245 /* Parse the common MAD Header
3246 * IN: parentTree to add the dissection to
3247 * IN: tvb - the data buffer from wireshark
3248 * IN/OUT: The current and updated offset
3249 * IN/OUT: MadData - the data from the MAD header */
3250 static gboolean parse_MAD_Common(proto_tree *parentTree, tvbuff_t *tvb, gint *offset, MAD_Data* MadData)
3251 {
3252     gint        local_offset = *offset;
3253     proto_item *MAD_header_item;
3254     proto_tree *MAD_header_tree;
3255
3256     if (MadData == NULL)
3257         return FALSE;
3258     if (!tvb_bytes_exist(tvb, *offset, 256))
3259         return FALSE;
3260
3261     /* Get the Management Class to decide between LID Routed and Direct Route */
3262     MadData->managementClass =      tvb_get_guint8(tvb, local_offset + 1);
3263     MadData->classVersion =         tvb_get_guint8(tvb, local_offset + 2);
3264     MadData->method =               tvb_get_guint8(tvb, local_offset + 3);
3265     MadData->status =               tvb_get_guint8(tvb, local_offset + 4);
3266     MadData->classSpecific =        tvb_get_ntohs(tvb, local_offset + 6);
3267     MadData->transactionID =        tvb_get_ntoh64(tvb, local_offset + 8);
3268     MadData->attributeID =          tvb_get_ntohs(tvb, local_offset + 16);
3269     MadData->attributeModifier =    tvb_get_ntohl(tvb, local_offset + 20);
3270     tvb_memcpy(tvb, MadData->data, local_offset + 24, MAD_DATA_SIZE);
3271
3272     /* Populate the Dissector Tree */
3273
3274     MAD_header_item = proto_tree_add_item(parentTree, hf_infiniband_MAD, tvb, local_offset, 256, ENC_NA);
3275     proto_item_set_text(MAD_header_item, "%s", "MAD Header - Common Management Datagram");
3276     MAD_header_tree = proto_item_add_subtree(MAD_header_item, ett_mad);
3277
3278     proto_tree_add_item(MAD_header_tree, hf_infiniband_base_version,        tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3279     proto_tree_add_item(MAD_header_tree, hf_infiniband_mgmt_class,          tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3280     proto_tree_add_item(MAD_header_tree, hf_infiniband_class_version,       tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3281     proto_tree_add_item(MAD_header_tree, hf_infiniband_method,              tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3282     proto_tree_add_item(MAD_header_tree, hf_infiniband_status,              tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3283     proto_tree_add_item(MAD_header_tree, hf_infiniband_class_specific,      tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3284     proto_tree_add_item(MAD_header_tree, hf_infiniband_transaction_id,      tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
3285     proto_tree_add_item(MAD_header_tree, hf_infiniband_attribute_id,        tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3286     proto_tree_add_item(MAD_header_tree, hf_infiniband_reserved16,          tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3287     proto_tree_add_item(MAD_header_tree, hf_infiniband_attribute_modifier,  tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3288     proto_tree_add_item(MAD_header_tree, hf_infiniband_data,                tvb, local_offset, MAD_DATA_SIZE, ENC_NA);
3289     *offset = local_offset; /* Move the offset to the start of the Data field - this will be where the other parsers start. */
3290
3291     return TRUE;
3292 }
3293
3294 /* Parse the RMPP (Reliable Multi-Packet Transaction Protocol
3295 * IN: parentTree to add the dissection to
3296 * IN: tvb - the data buffer from wireshark
3297 * IN/OUT: The current and updated offset */
3298 static gboolean parse_RMPP(proto_tree *parentTree, tvbuff_t *tvb, gint *offset)
3299 {
3300     gint        local_offset = *offset;
3301     guint8      RMPP_Type    = tvb_get_guint8(tvb, local_offset + 1);
3302     proto_item *RMPP_header_item;
3303     proto_tree *RMPP_header_tree;
3304
3305     RMPP_header_item = proto_tree_add_item(parentTree, hf_infiniband_RMPP, tvb, local_offset, 12, ENC_NA);
3306     proto_item_set_text(RMPP_header_item, "%s", val_to_str(RMPP_Type, RMPP_Packet_Types, "Reserved RMPP Type! (0x%02x)"));
3307     RMPP_header_tree = proto_item_add_subtree(RMPP_header_item, ett_rmpp);
3308
3309     proto_tree_add_item(RMPP_header_tree, hf_infiniband_rmpp_version,   tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3310     proto_tree_add_item(RMPP_header_tree, hf_infiniband_rmpp_type,      tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3311     proto_tree_add_item(RMPP_header_tree, hf_infiniband_r_resp_time,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
3312     proto_tree_add_item(RMPP_header_tree, hf_infiniband_rmpp_flags,     tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3313     proto_tree_add_item(RMPP_header_tree, hf_infiniband_rmpp_status,    tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3314     switch (RMPP_Type)
3315     {
3316         case RMPP_ILLEGAL:
3317             proto_tree_add_item(RMPP_header_tree, hf_infiniband_rmpp_data1,     tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3318             proto_tree_add_item(RMPP_header_tree, hf_infiniband_rmpp_data2,     tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3319             break;
3320         case RMPP_DATA:
3321             proto_tree_add_item(RMPP_header_tree, hf_infiniband_segment_number,     tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3322             proto_tree_add_item(RMPP_header_tree, hf_infiniband_payload_length32,   tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3323             proto_tree_add_item(RMPP_header_tree, hf_infiniband_transferred_data,   tvb, local_offset, 220, ENC_NA);
3324             break;
3325         case RMPP_ACK:
3326             proto_tree_add_item(RMPP_header_tree, hf_infiniband_segment_number,     tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3327             proto_tree_add_item(RMPP_header_tree, hf_infiniband_new_window_last,    tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3328             proto_tree_add_item(RMPP_header_tree, hf_infiniband_reserved220,        tvb, local_offset, 220, ENC_NA);
3329             break;
3330         case RMPP_STOP:
3331         case RMPP_ABORT:
3332             proto_tree_add_item(RMPP_header_tree, hf_infiniband_reserved32,                     tvb, local_offset, 4, ENC_NA); local_offset += 4;
3333             proto_tree_add_item(RMPP_header_tree, hf_infiniband_reserved32,                     tvb, local_offset, 4, ENC_NA); local_offset += 4;
3334             proto_tree_add_item(RMPP_header_tree, hf_infiniband_optional_extended_error_data,   tvb, local_offset, 220, ENC_NA);
3335             break;
3336         default:
3337             break;
3338     }
3339     *offset = local_offset;
3340     return TRUE;
3341 }
3342
3343 /* Parse the Method from the MAD Common Header.
3344 * Simply used to generate the identifier.
3345 * IN: SubMItem - the item to append the method label to.
3346 * IN: MadHeader - the MadData structure that contains the information from the Common MAD header.
3347 * IN: pinfo - packet info from wireshark. */
3348 static void label_SUBM_Method(proto_item *SubMItem, MAD_Data *MadHeader, packet_info *pinfo)
3349 {
3350     const char *label = val_to_str_const(MadHeader->method, SUBM_Methods, "(Unknown SubManagement Method!)");
3351
3352     proto_item_append_text(SubMItem, "%s", label);
3353     col_append_str(pinfo->cinfo, COL_INFO, label);
3354 }
3355
3356 /* Parse the SA Method from the MAD Common Header.
3357 * Simply used to generate the identifier.
3358 * IN: SubAItem - the item to append the method label to.
3359 * IN: MadHeader - the MadData structure that contains the information from the Common MAD header.
3360 * IN: pinfo - packet info from wireshark. */
3361 static void label_SUBA_Method(proto_item *SubAItem, MAD_Data *MadHeader, packet_info *pinfo)
3362 {
3363     const char *label = val_to_str_const(MadHeader->method, SUBA_Methods, "(Unknown SubAdministration Method!)");
3364
3365     proto_item_append_text(SubAItem, "%s", label);
3366     col_append_str(pinfo->cinfo, COL_INFO, label);
3367 }
3368
3369 /* Parse the Attribute from the MAD Common Header
3370 * Simply used to generate the identifier.
3371 * IN: SubMItem - the item to append the Attribute label to.
3372 * IN: MadHeader - the MadData structure that contains the information from the Common MAD header.
3373 * IN: pinfo - packet info from wireshark. */
3374 static void label_SUBM_Attribute(proto_item *SubMItem, MAD_Data *MadHeader, packet_info *pinfo)
3375 {
3376     const char *label = val_to_str_const(MadHeader->attributeID, SUBM_Attributes, "(Unknown SubManagement Attribute!)");
3377
3378     proto_item_append_text(SubMItem, "%s", &label[11]);
3379     col_append_str(pinfo->cinfo, COL_INFO, &label[11]);
3380 }
3381
3382 /* Parse the SA Attribute from the MAD Common Header
3383 * Simply used to generate the identifier.
3384 * IN: SubAItem - the item to append the Attribute label to.
3385 * IN: MadHeader - the MadData structure that contains the information from the Common MAD header.
3386 * IN: pinfo - packet info from wireshark. */
3387 static void label_SUBA_Attribute(proto_item *SubAItem, MAD_Data *MadHeader, packet_info *pinfo)
3388 {
3389     const char *label = val_to_str_const(MadHeader->attributeID, SUBA_Attributes, "(Unknown SubAdministration Attribute!)");
3390
3391     proto_item_append_text(SubAItem, "%s", &label[11]);
3392     col_append_str(pinfo->cinfo, COL_INFO, &label[11]);
3393 }
3394
3395 /* Parse the attribute from a Subnet Management Packet.
3396 * IN: Parent Tree to add the item to in the dissection tree
3397 * IN: tvbuff, offset - the data and where it is.
3398 * IN: MAD_Data the data from the Common MAD Header that provides the information we need */
3399 static gboolean parse_SUBM_Attribute(proto_tree *parentTree, tvbuff_t *tvb, gint *offset, MAD_Data *MadHeader)
3400 {
3401     guint16     attributeID = MadHeader->attributeID;
3402     proto_item *SUBM_Attribute_header_item;
3403     proto_tree *SUBM_Attribute_header_tree;
3404
3405     SUBM_Attribute_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, *offset, 64, ENC_NA);
3406     proto_item_set_text(SUBM_Attribute_header_item, "%s", val_to_str(attributeID, SUBM_Attributes, "Unknown Attribute Type! (0x%02x)"));
3407     SUBM_Attribute_header_tree = proto_item_add_subtree(SUBM_Attribute_header_item, ett_subm_attribute);
3408
3409
3410     switch (attributeID)
3411     {
3412         case 0x0002:
3413             parse_NoticesAndTraps(SUBM_Attribute_header_tree , tvb, offset);
3414             break;
3415         case 0x0010:
3416              parse_NodeDescription(SUBM_Attribute_header_tree , tvb, offset);
3417             break;
3418         case 0x0011:
3419             parse_NodeInfo(SUBM_Attribute_header_tree , tvb, offset);
3420             break;
3421         case 0x0012:
3422             parse_SwitchInfo(SUBM_Attribute_header_tree , tvb, offset);
3423             break;
3424         case 0x0014:
3425             parse_GUIDInfo(SUBM_Attribute_header_tree , tvb, offset);
3426             break;
3427         case 0x0015:
3428             parse_PortInfo(SUBM_Attribute_header_tree , tvb, offset);
3429             break;
3430         case 0x0016:
3431             parse_P_KeyTable(SUBM_Attribute_header_tree , tvb, offset);
3432             break;
3433         case 0x0017:
3434             parse_SLtoVLMappingTable(SUBM_Attribute_header_tree , tvb, offset);
3435             break;
3436         case 0x0018:
3437             parse_VLArbitrationTable(SUBM_Attribute_header_tree , tvb, offset);
3438             break;
3439         case 0x0019:
3440             parse_LinearForwardingTable(SUBM_Attribute_header_tree , tvb, offset);
3441             break;
3442         case 0x001A:
3443             parse_RandomForwardingTable(SUBM_Attribute_header_tree , tvb, offset);
3444             break;
3445         case 0x001B:
3446             parse_MulticastForwardingTable(SUBM_Attribute_header_tree , tvb, offset);
3447             break;
3448         case 0x001C:
3449             parse_SMInfo(SUBM_Attribute_header_tree , tvb, offset);
3450             break;
3451         case 0x0020:
3452             parse_VendorDiag(SUBM_Attribute_header_tree , tvb, offset);
3453             break;
3454         case 0x0030:
3455             parse_LedInfo(SUBM_Attribute_header_tree , tvb, offset);
3456             break;
3457         case 0x0031:
3458             parse_LinkSpeedWidthPairsTable(SUBM_Attribute_header_tree , tvb, offset);
3459             break;
3460         default:
3461             break;
3462     }
3463
3464
3465     *offset += 64;
3466     return TRUE;
3467
3468 }
3469 /* Parse the attribute from a Subnet Administration Packet.
3470 * IN: Parent Tree to add the item to in the dissection tree
3471 * IN: tvbuff, offset - the data and where it is.
3472 * IN: MAD_Data the data from the Common MAD Header that provides the information we need */
3473 static gboolean parse_SUBA_Attribute(proto_tree *parentTree, tvbuff_t *tvb, gint *offset, MAD_Data *MadHeader)
3474 {
3475     guint16     attributeID = MadHeader->attributeID;
3476     proto_item *SUBA_Attribute_header_item;
3477     proto_tree *SUBA_Attribute_header_tree;
3478
3479     SUBA_Attribute_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, *offset, 200, ENC_NA);
3480     proto_item_set_text(SUBA_Attribute_header_item, "%s", val_to_str(attributeID, SUBA_Attributes, "Unknown Attribute Type! (0x%02x)"));
3481     SUBA_Attribute_header_tree = proto_item_add_subtree(SUBA_Attribute_header_item, ett_suba_attribute);
3482
3483     /* Skim off the RID fields should they be present */
3484     parse_RID(SUBA_Attribute_header_tree, tvb, offset, MadHeader);
3485
3486     /* Parse the rest of the attributes */
3487     switch (MadHeader->attributeID)
3488     {
3489         case 0x0001: /* (ClassPortInfo) */
3490             parse_PortInfo(SUBA_Attribute_header_tree, tvb, offset);
3491             break;
3492         case 0x0002: /* (Notice) */
3493             parse_NoticesAndTraps(SUBA_Attribute_header_tree, tvb, offset);
3494             break;
3495         case 0x0003: /* (InformInfo) */
3496             parse_InformInfo(SUBA_Attribute_header_tree, tvb, offset);
3497             break;
3498         case 0x0011: /* (NodeRecord) */
3499             parse_NodeInfo(SUBA_Attribute_header_tree, tvb, offset);
3500             *offset += 40;
3501             parse_NodeDescription(SUBA_Attribute_header_tree, tvb, offset);
3502             break;
3503         case 0x0012: /* (PortInfoRecord) */
3504             parse_PortInfo(SUBA_Attribute_header_tree, tvb, offset);
3505             break;
3506         case 0x0013: /* (SLtoVLMappingTableRecord) */
3507             parse_SLtoVLMappingTable(SUBA_Attribute_header_tree, tvb, offset);
3508             break;
3509         case 0x0014: /* (SwitchInfoRecord) */
3510             parse_SwitchInfo(SUBA_Attribute_header_tree, tvb, offset);
3511             break;
3512         case 0x0015: /*(LinearForwardingTableRecord) */
3513             parse_LinearForwardingTable(SUBA_Attribute_header_tree, tvb, offset);
3514             break;
3515         case 0x0016: /* (RandomForwardingTableRecord) */
3516             parse_RandomForwardingTable(SUBA_Attribute_header_tree, tvb, offset);
3517             break;
3518         case 0x0017: /* (MulticastForwardingTableRecord) */
3519             parse_MulticastForwardingTable(SUBA_Attribute_header_tree, tvb, offset);
3520             break;
3521         case 0x0018: /* (SMInfoRecord) */
3522             parse_SMInfo(SUBA_Attribute_header_tree, tvb, offset);
3523             break;
3524         case 0x0019: /* (LinkSpeedWidthPairsTableRecord) */
3525             parse_LinkSpeedWidthPairsTable(SUBA_Attribute_header_tree, tvb, offset);
3526             break;
3527         case 0x00F3: /*(InformInfoRecord) */
3528             parse_InformInfo(SUBA_Attribute_header_tree, tvb, offset);
3529             break;
3530         case 0x0020: /* (LinkRecord) */
3531             parse_LinkRecord(SUBA_Attribute_header_tree, tvb, offset);
3532             break;
3533         case 0x0030: /* (GuidInforecord) */
3534             parse_GUIDInfo(SUBA_Attribute_header_tree, tvb, offset);
3535             break;
3536         case 0x0031: /*(ServiceRecord) */
3537             parse_ServiceRecord(SUBA_Attribute_header_tree, tvb, offset);
3538             break;
3539         case 0x0033: /* (P_KeyTableRecord) */
3540             parse_P_KeyTable(SUBA_Attribute_header_tree, tvb, offset);
3541             break;
3542         case 0x0035: /* (PathRecord) */
3543             parse_PathRecord(SUBA_Attribute_header_tree, tvb, offset);
3544             break;
3545         case 0x0036: /* (VLArbitrationTableRecord) */
3546             parse_VLArbitrationTable(SUBA_Attribute_header_tree, tvb, offset);
3547             break;
3548         case 0x0038: /* (MCMemberRecord) */
3549             parse_MCMemberRecord(SUBA_Attribute_header_tree, tvb, offset);
3550             break;
3551         case 0x0039: /* (TraceRecord) */
3552             parse_TraceRecord(SUBA_Attribute_header_tree, tvb, offset);
3553             break;
3554         case 0x003A: /* (MultiPathRecord) */
3555             parse_MultiPathRecord(SUBA_Attribute_header_tree, tvb, offset);
3556             break;
3557         case 0x003B: /* (ServiceAssociationRecord) */
3558             parse_ServiceAssociationRecord(SUBA_Attribute_header_tree, tvb, offset);
3559             break;
3560         default: /* (Unknown SubAdministration Attribute!) */
3561             /* We've already labeled as unknown in item construction */
3562             break;
3563     }
3564
3565     *offset += 200;
3566     return TRUE;
3567 }
3568
3569 /* Subnet Management Attribute Parsing Methods.
3570 *  Also Parsing for Attributes common to both SM/SA.
3571 * The Subnet Admin Parsing methods will call some of these methods when an attribute is present within an SA MAD
3572 */
3573
3574
3575 /* Parse NoticeDataDetails Attribute Field
3576 * IN:   parentTree - The tree to add the dissection to
3577 *       tvb - The tvbbuff of packet data
3578 *       offset - The offset in TVB where the attribute begins
3579 *       trapNumber - The Trap ID of the Trap Data being Dissected  */
3580
3581 static gint parse_NoticeDataDetails(proto_tree* parentTree, tvbuff_t* tvb, gint *offset, guint16 trapNumber)
3582 {
3583     gint        local_offset = *offset;
3584     proto_item *DataDetails_header_item;
3585     proto_tree *DataDetails_header_tree;
3586
3587     if (!parentTree)
3588         return 0;
3589
3590     DataDetails_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 54, ENC_NA);
3591     DataDetails_header_tree = proto_item_add_subtree(DataDetails_header_item, ett_datadetails);
3592
3593
3594     switch (trapNumber)
3595     {
3596         case 64:
3597             proto_item_set_text(DataDetails_header_item, "%s", "Trap 64 DataDetails");
3598             local_offset += 6;
3599             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR,    tvb, local_offset, 16, ENC_NA);  local_offset += 16;
3600         break;
3601         case 65:
3602             proto_item_set_text(DataDetails_header_item, "%s", "Trap 65 DataDetails");
3603             local_offset += 6;
3604             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR,    tvb, local_offset, 16, ENC_NA);  local_offset += 16;
3605         break;
3606         case 66:
3607             proto_item_set_text(DataDetails_header_item, "%s", "Trap 66 DataDetails");
3608             local_offset += 6;
3609             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR,    tvb, local_offset, 16, ENC_NA);  local_offset += 16;
3610         break;
3611         case 67:
3612             proto_item_set_text(DataDetails_header_item, "%s", "Trap 67 DataDetails");
3613             local_offset += 6;
3614             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR,    tvb, local_offset, 16, ENC_NA);  local_offset += 16;
3615         break;
3616         case 68:
3617             proto_item_set_text(DataDetails_header_item, "%s", "Trap 68 DataDetails");
3618             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_COMP_MASK,          tvb, local_offset, 8, ENC_BIG_ENDIAN);  local_offset += 8;
3619             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_WAIT_FOR_REPATH,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
3620         break;
3621         case 69:
3622             proto_item_set_text(DataDetails_header_item, "%s", "Trap 69 DataDetails");
3623             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_COMP_MASK,          tvb, local_offset, 8, ENC_BIG_ENDIAN);  local_offset += 8;
3624             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_WAIT_FOR_REPATH,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
3625         break;
3626         case 128:
3627             proto_item_set_text(DataDetails_header_item, "%s", "Trap 128 DataDetails");
3628             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR,        tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset += 2;
3629         break;
3630         case 129:
3631             proto_item_set_text(DataDetails_header_item, "%s", "Trap 129 DataDetails");
3632             local_offset += 2;
3633             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR,        tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset += 2;
3634             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_PORTNO,         tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset += 1;
3635         break;
3636         case 130:
3637             proto_item_set_text(DataDetails_header_item, "%s", "Trap 130 DataDetails");
3638             local_offset += 2;
3639             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR,        tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset += 2;
3640             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_PORTNO,         tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset += 1;
3641         break;
3642         case 131:
3643             proto_item_set_text(DataDetails_header_item, "%s", "Trap 131 DataDetails");
3644             local_offset += 2;
3645             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR,        tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset += 2;
3646             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_PORTNO,         tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset += 1;
3647         break;
3648         case 144:
3649             proto_item_set_text(DataDetails_header_item, "%s", "Trap 144 DataDetails");
3650             local_offset += 2;
3651             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR,        tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset += 2;
3652             local_offset += 1;
3653             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_OtherLocalChanges,      tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset += 1;
3654             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_CAPABILITYMASK,     tvb, local_offset, 4, ENC_BIG_ENDIAN);  local_offset += 4;
3655             local_offset += 1;
3656             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LinkSpeecEnabledChange,     tvb, local_offset, 1, ENC_BIG_ENDIAN);
3657             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LinkWidthEnabledChange,     tvb, local_offset, 1, ENC_BIG_ENDIAN);
3658             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_NodeDescriptionChange,      tvb, local_offset, 1, ENC_BIG_ENDIAN);
3659         break;
3660         case 145:
3661             proto_item_set_text(DataDetails_header_item, "%s", "Trap 145 DataDetails");
3662             local_offset += 2;
3663             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR,        tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset += 2;
3664             local_offset += 2;
3665             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_SYSTEMIMAGEGUID,        tvb, local_offset, 8, ENC_BIG_ENDIAN);  local_offset += 8;
3666         break;
3667         case 256:
3668             proto_item_set_text(DataDetails_header_item, "%s", "Trap 256 DataDetails");
3669             local_offset += 2;
3670             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR,            tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset += 2;
3671             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_DRSLID,             tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset += 2;
3672             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_METHOD,             tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset += 1;
3673             local_offset += 1;
3674             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_ATTRIBUTEID,        tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset += 2;
3675             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_ATTRIBUTEMODIFIER,  tvb, local_offset, 4, ENC_BIG_ENDIAN);  local_offset += 4;
3676             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_MKEY,               tvb, local_offset, 8, ENC_BIG_ENDIAN);  local_offset += 8;
3677             local_offset += 1;
3678             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_DRNotice,           tvb, local_offset, 1, ENC_BIG_ENDIAN);
3679             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_DRPathTruncated,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
3680             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_DRHopCount,         tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset += 1;
3681             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_DRNoticeReturnPath, tvb, local_offset, 30, ENC_NA);  local_offset += 30;
3682         break;
3683         case 257:
3684             proto_item_set_text(DataDetails_header_item, "%s", "Trap 257 DataDetails");
3685             local_offset += 2;
3686             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR1,   tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset += 2;
3687             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR2,   tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset += 2;
3688             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_KEY,        tvb, local_offset, 4, ENC_BIG_ENDIAN);  local_offset += 4;
3689             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_SL,         tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset += 1;
3690             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_QP1,        tvb, local_offset, 3, ENC_BIG_ENDIAN);  local_offset += 3;
3691             local_offset += 1;
3692             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_QP2,        tvb, local_offset, 3, ENC_BIG_ENDIAN);  local_offset += 3;
3693             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR1,   tvb, local_offset, 16, ENC_NA);  local_offset += 16;
3694             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR2,   tvb, local_offset, 16, ENC_NA);  local_offset += 16;
3695         break;
3696         case 258:
3697             proto_item_set_text(DataDetails_header_item, "%s", "Trap 258 DataDetails");
3698             local_offset += 2;
3699             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR1,   tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset += 2;
3700             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR2,   tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset += 2;
3701             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_KEY,        tvb, local_offset, 4, ENC_BIG_ENDIAN);  local_offset += 4;
3702             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_SL,         tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset  += 1;
3703             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_QP1,        tvb, local_offset, 3, ENC_BIG_ENDIAN);  local_offset += 3;
3704             local_offset += 1;
3705             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_QP2,        tvb, local_offset, 3, ENC_BIG_ENDIAN);  local_offset += 3;
3706             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR1,   tvb, local_offset, 16, ENC_NA);  local_offset += 16;
3707             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR2,   tvb, local_offset, 16, ENC_NA);  local_offset += 16;
3708         break;
3709         case 259:
3710             proto_item_set_text(DataDetails_header_item, "%s", "Trap 259 DataDetails");
3711             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_DataValid,  tvb, local_offset, 2, ENC_NA);  local_offset += 2;
3712             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR1,   tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset += 2;
3713             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_LIDADDR2,   tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset += 2;
3714             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_PKEY,       tvb, local_offset, 2, ENC_BIG_ENDIAN);  local_offset += 2;
3715             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_SL,         tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset += 1;
3716             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_QP1,        tvb, local_offset, 3, ENC_BIG_ENDIAN);  local_offset += 3;
3717             local_offset += 1;
3718             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_QP2,        tvb, local_offset, 3, ENC_BIG_ENDIAN);  local_offset += 3;
3719             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR1,   tvb, local_offset, 16, ENC_NA);  local_offset += 16;
3720             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_GIDADDR2,   tvb, local_offset, 16, ENC_NA);  local_offset += 16;
3721             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_SWLIDADDR,  tvb, local_offset, 2, ENC_NA);  local_offset += 2;
3722             proto_tree_add_item(DataDetails_header_tree, hf_infiniband_Trap_PORTNO,     tvb, local_offset, 1, ENC_BIG_ENDIAN);  local_offset += 1;
3723         break;
3724         default:
3725             proto_item_set_text(DataDetails_header_item, "%s", "Vendor Specific Subnet Management Trap"); local_offset += 54;
3726             break;
3727     }
3728
3729     return local_offset;
3730 }
3731
3732 /* Parse NoticesAndTraps Attribute
3733 * IN:   parentTree - The tree to add the dissection to
3734 *       tvb - The tvbbuff of packet data
3735 *       offset - The offset in TVB where the attribute begins
3736 *       MadHeader - The common MAD header of the current SMP/SMA  */
3737 static void parse_NoticesAndTraps(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
3738 {
3739     gint        local_offset = *offset;
3740     proto_item *NoticesAndTraps_header_item;
3741     proto_tree *NoticesAndTraps_header_tree;
3742     guint16     trapNumber   = tvb_get_ntohs(tvb, local_offset + 4);
3743
3744     if (!parentTree)
3745         return;
3746
3747     NoticesAndTraps_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
3748     proto_item_set_text(NoticesAndTraps_header_item, "%s", val_to_str(trapNumber, Trap_Description, "Unknown or Vendor Specific Trap Number! (0x%02x)"));
3749     NoticesAndTraps_header_tree = proto_item_add_subtree(NoticesAndTraps_header_item, ett_noticestraps);
3750
3751     proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_IsGeneric,                tvb, local_offset, 1, ENC_BIG_ENDIAN);
3752     proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_Type,                     tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3753     proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_ProducerTypeVendorID,     tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
3754     proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_TrapNumberDeviceID,       tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3755     proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_IssuerLID,                tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3756     proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_NoticeToggle,             tvb, local_offset, 1, ENC_BIG_ENDIAN);
3757     proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_NoticeCount,              tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3758
3759     parse_NoticeDataDetails(NoticesAndTraps_header_tree, tvb, &local_offset, trapNumber);
3760     proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_DataDetails,              tvb, local_offset, 54, ENC_NA); local_offset += 54;
3761
3762 #if 0    /* Only Defined For GMPs not SMPs which is not part of this dissector phase */
3763     *proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_IssuerGID,               tvb, local_offset, 16, ENC_NA); local_offset += 16;
3764     *proto_tree_add_item(NoticesAndTraps_header_tree, hf_infiniband_Notice_ClassTrapSpecificData,   tvb, local_offset, 1, ENC_NA); local_offset += 1;
3765 #endif
3766
3767 }
3768
3769 /* Parse NodeDescription Attribute
3770 * IN:   parentTree - The tree to add the dissection to
3771 *       tvb - The tvbbuff of packet data
3772 *       offset - The offset in TVB where the attribute begins
3773 *       MadHeader - The common MAD header of the current SMP/SMA  */
3774 static void parse_NodeDescription(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
3775 {
3776     gint        local_offset = *offset;
3777     proto_tree *NodeDescription_header_tree;
3778
3779     if (!parentTree)
3780         return;
3781
3782     NodeDescription_header_tree = parentTree;
3783     proto_tree_add_item(NodeDescription_header_tree, hf_infiniband_NodeDescription_NodeString,  tvb, local_offset, 64, ENC_ASCII|ENC_NA);
3784 }
3785
3786 /* Parse NodeInfo Attribute
3787 * IN:   parentTree - The tree to add the dissection to
3788 *       tvb - The tvbbuff of packet data
3789 *       offset - The offset in TVB where the attribute begins
3790 *       MadHeader - The common MAD header of the current SMP/SMA  */
3791 static int parse_NodeInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
3792 {
3793     gint        local_offset = *offset;
3794     proto_tree *NodeInfo_header_tree;
3795
3796     if (!parentTree)
3797         return *offset;
3798
3799     NodeInfo_header_tree = parentTree;
3800
3801     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_BaseVersion,       tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3802     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_ClassVersion,      tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3803     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_NodeType,          tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3804     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_NumPorts,          tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3805     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_SystemImageGUID,   tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
3806     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_NodeGUID,          tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
3807     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_PortGUID,          tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
3808     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_PartitionCap,      tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3809     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_DeviceID,          tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3810     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_Revision,          tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
3811     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_LocalPortNum,      tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3812     proto_tree_add_item(NodeInfo_header_tree, hf_infiniband_NodeInfo_VendorID,          tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
3813
3814     return local_offset;
3815
3816 }
3817
3818 /* Parse SwitchInfo Attribute
3819 * IN:   parentTree - The tree to add the dissection to
3820 *       tvb - The tvbbuff of packet data
3821 *       offset - The offset in TVB where the attribute begins
3822 *       MadHeader - The common MAD header of the current SMP/SMA  */
3823 static int parse_SwitchInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
3824 {
3825     gint        local_offset = *offset;
3826     proto_tree *SwitchInfo_header_tree;
3827
3828     if (!parentTree)
3829         return *offset;
3830
3831     SwitchInfo_header_tree = parentTree;
3832
3833     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_LinearFDBCap,                      tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3834     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_RandomFDBCap,                      tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3835     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_MulticastFDBCap,                   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3836     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_LinearFDBTop,                      tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3837     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_DefaultPort,                       tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3838     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_DefaultMulticastPrimaryPort,       tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3839     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_DefaultMulticastNotPrimaryPort,    tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3840     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_LifeTimeValue,                     tvb, local_offset, 1, ENC_BIG_ENDIAN);
3841     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_PortStateChange,                   tvb, local_offset, 1, ENC_BIG_ENDIAN);
3842     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_OptimizedSLtoVLMappingProgramming, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3843     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_LIDsPerPort,                       tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3844     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_PartitionEnforcementCap,           tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3845     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_InboundEnforcementCap,             tvb, local_offset, 1, ENC_BIG_ENDIAN);
3846     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_OutboundEnforcementCap,            tvb, local_offset, 1, ENC_BIG_ENDIAN);
3847     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_FilterRawInboundCap,               tvb, local_offset, 1, ENC_BIG_ENDIAN);
3848     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_FilterRawOutboundCap,              tvb, local_offset, 1, ENC_BIG_ENDIAN);
3849     proto_tree_add_item(SwitchInfo_header_tree, hf_infiniband_SwitchInfo_EnhancedPortZero,                  tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3850
3851     return local_offset;
3852 }
3853
3854 /* Parse GUIDInfo Attribute
3855 * IN:   parentTree - The tree to add the dissection to
3856 *       tvb - The tvbbuff of packet data
3857 *       offset - The offset in TVB where the attribute begins
3858 *       MadHeader - The common MAD header of the current SMP/SMA  */
3859 static int parse_GUIDInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
3860 {
3861     gint        local_offset = *offset;
3862     proto_tree *GUIDInfo_header_tree;
3863     proto_item *tempItemLow;
3864     gint        i;
3865
3866     if (!parentTree)
3867         return *offset;
3868
3869     GUIDInfo_header_tree = parentTree;
3870
3871     for (i = 0; i < 8; i++)
3872     {
3873         tempItemLow = proto_tree_add_item(GUIDInfo_header_tree, hf_infiniband_GUIDInfo_GUID, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
3874         proto_item_append_text(tempItemLow, "(%u)", i);
3875     }
3876     return local_offset;
3877 }
3878
3879 /* Parse PortInfo Attribute
3880 * IN:   parentTree - The tree to add the dissection to
3881 *       tvb - The tvbbuff of packet data
3882 *       offset - The offset in TVB where the attribute begins
3883 *       MadHeader - The common MAD header of the current SMP/SMA  */
3884 static int parse_PortInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
3885 {
3886     gint        local_offset = *offset;
3887     proto_tree *PortInfo_header_tree;
3888     proto_item *PortInfo_CapabilityMask_item;
3889     proto_tree *PortInfo_CapabilityMask_tree;
3890     proto_item *temp_item;
3891     guint16     temp_val;
3892
3893     if (!parentTree)
3894         return *offset;
3895
3896     PortInfo_header_tree = parentTree;
3897
3898     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_M_Key,                 tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
3899     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_GidPrefix,             tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
3900     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LID,                   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3901     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_MasterSMLID,           tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3902
3903     /* Capability Mask Flags */
3904     PortInfo_CapabilityMask_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_CapabilityMask,     tvb, local_offset, 4, ENC_BIG_ENDIAN);
3905     PortInfo_CapabilityMask_tree = proto_item_add_subtree(PortInfo_CapabilityMask_item, ett_portinfo_capmask);
3906
3907     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_SM,                             tvb, local_offset, 4, ENC_BIG_ENDIAN);
3908     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_NoticeSupported,                tvb, local_offset, 4, ENC_BIG_ENDIAN);
3909     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_TrapSupported,                  tvb, local_offset, 4, ENC_BIG_ENDIAN);
3910     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_OptionalPDSupported,            tvb, local_offset, 4, ENC_BIG_ENDIAN);
3911     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_AutomaticMigrationSupported,    tvb, local_offset, 4, ENC_BIG_ENDIAN);
3912     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_SLMappingSupported,             tvb, local_offset, 4, ENC_BIG_ENDIAN);
3913     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_MKeyNVRAM,                      tvb, local_offset, 4, ENC_BIG_ENDIAN);
3914     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_PKeyNVRAM,                      tvb, local_offset, 4, ENC_BIG_ENDIAN);
3915     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_LEDInfoSupported,               tvb, local_offset, 4, ENC_BIG_ENDIAN);
3916     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_SMdisabled,                     tvb, local_offset, 4, ENC_BIG_ENDIAN);
3917     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_SystemImageGUIDSupported,       tvb, local_offset, 4, ENC_BIG_ENDIAN);
3918     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_PKeySwitchExternalPortTrapSupported,    tvb, local_offset, 4, ENC_BIG_ENDIAN);
3919     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_CommunicationsManagementSupported,      tvb, local_offset, 4, ENC_BIG_ENDIAN);
3920     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_SNMPTunnelingSupported,                 tvb, local_offset, 4, ENC_BIG_ENDIAN);
3921     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_ReinitSupported,                tvb, local_offset, 4, ENC_BIG_ENDIAN);
3922     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_DeviceManagementSupported,      tvb, local_offset, 4, ENC_BIG_ENDIAN);
3923     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_VendorClassSupported,           tvb, local_offset, 4, ENC_BIG_ENDIAN);
3924     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_DRNoticeSupported,              tvb, local_offset, 4, ENC_BIG_ENDIAN);
3925     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_CapabilityMaskNoticeSupported,  tvb, local_offset, 4, ENC_BIG_ENDIAN);
3926     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_BootManagementSupported,        tvb, local_offset, 4, ENC_BIG_ENDIAN);
3927     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_LinkRoundTripLatencySupported,  tvb, local_offset, 4, ENC_BIG_ENDIAN);
3928     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_ClientRegistrationSupported,    tvb, local_offset, 4, ENC_BIG_ENDIAN);
3929     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_OtherLocalChangesNoticeSupported,   tvb, local_offset, 4, ENC_BIG_ENDIAN);
3930     proto_tree_add_item(PortInfo_CapabilityMask_tree, hf_infiniband_PortInfo_CapabilityMask_LinkSpeedWIdthPairsTableSupported,  tvb, local_offset, 4, ENC_BIG_ENDIAN);
3931     local_offset += 4;
3932     /* End Capability Mask Flags */
3933
3934     /* Diag Code */
3935     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_DiagCode,              tvb, local_offset, 2, ENC_BIG_ENDIAN);
3936     temp_val = tvb_get_ntohs(tvb, local_offset);
3937
3938     proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, DiagCode, "Reserved DiagCode! Possible Error"));
3939     local_offset += 2;
3940     /* End Diag Code */
3941
3942     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_M_KeyLeasePeriod,      tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
3943     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LocalPortNum,          tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
3944
3945     /* LinkWidthEnabled */
3946     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkWidthEnabled,      tvb, local_offset, 1, ENC_BIG_ENDIAN);
3947     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
3948
3949     proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, LinkWidthEnabled, "Reserved LinkWidthEnabled Value! Possible Error"));
3950     local_offset += 1;
3951     /* End LinkWidthEnabled */
3952
3953     /* LinkWidthSupported */
3954     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkWidthSupported,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
3955     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
3956
3957     proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, LinkWidthSupported, "Reserved LinkWidthSupported Value! Possible Error"));
3958     local_offset += 1;
3959     /* End LinkWidthSupported */
3960
3961     /* LinkWidthActive */
3962     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkWidthActive,       tvb, local_offset, 1, ENC_BIG_ENDIAN);
3963     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
3964
3965     proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, LinkWidthActive, "Reserved LinkWidthActive Value! Possible Error"));
3966     local_offset += 1;
3967     /* End LinkWidthActive */
3968
3969     /* LinkSpeedSupported */
3970     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkSpeedSupported,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
3971     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
3972
3973     /* 4 bit values = mask and shift */
3974     temp_val = temp_val & 0x00F0;
3975     temp_val = temp_val >> 4;
3976
3977     proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, LinkSpeedSupported, "Reserved LinkWidthSupported Value! Possible Error"));
3978     /* End LinkSpeedSupported */
3979
3980     /* PortState */
3981     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_PortState,             tvb, local_offset, 1, ENC_BIG_ENDIAN);
3982     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
3983
3984     /* 4 bit values = mask and shift */
3985     temp_val = temp_val & 0x000F;
3986     /*temp_val = temp_val >> 4 */
3987
3988     proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, PortState, "Reserved PortState Value! Possible Error"));
3989     local_offset += 1;
3990     /* End PortState */
3991
3992     /* PortPhysicalState */
3993     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_PortPhysicalState,     tvb, local_offset, 1, ENC_BIG_ENDIAN);
3994     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
3995
3996     /* 4 bit values = mask and shift */
3997     temp_val = temp_val & 0x00F0;
3998     temp_val = temp_val >> 4;
3999
4000     proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, PortPhysicalState, "Reserved PortPhysicalState Value! Possible Error"));
4001     /* End PortPhysicalState */
4002
4003     /* LinkDownDefaultState */
4004     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkDownDefaultState,  tvb, local_offset, 1, ENC_BIG_ENDIAN);
4005     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4006
4007     /* 4 bit values = mask and shift */
4008     temp_val = temp_val & 0x000F;
4009     /*temp_val = temp_val >> 4 */
4010
4011     proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, LinkDownDefaultState, "Reserved LinkDownDefaultState Value! Possible Error"));
4012     local_offset += 1;
4013     /* End LinkDownDefaultState */
4014
4015     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_M_KeyProtectBits,      tvb, local_offset, 1, ENC_BIG_ENDIAN);
4016     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LMC,                   tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4017
4018     /* LinkSpeedActive */
4019     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkSpeedActive,       tvb, local_offset, 1, ENC_BIG_ENDIAN);
4020     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4021
4022     /* 4 bit values = mask and shift */
4023     temp_val = temp_val & 0x00F0;
4024     temp_val = temp_val >> 4;
4025
4026     proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, LinkSpeedActive, "Reserved LinkSpeedActive Value! Possible Error"));
4027     /* End LinkSpeedActive */
4028
4029     /* LinkSpeedEnabled */
4030     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkSpeedEnabled,      tvb, local_offset, 1, ENC_BIG_ENDIAN);
4031     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4032
4033     /* 4 bit values = mask and shift */
4034     temp_val = temp_val & 0x000F;
4035     /*temp_val = temp_val >> 4 */
4036
4037     proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, LinkSpeedEnabled, "Reserved LinkSpeedEnabled Value! Possible Error"));
4038     local_offset += 1;
4039     /* End LinkSpeedEnabled */
4040
4041     /* NeighborMTU */
4042     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_NeighborMTU,           tvb, local_offset, 1, ENC_BIG_ENDIAN);
4043     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4044
4045     /* 4 bit values = mask and shift */
4046     temp_val = temp_val & 0x00F0;
4047     temp_val = temp_val >> 4;
4048
4049     proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, NeighborMTU, "Reserved NeighborMTU Value! Possible Error"));
4050
4051     /* End NeighborMTU */
4052
4053     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_MasterSMSL,            tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4054
4055     /* VLCap */
4056     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_VLCap,                 tvb, local_offset, 1, ENC_BIG_ENDIAN);
4057     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4058
4059     /* 4 bit values = mask and shift */
4060     temp_val = temp_val & 0x00F0;
4061     temp_val = temp_val >> 4;
4062
4063     proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, VLCap, "Reserved VLCap Value! Possible Error"));
4064
4065     /* End VLCap */
4066
4067     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_InitType,              tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4068     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_VLHighLimit,           tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4069     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_VLArbitrationHighCap,  tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4070     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_VLArbitrationLowCap,   tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4071     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_InitTypeReply,         tvb, local_offset, 1, ENC_BIG_ENDIAN);
4072
4073     /* MTUCap */
4074     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_MTUCap,                tvb, local_offset, 1, ENC_BIG_ENDIAN);
4075     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4076
4077     /* 4 bit values = mask and shift */
4078     temp_val = temp_val & 0x000F;
4079     /*temp_val = temp_val >> 4 */
4080
4081     proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, MTUCap, "Reserved MTUCap Value! Possible Error"));
4082     local_offset += 1;
4083     /* End MTUCap */
4084
4085     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_VLStallCount,          tvb, local_offset, 1, ENC_BIG_ENDIAN);
4086     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_HOQLife,               tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4087
4088     /* OperationalVLs */
4089     temp_item = proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_OperationalVLs,        tvb, local_offset, 1, ENC_BIG_ENDIAN);
4090     temp_val = (guint16)tvb_get_guint8(tvb, local_offset);
4091
4092     /* 4 bit values = mask and shift */
4093     temp_val = temp_val & 0x00F0;
4094     temp_val = temp_val >> 4;
4095
4096     proto_item_append_text(temp_item, ", %s", val_to_str_const(temp_val, OperationalVLs, "Reserved OperationalVLs Value! Possible Error"));
4097     /* End OperationalVLs */
4098
4099     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_PartitionEnforcementInbound,       tvb, local_offset, 1, ENC_BIG_ENDIAN);
4100     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_PartitionEnforcementOutbound,      tvb, local_offset, 1, ENC_BIG_ENDIAN);
4101     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_FilterRawInbound,      tvb, local_offset, 1, ENC_BIG_ENDIAN);
4102     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_FilterRawOutbound,     tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4103     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_M_KeyViolations,       tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4104     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_P_KeyViolations,       tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4105     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_Q_KeyViolations,       tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4106     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_GUIDCap,               tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4107     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_ClientReregister,      tvb, local_offset, 1, ENC_BIG_ENDIAN);
4108     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_SubnetTimeOut,         tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4109     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_RespTimeValue,         tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4110     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LocalPhyErrors,        tvb, local_offset, 1, ENC_BIG_ENDIAN);
4111     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_OverrunErrors,         tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4112     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_MaxCreditHint,         tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 3; /* 2 + 1 Reserved */
4113     proto_tree_add_item(PortInfo_header_tree, hf_infiniband_PortInfo_LinkRoundTripLatency,  tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
4114
4115     return local_offset;
4116 }
4117
4118 /* Parse P_KeyTable Attribute
4119 * IN:   parentTree - The tree to add the dissection to
4120 *       tvb - The tvbbuff of packet data
4121 *       offset - The offset in TVB where the attribute begins
4122 *       MadHeader - The common MAD header of the current SMP/SMA  */
4123 static void parse_P_KeyTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4124 {
4125     gint        local_offset = *offset;
4126     gint        i;
4127     proto_item *P_KeyTable_header_item;
4128     proto_tree *P_KeyTable_header_tree;
4129     proto_item *tempItemLow;
4130     proto_item *tempItemHigh;
4131
4132     if (!parentTree)
4133         return;
4134
4135     P_KeyTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_P_KeyTable_P_KeyTableBlock, tvb, local_offset, 64, ENC_NA);
4136     proto_item_set_text(P_KeyTable_header_item, "%s", "P_KeyTable");
4137     P_KeyTable_header_tree = proto_item_add_subtree(P_KeyTable_header_item, ett_pkeytable);
4138
4139     for (i = 0; i < 32; i++)
4140     {
4141         tempItemLow = proto_tree_add_item(P_KeyTable_header_tree, hf_infiniband_P_KeyTable_MembershipType,  tvb, local_offset, 1, ENC_BIG_ENDIAN);
4142         tempItemHigh = proto_tree_add_item(P_KeyTable_header_tree, hf_infiniband_P_KeyTable_P_KeyBase,          tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4143         proto_item_append_text(tempItemLow,  "(%u)", i);
4144         proto_item_append_text(tempItemHigh, "(%u)", i+1);
4145     }
4146 }
4147
4148 /* Parse SLtoVLMappingTable Attribute
4149 * IN:   parentTree - The tree to add the dissection to
4150 *       tvb - The tvbbuff of packet data
4151 *       offset - The offset in TVB where the attribute begins
4152 *       MadHeader - The common MAD header of the current SMP/SMA  */
4153 static void parse_SLtoVLMappingTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4154 {
4155     gint        local_offset = *offset;
4156     proto_item *SLtoVLMappingTable_header_item;
4157     proto_tree *SLtoVLMappingTable_header_tree;
4158     proto_item *tempItemLow;
4159     proto_item *tempItemHigh;
4160     gint        i;
4161
4162     if (!parentTree)
4163         return;
4164
4165     SLtoVLMappingTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
4166     proto_item_set_text(SLtoVLMappingTable_header_item, "%s", "SLtoVLMappingTable");
4167     SLtoVLMappingTable_header_tree = proto_item_add_subtree(SLtoVLMappingTable_header_item, ett_sltovlmapping);
4168
4169     for (i = 0; i < 8; i++)
4170     {
4171         tempItemLow = proto_tree_add_item(SLtoVLMappingTable_header_tree, hf_infiniband_SLtoVLMappingTable_SLtoVL_HighBits,  tvb, local_offset, 1, ENC_BIG_ENDIAN);
4172         tempItemHigh = proto_tree_add_item(SLtoVLMappingTable_header_tree, hf_infiniband_SLtoVLMappingTable_SLtoVL_LowBits,  tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4173         proto_item_append_text(tempItemLow,  "(%u)", i);
4174         proto_item_append_text(tempItemHigh, "(%u)", i+1);
4175     }
4176 }
4177
4178 /* Parse VLArbitrationTable Attribute
4179 * IN:   parentTree - The tree to add the dissection to
4180 *       tvb - The tvbbuff of packet data
4181 *       offset - The offset in TVB where the attribute begins
4182 *       MadHeader - The common MAD header of the current SMP/SMA  */
4183 static void parse_VLArbitrationTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4184 {
4185     gint        local_offset = *offset;
4186     gint        i;
4187     proto_item *VLArbitrationTable_header_item;
4188     proto_tree *VLArbitrationTable_header_tree;
4189     proto_item *tempItemLow;
4190     proto_item *tempItemHigh;
4191
4192     if (!parentTree)
4193         return;
4194
4195     VLArbitrationTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
4196     proto_item_set_text(VLArbitrationTable_header_item, "%s", "VLArbitrationTable");
4197     VLArbitrationTable_header_tree = proto_item_add_subtree(VLArbitrationTable_header_item, ett_vlarbitrationtable);
4198
4199     for (i = 0; i < 32; i++)
4200     {
4201         tempItemLow = proto_tree_add_item(VLArbitrationTable_header_tree, hf_infiniband_VLArbitrationTable_VL,      tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4202         tempItemHigh = proto_tree_add_item(VLArbitrationTable_header_tree, hf_infiniband_VLArbitrationTable_Weight, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4203         proto_item_append_text(tempItemLow,  "(%u)", i);
4204         proto_item_append_text(tempItemHigh, "(%u)", i);
4205     }
4206 }
4207
4208 /* Parse LinearForwardingTable Attribute
4209 * IN:   parentTree - The tree to add the dissection to
4210 *       tvb - The tvbbuff of packet data
4211 *       offset - The offset in TVB where the attribute begins
4212 *       MadHeader - The common MAD header of the current SMP/SMA  */
4213 static void parse_LinearForwardingTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4214 {
4215     gint        i;
4216     gint        local_offset = *offset;
4217     proto_item *LinearForwardingTable_header_item;
4218     proto_tree *LinearForwardingTable_header_tree;
4219     proto_item *tempItemLow;
4220
4221     if (!parentTree)
4222         return;
4223
4224     LinearForwardingTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
4225     proto_item_set_text(LinearForwardingTable_header_item, "%s", "LinearForwardingTable");
4226     LinearForwardingTable_header_tree = proto_item_add_subtree(LinearForwardingTable_header_item, ett_linearforwardingtable);
4227
4228     for (i = 0; i < 64; i++)
4229     {
4230         tempItemLow = proto_tree_add_item(LinearForwardingTable_header_tree, hf_infiniband_LinearForwardingTable_Port, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4231         proto_item_append_text(tempItemLow, "(%u)", i);
4232     }
4233 }
4234
4235 /* Parse RandomForwardingTable Attribute
4236 * IN:   parentTree - The tree to add the dissection to
4237 *       tvb - The tvbbuff of packet data
4238 *       offset - The offset in TVB where the attribute begins
4239 *       MadHeader - The common MAD header of the current SMP/SMA  */
4240 static void parse_RandomForwardingTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4241 {
4242     gint        i;
4243     gint        local_offset = *offset;
4244     proto_item *RandomForwardingTable_header_item;
4245     proto_tree *RandomForwardingTable_header_tree;
4246     proto_item *tempItemLow;
4247
4248     if (!parentTree)
4249         return;
4250
4251     RandomForwardingTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
4252     proto_item_set_text(RandomForwardingTable_header_item, "%s", "RandomForwardingTable");
4253     RandomForwardingTable_header_tree = proto_item_add_subtree(RandomForwardingTable_header_item, ett_randomforwardingtable);
4254
4255     for (i = 0; i < 16; i++)
4256     {
4257         tempItemLow = proto_tree_add_item(RandomForwardingTable_header_tree, hf_infiniband_RandomForwardingTable_LID,   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4258         proto_item_append_text(tempItemLow, "(%u)", i);
4259         tempItemLow = proto_tree_add_item(RandomForwardingTable_header_tree, hf_infiniband_RandomForwardingTable_Valid, tvb, local_offset, 1, ENC_BIG_ENDIAN);
4260         proto_item_append_text(tempItemLow, "(%u)", i);
4261         tempItemLow = proto_tree_add_item(RandomForwardingTable_header_tree, hf_infiniband_RandomForwardingTable_LMC,   tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4262         proto_item_append_text(tempItemLow, "(%u)", i);
4263         tempItemLow = proto_tree_add_item(RandomForwardingTable_header_tree, hf_infiniband_RandomForwardingTable_Port,  tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4264         proto_item_append_text(tempItemLow, "(%u)", i);
4265     }
4266 }
4267
4268 /* Parse NoticesAndTraps Attribute
4269 * IN:   parentTree - The tree to add the dissection to
4270 *       tvb - The tvbbuff of packet data
4271 *       offset - The offset in TVB where the attribute begins
4272 *       MadHeader - The common MAD header of the current SMP/SMA  */
4273 static void parse_MulticastForwardingTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4274 {
4275     gint        i;
4276     gint        local_offset = *offset;
4277     proto_item *MulticastForwardingTable_header_item;
4278     proto_tree *MulticastForwardingTable_header_tree;
4279     proto_item *tempItemLow;
4280
4281     if (!parentTree)
4282         return;
4283
4284     MulticastForwardingTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
4285     proto_item_set_text(MulticastForwardingTable_header_item, "%s", "MulticastForwardingTable");
4286     MulticastForwardingTable_header_tree = proto_item_add_subtree(MulticastForwardingTable_header_item, ett_multicastforwardingtable);
4287
4288     for (i = 0; i < 16; i++)
4289     {
4290         tempItemLow = proto_tree_add_item(MulticastForwardingTable_header_tree, hf_infiniband_MulticastForwardingTable_PortMask, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4291         proto_item_append_text(tempItemLow, "(%u)", i);
4292     }
4293
4294 }
4295
4296 /* Parse SMInfo Attribute
4297 * IN:   parentTree - The tree to add the dissection to
4298 *       tvb - The tvbbuff of packet data
4299 *       offset - The offset in TVB where the attribute begins
4300 *       MadHeader - The common MAD header of the current SMP/SMA  */
4301 static int parse_SMInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4302 {
4303     gint        local_offset = *offset;
4304     proto_item *SMInfo_header_item;
4305     proto_tree *SMInfo_header_tree;
4306
4307     if (!parentTree)
4308         return *offset;
4309
4310     SMInfo_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
4311     proto_item_set_text(SMInfo_header_item, "%s", "SMInfo");
4312     SMInfo_header_tree = proto_item_add_subtree(SMInfo_header_item, ett_sminfo);
4313
4314     proto_tree_add_item(SMInfo_header_tree, hf_infiniband_SMInfo_GUID,      tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4315     proto_tree_add_item(SMInfo_header_tree, hf_infiniband_SMInfo_SM_Key,    tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4316     proto_tree_add_item(SMInfo_header_tree, hf_infiniband_SMInfo_ActCount,  tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
4317     proto_tree_add_item(SMInfo_header_tree, hf_infiniband_SMInfo_Priority,  tvb, local_offset, 1, ENC_BIG_ENDIAN);
4318     proto_tree_add_item(SMInfo_header_tree, hf_infiniband_SMInfo_SMState,   tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4319     return local_offset;
4320 }
4321
4322 /* Parse VendorDiag Attribute
4323 * IN:   parentTree - The tree to add the dissection to
4324 *       tvb - The tvbbuff of packet data
4325 *       offset - The offset in TVB where the attribute begins
4326 *       MadHeader - The common MAD header of the current SMP/SMA  */
4327 static int parse_VendorDiag(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4328 {
4329     gint        local_offset = *offset;
4330     proto_item *VendorDiag_header_item;
4331     proto_tree *VendorDiag_header_tree;
4332
4333     if (!parentTree)
4334         return *offset;
4335
4336     VendorDiag_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
4337     proto_item_set_text(VendorDiag_header_item, "%s", "VendorDiag");
4338     VendorDiag_header_tree = proto_item_add_subtree(VendorDiag_header_item, ett_vendordiag);
4339
4340     proto_tree_add_item(VendorDiag_header_tree, hf_infiniband_VendorDiag_NextIndex,     tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4341     proto_tree_add_item(VendorDiag_header_tree, hf_infiniband_VendorDiag_DiagData,      tvb, local_offset, 62, ENC_NA); local_offset += 62;
4342
4343     return local_offset;
4344 }
4345
4346 /* Parse LedInfo Attribute
4347 * IN:   parentTree - The tree to add the dissection to
4348 *       tvb - The tvbbuff of packet data
4349 *       offset - The offset in TVB where the attribute begins
4350 *       MadHeader - The common MAD header of the current SMP/SMA  */
4351 static void parse_LedInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4352 {
4353     gint        local_offset = *offset;
4354     proto_item *LedInfo_header_item;
4355     proto_tree *LedInfo_header_tree;
4356
4357     if (!parentTree)
4358         return;
4359
4360     LedInfo_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
4361     proto_item_set_text(LedInfo_header_item, "%s", "LedInfo");
4362     LedInfo_header_tree = proto_item_add_subtree(LedInfo_header_item, ett_ledinfo);
4363
4364     proto_tree_add_item(LedInfo_header_tree, hf_infiniband_LedInfo_LedMask,     tvb, local_offset, 1, ENC_BIG_ENDIAN);
4365 }
4366
4367 /* Parse LinkSpeedWidthPairsTable Attribute
4368 * IN:   parentTree - The tree to add the dissection to
4369 *       tvb - The tvbbuff of packet data
4370 *       offset - The offset in TVB where the attribute begins
4371 *       MadHeader - The common MAD header of the current SMP/SMA  */
4372 static int parse_LinkSpeedWidthPairsTable(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4373 {
4374     gint        local_offset = *offset;
4375     proto_item *LinkSpeedWidthPairsTable_header_item;
4376     proto_tree *LinkSpeedWidthPairsTable_header_tree;
4377
4378     if (!parentTree)
4379         return *offset;
4380
4381     LinkSpeedWidthPairsTable_header_item = proto_tree_add_item(parentTree, hf_infiniband_smp_data, tvb, local_offset, 64, ENC_NA);
4382     proto_item_set_text(LinkSpeedWidthPairsTable_header_item, "%s", "LinkSpeedWidthPairsTable");
4383     LinkSpeedWidthPairsTable_header_tree = proto_item_add_subtree(LinkSpeedWidthPairsTable_header_item, ett_linkspeedwidthpairs);
4384
4385     proto_tree_add_item(LinkSpeedWidthPairsTable_header_tree, hf_infiniband_LinkSpeedWidthPairsTable_NumTables,     tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4386     proto_tree_add_item(LinkSpeedWidthPairsTable_header_tree, hf_infiniband_LinkSpeedWidthPairsTable_PortMask,      tvb, local_offset, 32, ENC_NA); local_offset += 32;
4387     proto_tree_add_item(LinkSpeedWidthPairsTable_header_tree, hf_infiniband_LinkSpeedWidthPairsTable_SpeedTwoFive,  tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4388     proto_tree_add_item(LinkSpeedWidthPairsTable_header_tree, hf_infiniband_LinkSpeedWidthPairsTable_SpeedFive,     tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4389     proto_tree_add_item(LinkSpeedWidthPairsTable_header_tree, hf_infiniband_LinkSpeedWidthPairsTable_SpeedTen,      tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4390
4391    return local_offset;
4392 }
4393
4394 /* Parse RID Field from Subnet Administraiton Packets.
4395 * IN: SA_header_tree - the dissection tree of the subnet admin attribute.
4396 *     tvb - the packet buffer
4397 *      MadHeader - the Common MAD header from this packet.
4398 * IN/OUT:  offset - the current and updated offset in the packet buffer */
4399 static void parse_RID(proto_tree* SA_header_tree, tvbuff_t* tvb, gint *offset, MAD_Data* MadHeader)
4400 {
4401     gint local_offset = *offset;
4402
4403     if (!SA_header_tree)
4404     {
4405         return;
4406     }
4407         switch (MadHeader->attributeID)
4408         {
4409             case 0x0011:
4410                 /* NodeRecord */
4411                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4412                 local_offset += 2; /* Reserved bits */
4413                 break;
4414             case 0x0012:
4415                 /* PortInfoRecord */
4416                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_EndportLID,    tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4417                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_PortNum,       tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4418                 local_offset += 1; /* Reserved bits */
4419                 break;
4420             case 0x0013:
4421                 /* SLtoVLMappingTableRecord */
4422                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,           tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4423                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_InputPortNum,  tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4424                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_OutputPortNum, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4425                 local_offset += 4; /* Reserved bits */
4426                 break;
4427             case 0x0014:
4428                 /* SwitchInfoRecord */
4429                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,           tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4430                 local_offset += 2; /* Reserved bits */
4431                 break;
4432             case 0x0015:
4433                 /* LinearForwardingTableRecord */
4434                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,                   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4435                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_BlockNum_SixteenBit,   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4436                 local_offset += 4; /* Reserved bits */
4437                 break;
4438             case 0x0016:
4439                 /* RandomForwardingTableRecord */
4440                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,                   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4441                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_BlockNum_SixteenBit,   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4442                 local_offset += 4; /* Reserved bits */
4443                 break;
4444             case 0x0017:
4445                 /* MulticastForwardingTableRecord */
4446                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,               tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4447                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_Position,          tvb, local_offset, 1, ENC_BIG_ENDIAN);
4448                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_BlockNum_NineBit,  tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4449                 local_offset += 4; /* Reserved bits */
4450                 break;
4451             case 0x0036:
4452                 /*VLArbitrationTableRecord */
4453                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,           tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4454                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_OutputPortNum, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4455                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_BlockNum_EightBit,     tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4456                 local_offset += 4; /* Reserved bits */
4457                 break;
4458             case 0x0018:
4459                 /* SMInfoRecord */
4460                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,               tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4461                 local_offset += 2; /* Reserved bits */
4462                 break;
4463             case 0x0033:
4464                 /* P_KeyTableRecord */
4465                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,                   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4466                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_BlockNum_SixteenBit,   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4467                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_PortNum,               tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4468                 local_offset += 3; /* Reserved bits */
4469                 break;
4470             case 0x00F3:
4471                 /* InformInfoRecord */
4472                 proto_tree_add_item(SA_header_tree, hf_infiniband_InformInfoRecord_SubscriberGID,   tvb, local_offset, 16, ENC_NA); local_offset += 16;
4473                 proto_tree_add_item(SA_header_tree, hf_infiniband_InformInfoRecord_Enum,            tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4474                 local_offset += 6; /* Reserved bits */
4475                 break;
4476             case 0x0020:
4477                 /* LinkRecord */
4478                 proto_tree_add_item(SA_header_tree, hf_infiniband_LinkRecord_FromLID,   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4479                 proto_tree_add_item(SA_header_tree, hf_infiniband_LinkRecord_FromPort,  tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4480                 break;
4481             case 0x0031:
4482                 /* ServiceRecord */
4483                 proto_tree_add_item(SA_header_tree, hf_infiniband_ServiceRecord_ServiceID,      tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4484                 proto_tree_add_item(SA_header_tree, hf_infiniband_ServiceRecord_ServiceGID,     tvb, local_offset, 16, ENC_NA); local_offset += 16;
4485                 proto_tree_add_item(SA_header_tree, hf_infiniband_ServiceRecord_ServiceP_Key,   tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4486                 local_offset += 2;
4487                 break;
4488             case 0x0038:
4489                 /* MCMemberRecord */
4490                 proto_tree_add_item(SA_header_tree, hf_infiniband_MCMemberRecord_MGID,      tvb, local_offset, 16, ENC_NA); local_offset += 16;
4491                 proto_tree_add_item(SA_header_tree, hf_infiniband_MCMemberRecord_PortGID,   tvb, local_offset, 16, ENC_NA); local_offset += 16;
4492                 break;
4493             case 0x0030:
4494                 /* GuidInfoRecord */
4495                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_LID,               tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4496                 proto_tree_add_item(SA_header_tree, hf_infiniband_SA_BlockNum_EightBit, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 2;
4497                 local_offset += 4;
4498                 break;
4499             default:
4500                 break;
4501         }
4502
4503     *offset = local_offset;
4504 }
4505
4506 /* Parse InformInfo Attribute
4507 * IN:   parentTree - The tree to add the dissection to
4508 *       tvb - The tvbbuff of packet data
4509 *       offset - The offset in TVB where the attribute begins
4510 *       MadHeader - The common MAD header of the current SMP/SMA  */
4511 static int parse_InformInfo(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4512 {
4513     gint        local_offset = *offset;
4514     proto_item *InformInfo_header_item;
4515     proto_tree *InformInfo_header_tree;
4516
4517     if (!parentTree)
4518     {
4519         return *offset;
4520     }
4521     InformInfo_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 36, ENC_NA);
4522     proto_item_set_text(InformInfo_header_item, "%s", "InformInfo");
4523     InformInfo_header_tree = proto_item_add_subtree(InformInfo_header_item, ett_informinfo);
4524
4525     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_GID,                   tvb, local_offset, 16, ENC_NA); local_offset += 16;
4526     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_LIDRangeBegin,         tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4527     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_LIDRangeEnd,           tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4528     local_offset += 2; /* Reserved Bits */
4529     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_IsGeneric,             tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4530     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_Subscribe,             tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4531     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_Type,                  tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4532     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_TrapNumberDeviceID,    tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4533     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_QPN,                   tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
4534     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_RespTimeValue,         tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4535     local_offset += 1;
4536     proto_tree_add_item(InformInfo_header_tree, hf_infiniband_InformInfo_ProducerTypeVendorID,  tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
4537
4538    return local_offset;
4539 }
4540 /* Parse LinkRecord Attribute
4541 * IN:   parentTree - The tree to add the dissection to
4542 *       tvb - The tvbbuff of packet data
4543 *       offset - The offset in TVB where the attribute begins
4544 *       MadHeader - The common MAD header of the current SMP/SMA  */
4545 static int parse_LinkRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4546 {
4547     gint        local_offset = *offset;
4548     proto_item *LinkRecord_header_item;
4549     proto_tree *LinkRecord_header_tree;
4550
4551     if (!parentTree)
4552     {
4553         return *offset;
4554     }
4555
4556     LinkRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 3, ENC_NA);
4557     proto_item_set_text(LinkRecord_header_item, "%s", "LinkRecord");
4558     LinkRecord_header_tree = proto_item_add_subtree(LinkRecord_header_item, ett_linkrecord);
4559
4560     proto_tree_add_item(LinkRecord_header_tree, hf_infiniband_LinkRecord_ToPort,    tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4561     proto_tree_add_item(LinkRecord_header_tree, hf_infiniband_LinkRecord_ToLID,     tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset  += 2;
4562
4563    return local_offset;
4564
4565 }
4566 /* Parse ServiceRecord Attribute
4567 * IN:   parentTree - The tree to add the dissection to
4568 *       tvb - The tvbbuff of packet data
4569 *       offset - The offset in TVB where the attribute begins
4570 *       MadHeader - The common MAD header of the current SMP/SMA  */
4571 static int parse_ServiceRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4572 {
4573     gint        local_offset = *offset;
4574     proto_item *ServiceRecord_header_item;
4575     proto_tree *ServiceRecord_header_tree;
4576     proto_item *tempData;
4577
4578     if (!parentTree)
4579     {
4580         return *offset;
4581     }
4582
4583     ServiceRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 176, ENC_NA);
4584     proto_item_set_text(ServiceRecord_header_item, "%s", "ServiceRecord");
4585     ServiceRecord_header_tree = proto_item_add_subtree(ServiceRecord_header_item, ett_servicerecord);
4586
4587     proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceLease,    tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
4588     proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceKey,      tvb, local_offset, 16, ENC_NA); local_offset += 16;
4589     proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceName,     tvb, local_offset, 64, ENC_NA); local_offset += 64;
4590
4591     tempData = proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceData,      tvb, local_offset, 16, ENC_NA); local_offset += 16;
4592     proto_item_append_text(tempData, "%s", "(ServiceData 8.1, 8.16)");
4593     tempData = proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceData,      tvb, local_offset, 16, ENC_NA); local_offset += 16;
4594     proto_item_append_text(tempData, "%s", "(ServiceData 16.1, 16.8)");
4595     tempData = proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceData,      tvb, local_offset, 16, ENC_NA); local_offset += 16;
4596     proto_item_append_text(tempData, "%s", "(ServiceData 32.1, 32.4)");
4597     tempData = proto_tree_add_item(ServiceRecord_header_tree, hf_infiniband_ServiceRecord_ServiceData,      tvb, local_offset, 16, ENC_NA); local_offset += 16;
4598     proto_item_append_text(tempData, "%s", "(ServiceData 64.1, 64.2)");
4599
4600     return local_offset;
4601
4602 }
4603 /* Parse PathRecord Attribute
4604 * IN:   parentTree - The tree to add the dissection to
4605 *       tvb - The tvbbuff of packet data
4606 *       offset - The offset in TVB where the attribute begins
4607 *       MadHeader - The common MAD header of the current SMP/SMA  */
4608 static int parse_PathRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4609 {
4610     gint        local_offset = *offset;
4611     proto_item *PathRecord_header_item;
4612     proto_tree *PathRecord_header_tree;
4613
4614     if (!parentTree)
4615     {
4616         return *offset;
4617     }
4618
4619     PathRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 64, ENC_NA);
4620     proto_item_set_text(PathRecord_header_item, "%s", "PathRecord");
4621     PathRecord_header_tree = proto_item_add_subtree(PathRecord_header_item, ett_pathrecord);
4622     local_offset += 8; /* Reserved Bits */
4623
4624     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_DGID,          tvb, local_offset, 16, ENC_NA); local_offset += 16;
4625     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_SGID,          tvb, local_offset, 16, ENC_NA); local_offset += 16;
4626     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_DLID,          tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4627     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_SLID,          tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4628     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_RawTraffic,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
4629     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_FlowLabel,     tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
4630     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_HopLimit,      tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4631     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_TClass,        tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4632     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_Reversible,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
4633     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_NumbPath,      tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4634     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_P_Key,         tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4635     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_SL,            tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4636     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_MTUSelector,   tvb, local_offset, 1, ENC_BIG_ENDIAN);
4637     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_MTU,           tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4638     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_RateSelector,  tvb, local_offset, 1, ENC_BIG_ENDIAN);
4639     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_Rate,          tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4640     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_PacketLifeTimeSelector,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
4641     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_PacketLifeTime,            tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4642     proto_tree_add_item(PathRecord_header_tree, hf_infiniband_PathRecord_Preference,                tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4643
4644     return local_offset;
4645 }
4646 /* Parse MCMemberRecord Attribute
4647 * IN:   parentTree - The tree to add the dissection to
4648 *       tvb - The tvbbuff of packet data
4649 *       offset - The offset in TVB where the attribute begins
4650 *       MadHeader - The common MAD header of the current SMP/SMA  */
4651 static int parse_MCMemberRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4652 {
4653     gint        local_offset = *offset;
4654     proto_item *MCMemberRecord_header_item;
4655     proto_tree *MCMemberRecord_header_tree;
4656
4657     if (!parentTree)
4658     {
4659         return *offset;
4660     }
4661
4662     MCMemberRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 64, ENC_NA);
4663     proto_item_set_text(MCMemberRecord_header_item, "%s", "MCMemberRecord");
4664     MCMemberRecord_header_tree = proto_item_add_subtree(MCMemberRecord_header_item, ett_mcmemberrecord);
4665
4666     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_Q_Key,         tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
4667     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_MLID,          tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4668     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_MTUSelector,   tvb, local_offset, 1, ENC_BIG_ENDIAN);
4669     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_MTU,           tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4670     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_TClass,        tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4671     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_P_Key,         tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4672     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_RateSelector,  tvb, local_offset, 1, ENC_BIG_ENDIAN);
4673     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_Rate,          tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4674     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_PacketLifeTimeSelector,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
4675     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_PacketLifeTime,            tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4676     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_SL,            tvb, local_offset, 1, ENC_BIG_ENDIAN);
4677     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_FlowLabel,     tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
4678     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_HopLimit,      tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4679     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_Scope,         tvb, local_offset, 1, ENC_BIG_ENDIAN);
4680     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_JoinState,     tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4681     proto_tree_add_item(MCMemberRecord_header_tree, hf_infiniband_MCMemberRecord_ProxyJoin,     tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 3;
4682
4683     return local_offset;
4684
4685 }
4686 /* Parse TraceRecord Attribute
4687 * IN:   parentTree - The tree to add the dissection to
4688 *       tvb - The tvbbuff of packet data
4689 *       offset - The offset in TVB where the attribute begins
4690 *       MadHeader - The common MAD header of the current SMP/SMA  */
4691 static int parse_TraceRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4692 {
4693     gint        local_offset = *offset;
4694     proto_item *TraceRecord_header_item;
4695     proto_tree *TraceRecord_header_tree;
4696
4697     if (!parentTree)
4698     {
4699         return *offset;
4700     }
4701
4702     TraceRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 46, ENC_NA);
4703     proto_item_set_text(TraceRecord_header_item, "%s", "TraceRecord");
4704     TraceRecord_header_tree = proto_item_add_subtree(TraceRecord_header_item, ett_tracerecord);
4705
4706     proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_GIDPrefix,       tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4707     proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_IDGeneration,    tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4708     local_offset += 1; /* Reserved Bits */
4709     proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_NodeType,        tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4710     proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_NodeID,          tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4711     proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_ChassisID,       tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4712     proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_EntryPortID,     tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4713     proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_ExitPortID,      tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4714     proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_EntryPort,       tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4715     proto_tree_add_item(TraceRecord_header_tree, hf_infiniband_TraceRecord_ExitPort,        tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4716
4717     return local_offset;
4718 }
4719 /* Parse MultiPathRecord Attribute
4720 * IN:   parentTree - The tree to add the dissection to
4721 *       tvb - The tvbbuff of packet data
4722 *       offset - The offset in TVB where the attribute begins
4723 *       MadHeader - The common MAD header of the current SMP/SMA  */
4724 static int parse_MultiPathRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4725 {
4726     gint        local_offset = *offset;
4727     proto_item *MultiPathRecord_header_item;
4728     proto_tree *MultiPathRecord_header_tree;
4729     proto_item *SDGID;
4730     guint8      SDGIDCount;
4731     guint8      DGIDCount;
4732     guint32     i;
4733
4734     if (!parentTree)
4735     {
4736         return *offset;
4737     }
4738
4739     MultiPathRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 200, ENC_NA);
4740     proto_item_set_text(MultiPathRecord_header_item, "%s", "MultiPathRecord");
4741     MultiPathRecord_header_tree = proto_item_add_subtree(MultiPathRecord_header_item, ett_multipathrecord);
4742
4743     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_RawTraffic,      tvb, local_offset, 1, ENC_BIG_ENDIAN);
4744     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_FlowLabel,       tvb, local_offset, 3, ENC_BIG_ENDIAN); local_offset += 3;
4745     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_HopLimit,        tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4746     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_TClass,          tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4747     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_Reversible,      tvb, local_offset, 1, ENC_BIG_ENDIAN);
4748     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_NumbPath,        tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4749     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_P_Key,           tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4750     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_SL,              tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4751     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_MTUSelector,     tvb, local_offset, 1, ENC_BIG_ENDIAN);
4752     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_MTU,             tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4753     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_RateSelector,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
4754     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_Rate,            tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4755     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_PacketLifeTimeSelector,  tvb, local_offset, 1, ENC_BIG_ENDIAN);
4756     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_PacketLifeTime,          tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4757     local_offset += 1; /* Reserved Bits */
4758     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_IndependenceSelector,    tvb, local_offset, 1, ENC_BIG_ENDIAN);
4759     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_GIDScope,                tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4760
4761     SDGIDCount = tvb_get_guint8(tvb, local_offset);
4762     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_SGIDCount,       tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4763     DGIDCount = tvb_get_guint8(tvb, local_offset);
4764     proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_DGIDCount,       tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4765     local_offset += 7; /*Reserved Bits */
4766
4767     for (i = 0; i < SDGIDCount; i++)
4768     {
4769         SDGID = proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_SDGID,       tvb, local_offset, 16, ENC_NA); local_offset += 16;
4770         proto_item_set_text(SDGID, "(%s%u)", "SGID", i);
4771     }
4772     for (i = 0; i < DGIDCount; i++)
4773     {
4774         SDGID = proto_tree_add_item(MultiPathRecord_header_tree, hf_infiniband_MultiPathRecord_SDGID,       tvb, local_offset, 16, ENC_NA); local_offset += 16;
4775         proto_item_set_text(SDGID, "(%s%u)", "DGID", i);
4776     }
4777
4778     return local_offset;
4779 }
4780 /* Parse ServiceAssociationRecord Attribute
4781 * IN:   parentTree - The tree to add the dissection to
4782 *       tvb - The tvbbuff of packet data
4783 *       offset - The offset in TVB where the attribute begins
4784 *       MadHeader - The common MAD header of the current SMP/SMA  */
4785 static int parse_ServiceAssociationRecord(proto_tree* parentTree, tvbuff_t* tvb, gint *offset)
4786 {
4787     gint        local_offset = *offset;
4788     proto_item *ServiceAssociationRecord_header_item;
4789     proto_tree *ServiceAssociationRecord_header_tree;
4790
4791     if (!parentTree)
4792     {
4793         return *offset;
4794     }
4795
4796     ServiceAssociationRecord_header_item = proto_tree_add_item(parentTree, hf_infiniband_SA, tvb, local_offset, 80, ENC_NA);
4797     proto_item_set_text(ServiceAssociationRecord_header_item, "%s", "ServiceAssociationRecord");
4798     ServiceAssociationRecord_header_tree = proto_item_add_subtree(ServiceAssociationRecord_header_item, ett_serviceassocrecord);
4799
4800     proto_tree_add_item(ServiceAssociationRecord_header_tree, hf_infiniband_ServiceAssociationRecord_ServiceKey,        tvb, local_offset, 16, ENC_NA); local_offset += 16;
4801     proto_tree_add_item(ServiceAssociationRecord_header_tree, hf_infiniband_ServiceAssociationRecord_ServiceName,       tvb, local_offset, 64, ENC_ASCII|ENC_NA); local_offset += 64;
4802
4803     return local_offset;
4804 }
4805
4806 /* Parse PortCounters MAD from the Performance management class.
4807 * IN:   parentTree - The tree to add the dissection to
4808 *       tvb - The tvbbuff of packet data
4809 *       offset - The offset in TVB where the attribute begins
4810 *       pinfo - The packet info structure with column information  */
4811 static int parse_PERF_PortCounters(proto_tree* parentTree, tvbuff_t* tvb, packet_info *pinfo, gint *offset)
4812 {
4813     proto_item *perf_item;
4814     proto_tree *perf_tree;
4815     gint        local_offset = *offset;
4816
4817     col_set_str(pinfo->cinfo, COL_INFO, "PERF (PortCounters)");
4818
4819     perf_item = proto_tree_add_item(parentTree, hf_infiniband_PortCounters, tvb, local_offset, 40, ENC_NA);
4820     perf_tree = proto_item_add_subtree(perf_item, ett_perfclass);
4821
4822     local_offset += 40; /* skip reserved field */
4823     local_offset += 1;  /* skip reserved field */
4824     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortSelect,  tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4825     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_CounterSelect, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4826     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_SymbolErrorCounter, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4827     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_LinkErrorRecoveryCounter, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4828     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_LinkDownedCounter, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4829     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortRcvErrors, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4830     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortRcvRemotePhysicalErrors, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4831     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortRcvSwitchRelayErrors, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4832     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortXmitDiscards, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4833     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortXmitConstraintErrors, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4834     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortRcvConstraintErrors, tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4835     local_offset += 1;  /* skip reserved field */
4836     proto_tree_add_bits_item(perf_tree, hf_infiniband_PortCounters_LocalLinkIntegrityErrors, tvb, local_offset*8, 4, ENC_BIG_ENDIAN);
4837     proto_tree_add_bits_item(perf_tree, hf_infiniband_PortCounters_ExcessiveBufferOverrunErrors, tvb, local_offset*8 + 4, 4, ENC_BIG_ENDIAN); local_offset += 1;
4838     local_offset += 2;  /* skip reserved field */
4839     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_VL15Dropped, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4840     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortXmitData, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
4841     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortRcvData, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
4842     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortXmitPkts, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
4843     proto_tree_add_item(perf_tree, hf_infiniband_PortCounters_PortRcvPkts, tvb, local_offset, 4, ENC_BIG_ENDIAN); local_offset += 4;
4844
4845     *offset = local_offset; /* update caller's offset to point to end of the PortCounters payload */
4846     return local_offset;
4847 }
4848
4849 /* Parse PortCountersExtended MAD from the Performance management class.
4850 * IN:   parentTree - The tree to add the dissection to
4851 *       tvb - The tvbbuff of packet data
4852 *       offset - The offset in TVB where the attribute begins
4853 *       pinfo - The packet info structure with column information  */
4854 static int parse_PERF_PortCountersExtended(proto_tree* parentTree, tvbuff_t* tvb, packet_info *pinfo, gint *offset)
4855 {
4856     proto_item *perf_item;
4857     proto_tree *perf_tree;
4858     gint        local_offset = *offset;
4859
4860     col_set_str(pinfo->cinfo, COL_INFO, "PERF (PortCountersExtended)");
4861
4862     perf_item = proto_tree_add_item(parentTree, hf_infiniband_PortCountersExt, tvb, local_offset, 72, ENC_NA);
4863     perf_tree = proto_item_add_subtree(perf_item, ett_perfclass);
4864
4865     local_offset += 40; /* skip reserved field */
4866     local_offset += 1;  /* skip reserved field */
4867     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortSelect,  tvb, local_offset, 1, ENC_BIG_ENDIAN); local_offset += 1;
4868     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_CounterSelect, tvb, local_offset, 2, ENC_BIG_ENDIAN); local_offset += 2;
4869     local_offset += 4;  /* skip reserved field */
4870     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortXmitData, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4871     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortRcvData, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4872     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortXmitPkts, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4873     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortRcvPkts, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4874     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortUnicastXmitPkts, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4875     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortUnicastRcvPkts, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4876     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortMulticastXmitPkts, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4877     proto_tree_add_item(perf_tree, hf_infiniband_PortCountersExt_PortMulticastRcvPkts, tvb, local_offset, 8, ENC_BIG_ENDIAN); local_offset += 8;
4878
4879     *offset = local_offset; /* update caller's offset to point to end of the PortCountersExt payload */
4880     return local_offset;
4881 }
4882
4883 /* dissect_general_info
4884 * Used to extract very few values from the packet in the case that full dissection is disabled by the user.
4885 * IN:
4886 *       tvb - The tvbbuff of packet data
4887 *       offset - The offset in TVB where the attribute begins
4888 *       pinfo - The packet info structure with column information
4889 *       starts_with_grh - If true this packets start with a GRH header, otherwise with LRH  */
4890 static void dissect_general_info(tvbuff_t *tvb, gint offset, packet_info *pinfo, gboolean starts_with_grh)
4891 {
4892     guint8            lnh_val            = 0; /* The Link Next Header Value.  Tells us which headers are coming */
4893     gboolean          bthFollows         = FALSE; /* Tracks if we are parsing a BTH.  This is a significant decision point */
4894     guint8            virtualLane        = 0; /* The Virtual Lane of the current Packet */
4895     guint8            opCode             = 0; /* OpCode from BTH header. */
4896     gint32            nextHeaderSequence = -1; /* defined by this dissector. #define which indicates the upcoming header sequence from OpCode */
4897     guint8            nxtHdr             = 0; /* that must be available for that header. */
4898     struct e_in6_addr SRCgid;   /* Struct to display ipv6 Address */
4899     struct e_in6_addr DSTgid;   /* Struct to display ipv6 Address */
4900     guint8            management_class   = 0;
4901     MAD_Data          MadData;
4902
4903     if (starts_with_grh) {
4904         /* this is a RoCE packet, skip LRH parsing */
4905         lnh_val = IBA_GLOBAL;
4906         goto skip_lrh;
4907     }
4908
4909     virtualLane =  tvb_get_guint8(tvb, offset);
4910     virtualLane = virtualLane & 0xF0;
4911     offset += 1;
4912
4913     /* Save Link Next Header... This tells us what the next header is. */
4914     lnh_val =  tvb_get_guint8(tvb, offset);
4915     lnh_val = lnh_val & 0x03;
4916     offset += 1;
4917
4918     /* Set destination in packet view. */
4919     *((guint16*) dst_addr) = tvb_get_ntohs(tvb, offset);
4920     SET_ADDRESS(&pinfo->dst, AT_IB, sizeof(guint16), dst_addr);
4921
4922     offset += 4;
4923
4924     /* Set Source in packet view. */
4925     *((guint16*) src_addr) = tvb_get_ntohs(tvb, offset);
4926     SET_ADDRESS(&pinfo->src, AT_IB, sizeof(guint16), src_addr);
4927
4928     offset += 2;
4929
4930 skip_lrh:
4931
4932     switch (lnh_val)
4933     {
4934         case IBA_GLOBAL:
4935             offset += 6;
4936             nxtHdr = tvb_get_guint8(tvb, offset);
4937             offset += 2;
4938
4939             tvb_get_ipv6(tvb, offset, &SRCgid);
4940
4941             /* Set source GID in packet view. */
4942             memcpy(src_addr, &SRCgid, GID_SIZE);
4943             SET_ADDRESS(&pinfo->src, AT_IB, GID_SIZE, src_addr);
4944
4945             offset += 16;
4946
4947             tvb_get_ipv6(tvb, offset, &DSTgid);
4948
4949             /* Set destination GID in packet view. */
4950             memcpy(dst_addr, &DSTgid, GID_SIZE);
4951             SET_ADDRESS(&pinfo->dst, AT_IB, GID_SIZE, dst_addr);
4952
4953             offset += 16;
4954
4955             if (nxtHdr != 0x1B)
4956             {
4957                 /* Some kind of packet being transported globally with IBA, but locally it is not IBA - no BTH following. */
4958                 break;
4959             }
4960             /* else
4961              * {
4962              *      Fall through switch and start parsing Local Headers and BTH
4963              * }
4964              */
4965         case IBA_LOCAL:
4966             bthFollows = TRUE;
4967
4968             /* Get the OpCode - this tells us what headers are following */
4969             opCode = tvb_get_guint8(tvb, offset);
4970             col_append_str(pinfo->cinfo, COL_INFO, val_to_str_const((guint32)opCode, OpCodeMap, "Unknown OpCode"));
4971             offset += 12;
4972             break;
4973         case IP_NON_IBA:
4974             /* Raw IPv6 Packet */
4975             g_snprintf((gchar *)dst_addr,  ADDR_MAX_LEN, "IPv6 over IB Packet");
4976             SET_ADDRESS(&pinfo->dst,  AT_STRINGZ, (int)strlen((char *)dst_addr)+1, dst_addr);
4977             break;
4978         case RAW:
4979             break;
4980         default:
4981             break;
4982     }
4983
4984     if (bthFollows)
4985     {
4986         /* Find our next header sequence based on the Opcode
4987          * Since we're not doing dissection here, we just need the proper offsets to get our labels in packet view */
4988
4989         nextHeaderSequence = find_next_header_sequence((guint32) opCode);
4990         switch (nextHeaderSequence)
4991         {
4992             case RDETH_DETH_PAYLD:
4993                 offset += 4; /* RDETH */
4994                 offset += 8; /* DETH */
4995                 break;
4996             case RDETH_DETH_RETH_PAYLD:
4997                 offset += 4; /* RDETH */
4998                 offset += 8; /* DETH */
4999                 offset += 16; /* RETH */
5000                 break;
5001             case RDETH_DETH_IMMDT_PAYLD:
5002                 offset += 4; /* RDETH */
5003                 offset += 8; /* DETH */
5004                 offset += 4; /* IMMDT */
5005                 break;
5006             case RDETH_DETH_RETH_IMMDT_PAYLD:
5007                 offset += 4; /* RDETH */
5008                 offset += 8; /* DETH */
5009                 offset += 16; /* RETH */
5010                 offset += 4; /* IMMDT */
5011                 break;
5012             case RDETH_DETH_RETH:
5013                 offset += 4; /* RDETH */
5014                 offset += 8; /* DETH */
5015                 offset += 16; /* RETH */
5016                 break;
5017             case RDETH_AETH_PAYLD:
5018                 offset += 4; /* RDETH */
5019                 offset += 4; /* AETH */
5020                 break;
5021             case RDETH_PAYLD:
5022                 offset += 4; /* RDETH */
5023                 break;
5024             case RDETH_AETH:
5025                 offset += 4; /* RDETH */
5026                 offset += 4; /* AETH */
5027                 break;
5028             case RDETH_AETH_ATOMICACKETH:
5029                 offset += 4; /* RDETH */
5030                 offset += 4; /* AETH */
5031                 offset += 8; /* AtomicAckETH */
5032                 break;
5033             case RDETH_DETH_ATOMICETH:
5034                 offset += 4; /* RDETH */
5035                 offset += 8; /* DETH */
5036                 offset += 28; /* AtomicETH */
5037                 break;
5038             case RDETH_DETH:
5039                 offset += 4; /* RDETH */
5040                 offset += 8; /* DETH */
5041                 break;
5042             case DETH_PAYLD:
5043                 offset += 8; /* DETH */
5044                 break;
5045             case PAYLD:
5046                 break;
5047             case IMMDT_PAYLD:
5048                 offset += 4; /* IMMDT */
5049                 break;
5050             case RETH_PAYLD:
5051                 offset += 16; /* RETH */
5052                 break;
5053             case RETH:
5054                 offset += 16; /* RETH */
5055                 break;
5056             case AETH_PAYLD:
5057                 offset += 4; /* AETH */
5058                 break;
5059             case AETH:
5060                 offset += 4; /* AETH */
5061                 break;
5062             case AETH_ATOMICACKETH:
5063                 offset += 4; /* AETH */
5064                 offset += 8; /* AtomicAckETH */
5065                 break;
5066             case ATOMICETH:
5067                 offset += 28; /* AtomicETH */
5068                 break;
5069             case IETH_PAYLD:
5070                 offset += 4; /* IETH */
5071                 break;
5072             case DETH_IMMDT_PAYLD:
5073                 offset += 8; /* DETH */
5074                 offset += 4; /* IMMDT */
5075                 break;
5076             default:
5077                 break;
5078         }
5079     }
5080     if (virtualLane == 0xF0)
5081     {
5082         management_class =  tvb_get_guint8(tvb, offset + 1);
5083         if (((management_class >= (guint8)VENDOR_1_START) && (management_class <= (guint8)VENDOR_1_END))
5084             || ((management_class >= (guint8)VENDOR_2_START) && (management_class <= (guint8)VENDOR_2_END)))
5085         {
5086             return;
5087         }
5088         else if ((management_class >= (guint8)APPLICATION_START) && (management_class <= (guint8)APPLICATION_END))
5089         {
5090             return;
5091         }
5092         else if (((management_class == (guint8)0x00) || (management_class == (guint8)0x02))
5093                  || ((management_class >= (guint8)0x50) && (management_class <= (guint8)0x80))
5094                  || ((management_class >= (guint8)0x82)))
5095         {
5096             return;
5097         }
5098         else /* we have a normal management_class */
5099         {
5100             if (parse_MAD_Common(NULL, tvb, &offset, &MadData)) {
5101                 label_SUBM_Method(NULL, &MadData, pinfo);
5102                 label_SUBM_Attribute(NULL, &MadData, pinfo);
5103             }
5104         }
5105     }
5106
5107     return;
5108 }
5109
5110 static void proto_init_infiniband(void)
5111 {
5112     src_addr = dst_addr = NULL;
5113 }
5114
5115 /* Protocol Registration */
5116 void proto_register_infiniband(void)
5117 {
5118     module_t *infiniband_module;
5119
5120     /* Field dissector structures.
5121     * For reserved fields, reservedX denotes the reserved field is X bits in length.
5122     * e.g. reserved2 is a reserved field 2 bits in length.
5123     * The third parameter is a filter string associated for this field.
5124     * So for instance, to filter packets for a given virtual lane,
5125     * The filter (infiniband.LRH.vl == 3) or something similar would be used. */
5126
5127     /* XXX: ToDo: Verify against Infiniband 1.2.1 Specification                           */
5128     /*            Fields verified/corrected: Those after comment "XX: All following ..."  */
5129
5130     /* meanings for MAD method field */
5131     static const value_string mad_method_str[] = {
5132         { 0x01, "Get()" },
5133         { 0x02, "Set()" },
5134         { 0x81, "GetResp()" },
5135         { 0x03, "Send()" },
5136         { 0x05, "Trap()" },
5137         { 0x06, "Report()" },
5138         { 0x86, "ReportResp()" },
5139         { 0x07, "TrapRepress()" },
5140         { 0,    NULL }
5141     };
5142
5143     static hf_register_info hf[] = {
5144         /* Local Route Header (LRH) */
5145         { &hf_infiniband_LRH, {
5146                 "Local Route Header", "infiniband.lrh",
5147                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5148         },
5149         { &hf_infiniband_virtual_lane, {
5150                 "Virtual Lane", "infiniband.lrh.vl",
5151                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
5152         },
5153         { &hf_infiniband_link_version, {
5154                 "Link Version", "infiniband.lrh.lver",
5155                 FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL}
5156         },
5157         { &hf_infiniband_service_level, {
5158                 "Service Level", "infiniband.lrh.sl",
5159                 FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL}
5160         },
5161         { &hf_infiniband_reserved2, {
5162                 "Reserved (2 bits)", "infiniband.lrh.reserved2",
5163                 FT_UINT8, BASE_DEC, NULL, 0x0C, NULL, HFILL}
5164         },
5165         { &hf_infiniband_link_next_header, {
5166                 "Link Next Header", "infiniband.lrh.lnh",
5167                 FT_UINT8, BASE_HEX, NULL, 0x03, NULL, HFILL}
5168         },
5169         { &hf_infiniband_destination_local_id, {
5170                 "Destination Local ID", "infiniband.lrh.dlid",
5171                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
5172         },
5173         { &hf_infiniband_reserved5, {
5174                 "Reserved (5 bits)", "infiniband.lrh.reserved5",
5175                 FT_UINT16, BASE_DEC, NULL, 0xF800, NULL, HFILL}
5176         },
5177         { &hf_infiniband_packet_length, {
5178                 "Packet Length", "infiniband.lrh.pktlen",
5179                 FT_UINT16, BASE_DEC, NULL, 0x07FF, NULL, HFILL}
5180         },
5181         { &hf_infiniband_source_local_id, {
5182                 "Source Local ID", "infiniband.lrh.slid",
5183                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
5184         },
5185
5186         /* Global Route Header (GRH) */
5187         { &hf_infiniband_GRH, {
5188                 "Global Route Header", "infiniband.grh",
5189                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5190         },
5191         { &hf_infiniband_ip_version, {
5192                 "IP Version", "infiniband.grh.ipver",
5193                 FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL}
5194         },
5195         { &hf_infiniband_traffic_class, {
5196                 "Traffic Class", "infiniband.grh.tclass",
5197                 FT_UINT16, BASE_DEC, NULL, 0x0FF0, NULL, HFILL}
5198         },
5199         { &hf_infiniband_flow_label, {
5200                 "Flow Label", "infiniband.grh.flowlabel",
5201                 FT_UINT32, BASE_DEC, NULL, 0x000FFFFF, NULL, HFILL}
5202         },
5203         { &hf_infiniband_payload_length, {
5204                 "Payload Length", "infiniband.grh.paylen",
5205                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
5206         },
5207         { &hf_infiniband_next_header, {
5208                 "Next Header", "infiniband.grh.nxthdr",
5209                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
5210         },
5211         { &hf_infiniband_hop_limit, {
5212                 "Hop Limit", "infiniband.grh.hoplmt",
5213                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
5214         },
5215         { &hf_infiniband_source_gid, {
5216                 "Source GID", "infiniband.grh.sgid",
5217                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
5218         },
5219         { &hf_infiniband_destination_gid, {
5220                 "Destination GID", "infiniband.grh.dgid",
5221                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
5222         },
5223
5224         /* Base Transport Header (BTH) */
5225         { &hf_infiniband_BTH, {
5226                 "Base Transport Header", "infiniband.bth",
5227                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5228         },
5229         { &hf_infiniband_opcode, {
5230                 "Opcode", "infiniband.bth.opcode",
5231                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
5232         },
5233         { &hf_infiniband_solicited_event, {
5234                 "Solicited Event", "infiniband.bth.se",
5235                 FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}
5236         },
5237         { &hf_infiniband_migreq, {
5238                 "MigReq", "infiniband.bth.m",
5239                 FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL}
5240         },
5241         { &hf_infiniband_pad_count, {
5242                 "Pad Count", "infiniband.bth.padcnt",
5243                 FT_UINT8, BASE_DEC, NULL, 0x30, NULL, HFILL}
5244         },
5245         { &hf_infiniband_transport_header_version, {
5246                 "Header Version", "infiniband.bth.tver",
5247                 FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL}
5248         },
5249         { &hf_infiniband_partition_key, {
5250                 "Partition Key", "infiniband.bth.p_key",
5251                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
5252         },
5253         { &hf_infiniband_reserved8, {
5254                 "Reserved (8 bits)", "infiniband.bth.reserved8",
5255                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
5256         },
5257         { &hf_infiniband_destination_qp, {
5258                 "Destination Queue Pair", "infiniband.bth.destqp",
5259                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
5260         },
5261         { &hf_infiniband_acknowledge_request, {
5262                 "Acknowledge Request", "infiniband.bth.a",
5263                 FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}
5264         },
5265         { &hf_infiniband_reserved7, {
5266                 "Reserved (7 bits)", "infiniband.bth.reserved7",
5267                 FT_UINT8, BASE_DEC, NULL, 0x7F, NULL, HFILL}
5268         },
5269         { &hf_infiniband_packet_sequence_number, {
5270                 "Packet Sequence Number", "infiniband.bth.psn",
5271                 FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL}
5272         },
5273
5274         /* Raw Header (RWH) */
5275         { &hf_infiniband_RWH, {
5276                 "Raw Header", "infiniband.rwh",
5277                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5278         },
5279         { &hf_infiniband_reserved16_RWH, {
5280                 "Reserved (16 bits)", "infiniband.rwh.reserved",
5281                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
5282         },
5283         { &hf_infiniband_etype, {
5284                 "Ethertype", "infiniband.rwh.etype",
5285                 FT_UINT16, BASE_HEX, NULL /*VALS(etype_vals)*/, 0x0, "Type", HFILL }
5286         },
5287
5288         /* Reliable Datagram Extended Transport Header (RDETH) */
5289         { &hf_infiniband_RDETH, {
5290                 "Reliable Datagram Extended Transport Header", "infiniband.rdeth",
5291                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5292         },
5293         { &hf_infiniband_reserved8_RDETH, {
5294                 "Reserved (8 bits)", "infiniband.rdeth.reserved8",
5295                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
5296         },
5297         { &hf_infiniband_ee_context, {
5298                 "E2E Context", "infiniband.rdeth.eecnxt",
5299                 FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL}
5300         },
5301
5302         /* Datagram Extended Transport Header (DETH) */
5303         { &hf_infiniband_DETH, {
5304                 "Datagram Extended Transport Header", "infiniband.deth",
5305                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5306         },
5307         { &hf_infiniband_queue_key, {
5308                 "Queue Key", "infiniband.deth.q_key",
5309                 FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
5310         },
5311         { &hf_infiniband_reserved8_DETH, {
5312                 "Reserved (8 bits)", "infiniband.deth.reserved8",
5313                 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
5314         },
5315         { &hf_infiniband_source_qp, {
5316                 "Source Queue Pair", "infiniband.deth.srcqp",
5317                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5318         },
5319
5320         /* RDMA Extended Transport Header (RETH) */
5321         { &hf_infiniband_RETH, {
5322                 "RDMA Extended Transport Header", "infiniband.reth",
5323                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5324         },
5325         { &hf_infiniband_virtual_address, {
5326                 "Virtual Address", "infiniband.reth.va",
5327                 FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
5328         },
5329         { &hf_infiniband_remote_key, {
5330                 "Remote Key", "infiniband.reth.r_key",
5331                 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
5332         },
5333         { &hf_infiniband_dma_length, {
5334                 "DMA Length", "infiniband.reth.dmalen",
5335                 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
5336         },
5337
5338         /* Atomic Extended Transport Header (AtomicETH) */
5339         { &hf_infiniband_AtomicETH, {
5340                 "Atomic Extended Transport Header", "infiniband.atomiceth",
5341                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5342         },
5343 #if 0
5344         { &hf_infiniband_virtual_address_AtomicETH, {
5345                 "Virtual Address", "infiniband.atomiceth.va",
5346                 FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
5347         },
5348         { &hf_infiniband_remote_key_AtomicETH, {
5349                 "Remote Key", "infiniband.atomiceth.r_key",
5350                 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
5351         },
5352 #endif
5353         { &hf_infiniband_swap_or_add_data, {
5354                 "Swap (Or Add) Data", "infiniband.atomiceth.swapdt",
5355                 FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
5356         },
5357         { &hf_infiniband_compare_data, {
5358                 "Compare Data", "infiniband.atomiceth.cmpdt",
5359                 FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
5360         },
5361
5362         /* ACK Extended Transport Header (AETH) */
5363         { &hf_infiniband_AETH, {
5364                 "ACK Extended Transport Header", "infiniband.aeth",
5365                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5366         },
5367         { &hf_infiniband_syndrome, {
5368                 "Syndrome", "infiniband.aeth.syndrome",
5369                 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
5370         },
5371         { &hf_infiniband_message_sequence_number, {
5372                 "Message Sequence Number", "infiniband.aeth.msn",
5373                 FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL}
5374         },
5375
5376         /* Atomic ACK Extended Transport Header (AtomicAckETH) */
5377         { &hf_infiniband_AtomicAckETH, {
5378                 "Atomic ACK Extended Transport Header", "infiniband.atomicacketh",
5379                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5380         },
5381         { &hf_infiniband_original_remote_data, {
5382                 "Original Remote Data", "infiniband.atomicacketh.origremdt",
5383                 FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
5384         },
5385
5386         /* Immediate Extended Transport Header (ImmDT) */
5387         { &hf_infiniband_IMMDT, {
5388                 "Immediate Data", "infiniband.immdt",
5389                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5390         },
5391
5392         /* Invalidate Extended Transport Header (IETH) */
5393         { &hf_infiniband_IETH, {
5394                 "RKey", "infiniband.ieth",
5395                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5396         },
5397
5398         /* Payload */
5399         { &hf_infiniband_payload, {
5400                 "Payload", "infiniband.payload",
5401                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5402         },
5403         { &hf_infiniband_invariant_crc, {
5404                 "Invariant CRC", "infiniband.invariant.crc",
5405                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5406         },
5407         { &hf_infiniband_variant_crc, {
5408                 "Variant CRC", "infiniband.variant.crc",
5409                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5410         },
5411         { &hf_infiniband_raw_data, {
5412                 "Raw Data", "infiniband.rawdata",
5413                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5414         },
5415         /* Unknown or Vendor Specific */
5416         { &hf_infiniband_vendor, {
5417                 "Unknown/Vendor Specific Data", "infiniband.vendor",
5418                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5419         },
5420         /* CM REQ Header */
5421         {&hf_cm_req_local_comm_id, {
5422                 "Local Communication ID", "infiniband.cm.req",
5423                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5424         },
5425         {&hf_cm_req_service_id, {
5426                 "ServiceID", "infiniband.cm.req.serviceid",
5427                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
5428         },
5429         {&hf_cm_req_local_ca_guid, {
5430                 "Local CA GUID", "infiniband.cm.req.localcaguid",
5431                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
5432         },
5433         {&hf_cm_req_local_qkey, {
5434                 "Local Q_Key", "infiniband.cm.req.localqkey",
5435                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5436         },
5437         {&hf_cm_req_local_qpn, {
5438                 "Local QPN", "infiniband.cm.req.localqpn",
5439                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
5440         },
5441         {&hf_cm_req_respo_res, {
5442                 "Responder Resources", "infiniband.cm.req.responderres",
5443                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5444         },
5445         {&hf_cm_req_local_eecn, {
5446                 "Local EECN", "infiniband.cm.req.localeecn",
5447                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
5448         },
5449         {&hf_cm_req_init_depth, {
5450                 "Initiator Depth", "infiniband.cm.req.initdepth",
5451                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5452         },
5453         {&hf_cm_req_remote_eecn, {
5454                 "Remote EECN", "infiniband.cm.req.remoteeecn",
5455                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
5456         },
5457         {&hf_cm_req_remote_cm_resp_to, {
5458                 "Remote CM Response Timeout", "infiniband.cm.req.remoteresptout",
5459                 FT_UINT8, BASE_HEX, NULL, 0x1f, NULL, HFILL}
5460         },
5461         {&hf_cm_req_transp_serv_type, {
5462                 "Transport Service Type", "infiniband.cm.req.transpsvctype",
5463                 FT_UINT8, BASE_HEX, NULL, 0x60, NULL, HFILL}
5464         },
5465         {&hf_cm_req_e2e_flow_ctrl, {
5466                 "End-to-End Flow Control", "infiniband.cm.req.e2eflowctrl",
5467                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
5468         },
5469         {&hf_cm_req_start_psn, {
5470                 "Starting PSN", "infiniband.cm.req.startpsn",
5471                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
5472         },
5473         {&hf_cm_req_local_cm_resp_to, {
5474                 "Local CM Response Timeout", "infiniband.cm.req.localresptout",
5475                 FT_UINT8, BASE_HEX, NULL, 0x1f, NULL, HFILL}
5476         },
5477         {&hf_cm_req_retry_count, {
5478                 "Retry Count", "infiniband.cm.req.retrcount",
5479                 FT_UINT8, BASE_HEX, NULL, 0xe0, NULL, HFILL}
5480         },
5481         {&hf_cm_req_pkey, {
5482                 "Partition Key", "infiniband.cm.req.pkey",
5483                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5484         },
5485         {&hf_cm_req_path_pp_mtu, {
5486                 "Path Packet Payload MTU", "infiniband.cm.req.pppmtu",
5487                 FT_UINT8, BASE_HEX, NULL, 0xf, NULL, HFILL}
5488         },
5489         {&hf_cm_req_rdc_exists, {
5490                 "RDC Exists", "infiniband.cm.req.rdcexist",
5491                 FT_UINT8, BASE_HEX, NULL, 0x10, NULL, HFILL}
5492         },
5493         {&hf_cm_req_rnr_retry_count, {
5494                 "RNR Retry Count", "infiniband.cm.req.rnrretrcount",
5495                 FT_UINT8, BASE_HEX, NULL, 0xe0, NULL, HFILL}
5496         },
5497         {&hf_cm_req_max_cm_retries, {
5498                 "Max CM Retries", "infiniband.cm.req.maxcmretr",
5499                 FT_UINT8, BASE_HEX, NULL, 0xf, NULL, HFILL}
5500         },
5501         {&hf_cm_req_srq, {
5502                 "SRQ", "infiniband.cm.req.srq",
5503                 FT_UINT8, BASE_HEX, NULL, 0x10, NULL, HFILL}
5504         },
5505         {&hf_cm_req_primary_local_lid, {
5506                 "Primary Local Port LID", "infiniband.cm.req.prim_locallid",
5507                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
5508         },
5509         {&hf_cm_req_primary_remote_lid, {
5510                 "Primary Remote Port LID", "infiniband.cm.req.prim_remotelid",
5511                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
5512         },
5513         {&hf_cm_req_primary_local_gid, {
5514                 "Primary Local Port GID", "infiniband.cm.req.prim_localgid",
5515                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
5516         },
5517         {&hf_cm_req_primary_remote_gid, {
5518                 "Primary Remote Port GID", "infiniband.cm.req.prim_remotegid",
5519                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
5520         },
5521         {&hf_cm_req_primary_flow_label, {
5522                 "Primary Flow Label", "infiniband.cm.req.prim_flowlabel",
5523                 FT_UINT24, BASE_HEX, NULL, 0xfffff, NULL, HFILL}
5524         },
5525         {&hf_cm_req_primary_packet_rate, {
5526                 "Primary Packet Rate", "infiniband.cm.req.prim_pktrate",
5527                 FT_UINT8, BASE_HEX, NULL, 0xfc, NULL, HFILL}
5528         },
5529         {&hf_cm_req_primary_traffic_class, {
5530                 "Primary Traffic Class", "infiniband.cm.req.prim_tfcclass",
5531                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5532         },
5533         {&hf_cm_req_primary_hop_limit, {
5534                 "Primary Hop Limit", "infiniband.cm.req.prim_hoplim",
5535                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5536         },
5537         {&hf_cm_req_primary_sl, {
5538                 "Primary SL", "infiniband.cm.req.prim_sl",
5539                 FT_UINT8, BASE_HEX, NULL, 0xf, NULL, HFILL}
5540         },
5541         {&hf_cm_req_primary_subnet_local, {
5542                 "Primary Subnet Local", "infiniband.cm.req.prim_subnetlocal",
5543                 FT_UINT8, BASE_HEX, NULL, 0x10, NULL, HFILL}
5544         },
5545         {&hf_cm_req_primary_local_ack_to, {
5546                 "Primary Local ACK Timeout", "infiniband.cm.req.prim_localacktout",
5547                 FT_UINT8, BASE_HEX, NULL, 0x1f, NULL, HFILL}
5548         },
5549         {&hf_cm_req_alt_local_lid, {
5550                 "Alternate Local Port LID", "infiniband.cm.req.alt_locallid",
5551                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
5552         },
5553         {&hf_cm_req_alt_remote_lid, {
5554                 "Alternate Remote Port LID", "infiniband.cm.req.alt_remotelid",
5555                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
5556         },
5557         {&hf_cm_req_alt_local_gid, {
5558                 "Alternate Local Port GID", "infiniband.cm.req.alt_localgid",
5559                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5560         },
5561         {&hf_cm_req_alt_remote_gid, {
5562                 "Alternate Remote Port GID", "infiniband.cm.req.alt_remotegid",
5563                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5564         },
5565         {&hf_cm_req_flow_label, {
5566                 "Alternate Flow Label", "infiniband.cm.req.alt_flowlabel",
5567                 FT_UINT24, BASE_HEX, NULL, 0xfffff, NULL, HFILL}
5568         },
5569         {&hf_cm_req_packet_rate, {
5570                 "Alternate Packet Rate", "infiniband.cm.req.alt_pktrate",
5571                 FT_UINT8, BASE_HEX, NULL, 0xfc, NULL, HFILL}
5572         },
5573         {&hf_cm_req_alt_traffic_class, {
5574                 "Alternate Traffic Class", "infiniband.cm.req.alt_tfcclass",
5575                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5576         },
5577         {&hf_cm_req_alt_hop_limit, {
5578                 "Alternate Hop Limit", "infiniband.cm.req.alt_hoplim",
5579                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5580         },
5581         {&hf_cm_req_SL, {
5582                 "Alternate SL", "infiniband.cm.req.alt_sl",
5583                 FT_UINT8, BASE_HEX, NULL, 0xf, NULL, HFILL}
5584         },
5585         {&hf_cm_req_subnet_local, {
5586                 "Alternate Subnet Local", "infiniband.cm.req.alt_subnetlocal",
5587                 FT_UINT8, BASE_HEX, NULL, 0x10, NULL, HFILL}
5588         },
5589         {&hf_cm_req_local_ACK_timeout, {
5590                 "Alternate Local ACK Timeout", "infiniband.cm.req.alt_localacktout",
5591                 FT_UINT8, BASE_HEX, NULL, 0x1f, NULL, HFILL}
5592         },
5593         {&hf_cm_req_private_data, {
5594                 "PrivateData", "infiniband.cm.req.private",
5595                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5596         },
5597         /* CM REP Header */
5598         {&hf_cm_rep_localcommid, {
5599                 "Local Communication ID", "infiniband.cm.rep",
5600                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5601         },
5602         {&hf_cm_rep_remotecommid, {
5603                 "Remote Communication ID", "infiniband.cm.rep.remotecommid",
5604                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5605         },
5606         {&hf_cm_rep_localqkey, {
5607                 "Local Q_Key", "infiniband.cm.rep.localqkey",
5608                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5609         },
5610         {&hf_cm_rep_localqpn, {
5611                 "Local QPN", "infiniband.cm.rep.localqpn",
5612                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
5613         },
5614         {&hf_cm_rep_localeecontnum, {
5615                 "Local EE Context Number", "infiniband.cm.rep.localeecn",
5616                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
5617         },
5618         {&hf_cm_rep_startingpsn, {
5619                 "Starting PSN", "infiniband.cm.rep.startpsn",
5620                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
5621         },
5622         {&hf_cm_rep_responderres, {
5623                 "Responder Resources", "infiniband.cm.rep.respres",
5624                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5625         },
5626         {&hf_cm_rep_initiatordepth, {
5627                 "Initiator Depth", "infiniband.cm.rep.initdepth",
5628                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5629         },
5630         {&hf_cm_rep_tgtackdelay, {
5631                 "Target ACK Delay", "infiniband.cm.rep.tgtackdelay",
5632                 FT_UINT8, BASE_HEX, NULL, 0x1f, NULL, HFILL}
5633         },
5634         {&hf_cm_rep_failoveracc, {
5635                 "Failover Accepted", "infiniband.cm.rep.failoveracc",
5636                 FT_UINT8, BASE_HEX, NULL, 0x60, NULL, HFILL}
5637         },
5638         {&hf_cm_rep_e2eflowctl, {
5639                 "End-To-End Flow Control", "infiniband.cm.rep.e2eflowctrl",
5640                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
5641         },
5642         {&hf_cm_rep_rnrretrycount, {
5643                 "RNR Retry Count", "infiniband.cm.rep.rnrretrcount",
5644                 FT_UINT8, BASE_HEX, NULL, 0x7, NULL, HFILL}
5645         },
5646         {&hf_cm_rep_srq, {
5647                 "SRQ", "infiniband.cm.rep.srq",
5648                 FT_UINT8, BASE_HEX, NULL, 0x8, NULL, HFILL}
5649         },
5650         {&hf_cm_rep_localcaguid, {
5651                 "Local CA GUID", "infiniband.cm.rep.localcaguid",
5652                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
5653         },
5654         {&hf_cm_rep_privatedata, {
5655                 "PrivateData", "infiniband.cm.rep.private",
5656                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5657         },
5658         /* IB CM RTU Header */
5659         {&hf_cm_rtu_localcommid, {
5660                 "Local Communication ID", "infiniband.cm.rtu.localcommid",
5661                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5662         },
5663         {&hf_cm_rtu_remotecommid, {
5664                 "Remote Communication ID", "infiniband.cm.rtu.remotecommid",
5665                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5666         },
5667         {&hf_cm_rtu_privatedata, {
5668                 "PrivateData", "infiniband.cm.rtu.private",
5669                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5670         },
5671         /* CM REJ Header */
5672         {&hf_cm_rej_local_commid, {
5673                 "Local Communication ID", "infiniband.cm.rej.localcommid",
5674                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5675         },
5676         {&hf_cm_rej_remote_commid, {
5677                 "Remote Communication ID", "infiniband.cm.rej.remotecommid",
5678                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5679         },
5680         {&hf_cm_rej_msg_rej, {
5681                 "Message REJected", "infiniband.cm.rej.msgrej",
5682                 FT_UINT8, BASE_HEX, NULL, 0x3, NULL, HFILL}
5683         },
5684         {&hf_cm_rej_rej_info_len, {
5685                 "Reject Info Length", "infiniband.cm.rej.rejinfolen",
5686                 FT_UINT8, BASE_HEX, NULL, 0x7f, NULL, HFILL}
5687         },
5688         {&hf_cm_rej_reason, {
5689                 "Reason", "infiniband.cm.rej.reason",
5690                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5691         },
5692         {&hf_cm_rej_add_rej_info, {
5693                 "Additional Reject Information (ARI)", "infiniband.cm.rej.ari",
5694                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5695         },
5696         {&hf_cm_rej_private_data, {
5697                 "PrivateData", "infiniband.cm.rej.private",
5698                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5699         },
5700         /* MAD Base Header */
5701         { &hf_infiniband_MAD, {
5702                 "MAD (Management Datagram) Common Header", "infiniband.mad",
5703                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5704         },
5705         { &hf_infiniband_base_version, {
5706                 "Base Version", "infiniband.mad.baseversion",
5707                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5708         },
5709         { &hf_infiniband_mgmt_class, {
5710                 "Management Class", "infiniband.mad.mgmtclass",
5711                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5712         },
5713         { &hf_infiniband_class_version, {
5714                 "Class Version", "infiniband.mad.classversion",
5715                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5716         },
5717 #if 0
5718         { &hf_infiniband_reserved1, {
5719                 "Reserved", "infiniband.mad.reserved1",
5720                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
5721         },
5722 #endif
5723         { &hf_infiniband_method, {
5724                 "Method", "infiniband.mad.method",
5725                 FT_UINT8, BASE_HEX, VALS(mad_method_str), 0x0, NULL, HFILL}
5726         },
5727         { &hf_infiniband_status, {
5728                 "Status", "infiniband.mad.status",
5729                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5730         },
5731         { &hf_infiniband_class_specific, {
5732                 "Class Specific", "infiniband.mad.classspecific",
5733                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5734         },
5735         { &hf_infiniband_transaction_id, {
5736                 "Transaction ID", "infiniband.mad.transactionid",
5737                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
5738         },
5739         { &hf_infiniband_attribute_id, {
5740                 "Attribute ID", "infiniband.mad.attributeid",
5741                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5742         },
5743         { &hf_infiniband_reserved16, {
5744                 "Reserved", "infiniband.mad.reserved16",
5745                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5746         },
5747         { &hf_infiniband_attribute_modifier, {
5748                 "Attribute Modifier", "infiniband.mad.attributemodifier",
5749                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5750         },
5751         { &hf_infiniband_data, {
5752                 "MAD Data Payload", "infiniband.mad.data",
5753                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5754         },
5755
5756         /* RMPP Header */
5757         { &hf_infiniband_RMPP, {
5758                 "RMPP (Reliable Multi-Packet Transaction Protocol)", "infiniband.rmpp",
5759                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5760         },
5761         { &hf_infiniband_rmpp_version, {
5762                 "RMPP Type", "infiniband.rmpp.rmppversion",
5763                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5764         },
5765         { &hf_infiniband_rmpp_type, {
5766                 "RMPP Type", "infiniband.rmpp.rmpptype",
5767                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5768         },
5769         { &hf_infiniband_r_resp_time, {
5770                 "R Resp Time", "infiniband.rmpp.rresptime",
5771                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
5772         },
5773         { &hf_infiniband_rmpp_flags, {
5774                 "RMPP Flags", "infiniband.rmpp.rmppflags",
5775                 FT_UINT8, BASE_HEX, VALS(RMPP_Flags), 0x0F, NULL, HFILL}
5776         },
5777         { &hf_infiniband_rmpp_status, {
5778                 "RMPP Status", "infiniband.rmpp.rmppstatus",
5779                 FT_UINT8, BASE_HEX, VALS(RMPP_Status), 0x0, NULL, HFILL}
5780         },
5781         { &hf_infiniband_rmpp_data1, {
5782                 "RMPP Data 1", "infiniband.rmpp.data1",
5783                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5784         },
5785         { &hf_infiniband_rmpp_data2, {
5786                 "RMPP Data 2", "infiniband.rmpp.data2",
5787                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5788         },
5789
5790     /* RMPP Data */
5791 #if 0
5792         { &hf_infiniband_RMPP_DATA, {
5793                 "RMPP Data (Reliable Multi-Packet Transaction Protocol)", "infiniband.rmpp.data",
5794                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5795         },
5796 #endif
5797         { &hf_infiniband_segment_number, {
5798                 "Segment Number", "infiniband.rmpp.segmentnumber",
5799                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5800         },
5801         { &hf_infiniband_payload_length32, {
5802                 "Payload Length", "infiniband.rmpp.payloadlength",
5803                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5804         },
5805         { &hf_infiniband_transferred_data, {
5806                 "Transferred Data", "infiniband.rmpp.transferreddata",
5807                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5808         },
5809
5810         /* RMPP ACK */
5811         { &hf_infiniband_new_window_last, {
5812                 "New Window Last", "infiniband.rmpp.newwindowlast",
5813                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5814         },
5815         { &hf_infiniband_reserved220, {
5816                 "Segment Number", "infiniband.rmpp.reserved220",
5817                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5818         },
5819
5820         /* RMPP ABORT/STOP */
5821         { &hf_infiniband_reserved32, {
5822                 "Reserved (32 bits)", "infiniband.rmpp.reserved32",
5823                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5824         },
5825         { &hf_infiniband_optional_extended_error_data, {
5826                 "Optional Extended Error Data", "infiniband.rmpp.extendederrordata",
5827                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5828         },
5829
5830         /* SMP Data (LID Routed) */
5831         { &hf_infiniband_SMP_LID, {
5832                 "Subnet Management Packet (LID Routed)", "infiniband.smplid",
5833                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5834         },
5835         { &hf_infiniband_m_key, {
5836                 "M_Key", "infiniband.smplid.mkey",
5837                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
5838         },
5839         { &hf_infiniband_smp_data, {
5840                 "SMP Data", "infiniband.smplid.smpdata",
5841                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5842         },
5843         { &hf_infiniband_reserved1024, {
5844                 "Reserved (1024 bits)", "infiniband.smplid.reserved1024",
5845                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5846         },
5847         { &hf_infiniband_reserved256, {
5848                 "Reserved (256 bits)", "infiniband.smplid.reserved256",
5849                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5850         },
5851
5852     /* XX: All following verified/corrected against Infiniband 1.2.1 Specification */
5853         /* SMP Data Directed Route */
5854         { &hf_infiniband_SMP_DIRECTED, {
5855                 "Subnet Management Packet (Directed Route)", "infiniband.smpdirected",
5856                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5857         },
5858         { &hf_infiniband_smp_status, {
5859                 "Status", "infiniband.smpdirected.smpstatus",
5860                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5861         },
5862         { &hf_infiniband_hop_pointer, {
5863                 "Hop Pointer", "infiniband.smpdirected.hoppointer",
5864                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5865         },
5866         { &hf_infiniband_hop_count, {
5867                 "Hop Count", "infiniband.smpdirected.hopcount",
5868                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5869         },
5870         { &hf_infiniband_dr_slid, {
5871                 "DrSLID", "infiniband.smpdirected.drslid",
5872                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5873         },
5874         { &hf_infiniband_dr_dlid, {
5875                 "DrDLID", "infiniband.smpdirected.drdlid",
5876                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5877         },
5878         { &hf_infiniband_reserved28, {
5879                 "Reserved (224 bits)", "infiniband.smpdirected.reserved28",
5880                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5881         },
5882         { &hf_infiniband_d, {
5883                 "D (Direction Bit)", "infiniband.smpdirected.d",
5884                 FT_UINT64, BASE_HEX, NULL, 0x8000, NULL, HFILL}
5885         },
5886         { &hf_infiniband_initial_path, {
5887                 "Initial Path", "infiniband.smpdirected.initialpath",
5888                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5889         },
5890         { &hf_infiniband_return_path, {
5891                 "Return Path", "infiniband.smpdirected.returnpath",
5892                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5893         },
5894
5895         /* SA MAD Header */
5896         { &hf_infiniband_SA, {
5897                 "SA Packet (Subnet Administration)", "infiniband.sa.drdlid",
5898                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5899         },
5900         { &hf_infiniband_sm_key, {
5901                 "SM_Key (Verification Key)", "infiniband.sa.smkey",
5902                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
5903         },
5904         { &hf_infiniband_attribute_offset, {
5905                 "Attribute Offset", "infiniband.sa.attributeoffset",
5906                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5907         },
5908         { &hf_infiniband_component_mask, {
5909                 "Component Mask", "infiniband.sa.componentmask",
5910                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
5911         },
5912         { &hf_infiniband_subnet_admin_data, {
5913                 "Subnet Admin Data", "infiniband.sa.subnetadmindata",
5914                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
5915         },
5916
5917         /* Mellanox EoIB encapsulation header */
5918         { &hf_infiniband_EOIB, {
5919                 "Mellanox EoIB Encapsulation Header", "infiniband.eoib",
5920                 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL}
5921         },
5922         { &hf_infiniband_ver, {
5923                 "Version", "infiniband.eoib.version",
5924                 FT_UINT16, BASE_HEX, NULL, 0x3000, NULL, HFILL}
5925         },
5926         { &hf_infiniband_tcp_chk, {
5927                 "TCP Checksum", "infiniband.eoib.tcp_chk",
5928                 FT_UINT16, BASE_HEX, NULL, 0x0c00, NULL, HFILL}
5929         },
5930         { &hf_infiniband_ip_chk, {
5931                 "IP Checksum", "infiniband.eoib.ip_chk",
5932                 FT_UINT16, BASE_HEX, NULL, 0x0300, NULL, HFILL}
5933         },
5934         { &hf_infiniband_fcs, {
5935                 "FCS Field Present", "infiniband.eoib.fcs",
5936                 FT_BOOLEAN, 16, NULL, 0x0040, NULL, HFILL}
5937         },
5938         { &hf_infiniband_ms, {
5939                 "More Segments to Follow", "infiniband.eoib.ms",
5940                 FT_BOOLEAN, 16, NULL, 0x0020, NULL, HFILL}
5941         },
5942         { &hf_infiniband_seg_off, {
5943                 "Segment Offset", "infiniband.eoib.ip_seg_offset",
5944                 FT_UINT16, BASE_DEC, NULL, 0x001f, NULL, HFILL}
5945         },
5946         { &hf_infiniband_seg_id, {
5947                 "Segment ID", "infiniband.eoib.ip_seg_id",
5948                 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
5949         },
5950
5951         /* NodeDescription */
5952         { &hf_infiniband_NodeDescription_NodeString, {
5953                 "NodeString", "infiniband.nodedescription.nodestring",
5954                 FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}
5955         },
5956
5957         /* NodeInfo */
5958         { &hf_infiniband_NodeInfo_BaseVersion, {
5959                 "BaseVersion", "infiniband.nodeinfo.baseversion",
5960                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5961         },
5962         { &hf_infiniband_NodeInfo_ClassVersion, {
5963                 "ClassVersion", "infiniband.nodeinfo.classversion",
5964                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5965         },
5966         { &hf_infiniband_NodeInfo_NodeType, {
5967                 "NodeType", "infiniband.nodeinfo.nodetype",
5968                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5969         },
5970         { &hf_infiniband_NodeInfo_NumPorts, {
5971                 "NumPorts", "infiniband.nodeinfo.numports",
5972                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
5973         },
5974         { &hf_infiniband_NodeInfo_SystemImageGUID, {
5975                 "SystemImageGUID", "infiniband.nodeinfo.systemimageguid",
5976                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
5977         },
5978         { &hf_infiniband_NodeInfo_NodeGUID, {
5979                 "NodeGUID", "infiniband.nodeinfo.nodeguid",
5980                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
5981         },
5982         { &hf_infiniband_NodeInfo_PortGUID, {
5983                 "PortGUID", "infiniband.nodeinfo.portguid",
5984                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
5985         },
5986         { &hf_infiniband_NodeInfo_PartitionCap, {
5987                 "PartitionCap", "infiniband.nodeinfo.partitioncap",
5988                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5989         },
5990         { &hf_infiniband_NodeInfo_DeviceID, {
5991                 "DeviceID", "infiniband.nodeinfo.deviceid",
5992                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
5993         },
5994         { &hf_infiniband_NodeInfo_Revision, {
5995                 "Revision", "infiniband.nodeinfo.revision",
5996                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
5997         },
5998         { &hf_infiniband_NodeInfo_LocalPortNum, {
5999                 "LocalPortNum", "infiniband.nodeinfo.localportnum",
6000                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6001         },
6002         { &hf_infiniband_NodeInfo_VendorID, {
6003                 "VendorID", "infiniband.nodeinfo.vendorid",
6004                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
6005         },
6006
6007         /* SwitchInfo */
6008         { &hf_infiniband_SwitchInfo_LinearFDBCap, {
6009                 "LinearFDBCap", "infiniband.switchinfo.linearfdbcap",
6010                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6011         },
6012         { &hf_infiniband_SwitchInfo_RandomFDBCap, {
6013                 "RandomFDBCap", "infiniband.switchinfo.randomfdbcap",
6014                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6015         },
6016         { &hf_infiniband_SwitchInfo_MulticastFDBCap, {
6017                 "MulticastFDBCap", "infiniband.switchinfo.multicastfdbcap",
6018                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6019         },
6020         { &hf_infiniband_SwitchInfo_LinearFDBTop, {
6021                 "LinearFDBTop", "infiniband.switchinfo.linearfdbtop",
6022                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6023         },
6024         { &hf_infiniband_SwitchInfo_DefaultPort, {
6025                 "DefaultPort", "infiniband.switchinfo.defaultport",
6026                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6027         },
6028         { &hf_infiniband_SwitchInfo_DefaultMulticastPrimaryPort, {
6029                 "DefaultMulticastPrimaryPort", "infiniband.switchinfo.defaultmulticastprimaryport",
6030                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6031         },
6032         { &hf_infiniband_SwitchInfo_DefaultMulticastNotPrimaryPort, {
6033                 "DefaultMulticastNotPrimaryPort", "infiniband.switchinfo.defaultmulticastnotprimaryport",
6034                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6035         },
6036         { &hf_infiniband_SwitchInfo_LifeTimeValue, {
6037                 "LifeTimeValue", "infiniband.switchinfo.lifetimevalue",
6038                 FT_UINT8, BASE_HEX, NULL, 0xF8, NULL, HFILL}
6039         },
6040         { &hf_infiniband_SwitchInfo_PortStateChange, {
6041                 "PortStateChange", "infiniband.switchinfo.portstatechange",
6042                 FT_UINT8, BASE_HEX, NULL, 0x04, NULL, HFILL}
6043         },
6044         { &hf_infiniband_SwitchInfo_OptimizedSLtoVLMappingProgramming, {
6045                 "OptimizedSLtoVLMappingProgramming", "infiniband.switchinfo.optimizedsltovlmappingprogramming",
6046                 FT_UINT8, BASE_HEX, NULL, 0x03, NULL, HFILL}
6047         },
6048         { &hf_infiniband_SwitchInfo_LIDsPerPort, {
6049                 "LIDsPerPort", "infiniband.switchinfo.lidsperport",
6050                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6051         },
6052         { &hf_infiniband_SwitchInfo_PartitionEnforcementCap, {
6053                 "PartitionEnforcementCap", "infiniband.switchinfo.partitionenforcementcap",
6054                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6055         },
6056         { &hf_infiniband_SwitchInfo_InboundEnforcementCap, {
6057                 "InboundEnforcementCap", "infiniband.switchinfo.inboundenforcementcap",
6058                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6059         },
6060         { &hf_infiniband_SwitchInfo_OutboundEnforcementCap, {
6061                 "OutboundEnforcementCap", "infiniband.switchinfo.outboundenforcementcap",
6062                 FT_UINT8, BASE_HEX, NULL, 0x40, NULL, HFILL}
6063         },
6064         { &hf_infiniband_SwitchInfo_FilterRawInboundCap, {
6065                 "FilterRawInboundCap", "infiniband.switchinfo.filterrawinboundcap",
6066                 FT_UINT8, BASE_HEX, NULL, 0x20, NULL, HFILL}
6067         },
6068         { &hf_infiniband_SwitchInfo_FilterRawOutboundCap, {
6069                 "FilterRawOutboundCap", "infiniband.switchinfo.filterrawoutboundcap",
6070                 FT_UINT8, BASE_HEX, NULL, 0x10, NULL, HFILL}
6071         },
6072         { &hf_infiniband_SwitchInfo_EnhancedPortZero, {
6073                 "EnhancedPortZero", "infiniband.switchinfo.enhancedportzero",
6074                 FT_UINT8, BASE_HEX, NULL, 0x08, NULL, HFILL}
6075         },
6076
6077         /* GUIDInfo */
6078 #if 0
6079         { &hf_infiniband_GUIDInfo_GUIDBlock, {
6080                 "GUIDBlock", "infiniband.switchinfo.guidblock",
6081                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6082         },
6083 #endif
6084         { &hf_infiniband_GUIDInfo_GUID, {
6085                 "GUID", "infiniband.switchinfo.guid",
6086                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6087         },
6088
6089         /* PortInfo */
6090         { &hf_infiniband_PortInfo_M_Key, {
6091                 "M_Key", "infiniband.portinfo.m_key",
6092                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6093         },
6094         { &hf_infiniband_PortInfo_GidPrefix, {
6095                 "GidPrefix", "infiniband.portinfo.guid",
6096                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6097         },
6098         { &hf_infiniband_PortInfo_LID, {
6099                 "LID", "infiniband.portinfo.lid",
6100                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6101         },
6102         { &hf_infiniband_PortInfo_MasterSMLID, {
6103                 "MasterSMLID", "infiniband.portinfo.mastersmlid",
6104                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6105         },
6106         { &hf_infiniband_PortInfo_CapabilityMask, {
6107                 "CapabilityMask", "infiniband.portinfo.capabilitymask",
6108                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
6109         },
6110
6111         /* Capability Mask Flags */
6112         { &hf_infiniband_PortInfo_CapabilityMask_SM, {
6113                 "SM", "infiniband.portinfo.capabilitymask.issm",
6114                 FT_UINT32, BASE_HEX, NULL, 0x00000002, NULL, HFILL}
6115         },
6116         { &hf_infiniband_PortInfo_CapabilityMask_NoticeSupported, {
6117                 "NoticeSupported", "infiniband.portinfo.capabilitymask.noticesupported",
6118                 FT_UINT32, BASE_HEX, NULL, 0x00000004, NULL, HFILL}
6119         },
6120         { &hf_infiniband_PortInfo_CapabilityMask_TrapSupported, {
6121                 "TrapSupported", "infiniband.portinfo.capabilitymask.trapsupported",
6122                 FT_UINT32, BASE_HEX, NULL, 0x00000008, NULL, HFILL}
6123         },
6124         { &hf_infiniband_PortInfo_CapabilityMask_OptionalPDSupported, {
6125                 "OptionalPDSupported", "infiniband.portinfo.capabilitymask.optionalpdsupported",
6126                 FT_UINT32, BASE_HEX, NULL, 0x00000010, NULL, HFILL}
6127         },
6128         { &hf_infiniband_PortInfo_CapabilityMask_AutomaticMigrationSupported, {
6129                 "AutomaticMigrationSupported", "infiniband.portinfo.capabilitymask.automaticmigrationsupported",
6130                 FT_UINT32, BASE_HEX, NULL, 0x00000020, NULL, HFILL}
6131         },
6132         { &hf_infiniband_PortInfo_CapabilityMask_SLMappingSupported, {
6133                 "SLMappingSupported", "infiniband.portinfo.capabilitymask.slmappingsupported",
6134                 FT_UINT32, BASE_HEX, NULL, 0x00000040, NULL, HFILL}
6135         },
6136         { &hf_infiniband_PortInfo_CapabilityMask_MKeyNVRAM, {
6137                 "MKeyNVRAM", "infiniband.portinfo.capabilitymask.mkeynvram",
6138                 FT_UINT32, BASE_HEX, NULL, 0x00000080, NULL, HFILL}
6139         },
6140         { &hf_infiniband_PortInfo_CapabilityMask_PKeyNVRAM, {
6141                 "PKeyNVRAM", "infiniband.portinfo.capabilitymask.pkeynvram",
6142                 FT_UINT32, BASE_HEX, NULL, 0x00000100, NULL, HFILL}
6143         },
6144         { &hf_infiniband_PortInfo_CapabilityMask_LEDInfoSupported, {
6145                 "LEDInfoSupported", "infiniband.portinfo.capabilitymask.ledinfosupported",
6146                 FT_UINT32, BASE_HEX, NULL, 0x00000200, NULL, HFILL}
6147         },
6148         { &hf_infiniband_PortInfo_CapabilityMask_SMdisabled, {
6149                 "SMdisabled", "infiniband.portinfo.capabilitymask.smdisabled",
6150                 FT_UINT32, BASE_HEX, NULL, 0x00000400, NULL, HFILL}
6151         },
6152         { &hf_infiniband_PortInfo_CapabilityMask_SystemImageGUIDSupported, {
6153                 "SystemImageGUIDSupported", "infiniband.portinfo.capabilitymask.systemimageguidsupported",
6154                 FT_UINT32, BASE_HEX, NULL, 0x00000800, NULL, HFILL}
6155         },
6156         { &hf_infiniband_PortInfo_CapabilityMask_PKeySwitchExternalPortTrapSupported, {
6157                 "PKeySwitchExternalPortTrapSupported", "infiniband.portinfo.capabilitymask.pkeyswitchexternalporttrapsupported",
6158                 FT_UINT32, BASE_HEX, NULL, 0x00001000, NULL, HFILL}
6159         },
6160         { &hf_infiniband_PortInfo_CapabilityMask_CommunicationsManagementSupported, {
6161                 "CommunicationsManagementSupported", "infiniband.portinfo.capabilitymask.communicationsmanagementsupported",
6162                 FT_UINT32, BASE_HEX, NULL, 0x00010000, NULL, HFILL}
6163         },
6164         { &hf_infiniband_PortInfo_CapabilityMask_SNMPTunnelingSupported, {
6165                 "SNMPTunnelingSupported", "infiniband.portinfo.capabilitymask.snmptunnelingsupported",
6166                 FT_UINT32, BASE_HEX, NULL, 0x00020000, NULL, HFILL}
6167         },
6168         { &hf_infiniband_PortInfo_CapabilityMask_ReinitSupported, {
6169                 "ReinitSupported", "infiniband.portinfo.capabilitymask.reinitsupported",
6170                 FT_UINT32, BASE_HEX, NULL, 0x00040000, NULL, HFILL}
6171         },
6172         { &hf_infiniband_PortInfo_CapabilityMask_DeviceManagementSupported, {
6173                 "DeviceManagementSupported", "infiniband.portinfo.capabilitymask.devicemanagementsupported",
6174                 FT_UINT32, BASE_HEX, NULL, 0x00080000, NULL, HFILL}
6175         },
6176         { &hf_infiniband_PortInfo_CapabilityMask_VendorClassSupported, {
6177                 "VendorClassSupported", "infiniband.portinfo.capabilitymask.vendorclasssupported",
6178                 FT_UINT32, BASE_HEX, NULL, 0x00100000, NULL, HFILL}
6179         },
6180         { &hf_infiniband_PortInfo_CapabilityMask_DRNoticeSupported, {
6181                 "DRNoticeSupported", "infiniband.portinfo.capabilitymask.drnoticesupported",
6182                 FT_UINT32, BASE_HEX, NULL, 0x00200000, NULL, HFILL}
6183         },
6184         { &hf_infiniband_PortInfo_CapabilityMask_CapabilityMaskNoticeSupported, {
6185                 "CapabilityMaskNoticeSupported", "infiniband.portinfo.capabilitymask.capabilitymasknoticesupported",
6186                 FT_UINT32, BASE_HEX, NULL, 0x00400000, NULL, HFILL}
6187         },
6188         { &hf_infiniband_PortInfo_CapabilityMask_BootManagementSupported, {
6189                 "BootManagementSupported", "infiniband.portinfo.capabilitymask.bootmanagementsupported",
6190                 FT_UINT32, BASE_HEX, NULL, 0x00800000, NULL, HFILL}
6191         },
6192         { &hf_infiniband_PortInfo_CapabilityMask_LinkRoundTripLatencySupported, {
6193                 "LinkRoundTripLatencySupported", "infiniband.portinfo.capabilitymask.linkroundtriplatencysupported",
6194                 FT_UINT32, BASE_HEX, NULL, 0x01000000, NULL, HFILL}
6195         },
6196         { &hf_infiniband_PortInfo_CapabilityMask_ClientRegistrationSupported, {
6197                 "ClientRegistrationSupported", "infiniband.portinfo.capabilitymask.clientregistrationsupported",
6198                 FT_UINT32, BASE_HEX, NULL, 0x02000000, NULL, HFILL}
6199         },
6200         { &hf_infiniband_PortInfo_CapabilityMask_OtherLocalChangesNoticeSupported, {
6201                 "OtherLocalChangesNoticeSupported", "infiniband.portinfo.capabilitymask.otherlocalchangesnoticesupported",
6202                 FT_UINT32, BASE_HEX, NULL, 0x04000000, NULL, HFILL}
6203         },
6204         { &hf_infiniband_PortInfo_CapabilityMask_LinkSpeedWIdthPairsTableSupported, {
6205                 "LinkSpeedWIdthPairsTableSupported", "infiniband.portinfo.capabilitymask.linkspeedwidthpairstablesupported",
6206                 FT_UINT32, BASE_HEX, NULL, 0x08000000, NULL, HFILL}
6207         },
6208         /* End Capability Mask Flags */
6209
6210         /* PortInfo */
6211         { &hf_infiniband_PortInfo_DiagCode, {
6212                 "DiagCode", "infiniband.portinfo.diagcode",
6213                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6214         },
6215         { &hf_infiniband_PortInfo_M_KeyLeasePeriod, {
6216                 "M_KeyLeasePeriod", "infiniband.portinfo.m_keyleaseperiod",
6217                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6218         },
6219         { &hf_infiniband_PortInfo_LocalPortNum, {
6220                 "LocalPortNum", "infiniband.portinfo.localportnum",
6221                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6222         },
6223         { &hf_infiniband_PortInfo_LinkWidthEnabled, {
6224                 "LinkWidthEnabled", "infiniband.portinfo.linkwidthenabled",
6225                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6226         },
6227         { &hf_infiniband_PortInfo_LinkWidthSupported, {
6228                 "LinkWidthSupported", "infiniband.portinfo.linkwidthsupported",
6229                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6230         },
6231         { &hf_infiniband_PortInfo_LinkWidthActive, {
6232                 "LinkWidthActive", "infiniband.portinfo.linkwidthactive",
6233                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6234         },
6235         { &hf_infiniband_PortInfo_LinkSpeedSupported, {
6236                 "LinkSpeedSupported", "infiniband.portinfo.linkspeedsupported",
6237                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6238         },
6239         { &hf_infiniband_PortInfo_PortState, {
6240                 "PortState", "infiniband.portinfo.portstate",
6241                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6242         },
6243         { &hf_infiniband_PortInfo_PortPhysicalState, {
6244                 "PortPhysicalState", "infiniband.portinfo.portphysicalstate",
6245                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6246         },
6247         { &hf_infiniband_PortInfo_LinkDownDefaultState, {
6248                 "LinkDownDefaultState", "infiniband.portinfo.linkdowndefaultstate",
6249                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6250         },
6251         { &hf_infiniband_PortInfo_M_KeyProtectBits, {
6252                 "M_KeyProtectBits", "infiniband.portinfo.m_keyprotectbits",
6253                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6254         },
6255         { &hf_infiniband_PortInfo_LMC, {
6256                 "LMC", "infiniband.portinfo.lmc",
6257                 FT_UINT8, BASE_HEX, NULL, 0x07, NULL, HFILL}
6258         },
6259         { &hf_infiniband_PortInfo_LinkSpeedActive, {
6260                 "LinkSpeedActive", "infiniband.portinfo.linkspeedactive",
6261                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6262         },
6263         { &hf_infiniband_PortInfo_LinkSpeedEnabled, {
6264                 "LinkSpeedEnabled", "infiniband.portinfo.linkspeedenabled",
6265                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6266         },
6267         { &hf_infiniband_PortInfo_NeighborMTU, {
6268                 "NeighborMTU", "infiniband.portinfo.neighbormtu",
6269                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6270         },
6271         { &hf_infiniband_PortInfo_MasterSMSL, {
6272                 "MasterSMSL", "infiniband.portinfo.mastersmsl",
6273                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6274         },
6275         { &hf_infiniband_PortInfo_VLCap, {
6276                 "VLCap", "infiniband.portinfo.vlcap",
6277                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6278         },
6279         { &hf_infiniband_PortInfo_InitType, {
6280                 "InitType", "infiniband.portinfo.inittype",
6281                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6282         },
6283         { &hf_infiniband_PortInfo_VLHighLimit, {
6284                 "VLHighLimit", "infiniband.portinfo.vlhighlimit",
6285                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6286         },
6287         { &hf_infiniband_PortInfo_VLArbitrationHighCap, {
6288                 "VLArbitrationHighCap", "infiniband.portinfo.vlarbitrationhighcap",
6289                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6290         },
6291         { &hf_infiniband_PortInfo_VLArbitrationLowCap, {
6292                 "VLArbitrationLowCap", "infiniband.portinfo.vlarbitrationlowcap",
6293                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6294         },
6295         { &hf_infiniband_PortInfo_InitTypeReply, {
6296                 "InitTypeReply", "infiniband.portinfo.inittypereply",
6297                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6298         },
6299         { &hf_infiniband_PortInfo_MTUCap, {
6300                 "MTUCap", "infiniband.portinfo.mtucap",
6301                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6302         },
6303         { &hf_infiniband_PortInfo_VLStallCount, {
6304                 "VLStallCount", "infiniband.portinfo.vlstallcount",
6305                 FT_UINT8, BASE_HEX, NULL, 0xE0, NULL, HFILL}
6306         },
6307         { &hf_infiniband_PortInfo_HOQLife, {
6308                 "HOQLife", "infiniband.portinfo.hoqlife",
6309                 FT_UINT8, BASE_HEX, NULL, 0x1F, NULL, HFILL}
6310         },
6311         { &hf_infiniband_PortInfo_OperationalVLs, {
6312                 "OperationalVLs", "infiniband.portinfo.operationalvls",
6313                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6314         },
6315         { &hf_infiniband_PortInfo_PartitionEnforcementInbound, {
6316                 "PartitionEnforcementInbound", "infiniband.portinfo.partitionenforcementinbound",
6317                 FT_UINT8, BASE_HEX, NULL, 0x08, NULL, HFILL}
6318         },
6319         { &hf_infiniband_PortInfo_PartitionEnforcementOutbound, {
6320                 "PartitionEnforcementOutbound", "infiniband.portinfo.partitionenforcementoutbound",
6321                 FT_UINT8, BASE_HEX, NULL, 0x04, NULL, HFILL}
6322         },
6323         { &hf_infiniband_PortInfo_FilterRawInbound, {
6324                 "FilterRawInbound", "infiniband.portinfo.filterrawinbound",
6325                 FT_UINT8, BASE_HEX, NULL, 0x02, NULL, HFILL}
6326         },
6327         { &hf_infiniband_PortInfo_FilterRawOutbound, {
6328                 "FilterRawOutbound", "infiniband.portinfo.filterrawoutbound",
6329                 FT_UINT8, BASE_HEX, NULL, 0x01, NULL, HFILL}
6330         },
6331         { &hf_infiniband_PortInfo_M_KeyViolations, {
6332                 "M_KeyViolations", "infiniband.portinfo.m_keyviolations",
6333                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6334         },
6335         { &hf_infiniband_PortInfo_P_KeyViolations, {
6336                 "P_KeyViolations", "infiniband.portinfo.p_keyviolations",
6337                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6338         },
6339         { &hf_infiniband_PortInfo_Q_KeyViolations, {
6340                 "Q_KeyViolations", "infiniband.portinfo.q_keyviolations",
6341                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6342         },
6343         { &hf_infiniband_PortInfo_GUIDCap, {
6344                 "GUIDCap", "infiniband.portinfo.guidcap",
6345                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6346         },
6347         { &hf_infiniband_PortInfo_ClientReregister, {
6348                 "ClientReregister", "infiniband.portinfo.clientreregister",
6349                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6350         },
6351         { &hf_infiniband_PortInfo_SubnetTimeOut, {
6352                 "SubnetTimeOut", "infiniband.portinfo.subnettimeout",
6353                 FT_UINT8, BASE_HEX, NULL, 0x1F, NULL, HFILL}
6354         },
6355         { &hf_infiniband_PortInfo_RespTimeValue, {
6356                 "RespTimeValue", "infiniband.portinfo.resptimevalue",
6357                 FT_UINT8, BASE_HEX, NULL, 0x1F, NULL, HFILL}
6358         },
6359         { &hf_infiniband_PortInfo_LocalPhyErrors, {
6360                 "LocalPhyErrors", "infiniband.portinfo.localphyerrors",
6361                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6362         },
6363         { &hf_infiniband_PortInfo_OverrunErrors, {
6364                 "OverrunErrors", "infiniband.portinfo.overrunerrors",
6365                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6366         },
6367         { &hf_infiniband_PortInfo_MaxCreditHint, {
6368                 "MaxCreditHint", "infiniband.portinfo.maxcredithint",
6369                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6370         },
6371         { &hf_infiniband_PortInfo_LinkRoundTripLatency, {
6372                 "LinkRoundTripLatency", "infiniband.portinfo.linkroundtriplatency",
6373                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
6374         },
6375
6376         /* P_KeyTable */
6377         { &hf_infiniband_P_KeyTable_P_KeyTableBlock, {
6378                 "P_KeyTableBlock", "infiniband.p_keytable.p_keytableblock",
6379                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6380         },
6381         { &hf_infiniband_P_KeyTable_MembershipType, {
6382                 "MembershipType", "infiniband.p_keytable.membershiptype",
6383                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6384         },
6385         { &hf_infiniband_P_KeyTable_P_KeyBase, {
6386                 "P_KeyBase", "infiniband.p_keytable.p_keybase",
6387                 FT_UINT16, BASE_HEX, NULL, 0x7FFF, NULL, HFILL}
6388         },
6389
6390         /* SLtoVLMappingTable */
6391         { &hf_infiniband_SLtoVLMappingTable_SLtoVL_HighBits, {
6392                 "SL(x)toVL", "infiniband.sltovlmappingtable.sltovlhighbits",
6393                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6394         },
6395         { &hf_infiniband_SLtoVLMappingTable_SLtoVL_LowBits, {
6396                 "SL(x)toVL", "infiniband.sltovlmappingtable.sltovllowbits",
6397                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6398         },
6399
6400         /* VLArbitrationTable */
6401 #if 0
6402         { &hf_infiniband_VLArbitrationTable_VLWeightPairs, {
6403                 "VLWeightPairs", "infiniband.vlarbitrationtable.vlweightpairs",
6404                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6405         },
6406 #endif
6407         { &hf_infiniband_VLArbitrationTable_VL, {
6408                 "VL", "infiniband.vlarbitrationtable.vl",
6409                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6410         },
6411         { &hf_infiniband_VLArbitrationTable_Weight, {
6412                 "Weight", "infiniband.vlarbitrationtable.weight",
6413                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6414         },
6415
6416         /* LinearForwardingTable */
6417 #if 0
6418         { &hf_infiniband_LinearForwardingTable_LinearForwardingTableBlock, {
6419                 "LinearForwardingTableBlock", "infiniband.linearforwardingtable.linearforwardingtableblock",
6420                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6421         },
6422 #endif
6423         { &hf_infiniband_LinearForwardingTable_Port, {
6424                 "Port", "infiniband.linearforwardingtable.port",
6425                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6426         },
6427
6428         /* RandomForwardingTable */
6429 #if 0
6430         { &hf_infiniband_RandomForwardingTable_RandomForwardingTableBlock, {
6431                 "RandomForwardingTableBlock", "infiniband.randomforwardingtable.randomforwardingtableblock",
6432                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6433         },
6434 #endif
6435         { &hf_infiniband_RandomForwardingTable_LID, {
6436                 "LID", "infiniband.randomforwardingtable.lid",
6437                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6438         },
6439         { &hf_infiniband_RandomForwardingTable_Valid, {
6440                 "Valid", "infiniband.randomforwardingtable.valid",
6441                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6442         },
6443         { &hf_infiniband_RandomForwardingTable_LMC, {
6444                 "LMC", "infiniband.randomforwardingtable.lmc",
6445                 FT_UINT8, BASE_HEX, NULL, 0x70, NULL, HFILL}
6446         },
6447         { &hf_infiniband_RandomForwardingTable_Port, {
6448                 "Port", "infiniband.randomforwardingtable.port",
6449                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6450         },
6451
6452         /* MulticastForwardingTable */
6453 #if 0
6454         { &hf_infiniband_MulticastForwardingTable_MulticastForwardingTableBlock , {
6455                 "MulticastForwardingTableBlock", "infiniband.multicastforwardingtable.multicastforwardingtableblock",
6456                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6457         },
6458 #endif
6459         { &hf_infiniband_MulticastForwardingTable_PortMask, {
6460                 "PortMask", "infiniband.multicastforwardingtable.portmask",
6461                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6462         },
6463
6464         /* SMInfo */
6465         { &hf_infiniband_SMInfo_GUID, {
6466                 "GUID", "infiniband.sminfo.guid",
6467                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6468         },
6469         { &hf_infiniband_SMInfo_SM_Key, {
6470                 "SM_Key", "infiniband.sminfo.sm_key",
6471                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6472         },
6473         { &hf_infiniband_SMInfo_ActCount, {
6474                 "ActCount", "infiniband.sminfo.actcount",
6475                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
6476         },
6477         { &hf_infiniband_SMInfo_Priority, {
6478                 "Priority", "infiniband.sminfo.priority",
6479                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6480         },
6481         { &hf_infiniband_SMInfo_SMState, {
6482                 "SMState", "infiniband.sminfo.smstate",
6483                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6484         },
6485
6486         /* VendorDiag */
6487         { &hf_infiniband_VendorDiag_NextIndex, {
6488                 "NextIndex", "infiniband.vendordiag.nextindex",
6489                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6490         },
6491         { &hf_infiniband_VendorDiag_DiagData, {
6492                 "DiagData", "infiniband.vendordiag.diagdata",
6493                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6494         },
6495
6496         /* LedInfo */
6497         { &hf_infiniband_LedInfo_LedMask, {
6498                 "LedMask", "infiniband.ledinfo.ledmask",
6499                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6500         },
6501
6502         /* LinkSpeedWidthPairsTable */
6503         { &hf_infiniband_LinkSpeedWidthPairsTable_NumTables, {
6504                 "NumTables", "infiniband.linkspeedwidthpairstable.numtables",
6505                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6506         },
6507         { &hf_infiniband_LinkSpeedWidthPairsTable_PortMask, {
6508                 "PortMask", "infiniband.linkspeedwidthpairstable.portmask",
6509                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6510         },
6511         { &hf_infiniband_LinkSpeedWidthPairsTable_SpeedTwoFive, {
6512                 "Speed 2.5 Gbps", "infiniband.linkspeedwidthpairstable.speedtwofive",
6513                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6514         },
6515         { &hf_infiniband_LinkSpeedWidthPairsTable_SpeedFive, {
6516                 "Speed 5 Gbps", "infiniband.linkspeedwidthpairstable.speedfive",
6517                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6518         },
6519         { &hf_infiniband_LinkSpeedWidthPairsTable_SpeedTen, {
6520                 "Speed 10 Gbps", "infiniband.linkspeedwidthpairstable.speedten",
6521                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6522         },
6523
6524         /* NodeRecord */
6525         /* PortInfoRecord */
6526         /* SLtoVLMappingTableRecord */
6527         /* SwitchInfoRecord */
6528         /* LinearForwardingTableRecord */
6529         /* RandomForwardingTableRecord */
6530         /* MulticastForwardingTableRecord */
6531         /* VLArbitrationTableRecord */
6532         { &hf_infiniband_SA_LID, {
6533                 "LID", "infiniband.sa.lid",
6534                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6535         },
6536         { &hf_infiniband_SA_EndportLID, {
6537                 "EndportLID", "infiniband.sa.endportlid",
6538                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6539         },
6540         { &hf_infiniband_SA_PortNum, {
6541                 "PortNum", "infiniband.sa.portnum",
6542                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6543         },
6544         { &hf_infiniband_SA_InputPortNum , {
6545                 "InputPortNum", "infiniband.sa.inputportnum",
6546                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6547         },
6548         { &hf_infiniband_SA_OutputPortNum, {
6549                 "OutputPortNum", "infiniband.sa.outputportnum",
6550                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6551         },
6552         { &hf_infiniband_SA_BlockNum_EightBit, {
6553                 "BlockNum_EightBit", "infiniband.sa.blocknum_eightbit",
6554                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6555         },
6556         { &hf_infiniband_SA_BlockNum_NineBit, {
6557                 "BlockNum_NineBit", "infiniband.sa.blocknum_ninebit",
6558                 FT_UINT16, BASE_HEX, NULL, 0x01FF, NULL, HFILL}
6559         },
6560         { &hf_infiniband_SA_BlockNum_SixteenBit, {
6561                 "BlockNum_SixteenBit", "infiniband.sa.blocknum_sixteenbit",
6562                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6563         },
6564         { &hf_infiniband_SA_Position, {
6565                 "Position", "infiniband.sa.position",
6566                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6567         },
6568 #if 0
6569         { &hf_infiniband_SA_Index, {
6570                 "Index", "infiniband.sa.index",
6571                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6572         },
6573 #endif
6574
6575         /* InformInfoRecord */
6576         { &hf_infiniband_InformInfoRecord_SubscriberGID, {
6577                 "SubscriberGID", "infiniband.informinforecord.subscribergid",
6578                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
6579         },
6580         { &hf_infiniband_InformInfoRecord_Enum, {
6581                 "Enum", "infiniband.informinforecord.enum",
6582                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6583         },
6584
6585         /* InformInfo */
6586         { &hf_infiniband_InformInfo_GID, {
6587                 "GID", "infiniband.informinfo.gid",
6588                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
6589         },
6590         { &hf_infiniband_InformInfo_LIDRangeBegin, {
6591                 "LIDRangeBegin", "infiniband.informinfo.lidrangebegin",
6592                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6593         },
6594         { &hf_infiniband_InformInfo_LIDRangeEnd, {
6595                 "LIDRangeEnd", "infiniband.informinfo.lidrangeend",
6596                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6597         },
6598         { &hf_infiniband_InformInfo_IsGeneric, {
6599                 "IsGeneric", "infiniband.informinfo.isgeneric",
6600                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6601         },
6602         { &hf_infiniband_InformInfo_Subscribe, {
6603                 "Subscribe", "infiniband.informinfo.subscribe",
6604                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6605         },
6606         { &hf_infiniband_InformInfo_Type, {
6607                 "Type", "infiniband.informinfo.type",
6608                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6609         },
6610         { &hf_infiniband_InformInfo_TrapNumberDeviceID, {
6611                 "TrapNumberDeviceID", "infiniband.informinfo.trapnumberdeviceid",
6612                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6613         },
6614         { &hf_infiniband_InformInfo_QPN, {
6615                 "QPN", "infiniband.informinfo.qpn",
6616                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
6617         },
6618         { &hf_infiniband_InformInfo_RespTimeValue, {
6619                 "RespTimeValue", "infiniband.informinfo.resptimevalue",
6620                 FT_UINT8, BASE_HEX, NULL, 0x1F, NULL, HFILL}
6621         },
6622         { &hf_infiniband_InformInfo_ProducerTypeVendorID, {
6623                 "ProducerTypeVendorID", "infiniband.informinfo.producertypevendorid",
6624                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
6625         },
6626
6627         /* LinkRecord */
6628         { &hf_infiniband_LinkRecord_FromLID, {
6629                 "FromLID", "infiniband.linkrecord.fromlid",
6630                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6631         },
6632         { &hf_infiniband_LinkRecord_FromPort, {
6633                 "FromPort", "infiniband.linkrecord.fromport",
6634                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6635         },
6636         { &hf_infiniband_LinkRecord_ToPort, {
6637                 "ToPort", "infiniband.linkrecord.toport",
6638                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6639         },
6640         { &hf_infiniband_LinkRecord_ToLID, {
6641                 "ToLID", "infiniband.linkrecord.tolid",
6642                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6643         },
6644
6645         /* ServiceRecord */
6646         { &hf_infiniband_ServiceRecord_ServiceID, {
6647                 "ServiceID", "infiniband.linkrecord.serviceid",
6648                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6649         },
6650         { &hf_infiniband_ServiceRecord_ServiceGID, {
6651                 "ServiceGID", "infiniband.linkrecord.servicegid",
6652                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
6653         },
6654         { &hf_infiniband_ServiceRecord_ServiceP_Key, {
6655                 "ServiceP_Key", "infiniband.linkrecord.servicep_key",
6656                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6657         },
6658         { &hf_infiniband_ServiceRecord_ServiceLease, {
6659                 "ServiceLease", "infiniband.linkrecord.servicelease",
6660                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
6661         },
6662         { &hf_infiniband_ServiceRecord_ServiceKey, {
6663                 "ServiceKey", "infiniband.linkrecord.servicekey",
6664                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6665         },
6666         { &hf_infiniband_ServiceRecord_ServiceName, {
6667                 "ServiceName", "infiniband.linkrecord.servicename",
6668                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6669         },
6670         { &hf_infiniband_ServiceRecord_ServiceData, {
6671                 "ServiceData", "infiniband.linkrecord.servicedata",
6672                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6673         },
6674
6675         /* ServiceAssociationRecord */
6676         { &hf_infiniband_ServiceAssociationRecord_ServiceKey, {
6677                 "ServiceKey", "infiniband.serviceassociationrecord.servicekey",
6678                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6679         },
6680         { &hf_infiniband_ServiceAssociationRecord_ServiceName, {
6681                 "ServiceName", "infiniband.serviceassociationrecord.servicename",
6682                 FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}
6683         },
6684
6685         /* PathRecord */
6686         { &hf_infiniband_PathRecord_DGID, {
6687                 "DGID", "infiniband.pathrecord.dgid",
6688                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
6689         },
6690         { &hf_infiniband_PathRecord_SGID, {
6691                 "SGID", "infiniband.pathrecord.sgid",
6692                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
6693         },
6694         { &hf_infiniband_PathRecord_DLID, {
6695                 "DLID", "infiniband.pathrecord.dlid",
6696                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6697         },
6698         { &hf_infiniband_PathRecord_SLID, {
6699                 "SLID", "infiniband.pathrecord.slid",
6700                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6701         },
6702         { &hf_infiniband_PathRecord_RawTraffic, {
6703                 "RawTraffic", "infiniband.pathrecord.rawtraffic",
6704                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6705         },
6706         { &hf_infiniband_PathRecord_FlowLabel, {
6707                 "FlowLabel", "infiniband.pathrecord.flowlabel",
6708                 FT_UINT24, BASE_HEX, NULL, 0x0FFFFF, NULL, HFILL}
6709         },
6710         { &hf_infiniband_PathRecord_HopLimit, {
6711                 "HopLimit", "infiniband.pathrecord.hoplimit",
6712                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6713         },
6714         { &hf_infiniband_PathRecord_TClass, {
6715                 "TClass", "infiniband.pathrecord.tclass",
6716                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6717         },
6718         { &hf_infiniband_PathRecord_Reversible, {
6719                 "Reversible", "infiniband.pathrecord.reversible",
6720                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6721         },
6722         { &hf_infiniband_PathRecord_NumbPath, {
6723                 "NumbPath", "infiniband.pathrecord.numbpath",
6724                 FT_UINT8, BASE_HEX, NULL, 0x7F, NULL, HFILL}
6725         },
6726         { &hf_infiniband_PathRecord_P_Key, {
6727                 "P_Key", "infiniband.pathrecord.p_key",
6728                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6729         },
6730         { &hf_infiniband_PathRecord_SL, {
6731                 "SL", "infiniband.pathrecord.sl",
6732                 FT_UINT16, BASE_HEX, NULL, 0x000F, NULL, HFILL}
6733         },
6734         { &hf_infiniband_PathRecord_MTUSelector, {
6735                 "MTUSelector", "infiniband.pathrecord.mtuselector",
6736                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6737         },
6738         { &hf_infiniband_PathRecord_MTU, {
6739                 "MTU", "infiniband.pathrecord.mtu",
6740                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6741         },
6742         { &hf_infiniband_PathRecord_RateSelector, {
6743                 "RateSelector", "infiniband.pathrecord.rateselector",
6744                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6745         },
6746         { &hf_infiniband_PathRecord_Rate, {
6747                 "Rate", "infiniband.pathrecord.rate",
6748                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6749         },
6750         { &hf_infiniband_PathRecord_PacketLifeTimeSelector, {
6751                 "PacketLifeTimeSelector", "infiniband.pathrecord.packetlifetimeselector",
6752                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6753         },
6754         { &hf_infiniband_PathRecord_PacketLifeTime, {
6755                 "PacketLifeTime", "infiniband.pathrecord.packetlifetime",
6756                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6757         },
6758         { &hf_infiniband_PathRecord_Preference, {
6759                 "Preference", "infiniband.pathrecord.preference",
6760                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6761         },
6762
6763         /* MCMemberRecord */
6764         { &hf_infiniband_MCMemberRecord_MGID, {
6765                 "MGID", "infiniband.mcmemberrecord.mgid",
6766                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
6767         },
6768         { &hf_infiniband_MCMemberRecord_PortGID, {
6769                 "PortGID", "infiniband.mcmemberrecord.portgid",
6770                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
6771         },
6772         { &hf_infiniband_MCMemberRecord_Q_Key, {
6773                 "Q_Key", "infiniband.mcmemberrecord.q_key",
6774                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
6775         },
6776         { &hf_infiniband_MCMemberRecord_MLID, {
6777                 "MLID", "infiniband.mcmemberrecord.mlid",
6778                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6779         },
6780         { &hf_infiniband_MCMemberRecord_MTUSelector, {
6781                 "MTUSelector", "infiniband.mcmemberrecord.mtuselector",
6782                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6783         },
6784         { &hf_infiniband_MCMemberRecord_MTU, {
6785                 "MTU", "infiniband.mcmemberrecord.mtu",
6786                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6787         },
6788         { &hf_infiniband_MCMemberRecord_TClass, {
6789                 "TClass", "infiniband.mcmemberrecord.tclass",
6790                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6791         },
6792         { &hf_infiniband_MCMemberRecord_P_Key, {
6793                 "P_Key", "infiniband.mcmemberrecord.p_key",
6794                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6795         },
6796         { &hf_infiniband_MCMemberRecord_RateSelector, {
6797                 "RateSelector", "infiniband.mcmemberrecord.rateselector",
6798                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6799         },
6800         { &hf_infiniband_MCMemberRecord_Rate, {
6801                 "Rate", "infiniband.mcmemberrecord.rate",
6802                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6803         },
6804         { &hf_infiniband_MCMemberRecord_PacketLifeTimeSelector, {
6805                 "PacketLifeTimeSelector", "infiniband.mcmemberrecord.packetlifetimeselector",
6806                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6807         },
6808         { &hf_infiniband_MCMemberRecord_PacketLifeTime, {
6809                 "PacketLifeTime", "infiniband.mcmemberrecord.packetlifetime",
6810                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6811         },
6812         { &hf_infiniband_MCMemberRecord_SL, {
6813                 "SL", "infiniband.mcmemberrecord.sl",
6814                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6815         },
6816         { &hf_infiniband_MCMemberRecord_FlowLabel, {
6817                 "FlowLabel", "infiniband.mcmemberrecord.flowlabel",
6818                 FT_UINT24, BASE_HEX, NULL, 0x0FFFFF, NULL, HFILL}
6819         },
6820         { &hf_infiniband_MCMemberRecord_HopLimit, {
6821                 "HopLimit", "infiniband.mcmemberrecord.hoplimit",
6822                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6823         },
6824         { &hf_infiniband_MCMemberRecord_Scope, {
6825                 "Scope", "infiniband.mcmemberrecord.scope",
6826                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6827         },
6828         { &hf_infiniband_MCMemberRecord_JoinState, {
6829                 "JoinState", "infiniband.mcmemberrecord.joinstate",
6830                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
6831         },
6832         { &hf_infiniband_MCMemberRecord_ProxyJoin, {
6833                 "ProxyJoin", "infiniband.mcmemberrecord.proxyjoin",
6834                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6835         },
6836
6837         /* TraceRecord */
6838         { &hf_infiniband_TraceRecord_GIDPrefix, {
6839                 "GidPrefix", "infiniband.tracerecord.gidprefix",
6840                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6841         },
6842         { &hf_infiniband_TraceRecord_IDGeneration, {
6843                 "IDGeneration", "infiniband.tracerecord.idgeneration",
6844                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6845         },
6846         { &hf_infiniband_TraceRecord_NodeType, {
6847                 "NodeType", "infiniband.tracerecord.nodetype",
6848                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6849         },
6850         { &hf_infiniband_TraceRecord_NodeID, {
6851                 "NodeID", "infiniband.tracerecord.nodeid",
6852                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6853         },
6854         { &hf_infiniband_TraceRecord_ChassisID, {
6855                 "ChassisID", "infiniband.tracerecord.chassisid",
6856                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6857         },
6858         { &hf_infiniband_TraceRecord_EntryPortID, {
6859                 "EntryPortID", "infiniband.tracerecord.entryportid",
6860                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6861         },
6862         { &hf_infiniband_TraceRecord_ExitPortID, {
6863                 "ExitPortID", "infiniband.tracerecord.exitportid",
6864                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
6865         },
6866         { &hf_infiniband_TraceRecord_EntryPort, {
6867                 "EntryPort", "infiniband.tracerecord.entryport",
6868                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6869         },
6870         { &hf_infiniband_TraceRecord_ExitPort, {
6871                 "ExitPort", "infiniband.tracerecord.exitport",
6872                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6873         },
6874
6875         /* MultiPathRecord */
6876         { &hf_infiniband_MultiPathRecord_RawTraffic, {
6877                 "RawTraffic", "infiniband.multipathrecord.rawtraffic",
6878                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6879         },
6880         { &hf_infiniband_MultiPathRecord_FlowLabel, {
6881                 "FlowLabel", "infiniband.multipathrecord.flowlabel",
6882                 FT_UINT24, BASE_HEX, NULL, 0x0FFFFF, NULL, HFILL}
6883         },
6884         { &hf_infiniband_MultiPathRecord_HopLimit, {
6885                 "HopLimit", "infiniband.multipathrecord.hoplimit",
6886                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6887         },
6888         { &hf_infiniband_MultiPathRecord_TClass, {
6889                 "TClass", "infiniband.multipathrecord.tclass",
6890                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6891         },
6892         { &hf_infiniband_MultiPathRecord_Reversible, {
6893                 "Reversible", "infiniband.multipathrecord.reversible",
6894                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6895         },
6896         { &hf_infiniband_MultiPathRecord_NumbPath, {
6897                 "NumbPath", "infiniband.multipathrecord.numbpath",
6898                 FT_UINT8, BASE_HEX, NULL, 0x7F, NULL, HFILL}
6899         },
6900         { &hf_infiniband_MultiPathRecord_P_Key, {
6901                 "P_Key", "infiniband.multipathrecord.p_key",
6902                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6903         },
6904         { &hf_infiniband_MultiPathRecord_SL, {
6905                 "SL", "infiniband.multipathrecord.sl",
6906                 FT_UINT8, BASE_HEX, NULL, 0x0F, NULL, HFILL}
6907         },
6908         { &hf_infiniband_MultiPathRecord_MTUSelector, {
6909                 "MTUSelector", "infiniband.multipathrecord.mtuselector",
6910                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6911         },
6912         { &hf_infiniband_MultiPathRecord_MTU, {
6913                 "MTU", "infiniband.multipathrecord.mtu",
6914                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6915         },
6916         { &hf_infiniband_MultiPathRecord_RateSelector, {
6917                 "RateSelector", "infiniband.multipathrecord.rateselector",
6918                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6919         },
6920         { &hf_infiniband_MultiPathRecord_Rate, {
6921                 "Rate", "infiniband.multipathrecord.rate",
6922                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6923         },
6924         { &hf_infiniband_MultiPathRecord_PacketLifeTimeSelector, {
6925                 "PacketLifeTimeSelector", "infiniband.multipathrecord.packetlifetimeselector",
6926                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6927         },
6928         { &hf_infiniband_MultiPathRecord_PacketLifeTime, {
6929                 "PacketLifeTime", "infiniband.multipathrecord.packetlifetime",
6930                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6931         },
6932         { &hf_infiniband_MultiPathRecord_IndependenceSelector, {
6933                 "IndependenceSelector", "infiniband.multipathrecord.independenceselector",
6934                 FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL}
6935         },
6936         { &hf_infiniband_MultiPathRecord_GIDScope, {
6937                 "GIDScope", "infiniband.multipathrecord.gidscope",
6938                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
6939         },
6940         { &hf_infiniband_MultiPathRecord_SGIDCount, {
6941                 "SGIDCount", "infiniband.multipathrecord.sgidcount",
6942                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6943         },
6944         { &hf_infiniband_MultiPathRecord_DGIDCount, {
6945                 "DGIDCount", "infiniband.multipathrecord.dgidcount",
6946                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
6947         },
6948         { &hf_infiniband_MultiPathRecord_SDGID, {
6949                 "SDGID", "infiniband.multipathrecord.sdgid",
6950                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
6951         },
6952
6953         /* Notice */
6954         { &hf_infiniband_Notice_IsGeneric, {
6955                 "IsGeneric", "infiniband.notice.isgeneric",
6956                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6957         },
6958         { &hf_infiniband_Notice_Type, {
6959                 "Type", "infiniband.notice.type",
6960                 FT_UINT8, BASE_HEX, NULL, 0x7F, NULL, HFILL}
6961         },
6962         { &hf_infiniband_Notice_ProducerTypeVendorID, {
6963                 "ProducerTypeVendorID", "infiniband.notice.producertypevendorid",
6964                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
6965         },
6966         { &hf_infiniband_Notice_TrapNumberDeviceID, {
6967                 "TrapNumberDeviceID", "infiniband.notice.trapnumberdeviceid",
6968                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6969         },
6970         { &hf_infiniband_Notice_IssuerLID, {
6971                 "IssuerLID", "infiniband.notice.issuerlid",
6972                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
6973         },
6974         { &hf_infiniband_Notice_NoticeToggle, {
6975                 "NoticeToggle", "infiniband.notice.noticetoggle",
6976                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
6977         },
6978         { &hf_infiniband_Notice_NoticeCount, {
6979                 "NoticeCount", "infiniband.notice.noticecount",
6980                 FT_UINT16, BASE_HEX, NULL, 0x7FFF, NULL, HFILL}
6981         },
6982         { &hf_infiniband_Notice_DataDetails, {
6983                 "DataDetails", "infiniband.notice.datadetails",
6984                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6985         },
6986 #if 0
6987         { &hf_infiniband_Notice_IssuerGID, {
6988                 "IssuerGID", "infiniband.notice.issuergid",
6989                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
6990         },
6991         { &hf_infiniband_Notice_ClassTrapSpecificData, {
6992                 "ClassTrapSpecificData", "infiniband.notice.classtrapspecificdata",
6993                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
6994         },
6995 #endif
6996
6997         /* Traps 64,65,66,67 */
6998         { &hf_infiniband_Trap_GIDADDR, {
6999                 "GIDADDR", "infiniband.trap.gidaddr",
7000                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
7001         },
7002         /* Traps 68,69 */
7003         { &hf_infiniband_Trap_COMP_MASK, {
7004                 "COMP_MASK", "infiniband.trap.comp_mask",
7005                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
7006         },
7007         { &hf_infiniband_Trap_WAIT_FOR_REPATH, {
7008                 "WAIT_FOR_REPATH", "infiniband.trap.wait_for_repath",
7009                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
7010         },
7011 #if 0
7012         { &hf_infiniband_Trap_PATH_REC, {
7013                 "PATH_REC", "infiniband.trap.path_rec",
7014                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
7015         },
7016 #endif
7017
7018         /* Trap 128 */
7019         { &hf_infiniband_Trap_LIDADDR, {
7020                 "LIDADDR", "infiniband.trap.lidaddr",
7021                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
7022         },
7023
7024         /* Trap 129, 130, 131 */
7025         { &hf_infiniband_Trap_PORTNO, {
7026                 "PORTNO", "infiniband.trap.portno",
7027                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
7028         },
7029
7030         /* Trap 144 */
7031         { &hf_infiniband_Trap_OtherLocalChanges, {
7032                 "OtherLocalChanges", "infiniband.trap.otherlocalchanges",
7033                 FT_UINT8, BASE_HEX, NULL, 0x01, NULL, HFILL}
7034         },
7035         { &hf_infiniband_Trap_CAPABILITYMASK, {
7036                 "CAPABILITYMASK", "infiniband.trap.capabilitymask",
7037                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
7038         },
7039         { &hf_infiniband_Trap_LinkSpeecEnabledChange, {
7040                 "LinkSpeecEnabledChange", "infiniband.trap.linkspeecenabledchange",
7041                 FT_UINT8, BASE_HEX, NULL, 0x04, NULL, HFILL}
7042         },
7043         { &hf_infiniband_Trap_LinkWidthEnabledChange, {
7044                 "LinkWidthEnabledChange", "infiniband.trap.linkwidthenabledchange",
7045                 FT_UINT8, BASE_HEX, NULL, 0x02, NULL, HFILL}
7046         },
7047         { &hf_infiniband_Trap_NodeDescriptionChange, {
7048                 "NodeDescriptionChange", "infiniband.trap.nodedescriptionchange",
7049                 FT_UINT8, BASE_HEX, NULL, 0x01, NULL, HFILL}
7050         },
7051
7052         /* Trap 145 */
7053         { &hf_infiniband_Trap_SYSTEMIMAGEGUID, {
7054                 "SYSTEMIMAGEGUID", "infiniband.trap.systemimageguid",
7055                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
7056         },
7057
7058         /* Trap 256 */
7059         { &hf_infiniband_Trap_DRSLID, {
7060                 "DRSLID", "infiniband.trap.drslid",
7061                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
7062         },
7063         { &hf_infiniband_Trap_METHOD, {
7064                 "METHOD", "infiniband.trap.method",
7065                 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
7066         },
7067         { &hf_infiniband_Trap_ATTRIBUTEID, {
7068                 "ATTRIBUTEID", "infiniband.trap.attributeid",
7069                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
7070         },
7071         { &hf_infiniband_Trap_ATTRIBUTEMODIFIER, {
7072                 "ATTRIBUTEMODIFIER", "infiniband.trap.attributemodifier",
7073                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
7074         },
7075         { &hf_infiniband_Trap_MKEY, {
7076                 "MKEY", "infiniband.trap.mkey",
7077                 FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
7078         },
7079         { &hf_infiniband_Trap_DRNotice, {
7080                 "DRNotice", "infiniband.trap.drnotice",
7081                 FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL}
7082         },
7083         { &hf_infiniband_Trap_DRPathTruncated, {
7084                 "DRPathTruncated", "infiniband.trap.drpathtruncated",
7085                 FT_UINT8, BASE_HEX, NULL, 0x40, NULL, HFILL}
7086         },
7087         { &hf_infiniband_Trap_DRHopCount, {
7088                 "DRHopCount", "infiniband.trap.drhopcount",
7089                 FT_UINT8, BASE_HEX, NULL, 0x3F, NULL, HFILL}
7090         },
7091         { &hf_infiniband_Trap_DRNoticeReturnPath, {
7092                 "DRNoticeReturnPath", "infiniband.trap.drnoticereturnpath",
7093                 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
7094         },
7095
7096         /* Trap 257, 258 */
7097         { &hf_infiniband_Trap_LIDADDR1, {
7098                 "LIDADDR1", "infiniband.trap.lidaddr1",
7099                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
7100         },
7101         { &hf_infiniband_Trap_LIDADDR2, {
7102                 "LIDADDR2", "infiniband.trap.lidaddr2",
7103                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
7104         },
7105         { &hf_infiniband_Trap_KEY, {
7106                 "KEY", "infiniband.trap.key",
7107                 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
7108         },
7109         { &hf_infiniband_Trap_SL, {
7110                 "SL", "infiniband.trap.sl",
7111                 FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL}
7112         },
7113         { &hf_infiniband_Trap_QP1, {
7114                 "QP1", "infiniband.trap.qp1",
7115                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
7116         },
7117         { &hf_infiniband_Trap_QP2, {
7118                 "QP2", "infiniband.trap.qp2",
7119                 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL}
7120         },
7121         { &hf_infiniband_Trap_GIDADDR1, {
7122                 "GIDADDR1", "infiniband.trap.gidaddr1",
7123                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
7124         },
7125         { &hf_infiniband_Trap_GIDADDR2, {
7126                 "GIDADDR2", "infiniband.trap.gidaddr2",
7127                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
7128         },
7129
7130         /* Trap 259 */
7131         { &hf_infiniband_Trap_DataValid, {
7132                 "DataValid", "infiniband.trap.datavalid",
7133                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
7134         },
7135         { &hf_infiniband_Trap_PKEY, {
7136                 "PKEY", "infiniband.trap.pkey",
7137                 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
7138         },
7139         { &hf_infiniband_Trap_SWLIDADDR, {
7140                 "SWLIDADDR", "infiniband.trap.swlidaddr",
7141                 FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL}
7142         },
7143         /* PortCounters in Performance class */
7144         { &hf_infiniband_PortCounters, {
7145                 "Port Counters (Performance Management MAD)", "infiniband.portcounters",
7146                 FT_NONE, BASE_NONE, NULL, 0x0,
7147                 "Performance class PortCounters packet", HFILL}
7148         },
7149         { &hf_infiniband_PortCounters_PortSelect, {
7150                 "PortSelect", "infiniband.portcounters.portselect",
7151                 FT_UINT8, BASE_HEX, NULL, 0x0,
7152                 "Selects the port that will be accessed", HFILL}
7153         },
7154         { &hf_infiniband_PortCounters_CounterSelect, {
7155                 "CounterSelect", "infiniband.portcounters.counterselect",
7156                 FT_UINT16, BASE_HEX, NULL, 0x0,
7157                 "When writing, selects which counters are affected by the operation", HFILL}
7158         },
7159         { &hf_infiniband_PortCounters_SymbolErrorCounter, {
7160                 "SymbolErrorCounter", "infiniband.portcounters.symbolerrorcounter",
7161                 FT_UINT16, BASE_DEC, NULL, 0x0,
7162                 "Total number of minor link errors", HFILL}
7163         },
7164         { &hf_infiniband_PortCounters_LinkErrorRecoveryCounter, {
7165                 "LinkErrorRecoveryCounter", "infiniband.portcounters.linkerrorrecoverycounter",
7166                 FT_UINT8, BASE_DEC, NULL, 0x0,
7167                 "Total number of times successfully completed link error recovery process", HFILL}
7168         },
7169         { &hf_infiniband_PortCounters_LinkDownedCounter, {
7170                 "LinkDownedCounter", "infiniband.portcounters.linkdownedcounter",
7171                 FT_UINT8, BASE_DEC, NULL, 0x0,
7172                 "Total number of times failed link error recovery process", HFILL}
7173         },
7174         { &hf_infiniband_PortCounters_PortRcvErrors, {
7175                 "PortRcvErrors", "infiniband.portcounters.portrcverrors",
7176                 FT_UINT16, BASE_DEC, NULL, 0x0,
7177                 "Total number of packets containing an error received", HFILL}
7178         },
7179         { &hf_infiniband_PortCounters_PortRcvRemotePhysicalErrors, {
7180                 "PortRcvRemotePhysicalErrors", "infiniband.portcounters.portrcvremotephysicalerrors",
7181                 FT_UINT16, BASE_DEC, NULL, 0x0,
7182                 "Total number of packets marked with EBP delimiter received", HFILL}
7183         },
7184         { &hf_infiniband_PortCounters_PortRcvSwitchRelayErrors, {
7185                 "PortRcvSwitchRelayErrors", "infiniband.portcounters.portrcvswitchrelayerrors",
7186                 FT_UINT16, BASE_DEC, NULL, 0x0,
7187                 "Total number of packets discarded because they could not be forwarded by switch relay",
7188                 HFILL}
7189         },
7190         { &hf_infiniband_PortCounters_PortXmitDiscards, {
7191                 "PortXmitDiscards", "infiniband.portcounters.portxmitdiscards",
7192                 FT_UINT16, BASE_DEC, NULL, 0x0,
7193                 "Total number of outbound packets discarded", HFILL}
7194         },
7195         { &hf_infiniband_PortCounters_PortXmitConstraintErrors, {
7196                 "PortXmitConstraintErrors", "infiniband.portcounters.portxmitconstrainterrors",
7197                 FT_UINT8, BASE_DEC, NULL, 0x0,
7198                 "Total number of packets not transmitted from the switch physical port", HFILL}
7199         },
7200         { &hf_infiniband_PortCounters_PortRcvConstraintErrors, {
7201                 "PortRcvConstraintErrors", "infiniband.portcounters.portrcvconstrainterrors",
7202                 FT_UINT8, BASE_DEC, NULL, 0x0,
7203                 "Total number of packets received on the switch physical port that are discarded", HFILL}
7204         },
7205         { &hf_infiniband_PortCounters_LocalLinkIntegrityErrors, {
7206                 "LocalLinkIntegrityErrors", "infiniband.portcounters.locallinkintegrityerrors",
7207                 FT_UINT8, BASE_DEC, NULL, 0x0,
7208                 "The number of times the count of local physical errors exceeded the threshold specified by LocalPhyErrors",
7209                 HFILL}
7210         },
7211         { &hf_infiniband_PortCounters_ExcessiveBufferOverrunErrors, {
7212                 "ExcessiveBufferOverrunErrors", "infiniband.portcounters.excessivebufferoverrunerrors",
7213                 FT_UINT8, BASE_DEC, NULL, 0x0,
7214                 "The number of times that OverrunErrors consecutive flow control update periods occurred",
7215                 HFILL}
7216         },
7217         { &hf_infiniband_PortCounters_VL15Dropped, {
7218                 "VL15Dropped", "infiniband.portcounters.vl15dropped",
7219                 FT_UINT16, BASE_DEC, NULL, 0x0,
7220                 "Number of incoming VL15 packets dropped", HFILL}
7221         },
7222         { &hf_infiniband_PortCounters_PortXmitData, {
7223                 "PortXmitData", "infiniband.portcounters.portxmitdata",
7224                 FT_UINT32, BASE_DEC, NULL, 0x0,
7225                 "Total number of data octets, divided by 4, transmitted on all VLs from the port", HFILL}
7226         },
7227         { &hf_infiniband_PortCounters_PortRcvData, {
7228                 "PortRcvData", "infiniband.portcounters.portrcvdata",
7229                 FT_UINT32, BASE_DEC, NULL, 0x0,
7230                 "Total number of data octets, divided by 4, received on all VLs at the port", HFILL}
7231         },
7232         { &hf_infiniband_PortCounters_PortXmitPkts, {
7233                 "PortXmitPkts", "infiniband.portcounters.portxmitpkts",
7234                 FT_UINT32, BASE_DEC, NULL, 0x0,
7235                 "Total number of packets transmitted on all VLs from the port", HFILL}
7236         },
7237         { &hf_infiniband_PortCounters_PortRcvPkts, {
7238                 "PortRcvPkts", "infiniband.portcounters.portrcvpkts",
7239                 FT_UINT32, BASE_DEC, NULL, 0x0,
7240                 "Total number of packets received from all VLs on the port", HFILL}
7241         },
7242         /* PortCountersExtended in Performance class */
7243         { &hf_infiniband_PortCountersExt, {
7244                 "Port Counters Extended (Performance Management MAD)", "infiniband.portcounters_ext",
7245                 FT_NONE, BASE_NONE, NULL, 0x0,
7246                 "Performance class PortCountersExtended packet", HFILL}
7247         },
7248         { &hf_infiniband_PortCountersExt_PortSelect, {
7249                 "PortSelect", "infiniband.portcounters_ext.portselect",
7250                 FT_UINT8, BASE_HEX, NULL, 0x0,
7251                 "Selects the port that will be accessed", HFILL}
7252         },
7253         { &hf_infiniband_PortCountersExt_CounterSelect, {
7254                 "CounterSelect", "infiniband.portcounters_ext.counterselect",
7255                 FT_UINT16, BASE_HEX, NULL, 0x0,
7256                 "When writing, selects which counters are affected by the operation", HFILL}
7257         },
7258         { &hf_infiniband_PortCountersExt_PortXmitData, {
7259                 "PortXmitData", "infiniband.portcounters_ext.portxmitdata",
7260                 FT_UINT64, BASE_DEC, NULL, 0x0,
7261                 "Total number of data octets, divided by 4, transmitted on all VLs from the port", HFILL}
7262         },
7263         { &hf_infiniband_PortCountersExt_PortRcvData, {
7264                 "PortRcvData", "infiniband.portcounters_ext.portrcvdata",
7265                 FT_UINT64, BASE_DEC, NULL, 0x0,
7266                 "Total number of data octets, divided by 4, received on all VLs at the port", HFILL}
7267         },
7268         { &hf_infiniband_PortCountersExt_PortXmitPkts, {
7269                 "PortXmitPkts", "infiniband.portcounters_ext.portxmitpkts",
7270                 FT_UINT64, BASE_DEC, NULL, 0x0,
7271                 "Total number of packets transmitted on all VLs from the port", HFILL}
7272         },
7273         { &hf_infiniband_PortCountersExt_PortRcvPkts, {
7274                 "PortRcvPkts", "infiniband.portcounters_ext.portrcvpkts",
7275                 FT_UINT64, BASE_DEC, NULL, 0x0,
7276                 "Total number of packets received from all VLs on the port", HFILL}
7277         },
7278         { &hf_infiniband_PortCountersExt_PortUnicastXmitPkts, {
7279                 "PortUnicastXmitPkts", "infiniband.portcounters_ext.portunicastxmitpkts",
7280                 FT_UINT64, BASE_DEC, NULL, 0x0,
7281                 "Total number of unicast packets transmitted on all VLs from the port", HFILL}
7282         },
7283         { &hf_infiniband_PortCountersExt_PortUnicastRcvPkts, {
7284                 "PortUnicastRcvPkts", "infiniband.portcounters_ext.portunicastrcvpkts",
7285                 FT_UINT64, BASE_DEC, NULL, 0x0,
7286                 "Total number of unicast packets received from all VLs on the port", HFILL}
7287         },
7288         { &hf_infiniband_PortCountersExt_PortMulticastXmitPkts, {
7289                 "PortMulticastXmitPkts", "infiniband.portcounters_ext.portmulticastxmitpkts",
7290                 FT_UINT64, BASE_DEC, NULL, 0x0,
7291                 "Total number of multicast packets transmitted on all VLs from the port", HFILL}
7292         },
7293         { &hf_infiniband_PortCountersExt_PortMulticastRcvPkts, {
7294                 "PortMulticastRcvPkts", "infiniband.portcounters_ext.portmulticastrcvpkts",
7295                 FT_UINT64, BASE_DEC, NULL, 0x0,
7296                 "Total number of multicast packets received from all VLs on the port", HFILL}
7297         }
7298     };
7299
7300     /* Array to hold expansion options between dissections */
7301     static gint *ett[] = {
7302     /*  &ett_infiniband,       */
7303         &ett_all_headers,
7304         &ett_lrh,
7305         &ett_grh,
7306         &ett_bth,
7307         &ett_rwh,
7308         &ett_rdeth,
7309         &ett_deth,
7310         &ett_reth,
7311         &ett_atomiceth,
7312         &ett_aeth,
7313         &ett_atomicacketh,
7314         &ett_immdt,
7315         &ett_ieth,
7316         &ett_payload,
7317         &ett_vendor,
7318         &ett_subn_lid_routed,
7319         &ett_subn_directed_route,
7320         &ett_subnadmin,
7321         &ett_cm,
7322         &ett_mad,
7323         &ett_rmpp,
7324         &ett_subm_attribute,
7325         &ett_suba_attribute,
7326         &ett_datadetails,
7327         &ett_noticestraps,
7328     /*  &ett_nodedesc,         */
7329     /*  &ett_nodeinfo,         */
7330     /*  &ett_switchinfo,       */
7331     /*  &ett_guidinfo,         */
7332     /*  &ett_portinfo,         */
7333         &ett_portinfo_capmask,
7334         &ett_pkeytable,
7335         &ett_sltovlmapping,
7336         &ett_vlarbitrationtable,
7337         &ett_linearforwardingtable,
7338         &ett_randomforwardingtable,
7339         &ett_multicastforwardingtable,
7340         &ett_sminfo,
7341         &ett_vendordiag,
7342         &ett_ledinfo,
7343         &ett_linkspeedwidthpairs,
7344         &ett_informinfo,
7345         &ett_linkrecord,
7346         &ett_servicerecord,
7347         &ett_pathrecord,
7348         &ett_mcmemberrecord,
7349         &ett_tracerecord,
7350         &ett_multipathrecord,
7351         &ett_serviceassocrecord,
7352         &ett_perfclass,
7353         &ett_eoib
7354     };
7355
7356     static hf_register_info hf_link[] = {
7357         { &hf_infiniband_link_op, {
7358                 "Operand", "infiniband_link.op",
7359                 FT_UINT16, BASE_DEC, VALS(Operand_Description), 0xF000, NULL, HFILL}
7360         },
7361         { &hf_infiniband_link_fctbs, {
7362                 "Flow Control Total Blocks Sent", "infiniband_link.fctbs",
7363                 FT_UINT16, BASE_DEC, NULL, 0x0FFF, NULL, HFILL}
7364         },
7365         { &hf_infiniband_link_vl, {
7366                 "Virtual Lane", "infiniband_link.vl",
7367                 FT_UINT16, BASE_DEC, NULL, 0xF000, NULL, HFILL}
7368         },
7369         { &hf_infiniband_link_fccl, {
7370                 "Flow Control Credit Limit", "infiniband_link.fccl",
7371                 FT_UINT16, BASE_DEC, NULL, 0x0FFF, NULL, HFILL}
7372         },
7373         { &hf_infiniband_link_lpcrc, {
7374                 "Link Packet CRC", "infiniband_link.lpcrc",
7375                 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL}
7376         }
7377     };
7378
7379
7380     static gint *ett_link_array[] = {
7381         &ett_link
7382     };
7383
7384     proto_infiniband = proto_register_protocol("InfiniBand", "InfiniBand", "infiniband");
7385     ib_handle = register_dissector("infiniband", dissect_infiniband, proto_infiniband);
7386
7387     proto_register_field_array(proto_infiniband, hf, array_length(hf));
7388     proto_register_subtree_array(ett, array_length(ett));
7389
7390     /* register the subdissector tables */
7391     register_heur_dissector_list("infiniband.payload", &heur_dissectors_payload);
7392     register_heur_dissector_list("infiniband.mad.cm.private", &heur_dissectors_cm_private);
7393
7394     /* register dissection preferences */
7395     infiniband_module = prefs_register_protocol(proto_infiniband, NULL);
7396
7397     prefs_register_bool_preference(infiniband_module, "identify_payload",
7398                                    "Attempt to identify and parse encapsulated IBA payloads",
7399                                    "When set, dissector will attempt to identify unknown IBA payloads "
7400                                    "as containing an encapsulated ethertype, and parse them accordingly",
7401                                    &pref_identify_iba_payload);
7402     prefs_register_bool_preference(infiniband_module, "dissect_eoib",
7403                                    "Attempt to identify and parse Mellanox EoIB packets",
7404                                    "When set, dissector will attempt to identify and parse "
7405                                    "Mellanox Ethernet-over-InfiniBand packets",
7406                                    &pref_dissect_eoib);
7407
7408     proto_infiniband_link = proto_register_protocol("InfiniBand Link", "InfiniBand Link", "infiniband_link");
7409     register_dissector("infiniband_link", dissect_infiniband_link, proto_infiniband_link);
7410
7411     proto_register_field_array(proto_infiniband_link, hf_link, array_length(hf_link));
7412     proto_register_subtree_array(ett_link_array, array_length(ett_link_array));
7413
7414     register_init_routine(proto_init_infiniband);
7415
7416     /* initialize the hash table */
7417     CM_context_table = g_hash_table_new_full(g_int64_hash, g_int64_equal,
7418                                              table_destroy_notify, table_destroy_notify);
7419 }
7420
7421 /* Reg Handoff.  Register dissectors we'll need for IPoIB and RoCE */
7422 void proto_reg_handoff_infiniband(void)
7423 {
7424     dissector_handle_t roce_handle;
7425
7426     ipv6_handle               = find_dissector("ipv6");
7427     data_handle               = find_dissector("data");
7428     eth_handle                = find_dissector("eth");
7429     ethertype_dissector_table = find_dissector_table("ethertype");
7430
7431     /* create and announce an anonymous RoCE dissector */
7432     roce_handle = create_dissector_handle(dissect_roce, proto_infiniband);
7433     dissector_add_uint("ethertype", ETHERTYPE_ROCE, roce_handle);
7434
7435     dissector_add_uint("wtap_encap", WTAP_ENCAP_INFINIBAND, ib_handle);
7436 }