From c1b7151a5ef4f35fb116d1a2689c5280938b0e8d Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Wed, 17 Oct 2007 12:18:23 +0200 Subject: forcedeth: fix rx-work condition in nv_rx_process_optimized() too The merge of my previous fix to forcedeth.c, bcb5febb248f7cc1e4a39ff61507f6343ba1c594, lost an important hunk. We need to fix nv_rx_process_optimized() too, as it contains duplicate logic. Signed-off-by: Ingo Molnar Signed-off-by: Jeff Garzik --- drivers/net/forcedeth.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c index cfbb7aacfe9..d0bff8a8766 100644 --- a/drivers/net/forcedeth.c +++ b/drivers/net/forcedeth.c @@ -2408,13 +2408,13 @@ static int nv_rx_process_optimized(struct net_device *dev, int limit) struct fe_priv *np = netdev_priv(dev); u32 flags; u32 vlanflags = 0; - u32 rx_processed_cnt = 0; + int rx_work = 0; struct sk_buff *skb; int len; while((np->get_rx.ex != np->put_rx.ex) && !((flags = le32_to_cpu(np->get_rx.ex->flaglen)) & NV_RX2_AVAIL) && - (rx_processed_cnt++ < limit)) { + (rx_work < limit)) { dprintk(KERN_DEBUG "%s: nv_rx_process_optimized: flags 0x%x.\n", dev->name, flags); @@ -2517,9 +2517,11 @@ next_pkt: np->get_rx.ex = np->first_rx.ex; if (unlikely(np->get_rx_ctx++ == np->last_rx_ctx)) np->get_rx_ctx = np->first_rx_ctx; + + rx_work++; } - return rx_processed_cnt; + return rx_work; } static void set_bufsize(struct net_device *dev) -- cgit v1.2.3 From 6880e7cb35bfde5c8ef65cc846e0df54808f982f Mon Sep 17 00:00:00 2001 From: Sebastian Siewior Date: Wed, 17 Oct 2007 10:52:22 +0200 Subject: gianfar: remove orphan struct. struct net_device_stats is no longer used in driver's private struct but in struct net_device. Cc: Li Yang Signed-off-by: Sebastian Siewior Signed-off-by: Jeff Garzik --- drivers/net/gianfar.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h index c16cc8b946a..46cd7735e6f 100644 --- a/drivers/net/gianfar.h +++ b/drivers/net/gianfar.h @@ -749,7 +749,6 @@ struct gfar_private { uint32_t msg_enable; /* Network Statistics */ - struct net_device_stats stats; struct gfar_extra_stats extra_stats; }; -- cgit v1.2.3 From f860f49ee2e59d1a665416c9155cad7661ee0552 Mon Sep 17 00:00:00 2001 From: Scott Wood Date: Wed, 17 Oct 2007 12:42:43 -0500 Subject: fs_enet: Update for API changes This driver was recently broken by several changes for which this driver was not (or was improperly) updated: 1. SET_MODULE_OWNER() was removed. 2. netif_napi_add() was only being called when building with the old CPM binding. 3. The received/budget test was backwards. 4. to_net_dev() was wrong -- the device struct embedded in the net_device struct is not the same as the of_platform device in the private struct. 5. napi_disable/napi_enable was being called even when napi was not being used. These changes have been fixed, and napi is now on by default. Signed-off-by: Scott Wood Signed-off-by: Jeff Garzik --- drivers/net/fs_enet/fs_enet-main.c | 28 ++++++++++++++++------------ drivers/net/fs_enet/fs_enet.h | 1 + 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c index 04c6faec88d..f2a4d399a6e 100644 --- a/drivers/net/fs_enet/fs_enet-main.c +++ b/drivers/net/fs_enet/fs_enet-main.c @@ -88,7 +88,7 @@ static void skb_align(struct sk_buff *skb, int align) static int fs_enet_rx_napi(struct napi_struct *napi, int budget) { struct fs_enet_private *fep = container_of(napi, struct fs_enet_private, napi); - struct net_device *dev = to_net_dev(fep->dev); + struct net_device *dev = fep->ndev; const struct fs_platform_info *fpi = fep->fpi; cbd_t __iomem *bdp; struct sk_buff *skb, *skbn, *skbt; @@ -217,7 +217,7 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int budget) fep->cur_rx = bdp; - if (received >= budget) { + if (received < budget) { /* done */ netif_rx_complete(dev, napi); (*fep->ops->napi_enable_rx)(dev); @@ -807,20 +807,23 @@ static int fs_enet_open(struct net_device *dev) int r; int err; - napi_enable(&fep->napi); + if (fep->fpi->use_napi) + napi_enable(&fep->napi); /* Install our interrupt handler. */ r = fs_request_irq(dev, fep->interrupt, "fs_enet-mac", fs_enet_interrupt); if (r != 0) { printk(KERN_ERR DRV_MODULE_NAME ": %s Could not allocate FS_ENET IRQ!", dev->name); - napi_disable(&fep->napi); + if (fep->fpi->use_napi) + napi_disable(&fep->napi); return -EINVAL; } err = fs_init_phy(dev); - if(err) { - napi_disable(&fep->napi); + if (err) { + if (fep->fpi->use_napi) + napi_disable(&fep->napi); return err; } phy_start(fep->phydev); @@ -1232,7 +1235,7 @@ static int __devinit fs_enet_probe(struct of_device *ofdev, fpi->rx_ring = 32; fpi->tx_ring = 32; fpi->rx_copybreak = 240; - fpi->use_napi = 0; + fpi->use_napi = 1; fpi->napi_weight = 17; ret = find_phy(ofdev->node, fpi); @@ -1249,11 +1252,11 @@ static int __devinit fs_enet_probe(struct of_device *ofdev, goto out_free_fpi; } - SET_MODULE_OWNER(ndev); dev_set_drvdata(&ofdev->dev, ndev); fep = netdev_priv(ndev); fep->dev = &ofdev->dev; + fep->ndev = ndev; fep->fpi = fpi; fep->ops = match->data; @@ -1288,10 +1291,11 @@ static int __devinit fs_enet_probe(struct of_device *ofdev, ndev->stop = fs_enet_close; ndev->get_stats = fs_enet_get_stats; ndev->set_multicast_list = fs_set_multicast_list; - if (fpi->use_napi) { - ndev->poll = fs_enet_rx_napi; - ndev->weight = fpi->napi_weight; - } + + if (fpi->use_napi) + netif_napi_add(ndev, &fep->napi, fs_enet_rx_napi, + fpi->napi_weight); + ndev->ethtool_ops = &fs_ethtool_ops; ndev->do_ioctl = fs_ioctl; diff --git a/drivers/net/fs_enet/fs_enet.h b/drivers/net/fs_enet/fs_enet.h index baf6477165a..c675e29aadc 100644 --- a/drivers/net/fs_enet/fs_enet.h +++ b/drivers/net/fs_enet/fs_enet.h @@ -75,6 +75,7 @@ struct phy_info { struct fs_enet_private { struct napi_struct napi; struct device *dev; /* pointer back to the device (must be initialized first) */ + struct net_device *ndev; spinlock_t lock; /* during all ops except TX pckt processing */ spinlock_t tx_lock; /* during fs_start_xmit and fs_tx */ struct fs_platform_info *fpi; -- cgit v1.2.3 From db0e8e3f71dbd9a67e44eaa01d10e468d11fa73e Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Wed, 17 Oct 2007 23:57:46 +0400 Subject: gianfar: fix obviously wrong #ifdef CONFIG_GFAR_NAPI placement Erroneous #ifdef introduced by 293c8513398657f6263fcdb03c87f2760cf61be4 causing NAPI-less ethernet malfunctioning. Signed-off-by: Anton Vorontsov Signed-off-by: Vitaly Bordug Signed-off-by: Jeff Garzik --- drivers/net/gianfar.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index cc288d8f6a5..38268d7335a 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c @@ -956,10 +956,12 @@ static int gfar_enet_open(struct net_device *dev) } err = startup_gfar(dev); - if (err) + if (err) { #ifdef CONFIG_GFAR_NAPI napi_disable(&priv->napi); #endif + return err; + } netif_start_queue(dev); -- cgit v1.2.3 From a7475906bc496456ded9e4b062f94067fb93057a Mon Sep 17 00:00:00 2001 From: Manfred Spraul Date: Wed, 17 Oct 2007 21:52:33 +0200 Subject: forcedeth msi bugfix pci_enable_msi() replaces the INTx irq number in pci_dev->irq with the new MSI irq number. The forcedeth driver did not update the copy in netdevice->irq and parts of the driver used the stale copy. See bugzilla.kernel.org, bug 9047. The patch - updates netdevice->irq - replaces all accesses to netdevice->irq with pci_dev->irq. The patch is against 2.6.23.1. IMHO suitable for both 2.6.23 and 2.6.24 Signed-Off-By: Manfred Spraul Signed-off-by: Jeff Garzik --- drivers/net/forcedeth.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c index d0bff8a8766..70ddf1acfd8 100644 --- a/drivers/net/forcedeth.c +++ b/drivers/net/forcedeth.c @@ -992,7 +992,7 @@ static void nv_enable_irq(struct net_device *dev) if (np->msi_flags & NV_MSI_X_ENABLED) enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector); else - enable_irq(dev->irq); + enable_irq(np->pci_dev->irq); } else { enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector); enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector); @@ -1008,7 +1008,7 @@ static void nv_disable_irq(struct net_device *dev) if (np->msi_flags & NV_MSI_X_ENABLED) disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector); else - disable_irq(dev->irq); + disable_irq(np->pci_dev->irq); } else { disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector); disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector); @@ -1607,7 +1607,7 @@ static void nv_do_rx_refill(unsigned long data) if (np->msi_flags & NV_MSI_X_ENABLED) disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector); else - disable_irq(dev->irq); + disable_irq(np->pci_dev->irq); } else { disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector); } @@ -1625,7 +1625,7 @@ static void nv_do_rx_refill(unsigned long data) if (np->msi_flags & NV_MSI_X_ENABLED) enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector); else - enable_irq(dev->irq); + enable_irq(np->pci_dev->irq); } else { enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector); } @@ -3560,10 +3560,12 @@ static int nv_request_irq(struct net_device *dev, int intr_test) if (ret != 0 && np->msi_flags & NV_MSI_CAPABLE) { if ((ret = pci_enable_msi(np->pci_dev)) == 0) { np->msi_flags |= NV_MSI_ENABLED; + dev->irq = np->pci_dev->irq; if (request_irq(np->pci_dev->irq, handler, IRQF_SHARED, dev->name, dev) != 0) { printk(KERN_INFO "forcedeth: request_irq failed %d\n", ret); pci_disable_msi(np->pci_dev); np->msi_flags &= ~NV_MSI_ENABLED; + dev->irq = np->pci_dev->irq; goto out_err; } @@ -3626,7 +3628,7 @@ static void nv_do_nic_poll(unsigned long data) if (np->msi_flags & NV_MSI_X_ENABLED) disable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector); else - disable_irq_lockdep(dev->irq); + disable_irq_lockdep(np->pci_dev->irq); mask = np->irqmask; } else { if (np->nic_poll_irq & NVREG_IRQ_RX_ALL) { @@ -3644,6 +3646,8 @@ static void nv_do_nic_poll(unsigned long data) } np->nic_poll_irq = 0; + /* disable_irq() contains synchronize_irq, thus no irq handler can run now */ + if (np->recover_error) { np->recover_error = 0; printk(KERN_INFO "forcedeth: MAC in recoverable error state\n"); @@ -3680,7 +3684,6 @@ static void nv_do_nic_poll(unsigned long data) } } - /* FIXME: Do we need synchronize_irq(dev->irq) here? */ writel(mask, base + NvRegIrqMask); pci_push(base); @@ -3693,7 +3696,7 @@ static void nv_do_nic_poll(unsigned long data) if (np->msi_flags & NV_MSI_X_ENABLED) enable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector); else - enable_irq_lockdep(dev->irq); + enable_irq_lockdep(np->pci_dev->irq); } else { if (np->nic_poll_irq & NVREG_IRQ_RX_ALL) { nv_nic_irq_rx(0, dev); @@ -4950,7 +4953,7 @@ static int nv_close(struct net_device *dev) #ifdef CONFIG_FORCEDETH_NAPI napi_disable(&np->napi); #endif - synchronize_irq(dev->irq); + synchronize_irq(np->pci_dev->irq); del_timer_sync(&np->oom_kick); del_timer_sync(&np->nic_poll); -- cgit v1.2.3 From c264c3dee9f20bad1f42ef5821300791291d0f77 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 17 Oct 2007 13:26:41 -0700 Subject: napi_synchronize: waiting for NAPI Some drivers with shared NAPI need a synchronization barrier. Also suggested by Benjamin Herrenschmidt for EMAC. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- include/linux/netdevice.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 39dd83b183a..a5e2dc1f0d9 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -407,6 +407,24 @@ static inline void napi_enable(struct napi_struct *n) clear_bit(NAPI_STATE_SCHED, &n->state); } +#ifdef CONFIG_SMP +/** + * napi_synchronize - wait until NAPI is not running + * @n: napi context + * + * Wait until NAPI is done being scheduled on this context. + * Waits till any outstanding processing completes but + * does not disable future activations. + */ +static inline void napi_synchronize(const struct napi_struct *n) +{ + while (test_bit(NAPI_STATE_SCHED, &n->state)) + msleep(1); +} +#else +# define napi_synchronize(n) barrier() +#endif + /* * The DEVICE structure. * Actually, this whole structure is a big mistake. It mixes I/O -- cgit v1.2.3 From 6de16237c78a9df6c7cb2d1b3bbd788322ecb344 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 17 Oct 2007 13:26:42 -0700 Subject: sky2: shutdown cleanup Solve issues with dual port devices due to shared NAPI. * shutting down one device shouldn't kill other one. * suspend shouldn't hang. Also fix potential race between restart and shutdown. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 7967240534d..6b2fc508fe0 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -1384,13 +1384,9 @@ static int sky2_up(struct net_device *dev) sky2_prefetch_init(hw, txqaddr[port], sky2->tx_le_map, TX_RING_SIZE - 1); - napi_enable(&hw->napi); - err = sky2_rx_start(sky2); - if (err) { - napi_disable(&hw->napi); + if (err) goto err_out; - } /* Enable interrupts from phy/mac for port */ imask = sky2_read32(hw, B0_IMSK); @@ -1679,13 +1675,13 @@ static int sky2_down(struct net_device *dev) /* Stop more packets from being queued */ netif_stop_queue(dev); - napi_disable(&hw->napi); - /* Disable port IRQ */ imask = sky2_read32(hw, B0_IMSK); imask &= ~portirq_msk[port]; sky2_write32(hw, B0_IMSK, imask); + synchronize_irq(hw->pdev->irq); + sky2_gmac_reset(hw, port); /* Stop transmitter */ @@ -1699,6 +1695,9 @@ static int sky2_down(struct net_device *dev) ctrl &= ~(GM_GPCR_TX_ENA | GM_GPCR_RX_ENA); gma_write16(hw, port, GM_GP_CTRL, ctrl); + /* Make sure no packets are pending */ + napi_synchronize(&hw->napi); + sky2_write8(hw, SK_REG(port, GPHY_CTRL), GPC_RST_SET); /* Workaround shared GMAC reset */ @@ -1736,8 +1735,6 @@ static int sky2_down(struct net_device *dev) /* turn off LED's */ sky2_write16(hw, B0_Y2LED, LED_STAT_OFF); - synchronize_irq(hw->pdev->irq); - sky2_tx_clean(dev); sky2_rx_clean(sky2); @@ -2048,9 +2045,6 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu) err = sky2_rx_start(sky2); sky2_write32(hw, B0_IMSK, imask); - /* Unconditionally re-enable NAPI because even if we - * call dev_close() that will do a napi_disable(). - */ napi_enable(&hw->napi); if (err) @@ -2915,6 +2909,7 @@ static void sky2_restart(struct work_struct *work) rtnl_lock(); sky2_write32(hw, B0_IMSK, 0); sky2_read32(hw, B0_IMSK); + napi_disable(&hw->napi); for (i = 0; i < hw->ports; i++) { dev = hw->dev[i]; @@ -2924,6 +2919,7 @@ static void sky2_restart(struct work_struct *work) sky2_reset(hw); sky2_write32(hw, B0_IMSK, Y2_IS_BASE); + napi_enable(&hw->napi); for (i = 0; i < hw->ports; i++) { dev = hw->dev[i]; @@ -4191,7 +4187,6 @@ static int __devinit sky2_probe(struct pci_dev *pdev, err = -ENOMEM; goto err_out_free_pci; } - netif_napi_add(dev, &hw->napi, sky2_poll, NAPI_WEIGHT); if (!disable_msi && pci_enable_msi(pdev) == 0) { err = sky2_test_msi(hw); @@ -4207,6 +4202,8 @@ static int __devinit sky2_probe(struct pci_dev *pdev, goto err_out_free_netdev; } + netif_napi_add(dev, &hw->napi, sky2_poll, NAPI_WEIGHT); + err = request_irq(pdev->irq, sky2_intr, (hw->flags & SKY2_HW_USE_MSI) ? 0 : IRQF_SHARED, dev->name, hw); @@ -4215,6 +4212,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev, goto err_out_unregister; } sky2_write32(hw, B0_IMSK, Y2_IS_BASE); + napi_enable(&hw->napi); sky2_show_addr(dev); @@ -4265,23 +4263,18 @@ err_out: static void __devexit sky2_remove(struct pci_dev *pdev) { struct sky2_hw *hw = pci_get_drvdata(pdev); - struct net_device *dev0, *dev1; + int i; if (!hw) return; del_timer_sync(&hw->watchdog_timer); + cancel_work_sync(&hw->restart_work); - flush_scheduled_work(); + for (i = hw->ports; i >= 0; --i) + unregister_netdev(hw->dev[i]); sky2_write32(hw, B0_IMSK, 0); - synchronize_irq(hw->pdev->irq); - - dev0 = hw->dev[0]; - dev1 = hw->dev[1]; - if (dev1) - unregister_netdev(dev1); - unregister_netdev(dev0); sky2_power_aux(hw); @@ -4296,9 +4289,9 @@ static void __devexit sky2_remove(struct pci_dev *pdev) pci_release_regions(pdev); pci_disable_device(pdev); - if (dev1) - free_netdev(dev1); - free_netdev(dev0); + for (i = hw->ports; i >= 0; --i) + free_netdev(hw->dev[i]); + iounmap(hw->regs); kfree(hw); @@ -4328,6 +4321,7 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state) } sky2_write32(hw, B0_IMSK, 0); + napi_disable(&hw->napi); sky2_power_aux(hw); pci_save_state(pdev); @@ -4362,8 +4356,8 @@ static int sky2_resume(struct pci_dev *pdev) pci_write_config_dword(pdev, PCI_DEV_REG3, 0); sky2_reset(hw); - sky2_write32(hw, B0_IMSK, Y2_IS_BASE); + napi_enable(&hw->napi); for (i = 0; i < hw->ports; i++) { struct net_device *dev = hw->dev[i]; -- cgit v1.2.3 From e30d42273bfa907dc06920c53fa3f303783e1e97 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Thu, 18 Oct 2007 09:14:03 +1000 Subject: fix EMAC driver for proper napi_synchronize API The EMAC driver "fix" was merged by mistake before the dust had settled on the new napi synchronize interface (and before it got merged). The final version of that function is spelled without underscores. Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Jeff Garzik --- drivers/net/ibm_newemac/mal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ibm_newemac/mal.c b/drivers/net/ibm_newemac/mal.c index a680eb05ba6..9a88f71db00 100644 --- a/drivers/net/ibm_newemac/mal.c +++ b/drivers/net/ibm_newemac/mal.c @@ -322,7 +322,7 @@ void mal_poll_disable(struct mal_instance *mal, struct mal_commac *commac) msleep(1); /* Synchronize with the MAL NAPI poller */ - __napi_synchronize(&mal->napi); + napi_synchronize(&mal->napi); } void mal_poll_enable(struct mal_instance *mal, struct mal_commac *commac) -- cgit v1.2.3 From feff348fc0fe06870a8ec05e78af8ed5cc4c2bdf Mon Sep 17 00:00:00 2001 From: Don Fry Date: Wed, 17 Oct 2007 15:59:22 -0700 Subject: pcnet32: fix non-napi packet reception Recent changes to the driver for the new napi API broke the reception of packets when in non-napi mode. The initialization of napi.weight was removed for the non-napi case leaving the value zero. Tested NAPI and non-NAPI on x86_64. Signed-off-by: Don Fry Signed-off-by: Jeff Garzik --- drivers/net/pcnet32.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c index 5f994b5beda..159a64586d0 100644 --- a/drivers/net/pcnet32.c +++ b/drivers/net/pcnet32.c @@ -1849,6 +1849,9 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) lp->mii_if.mdio_read = mdio_read; lp->mii_if.mdio_write = mdio_write; + /* napi.weight is used in both the napi and non-napi cases */ + lp->napi.weight = lp->rx_ring_size / 2; + #ifdef CONFIG_PCNET32_NAPI netif_napi_add(dev, &lp->napi, pcnet32_poll, lp->rx_ring_size / 2); #endif -- cgit v1.2.3 From 6ad6c75626cf8b69cd28ae0a81227503a7c3966e Mon Sep 17 00:00:00 2001 From: Don Fry Date: Wed, 17 Oct 2007 16:10:10 -0700 Subject: pcnet32: remove compile warnings in non-napi mode Remove compile warning when in non-napi mode. Signed-off-by: Don Fry Signed-off-by: Jeff Garzik --- drivers/net/pcnet32.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c index 159a64586d0..7f7feaaf53d 100644 --- a/drivers/net/pcnet32.c +++ b/drivers/net/pcnet32.c @@ -442,7 +442,9 @@ static struct pcnet32_access pcnet32_dwio = { static void pcnet32_netif_stop(struct net_device *dev) { +#ifdef CONFIG_PCNET32_NAPI struct pcnet32_private *lp = netdev_priv(dev); +#endif dev->trans_start = jiffies; #ifdef CONFIG_PCNET32_NAPI napi_disable(&lp->napi); @@ -452,7 +454,9 @@ static void pcnet32_netif_stop(struct net_device *dev) static void pcnet32_netif_start(struct net_device *dev) { +#ifdef CONFIG_PCNET32_NAPI struct pcnet32_private *lp = netdev_priv(dev); +#endif netif_wake_queue(dev); #ifdef CONFIG_PCNET32_NAPI napi_enable(&lp->napi); -- cgit v1.2.3 From 0280f9f90b4c53e23f8ca98e581eb02f1a598a1a Mon Sep 17 00:00:00 2001 From: Badari Pulavarty Date: Wed, 17 Oct 2007 16:15:56 -0700 Subject: vortex_up should initialize "err" Simple compile warning fix. (against 2.6.23-git12) Thanks, Badari vortex_up() should initialize 'err' for a successful return. drivers/net/3c59x.c: In function `vortex_up': drivers/net/3c59x.c:1494: warning: `err' might be used uninitialized in this function Signed-off-by: Badari Pulavarty Signed-off-by: Jeff Garzik --- drivers/net/3c59x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c index 862f47223fd..6f8e7d4cf74 100644 --- a/drivers/net/3c59x.c +++ b/drivers/net/3c59x.c @@ -1491,7 +1491,7 @@ vortex_up(struct net_device *dev) struct vortex_private *vp = netdev_priv(dev); void __iomem *ioaddr = vp->ioaddr; unsigned int config; - int i, mii_reg1, mii_reg5, err; + int i, mii_reg1, mii_reg5, err = 0; if (VORTEX_PCI(vp)) { pci_set_power_state(VORTEX_PCI(vp), PCI_D0); /* Go active */ -- cgit v1.2.3 From 4f1e5ba0977570b7a198bb3ac110ccc5f532821b Mon Sep 17 00:00:00 2001 From: Don Fry Date: Wed, 17 Oct 2007 17:06:19 -0700 Subject: pcnet32: remove private net_device_stats structure Remove the statistics from the private structure. Use the net_device_stats in netn_device structure. Following Jeff Garzik's massive cleanup Sep 01. pcnet32 was not "low-hanging fruit". Tested x86_64. Signed-off-by: Don Fry Signed-off-by: Jeff Garzik --- drivers/net/pcnet32.c | 51 +++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c index 7f7feaaf53d..ff92aca0a7b 100644 --- a/drivers/net/pcnet32.c +++ b/drivers/net/pcnet32.c @@ -282,7 +282,6 @@ struct pcnet32_private { struct net_device *dev; struct napi_struct napi; - struct net_device_stats stats; char tx_full; char phycount; /* number of phys found */ int options; @@ -1182,15 +1181,15 @@ static void pcnet32_rx_entry(struct net_device *dev, * buffers, with only the last correctly noting the error. */ if (status & 0x01) /* Only count a general error at the */ - lp->stats.rx_errors++; /* end of a packet. */ + dev->stats.rx_errors++; /* end of a packet. */ if (status & 0x20) - lp->stats.rx_frame_errors++; + dev->stats.rx_frame_errors++; if (status & 0x10) - lp->stats.rx_over_errors++; + dev->stats.rx_over_errors++; if (status & 0x08) - lp->stats.rx_crc_errors++; + dev->stats.rx_crc_errors++; if (status & 0x04) - lp->stats.rx_fifo_errors++; + dev->stats.rx_fifo_errors++; return; } @@ -1201,13 +1200,13 @@ static void pcnet32_rx_entry(struct net_device *dev, if (netif_msg_drv(lp)) printk(KERN_ERR "%s: Impossible packet size %d!\n", dev->name, pkt_len); - lp->stats.rx_errors++; + dev->stats.rx_errors++; return; } if (pkt_len < 60) { if (netif_msg_rx_err(lp)) printk(KERN_ERR "%s: Runt packet!\n", dev->name); - lp->stats.rx_errors++; + dev->stats.rx_errors++; return; } @@ -1241,7 +1240,7 @@ static void pcnet32_rx_entry(struct net_device *dev, printk(KERN_ERR "%s: Memory squeeze, dropping packet.\n", dev->name); - lp->stats.rx_dropped++; + dev->stats.rx_dropped++; return; } skb->dev = dev; @@ -1260,7 +1259,7 @@ static void pcnet32_rx_entry(struct net_device *dev, pkt_len, PCI_DMA_FROMDEVICE); } - lp->stats.rx_bytes += skb->len; + dev->stats.rx_bytes += skb->len; skb->protocol = eth_type_trans(skb, dev); #ifdef CONFIG_PCNET32_NAPI netif_receive_skb(skb); @@ -1268,7 +1267,7 @@ static void pcnet32_rx_entry(struct net_device *dev, netif_rx(skb); #endif dev->last_rx = jiffies; - lp->stats.rx_packets++; + dev->stats.rx_packets++; return; } @@ -1316,21 +1315,21 @@ static int pcnet32_tx(struct net_device *dev) if (status & 0x4000) { /* There was a major error, log it. */ int err_status = le32_to_cpu(lp->tx_ring[entry].misc); - lp->stats.tx_errors++; + dev->stats.tx_errors++; if (netif_msg_tx_err(lp)) printk(KERN_ERR "%s: Tx error status=%04x err_status=%08x\n", dev->name, status, err_status); if (err_status & 0x04000000) - lp->stats.tx_aborted_errors++; + dev->stats.tx_aborted_errors++; if (err_status & 0x08000000) - lp->stats.tx_carrier_errors++; + dev->stats.tx_carrier_errors++; if (err_status & 0x10000000) - lp->stats.tx_window_errors++; + dev->stats.tx_window_errors++; #ifndef DO_DXSUFLO if (err_status & 0x40000000) { - lp->stats.tx_fifo_errors++; + dev->stats.tx_fifo_errors++; /* Ackk! On FIFO errors the Tx unit is turned off! */ /* Remove this verbosity later! */ if (netif_msg_tx_err(lp)) @@ -1341,7 +1340,7 @@ static int pcnet32_tx(struct net_device *dev) } #else if (err_status & 0x40000000) { - lp->stats.tx_fifo_errors++; + dev->stats.tx_fifo_errors++; if (!lp->dxsuflo) { /* If controller doesn't recover ... */ /* Ackk! On FIFO errors the Tx unit is turned off! */ /* Remove this verbosity later! */ @@ -1355,8 +1354,8 @@ static int pcnet32_tx(struct net_device *dev) #endif } else { if (status & 0x1800) - lp->stats.collisions++; - lp->stats.tx_packets++; + dev->stats.collisions++; + dev->stats.tx_packets++; } /* We must free the original skb */ @@ -2478,7 +2477,7 @@ static void pcnet32_tx_timeout(struct net_device *dev) "%s: transmit timed out, status %4.4x, resetting.\n", dev->name, lp->a.read_csr(ioaddr, CSR0)); lp->a.write_csr(ioaddr, CSR0, CSR0_STOP); - lp->stats.tx_errors++; + dev->stats.tx_errors++; if (netif_msg_tx_err(lp)) { int i; printk(KERN_DEBUG @@ -2548,7 +2547,7 @@ static int pcnet32_start_xmit(struct sk_buff *skb, struct net_device *dev) lp->tx_ring[entry].status = cpu_to_le16(status); lp->cur_tx++; - lp->stats.tx_bytes += skb->len; + dev->stats.tx_bytes += skb->len; /* Trigger an immediate send poll. */ lp->a.write_csr(ioaddr, CSR0, CSR0_INTEN | CSR0_TXPOLL); @@ -2593,7 +2592,7 @@ pcnet32_interrupt(int irq, void *dev_id) /* Log misc errors. */ if (csr0 & 0x4000) - lp->stats.tx_errors++; /* Tx babble. */ + dev->stats.tx_errors++; /* Tx babble. */ if (csr0 & 0x1000) { /* * This happens when our receive ring is full. This @@ -2606,7 +2605,7 @@ pcnet32_interrupt(int irq, void *dev_id) * don't get a rx interrupt, but a missed frame * interrupt sooner or later. */ - lp->stats.rx_errors++; /* Missed a Rx frame. */ + dev->stats.rx_errors++; /* Missed a Rx frame. */ } if (csr0 & 0x0800) { if (netif_msg_drv(lp)) @@ -2668,7 +2667,7 @@ static int pcnet32_close(struct net_device *dev) spin_lock_irqsave(&lp->lock, flags); - lp->stats.rx_missed_errors = lp->a.read_csr(ioaddr, 112); + dev->stats.rx_missed_errors = lp->a.read_csr(ioaddr, 112); if (netif_msg_ifdown(lp)) printk(KERN_DEBUG @@ -2705,10 +2704,10 @@ static struct net_device_stats *pcnet32_get_stats(struct net_device *dev) unsigned long flags; spin_lock_irqsave(&lp->lock, flags); - lp->stats.rx_missed_errors = lp->a.read_csr(ioaddr, 112); + dev->stats.rx_missed_errors = lp->a.read_csr(ioaddr, 112); spin_unlock_irqrestore(&lp->lock, flags); - return &lp->stats; + return &dev->stats; } /* taken from the sunlance driver, which it took from the depca driver */ -- cgit v1.2.3