xref: /linux/drivers/net/ethernet/qlogic/qede/qede_dcbnl.c (revision e5c86679d5e864947a52fb31e45a425dea3e7fa9)
1 /* QLogic qede NIC Driver
2 * Copyright (c) 2015 QLogic Corporation
3 *
4 * This software is available under the terms of the GNU General Public License
5 * (GPL) Version 2, available from the file COPYING in the main directory of
6 * this source tree.
7 */
8 
9 #include <linux/types.h>
10 #include <linux/netdevice.h>
11 #include <linux/rtnetlink.h>
12 #include <net/dcbnl.h>
13 #include "qede.h"
14 
15 static u8 qede_dcbnl_getstate(struct net_device *netdev)
16 {
17 	struct qede_dev *edev = netdev_priv(netdev);
18 
19 	return edev->ops->dcb->getstate(edev->cdev);
20 }
21 
22 static u8 qede_dcbnl_setstate(struct net_device *netdev, u8 state)
23 {
24 	struct qede_dev *edev = netdev_priv(netdev);
25 
26 	return edev->ops->dcb->setstate(edev->cdev, state);
27 }
28 
29 static void qede_dcbnl_getpermhwaddr(struct net_device *netdev,
30 				     u8 *perm_addr)
31 {
32 	memcpy(perm_addr, netdev->dev_addr, netdev->addr_len);
33 }
34 
35 static void qede_dcbnl_getpgtccfgtx(struct net_device *netdev, int prio,
36 				    u8 *prio_type, u8 *pgid, u8 *bw_pct,
37 				    u8 *up_map)
38 {
39 	struct qede_dev *edev = netdev_priv(netdev);
40 
41 	edev->ops->dcb->getpgtccfgtx(edev->cdev, prio, prio_type,
42 				     pgid, bw_pct, up_map);
43 }
44 
45 static void qede_dcbnl_getpgbwgcfgtx(struct net_device *netdev,
46 				     int pgid, u8 *bw_pct)
47 {
48 	struct qede_dev *edev = netdev_priv(netdev);
49 
50 	edev->ops->dcb->getpgbwgcfgtx(edev->cdev, pgid, bw_pct);
51 }
52 
53 static void qede_dcbnl_getpgtccfgrx(struct net_device *netdev, int prio,
54 				    u8 *prio_type, u8 *pgid, u8 *bw_pct,
55 				    u8 *up_map)
56 {
57 	struct qede_dev *edev = netdev_priv(netdev);
58 
59 	edev->ops->dcb->getpgtccfgrx(edev->cdev, prio, prio_type, pgid, bw_pct,
60 				     up_map);
61 }
62 
63 static void qede_dcbnl_getpgbwgcfgrx(struct net_device *netdev,
64 				     int pgid, u8 *bw_pct)
65 {
66 	struct qede_dev *edev = netdev_priv(netdev);
67 
68 	edev->ops->dcb->getpgbwgcfgrx(edev->cdev, pgid, bw_pct);
69 }
70 
71 static void qede_dcbnl_getpfccfg(struct net_device *netdev, int prio,
72 				 u8 *setting)
73 {
74 	struct qede_dev *edev = netdev_priv(netdev);
75 
76 	edev->ops->dcb->getpfccfg(edev->cdev, prio, setting);
77 }
78 
79 static void qede_dcbnl_setpfccfg(struct net_device *netdev, int prio,
80 				 u8 setting)
81 {
82 	struct qede_dev *edev = netdev_priv(netdev);
83 
84 	edev->ops->dcb->setpfccfg(edev->cdev, prio, setting);
85 }
86 
87 static u8 qede_dcbnl_getcap(struct net_device *netdev, int capid, u8 *cap)
88 {
89 	struct qede_dev *edev = netdev_priv(netdev);
90 
91 	return edev->ops->dcb->getcap(edev->cdev, capid, cap);
92 }
93 
94 static int qede_dcbnl_getnumtcs(struct net_device *netdev, int tcid, u8 *num)
95 {
96 	struct qede_dev *edev = netdev_priv(netdev);
97 
98 	return edev->ops->dcb->getnumtcs(edev->cdev, tcid, num);
99 }
100 
101 static u8 qede_dcbnl_getpfcstate(struct net_device *netdev)
102 {
103 	struct qede_dev *edev = netdev_priv(netdev);
104 
105 	return edev->ops->dcb->getpfcstate(edev->cdev);
106 }
107 
108 static int qede_dcbnl_getapp(struct net_device *netdev, u8 idtype, u16 id)
109 {
110 	struct qede_dev *edev = netdev_priv(netdev);
111 
112 	return edev->ops->dcb->getapp(edev->cdev, idtype, id);
113 }
114 
115 static u8 qede_dcbnl_getdcbx(struct net_device *netdev)
116 {
117 	struct qede_dev *edev = netdev_priv(netdev);
118 
119 	return edev->ops->dcb->getdcbx(edev->cdev);
120 }
121 
122 static void qede_dcbnl_setpgtccfgtx(struct net_device *netdev, int prio,
123 				    u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map)
124 {
125 	struct qede_dev *edev = netdev_priv(netdev);
126 
127 	return edev->ops->dcb->setpgtccfgtx(edev->cdev, prio, pri_type, pgid,
128 					    bw_pct, up_map);
129 }
130 
131 static void qede_dcbnl_setpgtccfgrx(struct net_device *netdev, int prio,
132 				    u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map)
133 {
134 	struct qede_dev *edev = netdev_priv(netdev);
135 
136 	return edev->ops->dcb->setpgtccfgrx(edev->cdev, prio, pri_type, pgid,
137 					    bw_pct, up_map);
138 }
139 
140 static void qede_dcbnl_setpgbwgcfgtx(struct net_device *netdev, int pgid,
141 				     u8 bw_pct)
142 {
143 	struct qede_dev *edev = netdev_priv(netdev);
144 
145 	return edev->ops->dcb->setpgbwgcfgtx(edev->cdev, pgid, bw_pct);
146 }
147 
148 static void qede_dcbnl_setpgbwgcfgrx(struct net_device *netdev, int pgid,
149 				     u8 bw_pct)
150 {
151 	struct qede_dev *edev = netdev_priv(netdev);
152 
153 	return edev->ops->dcb->setpgbwgcfgrx(edev->cdev, pgid, bw_pct);
154 }
155 
156 static u8 qede_dcbnl_setall(struct net_device *netdev)
157 {
158 	struct qede_dev *edev = netdev_priv(netdev);
159 
160 	return edev->ops->dcb->setall(edev->cdev);
161 }
162 
163 static int qede_dcbnl_setnumtcs(struct net_device *netdev, int tcid, u8 num)
164 {
165 	struct qede_dev *edev = netdev_priv(netdev);
166 
167 	return edev->ops->dcb->setnumtcs(edev->cdev, tcid, num);
168 }
169 
170 static void qede_dcbnl_setpfcstate(struct net_device *netdev, u8 state)
171 {
172 	struct qede_dev *edev = netdev_priv(netdev);
173 
174 	return edev->ops->dcb->setpfcstate(edev->cdev, state);
175 }
176 
177 static int qede_dcbnl_setapp(struct net_device *netdev, u8 idtype, u16 idval,
178 			     u8 up)
179 {
180 	struct qede_dev *edev = netdev_priv(netdev);
181 
182 	return edev->ops->dcb->setapp(edev->cdev, idtype, idval, up);
183 }
184 
185 static u8 qede_dcbnl_setdcbx(struct net_device *netdev, u8 state)
186 {
187 	struct qede_dev *edev = netdev_priv(netdev);
188 
189 	return edev->ops->dcb->setdcbx(edev->cdev, state);
190 }
191 
192 static u8 qede_dcbnl_getfeatcfg(struct net_device *netdev, int featid,
193 				u8 *flags)
194 {
195 	struct qede_dev *edev = netdev_priv(netdev);
196 
197 	return edev->ops->dcb->getfeatcfg(edev->cdev, featid, flags);
198 }
199 
200 static u8 qede_dcbnl_setfeatcfg(struct net_device *netdev, int featid, u8 flags)
201 {
202 	struct qede_dev *edev = netdev_priv(netdev);
203 
204 	return edev->ops->dcb->setfeatcfg(edev->cdev, featid, flags);
205 }
206 
207 static int qede_dcbnl_peer_getappinfo(struct net_device *netdev,
208 				      struct dcb_peer_app_info *info,
209 				      u16 *count)
210 {
211 	struct qede_dev *edev = netdev_priv(netdev);
212 
213 	return edev->ops->dcb->peer_getappinfo(edev->cdev, info, count);
214 }
215 
216 static int qede_dcbnl_peer_getapptable(struct net_device *netdev,
217 				       struct dcb_app *app)
218 {
219 	struct qede_dev *edev = netdev_priv(netdev);
220 
221 	return edev->ops->dcb->peer_getapptable(edev->cdev, app);
222 }
223 
224 static int qede_dcbnl_cee_peer_getpfc(struct net_device *netdev,
225 				      struct cee_pfc *pfc)
226 {
227 	struct qede_dev *edev = netdev_priv(netdev);
228 
229 	return edev->ops->dcb->cee_peer_getpfc(edev->cdev, pfc);
230 }
231 
232 static int qede_dcbnl_cee_peer_getpg(struct net_device *netdev,
233 				     struct cee_pg *pg)
234 {
235 	struct qede_dev *edev = netdev_priv(netdev);
236 
237 	return edev->ops->dcb->cee_peer_getpg(edev->cdev, pg);
238 }
239 
240 static int qede_dcbnl_ieee_getpfc(struct net_device *netdev,
241 				  struct ieee_pfc *pfc)
242 {
243 	struct qede_dev *edev = netdev_priv(netdev);
244 
245 	return edev->ops->dcb->ieee_getpfc(edev->cdev, pfc);
246 }
247 
248 static int qede_dcbnl_ieee_setpfc(struct net_device *netdev,
249 				  struct ieee_pfc *pfc)
250 {
251 	struct qede_dev *edev = netdev_priv(netdev);
252 
253 	return edev->ops->dcb->ieee_setpfc(edev->cdev, pfc);
254 }
255 
256 static int qede_dcbnl_ieee_getets(struct net_device *netdev,
257 				  struct ieee_ets *ets)
258 {
259 	struct qede_dev *edev = netdev_priv(netdev);
260 
261 	return edev->ops->dcb->ieee_getets(edev->cdev, ets);
262 }
263 
264 static int qede_dcbnl_ieee_setets(struct net_device *netdev,
265 				  struct ieee_ets *ets)
266 {
267 	struct qede_dev *edev = netdev_priv(netdev);
268 
269 	return edev->ops->dcb->ieee_setets(edev->cdev, ets);
270 }
271 
272 static int qede_dcbnl_ieee_getapp(struct net_device *netdev,
273 				  struct dcb_app *app)
274 {
275 	struct qede_dev *edev = netdev_priv(netdev);
276 
277 	return edev->ops->dcb->ieee_getapp(edev->cdev, app);
278 }
279 
280 static int qede_dcbnl_ieee_setapp(struct net_device *netdev,
281 				  struct dcb_app *app)
282 {
283 	struct qede_dev *edev = netdev_priv(netdev);
284 
285 	return edev->ops->dcb->ieee_setapp(edev->cdev, app);
286 }
287 
288 static int qede_dcbnl_ieee_peer_getpfc(struct net_device *netdev,
289 				       struct ieee_pfc *pfc)
290 {
291 	struct qede_dev *edev = netdev_priv(netdev);
292 
293 	return edev->ops->dcb->ieee_peer_getpfc(edev->cdev, pfc);
294 }
295 
296 static int qede_dcbnl_ieee_peer_getets(struct net_device *netdev,
297 				       struct ieee_ets *ets)
298 {
299 	struct qede_dev *edev = netdev_priv(netdev);
300 
301 	return edev->ops->dcb->ieee_peer_getets(edev->cdev, ets);
302 }
303 
304 static const struct dcbnl_rtnl_ops qede_dcbnl_ops = {
305 	.ieee_getpfc = qede_dcbnl_ieee_getpfc,
306 	.ieee_setpfc = qede_dcbnl_ieee_setpfc,
307 	.ieee_getets = qede_dcbnl_ieee_getets,
308 	.ieee_setets = qede_dcbnl_ieee_setets,
309 	.ieee_getapp = qede_dcbnl_ieee_getapp,
310 	.ieee_setapp = qede_dcbnl_ieee_setapp,
311 	.getdcbx = qede_dcbnl_getdcbx,
312 	.ieee_peer_getpfc = qede_dcbnl_ieee_peer_getpfc,
313 	.ieee_peer_getets = qede_dcbnl_ieee_peer_getets,
314 	.getstate = qede_dcbnl_getstate,
315 	.setstate = qede_dcbnl_setstate,
316 	.getpermhwaddr = qede_dcbnl_getpermhwaddr,
317 	.getpgtccfgtx = qede_dcbnl_getpgtccfgtx,
318 	.getpgbwgcfgtx = qede_dcbnl_getpgbwgcfgtx,
319 	.getpgtccfgrx = qede_dcbnl_getpgtccfgrx,
320 	.getpgbwgcfgrx = qede_dcbnl_getpgbwgcfgrx,
321 	.getpfccfg = qede_dcbnl_getpfccfg,
322 	.setpfccfg = qede_dcbnl_setpfccfg,
323 	.getcap = qede_dcbnl_getcap,
324 	.getnumtcs = qede_dcbnl_getnumtcs,
325 	.getpfcstate = qede_dcbnl_getpfcstate,
326 	.getapp = qede_dcbnl_getapp,
327 	.getdcbx = qede_dcbnl_getdcbx,
328 	.setpgtccfgtx = qede_dcbnl_setpgtccfgtx,
329 	.setpgtccfgrx = qede_dcbnl_setpgtccfgrx,
330 	.setpgbwgcfgtx = qede_dcbnl_setpgbwgcfgtx,
331 	.setpgbwgcfgrx = qede_dcbnl_setpgbwgcfgrx,
332 	.setall = qede_dcbnl_setall,
333 	.setnumtcs = qede_dcbnl_setnumtcs,
334 	.setpfcstate = qede_dcbnl_setpfcstate,
335 	.setapp = qede_dcbnl_setapp,
336 	.setdcbx = qede_dcbnl_setdcbx,
337 	.setfeatcfg = qede_dcbnl_setfeatcfg,
338 	.getfeatcfg = qede_dcbnl_getfeatcfg,
339 	.peer_getappinfo = qede_dcbnl_peer_getappinfo,
340 	.peer_getapptable = qede_dcbnl_peer_getapptable,
341 	.cee_peer_getpfc = qede_dcbnl_cee_peer_getpfc,
342 	.cee_peer_getpg = qede_dcbnl_cee_peer_getpg,
343 };
344 
345 void qede_set_dcbnl_ops(struct net_device *dev)
346 {
347 	dev->dcbnl_ops = &qede_dcbnl_ops;
348 }
349