Skip to contentSkip to conversation

iavf: validate tx_coalesce_usecs even if rx_coalesce_usecs is zero

PATCH Superseded Jacob Keller 1 participant 1 message Nov 7, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iavf: validate tx_coalesce_usecs even if rx_coalesce_usecs is zero

In __iavf_set_coalesce, the driver checks both ec->rx_coalesce_usecs and ec->tx_coalesce_usecs for validity. It does this via a chain if if/else-if blocks. If every single branch of the series of if statements exited, this would be fine. However, the rx_coalesce_usecs is checked against zero to print an informative message if use_adaptive_rx_coalesce is enabled. If this check is true, it short circuits the entire chain of statements, preventing validation of the tx_coalesce_usecs field.

For example, the following ethtool command would allow programming a tx-usecs value outside the expected range:

 $ ethtool -C ens260f0v2 rx-usecs 0 tx-usecs 15000 adaptive-rx off adaptive-tx-off

As far as I can tell from code review, the result is the tx-usecs value getting bitwise truncated to fit the ITR register mask, incorrectly programming the Tx ITR value.

In addition, since commit e792779e6b63 ("iavf: Prevent changing static ITR values if adaptive moderation is on") the iavf driver actually rejects any change to the tx_coalesce_usecs or rx_coalesce_usecs when use_adaptive_tx_coalesce or use_adaptive_rx_coalesce is enabled. This check happens later in iavf_set_itr_per_queue(). The end result is that the existing check for adaptive-rx is irrelevant.

Fix this error by removing the unnecessary and redundant checks for use_adaptive_rx_coalesce and use_adaptive_tx_coalesce, preventing the short curcuit and ensuring that both the Tx and Rx ITR values are validated.

Fixes 65e87c0398f5 ("i40evf: support queue-specific settings for interrupt moderation")
---
 drivers/net/ethernet/intel/iavf/iavf_ethtool.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_ethtool.c +2 -8
index 6f236d1a6444..ee1702854451 100644
@@ -827,16 +827,10 @@ static int __iavf_set_coalesce(struct net_device *netdev,
 	struct iavf_adapter *adapter = netdev_priv(netdev);
 	int i;
 
-	if (ec->rx_coalesce_usecs == 0) {
-		if (ec->use_adaptive_rx_coalesce)
-			netif_info(adapter, drv, netdev, "rx-usecs=0, need to disable adaptive-rx for a complete disable\n");
-	} else if ((ec->rx_coalesce_usecs < IAVF_MIN_ITR) ||
-		   (ec->rx_coalesce_usecs > IAVF_MAX_ITR)) {
+	if ((ec->rx_coalesce_usecs < IAVF_MIN_ITR) ||
+	    (ec->rx_coalesce_usecs > IAVF_MAX_ITR)) {
 		netif_info(adapter, drv, netdev, "Invalid value, rx-usecs range is 0-8160\n");
 		return -EINVAL;
-	} else if (ec->tx_coalesce_usecs == 0) {
-		if (ec->use_adaptive_tx_coalesce)
-			netif_info(adapter, drv, netdev, "tx-usecs=0, need to disable adaptive-tx for a complete disable\n");
 	} else if ((ec->tx_coalesce_usecs < IAVF_MIN_ITR) ||
 		   (ec->tx_coalesce_usecs > IAVF_MAX_ITR)) {
 		netif_info(adapter, drv, netdev, "Invalid value, tx-usecs range is 0-8160\n");

base-commit: 21e5fd91eadd2d98429abcfc9e584ffb0bccd38f

Signature · 6 lines
2.41.0

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan