drm: bridge: adv7511: remove s32 format from i2s capabilities
[drm/drm-misc.git] / drivers / net / ethernet / hisilicon / hns3 / hns3_dcbnl.c
blobf72dc0cee30e553dba0fac192308107e858da404
1 // SPDX-License-Identifier: GPL-2.0+
2 // Copyright (c) 2016-2017 Hisilicon Limited.
4 #include "hnae3.h"
5 #include "hns3_enet.h"
7 static int hns3_dcbnl_ieee_getets(struct net_device *ndev, struct ieee_ets *ets)
9 struct hnae3_handle *h = hns3_get_handle(ndev);
11 if (hns3_nic_resetting(ndev))
12 return -EBUSY;
14 if (h->kinfo.dcb_ops->ieee_getets)
15 return h->kinfo.dcb_ops->ieee_getets(h, ets);
17 return -EOPNOTSUPP;
20 static int hns3_dcbnl_ieee_setets(struct net_device *ndev, struct ieee_ets *ets)
22 struct hnae3_handle *h = hns3_get_handle(ndev);
24 if (hns3_nic_resetting(ndev))
25 return -EBUSY;
27 if (h->kinfo.dcb_ops->ieee_setets)
28 return h->kinfo.dcb_ops->ieee_setets(h, ets);
30 return -EOPNOTSUPP;
33 static int hns3_dcbnl_ieee_getpfc(struct net_device *ndev, struct ieee_pfc *pfc)
35 struct hnae3_handle *h = hns3_get_handle(ndev);
37 if (hns3_nic_resetting(ndev))
38 return -EBUSY;
40 if (h->kinfo.dcb_ops->ieee_getpfc)
41 return h->kinfo.dcb_ops->ieee_getpfc(h, pfc);
43 return -EOPNOTSUPP;
46 static int hns3_dcbnl_ieee_setpfc(struct net_device *ndev, struct ieee_pfc *pfc)
48 struct hnae3_handle *h = hns3_get_handle(ndev);
50 if (hns3_nic_resetting(ndev))
51 return -EBUSY;
53 if (h->kinfo.dcb_ops->ieee_setpfc)
54 return h->kinfo.dcb_ops->ieee_setpfc(h, pfc);
56 return -EOPNOTSUPP;
59 static int hns3_dcbnl_ieee_setapp(struct net_device *ndev, struct dcb_app *app)
61 struct hnae3_handle *h = hns3_get_handle(ndev);
63 if (hns3_nic_resetting(ndev))
64 return -EBUSY;
66 if (h->kinfo.dcb_ops->ieee_setapp)
67 return h->kinfo.dcb_ops->ieee_setapp(h, app);
69 return -EOPNOTSUPP;
72 static int hns3_dcbnl_ieee_delapp(struct net_device *ndev, struct dcb_app *app)
74 struct hnae3_handle *h = hns3_get_handle(ndev);
76 if (hns3_nic_resetting(ndev))
77 return -EBUSY;
79 if (h->kinfo.dcb_ops->ieee_delapp)
80 return h->kinfo.dcb_ops->ieee_delapp(h, app);
82 return -EOPNOTSUPP;
85 /* DCBX configuration */
86 static u8 hns3_dcbnl_getdcbx(struct net_device *ndev)
88 struct hnae3_handle *h = hns3_get_handle(ndev);
90 if (h->kinfo.dcb_ops->getdcbx)
91 return h->kinfo.dcb_ops->getdcbx(h);
93 return 0;
96 /* return 0 if successful, otherwise fail */
97 static u8 hns3_dcbnl_setdcbx(struct net_device *ndev, u8 mode)
99 struct hnae3_handle *h = hns3_get_handle(ndev);
101 if (h->kinfo.dcb_ops->setdcbx)
102 return h->kinfo.dcb_ops->setdcbx(h, mode);
104 return 1;
107 static const struct dcbnl_rtnl_ops hns3_dcbnl_ops = {
108 .ieee_getets = hns3_dcbnl_ieee_getets,
109 .ieee_setets = hns3_dcbnl_ieee_setets,
110 .ieee_getpfc = hns3_dcbnl_ieee_getpfc,
111 .ieee_setpfc = hns3_dcbnl_ieee_setpfc,
112 .ieee_setapp = hns3_dcbnl_ieee_setapp,
113 .ieee_delapp = hns3_dcbnl_ieee_delapp,
114 .getdcbx = hns3_dcbnl_getdcbx,
115 .setdcbx = hns3_dcbnl_setdcbx,
118 /* hclge_dcbnl_setup - DCBNL setup
119 * @handle: the corresponding vport handle
120 * Set up DCBNL
122 void hns3_dcbnl_setup(struct hnae3_handle *handle)
124 struct net_device *dev = handle->kinfo.netdev;
126 if ((!handle->kinfo.dcb_ops) || (handle->flags & HNAE3_SUPPORT_VF))
127 return;
129 dev->dcbnl_ops = &hns3_dcbnl_ops;