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