Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright (c) 2019, Intel Corporation. */
0003 
0004 #ifndef _ICE_DCB_LIB_H_
0005 #define _ICE_DCB_LIB_H_
0006 
0007 #include "ice.h"
0008 #include "ice_base.h"
0009 #include "ice_lib.h"
0010 
0011 #ifdef CONFIG_DCB
0012 #define ICE_TC_MAX_BW       100 /* Default Max BW percentage */
0013 #define ICE_DCB_HW_CHG_RST  0 /* DCB configuration changed with reset */
0014 #define ICE_DCB_NO_HW_CHG   1 /* DCB configuration did not change */
0015 #define ICE_DCB_HW_CHG      2 /* DCB configuration changed, no reset */
0016 
0017 void ice_dcb_rebuild(struct ice_pf *pf);
0018 int ice_dcb_sw_dflt_cfg(struct ice_pf *pf, bool ets_willing, bool locked);
0019 u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg *dcbcfg);
0020 void ice_vsi_set_dcb_tc_cfg(struct ice_vsi *vsi);
0021 bool ice_is_pfc_causing_hung_q(struct ice_pf *pf, unsigned int txqueue);
0022 u8 ice_dcb_get_tc(struct ice_vsi *vsi, int queue_index);
0023 int
0024 ice_pf_dcb_cfg(struct ice_pf *pf, struct ice_dcbx_cfg *new_cfg, bool locked);
0025 int ice_dcb_bwchk(struct ice_pf *pf, struct ice_dcbx_cfg *dcbcfg);
0026 void ice_pf_dcb_recfg(struct ice_pf *pf);
0027 void ice_vsi_cfg_dcb_rings(struct ice_vsi *vsi);
0028 int ice_init_pf_dcb(struct ice_pf *pf, bool locked);
0029 void ice_update_dcb_stats(struct ice_pf *pf);
0030 void
0031 ice_tx_prepare_vlan_flags_dcb(struct ice_tx_ring *tx_ring,
0032                   struct ice_tx_buf *first);
0033 void
0034 ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf,
0035                     struct ice_rq_event_info *event);
0036 /**
0037  * ice_find_q_in_range
0038  * @low: start of queue range for a TC i.e. offset of TC
0039  * @high: start of queue for next TC
0040  * @tx_q: hung_queue/tx_queue
0041  *
0042  * finds if queue 'tx_q' falls between the two offsets of any given TC
0043  */
0044 static inline bool ice_find_q_in_range(u16 low, u16 high, unsigned int tx_q)
0045 {
0046     return (tx_q >= low) && (tx_q < high);
0047 }
0048 
0049 static inline void
0050 ice_set_cgd_num(struct ice_tlan_ctx *tlan_ctx, u8 dcb_tc)
0051 {
0052     tlan_ctx->cgd_num = dcb_tc;
0053 }
0054 
0055 static inline bool ice_is_dcb_active(struct ice_pf *pf)
0056 {
0057     return (test_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags) ||
0058         test_bit(ICE_FLAG_DCB_ENA, pf->flags));
0059 }
0060 
0061 static inline u8 ice_get_pfc_mode(struct ice_pf *pf)
0062 {
0063     return pf->hw.port_info->qos_cfg.local_dcbx_cfg.pfc_mode;
0064 }
0065 
0066 #else
0067 static inline void ice_dcb_rebuild(struct ice_pf *pf) { }
0068 
0069 static inline void ice_vsi_set_dcb_tc_cfg(struct ice_vsi *vsi)
0070 {
0071     vsi->tc_cfg.ena_tc = ICE_DFLT_TRAFFIC_CLASS;
0072     vsi->tc_cfg.numtc = 1;
0073 }
0074 
0075 static inline u8 ice_dcb_get_ena_tc(struct ice_dcbx_cfg __always_unused *dcbcfg)
0076 {
0077     return ICE_DFLT_TRAFFIC_CLASS;
0078 }
0079 
0080 static inline u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg __always_unused *dcbcfg)
0081 {
0082     return 1;
0083 }
0084 
0085 static inline u8
0086 ice_dcb_get_tc(struct ice_vsi __always_unused *vsi,
0087            int __always_unused queue_index)
0088 {
0089     return 0;
0090 }
0091 
0092 static inline int
0093 ice_init_pf_dcb(struct ice_pf *pf, bool __always_unused locked)
0094 {
0095     dev_dbg(ice_pf_to_dev(pf), "DCB not supported\n");
0096     return -EOPNOTSUPP;
0097 }
0098 
0099 static inline int
0100 ice_pf_dcb_cfg(struct ice_pf __always_unused *pf,
0101            struct ice_dcbx_cfg __always_unused *new_cfg,
0102            bool __always_unused locked)
0103 {
0104     return -EOPNOTSUPP;
0105 }
0106 
0107 static inline int
0108 ice_tx_prepare_vlan_flags_dcb(struct ice_tx_ring __always_unused *tx_ring,
0109                   struct ice_tx_buf __always_unused *first)
0110 {
0111     return 0;
0112 }
0113 
0114 static inline bool ice_is_dcb_active(struct ice_pf __always_unused *pf)
0115 {
0116     return false;
0117 }
0118 
0119 static inline bool
0120 ice_is_pfc_causing_hung_q(struct ice_pf __always_unused *pf,
0121               unsigned int __always_unused txqueue)
0122 {
0123     return false;
0124 }
0125 
0126 static inline u8 ice_get_pfc_mode(struct ice_pf *pf)
0127 {
0128     return 0;
0129 }
0130 
0131 static inline void ice_pf_dcb_recfg(struct ice_pf *pf) { }
0132 static inline void ice_vsi_cfg_dcb_rings(struct ice_vsi *vsi) { }
0133 static inline void ice_update_dcb_stats(struct ice_pf *pf) { }
0134 static inline void
0135 ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf, struct ice_rq_event_info *event) { }
0136 static inline void ice_set_cgd_num(struct ice_tlan_ctx *tlan_ctx, u8 dcb_tc) { }
0137 #endif /* CONFIG_DCB */
0138 #endif /* _ICE_DCB_LIB_H_ */