[netdrvr] Stop using legacy hooks ->self_test_count, ->get_stats_count
[safe/jmp/linux-2.6] / drivers / net / cassini.c
index 59b9943..563bf5f 100644 (file)
@@ -2485,7 +2485,7 @@ static irqreturn_t cas_interruptN(int irq, void *dev_id)
        if (status & INTR_RX_DONE_ALT) { /* handle rx separately */
 #ifdef USE_NAPI
                cas_mask_intr(cp);
-               netif_rx_schedule(dev);
+               netif_rx_schedule(dev, &cp->napi);
 #else
                cas_rx_ringN(cp, ring, 0);
 #endif
@@ -2536,7 +2536,7 @@ static irqreturn_t cas_interrupt1(int irq, void *dev_id)
        if (status & INTR_RX_DONE_ALT) { /* handle rx separately */
 #ifdef USE_NAPI
                cas_mask_intr(cp);
-               netif_rx_schedule(dev);
+               netif_rx_schedule(dev, &cp->napi);
 #else
                cas_rx_ringN(cp, 1, 0);
 #endif
@@ -2592,7 +2592,7 @@ static irqreturn_t cas_interrupt(int irq, void *dev_id)
        if (status & INTR_RX_DONE) {
 #ifdef USE_NAPI
                cas_mask_intr(cp);
-               netif_rx_schedule(dev);
+               netif_rx_schedule(dev, &cp->napi);
 #else
                cas_rx_ringN(cp, 0, 0);
 #endif
@@ -2607,9 +2607,10 @@ static irqreturn_t cas_interrupt(int irq, void *dev_id)
 
 
 #ifdef USE_NAPI
-static int cas_poll(struct net_device *dev, int *budget)
+static int cas_poll(struct napi_struct *napi, int budget)
 {
-       struct cas *cp = netdev_priv(dev);
+       struct cas *cp = container_of(napi, struct cas, napi);
+       struct net_device *dev = cp->dev;
        int i, enable_intr, todo, credits;
        u32 status = readl(cp->regs + REG_INTR_STATUS);
        unsigned long flags;
@@ -2620,20 +2621,18 @@ static int cas_poll(struct net_device *dev, int *budget)
 
        /* NAPI rx packets. we spread the credits across all of the
         * rxc rings
-        */
-       todo = min(*budget, dev->quota);
-
-       /* to make sure we're fair with the work we loop through each
+        *
+        * to make sure we're fair with the work we loop through each
         * ring N_RX_COMP_RING times with a request of
-        * todo / N_RX_COMP_RINGS
+        * budget / N_RX_COMP_RINGS
         */
        enable_intr = 1;
        credits = 0;
        for (i = 0; i < N_RX_COMP_RINGS; i++) {
                int j;
                for (j = 0; j < N_RX_COMP_RINGS; j++) {
-                       credits += cas_rx_ringN(cp, j, todo / N_RX_COMP_RINGS);
-                       if (credits >= todo) {
+                       credits += cas_rx_ringN(cp, j, budget / N_RX_COMP_RINGS);
+                       if (credits >= budget) {
                                enable_intr = 0;
                                goto rx_comp;
                        }
@@ -2641,9 +2640,6 @@ static int cas_poll(struct net_device *dev, int *budget)
        }
 
 rx_comp:
-       *budget    -= credits;
-       dev->quota -= credits;
-
        /* final rx completion */
        spin_lock_irqsave(&cp->lock, flags);
        if (status)
@@ -2674,11 +2670,10 @@ rx_comp:
 #endif
        spin_unlock_irqrestore(&cp->lock, flags);
        if (enable_intr) {
-               netif_rx_complete(dev);
+               netif_rx_complete(dev, napi);
                cas_unmask_intr(cp);
-               return 0;
        }
-       return 1;
+       return credits;
 }
 #endif
 
@@ -3422,21 +3417,19 @@ done:
 static void cas_check_pci_invariants(struct cas *cp)
 {
        struct pci_dev *pdev = cp->pdev;
-       u8 rev;
 
        cp->cas_flags = 0;
-       pci_read_config_byte(pdev, PCI_REVISION_ID, &rev);
        if ((pdev->vendor == PCI_VENDOR_ID_SUN) &&
            (pdev->device == PCI_DEVICE_ID_SUN_CASSINI)) {
-               if (rev >= CAS_ID_REVPLUS)
+               if (pdev->revision >= CAS_ID_REVPLUS)
                        cp->cas_flags |= CAS_FLAG_REG_PLUS;
-               if (rev < CAS_ID_REVPLUS02u)
+               if (pdev->revision < CAS_ID_REVPLUS02u)
                        cp->cas_flags |= CAS_FLAG_TARGET_ABORT;
 
                /* Original Cassini supports HW CSUM, but it's not
                 * enabled by default as it can trigger TX hangs.
                 */
-               if (rev < CAS_ID_REV2)
+               if (pdev->revision < CAS_ID_REV2)
                        cp->cas_flags |= CAS_FLAG_NO_HW_CSUM;
        } else {
                /* Only sun has original cassini chips.  */
@@ -4353,6 +4346,9 @@ static int cas_open(struct net_device *dev)
                goto err_spare;
        }
 
+#ifdef USE_NAPI
+       napi_enable(&cp->napi);
+#endif
        /* init hw */
        cas_lock_all_save(cp, flags);
        cas_clean_rings(cp);
@@ -4378,6 +4374,9 @@ static int cas_close(struct net_device *dev)
        unsigned long flags;
        struct cas *cp = netdev_priv(dev);
 
+#ifdef USE_NAPI
+       napi_enable(&cp->napi);
+#endif
        /* Make sure we don't get distracted by suspend/resume */
        mutex_lock(&cp->pm_mutex);
 
@@ -4773,9 +4772,14 @@ static void cas_get_regs(struct net_device *dev, struct ethtool_regs *regs,
        cas_read_regs(cp, p, regs->len / sizeof(u32));
 }
 
-static int cas_get_stats_count(struct net_device *dev)
+static int cas_get_sset_count(struct net_device *dev, int sset)
 {
-       return CAS_NUM_STAT_KEYS;
+       switch (sset) {
+       case ETH_SS_STATS:
+               return CAS_NUM_STAT_KEYS;
+       default:
+               return -EOPNOTSUPP;
+       }
 }
 
 static void cas_get_strings(struct net_device *dev, u32 stringset, u8 *data)
@@ -4819,7 +4823,7 @@ static const struct ethtool_ops cas_ethtool_ops = {
        .set_msglevel           = cas_set_msglevel,
        .get_regs_len           = cas_get_regs_len,
        .get_regs               = cas_get_regs,
-       .get_stats_count        = cas_get_stats_count,
+       .get_sset_count         = cas_get_sset_count,
        .get_strings            = cas_get_strings,
        .get_ethtool_stats      = cas_get_ethtool_stats,
 };
@@ -4878,6 +4882,7 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
        int i, err, pci_using_dac;
        u16 pci_cmd;
        u8 orig_cacheline_size = 0, cas_cacheline_size = 0;
+       DECLARE_MAC_BUF(mac);
 
        if (cas_version_printed++ == 0)
                printk(KERN_INFO "%s", version);
@@ -4901,7 +4906,6 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
                err = -ENOMEM;
                goto err_out_disable_pdev;
        }
-       SET_MODULE_OWNER(dev);
        SET_NETDEV_DEV(dev, &pdev->dev);
 
        err = pci_request_regions(pdev, dev->name);
@@ -4919,13 +4923,13 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
        pci_cmd &= ~PCI_COMMAND_SERR;
        pci_cmd |= PCI_COMMAND_PARITY;
        pci_write_config_word(pdev, PCI_COMMAND, pci_cmd);
-       if (pci_set_mwi(pdev))
+       if (pci_try_set_mwi(pdev))
                printk(KERN_WARNING PFX "Could not enable MWI for %s\n",
                       pci_name(pdev));
 
        /*
         * On some architectures, the default cache line size set
-        * by pci_set_mwi reduces perforamnce.  We have to increase
+        * by pci_try_set_mwi reduces perforamnce.  We have to increase
         * it for this case.  To start, we'll print some configuration
         * data.
         */
@@ -5064,8 +5068,7 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
        dev->watchdog_timeo = CAS_TX_TIMEOUT;
        dev->change_mtu = cas_change_mtu;
 #ifdef USE_NAPI
-       dev->poll = cas_poll;
-       dev->weight = 64;
+       netif_napi_add(dev, &cp->napi, cas_poll, 64);
 #endif
 #ifdef CONFIG_NET_POLL_CONTROLLER
        dev->poll_controller = cas_netpoll;
@@ -5087,16 +5090,12 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
 
        i = readl(cp->regs + REG_BIM_CFG);
        printk(KERN_INFO "%s: Sun Cassini%s (%sbit/%sMHz PCI/%s) "
-              "Ethernet[%d] ",  dev->name,
+              "Ethernet[%d] %s\n",  dev->name,
               (cp->cas_flags & CAS_FLAG_REG_PLUS) ? "+" : "",
               (i & BIM_CFG_32BIT) ? "32" : "64",
               (i & BIM_CFG_66MHZ) ? "66" : "33",
-              (cp->phy_type == CAS_PHY_SERDES) ? "Fi" : "Cu", pdev->irq);
-
-       for (i = 0; i < 6; i++)
-               printk("%2.2x%c", dev->dev_addr[i],
-                      i == 5 ? ' ' : ':');
-       printk("\n");
+              (cp->phy_type == CAS_PHY_SERDES) ? "Fi" : "Cu", pdev->irq,
+              print_mac(mac, dev->dev_addr));
 
        pci_set_drvdata(pdev, dev);
        cp->hw_running = 1;