1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Copyright (c) 2019, Intel Corporation. */ 3 4 #ifndef _ICE_DCB_LIB_H_ 5 #define _ICE_DCB_LIB_H_ 6 7 #include "ice.h" 8 #include "ice_base.h" 9 #include "ice_lib.h" 10 11 #ifdef CONFIG_DCB 12 #define ICE_TC_MAX_BW 100 /* Default Max BW percentage */ 13 #define ICE_DCB_HW_CHG_RST 0 /* DCB configuration changed with reset */ 14 #define ICE_DCB_NO_HW_CHG 1 /* DCB configuration did not change */ 15 #define ICE_DCB_HW_CHG 2 /* DCB configuration changed, no reset */ 16 17 void ice_dcb_rebuild(struct ice_pf *pf); 18 u8 ice_dcb_get_ena_tc(struct ice_dcbx_cfg *dcbcfg); 19 u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg *dcbcfg); 20 u8 ice_dcb_get_tc(struct ice_vsi *vsi, int queue_index); 21 int 22 ice_pf_dcb_cfg(struct ice_pf *pf, struct ice_dcbx_cfg *new_cfg, bool locked); 23 int ice_dcb_bwchk(struct ice_pf *pf, struct ice_dcbx_cfg *dcbcfg); 24 void ice_pf_dcb_recfg(struct ice_pf *pf); 25 void ice_vsi_cfg_dcb_rings(struct ice_vsi *vsi); 26 int ice_init_pf_dcb(struct ice_pf *pf, bool locked); 27 void ice_update_dcb_stats(struct ice_pf *pf); 28 int 29 ice_tx_prepare_vlan_flags_dcb(struct ice_ring *tx_ring, 30 struct ice_tx_buf *first); 31 void 32 ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf, 33 struct ice_rq_event_info *event); 34 void ice_vsi_cfg_netdev_tc(struct ice_vsi *vsi, u8 ena_tc); 35 static inline void 36 ice_set_cgd_num(struct ice_tlan_ctx *tlan_ctx, struct ice_ring *ring) 37 { 38 tlan_ctx->cgd_num = ring->dcb_tc; 39 } 40 #else 41 #define ice_dcb_rebuild(pf) do {} while (0) 42 43 static inline u8 ice_dcb_get_ena_tc(struct ice_dcbx_cfg __always_unused *dcbcfg) 44 { 45 return ICE_DFLT_TRAFFIC_CLASS; 46 } 47 48 static inline u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg __always_unused *dcbcfg) 49 { 50 return 1; 51 } 52 53 static inline u8 54 ice_dcb_get_tc(struct ice_vsi __always_unused *vsi, 55 int __always_unused queue_index) 56 { 57 return 0; 58 } 59 60 static inline int 61 ice_init_pf_dcb(struct ice_pf *pf, bool __always_unused locked) 62 { 63 dev_dbg(ice_pf_to_dev(pf), "DCB not supported\n"); 64 return -EOPNOTSUPP; 65 } 66 67 static inline int 68 ice_pf_dcb_cfg(struct ice_pf __always_unused *pf, 69 struct ice_dcbx_cfg __always_unused *new_cfg, 70 bool __always_unused locked) 71 { 72 return -EOPNOTSUPP; 73 } 74 75 static inline int 76 ice_tx_prepare_vlan_flags_dcb(struct ice_ring __always_unused *tx_ring, 77 struct ice_tx_buf __always_unused *first) 78 { 79 return 0; 80 } 81 82 #define ice_update_dcb_stats(pf) do {} while (0) 83 #define ice_pf_dcb_recfg(pf) do {} while (0) 84 #define ice_vsi_cfg_dcb_rings(vsi) do {} while (0) 85 #define ice_dcb_process_lldp_set_mib_change(pf, event) do {} while (0) 86 #define ice_set_cgd_num(tlan_ctx, ring) do {} while (0) 87 #define ice_vsi_cfg_netdev_tc(vsi, ena_tc) do {} while (0) 88 #endif /* CONFIG_DCB */ 89 #endif /* _ICE_DCB_LIB_H_ */ 90