1/*- 2 * Copyright (c) 2007-2014 QLogic Corporation. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS' 15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 18 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 24 * THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> 28__FBSDID("$FreeBSD$"); 29 30#ifndef BXE_DCB_H 31#define BXE_DCB_H 32 33#define LLFC_DRIVER_TRAFFIC_TYPE_MAX 3 /* NW, iSCSI, FCoE */ 34struct bxe_dcbx_app_params { 35 uint32_t enabled; 36 uint32_t traffic_type_priority[LLFC_DRIVER_TRAFFIC_TYPE_MAX]; 37}; 38 39#define DCBX_COS_MAX_NUM_E2 DCBX_E2E3_MAX_NUM_COS 40/* bxe currently limits numbers of supported COSes to 3 to be extended to 6 */ 41#define BXE_MAX_COS_SUPPORT 3 42#define DCBX_COS_MAX_NUM_E3B0 BXE_MAX_COS_SUPPORT 43#define DCBX_COS_MAX_NUM BXE_MAX_COS_SUPPORT 44 45struct bxe_dcbx_cos_params { 46 uint32_t bw_tbl; 47 uint32_t pri_bitmask; 48 /* 49 * strict priority: valid values are 0..5; 0 is highest priority. 50 * There can't be two COSes with the same priority. 51 */ 52 uint8_t strict; 53#define BXE_DCBX_STRICT_INVALID DCBX_COS_MAX_NUM 54#define BXE_DCBX_STRICT_COS_HIGHEST 0 55#define BXE_DCBX_STRICT_COS_NEXT_LOWER_PRI(sp) ((sp) + 1) 56 uint8_t pauseable; 57}; 58 59struct bxe_dcbx_pg_params { 60 uint32_t enabled; 61 uint8_t num_of_cos; /* valid COS entries */ 62 struct bxe_dcbx_cos_params cos_params[DCBX_COS_MAX_NUM]; 63}; 64 65struct bxe_dcbx_pfc_params { 66 uint32_t enabled; 67 uint32_t priority_non_pauseable_mask; 68}; 69 70struct bxe_dcbx_port_params { 71 struct bxe_dcbx_pfc_params pfc; 72 struct bxe_dcbx_pg_params ets; 73 struct bxe_dcbx_app_params app; 74}; 75 76#define BXE_DCBX_CONFIG_INV_VALUE (0xFFFFFFFF) 77#define BXE_DCBX_OVERWRITE_SETTINGS_DISABLE 0 78#define BXE_DCBX_OVERWRITE_SETTINGS_ENABLE 1 79#define BXE_DCBX_OVERWRITE_SETTINGS_INVALID (BXE_DCBX_CONFIG_INV_VALUE) 80#define BXE_IS_ETS_ENABLED(sc) \ 81 ((sc)->dcb_state == BXE_DCB_STATE_ON && \ 82 (sc)->dcbx_port_params.ets.enabled) 83 84struct bxe_config_lldp_params { 85 uint32_t overwrite_settings; 86 uint32_t msg_tx_hold; 87 uint32_t msg_fast_tx; 88 uint32_t tx_credit_max; 89 uint32_t msg_tx_interval; 90 uint32_t tx_fast; 91}; 92 93struct bxe_lldp_params_get { 94 uint32_t ver_num; 95#define LLDP_PARAMS_VER_NUM 2 96 struct bxe_config_lldp_params config_lldp_params; 97 /* The reserved field should follow in case the struct above will increase*/ 98 uint32_t _reserved[20]; 99 uint32_t admin_status; 100#define LLDP_TX_ONLY 0x01 101#define LLDP_RX_ONLY 0x02 102#define LLDP_TX_RX 0x03 103#define LLDP_DISABLED 0x04 104 uint32_t remote_chassis_id[REM_CHASSIS_ID_STAT_LEN]; 105 uint32_t remote_port_id[REM_PORT_ID_STAT_LEN]; 106 uint32_t local_chassis_id[LOCAL_CHASSIS_ID_STAT_LEN]; 107 uint32_t local_port_id[LOCAL_PORT_ID_STAT_LEN]; 108}; 109 110struct bxe_admin_priority_app_table { 111 uint32_t valid; 112 uint32_t priority; 113#define INVALID_TRAFFIC_TYPE_PRIORITY (0xFFFFFFFF) 114 uint32_t traffic_type; 115#define TRAFFIC_TYPE_ETH 0 116#define TRAFFIC_TYPE_PORT 1 117 uint32_t app_id; 118}; 119 120#define DCBX_CONFIG_MAX_APP_PROTOCOL 4 121struct bxe_config_dcbx_params { 122 uint32_t overwrite_settings; 123 uint32_t admin_dcbx_version; 124 uint32_t admin_ets_enable; 125 uint32_t admin_pfc_enable; 126 uint32_t admin_tc_supported_tx_enable; 127 uint32_t admin_ets_configuration_tx_enable; 128 uint32_t admin_ets_recommendation_tx_enable; 129 uint32_t admin_pfc_tx_enable; 130 uint32_t admin_application_priority_tx_enable; 131 uint32_t admin_ets_willing; 132 uint32_t admin_ets_reco_valid; 133 uint32_t admin_pfc_willing; 134 uint32_t admin_app_priority_willing; 135 uint32_t admin_configuration_bw_precentage[8]; 136 uint32_t admin_configuration_ets_pg[8]; 137 uint32_t admin_recommendation_bw_precentage[8]; 138 uint32_t admin_recommendation_ets_pg[8]; 139 uint32_t admin_pfc_bitmap; 140 struct bxe_admin_priority_app_table 141 admin_priority_app_table[DCBX_CONFIG_MAX_APP_PROTOCOL]; 142 uint32_t admin_default_priority; 143}; 144 145//#define DCBX_PARAMS_VER_NUM 3 /* XXX conflict with common_uif.h */ 146struct bxe_dcbx_params_get { 147 uint32_t ver_num; 148 uint32_t dcb_state; 149 uint32_t dcbx_enabled; 150 struct bxe_config_dcbx_params config_dcbx_params; 151 /* The reserved field should follow in case the struct above will increase*/ 152 uint32_t _reserved[19]; 153 154 uint32_t dcb_current_state; 155#define BXE_DCBX_CURRENT_STATE_IS_SYNC (1 << 0) 156#define BXE_PFC_IS_CURRENTLY_OPERATIONAL (1 << 1) 157#define BXE_ETS_IS_CURRENTLY_OPERATIONAL (1 << 2) 158#define BXE_PRIORITY_TAGGING_IS_CURRENTLY_OPERATIONAL (1 << 3) 159 160 uint32_t local_tc_supported; 161 uint32_t local_pfc_caps; 162 uint32_t remote_tc_supported; 163 uint32_t remote_pfc_cap; 164 uint32_t remote_ets_willing; 165 uint32_t remote_ets_reco_valid; 166 uint32_t remote_pfc_willing; 167 uint32_t remote_app_priority_willing; 168 uint32_t remote_configuration_bw_precentage[8]; 169 uint32_t remote_configuration_ets_pg[8]; 170 uint32_t remote_recommendation_bw_precentage[8]; 171 uint32_t remote_recommendation_ets_pg[8]; 172 uint32_t remote_pfc_bitmap; 173 struct bxe_admin_priority_app_table 174 remote_priority_app_table[DCBX_MAX_APP_PROTOCOL]; 175 uint32_t local_ets_enable; 176 uint32_t local_pfc_enable; 177 uint32_t local_configuration_bw_precentage[8]; 178 uint32_t local_configuration_ets_pg[8]; 179 uint32_t local_pfc_bitmap; 180 struct bxe_admin_priority_app_table 181 local_priority_app_table[DCBX_MAX_APP_PROTOCOL]; 182 uint32_t pfc_mismatch; 183 uint32_t priority_app_mismatch; 184 uint32_t dcbx_frames_sent; 185 uint32_t dcbx_frames_received; 186 uint32_t pfc_frames_sent[2]; 187 uint32_t pfc_frames_received[2]; 188}; 189 190struct bxe_dcbx_params_set { 191 uint32_t ver_num; 192 uint32_t dcb_state; 193 uint32_t dcbx_enabled; 194 struct bxe_config_dcbx_params config_dcbx_params; 195}; 196 197#define GET_FLAGS(flags, bits) ((flags) & (bits)) 198#define SET_FLAGS(flags, bits) ((flags) |= (bits)) 199#define RESET_FLAGS(flags, bits) ((flags) &= ~(bits)) 200 201enum { 202 DCBX_READ_LOCAL_MIB, 203 DCBX_READ_REMOTE_MIB 204}; 205 206#define ETH_TYPE_FCOE (0x8906) 207#define TCP_PORT_ISCSI (0xCBC) 208 209#define PFC_VALUE_FRAME_SIZE (512) 210#define PFC_QUANTA_IN_NANOSEC_FROM_SPEED_MEGA(mega_speed) \ 211 ((1000 * PFC_VALUE_FRAME_SIZE)/(mega_speed)) 212 213#define PFC_BRB1_REG_HIGH_LLFC_LOW_THRESHOLD 130 214#define PFC_BRB1_REG_HIGH_LLFC_HIGH_THRESHOLD 170 215 216struct cos_entry_help_data { 217 uint32_t pri_join_mask; 218 uint32_t cos_bw; 219 uint8_t strict; 220 uint8_t pausable; 221}; 222 223struct cos_help_data { 224 struct cos_entry_help_data data[DCBX_COS_MAX_NUM]; 225 uint8_t num_of_cos; 226}; 227 228#define DCBX_ILLEGAL_PG (0xFF) 229#define DCBX_PFC_PRI_MASK (0xFF) 230#define DCBX_STRICT_PRIORITY (15) 231#define DCBX_INVALID_COS_BW (0xFFFFFFFF) 232#define DCBX_PFC_PRI_NON_PAUSE_MASK(sc) \ 233 ((sc)->dcbx_port_params.pfc.priority_non_pauseable_mask) 234#define DCBX_PFC_PRI_PAUSE_MASK(sc) \ 235 ((uint8_t)~DCBX_PFC_PRI_NON_PAUSE_MASK(sc)) 236#define DCBX_PFC_PRI_GET_PAUSE(sc, pg_pri) \ 237 ((pg_pri) & (DCBX_PFC_PRI_PAUSE_MASK(sc))) 238#define DCBX_PFC_PRI_GET_NON_PAUSE(sc, pg_pri) \ 239 (DCBX_PFC_PRI_NON_PAUSE_MASK(sc) & (pg_pri)) 240#define DCBX_IS_PFC_PRI_SOME_PAUSE(sc, pg_pri) \ 241 (0 != DCBX_PFC_PRI_GET_PAUSE(sc, pg_pri)) 242#define IS_DCBX_PFC_PRI_ONLY_PAUSE(sc, pg_pri) \ 243 (pg_pri == DCBX_PFC_PRI_GET_PAUSE((sc), (pg_pri))) 244#define IS_DCBX_PFC_PRI_ONLY_NON_PAUSE(sc, pg_pri) \ 245 ((pg_pri) == DCBX_PFC_PRI_GET_NON_PAUSE((sc), (pg_pri))) 246#define IS_DCBX_PFC_PRI_MIX_PAUSE(sc, pg_pri) \ 247 (!(IS_DCBX_PFC_PRI_ONLY_NON_PAUSE((sc), (pg_pri)) || \ 248 IS_DCBX_PFC_PRI_ONLY_PAUSE((sc), (pg_pri)))) 249 250struct pg_entry_help_data { 251 uint8_t num_of_dif_pri; 252 uint8_t pg; 253 uint32_t pg_priority; 254}; 255 256struct pg_help_data { 257 struct pg_entry_help_data data[LLFC_DRIVER_TRAFFIC_TYPE_MAX]; 258 uint8_t num_of_pg; 259}; 260 261/* forward DCB/PFC related declarations */ 262struct bxe_softc; 263/* void bxe_dcbx_update(struct work_struct *work); */ 264void bxe_dcbx_init_params(struct bxe_softc *sc); 265void bxe_dcbx_set_state(struct bxe_softc *sc, uint8_t dcb_on, uint32_t dcbx_enabled); 266int bxe_dcb_get_lldp_params_ioctl(struct bxe_softc *sc, void *uaddr); 267int bxe_dcb_get_dcbx_params_ioctl(struct bxe_softc *sc, void *uaddr); 268int bxe_dcb_set_dcbx_params_ioctl(struct bxe_softc *sc, void *uaddr); 269 270enum { 271 BXE_DCBX_STATE_NEG_RECEIVED = 0x1, 272 BXE_DCBX_STATE_TX_PAUSED, 273 BXE_DCBX_STATE_TX_RELEASED 274}; 275 276void bxe_dcbx_set_params(struct bxe_softc *sc, uint32_t state); 277void bxe_dcbx_pmf_update(struct bxe_softc *sc); 278 279#endif /* BXE_DCB_H */ 280 281