vlan: Don't check for vlan group before vlan_tx_tag_present.
[linux-2.6.git] / drivers / net / e1000e / netdev.c
index 36d31a4..ec8cf3f 100644 (file)
@@ -475,7 +475,8 @@ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
 {
        u16 status = (u16)status_err;
        u8 errors = (u8)(status_err >> 24);
-       skb->ip_summed = CHECKSUM_NONE;
+
+       skb_checksum_none_assert(skb);
 
        /* Ignore Checksum bit is set */
        if (status & E1000_RXD_STAT_IXSM)
@@ -781,6 +782,7 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
                if (*work_done >= work_to_do)
                        break;
                (*work_done)++;
+               rmb();  /* read descriptor and rx_buffer_info after status DD */
 
                status = rx_desc->status;
                skb = buffer_info->skb;
@@ -991,6 +993,7 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter)
        while ((eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) &&
               (count < tx_ring->count)) {
                bool cleaned = false;
+               rmb(); /* read buffer_info after eop_desc */
                for (; !cleaned; count++) {
                        tx_desc = E1000_TX_DESC(*tx_ring, i);
                        buffer_info = &tx_ring->buffer_info[i];
@@ -1050,7 +1053,7 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter)
        adapter->total_tx_packets += total_tx_packets;
        netdev->stats.tx_bytes += total_tx_bytes;
        netdev->stats.tx_packets += total_tx_packets;
-       return (count < tx_ring->count);
+       return count < tx_ring->count;
 }
 
 /**
@@ -1087,6 +1090,7 @@ static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
                        break;
                (*work_done)++;
                skb = buffer_info->skb;
+               rmb();  /* read descriptor and rx_buffer_info after status DD */
 
                /* in the packet split case this is header only */
                prefetch(skb->data - NET_IP_ALIGN);
@@ -1286,6 +1290,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
                if (*work_done >= work_to_do)
                        break;
                (*work_done)++;
+               rmb();  /* read descriptor and rx_buffer_info after status DD */
 
                status = rx_desc->status;
                skb = buffer_info->skb;
@@ -2285,6 +2290,11 @@ static void e1000_set_itr(struct e1000_adapter *adapter)
                goto set_itr_now;
        }
 
+       if (adapter->flags2 & FLAG2_DISABLE_AIM) {
+               new_itr = 0;
+               goto set_itr_now;
+       }
+
        adapter->tx_itr = e1000_update_itr(adapter,
                                    adapter->tx_itr,
                                    adapter->total_tx_packets,
@@ -2333,7 +2343,10 @@ set_itr_now:
                if (adapter->msix_entries)
                        adapter->rx_ring->set_itr = 1;
                else
-                       ew32(ITR, 1000000000 / (new_itr * 256));
+                       if (new_itr)
+                               ew32(ITR, 1000000000 / (new_itr * 256));
+                       else
+                               ew32(ITR, 0);
        }
 }
 
@@ -2532,7 +2545,7 @@ static void e1000_restore_vlan(struct e1000_adapter *adapter)
        if (!adapter->vlgrp)
                return;
 
-       for (vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
+       for (vid = 0; vid < VLAN_N_VID; vid++) {
                if (!vlan_group_get_device(adapter->vlgrp, vid))
                        continue;
                e1000_vlan_rx_add_vid(adapter->netdev, vid);
@@ -2645,6 +2658,26 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
        /* Tx irq moderation */
        ew32(TADV, adapter->tx_abs_int_delay);
 
+       if (adapter->flags2 & FLAG2_DMA_BURST) {
+               u32 txdctl = er32(TXDCTL(0));
+               txdctl &= ~(E1000_TXDCTL_PTHRESH | E1000_TXDCTL_HTHRESH |
+                           E1000_TXDCTL_WTHRESH);
+               /*
+                * set up some performance related parameters to encourage the
+                * hardware to use the bus more efficiently in bursts, depends
+                * on the tx_int_delay to be enabled,
+                * wthresh = 5 ==> burst write a cacheline (64 bytes) at a time
+                * hthresh = 1 ==> prefetch when one or more available
+                * pthresh = 0x1f ==> prefetch if internal cache 31 or less
+                * BEWARE: this seems to work but should be considered first if
+                * there are tx hangs or other tx related bugs
+                */
+               txdctl |= E1000_TXDCTL_DMA_BURST_ENABLE;
+               ew32(TXDCTL(0), txdctl);
+               /* erratum work around: set txdctl the same for both queues */
+               ew32(TXDCTL(1), txdctl);
+       }
+
        /* Program the Transmit Control Register */
        tctl = er32(TCTL);
        tctl &= ~E1000_TCTL_CT;
@@ -2700,6 +2733,16 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
        u32 psrctl = 0;
        u32 pages = 0;
 
+       /* Workaround Si errata on 82579 - configure jumbo frame flow */
+       if (hw->mac.type == e1000_pch2lan) {
+               s32 ret_val;
+
+               if (adapter->netdev->mtu > ETH_DATA_LEN)
+                       ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, true);
+               else
+                       ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, false);
+       }
+
        /* Program MC offset vector base */
        rctl = er32(RCTL);
        rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
@@ -2740,16 +2783,6 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
                e1e_wphy(hw, 22, phy_data);
        }
 
-       /* Workaround Si errata on 82579 - configure jumbo frame flow */
-       if (hw->mac.type == e1000_pch2lan) {
-               s32 ret_val;
-
-               if (rctl & E1000_RCTL_LPE)
-                       ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, true);
-               else
-                       ret_val = e1000_lv_jumbo_workaround_ich8lan(hw, false);
-       }
-
        /* Setup buffer sizes */
        rctl &= ~E1000_RCTL_SZ_4096;
        rctl |= E1000_RCTL_BSEX;
@@ -2867,12 +2900,35 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
        e1e_flush();
        msleep(10);
 
+       if (adapter->flags2 & FLAG2_DMA_BURST) {
+               /*
+                * set the writeback threshold (only takes effect if the RDTR
+                * is set). set GRAN=1 and write back up to 0x4 worth, and
+                * enable prefetching of 0x20 rx descriptors
+                * granularity = 01
+                * wthresh = 04,
+                * hthresh = 04,
+                * pthresh = 0x20
+                */
+               ew32(RXDCTL(0), E1000_RXDCTL_DMA_BURST_ENABLE);
+               ew32(RXDCTL(1), E1000_RXDCTL_DMA_BURST_ENABLE);
+
+               /*
+                * override the delay timers for enabling bursting, only if
+                * the value was not set by the user via module options
+                */
+               if (adapter->rx_int_delay == DEFAULT_RDTR)
+                       adapter->rx_int_delay = BURST_RDTR;
+               if (adapter->rx_abs_int_delay == DEFAULT_RADV)
+                       adapter->rx_abs_int_delay = BURST_RADV;
+       }
+
        /* set the Receive Delay Timer Register */
        ew32(RDTR, adapter->rx_int_delay);
 
        /* irq moderation */
        ew32(RADV, adapter->rx_abs_int_delay);
-       if (adapter->itr_setting != 0)
+       if ((adapter->itr_setting != 0) && (adapter->itr != 0))
                ew32(ITR, 1000000000 / (adapter->itr * 256));
 
        ctrl_ext = er32(CTRL_EXT);
@@ -2917,11 +2973,13 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
         * packet size is equal or larger than the specified value (in 8 byte
         * units), e.g. using jumbo frames when setting to E1000_ERT_2048
         */
-       if (adapter->flags & FLAG_HAS_ERT) {
+       if ((adapter->flags & FLAG_HAS_ERT) ||
+           (adapter->hw.mac.type == e1000_pch2lan)) {
                if (adapter->netdev->mtu > ETH_DATA_LEN) {
                        u32 rxdctl = er32(RXDCTL(0));
                        ew32(RXDCTL(0), rxdctl | 0x3);
-                       ew32(ERT, E1000_ERT_2048 | (1 << 13));
+                       if (adapter->flags & FLAG_HAS_ERT)
+                               ew32(ERT, E1000_ERT_2048 | (1 << 13));
                        /*
                         * With jumbo frames and early-receive enabled,
                         * excessive C-state transition latencies result in
@@ -3184,9 +3242,35 @@ void e1000e_reset(struct e1000_adapter *adapter)
                fc->low_water = 0x05048;
                fc->pause_time = 0x0650;
                fc->refresh_time = 0x0400;
+               if (adapter->netdev->mtu > ETH_DATA_LEN) {
+                       pba = 14;
+                       ew32(PBA, pba);
+               }
                break;
        }
 
+       /*
+        * Disable Adaptive Interrupt Moderation if 2 full packets cannot
+        * fit in receive buffer and early-receive not supported.
+        */
+       if (adapter->itr_setting & 0x3) {
+               if (((adapter->max_frame_size * 2) > (pba << 10)) &&
+                   !(adapter->flags & FLAG_HAS_ERT)) {
+                       if (!(adapter->flags2 & FLAG2_DISABLE_AIM)) {
+                               dev_info(&adapter->pdev->dev,
+                                       "Interrupt Throttle Rate turned off\n");
+                               adapter->flags2 |= FLAG2_DISABLE_AIM;
+                               ew32(ITR, 0);
+                       }
+               } else if (adapter->flags2 & FLAG2_DISABLE_AIM) {
+                       dev_info(&adapter->pdev->dev,
+                                "Interrupt Throttle Rate turned on\n");
+                       adapter->flags2 &= ~FLAG2_DISABLE_AIM;
+                       adapter->itr = 20000;
+                       ew32(ITR, 1000000000 / (adapter->itr * 256));
+               }
+       }
+
        /* Allow time for pending master requests to run */
        mac->ops.reset_hw(hw);
 
@@ -3407,22 +3491,16 @@ static int e1000_test_msi_interrupt(struct e1000_adapter *adapter)
 
        if (adapter->flags & FLAG_MSI_TEST_FAILED) {
                adapter->int_mode = E1000E_INT_MODE_LEGACY;
-               err = -EIO;
-               e_info("MSI interrupt test failed!\n");
-       }
+               e_info("MSI interrupt test failed, using legacy interrupt.\n");
+       } else
+               e_dbg("MSI interrupt test succeeded!\n");
 
        free_irq(adapter->pdev->irq, netdev);
        pci_disable_msi(adapter->pdev);
 
-       if (err == -EIO)
-               goto msi_test_failed;
-
-       /* okay so the test worked, restore settings */
-       e_dbg("MSI interrupt test succeeded!\n");
 msi_test_failed:
        e1000e_set_interrupt_capability(adapter);
-       e1000_request_irq(adapter);
-       return err;
+       return e1000_request_irq(adapter);
 }
 
 /**
@@ -3454,21 +3532,6 @@ static int e1000_test_msi(struct e1000_adapter *adapter)
                pci_write_config_word(adapter->pdev, PCI_COMMAND, pci_cmd);
        }
 
-       /* success ! */
-       if (!err)
-               return 0;
-
-       /* EIO means MSI test failed */
-       if (err != -EIO)
-               return err;
-
-       /* back to INTx mode */
-       e_warn("MSI interrupt test failed, using legacy interrupt.\n");
-
-       e1000_free_irq(adapter);
-
-       err = e1000_request_irq(adapter);
-
        return err;
 }
 
@@ -3526,7 +3589,8 @@ static int e1000_open(struct net_device *netdev)
                e1000_update_mng_vlan(adapter);
 
        /* DMA latency requirement to workaround early-receive/jumbo issue */
-       if (adapter->flags & FLAG_HAS_ERT)
+       if ((adapter->flags & FLAG_HAS_ERT) ||
+           (adapter->hw.mac.type == e1000_pch2lan))
                pm_qos_add_request(&adapter->netdev->pm_qos_req,
                                   PM_QOS_CPU_DMA_LATENCY,
                                   PM_QOS_DEFAULT_VALUE);
@@ -3635,7 +3699,8 @@ static int e1000_close(struct net_device *netdev)
        if (adapter->flags & FLAG_HAS_AMT)
                e1000_release_hw_control(adapter);
 
-       if (adapter->flags & FLAG_HAS_ERT)
+       if ((adapter->flags & FLAG_HAS_ERT) ||
+           (adapter->hw.mac.type == e1000_pch2lan))
                pm_qos_remove_request(&adapter->netdev->pm_qos_req);
 
        pm_runtime_put_sync(&pdev->dev);
@@ -4251,6 +4316,16 @@ link_up:
        /* Force detection of hung controller every watchdog period */
        adapter->detect_tx_hung = 1;
 
+       /* flush partial descriptors to memory before detecting tx hang */
+       if (adapter->flags2 & FLAG2_DMA_BURST) {
+               ew32(TIDV, adapter->tx_int_delay | E1000_TIDV_FPD);
+               ew32(RDTR, adapter->rx_int_delay | E1000_RDTR_FPD);
+               /*
+                * no need to flush the writes because the timeout code does
+                * an er32 first thing
+                */
+       }
+
        /*
         * With 82571 controllers, LAA may be overwritten due to controller
         * reset from the other port. Set the appropriate LAA in RAR[0]
@@ -4725,7 +4800,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
        if (e1000_maybe_stop_tx(netdev, count + 2))
                return NETDEV_TX_BUSY;
 
-       if (adapter->vlgrp && vlan_tx_tag_present(skb)) {
+       if (vlan_tx_tag_present(skb)) {
                tx_flags |= E1000_TX_FLAGS_VLAN;
                tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
        }
@@ -4829,6 +4904,15 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
                return -EINVAL;
        }
 
+       /* Jumbo frame workaround on 82579 requires CRC be stripped */
+       if ((adapter->hw.mac.type == e1000_pch2lan) &&
+           !(adapter->flags2 & FLAG2_CRC_STRIPPING) &&
+           (new_mtu > ETH_DATA_LEN)) {
+               e_err("Jumbo Frames not supported on 82579 when CRC "
+                     "stripping is disabled.\n");
+               return -EINVAL;
+       }
+
        /* 82573 Errata 17 */
        if (((adapter->hw.mac.type == e1000_82573) ||
             (adapter->hw.mac.type == e1000_82574)) &&
@@ -5699,8 +5783,10 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
        netdev->vlan_features |= NETIF_F_HW_CSUM;
        netdev->vlan_features |= NETIF_F_SG;
 
-       if (pci_using_dac)
+       if (pci_using_dac) {
                netdev->features |= NETIF_F_HIGHDMA;
+               netdev->vlan_features |= NETIF_F_HIGHDMA;
+       }
 
        if (e1000e_enable_mng_pass_thru(&adapter->hw))
                adapter->flags |= FLAG_MNG_PT_ENABLED;
@@ -5741,11 +5827,11 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
        }
 
        init_timer(&adapter->watchdog_timer);
-       adapter->watchdog_timer.function = &e1000_watchdog;
+       adapter->watchdog_timer.function = e1000_watchdog;
        adapter->watchdog_timer.data = (unsigned long) adapter;
 
        init_timer(&adapter->phy_info_timer);
-       adapter->phy_info_timer.function = &e1000_update_phy_info;
+       adapter->phy_info_timer.function = e1000_update_phy_info;
        adapter->phy_info_timer.data = (unsigned long) adapter;
 
        INIT_WORK(&adapter->reset_task, e1000_reset_task);
@@ -5825,11 +5911,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
 
        e1000_print_device_info(adapter);
 
-       if (pci_dev_run_wake(pdev)) {
-               pm_runtime_set_active(&pdev->dev);
-               pm_runtime_enable(&pdev->dev);
-       }
-       pm_schedule_suspend(&pdev->dev, MSEC_PER_SEC);
+       if (pci_dev_run_wake(pdev))
+               pm_runtime_put_noidle(&pdev->dev);
 
        return 0;
 
@@ -5875,8 +5958,6 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
        struct e1000_adapter *adapter = netdev_priv(netdev);
        bool down = test_bit(__E1000_DOWN, &adapter->state);
 
-       pm_runtime_get_sync(&pdev->dev);
-
        /*
         * flush_scheduled work may reschedule our watchdog task, so
         * explicitly disable watchdog tasks from being rescheduled
@@ -5901,11 +5982,8 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
                clear_bit(__E1000_DOWN, &adapter->state);
        unregister_netdev(netdev);
 
-       if (pci_dev_run_wake(pdev)) {
-               pm_runtime_disable(&pdev->dev);
-               pm_runtime_set_suspended(&pdev->dev);
-       }
-       pm_runtime_put_noidle(&pdev->dev);
+       if (pci_dev_run_wake(pdev))
+               pm_runtime_get_noresume(&pdev->dev);
 
        /*
         * Release control of h/w to f/w.  If f/w is AMT enabled, this