1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#include "fm10k.h"
23
24
25
26
27
28
29static int fm10k_dcbnl_ieee_getets(struct net_device *dev, struct ieee_ets *ets)
30{
31 int i;
32
33
34 ets->ets_cap = IEEE_8021QAZ_MAX_TCS;
35 ets->cbs = 0;
36
37
38 memset(ets->tc_tx_bw, 0, sizeof(ets->tc_tx_bw));
39 memset(ets->tc_rx_bw, 0, sizeof(ets->tc_rx_bw));
40 memset(ets->tc_tsa, IEEE_8021QAZ_TSA_STRICT, sizeof(ets->tc_tsa));
41
42
43 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
44 ets->prio_tc[i] = netdev_get_prio_tc_map(dev, i);
45
46 return 0;
47}
48
49
50
51
52
53
54static int fm10k_dcbnl_ieee_setets(struct net_device *dev, struct ieee_ets *ets)
55{
56 u8 num_tc = 0;
57 int i, err;
58
59
60 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
61 if (ets->tc_tx_bw[i] || ets->tc_rx_bw[i])
62 return -EINVAL;
63 if (ets->tc_tsa[i] != IEEE_8021QAZ_TSA_STRICT)
64 return -EINVAL;
65 if (ets->prio_tc[i] > num_tc)
66 num_tc = ets->prio_tc[i];
67 }
68
69
70 if (num_tc)
71 num_tc++;
72
73 if (num_tc > IEEE_8021QAZ_MAX_TCS)
74 return -EINVAL;
75
76
77 if (num_tc != netdev_get_num_tc(dev)) {
78 err = fm10k_setup_tc(dev, num_tc);
79 if (err)
80 return err;
81 }
82
83
84 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++)
85 netdev_set_prio_tc_map(dev, i, ets->prio_tc[i]);
86
87 return 0;
88}
89
90
91
92
93
94
95static int fm10k_dcbnl_ieee_getpfc(struct net_device *dev, struct ieee_pfc *pfc)
96{
97 struct fm10k_intfc *interface = netdev_priv(dev);
98
99
100 pfc->pfc_cap = IEEE_8021QAZ_MAX_TCS;
101 pfc->pfc_en = interface->pfc_en;
102
103 return 0;
104}
105
106
107
108
109
110
111static int fm10k_dcbnl_ieee_setpfc(struct net_device *dev, struct ieee_pfc *pfc)
112{
113 struct fm10k_intfc *interface = netdev_priv(dev);
114
115
116 interface->pfc_en = pfc->pfc_en;
117
118
119 if (netif_running(dev))
120 fm10k_update_rx_drop_en(interface);
121
122 return 0;
123}
124
125
126
127
128
129
130
131static u8 fm10k_dcbnl_getdcbx(struct net_device __always_unused *dev)
132{
133 return DCB_CAP_DCBX_HOST | DCB_CAP_DCBX_VER_IEEE;
134}
135
136
137
138
139
140
141
142
143static u8 fm10k_dcbnl_setdcbx(struct net_device __always_unused *dev, u8 mode)
144{
145 return (mode != (DCB_CAP_DCBX_HOST | DCB_CAP_DCBX_VER_IEEE)) ? 1 : 0;
146}
147
148static const struct dcbnl_rtnl_ops fm10k_dcbnl_ops = {
149 .ieee_getets = fm10k_dcbnl_ieee_getets,
150 .ieee_setets = fm10k_dcbnl_ieee_setets,
151 .ieee_getpfc = fm10k_dcbnl_ieee_getpfc,
152 .ieee_setpfc = fm10k_dcbnl_ieee_setpfc,
153
154 .getdcbx = fm10k_dcbnl_getdcbx,
155 .setdcbx = fm10k_dcbnl_setdcbx,
156};
157
158
159
160
161
162
163
164void fm10k_dcbnl_set_ops(struct net_device *dev)
165{
166 struct fm10k_intfc *interface = netdev_priv(dev);
167 struct fm10k_hw *hw = &interface->hw;
168
169 if (hw->mac.type == fm10k_mac_pf)
170 dev->dcbnl_ops = &fm10k_dcbnl_ops;
171}
172