1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
2 /* QLogic qede NIC Driver
3 * Copyright (c) 2015 QLogic Corporation
4 * Copyright (c) 2019-2020 Marvell International Ltd.
7 #include <linux/types.h>
8 #include <linux/netdevice.h>
9 #include <linux/rtnetlink.h>
10 #include <net/dcbnl.h>
13 static u8
qede_dcbnl_getstate(struct net_device
*netdev
)
15 struct qede_dev
*edev
= netdev_priv(netdev
);
17 return edev
->ops
->dcb
->getstate(edev
->cdev
);
20 static u8
qede_dcbnl_setstate(struct net_device
*netdev
, u8 state
)
22 struct qede_dev
*edev
= netdev_priv(netdev
);
24 return edev
->ops
->dcb
->setstate(edev
->cdev
, state
);
27 static void qede_dcbnl_getpermhwaddr(struct net_device
*netdev
,
30 memcpy(perm_addr
, netdev
->dev_addr
, netdev
->addr_len
);
33 static void qede_dcbnl_getpgtccfgtx(struct net_device
*netdev
, int prio
,
34 u8
*prio_type
, u8
*pgid
, u8
*bw_pct
,
37 struct qede_dev
*edev
= netdev_priv(netdev
);
39 edev
->ops
->dcb
->getpgtccfgtx(edev
->cdev
, prio
, prio_type
,
40 pgid
, bw_pct
, up_map
);
43 static void qede_dcbnl_getpgbwgcfgtx(struct net_device
*netdev
,
46 struct qede_dev
*edev
= netdev_priv(netdev
);
48 edev
->ops
->dcb
->getpgbwgcfgtx(edev
->cdev
, pgid
, bw_pct
);
51 static void qede_dcbnl_getpgtccfgrx(struct net_device
*netdev
, int prio
,
52 u8
*prio_type
, u8
*pgid
, u8
*bw_pct
,
55 struct qede_dev
*edev
= netdev_priv(netdev
);
57 edev
->ops
->dcb
->getpgtccfgrx(edev
->cdev
, prio
, prio_type
, pgid
, bw_pct
,
61 static void qede_dcbnl_getpgbwgcfgrx(struct net_device
*netdev
,
64 struct qede_dev
*edev
= netdev_priv(netdev
);
66 edev
->ops
->dcb
->getpgbwgcfgrx(edev
->cdev
, pgid
, bw_pct
);
69 static void qede_dcbnl_getpfccfg(struct net_device
*netdev
, int prio
,
72 struct qede_dev
*edev
= netdev_priv(netdev
);
74 edev
->ops
->dcb
->getpfccfg(edev
->cdev
, prio
, setting
);
77 static void qede_dcbnl_setpfccfg(struct net_device
*netdev
, int prio
,
80 struct qede_dev
*edev
= netdev_priv(netdev
);
82 edev
->ops
->dcb
->setpfccfg(edev
->cdev
, prio
, setting
);
85 static u8
qede_dcbnl_getcap(struct net_device
*netdev
, int capid
, u8
*cap
)
87 struct qede_dev
*edev
= netdev_priv(netdev
);
89 return edev
->ops
->dcb
->getcap(edev
->cdev
, capid
, cap
);
92 static int qede_dcbnl_getnumtcs(struct net_device
*netdev
, int tcid
, u8
*num
)
94 struct qede_dev
*edev
= netdev_priv(netdev
);
96 return edev
->ops
->dcb
->getnumtcs(edev
->cdev
, tcid
, num
);
99 static u8
qede_dcbnl_getpfcstate(struct net_device
*netdev
)
101 struct qede_dev
*edev
= netdev_priv(netdev
);
103 return edev
->ops
->dcb
->getpfcstate(edev
->cdev
);
106 static int qede_dcbnl_getapp(struct net_device
*netdev
, u8 idtype
, u16 id
)
108 struct qede_dev
*edev
= netdev_priv(netdev
);
110 return edev
->ops
->dcb
->getapp(edev
->cdev
, idtype
, id
);
113 static u8
qede_dcbnl_getdcbx(struct net_device
*netdev
)
115 struct qede_dev
*edev
= netdev_priv(netdev
);
117 return edev
->ops
->dcb
->getdcbx(edev
->cdev
);
120 static void qede_dcbnl_setpgtccfgtx(struct net_device
*netdev
, int prio
,
121 u8 pri_type
, u8 pgid
, u8 bw_pct
, u8 up_map
)
123 struct qede_dev
*edev
= netdev_priv(netdev
);
125 return edev
->ops
->dcb
->setpgtccfgtx(edev
->cdev
, prio
, pri_type
, pgid
,
129 static void qede_dcbnl_setpgtccfgrx(struct net_device
*netdev
, int prio
,
130 u8 pri_type
, u8 pgid
, u8 bw_pct
, u8 up_map
)
132 struct qede_dev
*edev
= netdev_priv(netdev
);
134 return edev
->ops
->dcb
->setpgtccfgrx(edev
->cdev
, prio
, pri_type
, pgid
,
138 static void qede_dcbnl_setpgbwgcfgtx(struct net_device
*netdev
, int pgid
,
141 struct qede_dev
*edev
= netdev_priv(netdev
);
143 return edev
->ops
->dcb
->setpgbwgcfgtx(edev
->cdev
, pgid
, bw_pct
);
146 static void qede_dcbnl_setpgbwgcfgrx(struct net_device
*netdev
, int pgid
,
149 struct qede_dev
*edev
= netdev_priv(netdev
);
151 return edev
->ops
->dcb
->setpgbwgcfgrx(edev
->cdev
, pgid
, bw_pct
);
154 static u8
qede_dcbnl_setall(struct net_device
*netdev
)
156 struct qede_dev
*edev
= netdev_priv(netdev
);
158 return edev
->ops
->dcb
->setall(edev
->cdev
);
161 static int qede_dcbnl_setnumtcs(struct net_device
*netdev
, int tcid
, u8 num
)
163 struct qede_dev
*edev
= netdev_priv(netdev
);
165 return edev
->ops
->dcb
->setnumtcs(edev
->cdev
, tcid
, num
);
168 static void qede_dcbnl_setpfcstate(struct net_device
*netdev
, u8 state
)
170 struct qede_dev
*edev
= netdev_priv(netdev
);
172 return edev
->ops
->dcb
->setpfcstate(edev
->cdev
, state
);
175 static int qede_dcbnl_setapp(struct net_device
*netdev
, u8 idtype
, u16 idval
,
178 struct qede_dev
*edev
= netdev_priv(netdev
);
180 return edev
->ops
->dcb
->setapp(edev
->cdev
, idtype
, idval
, up
);
183 static u8
qede_dcbnl_setdcbx(struct net_device
*netdev
, u8 state
)
185 struct qede_dev
*edev
= netdev_priv(netdev
);
187 return edev
->ops
->dcb
->setdcbx(edev
->cdev
, state
);
190 static u8
qede_dcbnl_getfeatcfg(struct net_device
*netdev
, int featid
,
193 struct qede_dev
*edev
= netdev_priv(netdev
);
195 return edev
->ops
->dcb
->getfeatcfg(edev
->cdev
, featid
, flags
);
198 static u8
qede_dcbnl_setfeatcfg(struct net_device
*netdev
, int featid
, u8 flags
)
200 struct qede_dev
*edev
= netdev_priv(netdev
);
202 return edev
->ops
->dcb
->setfeatcfg(edev
->cdev
, featid
, flags
);
205 static int qede_dcbnl_peer_getappinfo(struct net_device
*netdev
,
206 struct dcb_peer_app_info
*info
,
209 struct qede_dev
*edev
= netdev_priv(netdev
);
211 return edev
->ops
->dcb
->peer_getappinfo(edev
->cdev
, info
, count
);
214 static int qede_dcbnl_peer_getapptable(struct net_device
*netdev
,
217 struct qede_dev
*edev
= netdev_priv(netdev
);
219 return edev
->ops
->dcb
->peer_getapptable(edev
->cdev
, app
);
222 static int qede_dcbnl_cee_peer_getpfc(struct net_device
*netdev
,
225 struct qede_dev
*edev
= netdev_priv(netdev
);
227 return edev
->ops
->dcb
->cee_peer_getpfc(edev
->cdev
, pfc
);
230 static int qede_dcbnl_cee_peer_getpg(struct net_device
*netdev
,
233 struct qede_dev
*edev
= netdev_priv(netdev
);
235 return edev
->ops
->dcb
->cee_peer_getpg(edev
->cdev
, pg
);
238 static int qede_dcbnl_ieee_getpfc(struct net_device
*netdev
,
239 struct ieee_pfc
*pfc
)
241 struct qede_dev
*edev
= netdev_priv(netdev
);
243 return edev
->ops
->dcb
->ieee_getpfc(edev
->cdev
, pfc
);
246 static int qede_dcbnl_ieee_setpfc(struct net_device
*netdev
,
247 struct ieee_pfc
*pfc
)
249 struct qede_dev
*edev
= netdev_priv(netdev
);
251 return edev
->ops
->dcb
->ieee_setpfc(edev
->cdev
, pfc
);
254 static int qede_dcbnl_ieee_getets(struct net_device
*netdev
,
255 struct ieee_ets
*ets
)
257 struct qede_dev
*edev
= netdev_priv(netdev
);
259 return edev
->ops
->dcb
->ieee_getets(edev
->cdev
, ets
);
262 static int qede_dcbnl_ieee_setets(struct net_device
*netdev
,
263 struct ieee_ets
*ets
)
265 struct qede_dev
*edev
= netdev_priv(netdev
);
267 return edev
->ops
->dcb
->ieee_setets(edev
->cdev
, ets
);
270 static int qede_dcbnl_ieee_getapp(struct net_device
*netdev
,
273 struct qede_dev
*edev
= netdev_priv(netdev
);
275 return edev
->ops
->dcb
->ieee_getapp(edev
->cdev
, app
);
278 static int qede_dcbnl_ieee_setapp(struct net_device
*netdev
,
281 struct qede_dev
*edev
= netdev_priv(netdev
);
284 err
= dcb_ieee_setapp(netdev
, app
);
288 return edev
->ops
->dcb
->ieee_setapp(edev
->cdev
, app
);
291 static int qede_dcbnl_ieee_peer_getpfc(struct net_device
*netdev
,
292 struct ieee_pfc
*pfc
)
294 struct qede_dev
*edev
= netdev_priv(netdev
);
296 return edev
->ops
->dcb
->ieee_peer_getpfc(edev
->cdev
, pfc
);
299 static int qede_dcbnl_ieee_peer_getets(struct net_device
*netdev
,
300 struct ieee_ets
*ets
)
302 struct qede_dev
*edev
= netdev_priv(netdev
);
304 return edev
->ops
->dcb
->ieee_peer_getets(edev
->cdev
, ets
);
307 static const struct dcbnl_rtnl_ops qede_dcbnl_ops
= {
308 .ieee_getpfc
= qede_dcbnl_ieee_getpfc
,
309 .ieee_setpfc
= qede_dcbnl_ieee_setpfc
,
310 .ieee_getets
= qede_dcbnl_ieee_getets
,
311 .ieee_setets
= qede_dcbnl_ieee_setets
,
312 .ieee_getapp
= qede_dcbnl_ieee_getapp
,
313 .ieee_setapp
= qede_dcbnl_ieee_setapp
,
314 .ieee_peer_getpfc
= qede_dcbnl_ieee_peer_getpfc
,
315 .ieee_peer_getets
= qede_dcbnl_ieee_peer_getets
,
316 .getstate
= qede_dcbnl_getstate
,
317 .setstate
= qede_dcbnl_setstate
,
318 .getpermhwaddr
= qede_dcbnl_getpermhwaddr
,
319 .getpgtccfgtx
= qede_dcbnl_getpgtccfgtx
,
320 .getpgbwgcfgtx
= qede_dcbnl_getpgbwgcfgtx
,
321 .getpgtccfgrx
= qede_dcbnl_getpgtccfgrx
,
322 .getpgbwgcfgrx
= qede_dcbnl_getpgbwgcfgrx
,
323 .getpfccfg
= qede_dcbnl_getpfccfg
,
324 .setpfccfg
= qede_dcbnl_setpfccfg
,
325 .getcap
= qede_dcbnl_getcap
,
326 .getnumtcs
= qede_dcbnl_getnumtcs
,
327 .getpfcstate
= qede_dcbnl_getpfcstate
,
328 .getapp
= qede_dcbnl_getapp
,
329 .getdcbx
= qede_dcbnl_getdcbx
,
330 .setpgtccfgtx
= qede_dcbnl_setpgtccfgtx
,
331 .setpgtccfgrx
= qede_dcbnl_setpgtccfgrx
,
332 .setpgbwgcfgtx
= qede_dcbnl_setpgbwgcfgtx
,
333 .setpgbwgcfgrx
= qede_dcbnl_setpgbwgcfgrx
,
334 .setall
= qede_dcbnl_setall
,
335 .setnumtcs
= qede_dcbnl_setnumtcs
,
336 .setpfcstate
= qede_dcbnl_setpfcstate
,
337 .setapp
= qede_dcbnl_setapp
,
338 .setdcbx
= qede_dcbnl_setdcbx
,
339 .setfeatcfg
= qede_dcbnl_setfeatcfg
,
340 .getfeatcfg
= qede_dcbnl_getfeatcfg
,
341 .peer_getappinfo
= qede_dcbnl_peer_getappinfo
,
342 .peer_getapptable
= qede_dcbnl_peer_getapptable
,
343 .cee_peer_getpfc
= qede_dcbnl_cee_peer_getpfc
,
344 .cee_peer_getpg
= qede_dcbnl_cee_peer_getpg
,
347 void qede_set_dcbnl_ops(struct net_device
*dev
)
349 dev
->dcbnl_ops
= &qede_dcbnl_ops
;