qib_mad.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. /*
  2. * Copyright (c) 2006, 2007, 2008, 2009, 2010 QLogic Corporation.
  3. * 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. #define IB_SMP_UNSUP_VERSION cpu_to_be16(0x0004)
  35. #define IB_SMP_UNSUP_METHOD cpu_to_be16(0x0008)
  36. #define IB_SMP_UNSUP_METH_ATTR cpu_to_be16(0x000C)
  37. #define IB_SMP_INVALID_FIELD cpu_to_be16(0x001C)
  38. struct ib_node_info {
  39. u8 base_version;
  40. u8 class_version;
  41. u8 node_type;
  42. u8 num_ports;
  43. __be64 sys_guid;
  44. __be64 node_guid;
  45. __be64 port_guid;
  46. __be16 partition_cap;
  47. __be16 device_id;
  48. __be32 revision;
  49. u8 local_port_num;
  50. u8 vendor_id[3];
  51. } __attribute__ ((packed));
  52. struct ib_mad_notice_attr {
  53. u8 generic_type;
  54. u8 prod_type_msb;
  55. __be16 prod_type_lsb;
  56. __be16 trap_num;
  57. __be16 issuer_lid;
  58. __be16 toggle_count;
  59. union {
  60. struct {
  61. u8 details[54];
  62. } raw_data;
  63. struct {
  64. __be16 reserved;
  65. __be16 lid; /* where violation happened */
  66. u8 port_num; /* where violation happened */
  67. } __attribute__ ((packed)) ntc_129_131;
  68. struct {
  69. __be16 reserved;
  70. __be16 lid; /* LID where change occured */
  71. u8 reserved2;
  72. u8 local_changes; /* low bit - local changes */
  73. __be32 new_cap_mask; /* new capability mask */
  74. u8 reserved3;
  75. u8 change_flags; /* low 3 bits only */
  76. } __attribute__ ((packed)) ntc_144;
  77. struct {
  78. __be16 reserved;
  79. __be16 lid; /* lid where sys guid changed */
  80. __be16 reserved2;
  81. __be64 new_sys_guid;
  82. } __attribute__ ((packed)) ntc_145;
  83. struct {
  84. __be16 reserved;
  85. __be16 lid;
  86. __be16 dr_slid;
  87. u8 method;
  88. u8 reserved2;
  89. __be16 attr_id;
  90. __be32 attr_mod;
  91. __be64 mkey;
  92. u8 reserved3;
  93. u8 dr_trunc_hop;
  94. u8 dr_rtn_path[30];
  95. } __attribute__ ((packed)) ntc_256;
  96. struct {
  97. __be16 reserved;
  98. __be16 lid1;
  99. __be16 lid2;
  100. __be32 key;
  101. __be32 sl_qp1; /* SL: high 4 bits */
  102. __be32 qp2; /* high 8 bits reserved */
  103. union ib_gid gid1;
  104. union ib_gid gid2;
  105. } __attribute__ ((packed)) ntc_257_258;
  106. } details;
  107. };
  108. /*
  109. * Generic trap/notice types
  110. */
  111. #define IB_NOTICE_TYPE_FATAL 0x80
  112. #define IB_NOTICE_TYPE_URGENT 0x81
  113. #define IB_NOTICE_TYPE_SECURITY 0x82
  114. #define IB_NOTICE_TYPE_SM 0x83
  115. #define IB_NOTICE_TYPE_INFO 0x84
  116. /*
  117. * Generic trap/notice producers
  118. */
  119. #define IB_NOTICE_PROD_CA cpu_to_be16(1)
  120. #define IB_NOTICE_PROD_SWITCH cpu_to_be16(2)
  121. #define IB_NOTICE_PROD_ROUTER cpu_to_be16(3)
  122. #define IB_NOTICE_PROD_CLASS_MGR cpu_to_be16(4)
  123. /*
  124. * Generic trap/notice numbers
  125. */
  126. #define IB_NOTICE_TRAP_LLI_THRESH cpu_to_be16(129)
  127. #define IB_NOTICE_TRAP_EBO_THRESH cpu_to_be16(130)
  128. #define IB_NOTICE_TRAP_FLOW_UPDATE cpu_to_be16(131)
  129. #define IB_NOTICE_TRAP_CAP_MASK_CHG cpu_to_be16(144)
  130. #define IB_NOTICE_TRAP_SYS_GUID_CHG cpu_to_be16(145)
  131. #define IB_NOTICE_TRAP_BAD_MKEY cpu_to_be16(256)
  132. #define IB_NOTICE_TRAP_BAD_PKEY cpu_to_be16(257)
  133. #define IB_NOTICE_TRAP_BAD_QKEY cpu_to_be16(258)
  134. /*
  135. * Repress trap/notice flags
  136. */
  137. #define IB_NOTICE_REPRESS_LLI_THRESH (1 << 0)
  138. #define IB_NOTICE_REPRESS_EBO_THRESH (1 << 1)
  139. #define IB_NOTICE_REPRESS_FLOW_UPDATE (1 << 2)
  140. #define IB_NOTICE_REPRESS_CAP_MASK_CHG (1 << 3)
  141. #define IB_NOTICE_REPRESS_SYS_GUID_CHG (1 << 4)
  142. #define IB_NOTICE_REPRESS_BAD_MKEY (1 << 5)
  143. #define IB_NOTICE_REPRESS_BAD_PKEY (1 << 6)
  144. #define IB_NOTICE_REPRESS_BAD_QKEY (1 << 7)
  145. /*
  146. * Generic trap/notice other local changes flags (trap 144).
  147. */
  148. #define IB_NOTICE_TRAP_LSE_CHG 0x04 /* Link Speed Enable changed */
  149. #define IB_NOTICE_TRAP_LWE_CHG 0x02 /* Link Width Enable changed */
  150. #define IB_NOTICE_TRAP_NODE_DESC_CHG 0x01
  151. /*
  152. * Generic trap/notice M_Key volation flags in dr_trunc_hop (trap 256).
  153. */
  154. #define IB_NOTICE_TRAP_DR_NOTICE 0x80
  155. #define IB_NOTICE_TRAP_DR_TRUNC 0x40
  156. struct ib_vl_weight_elem {
  157. u8 vl; /* Only low 4 bits, upper 4 bits reserved */
  158. u8 weight;
  159. };
  160. #define IB_VLARB_LOWPRI_0_31 1
  161. #define IB_VLARB_LOWPRI_32_63 2
  162. #define IB_VLARB_HIGHPRI_0_31 3
  163. #define IB_VLARB_HIGHPRI_32_63 4
  164. /*
  165. * PMA class portinfo capability mask bits
  166. */
  167. #define IB_PMA_CLASS_CAP_ALLPORTSELECT cpu_to_be16(1 << 8)
  168. #define IB_PMA_CLASS_CAP_EXT_WIDTH cpu_to_be16(1 << 9)
  169. #define IB_PMA_CLASS_CAP_XMIT_WAIT cpu_to_be16(1 << 12)
  170. #define IB_PMA_CLASS_PORT_INFO cpu_to_be16(0x0001)
  171. #define IB_PMA_PORT_SAMPLES_CONTROL cpu_to_be16(0x0010)
  172. #define IB_PMA_PORT_SAMPLES_RESULT cpu_to_be16(0x0011)
  173. #define IB_PMA_PORT_COUNTERS cpu_to_be16(0x0012)
  174. #define IB_PMA_PORT_COUNTERS_EXT cpu_to_be16(0x001D)
  175. #define IB_PMA_PORT_SAMPLES_RESULT_EXT cpu_to_be16(0x001E)
  176. #define IB_PMA_PORT_COUNTERS_CONG cpu_to_be16(0xFF00)
  177. struct ib_perf {
  178. u8 base_version;
  179. u8 mgmt_class;
  180. u8 class_version;
  181. u8 method;
  182. __be16 status;
  183. __be16 unused;
  184. __be64 tid;
  185. __be16 attr_id;
  186. __be16 resv;
  187. __be32 attr_mod;
  188. u8 reserved[40];
  189. u8 data[192];
  190. } __attribute__ ((packed));
  191. struct ib_pma_classportinfo {
  192. u8 base_version;
  193. u8 class_version;
  194. __be16 cap_mask;
  195. u8 reserved[3];
  196. u8 resp_time_value; /* only lower 5 bits */
  197. union ib_gid redirect_gid;
  198. __be32 redirect_tc_sl_fl; /* 8, 4, 20 bits respectively */
  199. __be16 redirect_lid;
  200. __be16 redirect_pkey;
  201. __be32 redirect_qp; /* only lower 24 bits */
  202. __be32 redirect_qkey;
  203. union ib_gid trap_gid;
  204. __be32 trap_tc_sl_fl; /* 8, 4, 20 bits respectively */
  205. __be16 trap_lid;
  206. __be16 trap_pkey;
  207. __be32 trap_hl_qp; /* 8, 24 bits respectively */
  208. __be32 trap_qkey;
  209. } __attribute__ ((packed));
  210. struct ib_pma_portsamplescontrol {
  211. u8 opcode;
  212. u8 port_select;
  213. u8 tick;
  214. u8 counter_width; /* only lower 3 bits */
  215. __be32 counter_mask0_9; /* 2, 10 * 3, bits */
  216. __be16 counter_mask10_14; /* 1, 5 * 3, bits */
  217. u8 sample_mechanisms;
  218. u8 sample_status; /* only lower 2 bits */
  219. __be64 option_mask;
  220. __be64 vendor_mask;
  221. __be32 sample_start;
  222. __be32 sample_interval;
  223. __be16 tag;
  224. __be16 counter_select[15];
  225. } __attribute__ ((packed));
  226. struct ib_pma_portsamplesresult {
  227. __be16 tag;
  228. __be16 sample_status; /* only lower 2 bits */
  229. __be32 counter[15];
  230. } __attribute__ ((packed));
  231. struct ib_pma_portsamplesresult_ext {
  232. __be16 tag;
  233. __be16 sample_status; /* only lower 2 bits */
  234. __be32 extended_width; /* only upper 2 bits */
  235. __be64 counter[15];
  236. } __attribute__ ((packed));
  237. struct ib_pma_portcounters {
  238. u8 reserved;
  239. u8 port_select;
  240. __be16 counter_select;
  241. __be16 symbol_error_counter;
  242. u8 link_error_recovery_counter;
  243. u8 link_downed_counter;
  244. __be16 port_rcv_errors;
  245. __be16 port_rcv_remphys_errors;
  246. __be16 port_rcv_switch_relay_errors;
  247. __be16 port_xmit_discards;
  248. u8 port_xmit_constraint_errors;
  249. u8 port_rcv_constraint_errors;
  250. u8 reserved1;
  251. u8 lli_ebor_errors; /* 4, 4, bits */
  252. __be16 reserved2;
  253. __be16 vl15_dropped;
  254. __be32 port_xmit_data;
  255. __be32 port_rcv_data;
  256. __be32 port_xmit_packets;
  257. __be32 port_rcv_packets;
  258. } __attribute__ ((packed));
  259. struct ib_pma_portcounters_cong {
  260. u8 reserved;
  261. u8 reserved1;
  262. __be16 port_check_rate;
  263. __be16 symbol_error_counter;
  264. u8 link_error_recovery_counter;
  265. u8 link_downed_counter;
  266. __be16 port_rcv_errors;
  267. __be16 port_rcv_remphys_errors;
  268. __be16 port_rcv_switch_relay_errors;
  269. __be16 port_xmit_discards;
  270. u8 port_xmit_constraint_errors;
  271. u8 port_rcv_constraint_errors;
  272. u8 reserved2;
  273. u8 lli_ebor_errors; /* 4, 4, bits */
  274. __be16 reserved3;
  275. __be16 vl15_dropped;
  276. __be64 port_xmit_data;
  277. __be64 port_rcv_data;
  278. __be64 port_xmit_packets;
  279. __be64 port_rcv_packets;
  280. __be64 port_xmit_wait;
  281. __be64 port_adr_events;
  282. } __attribute__ ((packed));
  283. #define IB_PMA_CONG_HW_CONTROL_TIMER 0x00
  284. #define IB_PMA_CONG_HW_CONTROL_SAMPLE 0x01
  285. #define QIB_XMIT_RATE_UNSUPPORTED 0x0
  286. #define QIB_XMIT_RATE_PICO 0x7
  287. /* number of 4nsec cycles equaling 2secs */
  288. #define QIB_CONG_TIMER_PSINTERVAL 0x1DCD64EC
  289. #define IB_PMA_SEL_SYMBOL_ERROR cpu_to_be16(0x0001)
  290. #define IB_PMA_SEL_LINK_ERROR_RECOVERY cpu_to_be16(0x0002)
  291. #define IB_PMA_SEL_LINK_DOWNED cpu_to_be16(0x0004)
  292. #define IB_PMA_SEL_PORT_RCV_ERRORS cpu_to_be16(0x0008)
  293. #define IB_PMA_SEL_PORT_RCV_REMPHYS_ERRORS cpu_to_be16(0x0010)
  294. #define IB_PMA_SEL_PORT_XMIT_DISCARDS cpu_to_be16(0x0040)
  295. #define IB_PMA_SEL_LOCAL_LINK_INTEGRITY_ERRORS cpu_to_be16(0x0200)
  296. #define IB_PMA_SEL_EXCESSIVE_BUFFER_OVERRUNS cpu_to_be16(0x0400)
  297. #define IB_PMA_SEL_PORT_VL15_DROPPED cpu_to_be16(0x0800)
  298. #define IB_PMA_SEL_PORT_XMIT_DATA cpu_to_be16(0x1000)
  299. #define IB_PMA_SEL_PORT_RCV_DATA cpu_to_be16(0x2000)
  300. #define IB_PMA_SEL_PORT_XMIT_PACKETS cpu_to_be16(0x4000)
  301. #define IB_PMA_SEL_PORT_RCV_PACKETS cpu_to_be16(0x8000)
  302. #define IB_PMA_SEL_CONG_ALL 0x01
  303. #define IB_PMA_SEL_CONG_PORT_DATA 0x02
  304. #define IB_PMA_SEL_CONG_XMIT 0x04
  305. #define IB_PMA_SEL_CONG_ROUTING 0x08
  306. struct ib_pma_portcounters_ext {
  307. u8 reserved;
  308. u8 port_select;
  309. __be16 counter_select;
  310. __be32 reserved1;
  311. __be64 port_xmit_data;
  312. __be64 port_rcv_data;
  313. __be64 port_xmit_packets;
  314. __be64 port_rcv_packets;
  315. __be64 port_unicast_xmit_packets;
  316. __be64 port_unicast_rcv_packets;
  317. __be64 port_multicast_xmit_packets;
  318. __be64 port_multicast_rcv_packets;
  319. } __attribute__ ((packed));
  320. #define IB_PMA_SELX_PORT_XMIT_DATA cpu_to_be16(0x0001)
  321. #define IB_PMA_SELX_PORT_RCV_DATA cpu_to_be16(0x0002)
  322. #define IB_PMA_SELX_PORT_XMIT_PACKETS cpu_to_be16(0x0004)
  323. #define IB_PMA_SELX_PORT_RCV_PACKETS cpu_to_be16(0x0008)
  324. #define IB_PMA_SELX_PORT_UNI_XMIT_PACKETS cpu_to_be16(0x0010)
  325. #define IB_PMA_SELX_PORT_UNI_RCV_PACKETS cpu_to_be16(0x0020)
  326. #define IB_PMA_SELX_PORT_MULTI_XMIT_PACKETS cpu_to_be16(0x0040)
  327. #define IB_PMA_SELX_PORT_MULTI_RCV_PACKETS cpu_to_be16(0x0080)
  328. /*
  329. * The PortSamplesControl.CounterMasks field is an array of 3 bit fields
  330. * which specify the N'th counter's capabilities. See ch. 16.1.3.2.
  331. * We support 5 counters which only count the mandatory quantities.
  332. */
  333. #define COUNTER_MASK(q, n) (q << ((9 - n) * 3))
  334. #define COUNTER_MASK0_9 \
  335. cpu_to_be32(COUNTER_MASK(1, 0) | \
  336. COUNTER_MASK(1, 1) | \
  337. COUNTER_MASK(1, 2) | \
  338. COUNTER_MASK(1, 3) | \
  339. COUNTER_MASK(1, 4))