1*4ad79e13SYuval Mintz /* bnx2x_dcb.h: QLogic Everest network driver. 2adfc5217SJeff Kirsher * 3247fa82bSYuval Mintz * Copyright 2009-2013 Broadcom Corporation 4*4ad79e13SYuval Mintz * Copyright 2014 QLogic Corporation 5*4ad79e13SYuval Mintz * All rights reserved 6adfc5217SJeff Kirsher * 7*4ad79e13SYuval Mintz * Unless you and QLogic execute a separate written software license 8adfc5217SJeff Kirsher * agreement governing use of this software, this software is licensed to you 9adfc5217SJeff Kirsher * under the terms of the GNU General Public License version 2, available 10adfc5217SJeff Kirsher * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL"). 11adfc5217SJeff Kirsher * 12adfc5217SJeff Kirsher * Notwithstanding the above, under no circumstances may you combine this 13*4ad79e13SYuval Mintz * software in any way with any other QLogic software provided under a 14*4ad79e13SYuval Mintz * license other than the GPL, without QLogic's express prior written 15adfc5217SJeff Kirsher * consent. 16adfc5217SJeff Kirsher * 1708f6dd89SAriel Elior * Maintained by: Ariel Elior <ariel.elior@qlogic.com> 18adfc5217SJeff Kirsher * Written by: Dmitry Kravkov 19adfc5217SJeff Kirsher * 20adfc5217SJeff Kirsher */ 21adfc5217SJeff Kirsher #ifndef BNX2X_DCB_H 22adfc5217SJeff Kirsher #define BNX2X_DCB_H 23adfc5217SJeff Kirsher 24adfc5217SJeff Kirsher #include "bnx2x_hsi.h" 25adfc5217SJeff Kirsher 26adfc5217SJeff Kirsher #define LLFC_DRIVER_TRAFFIC_TYPE_MAX 3 /* NW, iSCSI, FCoE */ 27adfc5217SJeff Kirsher struct bnx2x_dcbx_app_params { 28adfc5217SJeff Kirsher u32 enabled; 29adfc5217SJeff Kirsher u32 traffic_type_priority[LLFC_DRIVER_TRAFFIC_TYPE_MAX]; 30adfc5217SJeff Kirsher }; 31adfc5217SJeff Kirsher 32adfc5217SJeff Kirsher #define DCBX_COS_MAX_NUM_E2 DCBX_E2E3_MAX_NUM_COS 33adfc5217SJeff Kirsher /* bnx2x currently limits numbers of supported COSes to 3 to be extended to 6 */ 34adfc5217SJeff Kirsher #define BNX2X_MAX_COS_SUPPORT 3 35adfc5217SJeff Kirsher #define DCBX_COS_MAX_NUM_E3B0 BNX2X_MAX_COS_SUPPORT 36adfc5217SJeff Kirsher #define DCBX_COS_MAX_NUM BNX2X_MAX_COS_SUPPORT 37adfc5217SJeff Kirsher 38adfc5217SJeff Kirsher struct bnx2x_dcbx_cos_params { 39adfc5217SJeff Kirsher u32 bw_tbl; 40adfc5217SJeff Kirsher u32 pri_bitmask; 41adfc5217SJeff Kirsher /* 42adfc5217SJeff Kirsher * strict priority: valid values are 0..5; 0 is highest priority. 43adfc5217SJeff Kirsher * There can't be two COSes with the same priority. 44adfc5217SJeff Kirsher */ 45adfc5217SJeff Kirsher u8 strict; 46adfc5217SJeff Kirsher #define BNX2X_DCBX_STRICT_INVALID DCBX_COS_MAX_NUM 47adfc5217SJeff Kirsher #define BNX2X_DCBX_STRICT_COS_HIGHEST 0 48adfc5217SJeff Kirsher #define BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(sp) ((sp) + 1) 49adfc5217SJeff Kirsher u8 pauseable; 50adfc5217SJeff Kirsher }; 51adfc5217SJeff Kirsher 52adfc5217SJeff Kirsher struct bnx2x_dcbx_pg_params { 53adfc5217SJeff Kirsher u32 enabled; 54adfc5217SJeff Kirsher u8 num_of_cos; /* valid COS entries */ 55adfc5217SJeff Kirsher struct bnx2x_dcbx_cos_params cos_params[DCBX_COS_MAX_NUM]; 56adfc5217SJeff Kirsher }; 57adfc5217SJeff Kirsher 58adfc5217SJeff Kirsher struct bnx2x_dcbx_pfc_params { 59adfc5217SJeff Kirsher u32 enabled; 60adfc5217SJeff Kirsher u32 priority_non_pauseable_mask; 61adfc5217SJeff Kirsher }; 62adfc5217SJeff Kirsher 63adfc5217SJeff Kirsher struct bnx2x_dcbx_port_params { 64adfc5217SJeff Kirsher struct bnx2x_dcbx_pfc_params pfc; 65adfc5217SJeff Kirsher struct bnx2x_dcbx_pg_params ets; 66adfc5217SJeff Kirsher struct bnx2x_dcbx_app_params app; 67adfc5217SJeff Kirsher }; 68adfc5217SJeff Kirsher 69adfc5217SJeff Kirsher #define BNX2X_DCBX_CONFIG_INV_VALUE (0xFFFFFFFF) 70adfc5217SJeff Kirsher #define BNX2X_DCBX_OVERWRITE_SETTINGS_DISABLE 0 71adfc5217SJeff Kirsher #define BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE 1 72adfc5217SJeff Kirsher #define BNX2X_DCBX_OVERWRITE_SETTINGS_INVALID (BNX2X_DCBX_CONFIG_INV_VALUE) 73adfc5217SJeff Kirsher #define BNX2X_IS_ETS_ENABLED(bp) ((bp)->dcb_state == BNX2X_DCB_STATE_ON &&\ 74adfc5217SJeff Kirsher (bp)->dcbx_port_params.ets.enabled) 75adfc5217SJeff Kirsher 76adfc5217SJeff Kirsher struct bnx2x_config_lldp_params { 77adfc5217SJeff Kirsher u32 overwrite_settings; 78adfc5217SJeff Kirsher u32 msg_tx_hold; 79adfc5217SJeff Kirsher u32 msg_fast_tx; 80adfc5217SJeff Kirsher u32 tx_credit_max; 81adfc5217SJeff Kirsher u32 msg_tx_interval; 82adfc5217SJeff Kirsher u32 tx_fast; 83adfc5217SJeff Kirsher }; 84adfc5217SJeff Kirsher 85adfc5217SJeff Kirsher struct bnx2x_admin_priority_app_table { 86adfc5217SJeff Kirsher u32 valid; 87adfc5217SJeff Kirsher u32 priority; 88adfc5217SJeff Kirsher #define INVALID_TRAFFIC_TYPE_PRIORITY (0xFFFFFFFF) 89adfc5217SJeff Kirsher u32 traffic_type; 90adfc5217SJeff Kirsher #define TRAFFIC_TYPE_ETH 0 91adfc5217SJeff Kirsher #define TRAFFIC_TYPE_PORT 1 92adfc5217SJeff Kirsher u32 app_id; 93adfc5217SJeff Kirsher }; 94adfc5217SJeff Kirsher 95f9c058b6SDmitry Kravkov #define DCBX_CONFIG_MAX_APP_PROTOCOL 4 96adfc5217SJeff Kirsher struct bnx2x_config_dcbx_params { 97adfc5217SJeff Kirsher u32 overwrite_settings; 98adfc5217SJeff Kirsher u32 admin_dcbx_version; 99adfc5217SJeff Kirsher u32 admin_ets_enable; 100adfc5217SJeff Kirsher u32 admin_pfc_enable; 101adfc5217SJeff Kirsher u32 admin_tc_supported_tx_enable; 102adfc5217SJeff Kirsher u32 admin_ets_configuration_tx_enable; 103adfc5217SJeff Kirsher u32 admin_ets_recommendation_tx_enable; 104adfc5217SJeff Kirsher u32 admin_pfc_tx_enable; 105adfc5217SJeff Kirsher u32 admin_application_priority_tx_enable; 106adfc5217SJeff Kirsher u32 admin_ets_willing; 107adfc5217SJeff Kirsher u32 admin_ets_reco_valid; 108adfc5217SJeff Kirsher u32 admin_pfc_willing; 109adfc5217SJeff Kirsher u32 admin_app_priority_willing; 110adfc5217SJeff Kirsher u32 admin_configuration_bw_precentage[8]; 111adfc5217SJeff Kirsher u32 admin_configuration_ets_pg[8]; 112adfc5217SJeff Kirsher u32 admin_recommendation_bw_precentage[8]; 113adfc5217SJeff Kirsher u32 admin_recommendation_ets_pg[8]; 114adfc5217SJeff Kirsher u32 admin_pfc_bitmap; 115f9c058b6SDmitry Kravkov struct bnx2x_admin_priority_app_table 116f9c058b6SDmitry Kravkov admin_priority_app_table[DCBX_CONFIG_MAX_APP_PROTOCOL]; 117adfc5217SJeff Kirsher u32 admin_default_priority; 118adfc5217SJeff Kirsher }; 119adfc5217SJeff Kirsher 120adfc5217SJeff Kirsher #define GET_FLAGS(flags, bits) ((flags) & (bits)) 121adfc5217SJeff Kirsher #define SET_FLAGS(flags, bits) ((flags) |= (bits)) 122adfc5217SJeff Kirsher #define RESET_FLAGS(flags, bits) ((flags) &= ~(bits)) 123adfc5217SJeff Kirsher 124adfc5217SJeff Kirsher enum { 125adfc5217SJeff Kirsher DCBX_READ_LOCAL_MIB, 126adfc5217SJeff Kirsher DCBX_READ_REMOTE_MIB 127adfc5217SJeff Kirsher }; 128adfc5217SJeff Kirsher 129adfc5217SJeff Kirsher #define ETH_TYPE_FCOE (0x8906) 130adfc5217SJeff Kirsher #define TCP_PORT_ISCSI (0xCBC) 131adfc5217SJeff Kirsher 132adfc5217SJeff Kirsher #define PFC_VALUE_FRAME_SIZE (512) 133adfc5217SJeff Kirsher #define PFC_QUANTA_IN_NANOSEC_FROM_SPEED_MEGA(mega_speed) \ 134adfc5217SJeff Kirsher ((1000 * PFC_VALUE_FRAME_SIZE)/(mega_speed)) 135adfc5217SJeff Kirsher 136adfc5217SJeff Kirsher #define PFC_BRB1_REG_HIGH_LLFC_LOW_THRESHOLD 130 137adfc5217SJeff Kirsher #define PFC_BRB1_REG_HIGH_LLFC_HIGH_THRESHOLD 170 138adfc5217SJeff Kirsher 139adfc5217SJeff Kirsher struct cos_entry_help_data { 140adfc5217SJeff Kirsher u32 pri_join_mask; 141adfc5217SJeff Kirsher u32 cos_bw; 142adfc5217SJeff Kirsher u8 strict; 143adfc5217SJeff Kirsher bool pausable; 144adfc5217SJeff Kirsher }; 145adfc5217SJeff Kirsher 146adfc5217SJeff Kirsher struct cos_help_data { 147adfc5217SJeff Kirsher struct cos_entry_help_data data[DCBX_COS_MAX_NUM]; 148adfc5217SJeff Kirsher u8 num_of_cos; 149adfc5217SJeff Kirsher }; 150adfc5217SJeff Kirsher 151adfc5217SJeff Kirsher #define DCBX_ILLEGAL_PG (0xFF) 152adfc5217SJeff Kirsher #define DCBX_PFC_PRI_MASK (0xFF) 153adfc5217SJeff Kirsher #define DCBX_STRICT_PRIORITY (15) 154adfc5217SJeff Kirsher #define DCBX_INVALID_COS_BW (0xFFFFFFFF) 155adfc5217SJeff Kirsher #define DCBX_PFC_PRI_NON_PAUSE_MASK(bp) \ 156adfc5217SJeff Kirsher ((bp)->dcbx_port_params.pfc.priority_non_pauseable_mask) 157adfc5217SJeff Kirsher #define DCBX_PFC_PRI_PAUSE_MASK(bp) \ 158adfc5217SJeff Kirsher ((u8)~DCBX_PFC_PRI_NON_PAUSE_MASK(bp)) 159adfc5217SJeff Kirsher #define DCBX_PFC_PRI_GET_PAUSE(bp, pg_pri) \ 160adfc5217SJeff Kirsher ((pg_pri) & (DCBX_PFC_PRI_PAUSE_MASK(bp))) 161adfc5217SJeff Kirsher #define DCBX_PFC_PRI_GET_NON_PAUSE(bp, pg_pri) \ 162adfc5217SJeff Kirsher (DCBX_PFC_PRI_NON_PAUSE_MASK(bp) & (pg_pri)) 163adfc5217SJeff Kirsher #define DCBX_IS_PFC_PRI_SOME_PAUSE(bp, pg_pri) \ 164adfc5217SJeff Kirsher (0 != DCBX_PFC_PRI_GET_PAUSE(bp, pg_pri)) 165adfc5217SJeff Kirsher #define IS_DCBX_PFC_PRI_ONLY_PAUSE(bp, pg_pri) \ 166adfc5217SJeff Kirsher (pg_pri == DCBX_PFC_PRI_GET_PAUSE((bp), (pg_pri))) 167adfc5217SJeff Kirsher #define IS_DCBX_PFC_PRI_ONLY_NON_PAUSE(bp, pg_pri)\ 168adfc5217SJeff Kirsher ((pg_pri) == DCBX_PFC_PRI_GET_NON_PAUSE((bp), (pg_pri))) 169adfc5217SJeff Kirsher #define IS_DCBX_PFC_PRI_MIX_PAUSE(bp, pg_pri) \ 170adfc5217SJeff Kirsher (!(IS_DCBX_PFC_PRI_ONLY_NON_PAUSE((bp), (pg_pri)) || \ 171adfc5217SJeff Kirsher IS_DCBX_PFC_PRI_ONLY_PAUSE((bp), (pg_pri)))) 172adfc5217SJeff Kirsher 173adfc5217SJeff Kirsher struct pg_entry_help_data { 174adfc5217SJeff Kirsher u8 num_of_dif_pri; 175adfc5217SJeff Kirsher u8 pg; 176adfc5217SJeff Kirsher u32 pg_priority; 177adfc5217SJeff Kirsher }; 178adfc5217SJeff Kirsher 179adfc5217SJeff Kirsher struct pg_help_data { 180adfc5217SJeff Kirsher struct pg_entry_help_data data[LLFC_DRIVER_TRAFFIC_TYPE_MAX]; 181adfc5217SJeff Kirsher u8 num_of_pg; 182adfc5217SJeff Kirsher }; 183adfc5217SJeff Kirsher 184adfc5217SJeff Kirsher /* forward DCB/PFC related declarations */ 185adfc5217SJeff Kirsher struct bnx2x; 186adfc5217SJeff Kirsher void bnx2x_dcbx_update(struct work_struct *work); 187adfc5217SJeff Kirsher void bnx2x_dcbx_init_params(struct bnx2x *bp); 188adfc5217SJeff Kirsher void bnx2x_dcbx_set_state(struct bnx2x *bp, bool dcb_on, u32 dcbx_enabled); 189adfc5217SJeff Kirsher 190adfc5217SJeff Kirsher enum { 191adfc5217SJeff Kirsher BNX2X_DCBX_STATE_NEG_RECEIVED = 0x1, 192adfc5217SJeff Kirsher BNX2X_DCBX_STATE_TX_PAUSED, 193adfc5217SJeff Kirsher BNX2X_DCBX_STATE_TX_RELEASED 194adfc5217SJeff Kirsher }; 195adfc5217SJeff Kirsher 196adfc5217SJeff Kirsher void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state); 197adfc5217SJeff Kirsher void bnx2x_dcbx_pmf_update(struct bnx2x *bp); 198adfc5217SJeff Kirsher /* DCB netlink */ 199adfc5217SJeff Kirsher #ifdef BCM_DCBNL 200adfc5217SJeff Kirsher extern const struct dcbnl_rtnl_ops bnx2x_dcbnl_ops; 201adfc5217SJeff Kirsher int bnx2x_dcbnl_update_applist(struct bnx2x *bp, bool delall); 202adfc5217SJeff Kirsher #endif /* BCM_DCBNL */ 203adfc5217SJeff Kirsher 20407b4eb3bSDmitry Kravkov int bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp); 20507b4eb3bSDmitry Kravkov int bnx2x_dcbx_resume_hw_tx(struct bnx2x *bp); 20607b4eb3bSDmitry Kravkov 207adfc5217SJeff Kirsher #endif /* BNX2X_DCB_H */ 208