18c2ecf20Sopenharmony_ci/* bnx2x_dcb.h: QLogic Everest network driver. 28c2ecf20Sopenharmony_ci * 38c2ecf20Sopenharmony_ci * Copyright 2009-2013 Broadcom Corporation 48c2ecf20Sopenharmony_ci * Copyright 2014 QLogic Corporation 58c2ecf20Sopenharmony_ci * All rights reserved 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Unless you and QLogic execute a separate written software license 88c2ecf20Sopenharmony_ci * agreement governing use of this software, this software is licensed to you 98c2ecf20Sopenharmony_ci * under the terms of the GNU General Public License version 2, available 108c2ecf20Sopenharmony_ci * at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html (the "GPL"). 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * Notwithstanding the above, under no circumstances may you combine this 138c2ecf20Sopenharmony_ci * software in any way with any other QLogic software provided under a 148c2ecf20Sopenharmony_ci * license other than the GPL, without QLogic's express prior written 158c2ecf20Sopenharmony_ci * consent. 168c2ecf20Sopenharmony_ci * 178c2ecf20Sopenharmony_ci * Maintained by: Ariel Elior <ariel.elior@qlogic.com> 188c2ecf20Sopenharmony_ci * Written by: Dmitry Kravkov 198c2ecf20Sopenharmony_ci * 208c2ecf20Sopenharmony_ci */ 218c2ecf20Sopenharmony_ci#ifndef BNX2X_DCB_H 228c2ecf20Sopenharmony_ci#define BNX2X_DCB_H 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#include "bnx2x_hsi.h" 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define LLFC_DRIVER_TRAFFIC_TYPE_MAX 3 /* NW, iSCSI, FCoE */ 278c2ecf20Sopenharmony_cistruct bnx2x_dcbx_app_params { 288c2ecf20Sopenharmony_ci u32 enabled; 298c2ecf20Sopenharmony_ci u32 traffic_type_priority[LLFC_DRIVER_TRAFFIC_TYPE_MAX]; 308c2ecf20Sopenharmony_ci}; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#define DCBX_COS_MAX_NUM_E2 DCBX_E2E3_MAX_NUM_COS 338c2ecf20Sopenharmony_ci/* bnx2x currently limits numbers of supported COSes to 3 to be extended to 6 */ 348c2ecf20Sopenharmony_ci#define BNX2X_MAX_COS_SUPPORT 3 358c2ecf20Sopenharmony_ci#define DCBX_COS_MAX_NUM_E3B0 BNX2X_MAX_COS_SUPPORT 368c2ecf20Sopenharmony_ci#define DCBX_COS_MAX_NUM BNX2X_MAX_COS_SUPPORT 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_cistruct bnx2x_dcbx_cos_params { 398c2ecf20Sopenharmony_ci u32 bw_tbl; 408c2ecf20Sopenharmony_ci u32 pri_bitmask; 418c2ecf20Sopenharmony_ci /* 428c2ecf20Sopenharmony_ci * strict priority: valid values are 0..5; 0 is highest priority. 438c2ecf20Sopenharmony_ci * There can't be two COSes with the same priority. 448c2ecf20Sopenharmony_ci */ 458c2ecf20Sopenharmony_ci u8 strict; 468c2ecf20Sopenharmony_ci#define BNX2X_DCBX_STRICT_INVALID DCBX_COS_MAX_NUM 478c2ecf20Sopenharmony_ci#define BNX2X_DCBX_STRICT_COS_HIGHEST 0 488c2ecf20Sopenharmony_ci#define BNX2X_DCBX_STRICT_COS_NEXT_LOWER_PRI(sp) ((sp) + 1) 498c2ecf20Sopenharmony_ci u8 pauseable; 508c2ecf20Sopenharmony_ci}; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistruct bnx2x_dcbx_pg_params { 538c2ecf20Sopenharmony_ci u32 enabled; 548c2ecf20Sopenharmony_ci u8 num_of_cos; /* valid COS entries */ 558c2ecf20Sopenharmony_ci struct bnx2x_dcbx_cos_params cos_params[DCBX_COS_MAX_NUM]; 568c2ecf20Sopenharmony_ci}; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cistruct bnx2x_dcbx_pfc_params { 598c2ecf20Sopenharmony_ci u32 enabled; 608c2ecf20Sopenharmony_ci u32 priority_non_pauseable_mask; 618c2ecf20Sopenharmony_ci}; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_cistruct bnx2x_dcbx_port_params { 648c2ecf20Sopenharmony_ci struct bnx2x_dcbx_pfc_params pfc; 658c2ecf20Sopenharmony_ci struct bnx2x_dcbx_pg_params ets; 668c2ecf20Sopenharmony_ci struct bnx2x_dcbx_app_params app; 678c2ecf20Sopenharmony_ci}; 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#define BNX2X_DCBX_CONFIG_INV_VALUE (0xFFFFFFFF) 708c2ecf20Sopenharmony_ci#define BNX2X_DCBX_OVERWRITE_SETTINGS_DISABLE 0 718c2ecf20Sopenharmony_ci#define BNX2X_DCBX_OVERWRITE_SETTINGS_ENABLE 1 728c2ecf20Sopenharmony_ci#define BNX2X_DCBX_OVERWRITE_SETTINGS_INVALID (BNX2X_DCBX_CONFIG_INV_VALUE) 738c2ecf20Sopenharmony_ci#define BNX2X_IS_ETS_ENABLED(bp) ((bp)->dcb_state == BNX2X_DCB_STATE_ON &&\ 748c2ecf20Sopenharmony_ci (bp)->dcbx_port_params.ets.enabled) 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_cistruct bnx2x_config_lldp_params { 778c2ecf20Sopenharmony_ci u32 overwrite_settings; 788c2ecf20Sopenharmony_ci u32 msg_tx_hold; 798c2ecf20Sopenharmony_ci u32 msg_fast_tx; 808c2ecf20Sopenharmony_ci u32 tx_credit_max; 818c2ecf20Sopenharmony_ci u32 msg_tx_interval; 828c2ecf20Sopenharmony_ci u32 tx_fast; 838c2ecf20Sopenharmony_ci}; 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_cistruct bnx2x_admin_priority_app_table { 868c2ecf20Sopenharmony_ci u32 valid; 878c2ecf20Sopenharmony_ci u32 priority; 888c2ecf20Sopenharmony_ci#define INVALID_TRAFFIC_TYPE_PRIORITY (0xFFFFFFFF) 898c2ecf20Sopenharmony_ci u32 traffic_type; 908c2ecf20Sopenharmony_ci#define TRAFFIC_TYPE_ETH 0 918c2ecf20Sopenharmony_ci#define TRAFFIC_TYPE_PORT 1 928c2ecf20Sopenharmony_ci u32 app_id; 938c2ecf20Sopenharmony_ci}; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci#define DCBX_CONFIG_MAX_APP_PROTOCOL 4 968c2ecf20Sopenharmony_cistruct bnx2x_config_dcbx_params { 978c2ecf20Sopenharmony_ci u32 overwrite_settings; 988c2ecf20Sopenharmony_ci u32 admin_dcbx_version; 998c2ecf20Sopenharmony_ci u32 admin_ets_enable; 1008c2ecf20Sopenharmony_ci u32 admin_pfc_enable; 1018c2ecf20Sopenharmony_ci u32 admin_tc_supported_tx_enable; 1028c2ecf20Sopenharmony_ci u32 admin_ets_configuration_tx_enable; 1038c2ecf20Sopenharmony_ci u32 admin_ets_recommendation_tx_enable; 1048c2ecf20Sopenharmony_ci u32 admin_pfc_tx_enable; 1058c2ecf20Sopenharmony_ci u32 admin_application_priority_tx_enable; 1068c2ecf20Sopenharmony_ci u32 admin_ets_willing; 1078c2ecf20Sopenharmony_ci u32 admin_ets_reco_valid; 1088c2ecf20Sopenharmony_ci u32 admin_pfc_willing; 1098c2ecf20Sopenharmony_ci u32 admin_app_priority_willing; 1108c2ecf20Sopenharmony_ci u32 admin_configuration_bw_precentage[8]; 1118c2ecf20Sopenharmony_ci u32 admin_configuration_ets_pg[8]; 1128c2ecf20Sopenharmony_ci u32 admin_recommendation_bw_precentage[8]; 1138c2ecf20Sopenharmony_ci u32 admin_recommendation_ets_pg[8]; 1148c2ecf20Sopenharmony_ci u32 admin_pfc_bitmap; 1158c2ecf20Sopenharmony_ci struct bnx2x_admin_priority_app_table 1168c2ecf20Sopenharmony_ci admin_priority_app_table[DCBX_CONFIG_MAX_APP_PROTOCOL]; 1178c2ecf20Sopenharmony_ci u32 admin_default_priority; 1188c2ecf20Sopenharmony_ci}; 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci#define GET_FLAGS(flags, bits) ((flags) & (bits)) 1218c2ecf20Sopenharmony_ci#define SET_FLAGS(flags, bits) ((flags) |= (bits)) 1228c2ecf20Sopenharmony_ci#define RESET_FLAGS(flags, bits) ((flags) &= ~(bits)) 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_cienum { 1258c2ecf20Sopenharmony_ci DCBX_READ_LOCAL_MIB, 1268c2ecf20Sopenharmony_ci DCBX_READ_REMOTE_MIB 1278c2ecf20Sopenharmony_ci}; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci#define ETH_TYPE_FCOE (0x8906) 1308c2ecf20Sopenharmony_ci#define TCP_PORT_ISCSI (0xCBC) 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci#define PFC_VALUE_FRAME_SIZE (512) 1338c2ecf20Sopenharmony_ci#define PFC_QUANTA_IN_NANOSEC_FROM_SPEED_MEGA(mega_speed) \ 1348c2ecf20Sopenharmony_ci ((1000 * PFC_VALUE_FRAME_SIZE)/(mega_speed)) 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci#define PFC_BRB1_REG_HIGH_LLFC_LOW_THRESHOLD 130 1378c2ecf20Sopenharmony_ci#define PFC_BRB1_REG_HIGH_LLFC_HIGH_THRESHOLD 170 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_cistruct cos_entry_help_data { 1408c2ecf20Sopenharmony_ci u32 pri_join_mask; 1418c2ecf20Sopenharmony_ci u32 cos_bw; 1428c2ecf20Sopenharmony_ci u8 strict; 1438c2ecf20Sopenharmony_ci bool pausable; 1448c2ecf20Sopenharmony_ci}; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_cistruct cos_help_data { 1478c2ecf20Sopenharmony_ci struct cos_entry_help_data data[DCBX_COS_MAX_NUM]; 1488c2ecf20Sopenharmony_ci u8 num_of_cos; 1498c2ecf20Sopenharmony_ci}; 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci#define DCBX_ILLEGAL_PG (0xFF) 1528c2ecf20Sopenharmony_ci#define DCBX_PFC_PRI_MASK (0xFF) 1538c2ecf20Sopenharmony_ci#define DCBX_STRICT_PRIORITY (15) 1548c2ecf20Sopenharmony_ci#define DCBX_INVALID_COS_BW (0xFFFFFFFF) 1558c2ecf20Sopenharmony_ci#define DCBX_PFC_PRI_NON_PAUSE_MASK(bp) \ 1568c2ecf20Sopenharmony_ci ((bp)->dcbx_port_params.pfc.priority_non_pauseable_mask) 1578c2ecf20Sopenharmony_ci#define DCBX_PFC_PRI_PAUSE_MASK(bp) \ 1588c2ecf20Sopenharmony_ci ((u8)~DCBX_PFC_PRI_NON_PAUSE_MASK(bp)) 1598c2ecf20Sopenharmony_ci#define DCBX_PFC_PRI_GET_PAUSE(bp, pg_pri) \ 1608c2ecf20Sopenharmony_ci ((pg_pri) & (DCBX_PFC_PRI_PAUSE_MASK(bp))) 1618c2ecf20Sopenharmony_ci#define DCBX_PFC_PRI_GET_NON_PAUSE(bp, pg_pri) \ 1628c2ecf20Sopenharmony_ci (DCBX_PFC_PRI_NON_PAUSE_MASK(bp) & (pg_pri)) 1638c2ecf20Sopenharmony_ci#define DCBX_IS_PFC_PRI_SOME_PAUSE(bp, pg_pri) \ 1648c2ecf20Sopenharmony_ci (0 != DCBX_PFC_PRI_GET_PAUSE(bp, pg_pri)) 1658c2ecf20Sopenharmony_ci#define IS_DCBX_PFC_PRI_ONLY_PAUSE(bp, pg_pri) \ 1668c2ecf20Sopenharmony_ci (pg_pri == DCBX_PFC_PRI_GET_PAUSE((bp), (pg_pri))) 1678c2ecf20Sopenharmony_ci#define IS_DCBX_PFC_PRI_ONLY_NON_PAUSE(bp, pg_pri)\ 1688c2ecf20Sopenharmony_ci ((pg_pri) == DCBX_PFC_PRI_GET_NON_PAUSE((bp), (pg_pri))) 1698c2ecf20Sopenharmony_ci#define IS_DCBX_PFC_PRI_MIX_PAUSE(bp, pg_pri) \ 1708c2ecf20Sopenharmony_ci (!(IS_DCBX_PFC_PRI_ONLY_NON_PAUSE((bp), (pg_pri)) || \ 1718c2ecf20Sopenharmony_ci IS_DCBX_PFC_PRI_ONLY_PAUSE((bp), (pg_pri)))) 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_cistruct pg_entry_help_data { 1748c2ecf20Sopenharmony_ci u8 num_of_dif_pri; 1758c2ecf20Sopenharmony_ci u8 pg; 1768c2ecf20Sopenharmony_ci u32 pg_priority; 1778c2ecf20Sopenharmony_ci}; 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_cistruct pg_help_data { 1808c2ecf20Sopenharmony_ci struct pg_entry_help_data data[LLFC_DRIVER_TRAFFIC_TYPE_MAX]; 1818c2ecf20Sopenharmony_ci u8 num_of_pg; 1828c2ecf20Sopenharmony_ci}; 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci/* forward DCB/PFC related declarations */ 1858c2ecf20Sopenharmony_cistruct bnx2x; 1868c2ecf20Sopenharmony_civoid bnx2x_dcbx_update(struct work_struct *work); 1878c2ecf20Sopenharmony_civoid bnx2x_dcbx_init_params(struct bnx2x *bp); 1888c2ecf20Sopenharmony_civoid bnx2x_dcbx_set_state(struct bnx2x *bp, bool dcb_on, u32 dcbx_enabled); 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_cienum { 1918c2ecf20Sopenharmony_ci BNX2X_DCBX_STATE_NEG_RECEIVED = 0x1, 1928c2ecf20Sopenharmony_ci BNX2X_DCBX_STATE_TX_PAUSED, 1938c2ecf20Sopenharmony_ci BNX2X_DCBX_STATE_TX_RELEASED 1948c2ecf20Sopenharmony_ci}; 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_civoid bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state); 1978c2ecf20Sopenharmony_civoid bnx2x_dcbx_pmf_update(struct bnx2x *bp); 1988c2ecf20Sopenharmony_ci/* DCB netlink */ 1998c2ecf20Sopenharmony_ci#ifdef BCM_DCBNL 2008c2ecf20Sopenharmony_ciextern const struct dcbnl_rtnl_ops bnx2x_dcbnl_ops; 2018c2ecf20Sopenharmony_ciint bnx2x_dcbnl_update_applist(struct bnx2x *bp, bool delall); 2028c2ecf20Sopenharmony_ci#endif /* BCM_DCBNL */ 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ciint bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp); 2058c2ecf20Sopenharmony_ciint bnx2x_dcbx_resume_hw_tx(struct bnx2x *bp); 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ci#endif /* BNX2X_DCB_H */ 208