2 * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
4 * Copyright (c) 2004 Topspin Corporation. All rights reserved.
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
40 #include <rdma/ib_verbs.h>
54 size_t struct_offset_bytes;
55 size_t struct_size_bytes;
63 .field_name = "reserved"
66 * This macro cleans up the definitions of constants for BTH opcodes.
67 * It is used to define constants such as IB_OPCODE_UD_SEND_ONLY,
68 * which becomes IB_OPCODE_UD + IB_OPCODE_SEND_ONLY, and this gives
71 * In short, user code should use the constants defined using the
72 * macro rather than worrying about adding together other constants.
74 #define IB_OPCODE(transport, op) \
75 IB_OPCODE_ ## transport ## _ ## op = \
76 IB_OPCODE_ ## transport + IB_OPCODE_ ## op
79 /* transport types -- just used to define real constants */
84 /* per IBTA 1.3 vol 1 Table 38, A10.3.2 */
87 /* operations -- just used to define real constants */
88 IB_OPCODE_SEND_FIRST = 0x00,
89 IB_OPCODE_SEND_MIDDLE = 0x01,
90 IB_OPCODE_SEND_LAST = 0x02,
91 IB_OPCODE_SEND_LAST_WITH_IMMEDIATE = 0x03,
92 IB_OPCODE_SEND_ONLY = 0x04,
93 IB_OPCODE_SEND_ONLY_WITH_IMMEDIATE = 0x05,
94 IB_OPCODE_RDMA_WRITE_FIRST = 0x06,
95 IB_OPCODE_RDMA_WRITE_MIDDLE = 0x07,
96 IB_OPCODE_RDMA_WRITE_LAST = 0x08,
97 IB_OPCODE_RDMA_WRITE_LAST_WITH_IMMEDIATE = 0x09,
98 IB_OPCODE_RDMA_WRITE_ONLY = 0x0a,
99 IB_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE = 0x0b,
100 IB_OPCODE_RDMA_READ_REQUEST = 0x0c,
101 IB_OPCODE_RDMA_READ_RESPONSE_FIRST = 0x0d,
102 IB_OPCODE_RDMA_READ_RESPONSE_MIDDLE = 0x0e,
103 IB_OPCODE_RDMA_READ_RESPONSE_LAST = 0x0f,
104 IB_OPCODE_RDMA_READ_RESPONSE_ONLY = 0x10,
105 IB_OPCODE_ACKNOWLEDGE = 0x11,
106 IB_OPCODE_ATOMIC_ACKNOWLEDGE = 0x12,
107 IB_OPCODE_COMPARE_SWAP = 0x13,
108 IB_OPCODE_FETCH_ADD = 0x14,
109 /* opcode 0x15 is reserved */
110 IB_OPCODE_SEND_LAST_WITH_INVALIDATE = 0x16,
111 IB_OPCODE_SEND_ONLY_WITH_INVALIDATE = 0x17,
113 /* real constants follow -- see comment about above IB_OPCODE()
114 macro for more details */
117 IB_OPCODE(RC, SEND_FIRST),
118 IB_OPCODE(RC, SEND_MIDDLE),
119 IB_OPCODE(RC, SEND_LAST),
120 IB_OPCODE(RC, SEND_LAST_WITH_IMMEDIATE),
121 IB_OPCODE(RC, SEND_ONLY),
122 IB_OPCODE(RC, SEND_ONLY_WITH_IMMEDIATE),
123 IB_OPCODE(RC, RDMA_WRITE_FIRST),
124 IB_OPCODE(RC, RDMA_WRITE_MIDDLE),
125 IB_OPCODE(RC, RDMA_WRITE_LAST),
126 IB_OPCODE(RC, RDMA_WRITE_LAST_WITH_IMMEDIATE),
127 IB_OPCODE(RC, RDMA_WRITE_ONLY),
128 IB_OPCODE(RC, RDMA_WRITE_ONLY_WITH_IMMEDIATE),
129 IB_OPCODE(RC, RDMA_READ_REQUEST),
130 IB_OPCODE(RC, RDMA_READ_RESPONSE_FIRST),
131 IB_OPCODE(RC, RDMA_READ_RESPONSE_MIDDLE),
132 IB_OPCODE(RC, RDMA_READ_RESPONSE_LAST),
133 IB_OPCODE(RC, RDMA_READ_RESPONSE_ONLY),
134 IB_OPCODE(RC, ACKNOWLEDGE),
135 IB_OPCODE(RC, ATOMIC_ACKNOWLEDGE),
136 IB_OPCODE(RC, COMPARE_SWAP),
137 IB_OPCODE(RC, FETCH_ADD),
138 IB_OPCODE(RC, SEND_LAST_WITH_INVALIDATE),
139 IB_OPCODE(RC, SEND_ONLY_WITH_INVALIDATE),
142 IB_OPCODE(UC, SEND_FIRST),
143 IB_OPCODE(UC, SEND_MIDDLE),
144 IB_OPCODE(UC, SEND_LAST),
145 IB_OPCODE(UC, SEND_LAST_WITH_IMMEDIATE),
146 IB_OPCODE(UC, SEND_ONLY),
147 IB_OPCODE(UC, SEND_ONLY_WITH_IMMEDIATE),
148 IB_OPCODE(UC, RDMA_WRITE_FIRST),
149 IB_OPCODE(UC, RDMA_WRITE_MIDDLE),
150 IB_OPCODE(UC, RDMA_WRITE_LAST),
151 IB_OPCODE(UC, RDMA_WRITE_LAST_WITH_IMMEDIATE),
152 IB_OPCODE(UC, RDMA_WRITE_ONLY),
153 IB_OPCODE(UC, RDMA_WRITE_ONLY_WITH_IMMEDIATE),
156 IB_OPCODE(RD, SEND_FIRST),
157 IB_OPCODE(RD, SEND_MIDDLE),
158 IB_OPCODE(RD, SEND_LAST),
159 IB_OPCODE(RD, SEND_LAST_WITH_IMMEDIATE),
160 IB_OPCODE(RD, SEND_ONLY),
161 IB_OPCODE(RD, SEND_ONLY_WITH_IMMEDIATE),
162 IB_OPCODE(RD, RDMA_WRITE_FIRST),
163 IB_OPCODE(RD, RDMA_WRITE_MIDDLE),
164 IB_OPCODE(RD, RDMA_WRITE_LAST),
165 IB_OPCODE(RD, RDMA_WRITE_LAST_WITH_IMMEDIATE),
166 IB_OPCODE(RD, RDMA_WRITE_ONLY),
167 IB_OPCODE(RD, RDMA_WRITE_ONLY_WITH_IMMEDIATE),
168 IB_OPCODE(RD, RDMA_READ_REQUEST),
169 IB_OPCODE(RD, RDMA_READ_RESPONSE_FIRST),
170 IB_OPCODE(RD, RDMA_READ_RESPONSE_MIDDLE),
171 IB_OPCODE(RD, RDMA_READ_RESPONSE_LAST),
172 IB_OPCODE(RD, RDMA_READ_RESPONSE_ONLY),
173 IB_OPCODE(RD, ACKNOWLEDGE),
174 IB_OPCODE(RD, ATOMIC_ACKNOWLEDGE),
175 IB_OPCODE(RD, COMPARE_SWAP),
176 IB_OPCODE(RD, FETCH_ADD),
179 IB_OPCODE(UD, SEND_ONLY),
180 IB_OPCODE(UD, SEND_ONLY_WITH_IMMEDIATE)
186 IB_LNH_IBA_LOCAL = 2,
187 IB_LNH_IBA_GLOBAL = 3
190 struct ib_unpacked_lrh {
195 __be16 destination_lid;
196 __be16 packet_length;
200 struct ib_unpacked_grh {
204 __be16 payload_length;
207 union ib_gid source_gid;
208 union ib_gid destination_gid;
211 struct ib_unpacked_bth {
216 u8 transport_header_version;
218 __be32 destination_qpn;
223 struct ib_unpacked_deth {
228 struct ib_unpacked_eth {
236 struct ib_unpacked_ip4 {
250 struct ib_unpacked_udp {
257 struct ib_unpacked_vlan {
262 struct ib_ud_header {
264 struct ib_unpacked_lrh lrh;
266 struct ib_unpacked_eth eth;
268 struct ib_unpacked_vlan vlan;
270 struct ib_unpacked_grh grh;
272 struct ib_unpacked_ip4 ip4;
274 struct ib_unpacked_udp udp;
275 struct ib_unpacked_bth bth;
276 struct ib_unpacked_deth deth;
277 int immediate_present;
278 __be32 immediate_data;
281 void ib_pack(const struct ib_field *desc,
286 void ib_unpack(const struct ib_field *desc,
291 __sum16 ib_ud_ip4_csum(struct ib_ud_header *header);
293 int ib_ud_header_init(int payload_bytes,
300 int immediate_present,
301 struct ib_ud_header *header);
303 int ib_ud_header_pack(struct ib_ud_header *header,
306 int ib_ud_header_unpack(void *buf,
307 struct ib_ud_header *header);
309 #endif /* IB_PACK_H */