Commit 4a7fde55 authored by Arthur Kiyanovski's avatar Arthur Kiyanovski Committed by Kleber Sacilotto de Souza

UBUNTU: SAUCE: net: ena: fix issues in setting interrupt moderation params in ethtool

BugLink: https://bugs.launchpad.net/bugs/1853180

Issue 1:
--------
Reproduction steps:
1. sudo ethtool -C eth0 rx-usecs 128
2. sudo ethtool -C eth0 adaptive-rx on
3. sudo ethtool -C eth0 adaptive-rx off
4. ethtool -c eth0

expected output: rx-usecs 128
actual output: rx-usecs 0

Reason for issue:
In stage 3, ethtool userspace calls first the ena_get_coalesce() handler
to get the current value of all properties, and then the ena_set_coalesce()
handler. When ena_get_coalesce() is called the adaptive interrupt
moderation is still on. There is an if in the code that returns the
rx_coalesce_usecs only if the adaptive interrupt moderation is off.
And since it is still on, rx_coalesce_usecs is not set, meaning it
stays 0.

Solution to issue:
Remove this if static interrupt moderation intervals have nothing to do with
dynamic ones.

Issue 2:
--------
Reproduction steps:
1. sudo ethtool -C eth0 rx-usecs 128
2. sudo ethtool -C eth0 adaptive-rx on
3. sudo ethtool -C eth0 rx-usecs 128
4. ethtool -c eth0

expected output: rx-usecs 128
actual output: rx-usecs 0

Reason for issue:
In stage 3, when ena_set_coalesce() is called, the handler tests if
rx adaptive interrupt moderation is on, and if it is, it returns before
getting to the part in the function that sets the rx non-adaptive
interrupt moderation interval.

Solution to issue:
Remove the return from the function when rx adaptive interrupt moderation
is on.

Additional small fixes in this commit:
--------------------------------------
1. Remove 2 unnecessary comments.
2. Remove 4 unnecesary "{}" in single row if statements.
3. Reorder ena_set_coalesce() to make sense.
4. Change the names of ena_update_tx/rx_rings_intr_moderation()
   functions to ena_update_tx/rx_rings_nonadaptive_intr_moderation() for
   clarity.
Signed-off-by: default avatarArthur Kiyanovski <akiyano@amazon.com>
Reference: https://lore.kernel.org/netdev/1572868728-5211-1-git-send-email-akiyano@amazon.com/Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
Acked-by: default avatarKhaled Elmously <khalid.elmously@canonical.com>
Acked-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent 940cb3f5
......@@ -306,16 +306,13 @@ static int ena_get_coalesce(struct net_device *net_dev,
struct ena_adapter *adapter = netdev_priv(net_dev);
struct ena_com_dev *ena_dev = adapter->ena_dev;
if (!ena_com_interrupt_moderation_supported(ena_dev)) {
/* the devie doesn't support interrupt moderation */
if (!ena_com_interrupt_moderation_supported(ena_dev))
return -EOPNOTSUPP;
}
coalesce->tx_coalesce_usecs =
ena_com_get_nonadaptive_moderation_interval_tx(ena_dev) *
ena_dev->intr_delay_resolution;
if (!ena_com_get_adaptive_moderation_enabled(ena_dev))
coalesce->rx_coalesce_usecs =
ena_com_get_nonadaptive_moderation_interval_rx(ena_dev)
* ena_dev->intr_delay_resolution;
......@@ -326,7 +323,7 @@ static int ena_get_coalesce(struct net_device *net_dev,
return 0;
}
static void ena_update_tx_rings_intr_moderation(struct ena_adapter *adapter)
static void ena_update_tx_rings_nonadaptive_intr_moderation(struct ena_adapter *adapter)
{
unsigned int val;
int i;
......@@ -337,7 +334,7 @@ static void ena_update_tx_rings_intr_moderation(struct ena_adapter *adapter)
adapter->tx_ring[i].smoothed_interval = val;
}
static void ena_update_rx_rings_intr_moderation(struct ena_adapter *adapter)
static void ena_update_rx_rings_nonadaptive_intr_moderation(struct ena_adapter *adapter)
{
unsigned int val;
int i;
......@@ -355,35 +352,30 @@ static int ena_set_coalesce(struct net_device *net_dev,
struct ena_com_dev *ena_dev = adapter->ena_dev;
int rc;
if (!ena_com_interrupt_moderation_supported(ena_dev)) {
/* the devie doesn't support interrupt moderation */
if (!ena_com_interrupt_moderation_supported(ena_dev))
return -EOPNOTSUPP;
}
rc = ena_com_update_nonadaptive_moderation_interval_tx(ena_dev,
coalesce->tx_coalesce_usecs);
if (rc)
return rc;
ena_update_tx_rings_intr_moderation(adapter);
if (coalesce->use_adaptive_rx_coalesce) {
if (!ena_com_get_adaptive_moderation_enabled(ena_dev))
ena_com_enable_adaptive_moderation(ena_dev);
return 0;
}
ena_update_tx_rings_nonadaptive_intr_moderation(adapter);
rc = ena_com_update_nonadaptive_moderation_interval_rx(ena_dev,
coalesce->rx_coalesce_usecs);
if (rc)
return rc;
ena_update_rx_rings_intr_moderation(adapter);
ena_update_rx_rings_nonadaptive_intr_moderation(adapter);
if ((coalesce->use_adaptive_rx_coalesce) &&
(!ena_com_get_adaptive_moderation_enabled(ena_dev)))
ena_com_enable_adaptive_moderation(ena_dev);
if (!coalesce->use_adaptive_rx_coalesce) {
if (ena_com_get_adaptive_moderation_enabled(ena_dev))
if ((!coalesce->use_adaptive_rx_coalesce) &&
(ena_com_get_adaptive_moderation_enabled(ena_dev)))
ena_com_disable_adaptive_moderation(ena_dev);
}
return 0;
}
......
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