Commit 0e90b49c authored by Mitch A Williams's avatar Mitch A Williams Committed by David S. Miller

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: default avatarMitch Williams <mitch.a.williams@intel.com>
Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0c12d91b
...@@ -357,21 +357,28 @@ static int igbvf_set_coalesce(struct net_device *netdev, ...@@ -357,21 +357,28 @@ static int igbvf_set_coalesce(struct net_device *netdev,
struct igbvf_adapter *adapter = netdev_priv(netdev); struct igbvf_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw; struct e1000_hw *hw = &adapter->hw;
if ((ec->rx_coalesce_usecs > IGBVF_MAX_ITR_USECS) || if ((ec->rx_coalesce_usecs >= IGBVF_MIN_ITR_USECS) &&
((ec->rx_coalesce_usecs > 3) && (ec->rx_coalesce_usecs <= IGBVF_MAX_ITR_USECS)) {
(ec->rx_coalesce_usecs < IGBVF_MIN_ITR_USECS)) || adapter->current_itr = ec->rx_coalesce_usecs << 2;
(ec->rx_coalesce_usecs == 2)) adapter->requested_itr = 1000000000 /
return -EINVAL; (adapter->current_itr * 256);
} else if ((ec->rx_coalesce_usecs == 3) ||
/* convert to rate of irq's per second */ (ec->rx_coalesce_usecs == 2)) {
if (ec->rx_coalesce_usecs && ec->rx_coalesce_usecs <= 3) {
adapter->current_itr = IGBVF_START_ITR; adapter->current_itr = IGBVF_START_ITR;
adapter->requested_itr = ec->rx_coalesce_usecs; adapter->requested_itr = ec->rx_coalesce_usecs;
} else { } else if (ec->rx_coalesce_usecs == 0) {
adapter->current_itr = ec->rx_coalesce_usecs << 2; /*
* The user's desire is to turn off interrupt throttling
* altogether, but due to HW limitations, we can't do that.
* Instead we set a very small value in EITR, which would
* allow ~967k interrupts per second, but allow the adapter's
* internal clocking to still function properly.
*/
adapter->current_itr = 4;
adapter->requested_itr = 1000000000 / adapter->requested_itr = 1000000000 /
(adapter->current_itr * 256); (adapter->current_itr * 256);
} } else
return -EINVAL;
writel(adapter->current_itr, writel(adapter->current_itr,
hw->hw_addr + adapter->rx_ring->itr_register); hw->hw_addr + adapter->rx_ring->itr_register);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment