e1000: Fix NAPI state bug when Rx complete
[powerpc.git] / drivers / net / e1000 / e1000_main.c
index 723568d..4f37506 100644 (file)
@@ -37,8 +37,8 @@ static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
 #define DRIVERNAPI "-NAPI"
 #endif
 #define DRV_VERSION "7.3.20-k2"DRIVERNAPI
-char e1000_driver_version[] = DRV_VERSION;
-static char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
+const char e1000_driver_version[] = DRV_VERSION;
+static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
 
 /* e1000_pci_tbl - PCI Device ID Table
  *
@@ -188,7 +188,6 @@ static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
 static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
 static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
                           int cmd);
-void e1000_set_ethtool_ops(struct net_device *netdev);
 static void e1000_enter_82542_rst(struct e1000_adapter *adapter);
 static void e1000_leave_82542_rst(struct e1000_adapter *adapter);
 static void e1000_tx_timeout(struct net_device *dev);
@@ -213,8 +212,6 @@ static void e1000_shutdown(struct pci_dev *pdev);
 static void e1000_netpoll (struct net_device *netdev);
 #endif
 
-extern void e1000_check_options(struct e1000_adapter *adapter);
-
 #define COPYBREAK_DEFAULT 256
 static unsigned int copybreak __read_mostly = COPYBREAK_DEFAULT;
 module_param(copybreak, uint, 0644);
@@ -872,6 +869,8 @@ e1000_probe(struct pci_dev *pdev,
        int i, err, pci_using_dac;
        uint16_t eeprom_data = 0;
        uint16_t eeprom_apme_mask = E1000_EEPROM_APME;
+       DECLARE_MAC_BUF(mac);
+
        if ((err = pci_enable_device(pdev)))
                return err;
 
@@ -897,7 +896,6 @@ e1000_probe(struct pci_dev *pdev,
        if (!netdev)
                goto err_alloc_etherdev;
 
-       SET_MODULE_OWNER(netdev);
        SET_NETDEV_DEV(netdev, &pdev->dev);
 
        pci_set_drvdata(pdev, netdev);
@@ -1133,8 +1131,7 @@ e1000_probe(struct pci_dev *pdev,
                 "32-bit"));
        }
 
-       for (i = 0; i < 6; i++)
-               printk("%2.2x%c", netdev->dev_addr[i], i == 5 ? '\n' : ':');
+       printk("%s\n", print_mac(mac, netdev->dev_addr));
 
        /* reset the hardware with the new settings */
        e1000_reset(adapter);
@@ -3261,14 +3258,13 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
        unsigned int first, max_per_txd = E1000_MAX_DATA_PER_TXD;
        unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
        unsigned int tx_flags = 0;
-       unsigned int len = skb->len;
+       unsigned int len = skb->len - skb->data_len;
        unsigned long flags;
-       unsigned int nr_frags = 0;
-       unsigned int mss = 0;
+       unsigned int nr_frags;
+       unsigned int mss;
        int count = 0;
        int tso;
        unsigned int f;
-       len -= skb->data_len;
 
        /* This goes back to the question of how to logically map a tx queue
         * to a flow.  Right now, performance is impacted slightly negatively
@@ -3302,7 +3298,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
                * points to just header, pull a few bytes of payload from
                * frags into skb->data */
                hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
-               if (skb->data_len && (hdr_len == (skb->len - skb->data_len))) {
+               if (skb->data_len && hdr_len == len) {
                        switch (adapter->hw.mac_type) {
                                unsigned int pull_size;
                        case e1000_82544:
@@ -3591,7 +3587,7 @@ e1000_update_stats(struct e1000_adapter *adapter)
 
        spin_lock_irqsave(&adapter->stats_lock, flags);
 
-       /* these counters are modified from e1000_adjust_tbi_stats,
+       /* these counters are modified from e1000_tbi_adjust_stats,
         * called from the interrupt context, so they must only
         * be written while holding adapter->stats_lock
         */
@@ -3946,7 +3942,7 @@ e1000_clean(struct napi_struct *napi, int budget)
                          &work_done, budget);
 
        /* If no Tx and not enough Rx work done, exit the polling mode */
-       if ((!tx_cleaned && (work_done < budget)) ||
+       if ((!tx_cleaned && (work_done == 0)) ||
           !netif_running(poll_dev)) {
 quit_polling:
                if (likely(adapter->itr_setting & 3))
@@ -4808,6 +4804,7 @@ e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
                        spin_unlock_irqrestore(&adapter->stats_lock, flags);
                        return -EIO;
                }
+               spin_unlock_irqrestore(&adapter->stats_lock, flags);
                if (adapter->hw.media_type == e1000_media_type_copper) {
                        switch (data->reg_num) {
                        case PHY_CTRL:
@@ -4828,12 +4825,8 @@ e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
                                                   DUPLEX_HALF;
                                        retval = e1000_set_spd_dplx(adapter,
                                                                    spddplx);
-                                       if (retval) {
-                                               spin_unlock_irqrestore(
-                                                       &adapter->stats_lock,
-                                                       flags);
+                                       if (retval)
                                                return retval;
-                                       }
                                }
                                if (netif_running(adapter->netdev))
                                        e1000_reinit_locked(adapter);
@@ -4842,11 +4835,8 @@ e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
                                break;
                        case M88E1000_PHY_SPEC_CTRL:
                        case M88E1000_EXT_PHY_SPEC_CTRL:
-                               if (e1000_phy_reset(&adapter->hw)) {
-                                       spin_unlock_irqrestore(
-                                               &adapter->stats_lock, flags);
+                               if (e1000_phy_reset(&adapter->hw))
                                        return -EIO;
-                               }
                                break;
                        }
                } else {
@@ -4861,7 +4851,6 @@ e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
                                break;
                        }
                }
-               spin_unlock_irqrestore(&adapter->stats_lock, flags);
                break;
        default:
                return -EOPNOTSUPP;
@@ -4903,6 +4892,20 @@ e1000_write_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
        pci_write_config_word(adapter->pdev, reg, *value);
 }
 
+int
+e1000_pcix_get_mmrbc(struct e1000_hw *hw)
+{
+       struct e1000_adapter *adapter = hw->back;
+       return pcix_get_mmrbc(adapter->pdev);
+}
+
+void
+e1000_pcix_set_mmrbc(struct e1000_hw *hw, int mmrbc)
+{
+       struct e1000_adapter *adapter = hw->back;
+       pcix_set_mmrbc(adapter->pdev, mmrbc);
+}
+
 int32_t
 e1000_read_pcie_cap_reg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
 {