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.
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:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
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.
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
37 #include <rdma/ib_pma.h>
39 #define IB_SMP_UNSUP_VERSION cpu_to_be16(0x0004)
40 #define IB_SMP_UNSUP_METHOD cpu_to_be16(0x0008)
41 #define IB_SMP_UNSUP_METH_ATTR cpu_to_be16(0x000C)
42 #define IB_SMP_INVALID_FIELD cpu_to_be16(0x001C)
57 } __attribute__ ((packed
));
59 struct ib_mad_notice_attr
{
74 __be16 lid
; /* where violation happened */
75 u8 port_num
; /* where violation happened */
76 } __attribute__ ((packed
)) ntc_129_131
;
80 __be16 lid
; /* LID where change occurred */
82 u8 local_changes
; /* low bit - local changes */
83 __be32 new_cap_mask
; /* new capability mask */
85 u8 change_flags
; /* low 3 bits only */
86 } __attribute__ ((packed
)) ntc_144
;
90 __be16 lid
; /* lid where sys guid changed */
93 } __attribute__ ((packed
)) ntc_145
;
107 } __attribute__ ((packed
)) ntc_256
;
114 __be32 sl_qp1
; /* SL: high 4 bits */
115 __be32 qp2
; /* high 8 bits reserved */
118 } __attribute__ ((packed
)) ntc_257_258
;
124 * Generic trap/notice types
126 #define IB_NOTICE_TYPE_FATAL 0x80
127 #define IB_NOTICE_TYPE_URGENT 0x81
128 #define IB_NOTICE_TYPE_SECURITY 0x82
129 #define IB_NOTICE_TYPE_SM 0x83
130 #define IB_NOTICE_TYPE_INFO 0x84
133 * Generic trap/notice producers
135 #define IB_NOTICE_PROD_CA cpu_to_be16(1)
136 #define IB_NOTICE_PROD_SWITCH cpu_to_be16(2)
137 #define IB_NOTICE_PROD_ROUTER cpu_to_be16(3)
138 #define IB_NOTICE_PROD_CLASS_MGR cpu_to_be16(4)
141 * Generic trap/notice numbers
143 #define IB_NOTICE_TRAP_LLI_THRESH cpu_to_be16(129)
144 #define IB_NOTICE_TRAP_EBO_THRESH cpu_to_be16(130)
145 #define IB_NOTICE_TRAP_FLOW_UPDATE cpu_to_be16(131)
146 #define IB_NOTICE_TRAP_CAP_MASK_CHG cpu_to_be16(144)
147 #define IB_NOTICE_TRAP_SYS_GUID_CHG cpu_to_be16(145)
148 #define IB_NOTICE_TRAP_BAD_MKEY cpu_to_be16(256)
149 #define IB_NOTICE_TRAP_BAD_PKEY cpu_to_be16(257)
150 #define IB_NOTICE_TRAP_BAD_QKEY cpu_to_be16(258)
153 * Repress trap/notice flags
155 #define IB_NOTICE_REPRESS_LLI_THRESH (1 << 0)
156 #define IB_NOTICE_REPRESS_EBO_THRESH (1 << 1)
157 #define IB_NOTICE_REPRESS_FLOW_UPDATE (1 << 2)
158 #define IB_NOTICE_REPRESS_CAP_MASK_CHG (1 << 3)
159 #define IB_NOTICE_REPRESS_SYS_GUID_CHG (1 << 4)
160 #define IB_NOTICE_REPRESS_BAD_MKEY (1 << 5)
161 #define IB_NOTICE_REPRESS_BAD_PKEY (1 << 6)
162 #define IB_NOTICE_REPRESS_BAD_QKEY (1 << 7)
165 * Generic trap/notice other local changes flags (trap 144).
167 #define IB_NOTICE_TRAP_LSE_CHG 0x04 /* Link Speed Enable changed */
168 #define IB_NOTICE_TRAP_LWE_CHG 0x02 /* Link Width Enable changed */
169 #define IB_NOTICE_TRAP_NODE_DESC_CHG 0x01
172 * Generic trap/notice M_Key volation flags in dr_trunc_hop (trap 256).
174 #define IB_NOTICE_TRAP_DR_NOTICE 0x80
175 #define IB_NOTICE_TRAP_DR_TRUNC 0x40
177 struct ib_vl_weight_elem
{
178 u8 vl
; /* Only low 4 bits, upper 4 bits reserved */
182 #define IB_VLARB_LOWPRI_0_31 1
183 #define IB_VLARB_LOWPRI_32_63 2
184 #define IB_VLARB_HIGHPRI_0_31 3
185 #define IB_VLARB_HIGHPRI_32_63 4
187 #define IB_PMA_PORT_COUNTERS_CONG cpu_to_be16(0xFF00)
189 struct ib_pma_portcounters_cong
{
192 __be16 port_check_rate
;
193 __be16 symbol_error_counter
;
194 u8 link_error_recovery_counter
;
195 u8 link_downed_counter
;
196 __be16 port_rcv_errors
;
197 __be16 port_rcv_remphys_errors
;
198 __be16 port_rcv_switch_relay_errors
;
199 __be16 port_xmit_discards
;
200 u8 port_xmit_constraint_errors
;
201 u8 port_rcv_constraint_errors
;
203 u8 link_overrun_errors
; /* LocalLink: 7:4, BufferOverrun: 3:0 */
206 __be64 port_xmit_data
;
207 __be64 port_rcv_data
;
208 __be64 port_xmit_packets
;
209 __be64 port_rcv_packets
;
210 __be64 port_xmit_wait
;
211 __be64 port_adr_events
;
212 } __attribute__ ((packed
));
214 #define IB_PMA_CONG_HW_CONTROL_TIMER 0x00
215 #define IB_PMA_CONG_HW_CONTROL_SAMPLE 0x01
217 #define QIB_XMIT_RATE_UNSUPPORTED 0x0
218 #define QIB_XMIT_RATE_PICO 0x7
219 /* number of 4nsec cycles equaling 2secs */
220 #define QIB_CONG_TIMER_PSINTERVAL 0x1DCD64EC
222 #define IB_PMA_SEL_CONG_ALL 0x01
223 #define IB_PMA_SEL_CONG_PORT_DATA 0x02
224 #define IB_PMA_SEL_CONG_XMIT 0x04
225 #define IB_PMA_SEL_CONG_ROUTING 0x08
228 * Congestion control class attributes
230 #define IB_CC_ATTR_CLASSPORTINFO cpu_to_be16(0x0001)
231 #define IB_CC_ATTR_NOTICE cpu_to_be16(0x0002)
232 #define IB_CC_ATTR_CONGESTION_INFO cpu_to_be16(0x0011)
233 #define IB_CC_ATTR_CONGESTION_KEY_INFO cpu_to_be16(0x0012)
234 #define IB_CC_ATTR_CONGESTION_LOG cpu_to_be16(0x0013)
235 #define IB_CC_ATTR_SWITCH_CONGESTION_SETTING cpu_to_be16(0x0014)
236 #define IB_CC_ATTR_SWITCH_PORT_CONGESTION_SETTING cpu_to_be16(0x0015)
237 #define IB_CC_ATTR_CA_CONGESTION_SETTING cpu_to_be16(0x0016)
238 #define IB_CC_ATTR_CONGESTION_CONTROL_TABLE cpu_to_be16(0x0017)
239 #define IB_CC_ATTR_TIME_STAMP cpu_to_be16(0x0018)
241 /* generalizations for threshold values */
242 #define IB_CC_THRESHOLD_NONE 0x0
243 #define IB_CC_THRESHOLD_MIN 0x1
244 #define IB_CC_THRESHOLD_MAX 0xf
246 /* CCA MAD header constants */
247 #define IB_CC_MAD_LOGDATA_LEN 32
248 #define IB_CC_MAD_MGMTDATA_LEN 192
256 __be16 class_specific
;
263 /* For CongestionLog attribute only */
264 u8 log_data
[IB_CC_MAD_LOGDATA_LEN
];
266 u8 mgmt_data
[IB_CC_MAD_MGMTDATA_LEN
];
270 * Congestion Control class portinfo capability mask bits
272 #define IB_CC_CPI_CM_TRAP_GEN cpu_to_be16(1 << 0)
273 #define IB_CC_CPI_CM_GET_SET_NOTICE cpu_to_be16(1 << 1)
274 #define IB_CC_CPI_CM_CAP2 cpu_to_be16(1 << 2)
275 #define IB_CC_CPI_CM_ENHANCEDPORT0_CC cpu_to_be16(1 << 8)
277 struct ib_cc_classportinfo_attr
{
282 u8 resp_time_value
; /* only lower 5 bits */
283 union ib_gid redirect_gid
;
284 __be32 redirect_tc_sl_fl
; /* 8, 4, 20 bits respectively */
286 __be16 redirect_pkey
;
287 __be32 redirect_qp
; /* only lower 24 bits */
288 __be32 redirect_qkey
;
289 union ib_gid trap_gid
;
290 __be32 trap_tc_sl_fl
; /* 8, 4, 20 bits respectively */
293 __be32 trap_hl_qp
; /* 8, 24 bits respectively */
297 /* Congestion control traps */
298 #define IB_CC_TRAP_KEY_VIOLATION 0x0000
300 struct ib_cc_trap_key_violation_attr
{
312 /* Congestion info flags */
313 #define IB_CC_CI_FLAGS_CREDIT_STARVATION 0x1
314 #define IB_CC_TABLE_CAP_DEFAULT 31
316 struct ib_cc_info_attr
{
317 __be16 congestion_info
;
318 u8 control_table_cap
; /* Multiple of 64 entry unit CCTs */
321 struct ib_cc_key_info_attr
{
328 #define IB_CC_CL_CA_LOGEVENTS_LEN 208
330 struct ib_cc_log_attr
{
333 __be16 threshold_event_counter
;
334 __be16 threshold_congestion_event_map
;
335 __be16 current_time_stamp
;
336 u8 log_events
[IB_CC_CL_CA_LOGEVENTS_LEN
];
339 #define IB_CC_CLEC_SERVICETYPE_RC 0x0
340 #define IB_CC_CLEC_SERVICETYPE_UC 0x1
341 #define IB_CC_CLEC_SERVICETYPE_RD 0x2
342 #define IB_CC_CLEC_SERVICETYPE_UD 0x3
344 struct ib_cc_log_event
{
345 u8 local_qp_cn_entry
;
346 u8 remote_qp_number_cn_entry
[3];
348 u8 service_type_cn_entry
:4;
349 __be32 remote_lid_cn_entry
;
350 __be32 timestamp_cn_entry
;
353 /* Sixteen congestion entries */
354 #define IB_CC_CCS_ENTRIES 16
356 /* Port control flags */
357 #define IB_CC_CCS_PC_SL_BASED 0x01
359 struct ib_cc_congestion_entry
{
362 u8 trigger_threshold
;
363 u8 ccti_min
; /* min CCTI for cc table */
366 struct ib_cc_congestion_entry_shadow
{
369 u8 trigger_threshold
;
370 u8 ccti_min
; /* min CCTI for cc table */
373 struct ib_cc_congestion_setting_attr
{
376 struct ib_cc_congestion_entry entries
[IB_CC_CCS_ENTRIES
];
379 struct ib_cc_congestion_setting_attr_shadow
{
382 struct ib_cc_congestion_entry_shadow entries
[IB_CC_CCS_ENTRIES
];
385 #define IB_CC_TABLE_ENTRY_INCREASE_DEFAULT 1
386 #define IB_CC_TABLE_ENTRY_TIMER_DEFAULT 1
388 /* 64 Congestion Control table entries in a single MAD */
389 #define IB_CCT_ENTRIES 64
390 #define IB_CCT_MIN_ENTRIES (IB_CCT_ENTRIES * 2)
392 struct ib_cc_table_entry
{
393 __be16 entry
; /* shift:2, multiplier:14 */
396 struct ib_cc_table_entry_shadow
{
397 u16 entry
; /* shift:2, multiplier:14 */
400 struct ib_cc_table_attr
{
401 __be16 ccti_limit
; /* max CCTI for cc table */
402 struct ib_cc_table_entry ccti_entries
[IB_CCT_ENTRIES
];
405 struct ib_cc_table_attr_shadow
{
406 u16 ccti_limit
; /* max CCTI for cc table */
407 struct ib_cc_table_entry_shadow ccti_entries
[IB_CCT_ENTRIES
];
410 #define CC_TABLE_SHADOW_MAX \
411 (IB_CC_TABLE_CAP_DEFAULT * IB_CCT_ENTRIES)
413 struct cc_table_shadow
{
415 struct ib_cc_table_entry_shadow entries
[CC_TABLE_SHADOW_MAX
];
418 #endif /* _QIB_MAD_H */
420 * The PortSamplesControl.CounterMasks field is an array of 3 bit fields
421 * which specify the N'th counter's capabilities. See ch. 16.1.3.2.
422 * We support 5 counters which only count the mandatory quantities.
424 #define COUNTER_MASK(q, n) (q << ((9 - n) * 3))
425 #define COUNTER_MASK0_9 \
426 cpu_to_be32(COUNTER_MASK(1, 0) | \
427 COUNTER_MASK(1, 1) | \
428 COUNTER_MASK(1, 2) | \
429 COUNTER_MASK(1, 3) | \