* [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; 11+ 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] 11+ 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; 11+ 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 [flat|nested] 11+ 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; 11+ 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] 11+ 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-19 20:31 ` netdev-bot+sashiko 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, 2 replies; 11+ 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 [flat|nested] 11+ 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 2026-11-19 20:31 ` netdev-bot+sashiko 1 sibling, 0 replies; 11+ 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] 11+ 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 @ 2026-11-19 20:31 ` netdev-bot+sashiko 1 sibling, 0 replies; 11+ messages in thread From: netdev-bot+sashiko @ 2026-11-19 20:31 UTC (permalink / raw) To: nb Cc: opendmb, florian.fainelli, andrew+netdev, davem, edumazet, kuba, pabeni, justin.chen, pgynther, bcm-kernel-feedback-list, netdev, linux-kernel, f.fainelli Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 0 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] The patch fixes the 'cancelled profile work leaves DIM stuck in DIM_APPLY_NEW_PROFILE' bug only for close/open. -- net: bcmgenet: restart DIM from the default profile on ring init The patch clears struct dim in bcmgenet_init_dim() and sets profile_ix to NET_DIM_DEF_PROFILE_EQE. A close that cancels the pending DIM profile work can leave the state machine in DIM_APPLY_NEW_PROFILE, and this reset keeps it from staying stuck after the next open. > diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c > index 70c6a6465c81e..96620d2986777 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; [Severity: High] Can the same stuck DIM state still happen through Wake-on-LAN suspend/resume? The reset only runs from bcmgenet_init_dim(). Its only caller is bcmgenet_init_rx_ring(), which is reached through bcmgenet_init_dma(). The WoL branch of bcmgenet_suspend() goes through the same cancel that the commit message describes for close: bcmgenet_suspend() if (device_may_wakeup(d) && priv->wolopts) { ... bcmgenet_disable_rx_napi(priv); disable_irq(priv->irq1); ... } bcmgenet_disable_rx_napi() napi_disable(&ring->napi); cancel_work_sync(&ring->dim.dim.work); Suppose the last net_dim() call set dim->state = DIM_APPLY_NEW_PROFILE and scheduled the work just before this point. The work is cancelled, and bcmgenet_dim_work() never runs. It is the only place that moves the state back to DIM_START_MEASURE. On resume, the fast path in bcmgenet_resume() re-enables RX NAPI without reinitializing the rings: bcmgenet_resume() if (priv->tx_cbs && (reg & CMD_RX_EN)) { /* Successfully exited WoL, just resume data flows */ ... bcmgenet_enable_rx_napi(priv); That means bcmgenet_init_dim() is not called, so the new memset and profile_ix reset never run. After that, every net_dim() call hits: case DIM_APPLY_NEW_PROFILE: break; Adaptive RX coalescing stays frozen until the next ifdown/ifup. Also, profile_ix already points at the new profile, while the DMA_MBUF_DONE_THRESH and DMA_RING0_TIMEOUT registers still hold the old values. Toggling adaptive coalescing through ethtool doesn't seem to recover from this, since bcmgenet_set_ring_rx_coalesce() never touches dim.state. Would it work better to reset ring->dim.dim.state, and re-sync profile_ix, in bcmgenet_disable_rx_napi() right after cancel_work_sync()? That would cover both close and WoL suspend. The later patches in this series ("net: bcmgenet: reset the Rx discard count with the ring" and "net: systemport: accumulate the DIM packet and byte counters") don't touch this path, so the gap is still there at the end of the series. > dim->event_ctr = 0; > dim->packets = 0; > dim->bytes = 0; -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118-nb-genet-dim-stats-net-v1-0-13b275f1e088%40tipi-net.de ^ permalink raw reply [flat|nested] 11+ 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; 11+ 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 [flat|nested] 11+ 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; 11+ 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] 11+ 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 2026-11-19 20:31 ` netdev-bot+sashiko 3 siblings, 2 replies; 11+ 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 [flat|nested] 11+ 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 2026-11-19 20:31 ` netdev-bot+sashiko 1 sibling, 0 replies; 11+ 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] 11+ 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 @ 2026-11-19 20:31 ` netdev-bot+sashiko 1 sibling, 0 replies; 11+ messages in thread From: netdev-bot+sashiko @ 2026-11-19 20:31 UTC (permalink / raw) To: nb Cc: opendmb, florian.fainelli, andrew+netdev, davem, edumazet, kuba, pabeni, justin.chen, pgynther, bcm-kernel-feedback-list, netdev, linux-kernel, f.fainelli Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 (2) · Low: 0 (1) If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] This patch makes priv->dim.packets and priv->dim.bytes running totals in bcm_sysport_desc_rx(). Pre-existing issues: - [Medium] When net_dim_decision() changes the profile, net_dim() sets dim->state = DIM_APPLY_NEW_PROFILE and calls schedule_work(&dim->work). - [Medium] bcm_sysport_set_coalesce() can turn off adaptive RX coalescing (priv->dim.use_dim = 0) and write the user's static rx usecs/frames… - [Low] When use_dim is set, bcm_sysport_init_rx_coalesce() (and bcm_sysport_set_coalesce() when DIM is enabled) writes… -- net: systemport: accumulate the DIM packet and byte counters This commit makes bcm_sysport_desc_rx() add the per-poll packet and byte counts to priv->dim.packets and priv->dim.bytes. Before, it overwrote them. net_dim() computes rates from the difference between samples, so it needs running totals. > diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c > index bc88a27da16be..d3041ad606981 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; [Severity: Medium] Now that these are running totals, can the first net_dim() sample after each open or resume still give wrong rates? bcm_sysport_netif_start() calls bcm_sysport_init_dim() on every open and resume. That function sets the counters back to 0 but does not touch the embedded struct dim: drivers/net/ethernet/broadcom/bcmsysport.c:bcm_sysport_init_dim() { ... INIT_WORK(&dim->dim.work, cb); dim->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE; dim->event_ctr = 0; dim->packets = 0; dim->bytes = 0; } So dim->dim.state, start_sample, prev_stats and profile_ix all carry over from the previous session. At close the state is usually DIM_MEASURE_IN_PROGRESS, and start_sample holds the last large totals. On the first bcm_sysport_poll() after reopen, net_dim() compares the reset counters against that old start_sample. The u16 event gap wraps to roughly 65536 - E_old, which is at least DIM_NEVENTS, so the measurement is accepted right away. dim_calc_stats() then sees packet and byte deltas close to 2^32, and a delta_us that covers the whole downtime. net_dim_decision() can then step profile_ix based on those values and schedule bcm_sysport_dim_work(). The prev_stats left behind also skews the next comparison. Turning adaptive RX coalescing off and on again in bcm_sysport_set_coalesce() has a similar effect. desc_rx keeps adding to the counters while net_dim() is not called, so the first decision after re-enabling uses a start_sample that may be minutes old. The bcmgenet commit in this series, "net: bcmgenet: restart DIM from the default profile on ring init", handles this by resetting the whole struct: drivers/net/ethernet/broadcom/genet/bcmgenet.c:bcmgenet_init_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; ... } Would bcm_sysport_init_dim() need the same reset for this fix to cover close/open, suspend/resume and DIM off/on? [Severity: Low] This is a pre-existing issue, but bcm_sysport_init_dim() never sets dim->dim.profile_ix. When use_dim is set, bcm_sysport_init_rx_coalesce() programs the default EQE profile: drivers/net/ethernet/broadcom/bcmsysport.c:bcm_sysport_init_rx_coalesce() { ... if (dim->use_dim) { moder = net_dim_get_def_rx_moderation(dim->dim.mode); ... } That is profile index NET_DIM_DEF_PROFILE_EQE (1). Meanwhile profile_ix is 0 on first open, and after a close/open it is whatever the last session left behind. Does net_dim_step() then walk the profile table from a base that differs from what RDMA_MBDONE_INTR actually holds? bcmgenet_init_dim() sets profile_ix = NET_DIM_DEF_PROFILE_EQE for this reason. [Severity: Medium] This isn't a bug introduced by this patch, but can DIM get stuck in DIM_APPLY_NEW_PROFILE across a close/open? When net_dim() changes the profile, it sets DIM_APPLY_NEW_PROFILE and schedules the work. The only code that clears that state is the work item: drivers/net/ethernet/broadcom/bcmsysport.c:bcm_sysport_dim_work() { ... bcm_sysport_set_rx_coalesce(priv, cur_profile.usec, cur_profile.pkts); dim->state = DIM_START_MEASURE; } If the interface is closed or suspended while that work is pending, it gets cancelled: drivers/net/ethernet/broadcom/bcmsysport.c:bcm_sysport_netif_stop() { ... napi_disable(&priv->napi); cancel_work_sync(&priv->dim.dim.work); ... } On the next open or resume, bcm_sysport_init_dim() does not reset dim->dim.state. Every later net_dim() call then hits: lib/dim/net_dim.c:net_dim() { ... case DIM_APPLY_NEW_PROFILE: break; ... } Nothing reschedules the work, and bcm_sysport_set_coalesce() does not reset the state either. Would adaptive RX coalescing stay frozen until the driver is reloaded, so the corrected totals from this patch are never evaluated? The bcmgenet commit in this series fixes the same problem there. [Severity: Medium] This is a pre-existing issue, but can a pending DIM work item overwrite static coalescing settings that were just configured through ethtool? bcm_sysport_set_coalesce() turns DIM off and writes the static values without cancelling or flushing priv->dim.dim.work: drivers/net/ethernet/broadcom/bcmsysport.c:bcm_sysport_set_coalesce() { ... priv->dim.use_dim = ec->use_adaptive_rx_coalesce; /* Apply desired coalescing parameters */ bcm_sysport_set_rx_coalesce(priv, usecs, pkts); ... } If net_dim() has just queued the work, bcm_sysport_dim_work() can run after this. It does not check priv->dim.use_dim, and it calls bcm_sysport_set_rx_coalesce() with the profile_ix values. Once use_dim is 0, net_dim() is no longer called, so nothing puts the static values back. The hardware would then keep a DIM-chosen setting, while priv->rx_coalesce_usecs, rx_max_coalesced_frames and use_dim say something else. The two callers' read-modify-writes of RDMA_MBDONE_INTR in bcm_sysport_set_rx_coalesce() are also not serialized against each other. > > return processed; > } -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118-nb-genet-dim-stats-net-v1-0-13b275f1e088%40tipi-net.de ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-11-19 20:31 UTC | newest] Thread overview: 11+ 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-19 20:31 ` netdev-bot+sashiko 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 2026-11-19 20:31 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®