* Information about napi_struct and net_device
@ 2012-10-27 16:18 Javier Domingo
2012-10-27 17:03 ` Eric Dumazet
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Javier Domingo @ 2012-10-27 16:18 UTC (permalink / raw)
To: netdev
Hello,
I am updating a kernel patch from 2.6.23-rc7 to v3.6, using git
facilities, and I have found that there have been lots of changes in
networking. Now the drivers are all by vendor, and more important,
net_device is not used always, as napi_struct took its place.
I have asked in #kernel but no one answered me, so I subscribed here.
Is there any place I can read about how is it now designed the use of
napi_struct and net_device? I have found a presentation[1] about how
networking was changing etc, and I wondered if there is anything more
precise about how it is actually implemented.
I understand a little why napi_struct, but don't really know much
about the change,
Hope someone can help me,
Javier Domingo
[1]: http://vger.kernel.org/~davem/davem_nyc09.pdf
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Information about napi_struct and net_device
2012-10-27 16:18 Information about napi_struct and net_device Javier Domingo
@ 2012-10-27 17:03 ` Eric Dumazet
2012-10-27 18:22 ` Francois Romieu
2012-10-27 20:10 ` Rami Rosen
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Eric Dumazet @ 2012-10-27 17:03 UTC (permalink / raw)
To: Javier Domingo; +Cc: netdev
On Sat, 2012-10-27 at 18:18 +0200, Javier Domingo wrote:
> Hello,
>
> I am updating a kernel patch from 2.6.23-rc7 to v3.6, using git
> facilities, and I have found that there have been lots of changes in
> networking. Now the drivers are all by vendor, and more important,
> net_device is not used always, as napi_struct took its place.
>
Yes, some directories were created and files moved around.
Not really a big deal (no real code change)
> I have asked in #kernel but no one answered me, so I subscribed here.
> Is there any place I can read about how is it now designed the use of
> napi_struct and net_device? I have found a presentation[1] about how
> networking was changing etc, and I wondered if there is anything more
> precise about how it is actually implemented.
>
> I understand a little why napi_struct, but don't really know much
> about the change,
>
> Hope someone can help me,
Seems quite straightforward, we probably should add some docs in
Documentation/networking/netdevices.txt
You could take a look at a small driver like
drivers/net/ethernet/realtek/8139cp.c
and grep for "napi" in it
# grep -n napi drivers/net/ethernet/realtek/8139cp.c
327: struct napi_struct napi;
436: napi_gro_receive(&cp->napi, skb);
468:static int cp_rx_poll(struct napi_struct *napi, int budget)
470: struct cp_private *cp = container_of(napi, struct cp_private, napi);
566: napi_gro_flush(napi, false);
568: __napi_complete(napi);
605: if (napi_schedule_prep(&cp->napi)) {
607: __napi_schedule(&cp->napi);
1132: napi_enable(&cp->napi);
1149: napi_disable(&cp->napi);
1160: napi_disable(&cp->napi);
1933: netif_napi_add(dev, &cp->napi, cp_rx_poll, 16);
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Information about napi_struct and net_device
2012-10-27 17:03 ` Eric Dumazet
@ 2012-10-27 18:22 ` Francois Romieu
2012-10-27 23:02 ` Eric Dumazet
0 siblings, 1 reply; 11+ messages in thread
From: Francois Romieu @ 2012-10-27 18:22 UTC (permalink / raw)
To: Javier Domingo; +Cc: Eric Dumazet, netdev
Eric Dumazet <eric.dumazet@gmail.com> :
[...]
> # grep -n napi drivers/net/ethernet/realtek/8139cp.c
> 327: struct napi_struct napi;
> 436: napi_gro_receive(&cp->napi, skb);
> 468:static int cp_rx_poll(struct napi_struct *napi, int budget)
> 470: struct cp_private *cp = container_of(napi, struct cp_private, napi);
> 566: napi_gro_flush(napi, false);
> 568: __napi_complete(napi);
> 605: if (napi_schedule_prep(&cp->napi)) {
> 607: __napi_schedule(&cp->napi);
> 1132: napi_enable(&cp->napi);
> 1149: napi_disable(&cp->napi);
> 1160: napi_disable(&cp->napi);
> 1933: netif_napi_add(dev, &cp->napi, cp_rx_poll, 16);
Not all drivers use napi_gro_receive/napi_gro_flush.
It could be worth comparing with drivers/net/ethernet/via/via-rhine.c (small)
or drivers/net/ethernet/broadcom/tg3.c (bigger).
--
Ueimor
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Information about napi_struct and net_device
2012-10-27 16:18 Information about napi_struct and net_device Javier Domingo
2012-10-27 17:03 ` Eric Dumazet
@ 2012-10-27 20:10 ` Rami Rosen
2012-10-29 1:09 ` Stephen Hemminger
2012-10-29 2:41 ` Ben Hutchings
3 siblings, 0 replies; 11+ messages in thread
From: Rami Rosen @ 2012-10-27 20:10 UTC (permalink / raw)
To: Javier Domingo; +Cc: netdev
Hi,
You can find some info about net_device in this wiki page:
https://www.linuxfoundation.org/collaborate/workgroups/networking/networkoverview
A shameless plug - I wrote it.
Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen
On Sat, Oct 27, 2012 at 6:18 PM, Javier Domingo <javierdo1@gmail.com> wrote:
> Hello,
>
> I am updating a kernel patch from 2.6.23-rc7 to v3.6, using git
> facilities, and I have found that there have been lots of changes in
> networking. Now the drivers are all by vendor, and more important,
> net_device is not used always, as napi_struct took its place.
>
> I have asked in #kernel but no one answered me, so I subscribed here.
> Is there any place I can read about how is it now designed the use of
> napi_struct and net_device? I have found a presentation[1] about how
> networking was changing etc, and I wondered if there is anything more
> precise about how it is actually implemented.
>
> I understand a little why napi_struct, but don't really know much
> about the change,
>
> Hope someone can help me,
>
> Javier Domingo
>
>
> [1]: http://vger.kernel.org/~davem/davem_nyc09.pdf
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Information about napi_struct and net_device
2012-10-27 18:22 ` Francois Romieu
@ 2012-10-27 23:02 ` Eric Dumazet
2012-10-28 23:23 ` Javier Domingo
0 siblings, 1 reply; 11+ messages in thread
From: Eric Dumazet @ 2012-10-27 23:02 UTC (permalink / raw)
To: Francois Romieu; +Cc: Javier Domingo, netdev
On Sat, 2012-10-27 at 20:22 +0200, Francois Romieu wrote:
> Not all drivers use napi_gro_receive/napi_gro_flush.
>
Yes, note that I only mentioned "grep napi", not these specific verbs
Also, napi_gro_receive() could be used now GRO doesnt mandate hardware
checksums.
> It could be worth comparing with drivers/net/ethernet/via/via-rhine.c (small)
> or drivers/net/ethernet/broadcom/tg3.c (bigger).
Unfortunately tg3.c uses internal stuff sith napi substring, so I
ignored it :
$ grep napi drivers/net/ethernet/broadcom/tg3.c | wc -l
376
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Information about napi_struct and net_device
2012-10-28 23:23 ` Javier Domingo
@ 2012-10-28 23:13 ` Francois Romieu
2012-10-29 11:49 ` Javier Domingo
0 siblings, 1 reply; 11+ messages in thread
From: Francois Romieu @ 2012-10-28 23:13 UTC (permalink / raw)
To: Javier Domingo; +Cc: netdev
Javier Domingo <javierdo1@gmail.com> :
[...]
> inside of the net_device structure, I know I can take
> the net_device pointer as documented in [3], but how may I obtain the
> napi_struct from the netdevice? or I am doing it the wrong way?
You are doing it the wrong way. The napi_struct you need is not embedded
here. See
$ less +/napi drivers/net/ethernet/realtek/8139cp.c
(first match in struct cp_private).
You should really read one of the existing drivers.
--
Ueimor
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Information about napi_struct and net_device
2012-10-27 23:02 ` Eric Dumazet
@ 2012-10-28 23:23 ` Javier Domingo
2012-10-28 23:13 ` Francois Romieu
0 siblings, 1 reply; 11+ messages in thread
From: Javier Domingo @ 2012-10-28 23:23 UTC (permalink / raw)
To: netdev
Hi all,
I am going to read all the netdevice.h declarations, and try to obtain
a more general view about what does each function do. At the moment,
I've read the page Rami Rosen [1] told be about, but there isn't the
explanation I was looking for, but had links to the netdev conferences
from the past years, and I read many of them.
I wish to ask/state a few questions/words about the napi_struct
creation etc. correct me please if I'm wrong
1. napi_struct has the fields that usually had net_device about
all control about the polling, so that the device structure where each
driver puts its functions is now much cleaner. With this, though you
have the particular net_device struct it uses in the napi_struct, you
can make as if they would be separated [3].
a. I need to work with net_device, but I also need to work
with napi_struct, I found these lines of code:
/*
* Some hardware also needs these fields, but they are not
* part of the usual set specified in Space.c.
*/
unsigned long state;
struct list_head dev_list;
struct list_head napi_list;
struct list_head unreg_list;
inside of the net_device structure, I know I can take
the net_device pointer as documented in [3], but how may I obtain the
napi_struct from the netdevice? or I am doing it the wrong way?
2. I found what napi GRO was in a David S. Miller blog post [2],
which explains many things I found about GRO, that it is about
improving packet processing in the network stack functions.
Javier Domingo
[1]: http://www.linuxfoundation.org/collaborate/workgroups/networking/networkoverview
[2]: http://vger.kernel.org/~davem/cgi-bin/blog.cgi/2010/08/30
[3]: http://lwn.net/Articles/214457/
2012/10/28 Eric Dumazet <eric.dumazet@gmail.com>:
> On Sat, 2012-10-27 at 20:22 +0200, Francois Romieu wrote:
>
>> Not all drivers use napi_gro_receive/napi_gro_flush.
>>
>
> Yes, note that I only mentioned "grep napi", not these specific verbs
>
> Also, napi_gro_receive() could be used now GRO doesnt mandate hardware
> checksums.
>
>> It could be worth comparing with drivers/net/ethernet/via/via-rhine.c (small)
>> or drivers/net/ethernet/broadcom/tg3.c (bigger).
>
> Unfortunately tg3.c uses internal stuff sith napi substring, so I
> ignored it :
>
> $ grep napi drivers/net/ethernet/broadcom/tg3.c | wc -l
> 376
>
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Information about napi_struct and net_device
2012-10-27 16:18 Information about napi_struct and net_device Javier Domingo
2012-10-27 17:03 ` Eric Dumazet
2012-10-27 20:10 ` Rami Rosen
@ 2012-10-29 1:09 ` Stephen Hemminger
2012-10-29 2:41 ` Ben Hutchings
3 siblings, 0 replies; 11+ messages in thread
From: Stephen Hemminger @ 2012-10-29 1:09 UTC (permalink / raw)
To: Javier Domingo; +Cc: netdev
On Sat, 27 Oct 2012 18:18:39 +0200
Javier Domingo <javierdo1@gmail.com> wrote:
> Hello,
>
> I am updating a kernel patch from 2.6.23-rc7 to v3.6, using git
> facilities, and I have found that there have been lots of changes in
> networking. Now the drivers are all by vendor, and more important,
> net_device is not used always, as napi_struct took its place.
>
> I have asked in #kernel but no one answered me, so I subscribed here.
> Is there any place I can read about how is it now designed the use of
> napi_struct and net_device? I have found a presentation[1] about how
> networking was changing etc, and I wondered if there is anything more
> precise about how it is actually implemented.
>
> I understand a little why napi_struct, but don't really know much
> about the change,
>
> Hope someone can help me,
>
> Javier Domingo
>
>
> [1]: http://vger.kernel.org/~davem/davem_nyc09.pdf
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
First, off put your driver upstream. The kernel developers do not care
about drivers not in the tree. They can wither up and die.
Second, learn to look in the right place.
http://lwn.net/Articles/244640/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Information about napi_struct and net_device
2012-10-27 16:18 Information about napi_struct and net_device Javier Domingo
` (2 preceding siblings ...)
2012-10-29 1:09 ` Stephen Hemminger
@ 2012-10-29 2:41 ` Ben Hutchings
2012-10-29 17:40 ` Javier Domingo
3 siblings, 1 reply; 11+ messages in thread
From: Ben Hutchings @ 2012-10-29 2:41 UTC (permalink / raw)
To: Javier Domingo; +Cc: netdev
On Sat, 2012-10-27 at 18:18 +0200, Javier Domingo wrote:
> Hello,
>
> I am updating a kernel patch from 2.6.23-rc7 to v3.6, using git
> facilities, and I have found that there have been lots of changes in
> networking. Now the drivers are all by vendor, and more important,
> net_device is not used always, as napi_struct took its place.
>
> I have asked in #kernel but no one answered me, so I subscribed here.
> Is there any place I can read about how is it now designed the use of
> napi_struct and net_device? I have found a presentation[1] about how
> networking was changing etc, and I wondered if there is anything more
> precise about how it is actually implemented.
>
> I understand a little why napi_struct, but don't really know much
> about the change,
>
> Hope someone can help me,
The initial change to napi_struct is explained in
<http://lwn.net/Articles/244640/>.
Since then there have been further changes:
- netif_napi_del() has been added. You must call it to clean up NAPI
contexts before freeing the associated net device(s).
- Instead of netif_rx_schedule(), netif_rx_complete(), etc. you must use
napi_schedule(), napi_complete() etc. which just take a napi_struct
pointer.
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Information about napi_struct and net_device
2012-10-28 23:13 ` Francois Romieu
@ 2012-10-29 11:49 ` Javier Domingo
0 siblings, 0 replies; 11+ messages in thread
From: Javier Domingo @ 2012-10-29 11:49 UTC (permalink / raw)
To: Francois Romieu; +Cc: netdev
Hi Francois,
I have been reading the code you recommended, and I think I must have
misexplained myself. I am not developing a driver, I am updating a
patch that we use at our research group, in which we modify linux to
make our custom packet processing, getting all the packets from the
NICs into a custom queue for processing.
It will obviously not going to be integrated in the linux kernel,
because its way to work is just useful to us, thought when we have
something that works, we have planned to distribute it.
I work with net_device, because I mainly use its fields, but I provide
functions to enable/disable capturing from a specific net_device. Now,
as napi_struct has appeared, I can't no longer use the
netif_rx_disable/enable functions, but I still need to know how to get
the already created napi_struct from my net_device pointers.
I think I have been looking in a too low level,
Regards,
Javier Domingo
2012/10/29 Francois Romieu <romieu@fr.zoreil.com>:
> Javier Domingo <javierdo1@gmail.com> :
> [...]
>> inside of the net_device structure, I know I can take
>> the net_device pointer as documented in [3], but how may I obtain the
>> napi_struct from the netdevice? or I am doing it the wrong way?
>
> You are doing it the wrong way. The napi_struct you need is not embedded
> here. See
>
> $ less +/napi drivers/net/ethernet/realtek/8139cp.c
>
> (first match in struct cp_private).
>
> You should really read one of the existing drivers.
>
> --
> Ueimor
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Information about napi_struct and net_device
2012-10-29 2:41 ` Ben Hutchings
@ 2012-10-29 17:40 ` Javier Domingo
0 siblings, 0 replies; 11+ messages in thread
From: Javier Domingo @ 2012-10-29 17:40 UTC (permalink / raw)
To: netdev
I finally found the problem, and I think also the answer.
I am modifying netif_receive_skb(), putting there my own queue. So the
only problem I face now is how may I disable the main netpoll through.
Looking at dev.c file, and knowing that there must be some way the
solution I was looking for, I discovered enqueue_to_backlog function,
that does what I want to do, from a packet, after processing it, be
able to take the napi_struct that was responsible from it.
I if you could tell me if using the method to obtain the napi_struct
from the net_device pointer used in enqueue_to_backlog is ok, it would
be great,
Any way I will continue doing experiments and reading,
Thanks a lot for your help and attention, and for whoever did [1]
Javier Domingo
[1]: http://www.linuxfoundation.org/images/1/1c/Network_data_flow_through_kernel.png
2012/10/29 Ben Hutchings <bhutchings@solarflare.com>:
> On Sat, 2012-10-27 at 18:18 +0200, Javier Domingo wrote:
>> Hello,
>>
>> I am updating a kernel patch from 2.6.23-rc7 to v3.6, using git
>> facilities, and I have found that there have been lots of changes in
>> networking. Now the drivers are all by vendor, and more important,
>> net_device is not used always, as napi_struct took its place.
>>
>> I have asked in #kernel but no one answered me, so I subscribed here.
>> Is there any place I can read about how is it now designed the use of
>> napi_struct and net_device? I have found a presentation[1] about how
>> networking was changing etc, and I wondered if there is anything more
>> precise about how it is actually implemented.
>>
>> I understand a little why napi_struct, but don't really know much
>> about the change,
>>
>> Hope someone can help me,
>
> The initial change to napi_struct is explained in
> <http://lwn.net/Articles/244640/>.
>
> Since then there have been further changes:
>
> - netif_napi_del() has been added. You must call it to clean up NAPI
> contexts before freeing the associated net device(s).
>
> - Instead of netif_rx_schedule(), netif_rx_complete(), etc. you must use
> napi_schedule(), napi_complete() etc. which just take a napi_struct
> pointer.
>
> Ben.
>
> --
> Ben Hutchings, Staff Engineer, Solarflare
> Not speaking for my employer; that's the marketing department's job.
> They asked us to note that Solarflare product names are trademarked.
>
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2012-10-29 17:41 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-27 16:18 Information about napi_struct and net_device Javier Domingo
2012-10-27 17:03 ` Eric Dumazet
2012-10-27 18:22 ` Francois Romieu
2012-10-27 23:02 ` Eric Dumazet
2012-10-28 23:23 ` Javier Domingo
2012-10-28 23:13 ` Francois Romieu
2012-10-29 11:49 ` Javier Domingo
2012-10-27 20:10 ` Rami Rosen
2012-10-29 1:09 ` Stephen Hemminger
2012-10-29 2:41 ` Ben Hutchings
2012-10-29 17:40 ` Javier Domingo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).