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