]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/net/ixgbe/ixgbe_ethtool.c
ixgbe: Disable RSC when ITR setting is too high to allow RSC
[net-next-2.6.git] / drivers / net / ixgbe / ixgbe_ethtool.c
index cc7804962b2e4567817e5d1353745f80207836bc..561d47895d828e1f9f54bb54c793dacc3dc66b56 100644 (file)
@@ -1473,6 +1473,7 @@ static int ixgbe_setup_desc_rings(struct ixgbe_adapter *adapter)
        tx_ring->count = IXGBE_DEFAULT_TXD;
        tx_ring->queue_index = 0;
        tx_ring->dev = &adapter->pdev->dev;
+       tx_ring->netdev = adapter->netdev;
        tx_ring->reg_idx = adapter->tx_ring[0]->reg_idx;
        tx_ring->numa_node = adapter->node;
 
@@ -1492,6 +1493,7 @@ static int ixgbe_setup_desc_rings(struct ixgbe_adapter *adapter)
        rx_ring->count = IXGBE_DEFAULT_RXD;
        rx_ring->queue_index = 0;
        rx_ring->dev = &adapter->pdev->dev;
+       rx_ring->netdev = adapter->netdev;
        rx_ring->reg_idx = adapter->rx_ring[0]->reg_idx;
        rx_ring->rx_buf_len = IXGBE_RXBUFFER_2048;
        rx_ring->numa_node = adapter->node;
@@ -1595,8 +1597,7 @@ static int ixgbe_check_lbtest_frame(struct sk_buff *skb,
        return 13;
 }
 
-static u16 ixgbe_clean_test_rings(struct ixgbe_adapter *adapter,
-                                  struct ixgbe_ring *rx_ring,
+static u16 ixgbe_clean_test_rings(struct ixgbe_ring *rx_ring,
                                   struct ixgbe_ring *tx_ring,
                                   unsigned int size)
 {
@@ -1646,7 +1647,7 @@ static u16 ixgbe_clean_test_rings(struct ixgbe_adapter *adapter,
        }
 
        /* re-map buffers to ring, store next to clean values */
-       ixgbe_alloc_rx_buffers(adapter, rx_ring, count);
+       ixgbe_alloc_rx_buffers(rx_ring, count);
        rx_ring->next_to_clean = rx_ntc;
        tx_ring->next_to_clean = tx_ntc;
 
@@ -1690,7 +1691,6 @@ static int ixgbe_run_loopback_test(struct ixgbe_adapter *adapter)
                for (i = 0; i < 64; i++) {
                        skb_get(skb);
                        tx_ret_val = ixgbe_xmit_frame_ring(skb,
-                                                          adapter->netdev,
                                                           adapter,
                                                           tx_ring);
                        if (tx_ret_val == NETDEV_TX_OK)
@@ -1705,8 +1705,7 @@ static int ixgbe_run_loopback_test(struct ixgbe_adapter *adapter)
                /* allow 200 milliseconds for packets to go from Tx to Rx */
                msleep(200);
 
-               good_cnt = ixgbe_clean_test_rings(adapter, rx_ring,
-                                                 tx_ring, size);
+               good_cnt = ixgbe_clean_test_rings(rx_ring, tx_ring, size);
                if (good_cnt != 64) {
                        ret_val = 13;
                        break;
@@ -1976,6 +1975,41 @@ static int ixgbe_get_coalesce(struct net_device *netdev,
        return 0;
 }
 
+/*
+ * this function must be called before setting the new value of
+ * rx_itr_setting
+ */
+static bool ixgbe_update_rsc(struct ixgbe_adapter *adapter,
+                            struct ethtool_coalesce *ec)
+{
+       struct net_device *netdev = adapter->netdev;
+
+       if (!(adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE))
+               return false;
+
+       /* if interrupt rate is too high then disable RSC */
+       if (ec->rx_coalesce_usecs != 1 &&
+           ec->rx_coalesce_usecs <= 1000000/IXGBE_MAX_RSC_INT_RATE) {
+               if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) {
+                       e_info(probe, "rx-usecs set too low, "
+                                     "disabling RSC\n");
+                       adapter->flags2 &= ~IXGBE_FLAG2_RSC_ENABLED;
+                       return true;
+               }
+       } else {
+               /* check the feature flag value and enable RSC if necessary */
+               if ((netdev->features & NETIF_F_LRO) &&
+                   !(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)) {
+                       e_info(probe, "rx-usecs set to %d, "
+                                     "re-enabling RSC\n",
+                              ec->rx_coalesce_usecs);
+                       adapter->flags2 |= IXGBE_FLAG2_RSC_ENABLED;
+                       return true;
+               }
+       }
+       return false;
+}
+
 static int ixgbe_set_coalesce(struct net_device *netdev,
                               struct ethtool_coalesce *ec)
 {
@@ -1993,17 +2027,14 @@ static int ixgbe_set_coalesce(struct net_device *netdev,
                adapter->tx_ring[0]->work_limit = ec->tx_max_coalesced_frames_irq;
 
        if (ec->rx_coalesce_usecs > 1) {
-               u32 max_int;
-               if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)
-                       max_int = IXGBE_MAX_RSC_INT_RATE;
-               else
-                       max_int = IXGBE_MAX_INT_RATE;
-
                /* check the limits */
-               if ((1000000/ec->rx_coalesce_usecs > max_int) ||
+               if ((1000000/ec->rx_coalesce_usecs > IXGBE_MAX_INT_RATE) ||
                    (1000000/ec->rx_coalesce_usecs < IXGBE_MIN_INT_RATE))
                        return -EINVAL;
 
+               /* check the old value and enable RSC if necessary */
+               need_reset = ixgbe_update_rsc(adapter, ec);
+
                /* store the value in ints/second */
                adapter->rx_eitr_param = 1000000/ec->rx_coalesce_usecs;
 
@@ -2012,32 +2043,21 @@ static int ixgbe_set_coalesce(struct net_device *netdev,
                /* clear the lower bit as its used for dynamic state */
                adapter->rx_itr_setting &= ~1;
        } else if (ec->rx_coalesce_usecs == 1) {
+               /* check the old value and enable RSC if necessary */
+               need_reset = ixgbe_update_rsc(adapter, ec);
+
                /* 1 means dynamic mode */
                adapter->rx_eitr_param = 20000;
                adapter->rx_itr_setting = 1;
        } else {
+               /* check the old value and enable RSC if necessary */
+               need_reset = ixgbe_update_rsc(adapter, ec);
                /*
                 * any other value means disable eitr, which is best
                 * served by setting the interrupt rate very high
                 */
                adapter->rx_eitr_param = IXGBE_MAX_INT_RATE;
                adapter->rx_itr_setting = 0;
-
-               /*
-                * if hardware RSC is enabled, disable it when
-                * setting low latency mode, to avoid errata, assuming
-                * that when the user set low latency mode they want
-                * it at the cost of anything else
-                */
-               if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) {
-                       adapter->flags2 &= ~IXGBE_FLAG2_RSC_ENABLED;
-                       if (netdev->features & NETIF_F_LRO) {
-                               netdev->features &= ~NETIF_F_LRO;
-                               e_info(probe, "rx-usecs set to 0, "
-                                      "disabling RSC\n");
-                       }
-                       need_reset = true;
-               }
        }
 
        if (ec->tx_coalesce_usecs > 1) {
@@ -2124,15 +2144,15 @@ static int ixgbe_set_flags(struct net_device *netdev, u32 data)
                return rc;
 
        /* if state changes we need to update adapter->flags and reset */
-       if (adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE) {
-               /*
-                * cast both to bool and verify if they are set the same
-                * but only enable RSC if itr is non-zero, as
-                * itr=0 and RSC are mutually exclusive
-                */
-               if (((!!(data & ETH_FLAG_LRO)) !=
-                    (!!(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED))) &&
-                   adapter->rx_itr_setting) {
+       if ((adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE) &&
+           (!!(data & ETH_FLAG_LRO) !=
+            !!(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED))) {
+               if ((data & ETH_FLAG_LRO) &&
+                   (!adapter->rx_itr_setting ||
+                    (adapter->rx_itr_setting > IXGBE_MAX_RSC_INT_RATE))) {
+                       e_info(probe, "rx-usecs set too low, "
+                                     "not enabling RSC.\n");
+               } else {
                        adapter->flags2 ^= IXGBE_FLAG2_RSC_ENABLED;
                        switch (adapter->hw.mac.type) {
                        case ixgbe_mac_82599EB:
@@ -2141,11 +2161,6 @@ static int ixgbe_set_flags(struct net_device *netdev, u32 data)
                        default:
                                break;
                        }
-               } else if (!adapter->rx_itr_setting) {
-                       netdev->features &= ~NETIF_F_LRO;
-                       if (data & ETH_FLAG_LRO)
-                               e_info(probe, "rx-usecs set to 0, "
-                                      "LRO/RSC cannot be enabled.\n");
                }
        }