[infiniband] Use correct transaction identifier in CM responses
[ipxe.git] / 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_OR_UBDL );
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 #define IB_LINK_SPEED_FDR10 0x08
148 #define IB_LINK_SPEED_FDR 0x10
149 #define IB_LINK_SPEED_EDR 0x20
150
151 #define IB_PORT_STATE_DOWN 0x01
152 #define IB_PORT_STATE_INIT 0x02
153 #define IB_PORT_STATE_ARMED 0x03
154 #define IB_PORT_STATE_ACTIVE 0x04
155
156 #define IB_PORT_PHYS_STATE_SLEEP 0x01
157 #define IB_PORT_PHYS_STATE_POLLING 0x02
158
159 #define IB_MTU_256 0x01
160 #define IB_MTU_512 0x02
161 #define IB_MTU_1024 0x03
162 #define IB_MTU_2048 0x04
163 #define IB_MTU_4096 0x05
164
165 #define IB_VL_0 0x01
166 #define IB_VL_0_1 0x02
167 #define IB_VL_0_3 0x03
168 #define IB_VL_0_7 0x04
169 #define IB_VL_0_14 0x05
170
171 /** A Partition Key Table attribute
172 *
173 * Defined in section 14.2.5.7 of the IBA.
174 */
175 struct ib_pkey_table {
176 uint16_t pkey[32];
177 } __attribute__ (( packed ));
178
179 /** A subnet management attribute */
180 union ib_smp_data {
181 struct ib_node_desc node_desc;
182 struct ib_node_info node_info;
183 struct ib_guid_info guid_info;
184 struct ib_port_info port_info;
185 struct ib_pkey_table pkey_table;
186 uint8_t bytes[64];
187 } __attribute__ (( packed ));
188
189 /** A subnet management directed route path */
190 struct ib_smp_dr_path {
191 uint8_t hops[64];
192 } __attribute__ (( packed ));
193
194 /** Subnet management MAD class-specific data */
195 struct ib_smp_class_specific {
196 uint8_t hop_pointer;
197 uint8_t hop_count;
198 } __attribute__ (( packed ));
199
200 /*****************************************************************************
201 *
202 * Subnet administration MADs
203 *
204 *****************************************************************************
205 */
206
207 #define IB_SA_CLASS_VERSION 2
208
209 #define IB_SA_METHOD_DELETE_RESP 0x95
210
211 struct ib_rmpp_hdr {
212 uint32_t raw[3];
213 } __attribute__ (( packed ));
214
215 struct ib_sa_hdr {
216 uint32_t sm_key[2];
217 uint16_t reserved;
218 uint16_t attrib_offset;
219 uint32_t comp_mask[2];
220 } __attribute__ (( packed ));
221
222 #define IB_SA_ATTR_SERVICE_REC 0x31
223 #define IB_SA_ATTR_PATH_REC 0x35
224 #define IB_SA_ATTR_MC_MEMBER_REC 0x38
225
226 struct ib_service_record {
227 uint64_t id;
228 union ib_gid gid;
229 uint16_t pkey;
230 uint16_t reserved;
231 uint32_t lease;
232 uint8_t key[16];
233 char name[64];
234 uint8_t data8[16];
235 uint16_t data16[8];
236 uint32_t data32[4];
237 uint64_t data64[2];
238 } __attribute__ (( packed ));
239
240 #define IB_SA_SERVICE_REC_NAME (1<<6)
241
242 struct ib_path_record {
243 uint32_t reserved0[2];
244 union ib_gid dgid;
245 union ib_gid sgid;
246 uint16_t dlid;
247 uint16_t slid;
248 uint32_t hop_limit__flow_label__raw_traffic;
249 uint32_t pkey__numb_path__reversible__tclass;
250 uint8_t reserved1;
251 uint8_t reserved__sl;
252 uint8_t mtu_selector__mtu;
253 uint8_t rate_selector__rate;
254 uint32_t preference__packet_lifetime__packet_lifetime_selector;
255 uint32_t reserved2[35];
256 } __attribute__ (( packed ));
257
258 #define IB_SA_PATH_REC_DGID (1<<2)
259 #define IB_SA_PATH_REC_SGID (1<<3)
260
261 struct ib_mc_member_record {
262 union ib_gid mgid;
263 union ib_gid port_gid;
264 uint32_t qkey;
265 uint16_t mlid;
266 uint8_t mtu_selector__mtu;
267 uint8_t tclass;
268 uint16_t pkey;
269 uint8_t rate_selector__rate;
270 uint8_t packet_lifetime_selector__packet_lifetime;
271 uint32_t sl__flow_label__hop_limit;
272 uint8_t scope__join_state;
273 uint8_t proxy_join__reserved;
274 uint16_t reserved0;
275 uint32_t reserved1[37];
276 } __attribute__ (( packed ));
277
278 #define IB_SA_MCMEMBER_REC_MGID (1<<0)
279 #define IB_SA_MCMEMBER_REC_PORT_GID (1<<1)
280 #define IB_SA_MCMEMBER_REC_QKEY (1<<2)
281 #define IB_SA_MCMEMBER_REC_MLID (1<<3)
282 #define IB_SA_MCMEMBER_REC_MTU_SELECTOR (1<<4)
283 #define IB_SA_MCMEMBER_REC_MTU (1<<5)
284 #define IB_SA_MCMEMBER_REC_TRAFFIC_CLASS (1<<6)
285 #define IB_SA_MCMEMBER_REC_PKEY (1<<7)
286 #define IB_SA_MCMEMBER_REC_RATE_SELECTOR (1<<8)
287 #define IB_SA_MCMEMBER_REC_RATE (1<<9)
288 #define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME_SELECTOR (1<<10)
289 #define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME (1<<11)
290 #define IB_SA_MCMEMBER_REC_SL (1<<12)
291 #define IB_SA_MCMEMBER_REC_FLOW_LABEL (1<<13)
292 #define IB_SA_MCMEMBER_REC_HOP_LIMIT (1<<14)
293 #define IB_SA_MCMEMBER_REC_SCOPE (1<<15)
294 #define IB_SA_MCMEMBER_REC_JOIN_STATE (1<<16)
295 #define IB_SA_MCMEMBER_REC_PROXY_JOIN (1<<17)
296
297 union ib_sa_data {
298 struct ib_service_record service_record;
299 struct ib_path_record path_record;
300 struct ib_mc_member_record mc_member_record;
301 } __attribute__ (( packed ));
302
303 /*****************************************************************************
304 *
305 * Communication management MADs
306 *
307 *****************************************************************************
308 */
309
310 /** Communication management class version */
311 #define IB_CM_CLASS_VERSION 2
312
313 /* Communication management attributes */
314 #define IB_CM_ATTR_CLASS_PORT_INFO 0x0001
315 #define IB_CM_ATTR_CONNECT_REQUEST 0x0010
316 #define IB_CM_ATTR_MSG_RCPT_ACK 0x0011
317 #define IB_CM_ATTR_CONNECT_REJECT 0x0012
318 #define IB_CM_ATTR_CONNECT_REPLY 0x0013
319 #define IB_CM_ATTR_READY_TO_USE 0x0014
320 #define IB_CM_ATTR_DISCONNECT_REQUEST 0x0015
321 #define IB_CM_ATTR_DISCONNECT_REPLY 0x0016
322 #define IB_CM_ATTR_SERVICE_ID_RES_REQ 0x0016
323 #define IB_CM_ATTR_SERVICE_ID_RES_REQ_RESP 0x0018
324 #define IB_CM_ATTR_LOAD_ALTERNATE_PATH 0x0019
325 #define IB_CM_ATTR_ALTERNATE_PATH_RESPONSE 0x001a
326
327 /** Communication management common fields */
328 struct ib_cm_common {
329 /** Local communication ID */
330 uint32_t local_id;
331 /** Remote communication ID */
332 uint32_t remote_id;
333 /** Reserved */
334 uint8_t reserved[224];
335 } __attribute__ (( packed ));
336
337 /** A communication management path */
338 struct ib_cm_path {
339 /** Local port LID */
340 uint16_t local_lid;
341 /** Remote port LID */
342 uint16_t remote_lid;
343 /** Local port GID */
344 union ib_gid local_gid;
345 /** Remote port GID */
346 union ib_gid remote_gid;
347 /** Flow label and rate */
348 uint32_t flow_label__rate;
349 /** Traffic class */
350 uint8_t tc;
351 /** Hop limit */
352 uint8_t hop_limit;
353 /** SL and subnet local*/
354 uint8_t sl__subnet_local;
355 /** Local ACK timeout */
356 uint8_t local_ack_timeout;
357 } __attribute__ (( packed ));
358
359 /** A communication management connection request
360 *
361 * Defined in section 12.6.5 of the IBA.
362 */
363 struct ib_cm_connect_request {
364 /** Local communication ID */
365 uint32_t local_id;
366 /** Reserved */
367 uint32_t reserved0[1];
368 /** Service ID */
369 union ib_guid service_id;
370 /** Local CA GUID */
371 union ib_guid local_ca;
372 /** Reserved */
373 uint32_t reserved1[1];
374 /** Local queue key */
375 uint32_t local_qkey;
376 /** Local QPN and responder resources*/
377 uint32_t local_qpn__responder_resources;
378 /** Local EECN and initiator depth */
379 uint32_t local_eecn__initiator_depth;
380 /** Remote EECN, remote CM response timeout, transport service
381 * type, EE flow control
382 */
383 uint32_t remote_eecn__remote_timeout__service_type__ee_flow_ctrl;
384 /** Starting PSN, local CM response timeout and retry count */
385 uint32_t starting_psn__local_timeout__retry_count;
386 /** Partition key */
387 uint16_t pkey;
388 /** Path packet payload MTU, RDC exists, RNR retry count */
389 uint8_t payload_mtu__rdc_exists__rnr_retry;
390 /** Max CM retries and SRQ */
391 uint8_t max_cm_retries__srq;
392 /** Primary path */
393 struct ib_cm_path primary;
394 /** Alternate path */
395 struct ib_cm_path alternate;
396 /** Private data */
397 uint8_t private_data[92];
398 } __attribute__ (( packed ));
399
400 /** CM transport types */
401 #define IB_CM_TRANSPORT_RC 0
402 #define IB_CM_TRANSPORT_UC 1
403 #define IB_CM_TRANSPORT_RD 2
404
405 /** A communication management connection rejection
406 *
407 * Defined in section 12.6.7 of the IBA.
408 */
409 struct ib_cm_connect_reject {
410 /** Local communication ID */
411 uint32_t local_id;
412 /** Remote communication ID */
413 uint32_t remote_id;
414 /** Message rejected */
415 uint8_t message;
416 /** Reject information length */
417 uint8_t info_len;
418 /** Rejection reason */
419 uint16_t reason;
420 /** Additional rejection information */
421 uint8_t info[72];
422 /** Private data */
423 uint8_t private_data[148];
424 } __attribute__ (( packed ));
425
426 /** CM rejection reasons */
427 #define IB_CM_REJECT_BAD_SERVICE_ID 8
428 #define IB_CM_REJECT_STALE_CONN 10
429 #define IB_CM_REJECT_CONSUMER 28
430
431 /** A communication management connection reply
432 *
433 * Defined in section 12.6.8 of the IBA.
434 */
435 struct ib_cm_connect_reply {
436 /** Local communication ID */
437 uint32_t local_id;
438 /** Remote communication ID */
439 uint32_t remote_id;
440 /** Local queue key */
441 uint32_t local_qkey;
442 /** Local QPN */
443 uint32_t local_qpn;
444 /** Local EECN */
445 uint32_t local_eecn;
446 /** Starting PSN */
447 uint32_t starting_psn;
448 /** Responder resources */
449 uint8_t responder_resources;
450 /** Initiator depth */
451 uint8_t initiator_depth;
452 /** Target ACK delay, failover accepted, and end-to-end flow control */
453 uint8_t target_ack_delay__failover_accepted__ee_flow_ctrl;
454 /** RNR retry count, SRQ */
455 uint8_t rnr_retry__srq;
456 /** Local CA GUID */
457 union ib_guid local_ca;
458 /** Private data */
459 uint8_t private_data[196];
460 } __attribute__ (( packed ));
461
462 /** A communication management ready to use reply
463 *
464 * Defined in section 12.6.9 of the IBA.
465 */
466 struct ib_cm_ready_to_use {
467 /** Local communication ID */
468 uint32_t local_id;
469 /** Remote communication ID */
470 uint32_t remote_id;
471 /** Private data */
472 uint8_t private_data[224];
473 } __attribute__ (( packed ));
474
475 /** A communication management disconnection request
476 *
477 * Defined in section 12.6.10 of the IBA.
478 */
479 struct ib_cm_disconnect_request {
480 /** Local communication ID */
481 uint32_t local_id;
482 /** Remote communication ID */
483 uint32_t remote_id;
484 /** Remote QPN/EECN */
485 uint32_t remote_qpn_eecn;
486 /** Private data */
487 uint8_t private_data[220];
488 } __attribute__ (( packed ));
489
490 /** A communication management disconnection reply
491 *
492 * Defined in section 12.6.11 of the IBA.
493 */
494 struct ib_cm_disconnect_reply {
495 /** Local communication ID */
496 uint32_t local_id;
497 /** Remote communication ID */
498 uint32_t remote_id;
499 /** Private data */
500 uint8_t private_data[224];
501 } __attribute__ (( packed ));
502
503 /** A communication management attribute */
504 union ib_cm_data {
505 struct ib_cm_common common;
506 struct ib_cm_connect_request connect_request;
507 struct ib_cm_connect_reject connect_reject;
508 struct ib_cm_connect_reply connect_reply;
509 struct ib_cm_ready_to_use ready_to_use;
510 struct ib_cm_disconnect_request disconnect_request;
511 struct ib_cm_disconnect_reply disconnect_reply;
512 uint8_t bytes[232];
513 } __attribute__ (( packed ));
514
515 /*****************************************************************************
516 *
517 * MADs
518 *
519 *****************************************************************************
520 */
521
522 /** Management datagram class_specific data */
523 union ib_mad_class_specific {
524 uint16_t raw;
525 struct ib_smp_class_specific smp;
526 } __attribute__ (( packed ));
527
528 /** A management datagram transaction identifier */
529 struct ib_mad_tid {
530 uint32_t high;
531 uint32_t low;
532 } __attribute__ (( packed ));
533
534 /** A management datagram common header
535 *
536 * Defined in section 13.4.2 of the IBA.
537 */
538 struct ib_mad_hdr {
539 uint8_t base_version;
540 uint8_t mgmt_class;
541 uint8_t class_version;
542 uint8_t method;
543 uint16_t status;
544 union ib_mad_class_specific class_specific;
545 struct ib_mad_tid tid;
546 uint16_t attr_id;
547 uint8_t reserved[2];
548 uint32_t attr_mod;
549 } __attribute__ (( packed ));
550
551 /* Management base version */
552 #define IB_MGMT_BASE_VERSION 1
553
554 /* Management classes */
555 #define IB_MGMT_CLASS_SUBN_LID_ROUTED 0x01
556 #define IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE 0x81
557 #define IB_MGMT_CLASS_SUBN_ADM 0x03
558 #define IB_MGMT_CLASS_PERF_MGMT 0x04
559 #define IB_MGMT_CLASS_BM 0x05
560 #define IB_MGMT_CLASS_DEVICE_MGMT 0x06
561 #define IB_MGMT_CLASS_CM 0x07
562 #define IB_MGMT_CLASS_SNMP 0x08
563 #define IB_MGMT_CLASS_VENDOR_RANGE2_START 0x30
564 #define IB_MGMT_CLASS_VENDOR_RANGE2_END 0x4f
565
566 #define IB_MGMT_CLASS_MASK 0x7f
567
568 /* Management methods */
569 #define IB_MGMT_METHOD_GET 0x01
570 #define IB_MGMT_METHOD_SET 0x02
571 #define IB_MGMT_METHOD_GET_RESP 0x81
572 #define IB_MGMT_METHOD_SEND 0x03
573 #define IB_MGMT_METHOD_TRAP 0x05
574 #define IB_MGMT_METHOD_REPORT 0x06
575 #define IB_MGMT_METHOD_REPORT_RESP 0x86
576 #define IB_MGMT_METHOD_TRAP_REPRESS 0x07
577 #define IB_MGMT_METHOD_DELETE 0x15
578
579 /* Status codes */
580 #define IB_MGMT_STATUS_OK 0x0000
581 #define IB_MGMT_STATUS_BAD_VERSION 0x0001
582 #define IB_MGMT_STATUS_UNSUPPORTED_METHOD 0x0002
583 #define IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR 0x0003
584 #define IB_MGMT_STATUS_INVALID_VALUE 0x0004
585
586 /** A subnet management MAD */
587 struct ib_mad_smp {
588 struct ib_mad_hdr mad_hdr;
589 struct ib_smp_hdr smp_hdr;
590 union ib_smp_data smp_data;
591 struct ib_smp_dr_path initial_path;
592 struct ib_smp_dr_path return_path;
593 } __attribute__ (( packed ));
594
595 /** A subnet administration MAD */
596 struct ib_mad_sa {
597 struct ib_mad_hdr mad_hdr;
598 struct ib_rmpp_hdr rmpp_hdr;
599 struct ib_sa_hdr sa_hdr;
600 union ib_sa_data sa_data;
601 } __attribute__ (( packed ));
602
603 /** A communication management MAD */
604 struct ib_mad_cm {
605 struct ib_mad_hdr mad_hdr;
606 union ib_cm_data cm_data;
607 } __attribute__ (( packed ));
608
609 /** A management datagram */
610 union ib_mad {
611 struct ib_mad_hdr hdr;
612 struct ib_mad_smp smp;
613 struct ib_mad_sa sa;
614 struct ib_mad_cm cm;
615 uint8_t bytes[256];
616 } __attribute__ (( packed ));
617
618 #endif /* _IPXE_IB_MAD_H */