linux/drivers/net/ethernet/hisilicon/hns3/hns3_dcbnl.c
<<
>>
Prefs
   1/*
   2 * Copyright (c) 2016-2017 Hisilicon Limited.
   3 *
   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.
   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/* DCBX configuration */
  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/* return 0 if successful, otherwise fail */
  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/* hclge_dcbnl_setup - DCBNL setup
  89 * @handle: the corresponding vport handle
  90 * Set up DCBNL
  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