]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/net/e1000/e1000_main.c
net: replace uses of __constant_{endian}
[net-next-2.6.git] / drivers / net / e1000 / e1000_main.c
index 872799b746f501a3af4264c13b4674dbb8802382..40db34deebde84eee111e11fd89ded37dec76de0 100644 (file)
@@ -31,7 +31,7 @@
 
 char e1000_driver_name[] = "e1000";
 static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
-#define DRV_VERSION "7.3.20-k3-NAPI"
+#define DRV_VERSION "7.3.21-k3-NAPI"
 const char e1000_driver_version[] = DRV_VERSION;
 static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
 
@@ -888,6 +888,26 @@ static int e1000_is_need_ioport(struct pci_dev *pdev)
        }
 }
 
+static const struct net_device_ops e1000_netdev_ops = {
+       .ndo_open               = e1000_open,
+       .ndo_stop               = e1000_close,
+       .ndo_start_xmit         = e1000_xmit_frame,
+       .ndo_get_stats          = e1000_get_stats,
+       .ndo_set_rx_mode        = e1000_set_rx_mode,
+       .ndo_set_mac_address    = e1000_set_mac,
+       .ndo_tx_timeout         = e1000_tx_timeout,
+       .ndo_change_mtu         = e1000_change_mtu,
+       .ndo_do_ioctl           = e1000_ioctl,
+       .ndo_validate_addr      = eth_validate_addr,
+
+       .ndo_vlan_rx_register   = e1000_vlan_rx_register,
+       .ndo_vlan_rx_add_vid    = e1000_vlan_rx_add_vid,
+       .ndo_vlan_rx_kill_vid   = e1000_vlan_rx_kill_vid,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+       .ndo_poll_controller    = e1000_netpoll,
+#endif
+};
+
 /**
  * e1000_probe - Device Initialization Routine
  * @pdev: PCI device information struct
@@ -912,7 +932,6 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
        u16 eeprom_data = 0;
        u16 eeprom_apme_mask = E1000_EEPROM_APME;
        int bars, need_ioport;
-       DECLARE_MAC_BUF(mac);
 
        /* do not allocate ioport bars when not needed */
        need_ioport = e1000_is_need_ioport(pdev);
@@ -967,8 +986,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
        hw->back = adapter;
 
        err = -EIO;
-       hw->hw_addr = ioremap(pci_resource_start(pdev, BAR_0),
-                             pci_resource_len(pdev, BAR_0));
+       hw->hw_addr = pci_ioremap_bar(pdev, BAR_0);
        if (!hw->hw_addr)
                goto err_ioremap;
 
@@ -983,24 +1001,11 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
                }
        }
 
-       netdev->open = &e1000_open;
-       netdev->stop = &e1000_close;
-       netdev->hard_start_xmit = &e1000_xmit_frame;
-       netdev->get_stats = &e1000_get_stats;
-       netdev->set_rx_mode = &e1000_set_rx_mode;
-       netdev->set_mac_address = &e1000_set_mac;
-       netdev->change_mtu = &e1000_change_mtu;
-       netdev->do_ioctl = &e1000_ioctl;
+       netdev->netdev_ops = &e1000_netdev_ops;
        e1000_set_ethtool_ops(netdev);
-       netdev->tx_timeout = &e1000_tx_timeout;
        netdev->watchdog_timeo = 5 * HZ;
        netif_napi_add(netdev, &adapter->napi, e1000_clean, 64);
-       netdev->vlan_rx_register = e1000_vlan_rx_register;
-       netdev->vlan_rx_add_vid = e1000_vlan_rx_add_vid;
-       netdev->vlan_rx_kill_vid = e1000_vlan_rx_kill_vid;
-#ifdef CONFIG_NET_POLL_CONTROLLER
-       netdev->poll_controller = e1000_netpoll;
-#endif
+
        strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
 
        adapter->bd_number = cards_found;
@@ -1016,9 +1021,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
         * because it depends on mac_type */
        if ((hw->mac_type == e1000_ich8lan) &&
           (pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {
-               hw->flash_address =
-                       ioremap(pci_resource_start(pdev, 1),
-                               pci_resource_len(pdev, 1));
+               hw->flash_address = pci_ioremap_bar(pdev, 1);
                if (!hw->flash_address)
                        goto err_flashmap;
        }
@@ -1045,8 +1048,6 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
        if (pci_using_dac)
                netdev->features |= NETIF_F_HIGHDMA;
 
-       netdev->features |= NETIF_F_LLTX;
-
        netdev->vlan_features |= NETIF_F_TSO;
        netdev->vlan_features |= NETIF_F_TSO6;
        netdev->vlan_features |= NETIF_F_HW_CSUM;
@@ -1195,7 +1196,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
                 (hw->bus_width == e1000_bus_width_pciex_1) ? "Width x1" :
                 "32-bit"));
 
-       printk("%s\n", print_mac(mac, netdev->dev_addr));
+       printk("%pM\n", netdev->dev_addr);
 
        if (hw->bus_type == e1000_bus_type_pci_express) {
                DPRINTK(PROBE, WARNING, "This device (id %04x:%04x) will no "
@@ -1239,12 +1240,8 @@ err_eeprom:
        if (hw->flash_address)
                iounmap(hw->flash_address);
 err_flashmap:
-       for (i = 0; i < adapter->num_rx_queues; i++)
-               dev_put(&adapter->polling_netdev[i]);
-
        kfree(adapter->tx_ring);
        kfree(adapter->rx_ring);
-       kfree(adapter->polling_netdev);
 err_sw_init:
        iounmap(hw->hw_addr);
 err_ioremap:
@@ -1272,7 +1269,6 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
        struct net_device *netdev = pci_get_drvdata(pdev);
        struct e1000_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
-       int i;
 
        cancel_work_sync(&adapter->reset_task);
 
@@ -1282,9 +1278,6 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
         * would have already happened in close and is redundant. */
        e1000_release_hw_control(adapter);
 
-       for (i = 0; i < adapter->num_rx_queues; i++)
-               dev_put(&adapter->polling_netdev[i]);
-
        unregister_netdev(netdev);
 
        if (!e1000_check_phy_reset_block(hw))
@@ -1292,7 +1285,6 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
 
        kfree(adapter->tx_ring);
        kfree(adapter->rx_ring);
-       kfree(adapter->polling_netdev);
 
        iounmap(hw->hw_addr);
        if (hw->flash_address)
@@ -1318,7 +1310,6 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
        struct e1000_hw *hw = &adapter->hw;
        struct net_device *netdev = adapter->netdev;
        struct pci_dev *pdev = adapter->pdev;
-       int i;
 
        /* PCI config space info */
 
@@ -1375,13 +1366,6 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
                return -ENOMEM;
        }
 
-       for (i = 0; i < adapter->num_rx_queues; i++) {
-               adapter->polling_netdev[i].priv = adapter;
-               dev_hold(&adapter->polling_netdev[i]);
-               set_bit(__LINK_STATE_START, &adapter->polling_netdev[i].state);
-       }
-       spin_lock_init(&adapter->tx_queue_lock);
-
        /* Explicitly disable IRQ since the NIC can be in any state. */
        e1000_irq_disable(adapter);
 
@@ -1397,8 +1381,7 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
  * @adapter: board private structure to initialize
  *
  * We allocate one ring per queue at run-time since we don't know the
- * number of queues at compile-time.  The polling_netdev array is
- * intended for Multiqueue, but should work fine with a single queue.
+ * number of queues at compile-time.
  **/
 
 static int __devinit e1000_alloc_queues(struct e1000_adapter *adapter)
@@ -1415,15 +1398,6 @@ static int __devinit e1000_alloc_queues(struct e1000_adapter *adapter)
                return -ENOMEM;
        }
 
-       adapter->polling_netdev = kcalloc(adapter->num_rx_queues,
-                                         sizeof(struct net_device),
-                                         GFP_KERNEL);
-       if (!adapter->polling_netdev) {
-               kfree(adapter->tx_ring);
-               kfree(adapter->rx_ring);
-               return -ENOMEM;
-       }
-
        return E1000_SUCCESS;
 }
 
@@ -1646,7 +1620,6 @@ setup_tx_desc_die:
 
        txdr->next_to_use = 0;
        txdr->next_to_clean = 0;
-       spin_lock_init(&txdr->tx_lock);
 
        return 0;
 }
@@ -2521,10 +2494,11 @@ static void e1000_watchdog(unsigned long data)
                                                   &adapter->link_duplex);
 
                        ctrl = er32(CTRL);
-                       DPRINTK(LINK, INFO, "NIC Link is Up %d Mbps %s, "
-                               "Flow Control: %s\n",
-                               adapter->link_speed,
-                               adapter->link_duplex == FULL_DUPLEX ?
+                       printk(KERN_INFO "e1000: %s NIC Link is Up %d Mbps %s, "
+                              "Flow Control: %s\n",
+                              netdev->name,
+                              adapter->link_speed,
+                              adapter->link_duplex == FULL_DUPLEX ?
                                "Full Duplex" : "Half Duplex",
                                ((ctrl & E1000_CTRL_TFCE) && (ctrl &
                                E1000_CTRL_RFCE)) ? "RX/TX" : ((ctrl &
@@ -2600,7 +2574,8 @@ static void e1000_watchdog(unsigned long data)
                if (netif_carrier_ok(netdev)) {
                        adapter->link_speed = 0;
                        adapter->link_duplex = 0;
-                       DPRINTK(LINK, INFO, "NIC Link is Down\n");
+                       printk(KERN_INFO "e1000: %s NIC Link is Down\n",
+                              netdev->name);
                        netif_carrier_off(netdev);
                        netif_stop_queue(netdev);
                        mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ));
@@ -2885,11 +2860,11 @@ static bool e1000_tx_csum(struct e1000_adapter *adapter,
                return false;
 
        switch (skb->protocol) {
-       case __constant_htons(ETH_P_IP):
+       case cpu_to_be16(ETH_P_IP):
                if (ip_hdr(skb)->protocol == IPPROTO_TCP)
                        cmd_len |= E1000_TXD_CMD_TCP;
                break;
-       case __constant_htons(ETH_P_IPV6):
+       case cpu_to_be16(ETH_P_IPV6):
                /* XXX not handling all IPV6 headers */
                if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP)
                        cmd_len |= E1000_TXD_CMD_TCP;
@@ -3205,7 +3180,6 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
        unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
        unsigned int tx_flags = 0;
        unsigned int len = skb->len - skb->data_len;
-       unsigned long flags;
        unsigned int nr_frags;
        unsigned int mss;
        int count = 0;
@@ -3310,22 +3284,15 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
            (hw->mac_type == e1000_82573))
                e1000_transfer_dhcp_info(adapter, skb);
 
-       if (!spin_trylock_irqsave(&tx_ring->tx_lock, flags))
-               /* Collision - tell upper layer to requeue */
-               return NETDEV_TX_LOCKED;
-
        /* need: count + 2 desc gap to keep tail from touching
         * head, otherwise try next time */
-       if (unlikely(e1000_maybe_stop_tx(netdev, tx_ring, count + 2))) {
-               spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
+       if (unlikely(e1000_maybe_stop_tx(netdev, tx_ring, count + 2)))
                return NETDEV_TX_BUSY;
-       }
 
        if (unlikely(hw->mac_type == e1000_82547)) {
                if (unlikely(e1000_82547_fifo_workaround(adapter, skb))) {
                        netif_stop_queue(netdev);
                        mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1);
-                       spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
                        return NETDEV_TX_BUSY;
                }
        }
@@ -3340,7 +3307,6 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
        tso = e1000_tso(adapter, tx_ring, skb);
        if (tso < 0) {
                dev_kfree_skb_any(skb);
-               spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
                return NETDEV_TX_OK;
        }
 
@@ -3365,7 +3331,6 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
        /* Make sure there is space in the ring for the next send. */
        e1000_maybe_stop_tx(netdev, tx_ring, MAX_SKB_FRAGS + 2);
 
-       spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
        return NETDEV_TX_OK;
 }
 
@@ -3707,12 +3672,12 @@ static irqreturn_t e1000_intr_msi(int irq, void *data)
                        mod_timer(&adapter->watchdog_timer, jiffies + 1);
        }
 
-       if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
+       if (likely(napi_schedule_prep(&adapter->napi))) {
                adapter->total_tx_bytes = 0;
                adapter->total_tx_packets = 0;
                adapter->total_rx_bytes = 0;
                adapter->total_rx_packets = 0;
-               __netif_rx_schedule(netdev, &adapter->napi);
+               __napi_schedule(&adapter->napi);
        } else
                e1000_irq_enable(adapter);
 
@@ -3732,7 +3697,7 @@ static irqreturn_t e1000_intr(int irq, void *data)
        struct e1000_hw *hw = &adapter->hw;
        u32 rctl, icr = er32(ICR);
 
-       if (unlikely(!icr))
+       if (unlikely((!icr) || test_bit(__E1000_RESETTING, &adapter->flags)))
                return IRQ_NONE;  /* Not our interrupt */
 
        /* IMS will not auto-mask if INT_ASSERTED is not set, and if it is
@@ -3767,12 +3732,12 @@ static irqreturn_t e1000_intr(int irq, void *data)
                ew32(IMC, ~0);
                E1000_WRITE_FLUSH();
        }
-       if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
+       if (likely(napi_schedule_prep(&adapter->napi))) {
                adapter->total_tx_bytes = 0;
                adapter->total_tx_packets = 0;
                adapter->total_rx_bytes = 0;
                adapter->total_rx_packets = 0;
-               __netif_rx_schedule(netdev, &adapter->napi);
+               __napi_schedule(&adapter->napi);
        } else
                /* this really should not happen! if it does it is basically a
                 * bug, but not a hard error, so enable ints and continue */
@@ -3791,18 +3756,9 @@ static int e1000_clean(struct napi_struct *napi, int budget)
        struct net_device *poll_dev = adapter->netdev;
        int tx_cleaned = 0, work_done = 0;
 
-       /* Must NOT use netdev_priv macro here. */
-       adapter = poll_dev->priv;
-
-       /* e1000_clean is called per-cpu.  This lock protects
-        * tx_ring[0] from being cleaned by multiple cpus
-        * simultaneously.  A failure obtaining the lock means
-        * tx_ring[0] is currently being cleaned anyway. */
-       if (spin_trylock(&adapter->tx_queue_lock)) {
-               tx_cleaned = e1000_clean_tx_irq(adapter,
-                                               &adapter->tx_ring[0]);
-               spin_unlock(&adapter->tx_queue_lock);
-       }
+       adapter = netdev_priv(poll_dev);
+
+       tx_cleaned = e1000_clean_tx_irq(adapter, &adapter->tx_ring[0]);
 
        adapter->clean_rx(adapter, &adapter->rx_ring[0],
                          &work_done, budget);
@@ -3814,7 +3770,7 @@ static int e1000_clean(struct napi_struct *napi, int budget)
        if (work_done < budget) {
                if (likely(adapter->itr_setting & 3))
                        e1000_set_itr(adapter);
-               netif_rx_complete(poll_dev, napi);
+               napi_complete(napi);
                e1000_irq_enable(adapter);
        }
 
@@ -4104,8 +4060,6 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
                        netif_receive_skb(skb);
                }
 
-               netdev->last_rx = jiffies;
-
 next_desc:
                rx_desc->status = 0;
 
@@ -4789,7 +4743,7 @@ static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
                                                pci_channel_state_t state)
 {
        struct net_device *netdev = pci_get_drvdata(pdev);
-       struct e1000_adapter *adapter = netdev->priv;
+       struct e1000_adapter *adapter = netdev_priv(netdev);
 
        netif_device_detach(netdev);
 
@@ -4811,7 +4765,7 @@ static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
 static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
 {
        struct net_device *netdev = pci_get_drvdata(pdev);
-       struct e1000_adapter *adapter = netdev->priv;
+       struct e1000_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
        int err;
 
@@ -4845,7 +4799,7 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
 static void e1000_io_resume(struct pci_dev *pdev)
 {
        struct net_device *netdev = pci_get_drvdata(pdev);
-       struct e1000_adapter *adapter = netdev->priv;
+       struct e1000_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
 
        e1000_init_manageability(adapter);