Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1420466

[PATCH 2/3] ethtool: Add common functions for get and set settings

From Dongpo Li <lidongpo@hisilicon.com>
Newsgroups linux.kernel
Subject [PATCH 2/3] ethtool: Add common functions for get and set settings
Date 2016-06-13 08:20 +0200
Message-ID <rJto6-2pt-7@gated-at.bofh.it> (permalink)
References <rJto5-2pt-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Currently, most drivers only support get and set PHY settings
by PHY ethtool API. For those drivers, it's better to
supply common functions for get_settings and set_settings.
This patch adds common functions implementation.

Reviewed-by: Jiancheng Xue <xuejiancheng@hisilicon.com>
Signed-off-by: Dongpo Li <lidongpo@hisilicon.com>
---
 include/linux/ethtool.h |  2 ++
 net/core/ethtool.c      | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 9ded8c6..e114db9 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -82,6 +82,8 @@ struct net_device;
 /* Some generic methods drivers may use in their ethtool_ops */
 u32 ethtool_op_get_link(struct net_device *dev);
 int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *eti);
+int ethtool_op_get_settings(struct net_device *dev, struct ethtool_cmd *cmd);
+int ethtool_op_set_settings(struct net_device *dev, struct ethtool_cmd *cmd);
 
 /**
  * ethtool_rxfh_indir_default - get default value for RX flow hash indirection
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index f403481..270b6d1 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -50,6 +50,27 @@ int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info)
 }
 EXPORT_SYMBOL(ethtool_op_get_ts_info);
 
+int ethtool_op_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+	if (!dev->phydev)
+		return -ENODEV;
+
+	return phy_ethtool_gset(dev->phydev, cmd);
+}
+EXPORT_SYMBOL(ethtool_op_get_settings);
+
+int ethtool_op_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+	if (!capable(CAP_NET_ADMIN))
+		return -EPERM;
+
+	if (!dev->phydev)
+		return -ENODEV;
+
+	return phy_ethtool_sset(dev->phydev, cmd);
+}
+EXPORT_SYMBOL(ethtool_op_set_settings);
+
 /* Handlers for each ethtool command */
 
 #define ETHTOOL_DEV_FEATURE_WORDS	((NETDEV_FEATURE_COUNT + 31) / 32)
-- 
2.8.2

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/3] Add Hisilicon MDIO bus driver and FEMAC driver Dongpo Li <lidongpo@hisilicon.com> - 2016-06-13 08:20 +0200
  [PATCH 2/3] ethtool: Add common functions for get and set settings Dongpo Li <lidongpo@hisilicon.com> - 2016-06-13 08:20 +0200
    Re: [PATCH 2/3] ethtool: Add common functions for get and set  settings kbuild test robot <lkp@intel.com> - 2016-06-13 09:40 +0200
    Re: [PATCH 2/3] ethtool: Add common functions for get and set  settings kbuild test robot <lkp@intel.com> - 2016-06-13 10:20 +0200
    Re: [PATCH 2/3] ethtool: Add common functions for get and set  settings kbuild test robot <lkp@intel.com> - 2016-06-13 10:40 +0200
  [PATCH 3/3] net: hisilicon: Add Fast Ethernet MAC driver Dongpo Li <lidongpo@hisilicon.com> - 2016-06-13 08:20 +0200
    Re: [PATCH 3/3] net: hisilicon: Add Fast Ethernet MAC driver Arnd Bergmann <arnd@arndb.de> - 2016-06-13 12:40 +0200
      Re: [PATCH 3/3] net: hisilicon: Add Fast Ethernet MAC driver Li Dongpo <lidongpo@hisilicon.com> - 2016-06-14 15:20 +0200
        Re: [PATCH 3/3] net: hisilicon: Add Fast Ethernet MAC driver Arnd Bergmann <arnd@arndb.de> - 2016-06-14 23:20 +0200
          Re: [PATCH 3/3] net: hisilicon: Add Fast Ethernet MAC driver Dongpo Li <lidongpo@hisilicon.com> - 2016-06-15 12:00 +0200
    Re: [PATCH 3/3] net: hisilicon: Add Fast Ethernet MAC driver Rob Herring <robh@kernel.org> - 2016-06-15 00:40 +0200
      Re: [PATCH 3/3] net: hisilicon: Add Fast Ethernet MAC driver Dongpo Li <lidongpo@hisilicon.com> - 2016-06-15 12:20 +0200

csiph-web