1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
3 * Copyright (c) 2004 Topspin Corporation. All rights reserved.
9 #include <rdma/ib_verbs.h>
10 #include <uapi/linux/if_ether.h>
21 IB_EXT_ATOMICETH_BYTES = 28,
27 size_t struct_offset_bytes;
28 size_t struct_size_bytes;
36 .field_name = "reserved"
39 * This macro cleans up the definitions of constants for BTH opcodes.
40 * It is used to define constants such as IB_OPCODE_UD_SEND_ONLY,
41 * which becomes IB_OPCODE_UD + IB_OPCODE_SEND_ONLY, and this gives
44 * In short, user code should use the constants defined using the
45 * macro rather than worrying about adding together other constants.
47 #define IB_OPCODE(transport, op) \
48 IB_OPCODE_ ## transport ## _ ## op = \
49 IB_OPCODE_ ## transport + IB_OPCODE_ ## op
52 /* transport types -- just used to define real constants */
57 /* per IBTA 1.3 vol 1 Table 38, A10.3.2 */
59 /* Manufacturer specific */
62 /* operations -- just used to define real constants */
63 IB_OPCODE_SEND_FIRST = 0x00,
64 IB_OPCODE_SEND_MIDDLE = 0x01,
65 IB_OPCODE_SEND_LAST = 0x02,
66 IB_OPCODE_SEND_LAST_WITH_IMMEDIATE = 0x03,
67 IB_OPCODE_SEND_ONLY = 0x04,
68 IB_OPCODE_SEND_ONLY_WITH_IMMEDIATE = 0x05,
69 IB_OPCODE_RDMA_WRITE_FIRST = 0x06,
70 IB_OPCODE_RDMA_WRITE_MIDDLE = 0x07,
71 IB_OPCODE_RDMA_WRITE_LAST = 0x08,
72 IB_OPCODE_RDMA_WRITE_LAST_WITH_IMMEDIATE = 0x09,
73 IB_OPCODE_RDMA_WRITE_ONLY = 0x0a,
74 IB_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE = 0x0b,
75 IB_OPCODE_RDMA_READ_REQUEST = 0x0c,
76 IB_OPCODE_RDMA_READ_RESPONSE_FIRST = 0x0d,
77 IB_OPCODE_RDMA_READ_RESPONSE_MIDDLE = 0x0e,
78 IB_OPCODE_RDMA_READ_RESPONSE_LAST = 0x0f,
79 IB_OPCODE_RDMA_READ_RESPONSE_ONLY = 0x10,
80 IB_OPCODE_ACKNOWLEDGE = 0x11,
81 IB_OPCODE_ATOMIC_ACKNOWLEDGE = 0x12,
82 IB_OPCODE_COMPARE_SWAP = 0x13,
83 IB_OPCODE_FETCH_ADD = 0x14,
84 /* opcode 0x15 is reserved */
85 IB_OPCODE_SEND_LAST_WITH_INVALIDATE = 0x16,
86 IB_OPCODE_SEND_ONLY_WITH_INVALIDATE = 0x17,
87 IB_OPCODE_FLUSH = 0x1C,
88 IB_OPCODE_ATOMIC_WRITE = 0x1D,
90 /* real constants follow -- see comment about above IB_OPCODE()
91 macro for more details */
94 IB_OPCODE(RC, SEND_FIRST),
95 IB_OPCODE(RC, SEND_MIDDLE),
96 IB_OPCODE(RC, SEND_LAST),
97 IB_OPCODE(RC, SEND_LAST_WITH_IMMEDIATE),
98 IB_OPCODE(RC, SEND_ONLY),
99 IB_OPCODE(RC, SEND_ONLY_WITH_IMMEDIATE),
100 IB_OPCODE(RC, RDMA_WRITE_FIRST),
101 IB_OPCODE(RC, RDMA_WRITE_MIDDLE),
102 IB_OPCODE(RC, RDMA_WRITE_LAST),
103 IB_OPCODE(RC, RDMA_WRITE_LAST_WITH_IMMEDIATE),
104 IB_OPCODE(RC, RDMA_WRITE_ONLY),
105 IB_OPCODE(RC, RDMA_WRITE_ONLY_WITH_IMMEDIATE),
106 IB_OPCODE(RC, RDMA_READ_REQUEST),
107 IB_OPCODE(RC, RDMA_READ_RESPONSE_FIRST),
108 IB_OPCODE(RC, RDMA_READ_RESPONSE_MIDDLE),
109 IB_OPCODE(RC, RDMA_READ_RESPONSE_LAST),
110 IB_OPCODE(RC, RDMA_READ_RESPONSE_ONLY),
111 IB_OPCODE(RC, ACKNOWLEDGE),
112 IB_OPCODE(RC, ATOMIC_ACKNOWLEDGE),
113 IB_OPCODE(RC, COMPARE_SWAP),
114 IB_OPCODE(RC, FETCH_ADD),
115 IB_OPCODE(RC, SEND_LAST_WITH_INVALIDATE),
116 IB_OPCODE(RC, SEND_ONLY_WITH_INVALIDATE),
117 IB_OPCODE(RC, FLUSH),
118 IB_OPCODE(RC, ATOMIC_WRITE),
121 IB_OPCODE(UC, SEND_FIRST),
122 IB_OPCODE(UC, SEND_MIDDLE),
123 IB_OPCODE(UC, SEND_LAST),
124 IB_OPCODE(UC, SEND_LAST_WITH_IMMEDIATE),
125 IB_OPCODE(UC, SEND_ONLY),
126 IB_OPCODE(UC, SEND_ONLY_WITH_IMMEDIATE),
127 IB_OPCODE(UC, RDMA_WRITE_FIRST),
128 IB_OPCODE(UC, RDMA_WRITE_MIDDLE),
129 IB_OPCODE(UC, RDMA_WRITE_LAST),
130 IB_OPCODE(UC, RDMA_WRITE_LAST_WITH_IMMEDIATE),
131 IB_OPCODE(UC, RDMA_WRITE_ONLY),
132 IB_OPCODE(UC, RDMA_WRITE_ONLY_WITH_IMMEDIATE),
135 IB_OPCODE(RD, SEND_FIRST),
136 IB_OPCODE(RD, SEND_MIDDLE),
137 IB_OPCODE(RD, SEND_LAST),
138 IB_OPCODE(RD, SEND_LAST_WITH_IMMEDIATE),
139 IB_OPCODE(RD, SEND_ONLY),
140 IB_OPCODE(RD, SEND_ONLY_WITH_IMMEDIATE),
141 IB_OPCODE(RD, RDMA_WRITE_FIRST),
142 IB_OPCODE(RD, RDMA_WRITE_MIDDLE),
143 IB_OPCODE(RD, RDMA_WRITE_LAST),
144 IB_OPCODE(RD, RDMA_WRITE_LAST_WITH_IMMEDIATE),
145 IB_OPCODE(RD, RDMA_WRITE_ONLY),
146 IB_OPCODE(RD, RDMA_WRITE_ONLY_WITH_IMMEDIATE),
147 IB_OPCODE(RD, RDMA_READ_REQUEST),
148 IB_OPCODE(RD, RDMA_READ_RESPONSE_FIRST),
149 IB_OPCODE(RD, RDMA_READ_RESPONSE_MIDDLE),
150 IB_OPCODE(RD, RDMA_READ_RESPONSE_LAST),
151 IB_OPCODE(RD, RDMA_READ_RESPONSE_ONLY),
152 IB_OPCODE(RD, ACKNOWLEDGE),
153 IB_OPCODE(RD, ATOMIC_ACKNOWLEDGE),
154 IB_OPCODE(RD, COMPARE_SWAP),
155 IB_OPCODE(RD, FETCH_ADD),
156 IB_OPCODE(RD, FLUSH),
159 IB_OPCODE(UD, SEND_ONLY),
160 IB_OPCODE(UD, SEND_ONLY_WITH_IMMEDIATE)
166 IB_LNH_IBA_LOCAL = 2,
167 IB_LNH_IBA_GLOBAL = 3
170 struct ib_unpacked_lrh {
175 __be16 destination_lid;
176 __be16 packet_length;
180 struct ib_unpacked_grh {
184 __be16 payload_length;
187 union ib_gid source_gid;
188 union ib_gid destination_gid;
191 struct ib_unpacked_bth {
196 u8 transport_header_version;
198 __be32 destination_qpn;
203 struct ib_unpacked_deth {
208 struct ib_unpacked_eth {
216 struct ib_unpacked_ip4 {
230 struct ib_unpacked_udp {
237 struct ib_unpacked_vlan {
242 struct ib_ud_header {
244 struct ib_unpacked_lrh lrh;
246 struct ib_unpacked_eth eth;
248 struct ib_unpacked_vlan vlan;
250 struct ib_unpacked_grh grh;
252 struct ib_unpacked_ip4 ip4;
254 struct ib_unpacked_udp udp;
255 struct ib_unpacked_bth bth;
256 struct ib_unpacked_deth deth;
257 int immediate_present;
258 __be32 immediate_data;
261 void ib_pack(const struct ib_field *desc,
266 void ib_unpack(const struct ib_field *desc,
271 __sum16 ib_ud_ip4_csum(struct ib_ud_header *header);
273 int ib_ud_header_init(int payload_bytes,
280 int immediate_present,
281 struct ib_ud_header *header);
283 int ib_ud_header_pack(struct ib_ud_header *header,
286 int ib_ud_header_unpack(void *buf,
287 struct ib_ud_header *header);
289 #endif /* IB_PACK_H */