]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/netxen/netxen_nic_main.c
[ETHTOOL] Provide default behaviors for a few ethtool sub-ioctls
[linux-2.6-omap-h63xx.git] / drivers / net / netxen / netxen_nic_main.c
index 08a62acde8bf0e991c91706c53fa87fdb8c475d2..1b165a8c74f3a6a72b9d6979e9732eb4d13cd40f 100644 (file)
@@ -39,7 +39,6 @@
 #include "netxen_nic_phan_reg.h"
 
 #include <linux/dma-mapping.h>
-#include <linux/vmalloc.h>
 #include <net/ip.h>
 
 MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver");
@@ -68,7 +67,7 @@ static void netxen_tx_timeout(struct net_device *netdev);
 static void netxen_tx_timeout_task(struct work_struct *work);
 static void netxen_watchdog(unsigned long);
 static int netxen_handle_int(struct netxen_adapter *, struct net_device *);
-static int netxen_nic_poll(struct net_device *dev, int *budget);
+static int netxen_nic_poll(struct napi_struct *napi, int budget);
 #ifdef CONFIG_NET_POLL_CONTROLLER
 static void netxen_nic_poll_controller(struct net_device *netdev);
 #endif
@@ -326,11 +325,9 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                goto err_out_free_res;
        }
 
-       SET_MODULE_OWNER(netdev);
        SET_NETDEV_DEV(netdev, &pdev->dev);
 
        adapter = netdev->priv;
-       memset(adapter, 0 , sizeof(struct netxen_adapter));
 
        adapter->ahw.pdev = pdev;
        adapter->ahw.pci_func  = pci_func_id;
@@ -402,6 +399,9 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        adapter->netdev  = netdev;
        adapter->pdev    = pdev;
 
+       netif_napi_add(netdev, &adapter->napi,
+                      netxen_nic_poll, NETXEN_NETDEV_WEIGHT);
+
        /* this will be read from FW later */
        adapter->intr_scheme = -1;
 
@@ -422,8 +422,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        netxen_nic_change_mtu(netdev, netdev->mtu);
 
        SET_ETHTOOL_OPS(netdev, &netxen_nic_ethtool_ops);
-       netdev->poll = netxen_nic_poll;
-       netdev->weight = NETXEN_NETDEV_WEIGHT;
 #ifdef CONFIG_NET_POLL_CONTROLLER
        netdev->poll_controller = netxen_nic_poll_controller;
 #endif
@@ -639,10 +637,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                        NETXEN_CRB_NORMALIZE(adapter,
                                NETXEN_ROMUSB_GLB_PEGTUNE_DONE));
                /* Handshake with the card before we register the devices. */
-               writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
-               netxen_pinit_from_rom(adapter, 0);
-               msleep(1);
-               netxen_load_firmware(adapter);
                netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
        }
 
@@ -750,9 +744,6 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
 
        netxen_nic_disable_int(adapter);
 
-       if (adapter->irq)
-               free_irq(adapter->irq, adapter);
-
        if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) {
                init_firmware_done++;
                netxen_free_hw_resources(adapter);
@@ -776,13 +767,8 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
                }
        }
 
-       if (adapter->flags & NETXEN_NIC_MSI_ENABLED)
-               pci_disable_msi(pdev);
-
        vfree(adapter->cmd_buf_arr);
 
-       pci_disable_device(pdev);
-
        if (adapter->portnum == 0) {
                if (init_firmware_done) {
                        i = 100;
@@ -833,12 +819,19 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
                }
        }
 
+       if (adapter->irq)
+               free_irq(adapter->irq, adapter);
+
+       if (adapter->flags & NETXEN_NIC_MSI_ENABLED)
+               pci_disable_msi(pdev);
+
        iounmap(adapter->ahw.db_base);
        iounmap(adapter->ahw.pci_base0);
        iounmap(adapter->ahw.pci_base1);
        iounmap(adapter->ahw.pci_base2);
 
        pci_release_regions(pdev);
+       pci_disable_device(pdev);
        pci_set_drvdata(pdev, NULL);
 
        free_netdev(netdev);
@@ -890,6 +883,8 @@ static int netxen_nic_open(struct net_device *netdev)
        if (!adapter->driver_mismatch)
                mod_timer(&adapter->watchdog_timer, jiffies);
 
+       napi_enable(&adapter->napi);
+
        netxen_nic_enable_int(adapter);
 
        /* Done here again so that even if phantom sw overwrote it,
@@ -899,6 +894,7 @@ static int netxen_nic_open(struct net_device *netdev)
            del_timer_sync(&adapter->watchdog_timer);
                printk(KERN_ERR "%s: Failed to initialize port %d\n",
                                netxen_nic_driver_name, adapter->portnum);
+               napi_disable(&adapter->napi);
                return -EIO;
        }
        if (adapter->macaddr_set)
@@ -928,6 +924,7 @@ static int netxen_nic_close(struct net_device *netdev)
 
        netif_carrier_off(netdev);
        netif_stop_queue(netdev);
+       napi_disable(&adapter->napi);
 
        netxen_nic_disable_int(adapter);
 
@@ -1248,11 +1245,11 @@ netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev)
        netxen_nic_disable_int(adapter);
 
        if (netxen_nic_rx_has_work(adapter) || netxen_nic_tx_has_work(adapter)) {
-               if (netif_rx_schedule_prep(netdev)) {
+               if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
                        /*
                         * Interrupts are already disabled.
                         */
-                       __netif_rx_schedule(netdev);
+                       __netif_rx_schedule(netdev, &adapter->napi);
                } else {
                        static unsigned int intcount = 0;
                        if ((++intcount & 0xfff) == 0xfff)
@@ -1310,14 +1307,13 @@ irqreturn_t netxen_intr(int irq, void *data)
        return IRQ_HANDLED;
 }
 
-static int netxen_nic_poll(struct net_device *netdev, int *budget)
+static int netxen_nic_poll(struct napi_struct *napi, int budget)
 {
-       struct netxen_adapter *adapter = netdev_priv(netdev);
-       int work_to_do = min(*budget, netdev->quota);
+       struct netxen_adapter *adapter = container_of(napi, struct netxen_adapter, napi);
+       struct net_device *netdev = adapter->netdev;
        int done = 1;
        int ctx;
-       int this_work_done;
-       int work_done = 0;
+       int work_done;
 
        DPRINTK(INFO, "polling for %d descriptors\n", *budget);
 
@@ -1335,16 +1331,11 @@ static int netxen_nic_poll(struct net_device *netdev, int *budget)
                 * packets are on one context, it gets only half of the quota,
                 * and ends up not processing it.
                 */
-               this_work_done = netxen_process_rcv_ring(adapter, ctx,
-                                                        work_to_do /
-                                                        MAX_RCV_CTX);
-               work_done += this_work_done;
+               work_done += netxen_process_rcv_ring(adapter, ctx,
+                                                    budget / MAX_RCV_CTX);
        }
 
-       netdev->quota -= work_done;
-       *budget -= work_done;
-
-       if (work_done >= work_to_do && netxen_nic_rx_has_work(adapter) != 0)
+       if (work_done >= budget && netxen_nic_rx_has_work(adapter) != 0)
                done = 0;
 
        if (netxen_process_cmd_ring((unsigned long)adapter) == 0)
@@ -1353,11 +1344,11 @@ static int netxen_nic_poll(struct net_device *netdev, int *budget)
        DPRINTK(INFO, "new work_done: %d work_to_do: %d\n",
                work_done, work_to_do);
        if (done) {
-               netif_rx_complete(netdev);
+               netif_rx_complete(netdev, napi);
                netxen_nic_enable_int(adapter);
        }
 
-       return !done;
+       return work_done;
 }
 
 #ifdef CONFIG_NET_POLL_CONTROLLER