e1000/e1000e: implement a simple interrupt moderation
authorJesse Brandeburg <jesse.brandeburg@intel.com>
Tue, 4 May 2010 22:26:03 +0000 (22:26 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 6 May 2010 04:15:32 +0000 (21:15 -0700)
Back before e1000-7.3.20, the e1000 driver had a simple algorithm that
managed interrupt moderation.  The driver was updated in 7.3.20 to
have the new "adaptive" interrupt moderation but we have customer
requests to redeploy the old way as an option.  This patch adds the
old functionality back.  The new functionality can be enabled via
module parameter or at runtime via ethtool.
Module parameter: (InterruptThrottleRate=4) to use this new
moderation method.
Ethtool method: ethtool -C ethX rx-usecs 4

Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/e1000/e1000_ethtool.c
drivers/net/e1000/e1000_main.c
drivers/net/e1000/e1000_param.c
drivers/net/e1000e/ethtool.c
drivers/net/e1000e/netdev.c
drivers/net/e1000e/param.c

index d6931cabe421e4e4f60b61f77198faea59efe58e..2a3b2dccd06d98fa9552827ceb9049976788d8a2 100644 (file)
@@ -1808,7 +1808,7 @@ static int e1000_get_coalesce(struct net_device *netdev,
        if (adapter->hw.mac_type < e1000_82545)
                return -EOPNOTSUPP;
 
-       if (adapter->itr_setting <= 3)
+       if (adapter->itr_setting <= 4)
                ec->rx_coalesce_usecs = adapter->itr_setting;
        else
                ec->rx_coalesce_usecs = 1000000 / adapter->itr_setting;
@@ -1826,12 +1826,14 @@ static int e1000_set_coalesce(struct net_device *netdev,
                return -EOPNOTSUPP;
 
        if ((ec->rx_coalesce_usecs > E1000_MAX_ITR_USECS) ||
-           ((ec->rx_coalesce_usecs > 3) &&
+           ((ec->rx_coalesce_usecs > 4) &&
             (ec->rx_coalesce_usecs < E1000_MIN_ITR_USECS)) ||
            (ec->rx_coalesce_usecs == 2))
                return -EINVAL;
 
-       if (ec->rx_coalesce_usecs <= 3) {
+       if (ec->rx_coalesce_usecs == 4) {
+               adapter->itr = adapter->itr_setting = 4;
+       } else if (ec->rx_coalesce_usecs <= 3) {
                adapter->itr = 20000;
                adapter->itr_setting = ec->rx_coalesce_usecs;
        } else {
index e6ebc222459fe83aa9c14e70742832e5ea901c65..4dd2c23775cbcb07c8c8cb8c4e91dd58a458c190 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.21-k5-NAPI"
+#define DRV_VERSION "7.3.21-k6-NAPI"
 const char e1000_driver_version[] = DRV_VERSION;
 static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
 
@@ -2386,6 +2386,22 @@ link_up:
                }
        }
 
+       /* Simple mode for Interrupt Throttle Rate (ITR) */
+       if (hw->mac_type >= e1000_82540 && adapter->itr_setting == 4) {
+               /*
+                * Symmetric Tx/Rx gets a reduced ITR=2000;
+                * Total asymmetrical Tx or Rx gets ITR=8000;
+                * everyone else is between 2000-8000.
+                */
+               u32 goc = (adapter->gotcl + adapter->gorcl) / 10000;
+               u32 dif = (adapter->gotcl > adapter->gorcl ?
+                           adapter->gotcl - adapter->gorcl :
+                           adapter->gorcl - adapter->gotcl) / 10000;
+               u32 itr = goc > 0 ? (dif * 6000 / goc + 2000) : 8000;
+
+               ew32(ITR, 1000000000 / (itr * 256));
+       }
+
        /* Cause software interrupt to ensure rx ring is cleaned */
        ew32(ICS, E1000_ICS_RXDMT0);
 
index 543c6d1767bc80bbfb1f15d9bf5360ecdd5310a5..9fbb562dc964a511fd2cf5403c6764e3efb498b2 100644 (file)
@@ -484,11 +484,17 @@ void __devinit e1000_check_options(struct e1000_adapter *adapter)
                                adapter->itr_setting = adapter->itr;
                                adapter->itr = 20000;
                                break;
+                       case 4:
+                               e_dev_info("%s set to simplified "
+                                          "(2000-8000) ints mode\n", opt.name);
+                               adapter->itr_setting = adapter->itr;
+                               break;
                        default:
                                e1000_validate_option(&adapter->itr, &opt,
                                        adapter);
-                               /* save the setting, because the dynamic bits change itr */
-                               /* clear the lower two bits because they are
+                               /* save the setting, because the dynamic bits
+                                * change itr.
+                                * clear the lower two bits because they are
                                 * used as control */
                                adapter->itr_setting = adapter->itr & ~3;
                                break;
index b72c1c0876fc3a4a9cce02555f0e97780485def5..6ff376cfe1399e01afdc2a0e32117e547e923f68 100644 (file)
@@ -1890,7 +1890,7 @@ static int e1000_get_coalesce(struct net_device *netdev,
 {
        struct e1000_adapter *adapter = netdev_priv(netdev);
 
-       if (adapter->itr_setting <= 3)
+       if (adapter->itr_setting <= 4)
                ec->rx_coalesce_usecs = adapter->itr_setting;
        else
                ec->rx_coalesce_usecs = 1000000 / adapter->itr_setting;
@@ -1905,12 +1905,14 @@ static int e1000_set_coalesce(struct net_device *netdev,
        struct e1000_hw *hw = &adapter->hw;
 
        if ((ec->rx_coalesce_usecs > E1000_MAX_ITR_USECS) ||
-           ((ec->rx_coalesce_usecs > 3) &&
+           ((ec->rx_coalesce_usecs > 4) &&
             (ec->rx_coalesce_usecs < E1000_MIN_ITR_USECS)) ||
            (ec->rx_coalesce_usecs == 2))
                return -EINVAL;
 
-       if (ec->rx_coalesce_usecs <= 3) {
+       if (ec->rx_coalesce_usecs == 4) {
+               adapter->itr = adapter->itr_setting = 4;
+       } else if (ec->rx_coalesce_usecs <= 3) {
                adapter->itr = 20000;
                adapter->itr_setting = ec->rx_coalesce_usecs;
        } else {
index 478c34a47d180377225441a44609a486f2d1fe12..c5f65a29865aefe9c69daa716155d91c677f2041 100644 (file)
@@ -52,7 +52,7 @@
 
 #include "e1000.h"
 
-#define DRV_VERSION "1.0.2-k2"
+#define DRV_VERSION "1.0.2-k4"
 char e1000e_driver_name[] = "e1000e";
 const char e1000e_driver_version[] = DRV_VERSION;
 
@@ -4070,6 +4070,22 @@ link_up:
                }
        }
 
+       /* Simple mode for Interrupt Throttle Rate (ITR) */
+       if (adapter->itr_setting == 4) {
+               /*
+                * Symmetric Tx/Rx gets a reduced ITR=2000;
+                * Total asymmetrical Tx or Rx gets ITR=8000;
+                * everyone else is between 2000-8000.
+                */
+               u32 goc = (adapter->gotc + adapter->gorc) / 10000;
+               u32 dif = (adapter->gotc > adapter->gorc ?
+                           adapter->gotc - adapter->gorc :
+                           adapter->gorc - adapter->gotc) / 10000;
+               u32 itr = goc > 0 ? (dif * 6000 / goc + 2000) : 8000;
+
+               ew32(ITR, 1000000000 / (itr * 256));
+       }
+
        /* Cause software interrupt to ensure Rx ring is cleaned */
        if (adapter->msix_entries)
                ew32(ICS, adapter->rx_ring->ims_val);
index f775a481063ded025dd88a0ee81a73770e89a161..0f4077c3d538d70258e90f5029ce87a3ba100420 100644 (file)
@@ -351,6 +351,11 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter)
                                adapter->itr_setting = adapter->itr;
                                adapter->itr = 20000;
                                break;
+                       case 4:
+                               e_info("%s set to simplified (2000-8000 ints) "
+                                      "mode\n", opt.name);
+                               adapter->itr_setting = 4;
+                               break;
                        default:
                                /*
                                 * Save the setting, because the dynamic bits