* [PATCH net 0/4] net: bcmgenet, systemport: DIM and Rx discard fixes
@ 2026-11-18 19:55 Nicolai Buchwitz
2026-11-18 19:55 ` [PATCH net 1/4] net: bcmgenet: accumulate the DIM packet and byte counters Nicolai Buchwitz
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Nicolai Buchwitz @ 2026-11-18 19:55 UTC (permalink / raw)
To: Doug Berger, Florian Fainelli, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Nicolai Buchwitz
Cc: Justin Chen, Petri Gynther, Broadcom internal kernel review list,
netdev, linux-kernel, Florian Fainelli
Sashiko has flagged a few genet bugs over time. I'll work through them
as time permits, fixing the ones that seem worth it.
DIM on genet and systemport wants running totals but gets per-poll
counts, so it picks bogus profiles from the wrong numbers.
The series also fixes DIM getting stuck after a down/up and resets the
Rx discard count with the ring.
Patches 1-3 have been tested on a Raspberry Pi CM4. I don't have any
systemport hardware, but the bug there is the same.
---
Nicolai Buchwitz (4):
net: bcmgenet: accumulate the DIM packet and byte counters
net: bcmgenet: restart DIM from the default profile on ring init
net: bcmgenet: reset the Rx discard count with the ring
net: systemport: accumulate the DIM packet and byte counters
drivers/net/ethernet/broadcom/bcmsysport.c | 4 ++--
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 9 +++++++--
2 files changed, 9 insertions(+), 4 deletions(-)
---
base-commit: 2a324a58a084c5cfd7e5a2f55e0786bee170a4a5
change-id: 20261118-nb-genet-dim-stats-net-b6b6fd30398f
Best regards,
--
Nicolai Buchwitz <nb@tipi-net.de>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net 1/4] net: bcmgenet: accumulate the DIM packet and byte counters
2026-11-18 19:55 [PATCH net 0/4] net: bcmgenet, systemport: DIM and Rx discard fixes Nicolai Buchwitz
@ 2026-11-18 19:55 ` Nicolai Buchwitz
2026-11-18 19:58 ` Florian Fainelli
2026-11-18 19:55 ` [PATCH net 2/4] net: bcmgenet: restart DIM from the default profile on ring init Nicolai Buchwitz
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Nicolai Buchwitz @ 2026-11-18 19:55 UTC (permalink / raw)
To: Doug Berger, Florian Fainelli, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Nicolai Buchwitz
Cc: Justin Chen, Petri Gynther, Broadcom internal kernel review list,
netdev, linux-kernel, Florian Fainelli
net_dim() computes rates from the difference between two samples and
needs running totals, but bcmgenet_desc_rx() passes the counts of the
last poll. Adaptive coalescing then picks profiles from wrong rates.
On a CM4 at a steady 300 Mbit/s UDP, DIM changed profile about 1000
times in 20 s. With the fix it settles, and Rx interrupts drop from about
4500/s to 2240/s.
Accumulate the counters instead.
Fixes: 9f4ca05827a2 ("net: bcmgenet: Add support for adaptive RX coalescing")
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
---
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 4d2be2a21ed1..70c6a6465c81 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2486,8 +2486,8 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring,
bcmgenet_rdma_ring_writel(priv, ring->index, ring->c_index, RDMA_CONS_INDEX);
}
- ring->dim.bytes = bytes_processed;
- ring->dim.packets = rxpktprocessed;
+ ring->dim.bytes += bytes_processed;
+ ring->dim.packets += rxpktprocessed;
return rxpktprocessed;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net 2/4] net: bcmgenet: restart DIM from the default profile on ring init
2026-11-18 19:55 [PATCH net 0/4] net: bcmgenet, systemport: DIM and Rx discard fixes Nicolai Buchwitz
2026-11-18 19:55 ` [PATCH net 1/4] net: bcmgenet: accumulate the DIM packet and byte counters Nicolai Buchwitz
@ 2026-11-18 19:55 ` Nicolai Buchwitz
2026-11-18 20:00 ` Florian Fainelli
2026-11-18 19:55 ` [PATCH net 3/4] net: bcmgenet: reset the Rx discard count with the ring Nicolai Buchwitz
2026-11-18 19:55 ` [PATCH net 4/4] net: systemport: accumulate the DIM packet and byte counters Nicolai Buchwitz
3 siblings, 1 reply; 9+ messages in thread
From: Nicolai Buchwitz @ 2026-11-18 19:55 UTC (permalink / raw)
To: Doug Berger, Florian Fainelli, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Nicolai Buchwitz
Cc: Justin Chen, Petri Gynther, Broadcom internal kernel review list,
netdev, linux-kernel, Florian Fainelli
A close can cancel the pending profile work and leave DIM in
DIM_APPLY_NEW_PROFILE, where net_dim() does nothing. Adaptive coalescing
then stays stuck after the next open.
Reset the DIM state on ring init and start from the default profile,
which is what bcmgenet_init_rx_coalesce() programs.
Fixes: 9f4ca05827a2 ("net: bcmgenet: Add support for adaptive RX coalescing")
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
---
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 70c6a6465c81..96620d298677 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2702,8 +2702,11 @@ static void bcmgenet_init_dim(struct bcmgenet_rx_ring *ring,
{
struct bcmgenet_net_dim *dim = &ring->dim;
+ memset(&dim->dim, 0, sizeof(dim->dim));
INIT_WORK(&dim->dim.work, cb);
dim->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE;
+ /* Match the profile bcmgenet_init_rx_coalesce() programs */
+ dim->dim.profile_ix = NET_DIM_DEF_PROFILE_EQE;
dim->event_ctr = 0;
dim->packets = 0;
dim->bytes = 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net 3/4] net: bcmgenet: reset the Rx discard count with the ring
2026-11-18 19:55 [PATCH net 0/4] net: bcmgenet, systemport: DIM and Rx discard fixes Nicolai Buchwitz
2026-11-18 19:55 ` [PATCH net 1/4] net: bcmgenet: accumulate the DIM packet and byte counters Nicolai Buchwitz
2026-11-18 19:55 ` [PATCH net 2/4] net: bcmgenet: restart DIM from the default profile on ring init Nicolai Buchwitz
@ 2026-11-18 19:55 ` Nicolai Buchwitz
2026-11-18 20:00 ` Florian Fainelli
2026-11-18 19:55 ` [PATCH net 4/4] net: systemport: accumulate the DIM packet and byte counters Nicolai Buchwitz
3 siblings, 1 reply; 9+ messages in thread
From: Nicolai Buchwitz @ 2026-11-18 19:55 UTC (permalink / raw)
To: Doug Berger, Florian Fainelli, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Nicolai Buchwitz
Cc: Justin Chen, Petri Gynther, Broadcom internal kernel review list,
netdev, linux-kernel, Florian Fainelli
Ring init clears the hardware discard counter but not
ring->old_discards. Discards after an ifdown and ifup or a resume are
then missing from rx_missed. On a CM4, after an ifdown and ifup, 3666
discards showed up as 0 in rx_missed.
Reset old_discards together with the ring.
Fixes: d26ea6cc48da ("net: bcmgenet: collect Rx discarded packet count")
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
---
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 96620d298677..69c6139d3b23 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2825,6 +2825,8 @@ static int bcmgenet_init_rx_ring(struct bcmgenet_priv *priv,
ring->read_ptr = start_ptr;
ring->cb_ptr = start_ptr;
ring->end_ptr = end_ptr - 1;
+ /* Zeroing RDMA_PROD_INDEX below also clears the discard counter */
+ ring->old_discards = 0;
ret = bcmgenet_rx_ring_create_pool(priv, ring);
if (ret)
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net 4/4] net: systemport: accumulate the DIM packet and byte counters
2026-11-18 19:55 [PATCH net 0/4] net: bcmgenet, systemport: DIM and Rx discard fixes Nicolai Buchwitz
` (2 preceding siblings ...)
2026-11-18 19:55 ` [PATCH net 3/4] net: bcmgenet: reset the Rx discard count with the ring Nicolai Buchwitz
@ 2026-11-18 19:55 ` Nicolai Buchwitz
2026-11-18 20:00 ` Florian Fainelli
3 siblings, 1 reply; 9+ messages in thread
From: Nicolai Buchwitz @ 2026-11-18 19:55 UTC (permalink / raw)
To: Doug Berger, Florian Fainelli, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Nicolai Buchwitz
Cc: Justin Chen, Petri Gynther, Broadcom internal kernel review list,
netdev, linux-kernel, Florian Fainelli
net_dim() computes rates from the difference between two samples and
needs running totals, but bcm_sysport_desc_rx() passes the counts of the
last poll. Adaptive coalescing then picks profiles from wrong rates.
Accumulate the counters instead.
Fixes: b6e0e875421e ("net: systemport: Implement adaptive interrupt coalescing")
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
---
drivers/net/ethernet/broadcom/bcmsysport.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index bc88a27da16b..d3041ad60698 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -844,8 +844,8 @@ static unsigned int bcm_sysport_desc_rx(struct bcm_sysport_priv *priv,
priv->rx_read_ptr = 0;
}
- priv->dim.packets = processed;
- priv->dim.bytes = processed_bytes;
+ priv->dim.packets += processed;
+ priv->dim.bytes += processed_bytes;
return processed;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net 1/4] net: bcmgenet: accumulate the DIM packet and byte counters
2026-11-18 19:55 ` [PATCH net 1/4] net: bcmgenet: accumulate the DIM packet and byte counters Nicolai Buchwitz
@ 2026-11-18 19:58 ` Florian Fainelli
0 siblings, 0 replies; 9+ messages in thread
From: Florian Fainelli @ 2026-11-18 19:58 UTC (permalink / raw)
To: Nicolai Buchwitz, Doug Berger, Florian Fainelli, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Justin Chen, Petri Gynther, Broadcom internal kernel review list,
netdev, linux-kernel
On 11/18/26 11:55, Nicolai Buchwitz wrote:
> net_dim() computes rates from the difference between two samples and
> needs running totals, but bcmgenet_desc_rx() passes the counts of the
> last poll. Adaptive coalescing then picks profiles from wrong rates.
>
> On a CM4 at a steady 300 Mbit/s UDP, DIM changed profile about 1000
> times in 20 s. With the fix it settles, and Rx interrupts drop from about
> 4500/s to 2240/s.
>
> Accumulate the counters instead.
>
> Fixes: 9f4ca05827a2 ("net: bcmgenet: Add support for adaptive RX coalescing")
> Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net 2/4] net: bcmgenet: restart DIM from the default profile on ring init
2026-11-18 19:55 ` [PATCH net 2/4] net: bcmgenet: restart DIM from the default profile on ring init Nicolai Buchwitz
@ 2026-11-18 20:00 ` Florian Fainelli
0 siblings, 0 replies; 9+ messages in thread
From: Florian Fainelli @ 2026-11-18 20:00 UTC (permalink / raw)
To: Nicolai Buchwitz, Doug Berger, Florian Fainelli, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Justin Chen, Petri Gynther, Broadcom internal kernel review list,
netdev, linux-kernel
On 11/18/26 11:55, Nicolai Buchwitz wrote:
> A close can cancel the pending profile work and leave DIM in
> DIM_APPLY_NEW_PROFILE, where net_dim() does nothing. Adaptive coalescing
> then stays stuck after the next open.
>
> Reset the DIM state on ring init and start from the default profile,
> which is what bcmgenet_init_rx_coalesce() programs.
>
> Fixes: 9f4ca05827a2 ("net: bcmgenet: Add support for adaptive RX coalescing")
> Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net 3/4] net: bcmgenet: reset the Rx discard count with the ring
2026-11-18 19:55 ` [PATCH net 3/4] net: bcmgenet: reset the Rx discard count with the ring Nicolai Buchwitz
@ 2026-11-18 20:00 ` Florian Fainelli
0 siblings, 0 replies; 9+ messages in thread
From: Florian Fainelli @ 2026-11-18 20:00 UTC (permalink / raw)
To: Nicolai Buchwitz, Doug Berger, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Justin Chen, Petri Gynther, Broadcom internal kernel review list,
netdev, linux-kernel, Florian Fainelli
On 11/18/26 11:55, Nicolai Buchwitz wrote:
> Ring init clears the hardware discard counter but not
> ring->old_discards. Discards after an ifdown and ifup or a resume are
> then missing from rx_missed. On a CM4, after an ifdown and ifup, 3666
> discards showed up as 0 in rx_missed.
>
> Reset old_discards together with the ring.
>
> Fixes: d26ea6cc48da ("net: bcmgenet: collect Rx discarded packet count")
> Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net 4/4] net: systemport: accumulate the DIM packet and byte counters
2026-11-18 19:55 ` [PATCH net 4/4] net: systemport: accumulate the DIM packet and byte counters Nicolai Buchwitz
@ 2026-11-18 20:00 ` Florian Fainelli
0 siblings, 0 replies; 9+ messages in thread
From: Florian Fainelli @ 2026-11-18 20:00 UTC (permalink / raw)
To: Nicolai Buchwitz, Doug Berger, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Justin Chen, Petri Gynther, Broadcom internal kernel review list,
netdev, linux-kernel, Florian Fainelli
On 11/18/26 11:55, Nicolai Buchwitz wrote:
> net_dim() computes rates from the difference between two samples and
> needs running totals, but bcm_sysport_desc_rx() passes the counts of the
> last poll. Adaptive coalescing then picks profiles from wrong rates.
>
> Accumulate the counters instead.
>
> Fixes: b6e0e875421e ("net: systemport: Implement adaptive interrupt coalescing")
> Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-11-18 20:00 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 19:55 [PATCH net 0/4] net: bcmgenet, systemport: DIM and Rx discard fixes Nicolai Buchwitz
2026-11-18 19:55 ` [PATCH net 1/4] net: bcmgenet: accumulate the DIM packet and byte counters Nicolai Buchwitz
2026-11-18 19:58 ` Florian Fainelli
2026-11-18 19:55 ` [PATCH net 2/4] net: bcmgenet: restart DIM from the default profile on ring init Nicolai Buchwitz
2026-11-18 20:00 ` Florian Fainelli
2026-11-18 19:55 ` [PATCH net 3/4] net: bcmgenet: reset the Rx discard count with the ring Nicolai Buchwitz
2026-11-18 20:00 ` Florian Fainelli
2026-11-18 19:55 ` [PATCH net 4/4] net: systemport: accumulate the DIM packet and byte counters Nicolai Buchwitz
2026-11-18 20:00 ` Florian Fainelli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox