Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0+
0002 // Copyright (c) 2016-2017 Hisilicon Limited.
0003 
0004 #include "hnae3.h"
0005 #include "hns3_enet.h"
0006 
0007 static int hns3_dcbnl_ieee_getets(struct net_device *ndev, struct ieee_ets *ets)
0008 {
0009     struct hnae3_handle *h = hns3_get_handle(ndev);
0010 
0011     if (hns3_nic_resetting(ndev))
0012         return -EBUSY;
0013 
0014     if (h->kinfo.dcb_ops->ieee_getets)
0015         return h->kinfo.dcb_ops->ieee_getets(h, ets);
0016 
0017     return -EOPNOTSUPP;
0018 }
0019 
0020 static int hns3_dcbnl_ieee_setets(struct net_device *ndev, struct ieee_ets *ets)
0021 {
0022     struct hnae3_handle *h = hns3_get_handle(ndev);
0023 
0024     if (hns3_nic_resetting(ndev))
0025         return -EBUSY;
0026 
0027     if (h->kinfo.dcb_ops->ieee_setets)
0028         return h->kinfo.dcb_ops->ieee_setets(h, ets);
0029 
0030     return -EOPNOTSUPP;
0031 }
0032 
0033 static int hns3_dcbnl_ieee_getpfc(struct net_device *ndev, struct ieee_pfc *pfc)
0034 {
0035     struct hnae3_handle *h = hns3_get_handle(ndev);
0036 
0037     if (hns3_nic_resetting(ndev))
0038         return -EBUSY;
0039 
0040     if (h->kinfo.dcb_ops->ieee_getpfc)
0041         return h->kinfo.dcb_ops->ieee_getpfc(h, pfc);
0042 
0043     return -EOPNOTSUPP;
0044 }
0045 
0046 static int hns3_dcbnl_ieee_setpfc(struct net_device *ndev, struct ieee_pfc *pfc)
0047 {
0048     struct hnae3_handle *h = hns3_get_handle(ndev);
0049 
0050     if (hns3_nic_resetting(ndev))
0051         return -EBUSY;
0052 
0053     if (h->kinfo.dcb_ops->ieee_setpfc)
0054         return h->kinfo.dcb_ops->ieee_setpfc(h, pfc);
0055 
0056     return -EOPNOTSUPP;
0057 }
0058 
0059 /* DCBX configuration */
0060 static u8 hns3_dcbnl_getdcbx(struct net_device *ndev)
0061 {
0062     struct hnae3_handle *h = hns3_get_handle(ndev);
0063 
0064     if (h->kinfo.dcb_ops->getdcbx)
0065         return h->kinfo.dcb_ops->getdcbx(h);
0066 
0067     return 0;
0068 }
0069 
0070 /* return 0 if successful, otherwise fail */
0071 static u8 hns3_dcbnl_setdcbx(struct net_device *ndev, u8 mode)
0072 {
0073     struct hnae3_handle *h = hns3_get_handle(ndev);
0074 
0075     if (h->kinfo.dcb_ops->setdcbx)
0076         return h->kinfo.dcb_ops->setdcbx(h, mode);
0077 
0078     return 1;
0079 }
0080 
0081 static const struct dcbnl_rtnl_ops hns3_dcbnl_ops = {
0082     .ieee_getets    = hns3_dcbnl_ieee_getets,
0083     .ieee_setets    = hns3_dcbnl_ieee_setets,
0084     .ieee_getpfc    = hns3_dcbnl_ieee_getpfc,
0085     .ieee_setpfc    = hns3_dcbnl_ieee_setpfc,
0086     .getdcbx    = hns3_dcbnl_getdcbx,
0087     .setdcbx    = hns3_dcbnl_setdcbx,
0088 };
0089 
0090 /* hclge_dcbnl_setup - DCBNL setup
0091  * @handle: the corresponding vport handle
0092  * Set up DCBNL
0093  */
0094 void hns3_dcbnl_setup(struct hnae3_handle *handle)
0095 {
0096     struct net_device *dev = handle->kinfo.netdev;
0097 
0098     if ((!handle->kinfo.dcb_ops) || (handle->flags & HNAE3_SUPPORT_VF))
0099         return;
0100 
0101     dev->dcbnl_ops = &hns3_dcbnl_ops;
0102 }