netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* NAPI of many interfaces with just an interruption source
@ 2009-02-20 18:33 Miguel Ángel Álvarez
  2009-02-20 18:54 ` Stephen Hemminger
  0 siblings, 1 reply; 6+ messages in thread
From: Miguel Ángel Álvarez @ 2009-02-20 18:33 UTC (permalink / raw)
  To: netdev, Miguel Ángel Álvarez

Hi

I have four interfaces that share the same interruption source (four
hdlc channels in ixp4xx that share the same rx queue... but I am
trying to do the question generic).

My first approach was to declare a napi interface for each device.
When I detected the first interrupt, I determine the correct net
interface, and schedule a poll for it.

The question is that there is no warranty that the data received in
the polling belongs to the same interface, so...

- It is correct to do like this, and just analyse the data to check to
which net interface should the data be sent.
- Or NAPI is not correct for this case and we should just use the
simple interruption mechanism?

Thanks

Miguel Ángel Álvarez

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: NAPI of many interfaces with just an interruption source
  2009-02-20 18:33 NAPI of many interfaces with just an interruption source Miguel Ángel Álvarez
@ 2009-02-20 18:54 ` Stephen Hemminger
  2009-02-21 13:12   ` Herbert Xu
  0 siblings, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2009-02-20 18:54 UTC (permalink / raw)
  To: Miguel Ángel Álvarez; +Cc: netdev, Miguel Ángel Álvarez

On Fri, 20 Feb 2009 19:33:23 +0100
Miguel Ángel Álvarez <gotzoncabanes@gmail.com> wrote:

> Hi
> 
> I have four interfaces that share the same interruption source (four
> hdlc channels in ixp4xx that share the same rx queue... but I am
> trying to do the question generic).
> 
> My first approach was to declare a napi interface for each device.
> When I detected the first interrupt, I determine the correct net
> interface, and schedule a poll for it.
> 
> The question is that there is no warranty that the data received in
> the polling belongs to the same interface, so...
> 
> - It is correct to do like this, and just analyse the data to check to
> which net interface should the data be sent.
> - Or NAPI is not correct for this case and we should just use the
> simple interruption mechanism?
> 
> Thanks
> 
> Miguel Ángel Álvarez

Several other devices have this (like sky2).  Since NAPI needs
to control irq, you need to have 1 NAPI instance per IRQ, so for
these type of drivers there is 1 NAPI in hardware structure
and multiple network devices.

Note: netconsole/netpoll will only work on a single channel,
but usually a big issue.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: NAPI of many interfaces with just an interruption source
  2009-02-20 18:54 ` Stephen Hemminger
@ 2009-02-21 13:12   ` Herbert Xu
  2009-02-21 18:15     ` Miguel Ángel Álvarez
  2009-02-21 21:19     ` Benjamin Herrenschmidt
  0 siblings, 2 replies; 6+ messages in thread
From: Herbert Xu @ 2009-02-21 13:12 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: gotzoncabanes, netdev, Benjamin Herrenschmidt

Stephen Hemminger <shemminger@vyatta.com> wrote:
> On Fri, 20 Feb 2009 19:33:23 +0100
> Miguel Ángel Álvarez <gotzoncabanes@gmail.com> wrote:
>> 
>> I have four interfaces that share the same interruption source (four
>> hdlc channels in ixp4xx that share the same rx queue... but I am
>> trying to do the question generic).
>
> Several other devices have this (like sky2).  Since NAPI needs
> to control irq, you need to have 1 NAPI instance per IRQ, so for
> these type of drivers there is 1 NAPI in hardware structure
> and multiple network devices.

Ben has just done exactly the same thing for his driver so he
can tell you all about it and how to use his generic function :)

Thanks,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: NAPI of many interfaces with just an interruption source
  2009-02-21 13:12   ` Herbert Xu
@ 2009-02-21 18:15     ` Miguel Ángel Álvarez
  2009-02-21 21:19     ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 6+ messages in thread
From: Miguel Ángel Álvarez @ 2009-02-21 18:15 UTC (permalink / raw)
  To: Herbert Xu; +Cc: Stephen Hemminger, netdev, Benjamin Herrenschmidt

Thanks for your answers...

I understand that yes... if there is just an irq, the NAPI structure
should be one also...

The question is... I have one napi (inserted in an struct hss_t). This
hss structure has pointers to four struct port (each one is a network
device). So... When I detect the first IRQ, I can detect the dev
origin of the irq, and call netif_rx_schedule for it
(netif_rx_schedule(dev, &port->hss->napi).

In the poll function, I can obtain hss from napi, but not the dev
(unless I store the value of the last calling dev in hss_t). Is this
the way?

Thanks

Miguel Ángel Álvarez

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: NAPI of many interfaces with just an interruption source
  2009-02-21 13:12   ` Herbert Xu
  2009-02-21 18:15     ` Miguel Ángel Álvarez
@ 2009-02-21 21:19     ` Benjamin Herrenschmidt
  2009-02-23  9:21       ` Miguel Ángel Álvarez
  1 sibling, 1 reply; 6+ messages in thread
From: Benjamin Herrenschmidt @ 2009-02-21 21:19 UTC (permalink / raw)
  To: Herbert Xu; +Cc: Stephen Hemminger, gotzoncabanes, netdev


> Ben has just done exactly the same thing for his driver so he
> can tell you all about it and how to use his generic function :)

Right, you can look how it's done in ibm_newemac. There's basically
a "dummy" netdev which is created to handle the NAPI on behalf of
the real ones. The new core function init_dummy_netdev() will set
up that dummy netdev for you.

If you look at how I do it in emac, the actual ports "register"
internally with that "mal" module so that I can "poll" them when
the main NAPI is polled.

Cheers,
Ben.






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: NAPI of many interfaces with just an interruption source
  2009-02-21 21:19     ` Benjamin Herrenschmidt
@ 2009-02-23  9:21       ` Miguel Ángel Álvarez
  0 siblings, 0 replies; 6+ messages in thread
From: Miguel Ángel Álvarez @ 2009-02-23  9:21 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: Herbert Xu, Stephen Hemminger, netdev

Thanks for the help

On Sat, Feb 21, 2009 at 10:19 PM, Benjamin Herrenschmidt
<benh@kernel.crashing.org> wrote:
>
>> Ben has just done exactly the same thing for his driver so he
>> can tell you all about it and how to use his generic function :)
>
> Right, you can look how it's done in ibm_newemac. There's basically
> a "dummy" netdev which is created to handle the NAPI on behalf of
> the real ones. The new core function init_dummy_netdev() will set
> up that dummy netdev for you.
>
I am working with 2.26.7... I do not have that "init_dummy_netdev" for
what I see.

> If you look at how I do it in emac, the actual ports "register"
> internally with that "mal" module so that I can "poll" them when
> the main NAPI is polled.
>
I see how it works... Nice. So it seems there is API to work with NAPI
"out of" net interfaces. Perhaps that is what I need.

Just a question... Why do you register the dummy "mal" as a driver?
Should it not be enough to init it when the first real driver is
loaded?

Miguel Ángel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-02-23  9:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-20 18:33 NAPI of many interfaces with just an interruption source Miguel Ángel Álvarez
2009-02-20 18:54 ` Stephen Hemminger
2009-02-21 13:12   ` Herbert Xu
2009-02-21 18:15     ` Miguel Ángel Álvarez
2009-02-21 21:19     ` Benjamin Herrenschmidt
2009-02-23  9:21       ` Miguel Ángel Álvarez

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).