Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] net: stmmac: Cleanup rx coalescing computation when using RIWT
@ 2026-08-02 11:40 Maxime Chevallier
  2026-08-02 11:40 ` [PATCH net-next 1/2] net: stmmac: ethtool: Comment the magic numbers in RIWT computation Maxime Chevallier
  2026-08-02 11:40 ` [PATCH net-next 2/2] net: stmmac: ethtool: Address off-by-one when reading the coal rx-usecs Maxime Chevallier
  0 siblings, 2 replies; 5+ messages in thread
From: Maxime Chevallier @ 2026-08-02 11:40 UTC (permalink / raw)
  To: Andrew Lunn, Jakub Kicinski, davem, Eric Dumazet, Paolo Abeni,
	Simon Horman, Maxime Coquelin, Alexandre Torgue, Russell King
  Cc: Maxime Chevallier, thomas.petazzoni, Alexis Lothoré, netdev,
	linux-kernel, linux-arm-kernel, linux-stm32

Currently when configuring interrupt coalescing on devices that relies
on the Receive Interrupt Watchdog Timer feature of dwmac, the
computation of the RIWT timings leads to off-by-one values when
reporting the timings back to userspace.

RIWT works by arming a watchdog timer upon receiving frames with the RI
bit not set in the descriptor. The timer duration is expressed in units
of 256 stmmac clock ticks, and therefore requires a bit of computation
to derive it :

riwt = (rx_usecs * n_clk_ticks_per_usec) / 256

and conversely

rx_usecs = (riwt * 256) / n_clk_ticks_per_usec

This computation as-is leads to a consistent off-by-one when setting
then getting back the rx-usecs value due to rounding errors (by truncation):

ethtool -C eth1 rx-usecs 42
ethtool -c eth1
 -> reports rx-usecs: 41

Let's use DIV_ROUND_CLOSEST instead for the computations. It does have
one side effect, the accepted boundaries for rx-usecs also shifts by one
now, going from [16us, 246us] to [15us, 245us]. For that reason, I'm not
targeting the net tree here, and it's overall a very small issue.

Maxime

Maxime Chevallier (2):
  net: stmmac: ethtool: Comment the magic numbers in RIWT computation
  net: stmmac: ethtool: Address off-by-one when reading the coal
    rx-usecs

 drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

-- 
2.55.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-02 15:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-02 11:40 [PATCH net-next 0/2] net: stmmac: Cleanup rx coalescing computation when using RIWT Maxime Chevallier
2026-08-02 11:40 ` [PATCH net-next 1/2] net: stmmac: ethtool: Comment the magic numbers in RIWT computation Maxime Chevallier
2026-08-02 15:02   ` Andrew Lunn
2026-08-02 11:40 ` [PATCH net-next 2/2] net: stmmac: ethtool: Address off-by-one when reading the coal rx-usecs Maxime Chevallier
2026-08-02 15:05   ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox