qib_mad.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. /*
  2. * Copyright (c) 2012 Intel Corporation. All rights reserved.
  3. * Copyright (c) 2006 - 2012 QLogic Corporation. All rights reserved.
  4. * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved.
  5. *
  6. * This software is available to you under a choice of one of two
  7. * licenses. You may choose to be licensed under the terms of the GNU
  8. * General Public License (GPL) Version 2, available from the file
  9. * COPYING in the main directory of this source tree, or the
  10. * OpenIB.org BSD license below:
  11. *
  12. * Redistribution and use in source and binary forms, with or
  13. * without modification, are permitted provided that the following
  14. * conditions are met:
  15. *
  16. * - Redistributions of source code must retain the above
  17. * copyright notice, this list of conditions and the following
  18. * disclaimer.
  19. *
  20. * - Redistributions in binary form must reproduce the above
  21. * copyright notice, this list of conditions and the following
  22. * disclaimer in the documentation and/or other materials
  23. * provided with the distribution.
  24. *
  25. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  28. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  29. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  30. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  31. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  32. * SOFTWARE.
  33. */
  34. #ifndef _QIB_MAD_H
  35. #define _QIB_MAD_H
  36. #include <rdma/ib_pma.h>
  37. #define IB_SMP_UNSUP_VERSION cpu_to_be16(0x0004)
  38. #define IB_SMP_UNSUP_METHOD cpu_to_be16(0x0008)
  39. #define IB_SMP_UNSUP_METH_ATTR cpu_to_be16(0x000C)
  40. #define IB_SMP_INVALID_FIELD cpu_to_be16(0x001C)
  41. struct ib_node_info {
  42. u8 base_version;
  43. u8 class_version;
  44. u8 node_type;
  45. u8 num_ports;
  46. __be64 sys_guid;
  47. __be64 node_guid;
  48. __be64 port_guid;
  49. __be16 partition_cap;
  50. __be16 device_id;
  51. __be32 revision;
  52. u8 local_port_num;
  53. u8 vendor_id[3];
  54. } __packed;
  55. struct ib_mad_notice_attr {
  56. u8 generic_type;
  57. u8 prod_type_msb;
  58. __be16 prod_type_lsb;
  59. __be16 trap_num;
  60. __be16 issuer_lid;
  61. __be16 toggle_count;
  62. union {
  63. struct {
  64. u8 details[54];
  65. } raw_data;
  66. struct {
  67. __be16 reserved;
  68. __be16 lid; /* where violation happened */
  69. u8 port_num; /* where violation happened */
  70. } __packed ntc_129_131;
  71. struct {
  72. __be16 reserved;
  73. __be16 lid; /* LID where change occurred */
  74. u8 reserved2;
  75. u8 local_changes; /* low bit - local changes */
  76. __be32 new_cap_mask; /* new capability mask */
  77. u8 reserved3;
  78. u8 change_flags; /* low 3 bits only */
  79. } __packed ntc_144;
  80. struct {
  81. __be16 reserved;
  82. __be16 lid; /* lid where sys guid changed */
  83. __be16 reserved2;
  84. __be64 new_sys_guid;
  85. } __packed ntc_145;
  86. struct {
  87. __be16 reserved;
  88. __be16 lid;
  89. __be16 dr_slid;
  90. u8 method;
  91. u8 reserved2;
  92. __be16 attr_id;
  93. __be32 attr_mod;
  94. __be64 mkey;
  95. u8 reserved3;
  96. u8 dr_trunc_hop;
  97. u8 dr_rtn_path[30];
  98. } __packed ntc_256;
  99. struct {
  100. __be16 reserved;
  101. __be16 lid1;
  102. __be16 lid2;
  103. __be32 key;
  104. __be32 sl_qp1; /* SL: high 4 bits */
  105. __be32 qp2; /* high 8 bits reserved */
  106. union ib_gid gid1;
  107. union ib_gid gid2;
  108. } __packed ntc_257_258;
  109. } details;
  110. };
  111. /*
  112. * Generic trap/notice types
  113. */
  114. #define IB_NOTICE_TYPE_FATAL 0x80
  115. #define IB_NOTICE_TYPE_URGENT 0x81
  116. #define IB_NOTICE_TYPE_SECURITY 0x82
  117. #define IB_NOTICE_TYPE_SM 0x83
  118. #define IB_NOTICE_TYPE_INFO 0x84
  119. /*
  120. * Generic trap/notice producers
  121. */
  122. #define IB_NOTICE_PROD_CA cpu_to_be16(1)
  123. #define IB_NOTICE_PROD_SWITCH cpu_to_be16(2)
  124. #define IB_NOTICE_PROD_ROUTER cpu_to_be16(3)
  125. #define IB_NOTICE_PROD_CLASS_MGR cpu_to_be16(4)
  126. /*
  127. * Generic trap/notice numbers
  128. */
  129. #define IB_NOTICE_TRAP_LLI_THRESH cpu_to_be16(129)
  130. #define IB_NOTICE_TRAP_EBO_THRESH cpu_to_be16(130)
  131. #define IB_NOTICE_TRAP_FLOW_UPDATE cpu_to_be16(131)
  132. #define IB_NOTICE_TRAP_CAP_MASK_CHG cpu_to_be16(144)
  133. #define IB_NOTICE_TRAP_SYS_GUID_CHG cpu_to_be16(145)
  134. #define IB_NOTICE_TRAP_BAD_MKEY cpu_to_be16(256)
  135. #define IB_NOTICE_TRAP_BAD_PKEY cpu_to_be16(257)
  136. #define IB_NOTICE_TRAP_BAD_QKEY cpu_to_be16(258)
  137. /*
  138. * Repress trap/notice flags
  139. */
  140. #define IB_NOTICE_REPRESS_LLI_THRESH (1 << 0)
  141. #define IB_NOTICE_REPRESS_EBO_THRESH (1 << 1)
  142. #define IB_NOTICE_REPRESS_FLOW_UPDATE (1 << 2)
  143. #define IB_NOTICE_REPRESS_CAP_MASK_CHG (1 << 3)
  144. #define IB_NOTICE_REPRESS_SYS_GUID_CHG (1 << 4)
  145. #define IB_NOTICE_REPRESS_BAD_MKEY (1 << 5)
  146. #define IB_NOTICE_REPRESS_BAD_PKEY (1 << 6)
  147. #define IB_NOTICE_REPRESS_BAD_QKEY (1 << 7)
  148. /*
  149. * Generic trap/notice other local changes flags (trap 144).
  150. */
  151. #define IB_NOTICE_TRAP_LSE_CHG 0x04 /* Link Speed Enable changed */
  152. #define IB_NOTICE_TRAP_LWE_CHG 0x02 /* Link Width Enable changed */
  153. #define IB_NOTICE_TRAP_NODE_DESC_CHG 0x01
  154. /*
  155. * Generic trap/notice M_Key volation flags in dr_trunc_hop (trap 256).
  156. */
  157. #define IB_NOTICE_TRAP_DR_NOTICE 0x80
  158. #define IB_NOTICE_TRAP_DR_TRUNC 0x40
  159. struct ib_vl_weight_elem {
  160. u8 vl; /* Only low 4 bits, upper 4 bits reserved */
  161. u8 weight;
  162. };
  163. #define IB_VLARB_LOWPRI_0_31 1
  164. #define IB_VLARB_LOWPRI_32_63 2
  165. #define IB_VLARB_HIGHPRI_0_31 3
  166. #define IB_VLARB_HIGHPRI_32_63 4
  167. #define IB_PMA_PORT_COUNTERS_CONG cpu_to_be16(0xFF00)
  168. struct ib_pma_portcounters_cong {
  169. u8 reserved;
  170. u8 reserved1;
  171. __be16 port_check_rate;
  172. __be16 symbol_error_counter;
  173. u8 link_error_recovery_counter;
  174. u8 link_downed_counter;
  175. __be16 port_rcv_errors;
  176. __be16 port_rcv_remphys_errors;
  177. __be16 port_rcv_switch_relay_errors;
  178. __be16 port_xmit_discards;
  179. u8 port_xmit_constraint_errors;
  180. u8 port_rcv_constraint_errors;
  181. u8 reserved2;
  182. u8 link_overrun_errors; /* LocalLink: 7:4, BufferOverrun: 3:0 */
  183. __be16 reserved3;
  184. __be16 vl15_dropped;
  185. __be64 port_xmit_data;
  186. __be64 port_rcv_data;
  187. __be64 port_xmit_packets;
  188. __be64 port_rcv_packets;
  189. __be64 port_xmit_wait;
  190. __be64 port_adr_events;
  191. } __packed;
  192. #define IB_PMA_CONG_HW_CONTROL_TIMER 0x00
  193. #define IB_PMA_CONG_HW_CONTROL_SAMPLE 0x01
  194. #define QIB_XMIT_RATE_UNSUPPORTED 0x0
  195. #define QIB_XMIT_RATE_PICO 0x7
  196. /* number of 4nsec cycles equaling 2secs */
  197. #define QIB_CONG_TIMER_PSINTERVAL 0x1DCD64EC
  198. #define IB_PMA_SEL_CONG_ALL 0x01
  199. #define IB_PMA_SEL_CONG_PORT_DATA 0x02
  200. #define IB_PMA_SEL_CONG_XMIT 0x04
  201. #define IB_PMA_SEL_CONG_ROUTING 0x08
  202. /*
  203. * Congestion control class attributes
  204. */
  205. #define IB_CC_ATTR_CLASSPORTINFO cpu_to_be16(0x0001)
  206. #define IB_CC_ATTR_NOTICE cpu_to_be16(0x0002)
  207. #define IB_CC_ATTR_CONGESTION_INFO cpu_to_be16(0x0011)
  208. #define IB_CC_ATTR_CONGESTION_KEY_INFO cpu_to_be16(0x0012)
  209. #define IB_CC_ATTR_CONGESTION_LOG cpu_to_be16(0x0013)
  210. #define IB_CC_ATTR_SWITCH_CONGESTION_SETTING cpu_to_be16(0x0014)
  211. #define IB_CC_ATTR_SWITCH_PORT_CONGESTION_SETTING cpu_to_be16(0x0015)
  212. #define IB_CC_ATTR_CA_CONGESTION_SETTING cpu_to_be16(0x0016)
  213. #define IB_CC_ATTR_CONGESTION_CONTROL_TABLE cpu_to_be16(0x0017)
  214. #define IB_CC_ATTR_TIME_STAMP cpu_to_be16(0x0018)
  215. /* generalizations for threshold values */
  216. #define IB_CC_THRESHOLD_NONE 0x0
  217. #define IB_CC_THRESHOLD_MIN 0x1
  218. #define IB_CC_THRESHOLD_MAX 0xf
  219. /* CCA MAD header constants */
  220. #define IB_CC_MAD_LOGDATA_LEN 32
  221. #define IB_CC_MAD_MGMTDATA_LEN 192
  222. struct ib_cc_mad {
  223. u8 base_version;
  224. u8 mgmt_class;
  225. u8 class_version;
  226. u8 method;
  227. __be16 status;
  228. __be16 class_specific;
  229. __be64 tid;
  230. __be16 attr_id;
  231. __be16 resv;
  232. __be32 attr_mod;
  233. __be64 cckey;
  234. /* For CongestionLog attribute only */
  235. u8 log_data[IB_CC_MAD_LOGDATA_LEN];
  236. u8 mgmt_data[IB_CC_MAD_MGMTDATA_LEN];
  237. } __packed;
  238. /*
  239. * Congestion Control class portinfo capability mask bits
  240. */
  241. #define IB_CC_CPI_CM_TRAP_GEN cpu_to_be16(1 << 0)
  242. #define IB_CC_CPI_CM_GET_SET_NOTICE cpu_to_be16(1 << 1)
  243. #define IB_CC_CPI_CM_CAP2 cpu_to_be16(1 << 2)
  244. #define IB_CC_CPI_CM_ENHANCEDPORT0_CC cpu_to_be16(1 << 8)
  245. struct ib_cc_classportinfo_attr {
  246. u8 base_version;
  247. u8 class_version;
  248. __be16 cap_mask;
  249. u8 reserved[3];
  250. u8 resp_time_value; /* only lower 5 bits */
  251. union ib_gid redirect_gid;
  252. __be32 redirect_tc_sl_fl; /* 8, 4, 20 bits respectively */
  253. __be16 redirect_lid;
  254. __be16 redirect_pkey;
  255. __be32 redirect_qp; /* only lower 24 bits */
  256. __be32 redirect_qkey;
  257. union ib_gid trap_gid;
  258. __be32 trap_tc_sl_fl; /* 8, 4, 20 bits respectively */
  259. __be16 trap_lid;
  260. __be16 trap_pkey;
  261. __be32 trap_hl_qp; /* 8, 24 bits respectively */
  262. __be32 trap_qkey;
  263. } __packed;
  264. /* Congestion control traps */
  265. #define IB_CC_TRAP_KEY_VIOLATION 0x0000
  266. struct ib_cc_trap_key_violation_attr {
  267. __be16 source_lid;
  268. u8 method;
  269. u8 reserved1;
  270. __be16 attrib_id;
  271. __be32 attrib_mod;
  272. __be32 qp;
  273. __be64 cckey;
  274. u8 sgid[16];
  275. u8 padding[24];
  276. } __packed;
  277. /* Congestion info flags */
  278. #define IB_CC_CI_FLAGS_CREDIT_STARVATION 0x1
  279. #define IB_CC_TABLE_CAP_DEFAULT 31
  280. struct ib_cc_info_attr {
  281. __be16 congestion_info;
  282. u8 control_table_cap; /* Multiple of 64 entry unit CCTs */
  283. } __packed;
  284. struct ib_cc_key_info_attr {
  285. __be64 cckey;
  286. u8 protect;
  287. __be16 lease_period;
  288. __be16 violations;
  289. } __packed;
  290. #define IB_CC_CL_CA_LOGEVENTS_LEN 208
  291. struct ib_cc_log_attr {
  292. u8 log_type;
  293. u8 congestion_flags;
  294. __be16 threshold_event_counter;
  295. __be16 threshold_congestion_event_map;
  296. __be16 current_time_stamp;
  297. u8 log_events[IB_CC_CL_CA_LOGEVENTS_LEN];
  298. } __packed;
  299. #define IB_CC_CLEC_SERVICETYPE_RC 0x0
  300. #define IB_CC_CLEC_SERVICETYPE_UC 0x1
  301. #define IB_CC_CLEC_SERVICETYPE_RD 0x2
  302. #define IB_CC_CLEC_SERVICETYPE_UD 0x3
  303. struct ib_cc_log_event {
  304. u8 local_qp_cn_entry;
  305. u8 remote_qp_number_cn_entry[3];
  306. u8 sl_cn_entry:4;
  307. u8 service_type_cn_entry:4;
  308. __be32 remote_lid_cn_entry;
  309. __be32 timestamp_cn_entry;
  310. } __packed;
  311. /* Sixteen congestion entries */
  312. #define IB_CC_CCS_ENTRIES 16
  313. /* Port control flags */
  314. #define IB_CC_CCS_PC_SL_BASED 0x01
  315. struct ib_cc_congestion_entry {
  316. u8 ccti_increase;
  317. __be16 ccti_timer;
  318. u8 trigger_threshold;
  319. u8 ccti_min; /* min CCTI for cc table */
  320. } __packed;
  321. struct ib_cc_congestion_entry_shadow {
  322. u8 ccti_increase;
  323. u16 ccti_timer;
  324. u8 trigger_threshold;
  325. u8 ccti_min; /* min CCTI for cc table */
  326. } __packed;
  327. struct ib_cc_congestion_setting_attr {
  328. __be16 port_control;
  329. __be16 control_map;
  330. struct ib_cc_congestion_entry entries[IB_CC_CCS_ENTRIES];
  331. } __packed;
  332. struct ib_cc_congestion_setting_attr_shadow {
  333. u16 port_control;
  334. u16 control_map;
  335. struct ib_cc_congestion_entry_shadow entries[IB_CC_CCS_ENTRIES];
  336. } __packed;
  337. #define IB_CC_TABLE_ENTRY_INCREASE_DEFAULT 1
  338. #define IB_CC_TABLE_ENTRY_TIMER_DEFAULT 1
  339. /* 64 Congestion Control table entries in a single MAD */
  340. #define IB_CCT_ENTRIES 64
  341. #define IB_CCT_MIN_ENTRIES (IB_CCT_ENTRIES * 2)
  342. struct ib_cc_table_entry {
  343. __be16 entry; /* shift:2, multiplier:14 */
  344. };
  345. struct ib_cc_table_entry_shadow {
  346. u16 entry; /* shift:2, multiplier:14 */
  347. };
  348. struct ib_cc_table_attr {
  349. __be16 ccti_limit; /* max CCTI for cc table */
  350. struct ib_cc_table_entry ccti_entries[IB_CCT_ENTRIES];
  351. } __packed;
  352. struct ib_cc_table_attr_shadow {
  353. u16 ccti_limit; /* max CCTI for cc table */
  354. struct ib_cc_table_entry_shadow ccti_entries[IB_CCT_ENTRIES];
  355. } __packed;
  356. #define CC_TABLE_SHADOW_MAX \
  357. (IB_CC_TABLE_CAP_DEFAULT * IB_CCT_ENTRIES)
  358. struct cc_table_shadow {
  359. u16 ccti_last_entry;
  360. struct ib_cc_table_entry_shadow entries[CC_TABLE_SHADOW_MAX];
  361. } __packed;
  362. /*
  363. * The PortSamplesControl.CounterMasks field is an array of 3 bit fields
  364. * which specify the N'th counter's capabilities. See ch. 16.1.3.2.
  365. * We support 5 counters which only count the mandatory quantities.
  366. */
  367. #define COUNTER_MASK(q, n) (q << ((9 - n) * 3))
  368. #define COUNTER_MASK0_9 \
  369. cpu_to_be32(COUNTER_MASK(1, 0) | \
  370. COUNTER_MASK(1, 1) | \
  371. COUNTER_MASK(1, 2) | \
  372. COUNTER_MASK(1, 3) | \
  373. COUNTER_MASK(1, 4))
  374. #endif /* _QIB_MAD_H */