0001
0002
0003
0004
0005
0006 #ifndef _HFI1_MAD_H
0007 #define _HFI1_MAD_H
0008
0009 #include <rdma/ib_pma.h>
0010 #include <rdma/opa_smi.h>
0011 #include <rdma/opa_port_info.h>
0012 #include "opa_compat.h"
0013
0014
0015
0016
0017 #define OPA_TRAP_GID_NOW_IN_SERVICE cpu_to_be16(64)
0018 #define OPA_TRAP_GID_OUT_OF_SERVICE cpu_to_be16(65)
0019 #define OPA_TRAP_ADD_MULTICAST_GROUP cpu_to_be16(66)
0020 #define OPA_TRAL_DEL_MULTICAST_GROUP cpu_to_be16(67)
0021 #define OPA_TRAP_UNPATH cpu_to_be16(68)
0022 #define OPA_TRAP_REPATH cpu_to_be16(69)
0023 #define OPA_TRAP_PORT_CHANGE_STATE cpu_to_be16(128)
0024 #define OPA_TRAP_LINK_INTEGRITY cpu_to_be16(129)
0025 #define OPA_TRAP_EXCESSIVE_BUFFER_OVERRUN cpu_to_be16(130)
0026 #define OPA_TRAP_FLOW_WATCHDOG cpu_to_be16(131)
0027 #define OPA_TRAP_CHANGE_CAPABILITY cpu_to_be16(144)
0028 #define OPA_TRAP_CHANGE_SYSGUID cpu_to_be16(145)
0029 #define OPA_TRAP_BAD_M_KEY cpu_to_be16(256)
0030 #define OPA_TRAP_BAD_P_KEY cpu_to_be16(257)
0031 #define OPA_TRAP_BAD_Q_KEY cpu_to_be16(258)
0032 #define OPA_TRAP_SWITCH_BAD_PKEY cpu_to_be16(259)
0033 #define OPA_SMA_TRAP_DATA_LINK_WIDTH cpu_to_be16(2048)
0034
0035
0036
0037
0038 #define OPA_NOTICE_TRAP_LWDE_CHG 0x08
0039
0040
0041 #define OPA_NOTICE_TRAP_LSE_CHG 0x04
0042 #define OPA_NOTICE_TRAP_LWE_CHG 0x02
0043 #define OPA_NOTICE_TRAP_NODE_DESC_CHG 0x01
0044
0045 struct opa_mad_notice_attr {
0046 u8 generic_type;
0047 u8 prod_type_msb;
0048 __be16 prod_type_lsb;
0049 __be16 trap_num;
0050 __be16 toggle_count;
0051 __be32 issuer_lid;
0052 __be32 reserved1;
0053 union ib_gid issuer_gid;
0054
0055 union {
0056 struct {
0057 u8 details[64];
0058 } raw_data;
0059
0060 struct {
0061 union ib_gid gid;
0062 } __packed ntc_64_65_66_67;
0063
0064 struct {
0065 __be32 lid;
0066 } __packed ntc_128;
0067
0068 struct {
0069 __be32 lid;
0070 u8 port_num;
0071 } __packed ntc_129_130_131;
0072
0073 struct {
0074 __be32 lid;
0075 __be32 new_cap_mask;
0076 __be16 reserved2;
0077 __be16 cap_mask3;
0078 __be16 change_flags;
0079 } __packed ntc_144;
0080
0081 struct {
0082 __be64 new_sys_guid;
0083 __be32 lid;
0084 } __packed ntc_145;
0085
0086 struct {
0087 __be32 lid;
0088 __be32 dr_slid;
0089 u8 method;
0090 u8 dr_trunc_hop;
0091 __be16 attr_id;
0092 __be32 attr_mod;
0093 __be64 mkey;
0094 u8 dr_rtn_path[30];
0095 } __packed ntc_256;
0096
0097 struct {
0098 __be32 lid1;
0099 __be32 lid2;
0100 __be32 key;
0101 u8 sl;
0102 u8 reserved3[3];
0103 union ib_gid gid1;
0104 union ib_gid gid2;
0105 __be32 qp1;
0106 __be32 qp2;
0107 } __packed ntc_257_258;
0108
0109 struct {
0110 __be16 flags;
0111 __be16 pkey;
0112 __be32 lid1;
0113 __be32 lid2;
0114 u8 sl;
0115 u8 reserved4[3];
0116 union ib_gid gid1;
0117 union ib_gid gid2;
0118 __be32 qp1;
0119 __be32 qp2;
0120 } __packed ntc_259;
0121
0122 struct {
0123 __be32 lid;
0124 } __packed ntc_2048;
0125
0126 };
0127 u8 class_data[];
0128 };
0129
0130 #define IB_VLARB_LOWPRI_0_31 1
0131 #define IB_VLARB_LOWPRI_32_63 2
0132 #define IB_VLARB_HIGHPRI_0_31 3
0133 #define IB_VLARB_HIGHPRI_32_63 4
0134
0135 #define OPA_MAX_PREEMPT_CAP 32
0136 #define OPA_VLARB_LOW_ELEMENTS 0
0137 #define OPA_VLARB_HIGH_ELEMENTS 1
0138 #define OPA_VLARB_PREEMPT_ELEMENTS 2
0139 #define OPA_VLARB_PREEMPT_MATRIX 3
0140
0141 #define IB_PMA_PORT_COUNTERS_CONG cpu_to_be16(0xFF00)
0142 #define LINK_SPEED_25G 1
0143 #define LINK_SPEED_12_5G 2
0144 #define LINK_WIDTH_DEFAULT 4
0145 #define DECIMAL_FACTORING 1000
0146
0147
0148
0149
0150 #define FACTOR_LINK_WIDTH (LINK_WIDTH_DEFAULT * DECIMAL_FACTORING)
0151
0152 struct ib_pma_portcounters_cong {
0153 u8 reserved;
0154 u8 reserved1;
0155 __be16 port_check_rate;
0156 __be16 symbol_error_counter;
0157 u8 link_error_recovery_counter;
0158 u8 link_downed_counter;
0159 __be16 port_rcv_errors;
0160 __be16 port_rcv_remphys_errors;
0161 __be16 port_rcv_switch_relay_errors;
0162 __be16 port_xmit_discards;
0163 u8 port_xmit_constraint_errors;
0164 u8 port_rcv_constraint_errors;
0165 u8 reserved2;
0166 u8 link_overrun_errors;
0167 __be16 reserved3;
0168 __be16 vl15_dropped;
0169 __be64 port_xmit_data;
0170 __be64 port_rcv_data;
0171 __be64 port_xmit_packets;
0172 __be64 port_rcv_packets;
0173 __be64 port_xmit_wait;
0174 __be64 port_adr_events;
0175 } __packed;
0176
0177 #define IB_SMP_UNSUP_VERSION cpu_to_be16(0x0004)
0178 #define IB_SMP_UNSUP_METHOD cpu_to_be16(0x0008)
0179 #define IB_SMP_UNSUP_METH_ATTR cpu_to_be16(0x000C)
0180 #define IB_SMP_INVALID_FIELD cpu_to_be16(0x001C)
0181
0182 #define OPA_MAX_PREEMPT_CAP 32
0183 #define OPA_VLARB_LOW_ELEMENTS 0
0184 #define OPA_VLARB_HIGH_ELEMENTS 1
0185 #define OPA_VLARB_PREEMPT_ELEMENTS 2
0186 #define OPA_VLARB_PREEMPT_MATRIX 3
0187
0188 #define HFI1_XMIT_RATE_UNSUPPORTED 0x0
0189 #define HFI1_XMIT_RATE_PICO 0x7
0190
0191 #define HFI1_CONG_TIMER_PSINTERVAL 0x1DCD64EC
0192
0193 #define IB_CC_SVCTYPE_RC 0x0
0194 #define IB_CC_SVCTYPE_UC 0x1
0195 #define IB_CC_SVCTYPE_RD 0x2
0196 #define IB_CC_SVCTYPE_UD 0x3
0197
0198
0199
0200
0201
0202 #define OPA_CC_LOG_TYPE_HFI 2
0203
0204 struct opa_hfi1_cong_log_event_internal {
0205 u32 lqpn;
0206 u32 rqpn;
0207 u8 sl;
0208 u8 svc_type;
0209 u32 rlid;
0210 u64 timestamp;
0211 };
0212
0213 struct opa_hfi1_cong_log_event {
0214 u8 local_qp_cn_entry[3];
0215 u8 remote_qp_number_cn_entry[3];
0216 u8 sl_svc_type_cn_entry;
0217 u8 reserved;
0218 __be32 remote_lid_cn_entry;
0219 __be32 timestamp_cn_entry;
0220 } __packed;
0221
0222 #define OPA_CONG_LOG_ELEMS 96
0223
0224 struct opa_hfi1_cong_log {
0225 u8 log_type;
0226 u8 congestion_flags;
0227 __be16 threshold_event_counter;
0228 __be32 current_time_stamp;
0229 u8 threshold_cong_event_map[OPA_MAX_SLS / 8];
0230 struct opa_hfi1_cong_log_event events[OPA_CONG_LOG_ELEMS];
0231 } __packed;
0232
0233 #define IB_CC_TABLE_CAP_DEFAULT 31
0234
0235
0236 #define IB_CC_CCS_PC_SL_BASED 0x01
0237
0238 struct opa_congestion_setting_entry {
0239 u8 ccti_increase;
0240 u8 reserved;
0241 __be16 ccti_timer;
0242 u8 trigger_threshold;
0243 u8 ccti_min;
0244 } __packed;
0245
0246 struct opa_congestion_setting_entry_shadow {
0247 u8 ccti_increase;
0248 u8 reserved;
0249 u16 ccti_timer;
0250 u8 trigger_threshold;
0251 u8 ccti_min;
0252 } __packed;
0253
0254 struct opa_congestion_setting_attr {
0255 __be32 control_map;
0256 __be16 port_control;
0257 struct opa_congestion_setting_entry entries[OPA_MAX_SLS];
0258 } __packed;
0259
0260 struct opa_congestion_setting_attr_shadow {
0261 u32 control_map;
0262 u16 port_control;
0263 struct opa_congestion_setting_entry_shadow entries[OPA_MAX_SLS];
0264 } __packed;
0265
0266 #define IB_CC_TABLE_ENTRY_INCREASE_DEFAULT 1
0267 #define IB_CC_TABLE_ENTRY_TIMER_DEFAULT 1
0268
0269
0270 #define IB_CCT_ENTRIES 64
0271 #define IB_CCT_MIN_ENTRIES (IB_CCT_ENTRIES * 2)
0272
0273 struct ib_cc_table_entry {
0274 __be16 entry;
0275 };
0276
0277 struct ib_cc_table_entry_shadow {
0278 u16 entry;
0279 };
0280
0281 struct ib_cc_table_attr {
0282 __be16 ccti_limit;
0283 struct ib_cc_table_entry ccti_entries[IB_CCT_ENTRIES];
0284 } __packed;
0285
0286 struct ib_cc_table_attr_shadow {
0287 u16 ccti_limit;
0288 struct ib_cc_table_entry_shadow ccti_entries[IB_CCT_ENTRIES];
0289 } __packed;
0290
0291 #define CC_TABLE_SHADOW_MAX \
0292 (IB_CC_TABLE_CAP_DEFAULT * IB_CCT_ENTRIES)
0293
0294 struct cc_table_shadow {
0295 u16 ccti_limit;
0296 struct ib_cc_table_entry_shadow entries[CC_TABLE_SHADOW_MAX];
0297 } __packed;
0298
0299
0300
0301
0302
0303
0304
0305 struct cc_state {
0306 struct rcu_head rcu;
0307 struct cc_table_shadow cct;
0308 struct opa_congestion_setting_attr_shadow cong_setting;
0309 };
0310
0311
0312
0313
0314
0315
0316 #define OPA_AM_NPORT_SHIFT 24
0317 #define OPA_AM_NPORT_MASK 0xff
0318 #define OPA_AM_NPORT_SMASK (OPA_AM_NPORT_MASK << OPA_AM_NPORT_SHIFT)
0319 #define OPA_AM_NPORT(am) (((am) >> OPA_AM_NPORT_SHIFT) & \
0320 OPA_AM_NPORT_MASK)
0321
0322 #define OPA_AM_NBLK_SHIFT 24
0323 #define OPA_AM_NBLK_MASK 0xff
0324 #define OPA_AM_NBLK_SMASK (OPA_AM_NBLK_MASK << OPA_AM_NBLK_SHIFT)
0325 #define OPA_AM_NBLK(am) (((am) >> OPA_AM_NBLK_SHIFT) & \
0326 OPA_AM_NBLK_MASK)
0327
0328 #define OPA_AM_START_BLK_SHIFT 0
0329 #define OPA_AM_START_BLK_MASK 0xff
0330 #define OPA_AM_START_BLK_SMASK (OPA_AM_START_BLK_MASK << \
0331 OPA_AM_START_BLK_SHIFT)
0332 #define OPA_AM_START_BLK(am) (((am) >> OPA_AM_START_BLK_SHIFT) & \
0333 OPA_AM_START_BLK_MASK)
0334
0335 #define OPA_AM_PORTNUM_SHIFT 0
0336 #define OPA_AM_PORTNUM_MASK 0xff
0337 #define OPA_AM_PORTNUM_SMASK (OPA_AM_PORTNUM_MASK << OPA_AM_PORTNUM_SHIFT)
0338 #define OPA_AM_PORTNUM(am) (((am) >> OPA_AM_PORTNUM_SHIFT) & \
0339 OPA_AM_PORTNUM_MASK)
0340
0341 #define OPA_AM_ASYNC_SHIFT 12
0342 #define OPA_AM_ASYNC_MASK 0x1
0343 #define OPA_AM_ASYNC_SMASK (OPA_AM_ASYNC_MASK << OPA_AM_ASYNC_SHIFT)
0344 #define OPA_AM_ASYNC(am) (((am) >> OPA_AM_ASYNC_SHIFT) & \
0345 OPA_AM_ASYNC_MASK)
0346
0347 #define OPA_AM_START_SM_CFG_SHIFT 9
0348 #define OPA_AM_START_SM_CFG_MASK 0x1
0349 #define OPA_AM_START_SM_CFG_SMASK (OPA_AM_START_SM_CFG_MASK << \
0350 OPA_AM_START_SM_CFG_SHIFT)
0351 #define OPA_AM_START_SM_CFG(am) (((am) >> OPA_AM_START_SM_CFG_SHIFT) \
0352 & OPA_AM_START_SM_CFG_MASK)
0353
0354 #define OPA_AM_CI_ADDR_SHIFT 19
0355 #define OPA_AM_CI_ADDR_MASK 0xfff
0356 #define OPA_AM_CI_ADDR_SMASK (OPA_AM_CI_ADDR_MASK << OPA_CI_ADDR_SHIFT)
0357 #define OPA_AM_CI_ADDR(am) (((am) >> OPA_AM_CI_ADDR_SHIFT) & \
0358 OPA_AM_CI_ADDR_MASK)
0359
0360 #define OPA_AM_CI_LEN_SHIFT 13
0361 #define OPA_AM_CI_LEN_MASK 0x3f
0362 #define OPA_AM_CI_LEN_SMASK (OPA_AM_CI_LEN_MASK << OPA_CI_LEN_SHIFT)
0363 #define OPA_AM_CI_LEN(am) (((am) >> OPA_AM_CI_LEN_SHIFT) & \
0364 OPA_AM_CI_LEN_MASK)
0365
0366
0367 #define OPA_EI_STATUS_SMASK 0x80
0368 #define OPA_EI_CODE_SMASK 0x0f
0369
0370 struct vl_limit {
0371 __be16 dedicated;
0372 __be16 shared;
0373 };
0374
0375 struct buffer_control {
0376 __be16 reserved;
0377 __be16 overall_shared_limit;
0378 struct vl_limit vl[OPA_MAX_VLS];
0379 };
0380
0381 struct sc2vlnt {
0382 u8 vlnt[32];
0383 };
0384
0385
0386
0387
0388
0389
0390 #define COUNTER_MASK(q, n) (q << ((9 - n) * 3))
0391 #define COUNTER_MASK0_9 \
0392 cpu_to_be32(COUNTER_MASK(1, 0) | \
0393 COUNTER_MASK(1, 1) | \
0394 COUNTER_MASK(1, 2) | \
0395 COUNTER_MASK(1, 3) | \
0396 COUNTER_MASK(1, 4))
0397
0398 void hfi1_event_pkey_change(struct hfi1_devdata *dd, u32 port);
0399 void hfi1_handle_trap_timer(struct timer_list *t);
0400 u16 tx_link_width(u16 link_width);
0401 u64 get_xmit_wait_counters(struct hfi1_pportdata *ppd, u16 link_width,
0402 u16 link_speed, int vl);
0403
0404
0405
0406
0407
0408
0409
0410
0411
0412
0413
0414
0415
0416
0417 static inline u16 get_link_speed(u16 link_speed)
0418 {
0419 return (link_speed == 1) ?
0420 LINK_SPEED_12_5G : LINK_SPEED_25G;
0421 }
0422
0423
0424
0425
0426
0427
0428
0429
0430
0431 static inline u64 convert_xmit_counter(u64 xmit_wait_val, u16 link_width,
0432 u16 link_speed)
0433 {
0434 return (xmit_wait_val * 2 * (FACTOR_LINK_WIDTH / link_width)
0435 * link_speed) / DECIMAL_FACTORING;
0436 }
0437 #endif