qib_mad.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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 \
  38. cpu_to_be16(IB_MGMT_MAD_STATUS_BAD_VERSION)
  39. #define IB_SMP_UNSUP_METHOD \
  40. cpu_to_be16(IB_MGMT_MAD_STATUS_UNSUPPORTED_METHOD)
  41. #define IB_SMP_UNSUP_METH_ATTR \
  42. cpu_to_be16(IB_MGMT_MAD_STATUS_UNSUPPORTED_METHOD_ATTRIB)
  43. #define IB_SMP_INVALID_FIELD \
  44. cpu_to_be16(IB_MGMT_MAD_STATUS_INVALID_ATTRIB_VALUE)
  45. #define IB_VLARB_LOWPRI_0_31 1
  46. #define IB_VLARB_LOWPRI_32_63 2
  47. #define IB_VLARB_HIGHPRI_0_31 3
  48. #define IB_VLARB_HIGHPRI_32_63 4
  49. #define IB_PMA_PORT_COUNTERS_CONG cpu_to_be16(0xFF00)
  50. struct ib_pma_portcounters_cong {
  51. u8 reserved;
  52. u8 reserved1;
  53. __be16 port_check_rate;
  54. __be16 symbol_error_counter;
  55. u8 link_error_recovery_counter;
  56. u8 link_downed_counter;
  57. __be16 port_rcv_errors;
  58. __be16 port_rcv_remphys_errors;
  59. __be16 port_rcv_switch_relay_errors;
  60. __be16 port_xmit_discards;
  61. u8 port_xmit_constraint_errors;
  62. u8 port_rcv_constraint_errors;
  63. u8 reserved2;
  64. u8 link_overrun_errors; /* LocalLink: 7:4, BufferOverrun: 3:0 */
  65. __be16 reserved3;
  66. __be16 vl15_dropped;
  67. __be64 port_xmit_data;
  68. __be64 port_rcv_data;
  69. __be64 port_xmit_packets;
  70. __be64 port_rcv_packets;
  71. __be64 port_xmit_wait;
  72. __be64 port_adr_events;
  73. } __packed;
  74. #define IB_PMA_CONG_HW_CONTROL_TIMER 0x00
  75. #define IB_PMA_CONG_HW_CONTROL_SAMPLE 0x01
  76. #define QIB_XMIT_RATE_UNSUPPORTED 0x0
  77. #define QIB_XMIT_RATE_PICO 0x7
  78. /* number of 4nsec cycles equaling 2secs */
  79. #define QIB_CONG_TIMER_PSINTERVAL 0x1DCD64EC
  80. #define IB_PMA_SEL_CONG_ALL 0x01
  81. #define IB_PMA_SEL_CONG_PORT_DATA 0x02
  82. #define IB_PMA_SEL_CONG_XMIT 0x04
  83. #define IB_PMA_SEL_CONG_ROUTING 0x08
  84. /*
  85. * Congestion control class attributes
  86. */
  87. #define IB_CC_ATTR_CLASSPORTINFO cpu_to_be16(0x0001)
  88. #define IB_CC_ATTR_NOTICE cpu_to_be16(0x0002)
  89. #define IB_CC_ATTR_CONGESTION_INFO cpu_to_be16(0x0011)
  90. #define IB_CC_ATTR_CONGESTION_KEY_INFO cpu_to_be16(0x0012)
  91. #define IB_CC_ATTR_CONGESTION_LOG cpu_to_be16(0x0013)
  92. #define IB_CC_ATTR_SWITCH_CONGESTION_SETTING cpu_to_be16(0x0014)
  93. #define IB_CC_ATTR_SWITCH_PORT_CONGESTION_SETTING cpu_to_be16(0x0015)
  94. #define IB_CC_ATTR_CA_CONGESTION_SETTING cpu_to_be16(0x0016)
  95. #define IB_CC_ATTR_CONGESTION_CONTROL_TABLE cpu_to_be16(0x0017)
  96. #define IB_CC_ATTR_TIME_STAMP cpu_to_be16(0x0018)
  97. /* generalizations for threshold values */
  98. #define IB_CC_THRESHOLD_NONE 0x0
  99. #define IB_CC_THRESHOLD_MIN 0x1
  100. #define IB_CC_THRESHOLD_MAX 0xf
  101. /* CCA MAD header constants */
  102. #define IB_CC_MAD_LOGDATA_LEN 32
  103. #define IB_CC_MAD_MGMTDATA_LEN 192
  104. struct ib_cc_mad {
  105. u8 base_version;
  106. u8 mgmt_class;
  107. u8 class_version;
  108. u8 method;
  109. __be16 status;
  110. __be16 class_specific;
  111. __be64 tid;
  112. __be16 attr_id;
  113. __be16 resv;
  114. __be32 attr_mod;
  115. __be64 cckey;
  116. /* For CongestionLog attribute only */
  117. u8 log_data[IB_CC_MAD_LOGDATA_LEN];
  118. u8 mgmt_data[IB_CC_MAD_MGMTDATA_LEN];
  119. } __packed;
  120. /*
  121. * Congestion Control class portinfo capability mask bits
  122. */
  123. #define IB_CC_CPI_CM_TRAP_GEN cpu_to_be16(1 << 0)
  124. #define IB_CC_CPI_CM_GET_SET_NOTICE cpu_to_be16(1 << 1)
  125. #define IB_CC_CPI_CM_CAP2 cpu_to_be16(1 << 2)
  126. #define IB_CC_CPI_CM_ENHANCEDPORT0_CC cpu_to_be16(1 << 8)
  127. struct ib_cc_classportinfo_attr {
  128. u8 base_version;
  129. u8 class_version;
  130. __be16 cap_mask;
  131. u8 reserved[3];
  132. u8 resp_time_value; /* only lower 5 bits */
  133. union ib_gid redirect_gid;
  134. __be32 redirect_tc_sl_fl; /* 8, 4, 20 bits respectively */
  135. __be16 redirect_lid;
  136. __be16 redirect_pkey;
  137. __be32 redirect_qp; /* only lower 24 bits */
  138. __be32 redirect_qkey;
  139. union ib_gid trap_gid;
  140. __be32 trap_tc_sl_fl; /* 8, 4, 20 bits respectively */
  141. __be16 trap_lid;
  142. __be16 trap_pkey;
  143. __be32 trap_hl_qp; /* 8, 24 bits respectively */
  144. __be32 trap_qkey;
  145. } __packed;
  146. /* Congestion control traps */
  147. #define IB_CC_TRAP_KEY_VIOLATION 0x0000
  148. struct ib_cc_trap_key_violation_attr {
  149. __be16 source_lid;
  150. u8 method;
  151. u8 reserved1;
  152. __be16 attrib_id;
  153. __be32 attrib_mod;
  154. __be32 qp;
  155. __be64 cckey;
  156. u8 sgid[16];
  157. u8 padding[24];
  158. } __packed;
  159. /* Congestion info flags */
  160. #define IB_CC_CI_FLAGS_CREDIT_STARVATION 0x1
  161. #define IB_CC_TABLE_CAP_DEFAULT 31
  162. struct ib_cc_info_attr {
  163. __be16 congestion_info;
  164. u8 control_table_cap; /* Multiple of 64 entry unit CCTs */
  165. } __packed;
  166. struct ib_cc_key_info_attr {
  167. __be64 cckey;
  168. u8 protect;
  169. __be16 lease_period;
  170. __be16 violations;
  171. } __packed;
  172. #define IB_CC_CL_CA_LOGEVENTS_LEN 208
  173. struct ib_cc_log_attr {
  174. u8 log_type;
  175. u8 congestion_flags;
  176. __be16 threshold_event_counter;
  177. __be16 threshold_congestion_event_map;
  178. __be16 current_time_stamp;
  179. u8 log_events[IB_CC_CL_CA_LOGEVENTS_LEN];
  180. } __packed;
  181. #define IB_CC_CLEC_SERVICETYPE_RC 0x0
  182. #define IB_CC_CLEC_SERVICETYPE_UC 0x1
  183. #define IB_CC_CLEC_SERVICETYPE_RD 0x2
  184. #define IB_CC_CLEC_SERVICETYPE_UD 0x3
  185. struct ib_cc_log_event {
  186. u8 local_qp_cn_entry;
  187. u8 remote_qp_number_cn_entry[3];
  188. u8 sl_cn_entry:4;
  189. u8 service_type_cn_entry:4;
  190. __be32 remote_lid_cn_entry;
  191. __be32 timestamp_cn_entry;
  192. } __packed;
  193. /* Sixteen congestion entries */
  194. #define IB_CC_CCS_ENTRIES 16
  195. /* Port control flags */
  196. #define IB_CC_CCS_PC_SL_BASED 0x01
  197. struct ib_cc_congestion_entry {
  198. u8 ccti_increase;
  199. __be16 ccti_timer;
  200. u8 trigger_threshold;
  201. u8 ccti_min; /* min CCTI for cc table */
  202. } __packed;
  203. struct ib_cc_congestion_entry_shadow {
  204. u8 ccti_increase;
  205. u16 ccti_timer;
  206. u8 trigger_threshold;
  207. u8 ccti_min; /* min CCTI for cc table */
  208. } __packed;
  209. struct ib_cc_congestion_setting_attr {
  210. __be16 port_control;
  211. __be16 control_map;
  212. struct ib_cc_congestion_entry entries[IB_CC_CCS_ENTRIES];
  213. } __packed;
  214. struct ib_cc_congestion_setting_attr_shadow {
  215. u16 port_control;
  216. u16 control_map;
  217. struct ib_cc_congestion_entry_shadow entries[IB_CC_CCS_ENTRIES];
  218. } __packed;
  219. #define IB_CC_TABLE_ENTRY_INCREASE_DEFAULT 1
  220. #define IB_CC_TABLE_ENTRY_TIMER_DEFAULT 1
  221. /* 64 Congestion Control table entries in a single MAD */
  222. #define IB_CCT_ENTRIES 64
  223. #define IB_CCT_MIN_ENTRIES (IB_CCT_ENTRIES * 2)
  224. struct ib_cc_table_entry {
  225. __be16 entry; /* shift:2, multiplier:14 */
  226. };
  227. struct ib_cc_table_entry_shadow {
  228. u16 entry; /* shift:2, multiplier:14 */
  229. };
  230. struct ib_cc_table_attr {
  231. __be16 ccti_limit; /* max CCTI for cc table */
  232. struct ib_cc_table_entry ccti_entries[IB_CCT_ENTRIES];
  233. } __packed;
  234. struct ib_cc_table_attr_shadow {
  235. u16 ccti_limit; /* max CCTI for cc table */
  236. struct ib_cc_table_entry_shadow ccti_entries[IB_CCT_ENTRIES];
  237. } __packed;
  238. #define CC_TABLE_SHADOW_MAX \
  239. (IB_CC_TABLE_CAP_DEFAULT * IB_CCT_ENTRIES)
  240. struct cc_table_shadow {
  241. u16 ccti_last_entry;
  242. struct ib_cc_table_entry_shadow entries[CC_TABLE_SHADOW_MAX];
  243. } __packed;
  244. /*
  245. * The PortSamplesControl.CounterMasks field is an array of 3 bit fields
  246. * which specify the N'th counter's capabilities. See ch. 16.1.3.2.
  247. * We support 5 counters which only count the mandatory quantities.
  248. */
  249. #define COUNTER_MASK(q, n) (q << ((9 - n) * 3))
  250. #define COUNTER_MASK0_9 \
  251. cpu_to_be32(COUNTER_MASK(1, 0) | \
  252. COUNTER_MASK(1, 1) | \
  253. COUNTER_MASK(1, 2) | \
  254. COUNTER_MASK(1, 3) | \
  255. COUNTER_MASK(1, 4))
  256. #endif /* _QIB_MAD_H */