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 void ice_vsi_cfg_netdev_tc(struct ice_vsi *vsi, u8 ena_tc);
26 static inline void
27 ice_set_cgd_num(struct ice_tlan_ctx *tlan_ctx, struct ice_ring *ring)
28 {
29 	tlan_ctx->cgd_num = ring->dcb_tc;
30 }
31 #else
32 #define ice_dcb_rebuild(pf) do {} while (0)
33 
34 static inline u8 ice_dcb_get_ena_tc(struct ice_dcbx_cfg __always_unused *dcbcfg)
35 {
36 	return ICE_DFLT_TRAFFIC_CLASS;
37 }
38 
39 static inline u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg __always_unused *dcbcfg)
40 {
41 	return 1;
42 }
43 
44 static inline int
45 ice_init_pf_dcb(struct ice_pf *pf, bool __always_unused locked)
46 {
47 	dev_dbg(&pf->pdev->dev, "DCB not supported\n");
48 	return -EOPNOTSUPP;
49 }
50 
51 static inline int
52 ice_tx_prepare_vlan_flags_dcb(struct ice_ring __always_unused *tx_ring,
53 			      struct ice_tx_buf __always_unused *first)
54 {
55 	return 0;
56 }
57 
58 #define ice_update_dcb_stats(pf) do {} while (0)
59 #define ice_vsi_cfg_dcb_rings(vsi) do {} while (0)
60 #define ice_dcb_process_lldp_set_mib_change(pf, event) do {} while (0)
61 #define ice_set_cgd_num(tlan_ctx, ring) do {} while (0)
62 #define ice_vsi_cfg_netdev_tc(vsi, ena_tc) do {} while (0)
63 #endif /* CONFIG_DCB */
64 #endif /* _ICE_DCB_LIB_H_ */
65