Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2012 Intel Corporation.  All rights reserved.
0003  * Copyright (c) 2006 - 2012 QLogic Corporation. All rights reserved.
0004  * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved.
0005  *
0006  * This software is available to you under a choice of one of two
0007  * licenses.  You may choose to be licensed under the terms of the GNU
0008  * General Public License (GPL) Version 2, available from the file
0009  * COPYING in the main directory of this source tree, or the
0010  * OpenIB.org BSD license below:
0011  *
0012  *     Redistribution and use in source and binary forms, with or
0013  *     without modification, are permitted provided that the following
0014  *     conditions are met:
0015  *
0016  *      - Redistributions of source code must retain the above
0017  *        copyright notice, this list of conditions and the following
0018  *        disclaimer.
0019  *
0020  *      - Redistributions in binary form must reproduce the above
0021  *        copyright notice, this list of conditions and the following
0022  *        disclaimer in the documentation and/or other materials
0023  *        provided with the distribution.
0024  *
0025  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0026  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0027  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0028  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
0029  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0030  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0031  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0032  * SOFTWARE.
0033  */
0034 #ifndef _QIB_MAD_H
0035 #define _QIB_MAD_H
0036 
0037 #include <rdma/ib_pma.h>
0038 
0039 #define IB_SMP_UNSUP_VERSION \
0040 cpu_to_be16(IB_MGMT_MAD_STATUS_BAD_VERSION)
0041 
0042 #define IB_SMP_UNSUP_METHOD \
0043 cpu_to_be16(IB_MGMT_MAD_STATUS_UNSUPPORTED_METHOD)
0044 
0045 #define IB_SMP_UNSUP_METH_ATTR \
0046 cpu_to_be16(IB_MGMT_MAD_STATUS_UNSUPPORTED_METHOD_ATTRIB)
0047 
0048 #define IB_SMP_INVALID_FIELD \
0049 cpu_to_be16(IB_MGMT_MAD_STATUS_INVALID_ATTRIB_VALUE)
0050 
0051 #define IB_VLARB_LOWPRI_0_31    1
0052 #define IB_VLARB_LOWPRI_32_63   2
0053 #define IB_VLARB_HIGHPRI_0_31   3
0054 #define IB_VLARB_HIGHPRI_32_63  4
0055 
0056 #define IB_PMA_PORT_COUNTERS_CONG       cpu_to_be16(0xFF00)
0057 
0058 struct ib_pma_portcounters_cong {
0059     u8 reserved;
0060     u8 reserved1;
0061     __be16 port_check_rate;
0062     __be16 symbol_error_counter;
0063     u8 link_error_recovery_counter;
0064     u8 link_downed_counter;
0065     __be16 port_rcv_errors;
0066     __be16 port_rcv_remphys_errors;
0067     __be16 port_rcv_switch_relay_errors;
0068     __be16 port_xmit_discards;
0069     u8 port_xmit_constraint_errors;
0070     u8 port_rcv_constraint_errors;
0071     u8 reserved2;
0072     u8 link_overrun_errors; /* LocalLink: 7:4, BufferOverrun: 3:0 */
0073     __be16 reserved3;
0074     __be16 vl15_dropped;
0075     __be64 port_xmit_data;
0076     __be64 port_rcv_data;
0077     __be64 port_xmit_packets;
0078     __be64 port_rcv_packets;
0079     __be64 port_xmit_wait;
0080     __be64 port_adr_events;
0081 } __packed;
0082 
0083 #define IB_PMA_CONG_HW_CONTROL_TIMER            0x00
0084 #define IB_PMA_CONG_HW_CONTROL_SAMPLE           0x01
0085 
0086 #define QIB_XMIT_RATE_UNSUPPORTED               0x0
0087 #define QIB_XMIT_RATE_PICO                      0x7
0088 /* number of 4nsec cycles equaling 2secs */
0089 #define QIB_CONG_TIMER_PSINTERVAL               0x1DCD64EC
0090 
0091 #define IB_PMA_SEL_CONG_ALL                     0x01
0092 #define IB_PMA_SEL_CONG_PORT_DATA               0x02
0093 #define IB_PMA_SEL_CONG_XMIT                    0x04
0094 #define IB_PMA_SEL_CONG_ROUTING                 0x08
0095 
0096 /*
0097  * Congestion control class attributes
0098  */
0099 #define IB_CC_ATTR_CLASSPORTINFO            cpu_to_be16(0x0001)
0100 #define IB_CC_ATTR_NOTICE               cpu_to_be16(0x0002)
0101 #define IB_CC_ATTR_CONGESTION_INFO          cpu_to_be16(0x0011)
0102 #define IB_CC_ATTR_CONGESTION_KEY_INFO          cpu_to_be16(0x0012)
0103 #define IB_CC_ATTR_CONGESTION_LOG           cpu_to_be16(0x0013)
0104 #define IB_CC_ATTR_SWITCH_CONGESTION_SETTING        cpu_to_be16(0x0014)
0105 #define IB_CC_ATTR_SWITCH_PORT_CONGESTION_SETTING   cpu_to_be16(0x0015)
0106 #define IB_CC_ATTR_CA_CONGESTION_SETTING        cpu_to_be16(0x0016)
0107 #define IB_CC_ATTR_CONGESTION_CONTROL_TABLE     cpu_to_be16(0x0017)
0108 #define IB_CC_ATTR_TIME_STAMP               cpu_to_be16(0x0018)
0109 
0110 /* generalizations for threshold values */
0111 #define IB_CC_THRESHOLD_NONE 0x0
0112 #define IB_CC_THRESHOLD_MIN  0x1
0113 #define IB_CC_THRESHOLD_MAX  0xf
0114 
0115 /* CCA MAD header constants */
0116 #define IB_CC_MAD_LOGDATA_LEN 32
0117 #define IB_CC_MAD_MGMTDATA_LEN 192
0118 
0119 struct ib_cc_mad {
0120     u8  base_version;
0121     u8  mgmt_class;
0122     u8  class_version;
0123     u8  method;
0124     __be16  status;
0125     __be16  class_specific;
0126     __be64  tid;
0127     __be16  attr_id;
0128     __be16  resv;
0129     __be32  attr_mod;
0130     __be64 cckey;
0131 
0132     /* For CongestionLog attribute only */
0133     u8 log_data[IB_CC_MAD_LOGDATA_LEN];
0134 
0135     u8 mgmt_data[IB_CC_MAD_MGMTDATA_LEN];
0136 } __packed;
0137 
0138 /*
0139  * Congestion Control class portinfo capability mask bits
0140  */
0141 #define IB_CC_CPI_CM_TRAP_GEN       cpu_to_be16(1 << 0)
0142 #define IB_CC_CPI_CM_GET_SET_NOTICE cpu_to_be16(1 << 1)
0143 #define IB_CC_CPI_CM_CAP2       cpu_to_be16(1 << 2)
0144 #define IB_CC_CPI_CM_ENHANCEDPORT0_CC   cpu_to_be16(1 << 8)
0145 
0146 struct ib_cc_classportinfo_attr {
0147     u8 base_version;
0148     u8 class_version;
0149     __be16 cap_mask;
0150     u8 reserved[3];
0151     u8 resp_time_value;     /* only lower 5 bits */
0152     union ib_gid redirect_gid;
0153     __be32 redirect_tc_sl_fl;       /* 8, 4, 20 bits respectively */
0154     __be16 redirect_lid;
0155     __be16 redirect_pkey;
0156     __be32 redirect_qp;     /* only lower 24 bits */
0157     __be32 redirect_qkey;
0158     union ib_gid trap_gid;
0159     __be32 trap_tc_sl_fl;   /* 8, 4, 20 bits respectively */
0160     __be16 trap_lid;
0161     __be16 trap_pkey;
0162     __be32 trap_hl_qp;      /* 8, 24 bits respectively */
0163     __be32 trap_qkey;
0164 } __packed;
0165 
0166 /* Congestion control traps */
0167 #define IB_CC_TRAP_KEY_VIOLATION 0x0000
0168 
0169 struct ib_cc_trap_key_violation_attr {
0170     __be16 source_lid;
0171     u8 method;
0172     u8 reserved1;
0173     __be16 attrib_id;
0174     __be32 attrib_mod;
0175     __be32 qp;
0176     __be64 cckey;
0177     u8 sgid[16];
0178     u8 padding[24];
0179 } __packed;
0180 
0181 /* Congestion info flags */
0182 #define IB_CC_CI_FLAGS_CREDIT_STARVATION 0x1
0183 #define IB_CC_TABLE_CAP_DEFAULT 31
0184 
0185 struct ib_cc_info_attr {
0186     __be16 congestion_info;
0187     u8  control_table_cap; /* Multiple of 64 entry unit CCTs */
0188 } __packed;
0189 
0190 struct ib_cc_key_info_attr {
0191     __be64 cckey;
0192     u8  protect;
0193     __be16 lease_period;
0194     __be16 violations;
0195 } __packed;
0196 
0197 #define IB_CC_CL_CA_LOGEVENTS_LEN 208
0198 
0199 struct ib_cc_log_attr {
0200     u8 log_type;
0201     u8 congestion_flags;
0202     __be16 threshold_event_counter;
0203     __be16 threshold_congestion_event_map;
0204     __be16 current_time_stamp;
0205     u8 log_events[IB_CC_CL_CA_LOGEVENTS_LEN];
0206 } __packed;
0207 
0208 #define IB_CC_CLEC_SERVICETYPE_RC 0x0
0209 #define IB_CC_CLEC_SERVICETYPE_UC 0x1
0210 #define IB_CC_CLEC_SERVICETYPE_RD 0x2
0211 #define IB_CC_CLEC_SERVICETYPE_UD 0x3
0212 
0213 struct ib_cc_log_event {
0214     u8 local_qp_cn_entry;
0215     u8 remote_qp_number_cn_entry[3];
0216     u8  sl_cn_entry:4;
0217     u8  service_type_cn_entry:4;
0218     __be32 remote_lid_cn_entry;
0219     __be32 timestamp_cn_entry;
0220 } __packed;
0221 
0222 /* Sixteen congestion entries */
0223 #define IB_CC_CCS_ENTRIES 16
0224 
0225 /* Port control flags */
0226 #define IB_CC_CCS_PC_SL_BASED 0x01
0227 
0228 struct ib_cc_congestion_entry {
0229     u8 ccti_increase;
0230     __be16 ccti_timer;
0231     u8 trigger_threshold;
0232     u8 ccti_min; /* min CCTI for cc table */
0233 } __packed;
0234 
0235 struct ib_cc_congestion_entry_shadow {
0236     u8 ccti_increase;
0237     u16 ccti_timer;
0238     u8 trigger_threshold;
0239     u8 ccti_min; /* min CCTI for cc table */
0240 } __packed;
0241 
0242 struct ib_cc_congestion_setting_attr {
0243     __be16 port_control;
0244     __be16 control_map;
0245     struct ib_cc_congestion_entry entries[IB_CC_CCS_ENTRIES];
0246 } __packed;
0247 
0248 struct ib_cc_congestion_setting_attr_shadow {
0249     u16 port_control;
0250     u16 control_map;
0251     struct ib_cc_congestion_entry_shadow entries[IB_CC_CCS_ENTRIES];
0252 } __packed;
0253 
0254 #define IB_CC_TABLE_ENTRY_INCREASE_DEFAULT 1
0255 #define IB_CC_TABLE_ENTRY_TIMER_DEFAULT 1
0256 
0257 /* 64 Congestion Control table entries in a single MAD */
0258 #define IB_CCT_ENTRIES 64
0259 #define IB_CCT_MIN_ENTRIES (IB_CCT_ENTRIES * 2)
0260 
0261 struct ib_cc_table_entry {
0262     __be16 entry; /* shift:2, multiplier:14 */
0263 };
0264 
0265 struct ib_cc_table_entry_shadow {
0266     u16 entry; /* shift:2, multiplier:14 */
0267 };
0268 
0269 struct ib_cc_table_attr {
0270     __be16 ccti_limit; /* max CCTI for cc table */
0271     struct ib_cc_table_entry ccti_entries[IB_CCT_ENTRIES];
0272 } __packed;
0273 
0274 struct ib_cc_table_attr_shadow {
0275     u16 ccti_limit; /* max CCTI for cc table */
0276     struct ib_cc_table_entry_shadow ccti_entries[IB_CCT_ENTRIES];
0277 } __packed;
0278 
0279 #define CC_TABLE_SHADOW_MAX \
0280     (IB_CC_TABLE_CAP_DEFAULT * IB_CCT_ENTRIES)
0281 
0282 struct cc_table_shadow {
0283     u16 ccti_last_entry;
0284     struct ib_cc_table_entry_shadow entries[CC_TABLE_SHADOW_MAX];
0285 } __packed;
0286 
0287 /*
0288  * The PortSamplesControl.CounterMasks field is an array of 3 bit fields
0289  * which specify the N'th counter's capabilities. See ch. 16.1.3.2.
0290  * We support 5 counters which only count the mandatory quantities.
0291  */
0292 #define COUNTER_MASK(q, n) (q << ((9 - n) * 3))
0293 #define COUNTER_MASK0_9 \
0294     cpu_to_be32(COUNTER_MASK(1, 0) | \
0295             COUNTER_MASK(1, 1) | \
0296             COUNTER_MASK(1, 2) | \
0297             COUNTER_MASK(1, 3) | \
0298             COUNTER_MASK(1, 4))
0299 
0300 #endif              /* _QIB_MAD_H */