treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / net / ethernet / qlogic / qede / qede_dcbnl.c
blobe6e844a8cbc7cb18fc032b611067f0f79f3376be
1 // SPDX-License-Identifier: GPL-2.0-only
2 /* QLogic qede NIC Driver
3 * Copyright (c) 2015 QLogic Corporation
4 */
6 #include <linux/types.h>
7 #include <linux/netdevice.h>
8 #include <linux/rtnetlink.h>
9 #include <net/dcbnl.h>
10 #include "qede.h"
12 static u8 qede_dcbnl_getstate(struct net_device *netdev)
14 struct qede_dev *edev = netdev_priv(netdev);
16 return edev->ops->dcb->getstate(edev->cdev);
19 static u8 qede_dcbnl_setstate(struct net_device *netdev, u8 state)
21 struct qede_dev *edev = netdev_priv(netdev);
23 return edev->ops->dcb->setstate(edev->cdev, state);
26 static void qede_dcbnl_getpermhwaddr(struct net_device *netdev,
27 u8 *perm_addr)
29 memcpy(perm_addr, netdev->dev_addr, netdev->addr_len);
32 static void qede_dcbnl_getpgtccfgtx(struct net_device *netdev, int prio,
33 u8 *prio_type, u8 *pgid, u8 *bw_pct,
34 u8 *up_map)
36 struct qede_dev *edev = netdev_priv(netdev);
38 edev->ops->dcb->getpgtccfgtx(edev->cdev, prio, prio_type,
39 pgid, bw_pct, up_map);
42 static void qede_dcbnl_getpgbwgcfgtx(struct net_device *netdev,
43 int pgid, u8 *bw_pct)
45 struct qede_dev *edev = netdev_priv(netdev);
47 edev->ops->dcb->getpgbwgcfgtx(edev->cdev, pgid, bw_pct);
50 static void qede_dcbnl_getpgtccfgrx(struct net_device *netdev, int prio,
51 u8 *prio_type, u8 *pgid, u8 *bw_pct,
52 u8 *up_map)
54 struct qede_dev *edev = netdev_priv(netdev);
56 edev->ops->dcb->getpgtccfgrx(edev->cdev, prio, prio_type, pgid, bw_pct,
57 up_map);
60 static void qede_dcbnl_getpgbwgcfgrx(struct net_device *netdev,
61 int pgid, u8 *bw_pct)
63 struct qede_dev *edev = netdev_priv(netdev);
65 edev->ops->dcb->getpgbwgcfgrx(edev->cdev, pgid, bw_pct);
68 static void qede_dcbnl_getpfccfg(struct net_device *netdev, int prio,
69 u8 *setting)
71 struct qede_dev *edev = netdev_priv(netdev);
73 edev->ops->dcb->getpfccfg(edev->cdev, prio, setting);
76 static void qede_dcbnl_setpfccfg(struct net_device *netdev, int prio,
77 u8 setting)
79 struct qede_dev *edev = netdev_priv(netdev);
81 edev->ops->dcb->setpfccfg(edev->cdev, prio, setting);
84 static u8 qede_dcbnl_getcap(struct net_device *netdev, int capid, u8 *cap)
86 struct qede_dev *edev = netdev_priv(netdev);
88 return edev->ops->dcb->getcap(edev->cdev, capid, cap);
91 static int qede_dcbnl_getnumtcs(struct net_device *netdev, int tcid, u8 *num)
93 struct qede_dev *edev = netdev_priv(netdev);
95 return edev->ops->dcb->getnumtcs(edev->cdev, tcid, num);
98 static u8 qede_dcbnl_getpfcstate(struct net_device *netdev)
100 struct qede_dev *edev = netdev_priv(netdev);
102 return edev->ops->dcb->getpfcstate(edev->cdev);
105 static int qede_dcbnl_getapp(struct net_device *netdev, u8 idtype, u16 id)
107 struct qede_dev *edev = netdev_priv(netdev);
109 return edev->ops->dcb->getapp(edev->cdev, idtype, id);
112 static u8 qede_dcbnl_getdcbx(struct net_device *netdev)
114 struct qede_dev *edev = netdev_priv(netdev);
116 return edev->ops->dcb->getdcbx(edev->cdev);
119 static void qede_dcbnl_setpgtccfgtx(struct net_device *netdev, int prio,
120 u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map)
122 struct qede_dev *edev = netdev_priv(netdev);
124 return edev->ops->dcb->setpgtccfgtx(edev->cdev, prio, pri_type, pgid,
125 bw_pct, up_map);
128 static void qede_dcbnl_setpgtccfgrx(struct net_device *netdev, int prio,
129 u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map)
131 struct qede_dev *edev = netdev_priv(netdev);
133 return edev->ops->dcb->setpgtccfgrx(edev->cdev, prio, pri_type, pgid,
134 bw_pct, up_map);
137 static void qede_dcbnl_setpgbwgcfgtx(struct net_device *netdev, int pgid,
138 u8 bw_pct)
140 struct qede_dev *edev = netdev_priv(netdev);
142 return edev->ops->dcb->setpgbwgcfgtx(edev->cdev, pgid, bw_pct);
145 static void qede_dcbnl_setpgbwgcfgrx(struct net_device *netdev, int pgid,
146 u8 bw_pct)
148 struct qede_dev *edev = netdev_priv(netdev);
150 return edev->ops->dcb->setpgbwgcfgrx(edev->cdev, pgid, bw_pct);
153 static u8 qede_dcbnl_setall(struct net_device *netdev)
155 struct qede_dev *edev = netdev_priv(netdev);
157 return edev->ops->dcb->setall(edev->cdev);
160 static int qede_dcbnl_setnumtcs(struct net_device *netdev, int tcid, u8 num)
162 struct qede_dev *edev = netdev_priv(netdev);
164 return edev->ops->dcb->setnumtcs(edev->cdev, tcid, num);
167 static void qede_dcbnl_setpfcstate(struct net_device *netdev, u8 state)
169 struct qede_dev *edev = netdev_priv(netdev);
171 return edev->ops->dcb->setpfcstate(edev->cdev, state);
174 static int qede_dcbnl_setapp(struct net_device *netdev, u8 idtype, u16 idval,
175 u8 up)
177 struct qede_dev *edev = netdev_priv(netdev);
179 return edev->ops->dcb->setapp(edev->cdev, idtype, idval, up);
182 static u8 qede_dcbnl_setdcbx(struct net_device *netdev, u8 state)
184 struct qede_dev *edev = netdev_priv(netdev);
186 return edev->ops->dcb->setdcbx(edev->cdev, state);
189 static u8 qede_dcbnl_getfeatcfg(struct net_device *netdev, int featid,
190 u8 *flags)
192 struct qede_dev *edev = netdev_priv(netdev);
194 return edev->ops->dcb->getfeatcfg(edev->cdev, featid, flags);
197 static u8 qede_dcbnl_setfeatcfg(struct net_device *netdev, int featid, u8 flags)
199 struct qede_dev *edev = netdev_priv(netdev);
201 return edev->ops->dcb->setfeatcfg(edev->cdev, featid, flags);
204 static int qede_dcbnl_peer_getappinfo(struct net_device *netdev,
205 struct dcb_peer_app_info *info,
206 u16 *count)
208 struct qede_dev *edev = netdev_priv(netdev);
210 return edev->ops->dcb->peer_getappinfo(edev->cdev, info, count);
213 static int qede_dcbnl_peer_getapptable(struct net_device *netdev,
214 struct dcb_app *app)
216 struct qede_dev *edev = netdev_priv(netdev);
218 return edev->ops->dcb->peer_getapptable(edev->cdev, app);
221 static int qede_dcbnl_cee_peer_getpfc(struct net_device *netdev,
222 struct cee_pfc *pfc)
224 struct qede_dev *edev = netdev_priv(netdev);
226 return edev->ops->dcb->cee_peer_getpfc(edev->cdev, pfc);
229 static int qede_dcbnl_cee_peer_getpg(struct net_device *netdev,
230 struct cee_pg *pg)
232 struct qede_dev *edev = netdev_priv(netdev);
234 return edev->ops->dcb->cee_peer_getpg(edev->cdev, pg);
237 static int qede_dcbnl_ieee_getpfc(struct net_device *netdev,
238 struct ieee_pfc *pfc)
240 struct qede_dev *edev = netdev_priv(netdev);
242 return edev->ops->dcb->ieee_getpfc(edev->cdev, pfc);
245 static int qede_dcbnl_ieee_setpfc(struct net_device *netdev,
246 struct ieee_pfc *pfc)
248 struct qede_dev *edev = netdev_priv(netdev);
250 return edev->ops->dcb->ieee_setpfc(edev->cdev, pfc);
253 static int qede_dcbnl_ieee_getets(struct net_device *netdev,
254 struct ieee_ets *ets)
256 struct qede_dev *edev = netdev_priv(netdev);
258 return edev->ops->dcb->ieee_getets(edev->cdev, ets);
261 static int qede_dcbnl_ieee_setets(struct net_device *netdev,
262 struct ieee_ets *ets)
264 struct qede_dev *edev = netdev_priv(netdev);
266 return edev->ops->dcb->ieee_setets(edev->cdev, ets);
269 static int qede_dcbnl_ieee_getapp(struct net_device *netdev,
270 struct dcb_app *app)
272 struct qede_dev *edev = netdev_priv(netdev);
274 return edev->ops->dcb->ieee_getapp(edev->cdev, app);
277 static int qede_dcbnl_ieee_setapp(struct net_device *netdev,
278 struct dcb_app *app)
280 struct qede_dev *edev = netdev_priv(netdev);
281 int err;
283 err = dcb_ieee_setapp(netdev, app);
284 if (err)
285 return err;
287 return edev->ops->dcb->ieee_setapp(edev->cdev, app);
290 static int qede_dcbnl_ieee_peer_getpfc(struct net_device *netdev,
291 struct ieee_pfc *pfc)
293 struct qede_dev *edev = netdev_priv(netdev);
295 return edev->ops->dcb->ieee_peer_getpfc(edev->cdev, pfc);
298 static int qede_dcbnl_ieee_peer_getets(struct net_device *netdev,
299 struct ieee_ets *ets)
301 struct qede_dev *edev = netdev_priv(netdev);
303 return edev->ops->dcb->ieee_peer_getets(edev->cdev, ets);
306 static const struct dcbnl_rtnl_ops qede_dcbnl_ops = {
307 .ieee_getpfc = qede_dcbnl_ieee_getpfc,
308 .ieee_setpfc = qede_dcbnl_ieee_setpfc,
309 .ieee_getets = qede_dcbnl_ieee_getets,
310 .ieee_setets = qede_dcbnl_ieee_setets,
311 .ieee_getapp = qede_dcbnl_ieee_getapp,
312 .ieee_setapp = qede_dcbnl_ieee_setapp,
313 .ieee_peer_getpfc = qede_dcbnl_ieee_peer_getpfc,
314 .ieee_peer_getets = qede_dcbnl_ieee_peer_getets,
315 .getstate = qede_dcbnl_getstate,
316 .setstate = qede_dcbnl_setstate,
317 .getpermhwaddr = qede_dcbnl_getpermhwaddr,
318 .getpgtccfgtx = qede_dcbnl_getpgtccfgtx,
319 .getpgbwgcfgtx = qede_dcbnl_getpgbwgcfgtx,
320 .getpgtccfgrx = qede_dcbnl_getpgtccfgrx,
321 .getpgbwgcfgrx = qede_dcbnl_getpgbwgcfgrx,
322 .getpfccfg = qede_dcbnl_getpfccfg,
323 .setpfccfg = qede_dcbnl_setpfccfg,
324 .getcap = qede_dcbnl_getcap,
325 .getnumtcs = qede_dcbnl_getnumtcs,
326 .getpfcstate = qede_dcbnl_getpfcstate,
327 .getapp = qede_dcbnl_getapp,
328 .getdcbx = qede_dcbnl_getdcbx,
329 .setpgtccfgtx = qede_dcbnl_setpgtccfgtx,
330 .setpgtccfgrx = qede_dcbnl_setpgtccfgrx,
331 .setpgbwgcfgtx = qede_dcbnl_setpgbwgcfgtx,
332 .setpgbwgcfgrx = qede_dcbnl_setpgbwgcfgrx,
333 .setall = qede_dcbnl_setall,
334 .setnumtcs = qede_dcbnl_setnumtcs,
335 .setpfcstate = qede_dcbnl_setpfcstate,
336 .setapp = qede_dcbnl_setapp,
337 .setdcbx = qede_dcbnl_setdcbx,
338 .setfeatcfg = qede_dcbnl_setfeatcfg,
339 .getfeatcfg = qede_dcbnl_getfeatcfg,
340 .peer_getappinfo = qede_dcbnl_peer_getappinfo,
341 .peer_getapptable = qede_dcbnl_peer_getapptable,
342 .cee_peer_getpfc = qede_dcbnl_cee_peer_getpfc,
343 .cee_peer_getpg = qede_dcbnl_cee_peer_getpg,
346 void qede_set_dcbnl_ops(struct net_device *dev)
348 dev->dcbnl_ops = &qede_dcbnl_ops;