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 void ice_vsi_set_dcb_tc_cfg(struct ice_vsi *vsi); 21 bool ice_is_pfc_causing_hung_q(struct ice_pf *pf, unsigned int txqueue); 22 u8 ice_dcb_get_tc(struct ice_vsi *vsi, int queue_index); 23 int 24 ice_pf_dcb_cfg(struct ice_pf *pf, struct ice_dcbx_cfg *new_cfg, bool locked); 25 int ice_dcb_bwchk(struct ice_pf *pf, struct ice_dcbx_cfg *dcbcfg); 26 void ice_pf_dcb_recfg(struct ice_pf *pf); 27 void ice_vsi_cfg_dcb_rings(struct ice_vsi *vsi); 28 int ice_init_pf_dcb(struct ice_pf *pf, bool locked); 29 void ice_update_dcb_stats(struct ice_pf *pf); 30 void 31 ice_tx_prepare_vlan_flags_dcb(struct ice_ring *tx_ring, 32 struct ice_tx_buf *first); 33 void 34 ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf, 35 struct ice_rq_event_info *event); 36 void ice_vsi_cfg_netdev_tc(struct ice_vsi *vsi, u8 ena_tc); 37 38 /** 39 * ice_find_q_in_range 40 * @low: start of queue range for a TC i.e. offset of TC 41 * @high: start of queue for next TC 42 * @tx_q: hung_queue/tx_queue 43 * 44 * finds if queue 'tx_q' falls between the two offsets of any given TC 45 */ 46 static inline bool ice_find_q_in_range(u16 low, u16 high, unsigned int tx_q) 47 { 48 return (tx_q >= low) && (tx_q < high); 49 } 50 51 static inline void 52 ice_set_cgd_num(struct ice_tlan_ctx *tlan_ctx, struct ice_ring *ring) 53 { 54 tlan_ctx->cgd_num = ring->dcb_tc; 55 } 56 #else 57 #define ice_dcb_rebuild(pf) do {} while (0) 58 59 static inline u8 ice_dcb_get_ena_tc(struct ice_dcbx_cfg __always_unused *dcbcfg) 60 { 61 return ICE_DFLT_TRAFFIC_CLASS; 62 } 63 64 static inline u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg __always_unused *dcbcfg) 65 { 66 return 1; 67 } 68 69 static inline u8 70 ice_dcb_get_tc(struct ice_vsi __always_unused *vsi, 71 int __always_unused queue_index) 72 { 73 return 0; 74 } 75 76 static inline int 77 ice_init_pf_dcb(struct ice_pf *pf, bool __always_unused locked) 78 { 79 dev_dbg(ice_pf_to_dev(pf), "DCB not supported\n"); 80 return -EOPNOTSUPP; 81 } 82 83 static inline int 84 ice_pf_dcb_cfg(struct ice_pf __always_unused *pf, 85 struct ice_dcbx_cfg __always_unused *new_cfg, 86 bool __always_unused locked) 87 { 88 return -EOPNOTSUPP; 89 } 90 91 static inline int 92 ice_tx_prepare_vlan_flags_dcb(struct ice_ring __always_unused *tx_ring, 93 struct ice_tx_buf __always_unused *first) 94 { 95 return 0; 96 } 97 98 static inline bool 99 ice_is_pfc_causing_hung_q(struct ice_pf __always_unused *pf, 100 unsigned int __always_unused txqueue) 101 { 102 return false; 103 } 104 105 #define ice_update_dcb_stats(pf) do {} while (0) 106 #define ice_pf_dcb_recfg(pf) do {} while (0) 107 #define ice_vsi_cfg_dcb_rings(vsi) do {} while (0) 108 #define ice_dcb_process_lldp_set_mib_change(pf, event) do {} while (0) 109 #define ice_set_cgd_num(tlan_ctx, ring) do {} while (0) 110 #define ice_vsi_cfg_netdev_tc(vsi, ena_tc) do {} while (0) 111 #endif /* CONFIG_DCB */ 112 #endif /* _ICE_DCB_LIB_H_ */ 113