Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / include / ipxe / ib_packet.h
1 #ifndef _IPXE_IB_PACKET_H
2 #define _IPXE_IB_PACKET_H
3
4 /** @file
5  *
6  * Infiniband packet format
7  *
8  */
9
10 FILE_LICENCE ( GPL2_OR_LATER );
11
12 struct ib_device;
13 struct ib_queue_pair;
14 struct ib_address_vector;
15 struct io_buffer;
16
17 /** An Infiniband Globally Unique Identifier */
18 union ib_guid {
19         uint8_t bytes[8];
20         uint16_t words[4];
21         uint32_t dwords[2];
22 };
23
24 /** Infiniband Globally Unique Identifier debug message format */
25 #define IB_GUID_FMT "%08x:%08x"
26
27 /** Infiniband Globally Unique Identifier debug message arguments */
28 #define IB_GUID_ARGS( guid ) \
29         ntohl ( (guid)->dwords[0] ), ntohl ( (guid)->dwords[1] )
30
31 /** An Infiniband Global Identifier */
32 union ib_gid {
33         uint8_t bytes[16];
34         uint16_t words[8];
35         uint32_t dwords[4];
36         struct {
37                 union ib_guid prefix;
38                 union ib_guid guid;
39         } s;
40 };
41
42 /** Infiniband Global Identifier debug message format */
43 #define IB_GID_FMT IB_GUID_FMT ":" IB_GUID_FMT
44
45 /** Infiniband Global Identifier debug message arguments */
46 #define IB_GID_ARGS( gid ) \
47         IB_GUID_ARGS ( &(gid)->s.prefix ), IB_GUID_ARGS ( &(gid)->s.guid )
48
49 /** An Infiniband Local Route Header */
50 struct ib_local_route_header {
51         /** Virtual lane and link version */
52         uint8_t vl__lver;
53         /** Service level and next link header */
54         uint8_t sl__lnh;
55         /** Destination LID */
56         uint16_t dlid;
57         /** Packet length */
58         uint16_t length;
59         /** Source LID */
60         uint16_t slid;
61 } __attribute__ (( packed ));
62
63 /** Infiniband virtual lanes */
64 enum ib_vl {
65         IB_VL_DEFAULT = 0,
66         IB_VL_SMP = 15,
67 };
68
69 /** An Infiniband Link Next Header value */
70 enum ib_lnh {
71         IB_LNH_RAW = 0,
72         IB_LNH_IPv6 = 1,
73         IB_LNH_BTH = 2,
74         IB_LNH_GRH = 3
75 };
76
77 /** Default Infiniband LID */
78 #define IB_LID_NONE 0xffff
79
80 /** Test for multicast LID */
81 #define IB_LID_MULTICAST( lid ) ( ( (lid) >= 0xc000 ) && ( (lid) <= 0xfffe ) )
82
83 /** An Infiniband Global Route Header */
84 struct ib_global_route_header {
85         /** IP version, traffic class, and flow label
86          *
87          *  4 bits : Version of the GRH
88          *  8 bits : Traffic class
89          * 20 bits : Flow label
90          */
91         uint32_t ipver__tclass__flowlabel;
92         /** Payload length */
93         uint16_t paylen;
94         /** Next header */
95         uint8_t nxthdr;
96         /** Hop limit */
97         uint8_t hoplmt;
98         /** Source GID */
99         union ib_gid sgid;
100         /** Destiniation GID */
101         union ib_gid dgid;
102 } __attribute__ (( packed ));
103
104 #define IB_GRH_IPVER_IPv6 0x06
105 #define IB_GRH_NXTHDR_IBA 0x1b
106
107 /** An Infiniband Base Transport Header */
108 struct ib_base_transport_header {
109         /** Opcode */
110         uint8_t opcode;
111         /** Transport header version, pad count, migration and solicitation */
112         uint8_t se__m__padcnt__tver;
113         /** Partition key */
114         uint16_t pkey;
115         /** Destination queue pair */
116         uint32_t dest_qp;
117         /** Packet sequence number and acknowledge request */
118         uint32_t ack__psn;
119 } __attribute__ (( packed ));
120
121 /** An Infiniband BTH opcode */
122 enum ib_bth_opcode {
123         BTH_OPCODE_UD_SEND = 0x64,
124 };
125
126 /** An Infiniband Datagram Extended Transport Header */
127 struct ib_datagram_extended_transport_header {
128         /** Queue key */
129         uint32_t qkey;
130         /** Source queue pair */
131         uint32_t src_qp;
132 } __attribute__ (( packed ));
133
134 /** All known IB header formats */
135 union ib_headers {
136         struct ib_local_route_header lrh;
137         struct {
138                 struct ib_local_route_header lrh;
139                 struct ib_global_route_header grh;
140                 struct ib_base_transport_header bth;
141                 struct ib_datagram_extended_transport_header deth;
142         } __attribute__ (( packed )) lrh__grh__bth__deth;
143         struct {
144                 struct ib_local_route_header lrh;
145                 struct ib_base_transport_header bth;
146                 struct ib_datagram_extended_transport_header deth;
147         } __attribute__ (( packed )) lrh__bth__deth;
148 } __attribute__ (( packed ));
149
150 /** Maximum size required for IB headers */
151 #define IB_MAX_HEADER_SIZE sizeof ( union ib_headers )
152
153 extern int ib_push ( struct ib_device *ibdev, struct io_buffer *iobuf,
154                      struct ib_queue_pair *qp, size_t payload_len,
155                      const struct ib_address_vector *dest );
156 extern int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
157                      struct ib_queue_pair **qp, size_t *payload_len,
158                      struct ib_address_vector *dest,
159                      struct ib_address_vector *source );
160
161 #endif /* _IPXE_IB_PACKET_H */