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