xref: /linux/drivers/net/ethernet/intel/ice/ice_dcb_lib.h (revision 4d66c56f7efe122d09d06cd3ebfa52a43d51a9cb)
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 u8 ice_dcb_get_tc(struct ice_vsi *vsi, int queue_index);
21 int
22 ice_pf_dcb_cfg(struct ice_pf *pf, struct ice_dcbx_cfg *new_cfg, bool locked);
23 void ice_vsi_cfg_dcb_rings(struct ice_vsi *vsi);
24 int ice_init_pf_dcb(struct ice_pf *pf, bool locked);
25 void ice_update_dcb_stats(struct ice_pf *pf);
26 int
27 ice_tx_prepare_vlan_flags_dcb(struct ice_ring *tx_ring,
28 			      struct ice_tx_buf *first);
29 void
30 ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf,
31 				    struct ice_rq_event_info *event);
32 void ice_vsi_cfg_netdev_tc(struct ice_vsi *vsi, u8 ena_tc);
33 static inline void
34 ice_set_cgd_num(struct ice_tlan_ctx *tlan_ctx, struct ice_ring *ring)
35 {
36 	tlan_ctx->cgd_num = ring->dcb_tc;
37 }
38 #else
39 #define ice_dcb_rebuild(pf) do {} while (0)
40 
41 static inline u8 ice_dcb_get_ena_tc(struct ice_dcbx_cfg __always_unused *dcbcfg)
42 {
43 	return ICE_DFLT_TRAFFIC_CLASS;
44 }
45 
46 static inline u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg __always_unused *dcbcfg)
47 {
48 	return 1;
49 }
50 
51 static inline u8
52 ice_dcb_get_tc(struct ice_vsi __always_unused *vsi,
53 	       int __always_unused queue_index)
54 {
55 	return 0;
56 }
57 
58 static inline int
59 ice_init_pf_dcb(struct ice_pf *pf, bool __always_unused locked)
60 {
61 	dev_dbg(&pf->pdev->dev, "DCB not supported\n");
62 	return -EOPNOTSUPP;
63 }
64 
65 static inline int
66 ice_pf_dcb_cfg(struct ice_pf __always_unused *pf,
67 	       struct ice_dcbx_cfg __always_unused *new_cfg,
68 	       bool __always_unused locked)
69 {
70 	return -EOPNOTSUPP;
71 }
72 
73 static inline int
74 ice_tx_prepare_vlan_flags_dcb(struct ice_ring __always_unused *tx_ring,
75 			      struct ice_tx_buf __always_unused *first)
76 {
77 	return 0;
78 }
79 
80 #define ice_update_dcb_stats(pf) do {} while (0)
81 #define ice_vsi_cfg_dcb_rings(vsi) do {} while (0)
82 #define ice_dcb_process_lldp_set_mib_change(pf, event) do {} while (0)
83 #define ice_set_cgd_num(tlan_ctx, ring) do {} while (0)
84 #define ice_vsi_cfg_netdev_tc(vsi, ena_tc) do {} while (0)
85 #endif /* CONFIG_DCB */
86 #endif /* _ICE_DCB_LIB_H_ */
87