2 * Copyright (c) 2004 Topspin Corporation. All rights reserved.
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36 #include <rdma/ib_verbs.h>
37 #include <uapi/linux/if_ether.h>
49 size_t struct_offset_bytes;
50 size_t struct_size_bytes;
58 .field_name = "reserved"
61 * This macro cleans up the definitions of constants for BTH opcodes.
62 * It is used to define constants such as IB_OPCODE_UD_SEND_ONLY,
63 * which becomes IB_OPCODE_UD + IB_OPCODE_SEND_ONLY, and this gives
66 * In short, user code should use the constants defined using the
67 * macro rather than worrying about adding together other constants.
69 #define IB_OPCODE(transport, op) \
70 IB_OPCODE_ ## transport ## _ ## op = \
71 IB_OPCODE_ ## transport + IB_OPCODE_ ## op
74 /* transport types -- just used to define real constants */
79 /* per IBTA 1.3 vol 1 Table 38, A10.3.2 */
82 /* operations -- just used to define real constants */
83 IB_OPCODE_SEND_FIRST = 0x00,
84 IB_OPCODE_SEND_MIDDLE = 0x01,
85 IB_OPCODE_SEND_LAST = 0x02,
86 IB_OPCODE_SEND_LAST_WITH_IMMEDIATE = 0x03,
87 IB_OPCODE_SEND_ONLY = 0x04,
88 IB_OPCODE_SEND_ONLY_WITH_IMMEDIATE = 0x05,
89 IB_OPCODE_RDMA_WRITE_FIRST = 0x06,
90 IB_OPCODE_RDMA_WRITE_MIDDLE = 0x07,
91 IB_OPCODE_RDMA_WRITE_LAST = 0x08,
92 IB_OPCODE_RDMA_WRITE_LAST_WITH_IMMEDIATE = 0x09,
93 IB_OPCODE_RDMA_WRITE_ONLY = 0x0a,
94 IB_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE = 0x0b,
95 IB_OPCODE_RDMA_READ_REQUEST = 0x0c,
96 IB_OPCODE_RDMA_READ_RESPONSE_FIRST = 0x0d,
97 IB_OPCODE_RDMA_READ_RESPONSE_MIDDLE = 0x0e,
98 IB_OPCODE_RDMA_READ_RESPONSE_LAST = 0x0f,
99 IB_OPCODE_RDMA_READ_RESPONSE_ONLY = 0x10,
100 IB_OPCODE_ACKNOWLEDGE = 0x11,
101 IB_OPCODE_ATOMIC_ACKNOWLEDGE = 0x12,
102 IB_OPCODE_COMPARE_SWAP = 0x13,
103 IB_OPCODE_FETCH_ADD = 0x14,
105 /* real constants follow -- see comment about above IB_OPCODE()
106 macro for more details */
109 IB_OPCODE(RC, SEND_FIRST),
110 IB_OPCODE(RC, SEND_MIDDLE),
111 IB_OPCODE(RC, SEND_LAST),
112 IB_OPCODE(RC, SEND_LAST_WITH_IMMEDIATE),
113 IB_OPCODE(RC, SEND_ONLY),
114 IB_OPCODE(RC, SEND_ONLY_WITH_IMMEDIATE),
115 IB_OPCODE(RC, RDMA_WRITE_FIRST),
116 IB_OPCODE(RC, RDMA_WRITE_MIDDLE),
117 IB_OPCODE(RC, RDMA_WRITE_LAST),
118 IB_OPCODE(RC, RDMA_WRITE_LAST_WITH_IMMEDIATE),
119 IB_OPCODE(RC, RDMA_WRITE_ONLY),
120 IB_OPCODE(RC, RDMA_WRITE_ONLY_WITH_IMMEDIATE),
121 IB_OPCODE(RC, RDMA_READ_REQUEST),
122 IB_OPCODE(RC, RDMA_READ_RESPONSE_FIRST),
123 IB_OPCODE(RC, RDMA_READ_RESPONSE_MIDDLE),
124 IB_OPCODE(RC, RDMA_READ_RESPONSE_LAST),
125 IB_OPCODE(RC, RDMA_READ_RESPONSE_ONLY),
126 IB_OPCODE(RC, ACKNOWLEDGE),
127 IB_OPCODE(RC, ATOMIC_ACKNOWLEDGE),
128 IB_OPCODE(RC, COMPARE_SWAP),
129 IB_OPCODE(RC, FETCH_ADD),
132 IB_OPCODE(UC, SEND_FIRST),
133 IB_OPCODE(UC, SEND_MIDDLE),
134 IB_OPCODE(UC, SEND_LAST),
135 IB_OPCODE(UC, SEND_LAST_WITH_IMMEDIATE),
136 IB_OPCODE(UC, SEND_ONLY),
137 IB_OPCODE(UC, SEND_ONLY_WITH_IMMEDIATE),
138 IB_OPCODE(UC, RDMA_WRITE_FIRST),
139 IB_OPCODE(UC, RDMA_WRITE_MIDDLE),
140 IB_OPCODE(UC, RDMA_WRITE_LAST),
141 IB_OPCODE(UC, RDMA_WRITE_LAST_WITH_IMMEDIATE),
142 IB_OPCODE(UC, RDMA_WRITE_ONLY),
143 IB_OPCODE(UC, RDMA_WRITE_ONLY_WITH_IMMEDIATE),
146 IB_OPCODE(RD, SEND_FIRST),
147 IB_OPCODE(RD, SEND_MIDDLE),
148 IB_OPCODE(RD, SEND_LAST),
149 IB_OPCODE(RD, SEND_LAST_WITH_IMMEDIATE),
150 IB_OPCODE(RD, SEND_ONLY),
151 IB_OPCODE(RD, SEND_ONLY_WITH_IMMEDIATE),
152 IB_OPCODE(RD, RDMA_WRITE_FIRST),
153 IB_OPCODE(RD, RDMA_WRITE_MIDDLE),
154 IB_OPCODE(RD, RDMA_WRITE_LAST),
155 IB_OPCODE(RD, RDMA_WRITE_LAST_WITH_IMMEDIATE),
156 IB_OPCODE(RD, RDMA_WRITE_ONLY),
157 IB_OPCODE(RD, RDMA_WRITE_ONLY_WITH_IMMEDIATE),
158 IB_OPCODE(RD, RDMA_READ_REQUEST),
159 IB_OPCODE(RD, RDMA_READ_RESPONSE_FIRST),
160 IB_OPCODE(RD, RDMA_READ_RESPONSE_MIDDLE),
161 IB_OPCODE(RD, RDMA_READ_RESPONSE_LAST),
162 IB_OPCODE(RD, RDMA_READ_RESPONSE_ONLY),
163 IB_OPCODE(RD, ACKNOWLEDGE),
164 IB_OPCODE(RD, ATOMIC_ACKNOWLEDGE),
165 IB_OPCODE(RD, COMPARE_SWAP),
166 IB_OPCODE(RD, FETCH_ADD),
169 IB_OPCODE(UD, SEND_ONLY),
170 IB_OPCODE(UD, SEND_ONLY_WITH_IMMEDIATE)
176 IB_LNH_IBA_LOCAL = 2,
177 IB_LNH_IBA_GLOBAL = 3
180 struct ib_unpacked_lrh {
185 __be16 destination_lid;
186 __be16 packet_length;
190 struct ib_unpacked_grh {
194 __be16 payload_length;
197 union ib_gid source_gid;
198 union ib_gid destination_gid;
201 struct ib_unpacked_bth {
206 u8 transport_header_version;
208 __be32 destination_qpn;
213 struct ib_unpacked_deth {
218 struct ib_unpacked_eth {
226 struct ib_unpacked_vlan {
231 struct ib_ud_header {
233 struct ib_unpacked_lrh lrh;
235 struct ib_unpacked_eth eth;
237 struct ib_unpacked_vlan vlan;
239 struct ib_unpacked_grh grh;
240 struct ib_unpacked_bth bth;
241 struct ib_unpacked_deth deth;
242 int immediate_present;
243 __be32 immediate_data;
246 void ib_pack(const struct ib_field *desc,
251 void ib_unpack(const struct ib_field *desc,
256 void ib_ud_header_init(int payload_bytes,
261 int immediate_present,
262 struct ib_ud_header *header);
264 int ib_ud_header_pack(struct ib_ud_header *header,
267 int ib_ud_header_unpack(void *buf,
268 struct ib_ud_header *header);
270 #endif /* IB_PACK_H */