1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2019, Intel Corporation. */
4 #ifndef _ICE_DCB_LIB_H_
5 #define _ICE_DCB_LIB_H_
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 */
17 void ice_dcb_rebuild(struct ice_pf *pf);
18 int ice_dcb_sw_dflt_cfg(struct ice_pf *pf, bool ets_willing, bool locked);
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);
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);
31 ice_tx_prepare_vlan_flags_dcb(struct ice_tx_ring *tx_ring,
32 struct ice_tx_buf *first);
34 ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf,
35 struct ice_rq_event_info *event);
38 * @low: start of queue range for a TC i.e. offset of TC
39 * @high: start of queue for next TC
40 * @tx_q: hung_queue/tx_queue
42 * finds if queue 'tx_q' falls between the two offsets of any given TC
44 static inline bool ice_find_q_in_range(u16 low, u16 high, unsigned int tx_q)
46 return (tx_q >= low) && (tx_q < high);
50 ice_set_cgd_num(struct ice_tlan_ctx *tlan_ctx, u8 dcb_tc)
52 tlan_ctx->cgd_num = dcb_tc;
55 static inline bool ice_is_dcb_active(struct ice_pf *pf)
57 return (test_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags) ||
58 test_bit(ICE_FLAG_DCB_ENA, pf->flags));
61 static inline u8 ice_get_pfc_mode(struct ice_pf *pf)
63 return pf->hw.port_info->qos_cfg.local_dcbx_cfg.pfc_mode;
67 static inline void ice_dcb_rebuild(struct ice_pf *pf) { }
69 static inline void ice_vsi_set_dcb_tc_cfg(struct ice_vsi *vsi)
71 vsi->tc_cfg.ena_tc = ICE_DFLT_TRAFFIC_CLASS;
72 vsi->tc_cfg.numtc = 1;
75 static inline u8 ice_dcb_get_ena_tc(struct ice_dcbx_cfg __always_unused *dcbcfg)
77 return ICE_DFLT_TRAFFIC_CLASS;
80 static inline u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg __always_unused *dcbcfg)
86 ice_dcb_get_tc(struct ice_vsi __always_unused *vsi,
87 int __always_unused queue_index)
93 ice_init_pf_dcb(struct ice_pf *pf, bool __always_unused locked)
95 dev_dbg(ice_pf_to_dev(pf), "DCB not supported\n");
100 ice_pf_dcb_cfg(struct ice_pf __always_unused *pf,
101 struct ice_dcbx_cfg __always_unused *new_cfg,
102 bool __always_unused locked)
108 ice_tx_prepare_vlan_flags_dcb(struct ice_tx_ring __always_unused *tx_ring,
109 struct ice_tx_buf __always_unused *first)
114 static inline bool ice_is_dcb_active(struct ice_pf __always_unused *pf)
120 ice_is_pfc_causing_hung_q(struct ice_pf __always_unused *pf,
121 unsigned int __always_unused txqueue)
126 static inline u8 ice_get_pfc_mode(struct ice_pf *pf)
131 static inline void ice_pf_dcb_recfg(struct ice_pf *pf) { }
132 static inline void ice_vsi_cfg_dcb_rings(struct ice_vsi *vsi) { }
133 static inline void ice_update_dcb_stats(struct ice_pf *pf) { }
135 ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf, struct ice_rq_event_info *event) { }
136 static inline void ice_set_cgd_num(struct ice_tlan_ctx *tlan_ctx, u8 dcb_tc) { }
137 #endif /* CONFIG_DCB */
138 #endif /* _ICE_DCB_LIB_H_ */