amd-xgbe: Configure and retrieve 'tx-usecs' for Tx coalescing
Subsystems (3)
PATCH v3 1/1 amd-xgbe: Configure and retrieve 'tx-usecs' for Tx coalescing
Ethtool has advanced with additional configurable options, but the current driver does not support tx-usecs configuration using Ethtool.
Add support to configure and retrieve 'tx-usecs' using ethtool, which specifies the wait time before servicing an interrupt for Tx coalescing.
---
v2 -> v3:
- Update the commit message.
- Ensure tx-usecs value must be non zero.
- Round tx-usecs to nearest multiple of jiffy granularity.
- Link to v2: https://lore.kernel.org/netdev/[email protected]/
v1 -> v2:
- Replace netdev_err() with extack interface for user error reporting.
- Link to v1: https://lore.kernel.org/netdev/[email protected]/
--- drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 28 ++++++++++++++++++-- drivers/net/ethernet/amd/xgbe/xgbe.h | 1 + 2 files changed, 27 insertions(+), 2 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c +26 -2
@@ -450,6 +450,7 @@ static int xgbe_get_coalesce(struct net_device *netdev, ec->rx_coalesce_usecs = pdata->rx_usecs; ec->rx_max_coalesced_frames = pdata->rx_frames; + ec->tx_coalesce_usecs = pdata->tx_usecs; ec->tx_max_coalesced_frames = pdata->tx_frames;return 0 ;
@@ -463,7 +464,8 @@ static int xgbe_set_coalesce(struct net_device *netdev,struct xgbe_prv_data *pdata =netdev_priv (netdev);struct xgbe_hw_if *hw_if = &pdata->hw_if;unsigned int rx_frames, rx_riwt, rx_usecs; -unsigned int tx_frames; +unsigned int tx_frames, tx_usecs; +unsigned int jiffy_us =jiffies_to_usecs (1 ); rx_riwt = hw_if->usec_to_riwt (pdata, ec->rx_coalesce_usecs); rx_usecs = ec->rx_coalesce_usecs;
@@ -485,20 +487,42 @@ static int xgbe_set_coalesce(struct net_device *netdev,return -EINVAL ; } + tx_usecs = ec->tx_coalesce_usecs; tx_frames = ec->tx_max_coalesced_frames;/* Check the bounds of values for Tx */ +if (!tx_usecs) { +NL_SET_ERR_MSG_FMT_MOD (extack, +"tx-usecs must not be 0" ); +return -EINVAL ; + } +if (tx_usecs >XGMAC_MAX_COAL_TX_TICK ) { +NL_SET_ERR_MSG_FMT_MOD (extack,"tx-usecs is limited to %d usec" , +XGMAC_MAX_COAL_TX_TICK ); +return -EINVAL ; + }if (tx_frames > pdata->tx_desc_count) {netdev_err (netdev,"tx-frames is limited to %d frames\n" , pdata->tx_desc_count);return -EINVAL ; } +/* Round tx-usecs to nearest multiple of jiffy granularity */ +if (tx_usecs % jiffy_us) { + tx_usecs =rounddown (tx_usecs, jiffy_us); +if (!tx_usecs) + tx_usecs = jiffy_us; +NL_SET_ERR_MSG_FMT_MOD (extack, +"tx-usecs rounded to %u usec due to jiffy granularity (%u usec)" , + tx_usecs, jiffy_us); + } + pdata->rx_riwt = rx_riwt; pdata->rx_usecs = rx_usecs; pdata->rx_frames = rx_frames; hw_if->config_rx_coalesce (pdata); + pdata->tx_usecs = tx_usecs; pdata->tx_frames = tx_frames; hw_if->config_tx_coalesce (pdata);
@@ -830,7 +854,7 @@ static int xgbe_set_channels(struct net_device *netdev, }static const struct ethtool_ops xgbe_ethtool_ops = { - .supported_coalesce_params =ETHTOOL_COALESCE_RX_USECS | + .supported_coalesce_params =ETHTOOL_COALESCE_USECS |ETHTOOL_COALESCE_MAX_FRAMES , .get_drvinfo = xgbe_get_drvinfo, .get_msglevel = xgbe_get_msglevel,
drivers/net/ethernet/amd/xgbe/xgbe.h +1 -0
@@ -272,6 +272,7 @@/* Default coalescing parameters */ #define XGMAC_INIT_DMA_TX_USECS 1000#define XGMAC_INIT_DMA_TX_FRAMES 25 +#define XGMAC_MAX_COAL_TX_TICK 100000#define XGMAC_MAX_DMA_RIWT 0xff#define XGMAC_INIT_DMA_RX_USECS 30
Signature · 1 line
2.34.1
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Sat, 16 Aug 2025 19:49:41 +0530 you wrote:
Ethtool has advanced with additional configurable options, but the current driver does not support tx-usecs configuration using Ethtool.
Add support to configure and retrieve 'tx-usecs' using ethtool, which specifies the wait time before servicing an interrupt for Tx coalescing.
Signed-off-by Vishal Badole <[email protected]>Acked-by Shyam Sundar S K <[email protected]>[...]
Here is the summary with links:
- [v3,net-next] amd-xgbe: Configure and retrieve 'tx-usecs' for Tx coalescing
https://git.kernel.org/netdev/net-next/c/5883cb32fcea
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html