1
2
3
4
5
6
7
8
9
10#include "hnae3.h"
11#include "hns3_enet.h"
12
13static
14int hns3_dcbnl_ieee_getets(struct net_device *ndev, struct ieee_ets *ets)
15{
16 struct hnae3_handle *h = hns3_get_handle(ndev);
17
18 if (h->kinfo.dcb_ops->ieee_getets)
19 return h->kinfo.dcb_ops->ieee_getets(h, ets);
20
21 return -EOPNOTSUPP;
22}
23
24static
25int hns3_dcbnl_ieee_setets(struct net_device *ndev, struct ieee_ets *ets)
26{
27 struct hnae3_handle *h = hns3_get_handle(ndev);
28
29 if (h->kinfo.dcb_ops->ieee_setets)
30 return h->kinfo.dcb_ops->ieee_setets(h, ets);
31
32 return -EOPNOTSUPP;
33}
34
35static
36int hns3_dcbnl_ieee_getpfc(struct net_device *ndev, struct ieee_pfc *pfc)
37{
38 struct hnae3_handle *h = hns3_get_handle(ndev);
39
40 if (h->kinfo.dcb_ops->ieee_getpfc)
41 return h->kinfo.dcb_ops->ieee_getpfc(h, pfc);
42
43 return -EOPNOTSUPP;
44}
45
46static
47int hns3_dcbnl_ieee_setpfc(struct net_device *ndev, struct ieee_pfc *pfc)
48{
49 struct hnae3_handle *h = hns3_get_handle(ndev);
50
51 if (h->kinfo.dcb_ops->ieee_setpfc)
52 return h->kinfo.dcb_ops->ieee_setpfc(h, pfc);
53
54 return -EOPNOTSUPP;
55}
56
57
58static u8 hns3_dcbnl_getdcbx(struct net_device *ndev)
59{
60 struct hnae3_handle *h = hns3_get_handle(ndev);
61
62 if (h->kinfo.dcb_ops->getdcbx)
63 return h->kinfo.dcb_ops->getdcbx(h);
64
65 return 0;
66}
67
68
69static u8 hns3_dcbnl_setdcbx(struct net_device *ndev, u8 mode)
70{
71 struct hnae3_handle *h = hns3_get_handle(ndev);
72
73 if (h->kinfo.dcb_ops->setdcbx)
74 return h->kinfo.dcb_ops->setdcbx(h, mode);
75
76 return 1;
77}
78
79static 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,
86};
87
88
89
90
91
92void hns3_dcbnl_setup(struct hnae3_handle *handle)
93{
94 struct net_device *dev = handle->kinfo.netdev;
95
96 if ((!handle->kinfo.dcb_ops) || (handle->flags & HNAE3_SUPPORT_VF))
97 return;
98
99 dev->dcbnl_ops = &hns3_dcbnl_ops;
100}
101