diff options
author | Jeff Garzik <jeff@garzik.org> | 2010-03-04 03:21:53 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-03-05 17:00:17 -0500 |
commit | d17792ebdf90289c9fd1bce888076d3d60ecd53b (patch) | |
tree | 5b649c673b00d159c1a571387fead761cef570fe /net | |
parent | 723b2f57ad83ee7087acf9a95e8e289414b1f521 (diff) |
ethtool: Add direct access to ops->get_sset_count
On 03/04/2010 09:26 AM, Ben Hutchings wrote:
> On Thu, 2010-03-04 at 00:51 -0800, Jeff Kirsher wrote:
>> From: Jeff Garzik<jgarzik@redhat.com>
>>
>> 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.
> [...]
>> --- a/net/core/ethtool.c
>> +++ b/net/core/ethtool.c
>> @@ -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.
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.
> [...]
>> +static noinline int ethtool_get_sset_info(struct net_device *dev,
>> + void __user *useraddr)
>> +{
> [...]
>> + /* 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);
Agreed.
I've attached a follow-up patch, which should enable my/Jeff's kernel
patch to be applied, followed by this one.
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/ethtool.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 70075c47ada..33d2ded50f8 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
18 | #include <linux/ethtool.h> | 18 | #include <linux/ethtool.h> |
19 | #include <linux/netdevice.h> | 19 | #include <linux/netdevice.h> |
20 | #include <linux/bitops.h> | ||
20 | #include <asm/uaccess.h> | 21 | #include <asm/uaccess.h> |
21 | 22 | ||
22 | /* | 23 | /* |
@@ -216,7 +217,7 @@ static noinline int ethtool_get_drvinfo(struct net_device *dev, void __user *use | |||
216 | 217 | ||
217 | /* | 218 | /* |
218 | * this method of obtaining string set info is deprecated; | 219 | * this method of obtaining string set info is deprecated; |
219 | * consider using ETHTOOL_GSSET_INFO instead | 220 | * Use ETHTOOL_GSSET_INFO instead. |
220 | */ | 221 | */ |
221 | if (ops->get_sset_count) { | 222 | if (ops->get_sset_count) { |
222 | int rc; | 223 | int rc; |
@@ -265,9 +266,7 @@ static noinline int ethtool_get_sset_info(struct net_device *dev, | |||
265 | return 0; | 266 | return 0; |
266 | 267 | ||
267 | /* calculate size of return buffer */ | 268 | /* calculate size of return buffer */ |
268 | for (i = 0; i < 64; i++) | 269 | n_bits = hweight64(sset_mask); |
269 | if (sset_mask & (1ULL << i)) | ||
270 | n_bits++; | ||
271 | 270 | ||
272 | memset(&info, 0, sizeof(info)); | 271 | memset(&info, 0, sizeof(info)); |
273 | info.cmd = ETHTOOL_GSSET_INFO; | 272 | info.cmd = ETHTOOL_GSSET_INFO; |