Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / include / ipxe / ib_mad.h
1 #ifndef _IPXE_IB_MAD_H
2 #define _IPXE_IB_MAD_H
3
4 /** @file
5  *
6  * Infiniband management datagrams
7  *
8  */
9
10 FILE_LICENCE ( GPL2_OR_LATER );
11
12 #include <stdint.h>
13 #include <ipxe/ib_packet.h>
14
15 /*****************************************************************************
16  *
17  * Subnet management MADs
18  *
19  *****************************************************************************
20  */
21
22 /** A subnet management header
23  *
24  * Defined in sections 14.2.1.1 and 14.2.1.2 of the IBA.
25  */
26 struct ib_smp_hdr {
27         uint64_t mkey;
28         uint16_t slid;
29         uint16_t dlid;
30         uint8_t reserved[28];
31 } __attribute__ (( packed ));
32
33 /** Subnet management class version */
34 #define IB_SMP_CLASS_VERSION                    1
35
36 /** Subnet management direction bit
37  *
38  * This bit resides in the "status" field in the MAD header.
39  */
40 #define IB_SMP_STATUS_D_INBOUND                 0x8000
41
42 /* Subnet management attributes */
43 #define IB_SMP_ATTR_NOTICE                      0x0002
44 #define IB_SMP_ATTR_NODE_DESC                   0x0010
45 #define IB_SMP_ATTR_NODE_INFO                   0x0011
46 #define IB_SMP_ATTR_SWITCH_INFO                 0x0012
47 #define IB_SMP_ATTR_GUID_INFO                   0x0014
48 #define IB_SMP_ATTR_PORT_INFO                   0x0015
49 #define IB_SMP_ATTR_PKEY_TABLE                  0x0016
50 #define IB_SMP_ATTR_SL_TO_VL_TABLE              0x0017
51 #define IB_SMP_ATTR_VL_ARB_TABLE                0x0018
52 #define IB_SMP_ATTR_LINEAR_FORWARD_TABLE        0x0019
53 #define IB_SMP_ATTR_RANDOM_FORWARD_TABLE        0x001A
54 #define IB_SMP_ATTR_MCAST_FORWARD_TABLE         0x001B
55 #define IB_SMP_ATTR_SM_INFO                     0x0020
56 #define IB_SMP_ATTR_VENDOR_DIAG                 0x0030
57 #define IB_SMP_ATTR_LED_INFO                    0x0031
58 #define IB_SMP_ATTR_VENDOR_MASK                 0xFF00
59
60 /**
61  * A Node Description attribute
62  *
63  * Defined in section 14.2.5.2 of the IBA
64  */
65 struct ib_node_desc {
66         char node_string[64];
67 } __attribute__ (( packed ));
68
69 /** A Node Information attribute
70  *
71  * Defined in section 14.2.5.3 of the IBA.
72  */
73 struct ib_node_info {
74         uint8_t base_version;
75         uint8_t class_version;
76         uint8_t node_type;
77         uint8_t num_ports;
78         union ib_guid sys_guid;
79         union ib_guid node_guid;
80         union ib_guid port_guid;
81         uint16_t partition_cap;
82         uint16_t device_id;
83         uint32_t revision;
84         uint8_t local_port_num;
85         uint8_t vendor_id[3];
86 } __attribute__ ((packed));
87
88 #define IB_NODE_TYPE_HCA                0x01
89 #define IB_NODE_TYPE_SWITCH             0x02
90 #define IB_NODE_TYPE_ROUTER             0x03
91
92 /** A GUID Information attribute
93  *
94  * Defined in section 14.2.5.5 of the IBA.
95  */
96 struct ib_guid_info {
97         uint8_t guid[8][8];
98 } __attribute__ (( packed ));
99
100 /** A Port Information attribute
101  *
102  * Defined in section 14.2.5.6 of the IBA.
103  */
104 struct ib_port_info {
105         uint64_t mkey;
106         uint8_t gid_prefix[8];
107         uint16_t lid;
108         uint16_t mastersm_lid;
109         uint32_t cap_mask;
110         uint16_t diag_code;
111         uint16_t mkey_lease_period;
112         uint8_t local_port_num;
113         uint8_t link_width_enabled;
114         uint8_t link_width_supported;
115         uint8_t link_width_active;
116         uint8_t link_speed_supported__port_state;
117         uint8_t port_phys_state__link_down_def_state;
118         uint8_t mkey_prot_bits__lmc;
119         uint8_t link_speed_active__link_speed_enabled;
120         uint8_t neighbour_mtu__mastersm_sl;
121         uint8_t vl_cap__init_type;
122         uint8_t vl_high_limit;
123         uint8_t vl_arbitration_high_cap;
124         uint8_t vl_arbitration_low_cap;
125         uint8_t init_type_reply__mtu_cap;
126         uint8_t vl_stall_count__hoq_life;
127         uint8_t operational_vls__enforcement;
128         uint16_t mkey_violations;
129         uint16_t pkey_violations;
130         uint16_t qkey_violations;
131         uint8_t guid_cap;
132         uint8_t client_reregister__subnet_timeout;
133         uint8_t resp_time_value;
134         uint8_t local_phy_errors__overrun_errors;
135         uint16_t max_credit_hint;
136         uint32_t link_round_trip_latency;
137 } __attribute__ (( packed ));
138
139 #define IB_LINK_WIDTH_1X                0x01
140 #define IB_LINK_WIDTH_4X                0x02
141 #define IB_LINK_WIDTH_8X                0x04
142 #define IB_LINK_WIDTH_12X               0x08
143
144 #define IB_LINK_SPEED_SDR               0x01
145 #define IB_LINK_SPEED_DDR               0x02
146 #define IB_LINK_SPEED_QDR               0x04
147
148 #define IB_PORT_STATE_DOWN              0x01
149 #define IB_PORT_STATE_INIT              0x02
150 #define IB_PORT_STATE_ARMED             0x03
151 #define IB_PORT_STATE_ACTIVE            0x04
152
153 #define IB_PORT_PHYS_STATE_SLEEP        0x01
154 #define IB_PORT_PHYS_STATE_POLLING      0x02
155
156 #define IB_MTU_256                      0x01
157 #define IB_MTU_512                      0x02
158 #define IB_MTU_1024                     0x03
159 #define IB_MTU_2048                     0x04
160 #define IB_MTU_4096                     0x05
161
162 #define IB_VL_0                         0x01
163 #define IB_VL_0_1                       0x02
164 #define IB_VL_0_3                       0x03
165 #define IB_VL_0_7                       0x04
166 #define IB_VL_0_14                      0x05
167
168 /** A Partition Key Table attribute
169  *
170  * Defined in section 14.2.5.7 of the IBA.
171  */
172 struct ib_pkey_table {
173         uint16_t pkey[32];
174 } __attribute__ (( packed ));
175
176 /** A subnet management attribute */
177 union ib_smp_data {
178         struct ib_node_desc node_desc;
179         struct ib_node_info node_info;
180         struct ib_guid_info guid_info;
181         struct ib_port_info port_info;
182         struct ib_pkey_table pkey_table;
183         uint8_t bytes[64];
184 } __attribute__ (( packed ));
185
186 /** A subnet management directed route path */
187 struct ib_smp_dr_path {
188         uint8_t hops[64];
189 } __attribute__ (( packed ));
190
191 /** Subnet management MAD class-specific data */
192 struct ib_smp_class_specific {
193         uint8_t hop_pointer;
194         uint8_t hop_count;
195 } __attribute__ (( packed ));
196
197 /*****************************************************************************
198  *
199  * Subnet administration MADs
200  *
201  *****************************************************************************
202  */
203
204 #define IB_SA_CLASS_VERSION                     2
205
206 #define IB_SA_METHOD_DELETE_RESP                0x95
207
208 struct ib_rmpp_hdr {
209         uint32_t raw[3];
210 } __attribute__ (( packed ));
211
212 struct ib_sa_hdr {
213         uint32_t sm_key[2];
214         uint16_t reserved;
215         uint16_t attrib_offset;
216         uint32_t comp_mask[2];
217 } __attribute__ (( packed ));
218
219 #define IB_SA_ATTR_MC_MEMBER_REC                0x38
220 #define IB_SA_ATTR_PATH_REC                     0x35
221
222 struct ib_path_record {
223         uint32_t reserved0[2];
224         union ib_gid dgid;
225         union ib_gid sgid;
226         uint16_t dlid;
227         uint16_t slid;
228         uint32_t hop_limit__flow_label__raw_traffic;
229         uint32_t pkey__numb_path__reversible__tclass;
230         uint8_t reserved1;
231         uint8_t reserved__sl;
232         uint8_t mtu_selector__mtu;
233         uint8_t rate_selector__rate;
234         uint32_t preference__packet_lifetime__packet_lifetime_selector;
235         uint32_t reserved2[35];
236 } __attribute__ (( packed ));
237
238 #define IB_SA_PATH_REC_DGID                     (1<<2)
239 #define IB_SA_PATH_REC_SGID                     (1<<3)
240
241 struct ib_mc_member_record {
242         union ib_gid mgid;
243         union ib_gid port_gid;
244         uint32_t qkey;
245         uint16_t mlid;
246         uint8_t mtu_selector__mtu;
247         uint8_t tclass;
248         uint16_t pkey;
249         uint8_t rate_selector__rate;
250         uint8_t packet_lifetime_selector__packet_lifetime;
251         uint32_t sl__flow_label__hop_limit;
252         uint8_t scope__join_state;
253         uint8_t proxy_join__reserved;
254         uint16_t reserved0;
255         uint32_t reserved1[37];
256 } __attribute__ (( packed ));
257
258 #define IB_SA_MCMEMBER_REC_MGID                 (1<<0)
259 #define IB_SA_MCMEMBER_REC_PORT_GID             (1<<1)
260 #define IB_SA_MCMEMBER_REC_QKEY                 (1<<2)
261 #define IB_SA_MCMEMBER_REC_MLID                 (1<<3)
262 #define IB_SA_MCMEMBER_REC_MTU_SELECTOR         (1<<4)
263 #define IB_SA_MCMEMBER_REC_MTU                  (1<<5)
264 #define IB_SA_MCMEMBER_REC_TRAFFIC_CLASS        (1<<6)
265 #define IB_SA_MCMEMBER_REC_PKEY                 (1<<7)
266 #define IB_SA_MCMEMBER_REC_RATE_SELECTOR        (1<<8)
267 #define IB_SA_MCMEMBER_REC_RATE                 (1<<9)
268 #define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME_SELECTOR    (1<<10)
269 #define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME     (1<<11)
270 #define IB_SA_MCMEMBER_REC_SL                   (1<<12)
271 #define IB_SA_MCMEMBER_REC_FLOW_LABEL           (1<<13)
272 #define IB_SA_MCMEMBER_REC_HOP_LIMIT            (1<<14)
273 #define IB_SA_MCMEMBER_REC_SCOPE                (1<<15)
274 #define IB_SA_MCMEMBER_REC_JOIN_STATE           (1<<16)
275 #define IB_SA_MCMEMBER_REC_PROXY_JOIN           (1<<17)
276
277 union ib_sa_data {
278         struct ib_path_record path_record;
279         struct ib_mc_member_record mc_member_record;
280 } __attribute__ (( packed ));
281
282 /*****************************************************************************
283  *
284  * Communication management MADs
285  *
286  *****************************************************************************
287  */
288
289 /** Communication management class version */
290 #define IB_CM_CLASS_VERSION                     2
291
292 /* Communication management attributes */
293 #define IB_CM_ATTR_CLASS_PORT_INFO              0x0001
294 #define IB_CM_ATTR_CONNECT_REQUEST              0x0010
295 #define IB_CM_ATTR_MSG_RCPT_ACK                 0x0011
296 #define IB_CM_ATTR_CONNECT_REJECT               0x0012
297 #define IB_CM_ATTR_CONNECT_REPLY                0x0013
298 #define IB_CM_ATTR_READY_TO_USE                 0x0014
299 #define IB_CM_ATTR_DISCONNECT_REQUEST           0x0015
300 #define IB_CM_ATTR_DISCONNECT_REPLY             0x0016
301 #define IB_CM_ATTR_SERVICE_ID_RES_REQ           0x0016
302 #define IB_CM_ATTR_SERVICE_ID_RES_REQ_RESP      0x0018
303 #define IB_CM_ATTR_LOAD_ALTERNATE_PATH          0x0019
304 #define IB_CM_ATTR_ALTERNATE_PATH_RESPONSE      0x001a
305
306 /** Communication management common fields */
307 struct ib_cm_common {
308         /** Local communication ID */
309         uint32_t local_id;
310         /** Remote communication ID */
311         uint32_t remote_id;
312         /** Reserved */
313         uint8_t reserved[224];
314 } __attribute__ (( packed ));
315
316 /** A communication management path */
317 struct ib_cm_path {
318         /** Local port LID */
319         uint16_t local_lid;
320         /** Remote port LID */
321         uint16_t remote_lid;
322         /** Local port GID */
323         union ib_gid local_gid;
324         /** Remote port GID */
325         union ib_gid remote_gid;
326         /** Flow label and rate */
327         uint32_t flow_label__rate;
328         /** Traffic class */
329         uint8_t tc;
330         /** Hop limit */
331         uint8_t hop_limit;
332         /** SL and subnet local*/
333         uint8_t sl__subnet_local;
334         /** Local ACK timeout */
335         uint8_t local_ack_timeout;
336 } __attribute__ (( packed ));
337
338 /** A communication management connection request
339  *
340  * Defined in section 12.6.5 of the IBA.
341  */
342 struct ib_cm_connect_request {
343         /** Local communication ID */
344         uint32_t local_id;
345         /** Reserved */
346         uint32_t reserved0[1];
347         /** Service ID */
348         union ib_guid service_id;
349         /** Local CA GUID */
350         union ib_guid local_ca;
351         /** Reserved */
352         uint32_t reserved1[1];
353         /** Local queue key */
354         uint32_t local_qkey;
355         /** Local QPN and responder resources*/
356         uint32_t local_qpn__responder_resources;
357         /** Local EECN and initiator depth */
358         uint32_t local_eecn__initiator_depth;
359         /** Remote EECN, remote CM response timeout, transport service
360          * type, EE flow control
361          */
362         uint32_t remote_eecn__remote_timeout__service_type__ee_flow_ctrl;
363         /** Starting PSN, local CM response timeout and retry count */
364         uint32_t starting_psn__local_timeout__retry_count;
365         /** Partition key */
366         uint16_t pkey;
367         /** Path packet payload MTU, RDC exists, RNR retry count */
368         uint8_t payload_mtu__rdc_exists__rnr_retry;
369         /** Max CM retries and SRQ */
370         uint8_t max_cm_retries__srq;
371         /** Primary path */
372         struct ib_cm_path primary;
373         /** Alternate path */
374         struct ib_cm_path alternate;
375         /** Private data */
376         uint8_t private_data[92];
377 } __attribute__ (( packed ));
378
379 /** CM transport types */
380 #define IB_CM_TRANSPORT_RC              0
381 #define IB_CM_TRANSPORT_UC              1
382 #define IB_CM_TRANSPORT_RD              2
383
384 /** A communication management connection rejection
385  *
386  * Defined in section 12.6.7 of the IBA.
387  */
388 struct ib_cm_connect_reject {
389         /** Local communication ID */
390         uint32_t local_id;
391         /** Remote communication ID */
392         uint32_t remote_id;
393         /** Message rejected */
394         uint8_t message;
395         /** Reject information length */
396         uint8_t info_len;
397         /** Rejection reason */
398         uint16_t reason;
399         /** Additional rejection information */
400         uint8_t info[72];
401         /** Private data */
402         uint8_t private_data[148];
403 } __attribute__ (( packed ));
404
405 /** CM rejection reasons */
406 #define IB_CM_REJECT_BAD_SERVICE_ID     8
407 #define IB_CM_REJECT_STALE_CONN         10
408 #define IB_CM_REJECT_CONSUMER           28
409
410 /** A communication management connection reply
411  *
412  * Defined in section 12.6.8 of the IBA.
413  */
414 struct ib_cm_connect_reply {
415         /** Local communication ID */
416         uint32_t local_id;
417         /** Remote communication ID */
418         uint32_t remote_id;
419         /** Local queue key */
420         uint32_t local_qkey;
421         /** Local QPN */
422         uint32_t local_qpn;
423         /** Local EECN */
424         uint32_t local_eecn;
425         /** Starting PSN */
426         uint32_t starting_psn;
427         /** Responder resources */
428         uint8_t responder_resources;
429         /** Initiator depth */
430         uint8_t initiator_depth;
431         /** Target ACK delay, failover accepted, and end-to-end flow control */
432         uint8_t target_ack_delay__failover_accepted__ee_flow_ctrl;
433         /** RNR retry count, SRQ */
434         uint8_t rnr_retry__srq;
435         /** Local CA GUID */
436         union ib_guid local_ca;
437         /** Private data */
438         uint8_t private_data[196];
439 } __attribute__ (( packed ));
440
441 /** A communication management ready to use reply
442  *
443  * Defined in section 12.6.9 of the IBA.
444  */
445 struct ib_cm_ready_to_use {
446         /** Local communication ID */
447         uint32_t local_id;
448         /** Remote communication ID */
449         uint32_t remote_id;
450         /** Private data */
451         uint8_t private_data[224];
452 } __attribute__ (( packed ));
453
454 /** A communication management disconnection request
455  *
456  * Defined in section 12.6.10 of the IBA.
457  */
458 struct ib_cm_disconnect_request {
459         /** Local communication ID */
460         uint32_t local_id;
461         /** Remote communication ID */
462         uint32_t remote_id;
463         /** Remote QPN/EECN */
464         uint32_t remote_qpn_eecn;
465         /** Private data */
466         uint8_t private_data[220];
467 } __attribute__ (( packed ));
468
469 /** A communication management disconnection reply
470  *
471  * Defined in section 12.6.11 of the IBA.
472  */
473 struct ib_cm_disconnect_reply {
474         /** Local communication ID */
475         uint32_t local_id;
476         /** Remote communication ID */
477         uint32_t remote_id;
478         /** Private data */
479         uint8_t private_data[224];
480 } __attribute__ (( packed ));
481
482 /** A communication management attribute */
483 union ib_cm_data {
484         struct ib_cm_common common;
485         struct ib_cm_connect_request connect_request;
486         struct ib_cm_connect_reject connect_reject;
487         struct ib_cm_connect_reply connect_reply;
488         struct ib_cm_ready_to_use ready_to_use;
489         struct ib_cm_disconnect_request disconnect_request;
490         struct ib_cm_disconnect_reply disconnect_reply;
491         uint8_t bytes[232];
492 } __attribute__ (( packed ));
493
494 /*****************************************************************************
495  *
496  * MADs
497  *
498  *****************************************************************************
499  */
500
501 /** Management datagram class_specific data */
502 union ib_mad_class_specific {
503         uint16_t raw;
504         struct ib_smp_class_specific smp;
505 } __attribute__ (( packed ));
506
507 /** A management datagram common header
508  *
509  * Defined in section 13.4.2 of the IBA.
510  */
511 struct ib_mad_hdr {
512         uint8_t base_version;
513         uint8_t mgmt_class;
514         uint8_t class_version;
515         uint8_t method;
516         uint16_t status;
517         union ib_mad_class_specific class_specific;
518         uint32_t tid[2];
519         uint16_t attr_id;
520         uint8_t reserved[2];
521         uint32_t attr_mod;
522 } __attribute__ (( packed ));
523
524 /* Management base version */
525 #define IB_MGMT_BASE_VERSION                    1
526
527 /* Management classes */
528 #define IB_MGMT_CLASS_SUBN_LID_ROUTED           0x01
529 #define IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE       0x81
530 #define IB_MGMT_CLASS_SUBN_ADM                  0x03
531 #define IB_MGMT_CLASS_PERF_MGMT                 0x04
532 #define IB_MGMT_CLASS_BM                        0x05
533 #define IB_MGMT_CLASS_DEVICE_MGMT               0x06
534 #define IB_MGMT_CLASS_CM                        0x07
535 #define IB_MGMT_CLASS_SNMP                      0x08
536 #define IB_MGMT_CLASS_VENDOR_RANGE2_START       0x30
537 #define IB_MGMT_CLASS_VENDOR_RANGE2_END         0x4f
538
539 #define IB_MGMT_CLASS_MASK                      0x7f
540
541 /* Management methods */
542 #define IB_MGMT_METHOD_GET                      0x01
543 #define IB_MGMT_METHOD_SET                      0x02
544 #define IB_MGMT_METHOD_GET_RESP                 0x81
545 #define IB_MGMT_METHOD_SEND                     0x03
546 #define IB_MGMT_METHOD_TRAP                     0x05
547 #define IB_MGMT_METHOD_REPORT                   0x06
548 #define IB_MGMT_METHOD_REPORT_RESP              0x86
549 #define IB_MGMT_METHOD_TRAP_REPRESS             0x07
550 #define IB_MGMT_METHOD_DELETE                   0x15
551
552 /* Status codes */
553 #define IB_MGMT_STATUS_OK                       0x0000
554 #define IB_MGMT_STATUS_BAD_VERSION              0x0001
555 #define IB_MGMT_STATUS_UNSUPPORTED_METHOD       0x0002
556 #define IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR  0x0003
557 #define IB_MGMT_STATUS_INVALID_VALUE            0x0004
558
559 /** A subnet management MAD */
560 struct ib_mad_smp {
561         struct ib_mad_hdr mad_hdr;
562         struct ib_smp_hdr smp_hdr;
563         union ib_smp_data smp_data;
564         struct ib_smp_dr_path initial_path;
565         struct ib_smp_dr_path return_path;
566 } __attribute__ (( packed ));
567
568 /** A subnet administration MAD */
569 struct ib_mad_sa {
570         struct ib_mad_hdr mad_hdr;
571         struct ib_rmpp_hdr rmpp_hdr;
572         struct ib_sa_hdr sa_hdr;
573         union ib_sa_data sa_data;
574 } __attribute__ (( packed ));
575
576 /** A communication management MAD */
577 struct ib_mad_cm {
578         struct ib_mad_hdr mad_hdr;
579         union ib_cm_data cm_data;
580 } __attribute__ (( packed ));
581
582 /** A management datagram */
583 union ib_mad {
584         struct ib_mad_hdr hdr;
585         struct ib_mad_smp smp;
586         struct ib_mad_sa sa;
587         struct ib_mad_cm cm;
588         uint8_t bytes[256];
589 } __attribute__ (( packed ));
590
591 #endif /* _IPXE_IB_MAD_H */