Skip to content

Commit a206d99

Browse files
jacob-kelleranguy11
authored andcommitted
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. Indeed, since commit e792779 ("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, making this checking a bit redundant. Fix this error by removing the unnecessary and redundant checks for use_adaptive_rx_coalesce and use_adaptive_tx_coalesce. Since zero is a valid value, and since the tx_coalesce_usecs and rx_coalesce_usecs fields are already unsigned, remove the minimum value check. This allows assigning an ITR value ranging from 0-8160 as described by the printed message. Fixes: 65e87c0 ("i40evf: support queue-specific settings for interrupt moderation") Signed-off-by: Jacob Keller <[email protected]> Tested-by: Rafal Romanowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 7d9f22b commit a206d99

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

drivers/net/ethernet/intel/iavf/iavf_ethtool.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -827,18 +827,10 @@ static int __iavf_set_coalesce(struct net_device *netdev,
827827
struct iavf_adapter *adapter = netdev_priv(netdev);
828828
int i;
829829

830-
if (ec->rx_coalesce_usecs == 0) {
831-
if (ec->use_adaptive_rx_coalesce)
832-
netif_info(adapter, drv, netdev, "rx-usecs=0, need to disable adaptive-rx for a complete disable\n");
833-
} else if ((ec->rx_coalesce_usecs < IAVF_MIN_ITR) ||
834-
(ec->rx_coalesce_usecs > IAVF_MAX_ITR)) {
830+
if (ec->rx_coalesce_usecs > IAVF_MAX_ITR) {
835831
netif_info(adapter, drv, netdev, "Invalid value, rx-usecs range is 0-8160\n");
836832
return -EINVAL;
837-
} else if (ec->tx_coalesce_usecs == 0) {
838-
if (ec->use_adaptive_tx_coalesce)
839-
netif_info(adapter, drv, netdev, "tx-usecs=0, need to disable adaptive-tx for a complete disable\n");
840-
} else if ((ec->tx_coalesce_usecs < IAVF_MIN_ITR) ||
841-
(ec->tx_coalesce_usecs > IAVF_MAX_ITR)) {
833+
} else if (ec->tx_coalesce_usecs > IAVF_MAX_ITR) {
842834
netif_info(adapter, drv, netdev, "Invalid value, tx-usecs range is 0-8160\n");
843835
return -EINVAL;
844836
}

drivers/net/ethernet/intel/iavf/iavf_txrx.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
#define IAVF_ITR_DYNAMIC 0x8000 /* use top bit as a flag */
1717
#define IAVF_ITR_MASK 0x1FFE /* mask for ITR register value */
18-
#define IAVF_MIN_ITR 2 /* reg uses 2 usec resolution */
1918
#define IAVF_ITR_100K 10 /* all values below must be even */
2019
#define IAVF_ITR_50K 20
2120
#define IAVF_ITR_20K 50

0 commit comments

Comments
 (0)