ethtool: Add direct access to ops->get_sset_count
Subsystems (3)
PATCH v4 1/1 ethtool: Add direct access to ops->get_sset_count
From: Jeff Garzik <[email protected]>
This patch is an alternative approach for accessing string counts, vs. the drvinfo indirect approach. This way the drvinfo space doesn't run out, and we don't break ABI later.
---
include/linux/ethtool.h | 17 +++++++++-- net/core/ethtool.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 3 deletions(-)
include/linux/ethtool.h +14 -3
@@ -253,6 +253,17 @@ struct ethtool_gstrings {__u8 data[0 ]; }; +struct ethtool_sset_info { +__u32 cmd;/* ETHTOOL_GSSET_INFO */ +__u32 reserved; +__u64 sset_mask;/* input: each bit selects an sset to query */ +/* output: each bit a returned sset */ +__u32 data[0 ];/* ETH_SS_xxx count, in order, based on bits +in sset_mask. One bit implies one +__u32, two bits implies two +__u32's, etc. */ +}; +enum ethtool_test_flags {ETH_TEST_FL_OFFLINE = (1 <<0 ),/* online / offline */ ETH_TEST_FL_FAILED = (1 <<1 ),/* test passed / failed */
@@ -606,9 +617,9 @@ struct ethtool_ops {#define ETHTOOL_SRXCLSRLINS 0x00000032/* Insert RX classification rule */ #define ETHTOOL_FLASHDEV 0x00000033/* Flash firmware to device */ #define ETHTOOL_RESET 0x00000034/* Reset hardware */ - -#define ETHTOOL_SRXNTUPLE 0x00000035/* Add an n-tuple filter to device */ -#define ETHTOOL_GRXNTUPLE 0x00000036/* Get n-tuple filters from device */ +#define ETHTOOL_SRXNTUPLE 0x00000035/* Add an n-tuple filter to device */ +#define ETHTOOL_GRXNTUPLE 0x00000036/* Get n-tuple filters from device */ +#define ETHTOOL_GSSET_INFO 0x00000037/* Get string set info */ /* compatibility with older code */ #define SPARC_ETH_GSET ETHTOOL_GSET
net/core/ethtool.c +72 -0
90 lines not on this page · raw message
Quoted 6 lines · Jeff Kirsher
From: Jeff Garzik<[email protected]>
This patch is an alternative approach for accessing string counts, vs. the drvinfo indirect approach. This way the drvinfo space doesn't run out, and we don't break ABI later.
Quoted 8 lines
Signed-off-by Jeff Garzik<[email protected]>Signed-off-by Peter P Waskiewicz Jr<[email protected]>Signed-off-by Jeff Kirsher<[email protected]>---
include/linux/ethtool.h | 17 +++++++++-- net/core/ethtool.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 3 deletions(-)
Both patches look good to me. There is a cosmetic issue of needing to sync up userspace and kernel ethtool.h WRT whitespace and deleted constants, but I can do that after DaveM applies this patch.
Waiting for upstream application, or other objections...
From: Jeff Garzik <[email protected]>
Date: Thu, 04 Mar 2010 08:23:05 -0500
Quoted 17 lines · Jeff Kirsher
Quoted 9 lines
From: Jeff Garzik<[email protected]>
This patch is an alternative approach for accessing string counts, vs. the drvinfo indirect approach. This way the drvinfo space doesn't run out, and we don't break ABI later.
Signed-off-by Jeff Garzik<[email protected]>Signed-off-by Peter P Waskiewicz Jr<[email protected]>Signed-off-by Jeff Kirsher<[email protected]>Quoted 6 lines
---
include/linux/ethtool.h | 17 +++++++++-- net/core/ethtool.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 3 deletions(-)
Quoted 5 lines
Both patches look good to me. There is a cosmetic issue of needing to sync up userspace and kernel
ethtool.hWRT whitespace and deleted constants, but I can do that after DaveM applies this patch.Waiting for upstream application, or other objections...
Applied, thanks guys.
Quoted 5 lines · Jeff Kirsher
From: Jeff Garzik <[email protected]>
This patch is an alternative approach for accessing string counts, vs. the drvinfo indirect approach. This way the drvinfo space doesn't run out, and we don't break ABI later.
[...]
net/core/ethtool.c static noinline int ethtool_get_drvinfo(struct net_device *dev, void __user *use · line 220
Quoted 10 lines
net/core/ethtool.c +4
-0@@ -214,6 +214,10 @@ static noinline int ethtool_get_drvinfo(struct net_device *dev, void __user *use info.cmd =ETHTOOL_GDRVINFO ; ops->get_drvinfo (dev, &info); +/* +* this method of obtaining string set info is deprecated; +* consider using ETHTOOL_GSSET_INFO instead +*/
This comment belongs on the interface (ethtool.h) not the implementation.
[...]
Quoted 3 lines
net/core/ethtool.c +3
-0+static noinline int ethtool_get_sset_info(struct net_device *dev, +void __user *useraddr) +{
[...]
net/core/ethtool.c static noinline int ethtool_get_drvinfo(struct net_device *dev, void __user *use · line 270
Quoted 4 lines
net/core/ethtool.c +4
-0+/* calculate size of return buffer */ +for (i =0 ; i <64 ; i++) +if (sset_mask & (1ULL << i)) + n_bits++;
[...]
We have a function for this:
n_bits = hweight64(sset_mask);
Ben.
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Quoted 13 lines · Ben Hutchings
Quoted 5 lines · Jeff Kirsher
From: Jeff Garzik<[email protected]>
This patch is an alternative approach for accessing string counts, vs. the drvinfo indirect approach. This way the drvinfo space doesn't run out, and we don't break ABI later.
[...]
Quoted 6 lines
net/core/ethtool.c +0
-0@@ -214,6 +214,10 @@ static noinline int ethtool_get_drvinfo(struct net_device *dev, void __user *use info.cmd =ETHTOOL_GDRVINFO ; ops->get_drvinfo (dev,&info);
Quoted 7 lines
net/core/ethtool.c static noinline int ethtool_get_drvinfo(struct net_device *dev, void __user *use · line 220
Quoted 4 lines
net/core/ethtool.c +4
-0+/* +* this method of obtaining string set info is deprecated; +* consider using ETHTOOL_GSSET_INFO instead +*/ This comment belongs on the interface (
ethtool.h) not the implementation.
Debatable -- the current comment is located at the callsite of ops->get_sset_count(), which is where an implementor might think to add a new call. Not all the numeric fields in ethtool_drvinfo are obtained from ->get_sset_count().
Hence the "some" in the attached patch to include/linux/ethtool.h, addressing your comment.
Quoted 11 lines
[...]
Quoted 3 lines
net/core/ethtool.c +3
-0+static noinline int ethtool_get_sset_info(struct net_device *dev, +void __user *useraddr) +{[...]
Quoted 4 lines
net/core/ethtool.c +4
-0+/* calculate size of return buffer */ +for (i =0 ; i<64 ; i++) +if (sset_mask& (1ULL << i)) + n_bits++;[...]
Quoted 3 lines
We have a function for this:
n_bits = hweight64(sset_mask);
Agreed.
I've attached a follow-up patch, which should enable my/Jeff's kernel patch to be applied, followed by this one.
Jeff
--- include/linux/ethtool.h | 7 +++++++ net/core/ethtool.c | 7 +++---- 2 files changed, 10 insertions(+), 4 deletions(-)
include/linux/ethtool.h +7 -0
@@ -61,6 +61,13 @@ struct ethtool_drvinfo {/* For PCI devices, use pci_name(pci_dev). */ char reserved1[32 ];char reserved2[12 ]; +/* +* Some struct members below are filled in +* using ops->get_sset_count(). Obtaining +* this info from ethtool_drvinfo is now +* deprecated; Use ETHTOOL_GSSET_INFO +* instead. +*/ __u32 n_priv_flags;/* number of flags valid in ETHTOOL_GPFLAGS */ __u32 n_stats;/* number of u64's from ETHTOOL_GSTATS */ __u32 testinfo_len;
net/core/ethtool.c +3 -4
@@ -17,6 +17,7 @@#include <linux/errno.h> #include <linux/ethtool.h> #include <linux/netdevice.h> +#include <linux/bitops.h> #include <asm/uaccess.h> /*
@@ -216,7 +217,7 @@ static noinline int ethtool_get_drvinfo(struct net_device *dev, void __user *use/* * this method of obtaining string set info is deprecated; -* consider using ETHTOOL_GSSET_INFO instead +* Use ETHTOOL_GSSET_INFO instead. */ if (ops->get_sset_count) {int rc;
@@ -265,9 +266,7 @@ static noinline int ethtool_get_sset_info(struct net_device *dev,return 0 ;/* calculate size of return buffer */ -for (i =0 ; i <64 ; i++) -if (sset_mask & (1ULL << i)) - n_bits++; + n_bits =hweight64 (sset_mask);memset (&info,0 ,sizeof (info)); info.cmd =ETHTOOL_GSSET_INFO ;
From: Jeff Garzik <[email protected]>
Date: Thu, 04 Mar 2010 13:21:53 -0500
Quoted 2 lines
I've attached a follow-up patch, which should enable my/Jeff's kernel patch to be applied, followed by this one.
Applied, thanks Jeff.