Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[sfrench/cifs-2.6.git] / drivers / net / ixgb / ixgb_main.c
index 991c8833e23c955f02cff9562c2973fbbfe1c205..d2fb88d5cda2773675e87de42d3dee6e0789e8f7 100644 (file)
@@ -37,8 +37,8 @@ static char ixgb_driver_string[] = "Intel(R) PRO/10GbE Network Driver";
 #define DRIVERNAPI "-NAPI"
 #endif
 #define DRV_VERSION            "1.0.126-k2"DRIVERNAPI
-char ixgb_driver_version[] = DRV_VERSION;
-static char ixgb_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
+const char ixgb_driver_version[] = DRV_VERSION;
+static const char ixgb_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
 
 /* ixgb_pci_tbl - PCI Device ID Table
  *
@@ -97,14 +97,13 @@ static irqreturn_t ixgb_intr(int irq, void *data);
 static boolean_t ixgb_clean_tx_irq(struct ixgb_adapter *adapter);
 
 #ifdef CONFIG_IXGB_NAPI
-static int ixgb_clean(struct net_device *netdev, int *budget);
+static int ixgb_clean(struct napi_struct *napi, int budget);
 static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter,
                                   int *work_done, int work_to_do);
 #else
 static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter);
 #endif
 static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter);
-void ixgb_set_ethtool_ops(struct net_device *netdev);
 static void ixgb_tx_timeout(struct net_device *dev);
 static void ixgb_tx_timeout_task(struct work_struct *work);
 static void ixgb_vlan_rx_register(struct net_device *netdev,
@@ -123,9 +122,6 @@ static pci_ers_result_t ixgb_io_error_detected (struct pci_dev *pdev,
 static pci_ers_result_t ixgb_io_slot_reset (struct pci_dev *pdev);
 static void ixgb_io_resume (struct pci_dev *pdev);
 
-/* Exported from other modules */
-extern void ixgb_check_options(struct ixgb_adapter *adapter);
-
 static struct pci_error_handlers ixgb_err_handler = {
        .error_detected = ixgb_io_error_detected,
        .slot_reset = ixgb_io_slot_reset,
@@ -288,7 +284,7 @@ ixgb_up(struct ixgb_adapter *adapter)
        mod_timer(&adapter->watchdog_timer, jiffies);
 
 #ifdef CONFIG_IXGB_NAPI
-       netif_poll_enable(netdev);
+       napi_enable(&adapter->napi);
 #endif
        ixgb_irq_enable(adapter);
 
@@ -309,7 +305,7 @@ ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog)
        if(kill_watchdog)
                del_timer_sync(&adapter->watchdog_timer);
 #ifdef CONFIG_IXGB_NAPI
-       netif_poll_disable(netdev);
+       napi_disable(&adapter->napi);
 #endif
        adapter->link_speed = 0;
        adapter->link_duplex = 0;
@@ -324,10 +320,22 @@ ixgb_down(struct ixgb_adapter *adapter, boolean_t kill_watchdog)
 void
 ixgb_reset(struct ixgb_adapter *adapter)
 {
+       struct ixgb_hw *hw = &adapter->hw;
 
-       ixgb_adapter_stop(&adapter->hw);
-       if(!ixgb_init_hw(&adapter->hw))
+       ixgb_adapter_stop(hw);
+       if (!ixgb_init_hw(hw))
                DPRINTK(PROBE, ERR, "ixgb_init_hw failed.\n");
+
+       /* restore frame size information */
+       IXGB_WRITE_REG(hw, MFS, hw->max_frame_size << IXGB_MFS_SHIFT);
+       if (hw->max_frame_size >
+           IXGB_MAX_ENET_FRAME_SIZE_WITHOUT_FCS + ENET_FCS_LENGTH) {
+               u32 ctrl0 = IXGB_READ_REG(hw, CTRL0);
+               if (!(ctrl0 & IXGB_CTRL0_JFE)) {
+                       ctrl0 |= IXGB_CTRL0_JFE;
+                       IXGB_WRITE_REG(hw, CTRL0, ctrl0);
+               }
+       }
 }
 
 /**
@@ -382,7 +390,6 @@ ixgb_probe(struct pci_dev *pdev,
                goto err_alloc_etherdev;
        }
 
-       SET_MODULE_OWNER(netdev);
        SET_NETDEV_DEV(netdev, &pdev->dev);
 
        pci_set_drvdata(pdev, netdev);
@@ -421,8 +428,7 @@ ixgb_probe(struct pci_dev *pdev,
        netdev->tx_timeout = &ixgb_tx_timeout;
        netdev->watchdog_timeo = 5 * HZ;
 #ifdef CONFIG_IXGB_NAPI
-       netdev->poll = &ixgb_clean;
-       netdev->weight = 64;
+       netif_napi_add(netdev, &adapter->napi, ixgb_clean, 64);
 #endif
        netdev->vlan_rx_register = ixgb_vlan_rx_register;
        netdev->vlan_rx_add_vid = ixgb_vlan_rx_add_vid;
@@ -1087,7 +1093,8 @@ ixgb_set_multi(struct net_device *netdev)
                rctl |= IXGB_RCTL_MPE;
                IXGB_WRITE_REG(hw, RCTL, rctl);
        } else {
-               uint8_t mta[netdev->mc_count * IXGB_ETH_LENGTH_OF_ADDRESS];
+               uint8_t mta[IXGB_MAX_NUM_MULTICAST_ADDRESSES *
+                           IXGB_ETH_LENGTH_OF_ADDRESS];
 
                IXGB_WRITE_REG(hw, RCTL, rctl);
 
@@ -1326,8 +1333,8 @@ ixgb_tx_map(struct ixgb_adapter *adapter, struct sk_buff *skb,
 
                        /* Workaround for premature desc write-backs
                         * in TSO mode.  Append 4-byte sentinel desc */
-                       if (unlikely(mss && !nr_frags && size == len
-                                    && size > 8))
+                       if (unlikely(mss && (f == (nr_frags - 1))
+                                    && size == len && size > 8))
                                size -= 4;
 
                        buffer_info->length = size;
@@ -1746,7 +1753,7 @@ ixgb_intr(int irq, void *data)
        }
 
 #ifdef CONFIG_IXGB_NAPI
-       if(netif_rx_schedule_prep(netdev)) {
+       if (netif_rx_schedule_prep(netdev, &adapter->napi)) {
 
                /* Disable interrupts and register for poll. The flush 
                  of the posted write is intentionally left out.
@@ -1754,7 +1761,7 @@ ixgb_intr(int irq, void *data)
 
                atomic_inc(&adapter->irq_sem);
                IXGB_WRITE_REG(&adapter->hw, IMC, ~0);
-               __netif_rx_schedule(netdev);
+               __netif_rx_schedule(netdev, &adapter->napi);
        }
 #else
        /* yes, that is actually a & and it is meant to make sure that
@@ -1776,27 +1783,22 @@ ixgb_intr(int irq, void *data)
  **/
 
 static int
-ixgb_clean(struct net_device *netdev, int *budget)
+ixgb_clean(struct napi_struct *napi, int budget)
 {
-       struct ixgb_adapter *adapter = netdev_priv(netdev);
-       int work_to_do = min(*budget, netdev->quota);
-       int tx_cleaned;
+       struct ixgb_adapter *adapter = container_of(napi, struct ixgb_adapter, napi);
+       struct net_device *netdev = adapter->netdev;
        int work_done = 0;
 
-       tx_cleaned = ixgb_clean_tx_irq(adapter);
-       ixgb_clean_rx_irq(adapter, &work_done, work_to_do);
+       ixgb_clean_tx_irq(adapter);
+       ixgb_clean_rx_irq(adapter, &work_done, budget);
 
-       *budget -= work_done;
-       netdev->quota -= work_done;
-
-       /* if no Tx and not enough Rx work done, exit the polling mode */
-       if((!tx_cleaned && (work_done == 0)) || !netif_running(netdev)) {
-               netif_rx_complete(netdev);
+       /* If budget not fully consumed, exit the polling mode */
+       if (work_done < budget) {
+               netif_rx_complete(netdev, napi);
                ixgb_irq_enable(adapter);
-               return 0;
        }
 
-       return 1;
+       return work_done;
 }
 #endif