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.
11 #include "hns3_enet.h"
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
);
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
);
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
);
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
);
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
);
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
);
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
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
))
99 dev
->dcbnl_ops
= &hns3_dcbnl_ops
;