1 /* packet-infiniband.h
2  * Routines for Infiniband/ERF Dissection
3  * Copyright 2008 Endace Technology Limited
4  *
5  * Wireshark - Network traffic analyzer
6  * By Gerald Combs <gerald@wireshark.org>
7  * Copyright 1998 Gerald Combs
8  *
9  * Modified 2010 by Mellanox Technologies Ltd.
10  *
11  * SPDX-License-Identifier: GPL-2.0-or-later
12  */
13 #ifndef __PACKET_INFINIBAND_H_
14 #define __PACKET_INFINIBAND_H_
15 
16 #define MAD_DATA_SIZE     232     /* size of data field a MAD payload carries */
17 #define GID_SIZE          16      /* size of GID = 128bit (same as IPv6) */
18 
19 /* infiniband-specific information for conversations */
20 typedef struct {
21     guint64 service_id;         /* service id specified when the (RC) channel was set-up */
22     gboolean client_to_server;  /* message direction */
23     guint32 src_qp;             /* originator src qp as this is not present in RC packets */
24 
25     /* store mad data so that it can be parsed for private data by ULP */
26     guint8 mad_private_data[MAD_DATA_SIZE];
27 } conversation_infiniband_data;
28 
29 /* OpCodeValues
30 * Code Bits [7-5] Connection Type
31 *           [4-0] Message Type
32 
33 * Reliable Connection (RC)
34 * [7-5] = 000 */
35 #define RC_SEND_FIRST                    0 /*0x00000000 */
36 #define RC_SEND_MIDDLE                   1 /*0x00000001 */
37 #define RC_SEND_LAST                     2 /*0x00000010 */
38 #define RC_SEND_LAST_IMM                 3 /*0x00000011 */
39 #define RC_SEND_ONLY                     4 /*0x00000100 */
40 #define RC_SEND_ONLY_IMM                 5 /*0x00000101 */
41 #define RC_RDMA_WRITE_FIRST              6 /*0x00000110 */
42 #define RC_RDMA_WRITE_MIDDLE             7 /*0x00000111 */
43 #define RC_RDMA_WRITE_LAST               8 /*0x00001000 */
44 #define RC_RDMA_WRITE_LAST_IMM           9 /*0x00001001 */
45 #define RC_RDMA_WRITE_ONLY              10 /*0x00001010 */
46 #define RC_RDMA_WRITE_ONLY_IMM          11 /*0x00001011 */
47 #define RC_RDMA_READ_REQUEST            12 /*0x00001100 */
48 #define RC_RDMA_READ_RESPONSE_FIRST     13 /*0x00001101 */
49 #define RC_RDMA_READ_RESPONSE_MIDDLE    14 /*0x00001110 */
50 #define RC_RDMA_READ_RESPONSE_LAST      15 /*0x00001111 */
51 #define RC_RDMA_READ_RESPONSE_ONLY      16 /*0x00010000 */
52 #define RC_ACKNOWLEDGE                  17 /*0x00010001 */
53 #define RC_ATOMIC_ACKNOWLEDGE           18 /*0x00010010 */
54 #define RC_CMP_SWAP                     19 /*0x00010011 */
55 #define RC_FETCH_ADD                    20 /*0x00010100 */
56 #define RC_SEND_LAST_INVAL              22 /*0x00010110 */
57 #define RC_SEND_ONLY_INVAL              23 /*0x00010111 */
58 
59 /* Reliable Datagram (RD)
60 * [7-5] = 010 */
61 #define RD_SEND_FIRST                   64 /*0x01000000 */
62 #define RD_SEND_MIDDLE                  65 /*0x01000001 */
63 #define RD_SEND_LAST                    66 /*0x01000010 */
64 #define RD_SEND_LAST_IMM                67 /*0x01000011 */
65 #define RD_SEND_ONLY                    68 /*0x01000100 */
66 #define RD_SEND_ONLY_IMM                69 /*0x01000101 */
67 #define RD_RDMA_WRITE_FIRST             70 /*0x01000110 */
68 #define RD_RDMA_WRITE_MIDDLE            71 /*0x01000111 */
69 #define RD_RDMA_WRITE_LAST              72 /*0x01001000 */
70 #define RD_RDMA_WRITE_LAST_IMM          73 /*0x01001001 */
71 #define RD_RDMA_WRITE_ONLY              74 /*0x01001010 */
72 #define RD_RDMA_WRITE_ONLY_IMM          75 /*0x01001011 */
73 #define RD_RDMA_READ_REQUEST            76 /*0x01001100 */
74 #define RD_RDMA_READ_RESPONSE_FIRST     77 /*0x01001101 */
75 #define RD_RDMA_READ_RESPONSE_MIDDLE    78 /*0x01001110 */
76 #define RD_RDMA_READ_RESPONSE_LAST      79 /*0x01001111 */
77 #define RD_RDMA_READ_RESPONSE_ONLY      80 /*0x01010000 */
78 #define RD_ACKNOWLEDGE                  81 /*0x01010001 */
79 #define RD_ATOMIC_ACKNOWLEDGE           82 /*0x01010010 */
80 #define RD_CMP_SWAP                     83 /*0x01010011 */
81 #define RD_FETCH_ADD                    84 /*0x01010100 */
82 #define RD_RESYNC                       85 /*0x01010101 */
83 
84 /* Unreliable Datagram (UD)
85 * [7-5] = 011 */
86 #define UD_SEND_ONLY                   100 /*0x01100100 */
87 #define UD_SEND_ONLY_IMM               101 /*0x01100101 */
88 
89 /* Unreliable Connection (UC)
90 * [7-5] = 001 */
91 #define UC_SEND_FIRST                   32 /*0x00100000 */
92 #define UC_SEND_MIDDLE                  33 /*0x00100001 */
93 #define UC_SEND_LAST                    34 /*0x00100010 */
94 #define UC_SEND_LAST_IMM                35 /*0x00100011 */
95 #define UC_SEND_ONLY                    36 /*0x00100100 */
96 #define UC_SEND_ONLY_IMM                37 /*0x00100101 */
97 #define UC_RDMA_WRITE_FIRST             38 /*0x00100110 */
98 #define UC_RDMA_WRITE_MIDDLE            39 /*0x00100111 */
99 #define UC_RDMA_WRITE_LAST              40 /*0x00101000 */
100 #define UC_RDMA_WRITE_LAST_IMM          41 /*0x00101001 */
101 #define UC_RDMA_WRITE_ONLY              42 /*0x00101010 */
102 #define UC_RDMA_WRITE_ONLY_IMM          43 /*0x00101011 */
103 
104 /* ComMgt class Attributes */
105 #define ATTR_CM_REQ             0x0010
106 #define ATTR_CM_REJ             0x0012
107 #define ATTR_CM_REP             0x0013
108 #define ATTR_CM_RTU             0x0014
109 #define ATTR_CM_DREQ            0x0015
110 #define ATTR_CM_DRSP            0x0016
111 
112 /*
113  * Private data passed from the infiniband dissector to payload subdissectors.
114  */
115 struct infinibandinfo {
116     proto_tree* payload_tree;
117     guint8 opCode;              /* OpCode from BTH header. */
118     guint8 pad_count;           /* PadCount from BTH header. */
119     guint16 cm_attribute_id;    /* attribute id for CM messages */
120     guint32 reth_remote_key;    /* Remote Key from RETH header */
121     guint64 reth_remote_address;/* Remote address from RETH header */
122     guint32 reth_dma_length;    /* DMA Length from RETH header */
123     guint32 packet_seq_num;     /* Packet sequence number */
124     gboolean dctConnect;        /* indicator for DCT connect/disconnect */
125 };
126 
127 #endif
128 
129 /*
130  * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
131  *
132  * Local variables:
133  * c-basic-offset: 4
134  * tab-width: 8
135  * indent-tabs-mode: nil
136  * End:
137  *
138  * vi: set shiftwidth=4 tabstop=8 expandtab:
139  * :indentSize=4:tabSize=8:noTabs=true:
140  */
141