162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Copyright (c) 2012 Intel Corporation. All rights reserved. 362306a36Sopenharmony_ci * Copyright (c) 2006 - 2012 QLogic Corporation. All rights reserved. 462306a36Sopenharmony_ci * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * This software is available to you under a choice of one of two 762306a36Sopenharmony_ci * licenses. You may choose to be licensed under the terms of the GNU 862306a36Sopenharmony_ci * General Public License (GPL) Version 2, available from the file 962306a36Sopenharmony_ci * COPYING in the main directory of this source tree, or the 1062306a36Sopenharmony_ci * OpenIB.org BSD license below: 1162306a36Sopenharmony_ci * 1262306a36Sopenharmony_ci * Redistribution and use in source and binary forms, with or 1362306a36Sopenharmony_ci * without modification, are permitted provided that the following 1462306a36Sopenharmony_ci * conditions are met: 1562306a36Sopenharmony_ci * 1662306a36Sopenharmony_ci * - Redistributions of source code must retain the above 1762306a36Sopenharmony_ci * copyright notice, this list of conditions and the following 1862306a36Sopenharmony_ci * disclaimer. 1962306a36Sopenharmony_ci * 2062306a36Sopenharmony_ci * - Redistributions in binary form must reproduce the above 2162306a36Sopenharmony_ci * copyright notice, this list of conditions and the following 2262306a36Sopenharmony_ci * disclaimer in the documentation and/or other materials 2362306a36Sopenharmony_ci * provided with the distribution. 2462306a36Sopenharmony_ci * 2562306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 2662306a36Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2762306a36Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2862306a36Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 2962306a36Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 3062306a36Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 3162306a36Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 3262306a36Sopenharmony_ci * SOFTWARE. 3362306a36Sopenharmony_ci */ 3462306a36Sopenharmony_ci#ifndef _QIB_MAD_H 3562306a36Sopenharmony_ci#define _QIB_MAD_H 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci#include <rdma/ib_pma.h> 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci#define IB_SMP_UNSUP_VERSION \ 4062306a36Sopenharmony_cicpu_to_be16(IB_MGMT_MAD_STATUS_BAD_VERSION) 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci#define IB_SMP_UNSUP_METHOD \ 4362306a36Sopenharmony_cicpu_to_be16(IB_MGMT_MAD_STATUS_UNSUPPORTED_METHOD) 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci#define IB_SMP_UNSUP_METH_ATTR \ 4662306a36Sopenharmony_cicpu_to_be16(IB_MGMT_MAD_STATUS_UNSUPPORTED_METHOD_ATTRIB) 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci#define IB_SMP_INVALID_FIELD \ 4962306a36Sopenharmony_cicpu_to_be16(IB_MGMT_MAD_STATUS_INVALID_ATTRIB_VALUE) 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci#define IB_VLARB_LOWPRI_0_31 1 5262306a36Sopenharmony_ci#define IB_VLARB_LOWPRI_32_63 2 5362306a36Sopenharmony_ci#define IB_VLARB_HIGHPRI_0_31 3 5462306a36Sopenharmony_ci#define IB_VLARB_HIGHPRI_32_63 4 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci#define IB_PMA_PORT_COUNTERS_CONG cpu_to_be16(0xFF00) 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_cistruct ib_pma_portcounters_cong { 5962306a36Sopenharmony_ci u8 reserved; 6062306a36Sopenharmony_ci u8 reserved1; 6162306a36Sopenharmony_ci __be16 port_check_rate; 6262306a36Sopenharmony_ci __be16 symbol_error_counter; 6362306a36Sopenharmony_ci u8 link_error_recovery_counter; 6462306a36Sopenharmony_ci u8 link_downed_counter; 6562306a36Sopenharmony_ci __be16 port_rcv_errors; 6662306a36Sopenharmony_ci __be16 port_rcv_remphys_errors; 6762306a36Sopenharmony_ci __be16 port_rcv_switch_relay_errors; 6862306a36Sopenharmony_ci __be16 port_xmit_discards; 6962306a36Sopenharmony_ci u8 port_xmit_constraint_errors; 7062306a36Sopenharmony_ci u8 port_rcv_constraint_errors; 7162306a36Sopenharmony_ci u8 reserved2; 7262306a36Sopenharmony_ci u8 link_overrun_errors; /* LocalLink: 7:4, BufferOverrun: 3:0 */ 7362306a36Sopenharmony_ci __be16 reserved3; 7462306a36Sopenharmony_ci __be16 vl15_dropped; 7562306a36Sopenharmony_ci __be64 port_xmit_data; 7662306a36Sopenharmony_ci __be64 port_rcv_data; 7762306a36Sopenharmony_ci __be64 port_xmit_packets; 7862306a36Sopenharmony_ci __be64 port_rcv_packets; 7962306a36Sopenharmony_ci __be64 port_xmit_wait; 8062306a36Sopenharmony_ci __be64 port_adr_events; 8162306a36Sopenharmony_ci} __packed; 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci#define IB_PMA_CONG_HW_CONTROL_TIMER 0x00 8462306a36Sopenharmony_ci#define IB_PMA_CONG_HW_CONTROL_SAMPLE 0x01 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci#define QIB_XMIT_RATE_UNSUPPORTED 0x0 8762306a36Sopenharmony_ci#define QIB_XMIT_RATE_PICO 0x7 8862306a36Sopenharmony_ci/* number of 4nsec cycles equaling 2secs */ 8962306a36Sopenharmony_ci#define QIB_CONG_TIMER_PSINTERVAL 0x1DCD64EC 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci#define IB_PMA_SEL_CONG_ALL 0x01 9262306a36Sopenharmony_ci#define IB_PMA_SEL_CONG_PORT_DATA 0x02 9362306a36Sopenharmony_ci#define IB_PMA_SEL_CONG_XMIT 0x04 9462306a36Sopenharmony_ci#define IB_PMA_SEL_CONG_ROUTING 0x08 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci/* 9762306a36Sopenharmony_ci * Congestion control class attributes 9862306a36Sopenharmony_ci */ 9962306a36Sopenharmony_ci#define IB_CC_ATTR_CLASSPORTINFO cpu_to_be16(0x0001) 10062306a36Sopenharmony_ci#define IB_CC_ATTR_NOTICE cpu_to_be16(0x0002) 10162306a36Sopenharmony_ci#define IB_CC_ATTR_CONGESTION_INFO cpu_to_be16(0x0011) 10262306a36Sopenharmony_ci#define IB_CC_ATTR_CONGESTION_KEY_INFO cpu_to_be16(0x0012) 10362306a36Sopenharmony_ci#define IB_CC_ATTR_CONGESTION_LOG cpu_to_be16(0x0013) 10462306a36Sopenharmony_ci#define IB_CC_ATTR_SWITCH_CONGESTION_SETTING cpu_to_be16(0x0014) 10562306a36Sopenharmony_ci#define IB_CC_ATTR_SWITCH_PORT_CONGESTION_SETTING cpu_to_be16(0x0015) 10662306a36Sopenharmony_ci#define IB_CC_ATTR_CA_CONGESTION_SETTING cpu_to_be16(0x0016) 10762306a36Sopenharmony_ci#define IB_CC_ATTR_CONGESTION_CONTROL_TABLE cpu_to_be16(0x0017) 10862306a36Sopenharmony_ci#define IB_CC_ATTR_TIME_STAMP cpu_to_be16(0x0018) 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci/* generalizations for threshold values */ 11162306a36Sopenharmony_ci#define IB_CC_THRESHOLD_NONE 0x0 11262306a36Sopenharmony_ci#define IB_CC_THRESHOLD_MIN 0x1 11362306a36Sopenharmony_ci#define IB_CC_THRESHOLD_MAX 0xf 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci/* CCA MAD header constants */ 11662306a36Sopenharmony_ci#define IB_CC_MAD_LOGDATA_LEN 32 11762306a36Sopenharmony_ci#define IB_CC_MAD_MGMTDATA_LEN 192 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_cistruct ib_cc_mad { 12062306a36Sopenharmony_ci u8 base_version; 12162306a36Sopenharmony_ci u8 mgmt_class; 12262306a36Sopenharmony_ci u8 class_version; 12362306a36Sopenharmony_ci u8 method; 12462306a36Sopenharmony_ci __be16 status; 12562306a36Sopenharmony_ci __be16 class_specific; 12662306a36Sopenharmony_ci __be64 tid; 12762306a36Sopenharmony_ci __be16 attr_id; 12862306a36Sopenharmony_ci __be16 resv; 12962306a36Sopenharmony_ci __be32 attr_mod; 13062306a36Sopenharmony_ci __be64 cckey; 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci /* For CongestionLog attribute only */ 13362306a36Sopenharmony_ci u8 log_data[IB_CC_MAD_LOGDATA_LEN]; 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_ci u8 mgmt_data[IB_CC_MAD_MGMTDATA_LEN]; 13662306a36Sopenharmony_ci} __packed; 13762306a36Sopenharmony_ci 13862306a36Sopenharmony_ci/* 13962306a36Sopenharmony_ci * Congestion Control class portinfo capability mask bits 14062306a36Sopenharmony_ci */ 14162306a36Sopenharmony_ci#define IB_CC_CPI_CM_TRAP_GEN cpu_to_be16(1 << 0) 14262306a36Sopenharmony_ci#define IB_CC_CPI_CM_GET_SET_NOTICE cpu_to_be16(1 << 1) 14362306a36Sopenharmony_ci#define IB_CC_CPI_CM_CAP2 cpu_to_be16(1 << 2) 14462306a36Sopenharmony_ci#define IB_CC_CPI_CM_ENHANCEDPORT0_CC cpu_to_be16(1 << 8) 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_cistruct ib_cc_classportinfo_attr { 14762306a36Sopenharmony_ci u8 base_version; 14862306a36Sopenharmony_ci u8 class_version; 14962306a36Sopenharmony_ci __be16 cap_mask; 15062306a36Sopenharmony_ci u8 reserved[3]; 15162306a36Sopenharmony_ci u8 resp_time_value; /* only lower 5 bits */ 15262306a36Sopenharmony_ci union ib_gid redirect_gid; 15362306a36Sopenharmony_ci __be32 redirect_tc_sl_fl; /* 8, 4, 20 bits respectively */ 15462306a36Sopenharmony_ci __be16 redirect_lid; 15562306a36Sopenharmony_ci __be16 redirect_pkey; 15662306a36Sopenharmony_ci __be32 redirect_qp; /* only lower 24 bits */ 15762306a36Sopenharmony_ci __be32 redirect_qkey; 15862306a36Sopenharmony_ci union ib_gid trap_gid; 15962306a36Sopenharmony_ci __be32 trap_tc_sl_fl; /* 8, 4, 20 bits respectively */ 16062306a36Sopenharmony_ci __be16 trap_lid; 16162306a36Sopenharmony_ci __be16 trap_pkey; 16262306a36Sopenharmony_ci __be32 trap_hl_qp; /* 8, 24 bits respectively */ 16362306a36Sopenharmony_ci __be32 trap_qkey; 16462306a36Sopenharmony_ci} __packed; 16562306a36Sopenharmony_ci 16662306a36Sopenharmony_ci/* Congestion control traps */ 16762306a36Sopenharmony_ci#define IB_CC_TRAP_KEY_VIOLATION 0x0000 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_cistruct ib_cc_trap_key_violation_attr { 17062306a36Sopenharmony_ci __be16 source_lid; 17162306a36Sopenharmony_ci u8 method; 17262306a36Sopenharmony_ci u8 reserved1; 17362306a36Sopenharmony_ci __be16 attrib_id; 17462306a36Sopenharmony_ci __be32 attrib_mod; 17562306a36Sopenharmony_ci __be32 qp; 17662306a36Sopenharmony_ci __be64 cckey; 17762306a36Sopenharmony_ci u8 sgid[16]; 17862306a36Sopenharmony_ci u8 padding[24]; 17962306a36Sopenharmony_ci} __packed; 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ci/* Congestion info flags */ 18262306a36Sopenharmony_ci#define IB_CC_CI_FLAGS_CREDIT_STARVATION 0x1 18362306a36Sopenharmony_ci#define IB_CC_TABLE_CAP_DEFAULT 31 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_cistruct ib_cc_info_attr { 18662306a36Sopenharmony_ci __be16 congestion_info; 18762306a36Sopenharmony_ci u8 control_table_cap; /* Multiple of 64 entry unit CCTs */ 18862306a36Sopenharmony_ci} __packed; 18962306a36Sopenharmony_ci 19062306a36Sopenharmony_cistruct ib_cc_key_info_attr { 19162306a36Sopenharmony_ci __be64 cckey; 19262306a36Sopenharmony_ci u8 protect; 19362306a36Sopenharmony_ci __be16 lease_period; 19462306a36Sopenharmony_ci __be16 violations; 19562306a36Sopenharmony_ci} __packed; 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ci#define IB_CC_CL_CA_LOGEVENTS_LEN 208 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_cistruct ib_cc_log_attr { 20062306a36Sopenharmony_ci u8 log_type; 20162306a36Sopenharmony_ci u8 congestion_flags; 20262306a36Sopenharmony_ci __be16 threshold_event_counter; 20362306a36Sopenharmony_ci __be16 threshold_congestion_event_map; 20462306a36Sopenharmony_ci __be16 current_time_stamp; 20562306a36Sopenharmony_ci u8 log_events[IB_CC_CL_CA_LOGEVENTS_LEN]; 20662306a36Sopenharmony_ci} __packed; 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci#define IB_CC_CLEC_SERVICETYPE_RC 0x0 20962306a36Sopenharmony_ci#define IB_CC_CLEC_SERVICETYPE_UC 0x1 21062306a36Sopenharmony_ci#define IB_CC_CLEC_SERVICETYPE_RD 0x2 21162306a36Sopenharmony_ci#define IB_CC_CLEC_SERVICETYPE_UD 0x3 21262306a36Sopenharmony_ci 21362306a36Sopenharmony_cistruct ib_cc_log_event { 21462306a36Sopenharmony_ci u8 local_qp_cn_entry; 21562306a36Sopenharmony_ci u8 remote_qp_number_cn_entry[3]; 21662306a36Sopenharmony_ci u8 sl_cn_entry:4; 21762306a36Sopenharmony_ci u8 service_type_cn_entry:4; 21862306a36Sopenharmony_ci __be32 remote_lid_cn_entry; 21962306a36Sopenharmony_ci __be32 timestamp_cn_entry; 22062306a36Sopenharmony_ci} __packed; 22162306a36Sopenharmony_ci 22262306a36Sopenharmony_ci/* Sixteen congestion entries */ 22362306a36Sopenharmony_ci#define IB_CC_CCS_ENTRIES 16 22462306a36Sopenharmony_ci 22562306a36Sopenharmony_ci/* Port control flags */ 22662306a36Sopenharmony_ci#define IB_CC_CCS_PC_SL_BASED 0x01 22762306a36Sopenharmony_ci 22862306a36Sopenharmony_cistruct ib_cc_congestion_entry { 22962306a36Sopenharmony_ci u8 ccti_increase; 23062306a36Sopenharmony_ci __be16 ccti_timer; 23162306a36Sopenharmony_ci u8 trigger_threshold; 23262306a36Sopenharmony_ci u8 ccti_min; /* min CCTI for cc table */ 23362306a36Sopenharmony_ci} __packed; 23462306a36Sopenharmony_ci 23562306a36Sopenharmony_cistruct ib_cc_congestion_entry_shadow { 23662306a36Sopenharmony_ci u8 ccti_increase; 23762306a36Sopenharmony_ci u16 ccti_timer; 23862306a36Sopenharmony_ci u8 trigger_threshold; 23962306a36Sopenharmony_ci u8 ccti_min; /* min CCTI for cc table */ 24062306a36Sopenharmony_ci} __packed; 24162306a36Sopenharmony_ci 24262306a36Sopenharmony_cistruct ib_cc_congestion_setting_attr { 24362306a36Sopenharmony_ci __be16 port_control; 24462306a36Sopenharmony_ci __be16 control_map; 24562306a36Sopenharmony_ci struct ib_cc_congestion_entry entries[IB_CC_CCS_ENTRIES]; 24662306a36Sopenharmony_ci} __packed; 24762306a36Sopenharmony_ci 24862306a36Sopenharmony_cistruct ib_cc_congestion_setting_attr_shadow { 24962306a36Sopenharmony_ci u16 port_control; 25062306a36Sopenharmony_ci u16 control_map; 25162306a36Sopenharmony_ci struct ib_cc_congestion_entry_shadow entries[IB_CC_CCS_ENTRIES]; 25262306a36Sopenharmony_ci} __packed; 25362306a36Sopenharmony_ci 25462306a36Sopenharmony_ci#define IB_CC_TABLE_ENTRY_INCREASE_DEFAULT 1 25562306a36Sopenharmony_ci#define IB_CC_TABLE_ENTRY_TIMER_DEFAULT 1 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_ci/* 64 Congestion Control table entries in a single MAD */ 25862306a36Sopenharmony_ci#define IB_CCT_ENTRIES 64 25962306a36Sopenharmony_ci#define IB_CCT_MIN_ENTRIES (IB_CCT_ENTRIES * 2) 26062306a36Sopenharmony_ci 26162306a36Sopenharmony_cistruct ib_cc_table_entry { 26262306a36Sopenharmony_ci __be16 entry; /* shift:2, multiplier:14 */ 26362306a36Sopenharmony_ci}; 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_cistruct ib_cc_table_entry_shadow { 26662306a36Sopenharmony_ci u16 entry; /* shift:2, multiplier:14 */ 26762306a36Sopenharmony_ci}; 26862306a36Sopenharmony_ci 26962306a36Sopenharmony_cistruct ib_cc_table_attr { 27062306a36Sopenharmony_ci __be16 ccti_limit; /* max CCTI for cc table */ 27162306a36Sopenharmony_ci struct ib_cc_table_entry ccti_entries[IB_CCT_ENTRIES]; 27262306a36Sopenharmony_ci} __packed; 27362306a36Sopenharmony_ci 27462306a36Sopenharmony_cistruct ib_cc_table_attr_shadow { 27562306a36Sopenharmony_ci u16 ccti_limit; /* max CCTI for cc table */ 27662306a36Sopenharmony_ci struct ib_cc_table_entry_shadow ccti_entries[IB_CCT_ENTRIES]; 27762306a36Sopenharmony_ci} __packed; 27862306a36Sopenharmony_ci 27962306a36Sopenharmony_ci#define CC_TABLE_SHADOW_MAX \ 28062306a36Sopenharmony_ci (IB_CC_TABLE_CAP_DEFAULT * IB_CCT_ENTRIES) 28162306a36Sopenharmony_ci 28262306a36Sopenharmony_cistruct cc_table_shadow { 28362306a36Sopenharmony_ci u16 ccti_last_entry; 28462306a36Sopenharmony_ci struct ib_cc_table_entry_shadow entries[CC_TABLE_SHADOW_MAX]; 28562306a36Sopenharmony_ci} __packed; 28662306a36Sopenharmony_ci 28762306a36Sopenharmony_ci/* 28862306a36Sopenharmony_ci * The PortSamplesControl.CounterMasks field is an array of 3 bit fields 28962306a36Sopenharmony_ci * which specify the N'th counter's capabilities. See ch. 16.1.3.2. 29062306a36Sopenharmony_ci * We support 5 counters which only count the mandatory quantities. 29162306a36Sopenharmony_ci */ 29262306a36Sopenharmony_ci#define COUNTER_MASK(q, n) (q << ((9 - n) * 3)) 29362306a36Sopenharmony_ci#define COUNTER_MASK0_9 \ 29462306a36Sopenharmony_ci cpu_to_be32(COUNTER_MASK(1, 0) | \ 29562306a36Sopenharmony_ci COUNTER_MASK(1, 1) | \ 29662306a36Sopenharmony_ci COUNTER_MASK(1, 2) | \ 29762306a36Sopenharmony_ci COUNTER_MASK(1, 3) | \ 29862306a36Sopenharmony_ci COUNTER_MASK(1, 4)) 29962306a36Sopenharmony_ci 30062306a36Sopenharmony_ci#endif /* _QIB_MAD_H */ 301