diff options
author | Emil Tantilov <emil.s.tantilov@intel.com> | 2011-08-30 20:01:16 -0400 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2011-09-29 02:08:23 -0400 |
commit | d5bf4f67a6b414628dc95b9c4891525296c09a29 (patch) | |
tree | 6f26c9b28c45f1aa923e138f5153505dc949aaaa /drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | |
parent | dd1ed3b7bfed15f6162f63840941e9cf4f3611a1 (diff) |
ixgbe: Cleanup q_vector interrupt throttle rate logic
This patch is meant to help cleanup the interrupt throttle rate logic by
storing the interrupt throttle rate as a value in microseconds instead of
interrupts per second. The advantage to this approach is that the value
can now be stored in an 16 bit field and doesn't require as much math to
flip the value back and forth since the hardware already used microseconds
when setting the rate.
Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c')
-rw-r--r-- | drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 153 |
1 files changed, 47 insertions, 106 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c index debcf5f350c7..ae9fba5d3036 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | |||
@@ -2026,39 +2026,20 @@ static int ixgbe_get_coalesce(struct net_device *netdev, | |||
2026 | ec->tx_max_coalesced_frames_irq = adapter->tx_work_limit; | 2026 | ec->tx_max_coalesced_frames_irq = adapter->tx_work_limit; |
2027 | 2027 | ||
2028 | /* only valid if in constant ITR mode */ | 2028 | /* only valid if in constant ITR mode */ |
2029 | switch (adapter->rx_itr_setting) { | 2029 | if (adapter->rx_itr_setting <= 1) |
2030 | case 0: | 2030 | ec->rx_coalesce_usecs = adapter->rx_itr_setting; |
2031 | /* throttling disabled */ | 2031 | else |
2032 | ec->rx_coalesce_usecs = 0; | 2032 | ec->rx_coalesce_usecs = adapter->rx_itr_setting >> 2; |
2033 | break; | ||
2034 | case 1: | ||
2035 | /* dynamic ITR mode */ | ||
2036 | ec->rx_coalesce_usecs = 1; | ||
2037 | break; | ||
2038 | default: | ||
2039 | /* fixed interrupt rate mode */ | ||
2040 | ec->rx_coalesce_usecs = 1000000/adapter->rx_eitr_param; | ||
2041 | break; | ||
2042 | } | ||
2043 | 2033 | ||
2044 | /* if in mixed tx/rx queues per vector mode, report only rx settings */ | 2034 | /* if in mixed tx/rx queues per vector mode, report only rx settings */ |
2045 | if (adapter->q_vector[0]->tx.count && adapter->q_vector[0]->rx.count) | 2035 | if (adapter->q_vector[0]->tx.count && adapter->q_vector[0]->rx.count) |
2046 | return 0; | 2036 | return 0; |
2047 | 2037 | ||
2048 | /* only valid if in constant ITR mode */ | 2038 | /* only valid if in constant ITR mode */ |
2049 | switch (adapter->tx_itr_setting) { | 2039 | if (adapter->tx_itr_setting <= 1) |
2050 | case 0: | 2040 | ec->tx_coalesce_usecs = adapter->tx_itr_setting; |
2051 | /* throttling disabled */ | 2041 | else |
2052 | ec->tx_coalesce_usecs = 0; | 2042 | ec->tx_coalesce_usecs = adapter->tx_itr_setting >> 2; |
2053 | break; | ||
2054 | case 1: | ||
2055 | /* dynamic ITR mode */ | ||
2056 | ec->tx_coalesce_usecs = 1; | ||
2057 | break; | ||
2058 | default: | ||
2059 | ec->tx_coalesce_usecs = 1000000/adapter->tx_eitr_param; | ||
2060 | break; | ||
2061 | } | ||
2062 | 2043 | ||
2063 | return 0; | 2044 | return 0; |
2064 | } | 2045 | } |
@@ -2077,10 +2058,9 @@ static bool ixgbe_update_rsc(struct ixgbe_adapter *adapter, | |||
2077 | 2058 | ||
2078 | /* if interrupt rate is too high then disable RSC */ | 2059 | /* if interrupt rate is too high then disable RSC */ |
2079 | if (ec->rx_coalesce_usecs != 1 && | 2060 | if (ec->rx_coalesce_usecs != 1 && |
2080 | ec->rx_coalesce_usecs <= 1000000/IXGBE_MAX_RSC_INT_RATE) { | 2061 | ec->rx_coalesce_usecs <= (IXGBE_MIN_RSC_ITR >> 2)) { |
2081 | if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) { | 2062 | if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) { |
2082 | e_info(probe, "rx-usecs set too low, " | 2063 | e_info(probe, "rx-usecs set too low, disabling RSC\n"); |
2083 | "disabling RSC\n"); | ||
2084 | adapter->flags2 &= ~IXGBE_FLAG2_RSC_ENABLED; | 2064 | adapter->flags2 &= ~IXGBE_FLAG2_RSC_ENABLED; |
2085 | return true; | 2065 | return true; |
2086 | } | 2066 | } |
@@ -2088,8 +2068,7 @@ static bool ixgbe_update_rsc(struct ixgbe_adapter *adapter, | |||
2088 | /* check the feature flag value and enable RSC if necessary */ | 2068 | /* check the feature flag value and enable RSC if necessary */ |
2089 | if ((netdev->features & NETIF_F_LRO) && | 2069 | if ((netdev->features & NETIF_F_LRO) && |
2090 | !(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)) { | 2070 | !(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)) { |
2091 | e_info(probe, "rx-usecs set to %d, " | 2071 | e_info(probe, "rx-usecs set to %d, re-enabling RSC\n", |
2092 | "re-enabling RSC\n", | ||
2093 | ec->rx_coalesce_usecs); | 2072 | ec->rx_coalesce_usecs); |
2094 | adapter->flags2 |= IXGBE_FLAG2_RSC_ENABLED; | 2073 | adapter->flags2 |= IXGBE_FLAG2_RSC_ENABLED; |
2095 | return true; | 2074 | return true; |
@@ -2104,97 +2083,59 @@ static int ixgbe_set_coalesce(struct net_device *netdev, | |||
2104 | struct ixgbe_adapter *adapter = netdev_priv(netdev); | 2083 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
2105 | struct ixgbe_q_vector *q_vector; | 2084 | struct ixgbe_q_vector *q_vector; |
2106 | int i; | 2085 | int i; |
2086 | int num_vectors; | ||
2087 | u16 tx_itr_param, rx_itr_param; | ||
2107 | bool need_reset = false; | 2088 | bool need_reset = false; |
2108 | 2089 | ||
2109 | /* don't accept tx specific changes if we've got mixed RxTx vectors */ | 2090 | /* don't accept tx specific changes if we've got mixed RxTx vectors */ |
2110 | if (adapter->q_vector[0]->tx.count && adapter->q_vector[0]->rx.count | 2091 | if (adapter->q_vector[0]->tx.count && adapter->q_vector[0]->rx.count |
2111 | && ec->tx_coalesce_usecs) | 2092 | && ec->tx_coalesce_usecs) |
2112 | return -EINVAL; | 2093 | return -EINVAL; |
2113 | 2094 | ||
2114 | if (ec->tx_max_coalesced_frames_irq) | 2095 | if (ec->tx_max_coalesced_frames_irq) |
2115 | adapter->tx_work_limit = ec->tx_max_coalesced_frames_irq; | 2096 | adapter->tx_work_limit = ec->tx_max_coalesced_frames_irq; |
2116 | 2097 | ||
2117 | if (ec->rx_coalesce_usecs > 1) { | 2098 | if ((ec->rx_coalesce_usecs > (IXGBE_MAX_EITR >> 2)) || |
2118 | /* check the limits */ | 2099 | (ec->tx_coalesce_usecs > (IXGBE_MAX_EITR >> 2))) |
2119 | if ((1000000/ec->rx_coalesce_usecs > IXGBE_MAX_INT_RATE) || | 2100 | return -EINVAL; |
2120 | (1000000/ec->rx_coalesce_usecs < IXGBE_MIN_INT_RATE)) | ||
2121 | return -EINVAL; | ||
2122 | |||
2123 | /* check the old value and enable RSC if necessary */ | ||
2124 | need_reset = ixgbe_update_rsc(adapter, ec); | ||
2125 | |||
2126 | /* store the value in ints/second */ | ||
2127 | adapter->rx_eitr_param = 1000000/ec->rx_coalesce_usecs; | ||
2128 | 2101 | ||
2129 | /* static value of interrupt rate */ | 2102 | /* check the old value and enable RSC if necessary */ |
2130 | adapter->rx_itr_setting = adapter->rx_eitr_param; | 2103 | need_reset = ixgbe_update_rsc(adapter, ec); |
2131 | /* clear the lower bit as its used for dynamic state */ | ||
2132 | adapter->rx_itr_setting &= ~1; | ||
2133 | } else if (ec->rx_coalesce_usecs == 1) { | ||
2134 | /* check the old value and enable RSC if necessary */ | ||
2135 | need_reset = ixgbe_update_rsc(adapter, ec); | ||
2136 | 2104 | ||
2137 | /* 1 means dynamic mode */ | 2105 | if (ec->rx_coalesce_usecs > 1) |
2138 | adapter->rx_eitr_param = 20000; | 2106 | adapter->rx_itr_setting = ec->rx_coalesce_usecs << 2; |
2139 | adapter->rx_itr_setting = 1; | 2107 | else |
2140 | } else { | 2108 | adapter->rx_itr_setting = ec->rx_coalesce_usecs; |
2141 | /* check the old value and enable RSC if necessary */ | ||
2142 | need_reset = ixgbe_update_rsc(adapter, ec); | ||
2143 | /* | ||
2144 | * any other value means disable eitr, which is best | ||
2145 | * served by setting the interrupt rate very high | ||
2146 | */ | ||
2147 | adapter->rx_eitr_param = IXGBE_MAX_INT_RATE; | ||
2148 | adapter->rx_itr_setting = 0; | ||
2149 | } | ||
2150 | 2109 | ||
2151 | if (ec->tx_coalesce_usecs > 1) { | 2110 | if (adapter->rx_itr_setting == 1) |
2152 | /* | 2111 | rx_itr_param = IXGBE_20K_ITR; |
2153 | * don't have to worry about max_int as above because | 2112 | else |
2154 | * tx vectors don't do hardware RSC (an rx function) | 2113 | rx_itr_param = adapter->rx_itr_setting; |
2155 | */ | ||
2156 | /* check the limits */ | ||
2157 | if ((1000000/ec->tx_coalesce_usecs > IXGBE_MAX_INT_RATE) || | ||
2158 | (1000000/ec->tx_coalesce_usecs < IXGBE_MIN_INT_RATE)) | ||
2159 | return -EINVAL; | ||
2160 | 2114 | ||
2161 | /* store the value in ints/second */ | 2115 | if (ec->tx_coalesce_usecs > 1) |
2162 | adapter->tx_eitr_param = 1000000/ec->tx_coalesce_usecs; | 2116 | adapter->tx_itr_setting = ec->tx_coalesce_usecs << 2; |
2117 | else | ||
2118 | adapter->tx_itr_setting = ec->tx_coalesce_usecs; | ||
2163 | 2119 | ||
2164 | /* static value of interrupt rate */ | 2120 | if (adapter->tx_itr_setting == 1) |
2165 | adapter->tx_itr_setting = adapter->tx_eitr_param; | 2121 | tx_itr_param = IXGBE_10K_ITR; |
2122 | else | ||
2123 | tx_itr_param = adapter->tx_itr_setting; | ||
2166 | 2124 | ||
2167 | /* clear the lower bit as its used for dynamic state */ | 2125 | if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) |
2168 | adapter->tx_itr_setting &= ~1; | 2126 | num_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; |
2169 | } else if (ec->tx_coalesce_usecs == 1) { | 2127 | else |
2170 | /* 1 means dynamic mode */ | 2128 | num_vectors = 1; |
2171 | adapter->tx_eitr_param = 10000; | ||
2172 | adapter->tx_itr_setting = 1; | ||
2173 | } else { | ||
2174 | adapter->tx_eitr_param = IXGBE_MAX_INT_RATE; | ||
2175 | adapter->tx_itr_setting = 0; | ||
2176 | } | ||
2177 | 2129 | ||
2178 | /* MSI/MSIx Interrupt Mode */ | 2130 | for (i = 0; i < num_vectors; i++) { |
2179 | if (adapter->flags & | 2131 | q_vector = adapter->q_vector[i]; |
2180 | (IXGBE_FLAG_MSIX_ENABLED | IXGBE_FLAG_MSI_ENABLED)) { | ||
2181 | int num_vectors = adapter->num_msix_vectors - NON_Q_VECTORS; | ||
2182 | for (i = 0; i < num_vectors; i++) { | ||
2183 | q_vector = adapter->q_vector[i]; | ||
2184 | if (q_vector->tx.count && !q_vector->rx.count) | ||
2185 | /* tx only */ | ||
2186 | q_vector->eitr = adapter->tx_eitr_param; | ||
2187 | else | ||
2188 | /* rx only or mixed */ | ||
2189 | q_vector->eitr = adapter->rx_eitr_param; | ||
2190 | q_vector->tx.work_limit = adapter->tx_work_limit; | ||
2191 | ixgbe_write_eitr(q_vector); | ||
2192 | } | ||
2193 | /* Legacy Interrupt Mode */ | ||
2194 | } else { | ||
2195 | q_vector = adapter->q_vector[0]; | ||
2196 | q_vector->eitr = adapter->rx_eitr_param; | ||
2197 | q_vector->tx.work_limit = adapter->tx_work_limit; | 2132 | q_vector->tx.work_limit = adapter->tx_work_limit; |
2133 | if (q_vector->tx.count && !q_vector->rx.count) | ||
2134 | /* tx only */ | ||
2135 | q_vector->itr = tx_itr_param; | ||
2136 | else | ||
2137 | /* rx only or mixed */ | ||
2138 | q_vector->itr = rx_itr_param; | ||
2198 | ixgbe_write_eitr(q_vector); | 2139 | ixgbe_write_eitr(q_vector); |
2199 | } | 2140 | } |
2200 | 2141 | ||