aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorMitch A Williams <mitch.a.williams@intel.com>2012-06-29 20:23:19 -0400
committerDavid S. Miller <davem@davemloft.net>2012-06-30 20:40:45 -0400
commit0e90b49ca4b891f085b57559a3071a4feefb496c (patch)
treef34c038e177f5ab0779870b6d2a40e0b155bc515 /drivers/net
parent0c12d91b7064e16e96939243187b12fbd99caac7 (diff)
igbvf: fix divide by zero
Using ethtool -C ethX rx-usecs 0 crashes with a divide by zero. Refactor this function to fix this issue and make it more clear what the intent of each conditional is. Add comment regarding using a setting of zero. CC: stable <stable@vger.kernel.org> [3.3+] CC: David Ahern <daahern@cisco.com> Signed-off-by: Mitch Williams <mitch.a.williams@intel.com> Tested-by: Aaron Brown <aaron.f.brown@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/intel/igbvf/ethtool.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/drivers/net/ethernet/intel/igbvf/ethtool.c b/drivers/net/ethernet/intel/igbvf/ethtool.c
index 8ce67064b9c5..90eef07943f4 100644
--- a/drivers/net/ethernet/intel/igbvf/ethtool.c
+++ b/drivers/net/ethernet/intel/igbvf/ethtool.c
@@ -357,21 +357,28 @@ static int igbvf_set_coalesce(struct net_device *netdev,
357 struct igbvf_adapter *adapter = netdev_priv(netdev); 357 struct igbvf_adapter *adapter = netdev_priv(netdev);
358 struct e1000_hw *hw = &adapter->hw; 358 struct e1000_hw *hw = &adapter->hw;
359 359
360 if ((ec->rx_coalesce_usecs > IGBVF_MAX_ITR_USECS) || 360 if ((ec->rx_coalesce_usecs >= IGBVF_MIN_ITR_USECS) &&
361 ((ec->rx_coalesce_usecs > 3) && 361 (ec->rx_coalesce_usecs <= IGBVF_MAX_ITR_USECS)) {
362 (ec->rx_coalesce_usecs < IGBVF_MIN_ITR_USECS)) || 362 adapter->current_itr = ec->rx_coalesce_usecs << 2;
363 (ec->rx_coalesce_usecs == 2)) 363 adapter->requested_itr = 1000000000 /
364 return -EINVAL; 364 (adapter->current_itr * 256);
365 365 } else if ((ec->rx_coalesce_usecs == 3) ||
366 /* convert to rate of irq's per second */ 366 (ec->rx_coalesce_usecs == 2)) {
367 if (ec->rx_coalesce_usecs && ec->rx_coalesce_usecs <= 3) {
368 adapter->current_itr = IGBVF_START_ITR; 367 adapter->current_itr = IGBVF_START_ITR;
369 adapter->requested_itr = ec->rx_coalesce_usecs; 368 adapter->requested_itr = ec->rx_coalesce_usecs;
370 } else { 369 } else if (ec->rx_coalesce_usecs == 0) {
371 adapter->current_itr = ec->rx_coalesce_usecs << 2; 370 /*
371 * The user's desire is to turn off interrupt throttling
372 * altogether, but due to HW limitations, we can't do that.
373 * Instead we set a very small value in EITR, which would
374 * allow ~967k interrupts per second, but allow the adapter's
375 * internal clocking to still function properly.
376 */
377 adapter->current_itr = 4;
372 adapter->requested_itr = 1000000000 / 378 adapter->requested_itr = 1000000000 /
373 (adapter->current_itr * 256); 379 (adapter->current_itr * 256);
374 } 380 } else
381 return -EINVAL;
375 382
376 writel(adapter->current_itr, 383 writel(adapter->current_itr,
377 hw->hw_addr + adapter->rx_ring->itr_register); 384 hw->hw_addr + adapter->rx_ring->itr_register);