Linux 4.16.11
[linux/fpc-iii.git] / drivers / net / ethernet / hisilicon / hns3 / hns3_dcbnl.c
blobeb82700da7d0dbc60c1b115695e4fe4ae2667d5a
1 /*
2 * Copyright (c) 2016-2017 Hisilicon Limited.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
10 #include "hnae3.h"
11 #include "hns3_enet.h"
13 static
14 int hns3_dcbnl_ieee_getets(struct net_device *ndev, struct ieee_ets *ets)
16 struct hnae3_handle *h = hns3_get_handle(ndev);
18 if (h->kinfo.dcb_ops->ieee_getets)
19 return h->kinfo.dcb_ops->ieee_getets(h, ets);
21 return -EOPNOTSUPP;
24 static
25 int hns3_dcbnl_ieee_setets(struct net_device *ndev, struct ieee_ets *ets)
27 struct hnae3_handle *h = hns3_get_handle(ndev);
29 if (h->kinfo.dcb_ops->ieee_setets)
30 return h->kinfo.dcb_ops->ieee_setets(h, ets);
32 return -EOPNOTSUPP;
35 static
36 int hns3_dcbnl_ieee_getpfc(struct net_device *ndev, struct ieee_pfc *pfc)
38 struct hnae3_handle *h = hns3_get_handle(ndev);
40 if (h->kinfo.dcb_ops->ieee_getpfc)
41 return h->kinfo.dcb_ops->ieee_getpfc(h, pfc);
43 return -EOPNOTSUPP;
46 static
47 int hns3_dcbnl_ieee_setpfc(struct net_device *ndev, struct ieee_pfc *pfc)
49 struct hnae3_handle *h = hns3_get_handle(ndev);
51 if (h->kinfo.dcb_ops->ieee_setpfc)
52 return h->kinfo.dcb_ops->ieee_setpfc(h, pfc);
54 return -EOPNOTSUPP;
57 /* DCBX configuration */
58 static u8 hns3_dcbnl_getdcbx(struct net_device *ndev)
60 struct hnae3_handle *h = hns3_get_handle(ndev);
62 if (h->kinfo.dcb_ops->getdcbx)
63 return h->kinfo.dcb_ops->getdcbx(h);
65 return 0;
68 /* return 0 if successful, otherwise fail */
69 static u8 hns3_dcbnl_setdcbx(struct net_device *ndev, u8 mode)
71 struct hnae3_handle *h = hns3_get_handle(ndev);
73 if (h->kinfo.dcb_ops->setdcbx)
74 return h->kinfo.dcb_ops->setdcbx(h, mode);
76 return 1;
79 static const struct dcbnl_rtnl_ops hns3_dcbnl_ops = {
80 .ieee_getets = hns3_dcbnl_ieee_getets,
81 .ieee_setets = hns3_dcbnl_ieee_setets,
82 .ieee_getpfc = hns3_dcbnl_ieee_getpfc,
83 .ieee_setpfc = hns3_dcbnl_ieee_setpfc,
84 .getdcbx = hns3_dcbnl_getdcbx,
85 .setdcbx = hns3_dcbnl_setdcbx,
88 /* hclge_dcbnl_setup - DCBNL setup
89 * @handle: the corresponding vport handle
90 * Set up DCBNL
92 void hns3_dcbnl_setup(struct hnae3_handle *handle)
94 struct net_device *dev = handle->kinfo.netdev;
96 if ((!handle->kinfo.dcb_ops) || (handle->flags & HNAE3_SUPPORT_VF))
97 return;
99 dev->dcbnl_ops = &hns3_dcbnl_ops;