Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. #ifndef _GPXE_IB_MAD_H
  2. #define _GPXE_IB_MAD_H
  3. /** @file
  4. *
  5. * Infiniband management datagrams
  6. *
  7. */
  8. #include <stdint.h>
  9. #include <gpxe/ib_packet.h>
  10. /*****************************************************************************
  11. *
  12. * Subnet management MADs
  13. *
  14. *****************************************************************************
  15. */
  16. /** A subnet management header
  17. *
  18. * Defined in sections 14.2.1.1 and 14.2.1.2 of the IBA.
  19. */
  20. struct ib_smp_hdr {
  21. uint64_t mkey;
  22. uint16_t slid;
  23. uint16_t dlid;
  24. uint8_t reserved[28];
  25. } __attribute__ (( packed ));
  26. /** Subnet management class version */
  27. #define IB_SMP_CLASS_VERSION 1
  28. /** Subnet management direction bit
  29. *
  30. * This bit resides in the "status" field in the MAD header.
  31. */
  32. #define IB_SMP_STATUS_D_INBOUND 0x8000
  33. /* Subnet management attributes */
  34. #define IB_SMP_ATTR_NOTICE 0x0002
  35. #define IB_SMP_ATTR_NODE_DESC 0x0010
  36. #define IB_SMP_ATTR_NODE_INFO 0x0011
  37. #define IB_SMP_ATTR_SWITCH_INFO 0x0012
  38. #define IB_SMP_ATTR_GUID_INFO 0x0014
  39. #define IB_SMP_ATTR_PORT_INFO 0x0015
  40. #define IB_SMP_ATTR_PKEY_TABLE 0x0016
  41. #define IB_SMP_ATTR_SL_TO_VL_TABLE 0x0017
  42. #define IB_SMP_ATTR_VL_ARB_TABLE 0x0018
  43. #define IB_SMP_ATTR_LINEAR_FORWARD_TABLE 0x0019
  44. #define IB_SMP_ATTR_RANDOM_FORWARD_TABLE 0x001A
  45. #define IB_SMP_ATTR_MCAST_FORWARD_TABLE 0x001B
  46. #define IB_SMP_ATTR_SM_INFO 0x0020
  47. #define IB_SMP_ATTR_VENDOR_DIAG 0x0030
  48. #define IB_SMP_ATTR_LED_INFO 0x0031
  49. #define IB_SMP_ATTR_VENDOR_MASK 0xFF00
  50. /**
  51. * A Node Description attribute
  52. *
  53. * Defined in section 14.2.5.2 of the IBA
  54. */
  55. struct ib_node_desc {
  56. char node_string[64];
  57. } __attribute__ (( packed ));
  58. /** A Node Information attribute
  59. *
  60. * Defined in section 14.2.5.3 of the IBA.
  61. */
  62. struct ib_node_info {
  63. uint8_t base_version;
  64. uint8_t class_version;
  65. uint8_t node_type;
  66. uint8_t num_ports;
  67. uint8_t sys_guid[8];
  68. uint8_t node_guid[8];
  69. uint8_t port_guid[8];
  70. uint16_t partition_cap;
  71. uint16_t device_id;
  72. uint32_t revision;
  73. uint8_t local_port_num;
  74. uint8_t vendor_id[3];
  75. } __attribute__ ((packed));
  76. #define IB_NODE_TYPE_HCA 0x01
  77. #define IB_NODE_TYPE_SWITCH 0x02
  78. #define IB_NODE_TYPE_ROUTER 0x03
  79. /** A GUID Information attribute
  80. *
  81. * Defined in section 14.2.5.5 of the IBA.
  82. */
  83. struct ib_guid_info {
  84. uint8_t guid[8][8];
  85. } __attribute__ (( packed ));
  86. /** A Port Information attribute
  87. *
  88. * Defined in section 14.2.5.6 of the IBA.
  89. */
  90. struct ib_port_info {
  91. uint64_t mkey;
  92. uint8_t gid_prefix[8];
  93. uint16_t lid;
  94. uint16_t mastersm_lid;
  95. uint32_t cap_mask;
  96. uint16_t diag_code;
  97. uint16_t mkey_lease_period;
  98. uint8_t local_port_num;
  99. uint8_t link_width_enabled;
  100. uint8_t link_width_supported;
  101. uint8_t link_width_active;
  102. uint8_t link_speed_supported__port_state;
  103. uint8_t port_phys_state__link_down_def_state;
  104. uint8_t mkey_prot_bits__lmc;
  105. uint8_t link_speed_active__link_speed_enabled;
  106. uint8_t neighbour_mtu__mastersm_sl;
  107. uint8_t vl_cap__init_type;
  108. uint8_t vl_high_limit;
  109. uint8_t vl_arbitration_high_cap;
  110. uint8_t vl_arbitration_low_cap;
  111. uint8_t init_type_reply__mtu_cap;
  112. uint8_t vl_stall_count__hoq_life;
  113. uint8_t operational_vls__enforcement;
  114. uint16_t mkey_violations;
  115. uint16_t pkey_violations;
  116. uint16_t qkey_violations;
  117. uint8_t guid_cap;
  118. uint8_t client_reregister__subnet_timeout;
  119. uint8_t resp_time_value;
  120. uint8_t local_phy_errors__overrun_errors;
  121. uint16_t max_credit_hint;
  122. uint32_t link_round_trip_latency;
  123. } __attribute__ (( packed ));
  124. #define IB_LINK_WIDTH_1X 0x01
  125. #define IB_LINK_WIDTH_4X 0x02
  126. #define IB_LINK_WIDTH_8X 0x04
  127. #define IB_LINK_WIDTH_12X 0x08
  128. #define IB_LINK_SPEED_SDR 0x01
  129. #define IB_LINK_SPEED_DDR 0x02
  130. #define IB_LINK_SPEED_QDR 0x04
  131. #define IB_PORT_STATE_DOWN 0x01
  132. #define IB_PORT_STATE_INIT 0x02
  133. #define IB_PORT_STATE_ARMED 0x03
  134. #define IB_PORT_STATE_ACTIVE 0x04
  135. #define IB_PORT_PHYS_STATE_SLEEP 0x01
  136. #define IB_PORT_PHYS_STATE_POLLING 0x02
  137. #define IB_MTU_256 0x01
  138. #define IB_MTU_512 0x02
  139. #define IB_MTU_1024 0x03
  140. #define IB_MTU_2048 0x04
  141. #define IB_MTU_4096 0x05
  142. #define IB_VL_0 0x01
  143. #define IB_VL_0_1 0x02
  144. #define IB_VL_0_3 0x03
  145. #define IB_VL_0_7 0x04
  146. #define IB_VL_0_14 0x05
  147. /** A Partition Key Table attribute
  148. *
  149. * Defined in section 14.2.5.7 of the IBA.
  150. */
  151. struct ib_pkey_table {
  152. uint16_t pkey[32];
  153. } __attribute__ (( packed ));
  154. /** A subnet management attribute */
  155. union ib_smp_data {
  156. struct ib_node_desc node_desc;
  157. struct ib_node_info node_info;
  158. struct ib_guid_info guid_info;
  159. struct ib_port_info port_info;
  160. struct ib_pkey_table pkey_table;
  161. uint8_t bytes[64];
  162. } __attribute__ (( packed ));
  163. /** A subnet management directed route path */
  164. struct ib_smp_dr_path {
  165. uint8_t hops[64];
  166. } __attribute__ (( packed ));
  167. /** Subnet management MAD class-specific data */
  168. struct ib_smp_class_specific {
  169. uint8_t hop_pointer;
  170. uint8_t hop_count;
  171. } __attribute__ (( packed ));
  172. /*****************************************************************************
  173. *
  174. * Subnet administration MADs
  175. *
  176. *****************************************************************************
  177. */
  178. struct ib_rmpp_hdr {
  179. uint32_t raw[3];
  180. } __attribute__ (( packed ));
  181. struct ib_sa_hdr {
  182. uint32_t sm_key[2];
  183. uint16_t reserved;
  184. uint16_t attrib_offset;
  185. uint32_t comp_mask[2];
  186. } __attribute__ (( packed ));
  187. #define IB_SA_ATTR_MC_MEMBER_REC 0x38
  188. #define IB_SA_ATTR_PATH_REC 0x35
  189. struct ib_path_record {
  190. uint32_t reserved0[2];
  191. struct ib_gid dgid;
  192. struct ib_gid sgid;
  193. uint16_t dlid;
  194. uint16_t slid;
  195. uint32_t hop_limit__flow_label__raw_traffic;
  196. uint32_t pkey__numb_path__reversible__tclass;
  197. uint8_t reserved1;
  198. uint8_t reserved__sl;
  199. uint8_t mtu_selector__mtu;
  200. uint8_t rate_selector__rate;
  201. uint32_t preference__packet_lifetime__packet_lifetime_selector;
  202. uint32_t reserved2[35];
  203. } __attribute__ (( packed ));
  204. #define IB_SA_PATH_REC_DGID (1<<2)
  205. #define IB_SA_PATH_REC_SGID (1<<3)
  206. struct ib_mc_member_record {
  207. struct ib_gid mgid;
  208. struct ib_gid port_gid;
  209. uint32_t qkey;
  210. uint16_t mlid;
  211. uint8_t mtu_selector__mtu;
  212. uint8_t tclass;
  213. uint16_t pkey;
  214. uint8_t rate_selector__rate;
  215. uint8_t packet_lifetime_selector__packet_lifetime;
  216. uint32_t sl__flow_label__hop_limit;
  217. uint8_t scope__join_state;
  218. uint8_t proxy_join__reserved;
  219. uint16_t reserved0;
  220. uint32_t reserved1[37];
  221. } __attribute__ (( packed ));
  222. #define IB_SA_MCMEMBER_REC_MGID (1<<0)
  223. #define IB_SA_MCMEMBER_REC_PORT_GID (1<<1)
  224. #define IB_SA_MCMEMBER_REC_QKEY (1<<2)
  225. #define IB_SA_MCMEMBER_REC_MLID (1<<3)
  226. #define IB_SA_MCMEMBER_REC_MTU_SELECTOR (1<<4)
  227. #define IB_SA_MCMEMBER_REC_MTU (1<<5)
  228. #define IB_SA_MCMEMBER_REC_TRAFFIC_CLASS (1<<6)
  229. #define IB_SA_MCMEMBER_REC_PKEY (1<<7)
  230. #define IB_SA_MCMEMBER_REC_RATE_SELECTOR (1<<8)
  231. #define IB_SA_MCMEMBER_REC_RATE (1<<9)
  232. #define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME_SELECTOR (1<<10)
  233. #define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME (1<<11)
  234. #define IB_SA_MCMEMBER_REC_SL (1<<12)
  235. #define IB_SA_MCMEMBER_REC_FLOW_LABEL (1<<13)
  236. #define IB_SA_MCMEMBER_REC_HOP_LIMIT (1<<14)
  237. #define IB_SA_MCMEMBER_REC_SCOPE (1<<15)
  238. #define IB_SA_MCMEMBER_REC_JOIN_STATE (1<<16)
  239. #define IB_SA_MCMEMBER_REC_PROXY_JOIN (1<<17)
  240. union ib_sa_data {
  241. struct ib_path_record path_record;
  242. struct ib_mc_member_record mc_member_record;
  243. } __attribute__ (( packed ));
  244. /*****************************************************************************
  245. *
  246. * MADs
  247. *
  248. *****************************************************************************
  249. */
  250. /** Management datagram class_specific data */
  251. union ib_mad_class_specific {
  252. uint16_t raw;
  253. struct ib_smp_class_specific smp;
  254. } __attribute__ (( packed ));
  255. /** A management datagram common header
  256. *
  257. * Defined in section 13.4.2 of the IBA.
  258. */
  259. struct ib_mad_hdr {
  260. uint8_t base_version;
  261. uint8_t mgmt_class;
  262. uint8_t class_version;
  263. uint8_t method;
  264. uint16_t status;
  265. union ib_mad_class_specific class_specific;
  266. uint32_t tid[2];
  267. uint16_t attr_id;
  268. uint8_t reserved[2];
  269. uint32_t attr_mod;
  270. } __attribute__ (( packed ));
  271. /* Management base version */
  272. #define IB_MGMT_BASE_VERSION 1
  273. /* Management classes */
  274. #define IB_MGMT_CLASS_SUBN_LID_ROUTED 0x01
  275. #define IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE 0x81
  276. #define IB_MGMT_CLASS_SUBN_ADM 0x03
  277. #define IB_MGMT_CLASS_PERF_MGMT 0x04
  278. #define IB_MGMT_CLASS_BM 0x05
  279. #define IB_MGMT_CLASS_DEVICE_MGMT 0x06
  280. #define IB_MGMT_CLASS_CM 0x07
  281. #define IB_MGMT_CLASS_SNMP 0x08
  282. #define IB_MGMT_CLASS_VENDOR_RANGE2_START 0x30
  283. #define IB_MGMT_CLASS_VENDOR_RANGE2_END 0x4F
  284. /* Management methods */
  285. #define IB_MGMT_METHOD_GET 0x01
  286. #define IB_MGMT_METHOD_SET 0x02
  287. #define IB_MGMT_METHOD_GET_RESP 0x81
  288. #define IB_MGMT_METHOD_SEND 0x03
  289. #define IB_MGMT_METHOD_TRAP 0x05
  290. #define IB_MGMT_METHOD_REPORT 0x06
  291. #define IB_MGMT_METHOD_REPORT_RESP 0x86
  292. #define IB_MGMT_METHOD_TRAP_REPRESS 0x07
  293. #define IB_MGMT_METHOD_DELETE 0x15
  294. /* Status codes */
  295. #define IB_MGMT_STATUS_OK 0x0000
  296. #define IB_MGMT_STATUS_BAD_VERSION 0x0001
  297. #define IB_MGMT_STATUS_UNSUPPORTED_METHOD 0x0002
  298. #define IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR 0x0003
  299. #define IB_MGMT_STATUS_INVALID_VALUE 0x0004
  300. /** A subnet management MAD */
  301. struct ib_mad_smp {
  302. struct ib_mad_hdr mad_hdr;
  303. struct ib_smp_hdr smp_hdr;
  304. union ib_smp_data smp_data;
  305. struct ib_smp_dr_path initial_path;
  306. struct ib_smp_dr_path return_path;
  307. } __attribute__ (( packed ));
  308. /** A subnet administration MAD */
  309. struct ib_mad_sa {
  310. struct ib_mad_hdr mad_hdr;
  311. struct ib_rmpp_hdr rmpp_hdr;
  312. struct ib_sa_hdr sa_hdr;
  313. union ib_sa_data sa_data;
  314. } __attribute__ (( packed ));
  315. /** A management datagram */
  316. union ib_mad {
  317. struct ib_mad_hdr hdr;
  318. struct ib_mad_smp smp;
  319. struct ib_mad_sa sa;
  320. uint8_t bytes[256];
  321. } __attribute__ (( packed ));
  322. #endif /* _GPXE_IB_MAD_H */