ibm_emac: Convert to use napi_struct independent of struct net_device
Gitweb: http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=bfe13f54f5028cff034e3b6247e9f433908f4f4f Commit: bfe13f54f5028cff034e3b6247e9f433908f4f4f Parent: 9153f66a5b8e63c61374df4e6a4cbd0056e45178 Author: Roland Dreier [EMAIL PROTECTED] AuthorDate: Tue Oct 9 15:47:37 2007 -0700 Committer: David S. Miller [EMAIL PROTECTED] CommitDate: Wed Oct 10 16:55:31 2007 -0700 ibm_emac: Convert to use napi_struct independent of struct net_device Commit da3dedd9 ([NET]: Make NAPI polling independent of struct net_device objects.) changed the interface to NAPI polling. Fix up the ibm_emac driver so that it works with this new interface. This is actually a nice cleanup because ibm_emac is one of the drivers that wants to have multiple NAPI structures for a single net_device. Tested with the internal MAC of a PowerPC 440SPe SoC with an AMCC 'Yucca' evaluation board. Signed-off-by: Roland Dreier [EMAIL PROTECTED] Signed-off-by: Jeff Garzik [EMAIL PROTECTED] --- drivers/net/ibm_emac/ibm_emac_mal.c | 48 -- drivers/net/ibm_emac/ibm_emac_mal.h |2 +- include/linux/netdevice.h | 10 +++ 3 files changed, 28 insertions(+), 32 deletions(-) diff --git a/drivers/net/ibm_emac/ibm_emac_mal.c b/drivers/net/ibm_emac/ibm_emac_mal.c index cabd984..4e49e8c 100644 --- a/drivers/net/ibm_emac/ibm_emac_mal.c +++ b/drivers/net/ibm_emac/ibm_emac_mal.c @@ -207,10 +207,10 @@ static irqreturn_t mal_serr(int irq, void *dev_instance) static inline void mal_schedule_poll(struct ibm_ocp_mal *mal) { - if (likely(netif_rx_schedule_prep(mal-poll_dev))) { + if (likely(napi_schedule_prep(mal-napi))) { MAL_DBG2(%d: schedule_poll NL, mal-def-index); mal_disable_eob_irq(mal); - __netif_rx_schedule(mal-poll_dev); + __napi_schedule(mal-napi); } else MAL_DBG2(%d: already in poll NL, mal-def-index); } @@ -273,11 +273,11 @@ static irqreturn_t mal_rxde(int irq, void *dev_instance) return IRQ_HANDLED; } -static int mal_poll(struct net_device *ndev, int *budget) +static int mal_poll(struct napi_struct *napi, int budget) { - struct ibm_ocp_mal *mal = ndev-priv; + struct ibm_ocp_mal *mal = container_of(napi, struct ibm_ocp_mal, napi); struct list_head *l; - int rx_work_limit = min(ndev-quota, *budget), received = 0, done; + int received = 0; MAL_DBG2(%d: poll(%d) %d - NL, mal-def-index, *budget, rx_work_limit); @@ -295,38 +295,34 @@ static int mal_poll(struct net_device *ndev, int *budget) list_for_each(l, mal-poll_list) { struct mal_commac *mc = list_entry(l, struct mal_commac, poll_list); - int n = mc-ops-poll_rx(mc-dev, rx_work_limit); + int n = mc-ops-poll_rx(mc-dev, budget); if (n) { received += n; - rx_work_limit -= n; - if (rx_work_limit = 0) { - done = 0; + budget -= n; + if (budget = 0) goto more_work; // XXX What if this is the last one ? - } } } /* We need to disable IRQs to protect from RXDE IRQ here */ local_irq_disable(); - __netif_rx_complete(ndev); + __napi_complete(napi); mal_enable_eob_irq(mal); local_irq_enable(); - done = 1; - /* Check for rotting packet(s) */ list_for_each(l, mal-poll_list) { struct mal_commac *mc = list_entry(l, struct mal_commac, poll_list); if (unlikely(mc-ops-peek_rx(mc-dev) || mc-rx_stopped)) { MAL_DBG2(%d: rotting packet NL, mal-def-index); - if (netif_rx_reschedule(ndev, received)) + if (napi_reschedule(napi)) mal_disable_eob_irq(mal); else MAL_DBG2(%d: already in poll list NL, mal-def-index); - if (rx_work_limit 0) + if (budget 0) goto again; else goto more_work; @@ -335,12 +331,8 @@ static int mal_poll(struct net_device *ndev, int *budget) } more_work: - ndev-quota -= received; - *budget -= received; - - MAL_DBG2(%d: poll() %d - %d NL, mal-def-index, *budget, -done ? 0 : 1); - return done ? 0 : 1; + MAL_DBG2(%d: poll() %d - %d NL, mal-def-index, budget, received); + return received; } static void mal_reset(struct ibm_ocp_mal *mal) @@ -425,11 +417,8 @@ static int __init
ibm_emac: Convert to use napi_struct independent of struct net_device
Gitweb: http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=59e90b2d22500f2e9cc635793562154abc8f4621 Commit: 59e90b2d22500f2e9cc635793562154abc8f4621 Parent: 61ba5b3c14b4956493d1180e0a860e941108393e Author: Roland Dreier [EMAIL PROTECTED] AuthorDate: Tue Oct 9 15:48:56 2007 -0700 Committer: David S. Miller [EMAIL PROTECTED] CommitDate: Wed Oct 10 16:55:32 2007 -0700 ibm_emac: Convert to use napi_struct independent of struct net_device Commit da3dedd9 ([NET]: Make NAPI polling independent of struct net_device objects.) changed the interface to NAPI polling. Fix up the ibm_newemac driver so that it works with this new interface. This is actually a nice cleanup because ibm_newemac is one of the drivers that wants to have multiple NAPI structures for a single net_device. Compile-tested only as I don't have a system that uses the ibm_newemac driver. This conversion the conversion for the ibm_emac driver that was tested on real PowerPC 440SPe hardware. Signed-off-by: Roland Dreier [EMAIL PROTECTED] Signed-off-by: Jeff Garzik [EMAIL PROTECTED] --- drivers/net/ibm_newemac/mal.c | 55 ++-- drivers/net/ibm_newemac/mal.h |2 +- 2 files changed, 20 insertions(+), 37 deletions(-) diff --git a/drivers/net/ibm_newemac/mal.c b/drivers/net/ibm_newemac/mal.c index c4335b7..5885411 100644 --- a/drivers/net/ibm_newemac/mal.c +++ b/drivers/net/ibm_newemac/mal.c @@ -235,10 +235,10 @@ static irqreturn_t mal_serr(int irq, void *dev_instance) static inline void mal_schedule_poll(struct mal_instance *mal) { - if (likely(netif_rx_schedule_prep(mal-poll_dev))) { + if (likely(napi_schedule_prep(mal-napi))) { MAL_DBG2(mal, schedule_poll NL); mal_disable_eob_irq(mal); - __netif_rx_schedule(mal-poll_dev); + __napi_schedule(mal-napi); } else MAL_DBG2(mal, already in poll NL); } @@ -318,8 +318,7 @@ void mal_poll_disable(struct mal_instance *mal, struct mal_commac *commac) msleep(1); /* Synchronize with the MAL NAPI poller. */ - while (test_bit(__LINK_STATE_RX_SCHED, mal-poll_dev.state)) - msleep(1); + napi_disable(mal-napi); } void mal_poll_enable(struct mal_instance *mal, struct mal_commac *commac) @@ -330,11 +329,11 @@ void mal_poll_enable(struct mal_instance *mal, struct mal_commac *commac) // XXX might want to kick a poll now... } -static int mal_poll(struct net_device *ndev, int *budget) +static int mal_poll(struct napi_struct *napi, int budget) { - struct mal_instance *mal = netdev_priv(ndev); + struct mal_instance *mal = container_of(napi, struct mal_instance, napi); struct list_head *l; - int rx_work_limit = min(ndev-quota, *budget), received = 0, done; + int received = 0; unsigned long flags; MAL_DBG2(mal, poll(%d) %d - NL, *budget, @@ -358,26 +357,21 @@ static int mal_poll(struct net_device *ndev, int *budget) int n; if (unlikely(test_bit(MAL_COMMAC_POLL_DISABLED, mc-flags))) continue; - n = mc-ops-poll_rx(mc-dev, rx_work_limit); + n = mc-ops-poll_rx(mc-dev, budget); if (n) { received += n; - rx_work_limit -= n; - if (rx_work_limit = 0) { - done = 0; - // XXX What if this is the last one ? - goto more_work; - } + budget -= n; + if (budget = 0) + goto more_work; // XXX What if this is the last one ? } } /* We need to disable IRQs to protect from RXDE IRQ here */ spin_lock_irqsave(mal-lock, flags); - __netif_rx_complete(ndev); + __napi_complete(napi); mal_enable_eob_irq(mal); spin_unlock_irqrestore(mal-lock, flags); - done = 1; - /* Check for rotting packet(s) */ list_for_each(l, mal-poll_list) { struct mal_commac *mc = @@ -387,12 +381,12 @@ static int mal_poll(struct net_device *ndev, int *budget) if (unlikely(mc-ops-peek_rx(mc-dev) || test_bit(MAL_COMMAC_RX_STOPPED, mc-flags))) { MAL_DBG2(mal, rotting packet NL); - if (netif_rx_reschedule(ndev, received)) + if (napi_reschedule(napi)) mal_disable_eob_irq(mal); else MAL_DBG2(mal, already in poll list NL); - if (rx_work_limit 0) + if (budget 0) goto again