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_lib.h"
9 
10 #ifdef CONFIG_DCB
11 #define ICE_TC_MAX_BW 100 /* Default Max BW percentage */
12 
13 void ice_dcb_rebuild(struct ice_pf *pf);
14 u8 ice_dcb_get_ena_tc(struct ice_dcbx_cfg *dcbcfg);
15 u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg *dcbcfg);
16 void ice_vsi_cfg_dcb_rings(struct ice_vsi *vsi);
17 int ice_init_pf_dcb(struct ice_pf *pf, bool locked);
18 void ice_update_dcb_stats(struct ice_pf *pf);
19 int
20 ice_tx_prepare_vlan_flags_dcb(struct ice_ring *tx_ring,
21 			      struct ice_tx_buf *first);
22 void
23 ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf,
24 				    struct ice_rq_event_info *event);
25 static inline void
26 ice_set_cgd_num(struct ice_tlan_ctx *tlan_ctx, struct ice_ring *ring)
27 {
28 	tlan_ctx->cgd_num = ring->dcb_tc;
29 }
30 #else
31 #define ice_dcb_rebuild(pf) do {} while (0)
32 
33 static inline u8 ice_dcb_get_ena_tc(struct ice_dcbx_cfg __always_unused *dcbcfg)
34 {
35 	return ICE_DFLT_TRAFFIC_CLASS;
36 }
37 
38 static inline u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg __always_unused *dcbcfg)
39 {
40 	return 1;
41 }
42 
43 static inline int
44 ice_init_pf_dcb(struct ice_pf *pf, bool __always_unused locked)
45 {
46 	dev_dbg(&pf->pdev->dev, "DCB not supported\n");
47 	return -EOPNOTSUPP;
48 }
49 
50 static inline int
51 ice_tx_prepare_vlan_flags_dcb(struct ice_ring __always_unused *tx_ring,
52 			      struct ice_tx_buf __always_unused *first)
53 {
54 	return 0;
55 }
56 
57 #define ice_update_dcb_stats(pf) do {} while (0)
58 #define ice_vsi_cfg_dcb_rings(vsi) do {} while (0)
59 #define ice_dcb_process_lldp_set_mib_change(pf, event) do {} while (0)
60 #define ice_set_cgd_num(tlan_ctx, ring) do {} while (0)
61 #endif /* CONFIG_DCB */
62 #endif /* _ICE_DCB_LIB_H_ */
63