From: David Miller <davem@davemloft.net>
To: rusty@rustcorp.com.au
Cc: netdev@vger.kernel.org, shemminger@linux-foundation.org,
jgarzik@pobox.com, hadi@cyberus.ca
Subject: Re: [PATCH RFX]: napi_struct V3
Date: Tue, 24 Jul 2007 17:45:37 -0700 (PDT) [thread overview]
Message-ID: <20070724.174537.21926733.davem@davemloft.net> (raw)
In-Reply-To: <1185258104.1803.223.camel@localhost.localdomain>
From: Rusty Russell <rusty@rustcorp.com.au>
Date: Tue, 24 Jul 2007 16:21:43 +1000
> On Mon, 2007-07-23 at 22:47 -0700, David Miller wrote:
> > Any objections?
>
> On the contrary, this looks good.
It turns out the explicit restart logic isn't necessary. On the first
driver I tried to "convert" this became apparent real fast.
The key is what the ->poll() caller does if you don't complete the
NAPI, from net_rx_action():
/* if napi_complete not called, reschedule */
if (test_bit(NAPI_STATE_SCHED, &n->state))
__napi_schedule(n);
Let's look at ep93xx_poll() as it sits in my current tree, which used
to use netif_rx_reschedule():
static int ep93xx_poll(struct napi_struct *napi, int budget)
{
struct ep93xx_priv *ep = container_of(napi, struct ep93xx_priv, napi);
struct net_device *dev = ep->dev;
int rx;
/*
* @@@ Have to stop polling if device is downed while we
* are polling.
*/
rx = ep93xx_rx(dev, 0, budget);
if (rx < budget) {
spin_lock_irq(&ep->rx_lock);
wrl(ep, REG_INTEN, REG_INTEN_TX | REG_INTEN_RX);
if (ep93xx_have_more_rx(ep))
wrl(ep, REG_INTEN, REG_INTEN_TX);
else
netif_rx_complete(dev, napi);
spin_unlock_irq(&ep->rx_lock);
}
return rx;
}
This driver handles TX in it's hardware interrupt handler, and RX
via NAPI. So to NAPI poll it simply disables RX interrupts and
schedules NAPI.
if (status & REG_INTSTS_RX) {
spin_lock(&ep->rx_lock);
if (likely(__netif_rx_schedule_prep(dev, &ep->napi))) {
wrl(ep, REG_INTEN, REG_INTEN_TX);
__netif_rx_schedule(dev, &ep->napi);
}
spin_unlock(&ep->rx_lock);
}
anyways, if after re-enabling RX interrupts it sees some RX
work, it can simply re-disable RX interrupts and leave the NAPI
state alone. And that's how I've coded things above.
The caller will requeue the NAPI instance onto the poll list,
nothing more needs to be done to prevent event loss.
I'm now going to go over the other resched cases and make sure
things can be similarly handled in those drivers as well.
To be honest I'm quite confident this will be the case.
next prev parent reply other threads:[~2007-07-25 0:45 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-24 4:07 [PATCH RFX]: napi_struct V3 David Miller
2007-07-24 4:47 ` Rusty Russell
2007-07-24 5:47 ` David Miller
2007-07-24 6:21 ` Rusty Russell
2007-07-25 0:45 ` David Miller [this message]
2007-07-25 1:15 ` Rusty Russell
2007-07-25 1:47 ` David Miller
2007-07-25 2:33 ` Rusty Russell
2007-07-25 4:29 ` David Miller
2007-07-25 5:09 ` Rusty Russell
2007-07-25 5:12 ` David Miller
2007-07-25 5:10 ` David Miller
2007-07-24 7:12 ` Francois Romieu
2007-07-24 7:33 ` Jeff Garzik
2007-07-24 7:35 ` David Miller
2007-07-28 15:21 ` Roland Dreier
2007-07-29 5:30 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070724.174537.21926733.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=hadi@cyberus.ca \
--cc=jgarzik@pobox.com \
--cc=netdev@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=shemminger@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).