~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/ipxe/src/include/ipxe/ib_packet.h

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

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