Blame view
include/rdma/ib_pack.h
7.71 KB
6bf9d8f6f RDMA/include: Rep... |
1 |
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ |
1da177e4c Linux-2.6.12-rc2 |
2 3 |
/* * Copyright (c) 2004 Topspin Corporation. All rights reserved. |
1da177e4c Linux-2.6.12-rc2 |
4 5 6 7 |
*/ #ifndef IB_PACK_H #define IB_PACK_H |
a4d61e848 [PATCH] IB: move ... |
8 |
#include <rdma/ib_verbs.h> |
dd5f03beb IB/core: Ethernet... |
9 |
#include <uapi/linux/if_ether.h> |
1da177e4c Linux-2.6.12-rc2 |
10 11 |
enum { |
99260132f IB/core: Fix calc... |
12 13 14 15 16 17 18 19 20 21 22 |
IB_LRH_BYTES = 8, IB_ETH_BYTES = 14, IB_VLAN_BYTES = 4, IB_GRH_BYTES = 40, IB_IP4_BYTES = 20, IB_UDP_BYTES = 8, IB_BTH_BYTES = 12, IB_DETH_BYTES = 8, IB_EXT_ATOMICETH_BYTES = 28, IB_EXT_XRC_BYTES = 4, IB_ICRC_BYTES = 4 |
1da177e4c Linux-2.6.12-rc2 |
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
}; struct ib_field { size_t struct_offset_bytes; size_t struct_size_bytes; int offset_words; int offset_bits; int size_bits; char *field_name; }; #define RESERVED \ .field_name = "reserved" /* * This macro cleans up the definitions of constants for BTH opcodes. * It is used to define constants such as IB_OPCODE_UD_SEND_ONLY, * which becomes IB_OPCODE_UD + IB_OPCODE_SEND_ONLY, and this gives * the correct value. * * In short, user code should use the constants defined using the * macro rather than worrying about adding together other constants. */ #define IB_OPCODE(transport, op) \ IB_OPCODE_ ## transport ## _ ## op = \ IB_OPCODE_ ## transport + IB_OPCODE_ ## op enum { /* transport types -- just used to define real constants */ IB_OPCODE_RC = 0x00, IB_OPCODE_UC = 0x20, IB_OPCODE_RD = 0x40, IB_OPCODE_UD = 0x60, |
931cf9a3e ib_pack.h: Fix co... |
56 |
/* per IBTA 1.3 vol 1 Table 38, A10.3.2 */ |
d4ab34700 IB/core: Add core... |
57 |
IB_OPCODE_CNP = 0x80, |
243d9f436 IB/hfi1: Add tran... |
58 59 |
/* Manufacturer specific */ IB_OPCODE_MSP = 0xe0, |
1da177e4c Linux-2.6.12-rc2 |
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
/* operations -- just used to define real constants */ IB_OPCODE_SEND_FIRST = 0x00, IB_OPCODE_SEND_MIDDLE = 0x01, IB_OPCODE_SEND_LAST = 0x02, IB_OPCODE_SEND_LAST_WITH_IMMEDIATE = 0x03, IB_OPCODE_SEND_ONLY = 0x04, IB_OPCODE_SEND_ONLY_WITH_IMMEDIATE = 0x05, IB_OPCODE_RDMA_WRITE_FIRST = 0x06, IB_OPCODE_RDMA_WRITE_MIDDLE = 0x07, IB_OPCODE_RDMA_WRITE_LAST = 0x08, IB_OPCODE_RDMA_WRITE_LAST_WITH_IMMEDIATE = 0x09, IB_OPCODE_RDMA_WRITE_ONLY = 0x0a, IB_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE = 0x0b, IB_OPCODE_RDMA_READ_REQUEST = 0x0c, IB_OPCODE_RDMA_READ_RESPONSE_FIRST = 0x0d, IB_OPCODE_RDMA_READ_RESPONSE_MIDDLE = 0x0e, IB_OPCODE_RDMA_READ_RESPONSE_LAST = 0x0f, IB_OPCODE_RDMA_READ_RESPONSE_ONLY = 0x10, IB_OPCODE_ACKNOWLEDGE = 0x11, IB_OPCODE_ATOMIC_ACKNOWLEDGE = 0x12, IB_OPCODE_COMPARE_SWAP = 0x13, IB_OPCODE_FETCH_ADD = 0x14, |
bf77cc34f ib_pack.h: Add op... |
83 84 85 |
/* opcode 0x15 is reserved */ IB_OPCODE_SEND_LAST_WITH_INVALIDATE = 0x16, IB_OPCODE_SEND_ONLY_WITH_INVALIDATE = 0x17, |
1da177e4c Linux-2.6.12-rc2 |
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
/* real constants follow -- see comment about above IB_OPCODE() macro for more details */ /* RC */ IB_OPCODE(RC, SEND_FIRST), IB_OPCODE(RC, SEND_MIDDLE), IB_OPCODE(RC, SEND_LAST), IB_OPCODE(RC, SEND_LAST_WITH_IMMEDIATE), IB_OPCODE(RC, SEND_ONLY), IB_OPCODE(RC, SEND_ONLY_WITH_IMMEDIATE), IB_OPCODE(RC, RDMA_WRITE_FIRST), IB_OPCODE(RC, RDMA_WRITE_MIDDLE), IB_OPCODE(RC, RDMA_WRITE_LAST), IB_OPCODE(RC, RDMA_WRITE_LAST_WITH_IMMEDIATE), IB_OPCODE(RC, RDMA_WRITE_ONLY), IB_OPCODE(RC, RDMA_WRITE_ONLY_WITH_IMMEDIATE), IB_OPCODE(RC, RDMA_READ_REQUEST), IB_OPCODE(RC, RDMA_READ_RESPONSE_FIRST), IB_OPCODE(RC, RDMA_READ_RESPONSE_MIDDLE), IB_OPCODE(RC, RDMA_READ_RESPONSE_LAST), IB_OPCODE(RC, RDMA_READ_RESPONSE_ONLY), IB_OPCODE(RC, ACKNOWLEDGE), IB_OPCODE(RC, ATOMIC_ACKNOWLEDGE), IB_OPCODE(RC, COMPARE_SWAP), IB_OPCODE(RC, FETCH_ADD), |
bf77cc34f ib_pack.h: Add op... |
112 113 |
IB_OPCODE(RC, SEND_LAST_WITH_INVALIDATE), IB_OPCODE(RC, SEND_ONLY_WITH_INVALIDATE), |
1da177e4c Linux-2.6.12-rc2 |
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
/* UC */ IB_OPCODE(UC, SEND_FIRST), IB_OPCODE(UC, SEND_MIDDLE), IB_OPCODE(UC, SEND_LAST), IB_OPCODE(UC, SEND_LAST_WITH_IMMEDIATE), IB_OPCODE(UC, SEND_ONLY), IB_OPCODE(UC, SEND_ONLY_WITH_IMMEDIATE), IB_OPCODE(UC, RDMA_WRITE_FIRST), IB_OPCODE(UC, RDMA_WRITE_MIDDLE), IB_OPCODE(UC, RDMA_WRITE_LAST), IB_OPCODE(UC, RDMA_WRITE_LAST_WITH_IMMEDIATE), IB_OPCODE(UC, RDMA_WRITE_ONLY), IB_OPCODE(UC, RDMA_WRITE_ONLY_WITH_IMMEDIATE), /* RD */ IB_OPCODE(RD, SEND_FIRST), IB_OPCODE(RD, SEND_MIDDLE), IB_OPCODE(RD, SEND_LAST), IB_OPCODE(RD, SEND_LAST_WITH_IMMEDIATE), IB_OPCODE(RD, SEND_ONLY), IB_OPCODE(RD, SEND_ONLY_WITH_IMMEDIATE), IB_OPCODE(RD, RDMA_WRITE_FIRST), IB_OPCODE(RD, RDMA_WRITE_MIDDLE), IB_OPCODE(RD, RDMA_WRITE_LAST), IB_OPCODE(RD, RDMA_WRITE_LAST_WITH_IMMEDIATE), IB_OPCODE(RD, RDMA_WRITE_ONLY), IB_OPCODE(RD, RDMA_WRITE_ONLY_WITH_IMMEDIATE), IB_OPCODE(RD, RDMA_READ_REQUEST), IB_OPCODE(RD, RDMA_READ_RESPONSE_FIRST), IB_OPCODE(RD, RDMA_READ_RESPONSE_MIDDLE), IB_OPCODE(RD, RDMA_READ_RESPONSE_LAST), IB_OPCODE(RD, RDMA_READ_RESPONSE_ONLY), IB_OPCODE(RD, ACKNOWLEDGE), IB_OPCODE(RD, ATOMIC_ACKNOWLEDGE), IB_OPCODE(RD, COMPARE_SWAP), IB_OPCODE(RD, FETCH_ADD), /* UD */ IB_OPCODE(UD, SEND_ONLY), IB_OPCODE(UD, SEND_ONLY_WITH_IMMEDIATE) }; enum { IB_LNH_RAW = 0, IB_LNH_IP = 1, IB_LNH_IBA_LOCAL = 2, IB_LNH_IBA_GLOBAL = 3 }; struct ib_unpacked_lrh { u8 virtual_lane; u8 link_version; u8 service_level; u8 link_next_header; __be16 destination_lid; __be16 packet_length; __be16 source_lid; }; struct ib_unpacked_grh { u8 ip_version; u8 traffic_class; __be32 flow_label; __be16 payload_length; u8 next_header; u8 hop_limit; union ib_gid source_gid; union ib_gid destination_gid; }; struct ib_unpacked_bth { u8 opcode; u8 solicited_event; u8 mig_req; u8 pad_count; u8 transport_header_version; __be16 pkey; __be32 destination_qpn; u8 ack_req; __be32 psn; }; struct ib_unpacked_deth { __be32 qkey; __be32 source_qpn; }; |
ff7f5aab3 IB/pack: IBoE UD ... |
201 202 203 204 205 206 207 |
struct ib_unpacked_eth { u8 dmac_h[4]; u8 dmac_l[2]; u8 smac_h[2]; u8 smac_l[4]; __be16 type; }; |
25f40220e IB/core: Initiali... |
208 209 210 211 212 213 214 215 216 |
struct ib_unpacked_ip4 { u8 ver; u8 hdr_len; u8 tos; __be16 tot_len; __be16 id; __be16 frag_off; u8 ttl; u8 protocol; |
3ef967a4a IB/mlx4: Enable s... |
217 |
__sum16 check; |
25f40220e IB/core: Initiali... |
218 219 220 221 222 223 224 225 226 227 |
__be32 saddr; __be32 daddr; }; struct ib_unpacked_udp { __be16 sport; __be16 dport; __be16 length; __be16 csum; }; |
af7bd4637 IB/core: Add VLAN... |
228 229 230 231 |
struct ib_unpacked_vlan { __be16 tag; __be16 type; }; |
1da177e4c Linux-2.6.12-rc2 |
232 |
struct ib_ud_header { |
ff7f5aab3 IB/pack: IBoE UD ... |
233 |
int lrh_present; |
1da177e4c Linux-2.6.12-rc2 |
234 |
struct ib_unpacked_lrh lrh; |
ff7f5aab3 IB/pack: IBoE UD ... |
235 236 |
int eth_present; struct ib_unpacked_eth eth; |
af7bd4637 IB/core: Add VLAN... |
237 238 |
int vlan_present; struct ib_unpacked_vlan vlan; |
ff7f5aab3 IB/pack: IBoE UD ... |
239 240 |
int grh_present; struct ib_unpacked_grh grh; |
25f40220e IB/core: Initiali... |
241 242 243 244 |
int ipv4_present; struct ib_unpacked_ip4 ip4; int udp_present; struct ib_unpacked_udp udp; |
ff7f5aab3 IB/pack: IBoE UD ... |
245 |
struct ib_unpacked_bth bth; |
1da177e4c Linux-2.6.12-rc2 |
246 |
struct ib_unpacked_deth deth; |
ff7f5aab3 IB/pack: IBoE UD ... |
247 248 |
int immediate_present; __be32 immediate_data; |
1da177e4c Linux-2.6.12-rc2 |
249 250 251 252 253 254 255 256 257 258 259 |
}; void ib_pack(const struct ib_field *desc, int desc_len, void *structure, void *buf); void ib_unpack(const struct ib_field *desc, int desc_len, void *buf, void *structure); |
3ef967a4a IB/mlx4: Enable s... |
260 |
__sum16 ib_ud_ip4_csum(struct ib_ud_header *header); |
25f40220e IB/core: Initiali... |
261 262 263 264 265 266 267 268 269 270 |
int ib_ud_header_init(int payload_bytes, int lrh_present, int eth_present, int vlan_present, int grh_present, int ip_version, int udp_present, int immediate_present, struct ib_ud_header *header); |
1da177e4c Linux-2.6.12-rc2 |
271 272 273 274 275 276 277 278 |
int ib_ud_header_pack(struct ib_ud_header *header, void *buf); int ib_ud_header_unpack(void *buf, struct ib_ud_header *header); #endif /* IB_PACK_H */ |