igb: only use vlan_gro_receive if vlans are registered
[safe/jmp/linux-2.6] / drivers / net / igb / igb_main.c
index cba0115..01c65c7 100644 (file)
@@ -72,6 +72,7 @@ static DEFINE_PCI_DEVICE_TABLE(igb_pci_tbl) = {
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_FIBER), board_82575 },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_SERDES), board_82575 },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_SERDES_QUAD), board_82575 },
+       { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_QUAD_COPPER_ET2), board_82575 },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_QUAD_COPPER), board_82575 },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575EB_COPPER), board_82575 },
        { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575EB_FIBER_SERDES), board_82575 },
@@ -649,6 +650,8 @@ static void igb_free_q_vectors(struct igb_adapter *adapter)
        for (v_idx = 0; v_idx < adapter->num_q_vectors; v_idx++) {
                struct igb_q_vector *q_vector = adapter->q_vector[v_idx];
                adapter->q_vector[v_idx] = NULL;
+               if (!q_vector)
+                       continue;
                netif_napi_del(&q_vector->napi);
                kfree(q_vector);
        }
@@ -686,7 +689,7 @@ static void igb_set_interrupt_capability(struct igb_adapter *adapter)
        /* start with one vector for every rx queue */
        numvecs = adapter->num_rx_queues;
 
-       /* if tx handler is seperate add 1 for every tx queue */
+       /* if tx handler is separate add 1 for every tx queue */
        if (!(adapter->flags & IGB_FLAG_QUEUE_PAIRS))
                numvecs += adapter->num_tx_queues;
 
@@ -768,13 +771,7 @@ static int igb_alloc_q_vectors(struct igb_adapter *adapter)
        return 0;
 
 err_out:
-       while (v_idx) {
-               v_idx--;
-               q_vector = adapter->q_vector[v_idx];
-               netif_napi_del(&q_vector->napi);
-               kfree(q_vector);
-               adapter->q_vector[v_idx] = NULL;
-       }
+       igb_free_q_vectors(adapter);
        return -ENOMEM;
 }
 
@@ -1108,9 +1105,6 @@ static void igb_configure(struct igb_adapter *adapter)
                struct igb_ring *ring = adapter->rx_ring[i];
                igb_alloc_rx_buffers_adv(ring, igb_desc_unused(ring));
        }
-
-
-       adapter->tx_queue_len = netdev->tx_queue_len;
 }
 
 /**
@@ -1216,7 +1210,6 @@ void igb_down(struct igb_adapter *adapter)
        del_timer_sync(&adapter->watchdog_timer);
        del_timer_sync(&adapter->phy_info_timer);
 
-       netdev->tx_queue_len = adapter->tx_queue_len;
        netif_carrier_off(netdev);
 
        /* record the stats before reset*/
@@ -2881,9 +2874,8 @@ static int igb_write_mc_addr_list(struct net_device *netdev)
 {
        struct igb_adapter *adapter = netdev_priv(netdev);
        struct e1000_hw *hw = &adapter->hw;
-       struct dev_mc_list *mc_ptr = netdev->mc_list;
+       struct dev_mc_list *mc_ptr;
        u8  *mta_list;
-       u32 vmolr = 0;
        int i;
 
        if (netdev_mc_empty(netdev)) {
@@ -2897,18 +2889,11 @@ static int igb_write_mc_addr_list(struct net_device *netdev)
        if (!mta_list)
                return -ENOMEM;
 
-       /* set vmolr receive overflow multicast bit */
-       vmolr |= E1000_VMOLR_ROMPE;
-
        /* The shared function expects a packed array of only addresses. */
-       mc_ptr = netdev->mc_list;
+       i = 0;
+       netdev_for_each_mc_addr(mc_ptr, netdev)
+               memcpy(mta_list + (i++ * ETH_ALEN), mc_ptr->dmi_addr, ETH_ALEN);
 
-       for (i = 0; i < netdev_mc_count(netdev); i++) {
-               if (!mc_ptr)
-                       break;
-               memcpy(mta_list + (i*ETH_ALEN), mc_ptr->dmi_addr, ETH_ALEN);
-               mc_ptr = mc_ptr->next;
-       }
        igb_update_mc_addr_list(hw, mta_list, i);
        kfree(mta_list);
 
@@ -3117,17 +3102,13 @@ static void igb_watchdog_task(struct work_struct *work)
                               ((ctrl & E1000_CTRL_RFCE) ?  "RX" :
                               ((ctrl & E1000_CTRL_TFCE) ?  "TX" : "None")));
 
-                       /* tweak tx_queue_len according to speed/duplex and
-                        * adjust the timeout factor */
-                       netdev->tx_queue_len = adapter->tx_queue_len;
+                       /* adjust timeout factor according to speed/duplex */
                        adapter->tx_timeout_factor = 1;
                        switch (adapter->link_speed) {
                        case SPEED_10:
-                               netdev->tx_queue_len = 10;
                                adapter->tx_timeout_factor = 14;
                                break;
                        case SPEED_100:
-                               netdev->tx_queue_len = 100;
                                /* maybe add some timeout factor ? */
                                break;
                        }
@@ -3434,8 +3415,8 @@ static inline int igb_tso_adv(struct igb_ring *tx_ring,
        int err;
        struct igb_buffer *buffer_info;
        u32 info = 0, tu_cmd = 0;
-       u32 mss_l4len_idx, l4len;
-       *hdr_len = 0;
+       u32 mss_l4len_idx;
+       u8 l4len;
 
        if (skb_header_cloned(skb)) {
                err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
@@ -3641,6 +3622,7 @@ static inline int igb_tx_map_adv(struct igb_ring *tx_ring, struct sk_buff *skb,
        }
 
        tx_ring->buffer_info[i].skb = skb;
+       tx_ring->buffer_info[i].gso_segs = skb_shinfo(skb)->gso_segs ?: 1;
        tx_ring->buffer_info[first].next_to_watch = i;
 
        return ++count;
@@ -3654,14 +3636,12 @@ dma_error:
        buffer_info->length = 0;
        buffer_info->next_to_watch = 0;
        buffer_info->mapped_as_page = false;
-       count--;
 
        /* clear timestamp and dma mappings for remaining portion of packet */
-       while (count >= 0) {
-               count--;
+       while (count--) {
+               if (i == 0)
+                       i = tx_ring->count;
                i--;
-               if (i < 0)
-                       i += tx_ring->count;
                buffer_info = &tx_ring->buffer_info[i];
                igb_unmap_and_free_tx_resource(tx_ring, buffer_info);
        }
@@ -3670,7 +3650,7 @@ dma_error:
 }
 
 static inline void igb_tx_queue_adv(struct igb_ring *tx_ring,
-                                   int tx_flags, int count, u32 paylen,
+                                   u32 tx_flags, int count, u32 paylen,
                                    u8 hdr_len)
 {
        union e1000_adv_tx_desc *tx_desc;
@@ -3758,7 +3738,7 @@ static int __igb_maybe_stop_tx(struct igb_ring *tx_ring, int size)
        return 0;
 }
 
-static int igb_maybe_stop_tx(struct igb_ring *tx_ring, int size)
+static inline int igb_maybe_stop_tx(struct igb_ring *tx_ring, int size)
 {
        if (igb_desc_unused(tx_ring) >= size)
                return 0;
@@ -3769,10 +3749,10 @@ netdev_tx_t igb_xmit_frame_ring_adv(struct sk_buff *skb,
                                    struct igb_ring *tx_ring)
 {
        struct igb_adapter *adapter = netdev_priv(tx_ring->netdev);
-       unsigned int first;
-       unsigned int tx_flags = 0;
-       u8 hdr_len = 0;
        int tso = 0, count;
+       u32 tx_flags = 0;
+       u16 first;
+       u8 hdr_len = 0;
        union skb_shared_tx *shtx = skb_tx(skb);
 
        /* need: 1 descriptor per page,
@@ -3975,7 +3955,7 @@ void igb_update_stats(struct igb_adapter *adapter)
        struct net_device_stats *net_stats = igb_get_stats(adapter->netdev);
        struct e1000_hw *hw = &adapter->hw;
        struct pci_dev *pdev = adapter->pdev;
-       u32 rnbc, reg;
+       u32 reg, mpc;
        u16 phy_tmp;
        int i;
        u64 bytes, packets;
@@ -4033,7 +4013,9 @@ void igb_update_stats(struct igb_adapter *adapter)
        adapter->stats.symerrs += rd32(E1000_SYMERRS);
        adapter->stats.sec += rd32(E1000_SEC);
 
-       adapter->stats.mpc += rd32(E1000_MPC);
+       mpc = rd32(E1000_MPC);
+       adapter->stats.mpc += mpc;
+       net_stats->rx_fifo_errors += mpc;
        adapter->stats.scc += rd32(E1000_SCC);
        adapter->stats.ecol += rd32(E1000_ECOL);
        adapter->stats.mcc += rd32(E1000_MCC);
@@ -4048,9 +4030,7 @@ void igb_update_stats(struct igb_adapter *adapter)
        adapter->stats.gptc += rd32(E1000_GPTC);
        adapter->stats.gotc += rd32(E1000_GOTCL);
        rd32(E1000_GOTCH); /* clear GOTCL */
-       rnbc = rd32(E1000_RNBC);
-       adapter->stats.rnbc += rnbc;
-       net_stats->rx_fifo_errors += rnbc;
+       adapter->stats.rnbc += rd32(E1000_RNBC);
        adapter->stats.ruc += rd32(E1000_RUC);
        adapter->stats.rfc += rd32(E1000_RFC);
        adapter->stats.rjc += rd32(E1000_RJC);
@@ -5032,7 +5012,7 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector)
                        if (skb) {
                                unsigned int segs, bytecount;
                                /* gso_segs is currently only valid for tcp */
-                               segs = skb_shinfo(skb)->gso_segs ?: 1;
+                               segs = buffer_info->gso_segs;
                                /* multiply data chunks by size of headers */
                                bytecount = ((segs - 1) * skb_headlen(skb)) +
                                            skb->len;
@@ -5122,7 +5102,7 @@ static void igb_receive_skb(struct igb_q_vector *q_vector,
 {
        struct igb_adapter *adapter = q_vector->adapter;
 
-       if (vlan_tag)
+       if (vlan_tag && adapter->vlgrp)
                vlan_gro_receive(&q_vector->napi, adapter->vlgrp,
                                 vlan_tag, skb);
        else