[contrib] Allow Network Protocol header to display in rom-o-matic
[gpxe.git] / src / include / gpxe / ib_packet.h
blobd46885969a79666b3520f6ab816d83e623358fe9
1 #ifndef _GPXE_IB_PACKET_H
2 #define _GPXE_IB_PACKET_H
4 /** @file
6 * Infiniband packet format
8 */
10 FILE_LICENCE ( GPL2_OR_LATER );
12 struct ib_device;
13 struct ib_queue_pair;
14 struct ib_address_vector;
15 struct io_buffer;
17 /** Half of an Infiniband Global Identifier */
18 struct ib_gid_half {
19 union {
20 uint8_t bytes[8];
21 uint16_t words[4];
22 uint32_t dwords[2];
23 } u;
26 /** An Infiniband Global Identifier */
27 struct ib_gid {
28 union {
29 uint8_t bytes[16];
30 uint16_t words[8];
31 uint32_t dwords[4];
32 struct ib_gid_half half[2];
33 } u;
36 /** An Infiniband Local Route Header */
37 struct ib_local_route_header {
38 /** Virtual lane and link version */
39 uint8_t vl__lver;
40 /** Service level and next link header */
41 uint8_t sl__lnh;
42 /** Destination LID */
43 uint16_t dlid;
44 /** Packet length */
45 uint16_t length;
46 /** Source LID */
47 uint16_t slid;
48 } __attribute__ (( packed ));
50 /** Infiniband virtual lanes */
51 enum ib_vl {
52 IB_VL_DEFAULT = 0,
53 IB_VL_SMP = 15,
56 /** An Infiniband Link Next Header value */
57 enum ib_lnh {
58 IB_LNH_RAW = 0,
59 IB_LNH_IPv6 = 1,
60 IB_LNH_BTH = 2,
61 IB_LNH_GRH = 3
64 /** Default Infiniband LID */
65 #define IB_LID_NONE 0xffff
67 /** Test for multicast LID */
68 #define IB_LID_MULTICAST( lid ) ( ( (lid) >= 0xc000 ) && ( (lid) <= 0xfffe ) )
70 /** An Infiniband Global Route Header */
71 struct ib_global_route_header {
72 /** IP version, traffic class, and flow label
74 * 4 bits : Version of the GRH
75 * 8 bits : Traffic class
76 * 20 bits : Flow label
78 uint32_t ipver__tclass__flowlabel;
79 /** Payload length */
80 uint16_t paylen;
81 /** Next header */
82 uint8_t nxthdr;
83 /** Hop limit */
84 uint8_t hoplmt;
85 /** Source GID */
86 struct ib_gid sgid;
87 /** Destiniation GID */
88 struct ib_gid dgid;
89 } __attribute__ (( packed ));
91 #define IB_GRH_IPVER_IPv6 0x06
92 #define IB_GRH_NXTHDR_IBA 0x1b
94 /** An Infiniband Base Transport Header */
95 struct ib_base_transport_header {
96 /** Opcode */
97 uint8_t opcode;
98 /** Transport header version, pad count, migration and solicitation */
99 uint8_t se__m__padcnt__tver;
100 /** Partition key */
101 uint16_t pkey;
102 /** Destination queue pair */
103 uint32_t dest_qp;
104 /** Packet sequence number and acknowledge request */
105 uint32_t ack__psn;
106 } __attribute__ (( packed ));
108 /** An Infiniband BTH opcode */
109 enum ib_bth_opcode {
110 BTH_OPCODE_UD_SEND = 0x64,
113 /** An Infiniband Datagram Extended Transport Header */
114 struct ib_datagram_extended_transport_header {
115 /** Queue key */
116 uint32_t qkey;
117 /** Source queue pair */
118 uint32_t src_qp;
119 } __attribute__ (( packed ));
121 /** All known IB header formats */
122 union ib_headers {
123 struct ib_local_route_header lrh;
124 struct {
125 struct ib_local_route_header lrh;
126 struct ib_global_route_header grh;
127 struct ib_base_transport_header bth;
128 struct ib_datagram_extended_transport_header deth;
129 } __attribute__ (( packed )) lrh__grh__bth__deth;
130 struct {
131 struct ib_local_route_header lrh;
132 struct ib_base_transport_header bth;
133 struct ib_datagram_extended_transport_header deth;
134 } __attribute__ (( packed )) lrh__bth__deth;
135 } __attribute__ (( packed ));
137 /** Maximum size required for IB headers */
138 #define IB_MAX_HEADER_SIZE sizeof ( union ib_headers )
140 extern int ib_push ( struct ib_device *ibdev, struct io_buffer *iobuf,
141 struct ib_queue_pair *qp, size_t payload_len,
142 const struct ib_address_vector *av );
143 extern int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
144 struct ib_queue_pair **qp, size_t *payload_len,
145 struct ib_address_vector *av );
147 #endif /* _GPXE_IB_PACKET_H */