]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/bnx2.c
[NET]: Introduce and use print_mac() and DECLARE_MAC_BUF()
[linux-2.6-omap-h63xx.git] / drivers / net / bnx2.c
index a729da061bbb649ab51ee0d53775f2a536f049fc..ee9aed3aa4899f14a0b985512b679b297464ec53 100644 (file)
@@ -54,8 +54,8 @@
 
 #define DRV_MODULE_NAME                "bnx2"
 #define PFX DRV_MODULE_NAME    ": "
-#define DRV_MODULE_VERSION     "1.6.3"
-#define DRV_MODULE_RELDATE     "July 16, 2007"
+#define DRV_MODULE_VERSION     "1.6.5"
+#define DRV_MODULE_RELDATE     "September 20, 2007"
 
 #define RUN_AT(x) (jiffies + (x))
 
@@ -428,7 +428,7 @@ bnx2_netif_stop(struct bnx2 *bp)
 {
        bnx2_disable_int_sync(bp);
        if (netif_running(bp->dev)) {
-               netif_poll_disable(bp->dev);
+               napi_disable(&bp->napi);
                netif_tx_disable(bp->dev);
                bp->dev->trans_start = jiffies; /* prevent tx timeout */
        }
@@ -440,7 +440,7 @@ bnx2_netif_start(struct bnx2 *bp)
        if (atomic_dec_and_test(&bp->intr_sem)) {
                if (netif_running(bp->dev)) {
                        netif_wake_queue(bp->dev);
-                       netif_poll_enable(bp->dev);
+                       napi_enable(&bp->napi);
                        bnx2_enable_int(bp);
                }
        }
@@ -2551,7 +2551,7 @@ bnx2_msi(int irq, void *dev_instance)
        if (unlikely(atomic_read(&bp->intr_sem) != 0))
                return IRQ_HANDLED;
 
-       netif_rx_schedule(dev);
+       netif_rx_schedule(dev, &bp->napi);
 
        return IRQ_HANDLED;
 }
@@ -2568,7 +2568,7 @@ bnx2_msi_1shot(int irq, void *dev_instance)
        if (unlikely(atomic_read(&bp->intr_sem) != 0))
                return IRQ_HANDLED;
 
-       netif_rx_schedule(dev);
+       netif_rx_schedule(dev, &bp->napi);
 
        return IRQ_HANDLED;
 }
@@ -2604,9 +2604,9 @@ bnx2_interrupt(int irq, void *dev_instance)
        if (unlikely(atomic_read(&bp->intr_sem) != 0))
                return IRQ_HANDLED;
 
-       if (netif_rx_schedule_prep(dev)) {
+       if (netif_rx_schedule_prep(dev, &bp->napi)) {
                bp->last_status_idx = sblk->status_idx;
-               __netif_rx_schedule(dev);
+               __netif_rx_schedule(dev, &bp->napi);
        }
 
        return IRQ_HANDLED;
@@ -2632,12 +2632,14 @@ bnx2_has_work(struct bnx2 *bp)
 }
 
 static int
-bnx2_poll(struct net_device *dev, int *budget)
+bnx2_poll(struct napi_struct *napi, int budget)
 {
-       struct bnx2 *bp = netdev_priv(dev);
+       struct bnx2 *bp = container_of(napi, struct bnx2, napi);
+       struct net_device *dev = bp->dev;
        struct status_block *sblk = bp->status_blk;
        u32 status_attn_bits = sblk->status_attn_bits;
        u32 status_attn_bits_ack = sblk->status_attn_bits_ack;
+       int work_done = 0;
 
        if ((status_attn_bits & STATUS_ATTN_EVENTS) !=
            (status_attn_bits_ack & STATUS_ATTN_EVENTS)) {
@@ -2655,23 +2657,14 @@ bnx2_poll(struct net_device *dev, int *budget)
        if (bp->status_blk->status_tx_quick_consumer_index0 != bp->hw_tx_cons)
                bnx2_tx_int(bp);
 
-       if (bp->status_blk->status_rx_quick_consumer_index0 != bp->hw_rx_cons) {
-               int orig_budget = *budget;
-               int work_done;
-
-               if (orig_budget > dev->quota)
-                       orig_budget = dev->quota;
-
-               work_done = bnx2_rx_int(bp, orig_budget);
-               *budget -= work_done;
-               dev->quota -= work_done;
-       }
+       if (bp->status_blk->status_rx_quick_consumer_index0 != bp->hw_rx_cons)
+               work_done = bnx2_rx_int(bp, budget);
 
        bp->last_status_idx = bp->status_blk->status_idx;
        rmb();
 
        if (!bnx2_has_work(bp)) {
-               netif_rx_complete(dev);
+               netif_rx_complete(dev, napi);
                if (likely(bp->flags & USING_MSI_FLAG)) {
                        REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
                               BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID |
@@ -2686,10 +2679,9 @@ bnx2_poll(struct net_device *dev, int *budget)
                REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
                       BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID |
                       bp->last_status_idx);
-               return 0;
        }
 
-       return 1;
+       return work_done;
 }
 
 /* Called with rtnl_lock from vlan functions and also netif_tx_lock
@@ -3500,7 +3492,7 @@ bnx2_init_nvram(struct bnx2 *bp)
        /* Determine the selected interface. */
        val = REG_RD(bp, BNX2_NVM_CFG1);
 
-       entry_count = sizeof(flash_table) / sizeof(struct flash_spec);
+       entry_count = ARRAY_SIZE(flash_table);
 
        if (val & 0x40000000) {
 
@@ -3934,11 +3926,13 @@ bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
                /* Chip reset. */
                REG_WR(bp, BNX2_PCICFG_MISC_CONFIG, val);
 
+               /* Reading back any register after chip reset will hang the
+                * bus on 5706 A0 and A1.  The msleep below provides plenty
+                * of margin for write posting.
+                */
                if ((CHIP_ID(bp) == CHIP_ID_5706_A0) ||
-                   (CHIP_ID(bp) == CHIP_ID_5706_A1)) {
-                       current->state = TASK_UNINTERRUPTIBLE;
-                       schedule_timeout(HZ / 50);
-               }
+                   (CHIP_ID(bp) == CHIP_ID_5706_A1))
+                       msleep(20);
 
                /* Reset takes approximate 30 usec */
                for (i = 0; i < 10; i++) {
@@ -5037,6 +5031,8 @@ bnx2_open(struct net_device *dev)
        if (rc)
                return rc;
 
+       napi_enable(&bp->napi);
+
        if ((bp->flags & MSI_CAP_FLAG) && !disable_msi) {
                if (pci_enable_msi(bp->pdev) == 0) {
                        bp->flags |= USING_MSI_FLAG;
@@ -5047,6 +5043,7 @@ bnx2_open(struct net_device *dev)
        rc = bnx2_request_irq(bp);
 
        if (rc) {
+               napi_disable(&bp->napi);
                bnx2_free_mem(bp);
                return rc;
        }
@@ -5054,6 +5051,7 @@ bnx2_open(struct net_device *dev)
        rc = bnx2_init_nic(bp);
 
        if (rc) {
+               napi_disable(&bp->napi);
                bnx2_free_irq(bp);
                bnx2_free_skbs(bp);
                bnx2_free_mem(bp);
@@ -5086,6 +5084,7 @@ bnx2_open(struct net_device *dev)
                                rc = bnx2_request_irq(bp);
 
                        if (rc) {
+                               napi_disable(&bp->napi);
                                bnx2_free_skbs(bp);
                                bnx2_free_mem(bp);
                                del_timer_sync(&bp->timer);
@@ -5299,7 +5298,8 @@ bnx2_close(struct net_device *dev)
        while (bp->in_reset_task)
                msleep(1);
 
-       bnx2_netif_stop(bp);
+       bnx2_disable_int_sync(bp);
+       napi_disable(&bp->napi);
        del_timer_sync(&bp->timer);
        if (bp->flags & NO_WOL_FLAG)
                reset_code = BNX2_DRV_MSG_CODE_UNLOAD_LNK_DN;
@@ -6257,11 +6257,8 @@ static const struct ethtool_ops bnx2_ethtool_ops = {
        .set_pauseparam         = bnx2_set_pauseparam,
        .get_rx_csum            = bnx2_get_rx_csum,
        .set_rx_csum            = bnx2_set_rx_csum,
-       .get_tx_csum            = ethtool_op_get_tx_csum,
        .set_tx_csum            = bnx2_set_tx_csum,
-       .get_sg                 = ethtool_op_get_sg,
        .set_sg                 = ethtool_op_set_sg,
-       .get_tso                = ethtool_op_get_tso,
        .set_tso                = bnx2_set_tso,
        .self_test_count        = bnx2_self_test_count,
        .self_test              = bnx2_self_test,
@@ -6269,7 +6266,6 @@ static const struct ethtool_ops bnx2_ethtool_ops = {
        .phys_id                = bnx2_phys_id,
        .get_stats_count        = bnx2_get_stats_count,
        .get_ethtool_stats      = bnx2_get_ethtool_stats,
-       .get_perm_addr          = ethtool_op_get_perm_addr,
 };
 
 /* Called with rtnl_lock */
@@ -6475,7 +6471,6 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
        u32 reg;
        u64 dma_mask, persist_dma_mask;
 
-       SET_MODULE_OWNER(dev);
        SET_NETDEV_DEV(dev, &pdev->dev);
        bp = netdev_priv(dev);
 
@@ -6726,7 +6721,8 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
        } else if (CHIP_NUM(bp) == CHIP_NUM_5706 ||
                   CHIP_NUM(bp) == CHIP_NUM_5708)
                bp->phy_flags |= PHY_CRC_FIX_FLAG;
-       else if (CHIP_ID(bp) == CHIP_ID_5709_A0)
+       else if (CHIP_ID(bp) == CHIP_ID_5709_A0 ||
+                CHIP_ID(bp) == CHIP_ID_5709_A1)
                bp->phy_flags |= PHY_DIS_EARLY_DAC_FLAG;
 
        if ((CHIP_ID(bp) == CHIP_ID_5708_A0) ||
@@ -6825,8 +6821,9 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        static int version_printed = 0;
        struct net_device *dev = NULL;
        struct bnx2 *bp;
-       int rc, i;
+       int rc;
        char str[40];
+       DECLARE_MAC_BUF(mac);
 
        if (version_printed++ == 0)
                printk(KERN_INFO "%s", version);
@@ -6856,11 +6853,10 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 #ifdef BCM_VLAN
        dev->vlan_rx_register = bnx2_vlan_rx_register;
 #endif
-       dev->poll = bnx2_poll;
        dev->ethtool_ops = &bnx2_ethtool_ops;
-       dev->weight = 64;
 
        bp = netdev_priv(dev);
+       netif_napi_add(dev, &bp->napi, bnx2_poll, 64);
 
 #if defined(HAVE_POLL_CONTROLLER) || defined(CONFIG_NET_POLL_CONTROLLER)
        dev->poll_controller = poll_bnx2;
@@ -6895,19 +6891,14 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        }
 
        printk(KERN_INFO "%s: %s (%c%d) %s found at mem %lx, "
-               "IRQ %d, ",
+               "IRQ %d, node addr %s\n",
                dev->name,
                bp->name,
                ((CHIP_ID(bp) & 0xf000) >> 12) + 'A',
                ((CHIP_ID(bp) & 0x0ff0) >> 4),
                bnx2_bus_string(bp, str),
                dev->base_addr,
-               bp->pdev->irq);
-
-       printk("node addr ");
-       for (i = 0; i < 6; i++)
-               printk("%2.2x", dev->dev_addr[i]);
-       printk("\n");
+               bp->pdev->irq, print_mac(mac, dev->dev_addr));
 
        return 0;
 }
@@ -6938,6 +6929,11 @@ bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
        struct bnx2 *bp = netdev_priv(dev);
        u32 reset_code;
 
+       /* PCI register 4 needs to be saved whether netif_running() or not.
+        * MSI address and data need to be saved if using MSI and
+        * netif_running().
+        */
+       pci_save_state(pdev);
        if (!netif_running(dev))
                return 0;
 
@@ -6953,7 +6949,6 @@ bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
                reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
        bnx2_reset_chip(bp, reset_code);
        bnx2_free_skbs(bp);
-       pci_save_state(pdev);
        bnx2_set_power_state(bp, pci_choose_state(pdev, state));
        return 0;
 }
@@ -6964,10 +6959,10 @@ bnx2_resume(struct pci_dev *pdev)
        struct net_device *dev = pci_get_drvdata(pdev);
        struct bnx2 *bp = netdev_priv(dev);
 
+       pci_restore_state(pdev);
        if (!netif_running(dev))
                return 0;
 
-       pci_restore_state(pdev);
        bnx2_set_power_state(bp, PCI_D0);
        netif_device_attach(dev);
        bnx2_init_nic(bp);