1 // SPDX-License-Identifier: GPL-2.0+
2 // Copyright (c) 2016-2017 Hisilicon Limited.
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
))
14 if (h
->kinfo
.dcb_ops
->ieee_getets
)
15 return h
->kinfo
.dcb_ops
->ieee_getets(h
, ets
);
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
))
27 if (h
->kinfo
.dcb_ops
->ieee_setets
)
28 return h
->kinfo
.dcb_ops
->ieee_setets(h
, ets
);
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
))
40 if (h
->kinfo
.dcb_ops
->ieee_getpfc
)
41 return h
->kinfo
.dcb_ops
->ieee_getpfc(h
, pfc
);
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
))
53 if (h
->kinfo
.dcb_ops
->ieee_setpfc
)
54 return h
->kinfo
.dcb_ops
->ieee_setpfc(h
, pfc
);
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
))
66 if (h
->kinfo
.dcb_ops
->ieee_setapp
)
67 return h
->kinfo
.dcb_ops
->ieee_setapp(h
, app
);
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
))
79 if (h
->kinfo
.dcb_ops
->ieee_delapp
)
80 return h
->kinfo
.dcb_ops
->ieee_delapp(h
, app
);
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
);
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
);
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
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
))
129 dev
->dcbnl_ops
= &hns3_dcbnl_ops
;