]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/cassini.c
[PATCH] libertas: use LBS_DEB_HOST for host-to-card communications
[linux-2.6-omap-h63xx.git] / drivers / net / cassini.c
index 4aec747d9e437a819f6e0127598a35a4f373a88d..13f14df21e6e080d4934f8d54e5f8dab00e48b2c 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);
 
@@ -4919,10 +4918,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);
-       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.
         */
@@ -5061,8 +5063,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;