Skip to content

Commit 9d301a5

Browse files
Sean Andersonkuba-moo
authored andcommitted
net: xilinx: axienet: Report an error for bad coalesce settings
Instead of silently ignoring invalid/unsupported settings, report an error. Additionally, relax the check for non-zero usecs to apply only when it will be used (i.e. when frames != 1). Signed-off-by: Sean Anderson <[email protected]> Reviewed by: Shannon Nelson <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 5cff9d1 commit 9d301a5

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

drivers/net/ethernet/xilinx/xilinx_axienet_main.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,14 +2059,25 @@ axienet_ethtools_set_coalesce(struct net_device *ndev,
20592059
return -EINVAL;
20602060
}
20612061

2062-
if (ecoalesce->rx_max_coalesced_frames)
2063-
lp->coalesce_count_rx = ecoalesce->rx_max_coalesced_frames;
2064-
if (ecoalesce->rx_coalesce_usecs)
2065-
lp->coalesce_usec_rx = ecoalesce->rx_coalesce_usecs;
2066-
if (ecoalesce->tx_max_coalesced_frames)
2067-
lp->coalesce_count_tx = ecoalesce->tx_max_coalesced_frames;
2068-
if (ecoalesce->tx_coalesce_usecs)
2069-
lp->coalesce_usec_tx = ecoalesce->tx_coalesce_usecs;
2062+
if (!ecoalesce->rx_max_coalesced_frames ||
2063+
!ecoalesce->tx_max_coalesced_frames) {
2064+
NL_SET_ERR_MSG(extack, "frames must be non-zero");
2065+
return -EINVAL;
2066+
}
2067+
2068+
if ((ecoalesce->rx_max_coalesced_frames > 1 &&
2069+
!ecoalesce->rx_coalesce_usecs) ||
2070+
(ecoalesce->tx_max_coalesced_frames > 1 &&
2071+
!ecoalesce->tx_coalesce_usecs)) {
2072+
NL_SET_ERR_MSG(extack,
2073+
"usecs must be non-zero when frames is greater than one");
2074+
return -EINVAL;
2075+
}
2076+
2077+
lp->coalesce_count_rx = ecoalesce->rx_max_coalesced_frames;
2078+
lp->coalesce_usec_rx = ecoalesce->rx_coalesce_usecs;
2079+
lp->coalesce_count_tx = ecoalesce->tx_max_coalesced_frames;
2080+
lp->coalesce_usec_tx = ecoalesce->tx_coalesce_usecs;
20702081

20712082
return 0;
20722083
}

0 commit comments

Comments
 (0)