kernel-hacking-2024-linux-s.../net/core
Jeff Garzik d17792ebdf 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>
2010-03-05 14:00:17 -08:00
..
datagram.c Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6 2009-11-06 00:55:55 -08:00
dev.c Merge branch 'master' of /home/davem/src/GIT/linux-2.6/ 2010-02-28 19:23:06 -08:00
dev_mcast.c net: add addr len check to dev_mc_add 2010-02-26 04:22:26 -08:00
drop_monitor.c net: remove INIT_RCU_HEAD() usage 2010-02-17 00:03:27 -08:00
dst.c dst: call cond_resched() in dst_gc_task() 2010-02-08 15:00:39 -08:00
ethtool.c ethtool: Add direct access to ops->get_sset_count 2010-03-05 14:00:17 -08:00
fib_rules.c net: spread __net_init, __net_exit 2010-01-17 19:16:02 -08:00
filter.c Merge branch 'master' of /home/davem/src/GIT/linux-2.6/ 2010-02-28 19:23:06 -08:00
flow.c
gen_estimator.c
gen_stats.c
iovec.c
kmap_skb.h
link_watch.c linkwatch: linkwatch_forget_dev() to speedup device dismantle 2009-11-18 05:03:11 -08:00
Makefile skbuff: remove skb_dma_map/unmap 2009-12-02 19:57:15 -08:00
neighbour.c net neigh: Decouple per interface neighbour table controls from binary sysctls 2010-02-16 15:55:18 -08:00
net-sysfs.c net-sysfs: Use rtnl_trylock in wireless sysfs methods. 2010-02-19 15:40:51 -08:00
net-sysfs.h
net-traces.c
net_namespace.c netns: Add an explicit rcu_barrier to unregister_pernet_{device|subsys} 2009-12-03 12:22:03 -08:00
netevent.c
netpoll.c netpoll: allow execution of multiple rx_hooks per interface 2010-01-13 20:38:26 -08:00
pktgen.c xfrm: SA lookups signature with mark 2010-02-22 16:20:22 -08:00
request_sock.c
rtnetlink.c Merge branch 'master' of /home/davem/src/GIT/linux-2.6/ 2010-02-28 19:23:06 -08:00
scm.c scm: Only support SCM_RIGHTS on unix domain sockets. 2010-02-28 18:22:02 -08:00
skbuff.c const: constify remaining pipe_buf_operations 2009-12-16 07:20:05 -08:00
sock.c net: backlog functions rename 2010-03-05 13:34:03 -08:00
stream.c
sysctl_net_core.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6 2009-12-08 07:55:01 -08:00
user_dma.c
utils.c