You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ib_mad.h 14KB

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