Thread View: linux.kernel.netdev
7 messages
7 total messages
Started by Nicolai Buchwitz
Sun, 22 Nov 2026 18:01
Re: [PATCH net] net: stmmac: retry a failed RX refill from a timer
Author: Nicolai Buchwitz
Date: Sun, 22 Nov 2026 18:01
Date: Sun, 22 Nov 2026 18:01
22 lines
9368 bytes
9368 bytes
Hi Anandu On 20.11.2026 08:49, Anandu Padinhare wrote: > [...] > @@ -6164,6 +6205,8 @@ static int stmmac_napi_poll_rx(struct napi_struct > *napi, int budget) > u64_stats_update_end(&rxq_stats->napi_syncp); > > work_done = stmmac_rx(priv, budget, chan); > + if (unlikely(stmmac_rx_refill_needed(priv, chan))) > + stmmac_rx_refill_timer_arm(ch); After a successful retry, doesn't this leave the last received frame in the ring until the next RX irq? Could the poll refill first? > [...] Regards, Nicolai
Re: [PATCH net] net: stmmac: retry a failed RX refill from a timer
Author: Sam Edwards
Date: Sun, 22 Nov 2026 20:20
Date: Sun, 22 Nov 2026 20:20
48 lines
14198 bytes
14198 bytes
On Sun, Nov 22, 2026 at 10:01 AM Nicolai Buchwitz <nb@tipi-net.de> wrote: > > Hi Anandu > > On 20.11.2026 08:49, Anandu Padinhare wrote: > > > [...] > > > @@ -6164,6 +6205,8 @@ static int stmmac_napi_poll_rx(struct napi_struct > > *napi, int budget) > > u64_stats_update_end(&rxq_stats->napi_syncp); > > > > work_done = stmmac_rx(priv, budget, chan); > > + if (unlikely(stmmac_rx_refill_needed(priv, chan))) > > + stmmac_rx_refill_timer_arm(ch); > > After a successful retry, doesn't this leave the last received frame in > the ring until the next RX irq? Could the poll refill first? Do you mean "first as well" or "first instead"? Because "instead" can cause avoidable packet loss: 1) Initially, network is idle and ring is full of empty DMA buffers 2) A burst of exactly one ring's worth of packets arrives 3) The RX irq fires and stmmac_rx() attempts its refill-first (none needed) then depletes the ring to the maximally-dirty state; the refill timer is armed 4) During the 10ms timer period, more traffic arrives 5) The RX irq doesn't fire again because no additional DMA is happening: there are no usable buffers in the ring. So we're forced to wait out the timer. 6) Any packets during this time (beyond the RxFIFO's capacity) are discarded by the hardware But, "first as well" sounds good to me: before entering the main loop, refill 1 buffer (if possible) just to ensure either the IRQ fires again immediately (if the FIFO is holding onto another packet for us), or the inaccessible ring slot is clean (if the FIFO is empty). Cheers, Sam > > > [...] > > Regards, > Nicolai
Re: [PATCH net] net: stmmac: retry a failed RX refill from a timer
Author: Nicolai Buchwitz
Date: Sun, 22 Nov 2026 20:37
Date: Sun, 22 Nov 2026 20:37
21 lines
9567 bytes
9567 bytes
On 22.11.2026 21:20, Sam Edwards wrote: > [...] >> After a successful retry, doesn't this leave the last received frame >> in >> the ring until the next RX irq? Could the poll refill first? > > Do you mean "first as well" or "first instead"? Because "instead" can > [...] > But, "first as well" sounds good to me: before entering the main loop, > refill 1 buffer (if possible) just to ensure either the IRQ fires > again immediately (if the FIFO is holding onto another packet for us), > or the inaccessible ring slot is clean (if the FIFO is empty). This (first as well). BR Nicolai
Re: [PATCH net] net: stmmac: retry a failed RX refill from a timer
Author: Sam Edwards
Date: Sun, 22 Nov 2026 21:02
Date: Sun, 22 Nov 2026 21:02
59 lines
14677 bytes
14677 bytes
On Sun, Nov 22, 2026 at 12:20 PM Sam Edwards <cfsworks@gmail.com> wrote: > > On Sun, Nov 22, 2026 at 10:01 AM Nicolai Buchwitz <nb@tipi-net.de> wrote: > > > > Hi Anandu > > > > On 20.11.2026 08:49, Anandu Padinhare wrote: > > > > > [...] > > > > > @@ -6164,6 +6205,8 @@ static int stmmac_napi_poll_rx(struct napi_struct > > > *napi, int budget) > > > u64_stats_update_end(&rxq_stats->napi_syncp); > > > > > > work_done = stmmac_rx(priv, budget, chan); > > > + if (unlikely(stmmac_rx_refill_needed(priv, chan))) > > > + stmmac_rx_refill_timer_arm(ch); > > > > After a successful retry, doesn't this leave the last received frame in > > the ring until the next RX irq? Could the poll refill first? > > Do you mean "first as well" or "first instead"? Because "instead" can > cause avoidable packet loss: > 1) Initially, network is idle and ring is full of empty DMA buffers > 2) A burst of exactly one ring's worth of packets arrives > 3) The RX irq fires and stmmac_rx() attempts its refill-first (none > needed) then depletes the ring to the maximally-dirty state; the > refill timer is armed Thinking about it more: the "unreachable packet" problem happens at this point too, even with the "first as well" behavior. Maybe the best way to resolve it is to adopt stmmac_rx_zc()'s behavior of refilling during the loop? > 4) During the 10ms timer period, more traffic arrives > 5) The RX irq doesn't fire again because no additional DMA is > happening: there are no usable buffers in the ring. So we're forced to > wait out the timer. > 6) Any packets during this time (beyond the RxFIFO's capacity) are > discarded by the hardware > > But, "first as well" sounds good to me: before entering the main loop, > refill 1 buffer (if possible) just to ensure either the IRQ fires > again immediately (if the FIFO is holding onto another packet for us), > or the inaccessible ring slot is clean (if the FIFO is empty). > > Cheers, > Sam > > > > > > [...] > > > > Regards, > > Nicolai
Re: [PATCH net] net: stmmac: retry a failed RX refill from a timer
Author: Nicolai Buchwitz
Date: Sun, 22 Nov 2026 21:09
Date: Sun, 22 Nov 2026 21:09
35 lines
10015 bytes
10015 bytes
Hi Sam On 22.11.2026 22:02, Sam Edwards wrote: > [...] >> Do you mean "first as well" or "first instead"? Because "instead" can >> cause avoidable packet loss: >> 1) Initially, network is idle and ring is full of empty DMA buffers >> 2) A burst of exactly one ring's worth of packets arrives >> 3) The RX irq fires and stmmac_rx() attempts its refill-first (none >> needed) then depletes the ring to the maximally-dirty state; the >> refill timer is armed > > Thinking about it more: the "unreachable packet" problem happens at > this point too, even with the "first as well" behavior. > > Maybe the best way to resolve it is to adopt stmmac_rx_zc()'s behavior > of refilling during the loop? > Only if the ring is no bigger than the NAPI budget, right? Otherwise tne poll can't empty it unless a refill failed, and refill first covers that. Refill in the loop sounds good, but this would be IMHO a net-next follow-up. > [...] Regards Nicolai
Re: [PATCH net] net: stmmac: retry a failed RX refill from a timer
Author: Sam Edwards
Date: Sun, 22 Nov 2026 21:34
Date: Sun, 22 Nov 2026 21:34
53 lines
14318 bytes
14318 bytes
On Sun, Nov 22, 2026 at 1:09 PM Nicolai Buchwitz <nb@tipi-net.de> wrote:
>
> Hi Sam
>
> On 22.11.2026 22:02, Sam Edwards wrote:
>
> > [...]
>
> >> Do you mean "first as well" or "first instead"? Because "instead" can
> >> cause avoidable packet loss:
> >> 1) Initially, network is idle and ring is full of empty DMA buffers
> >> 2) A burst of exactly one ring's worth of packets arrives
> >> 3) The RX irq fires and stmmac_rx() attempts its refill-first (none
> >> needed) then depletes the ring to the maximally-dirty state; the
> >> refill timer is armed
> >
> > Thinking about it more: the "unreachable packet" problem happens at
> > this point too, even with the "first as well" behavior.
> >
> > Maybe the best way to resolve it is to adopt stmmac_rx_zc()'s behavior
> > of refilling during the loop?
> >
>
> Only if the ring is no bigger than the NAPI budget, right?
Right, but as pointed out in b6cb4541853c7 ("net: stmmac: avoid rx
queue overrun" -- the commit that introduced the "leave one behind"
behavior) the ring can be as small as 64 and that commit's author was
seeing budgets larger than that.
Perhaps NAPI should only be told to stop polling if we either:
a) Reach the clean tail of the ring (so we *know* there are no further
packets for us)
b) Run out of memory and have to arm the retry timer
Thoughts?
Sam
>
> Otherwise tne poll can't empty it unless a refill failed, and refill
> first
> covers that.
>
> Refill in the loop sounds good, but this would be IMHO a net-next
> follow-up.
>
> > [...]
>
> Regards
> Nicolai
Re: [PATCH net] net: stmmac: retry a failed RX refill from a timer
Author: Nicolai Buchwitz
Date: Sun, 22 Nov 2026 22:14
Date: Sun, 22 Nov 2026 22:14
31 lines
10038 bytes
10038 bytes
On 22.11.2026 22:34, Sam Edwards wrote:
> [...]
>> Only if the ring is no bigger than the NAPI budget, right?
>
> Right, but as pointed out in b6cb4541853c7 ("net: stmmac: avoid rx
> queue overrun" -- the commit that introduced the "leave one behind"
> behavior) the ring can be as small as 64 and that commit's author was
> seeing budgets larger than that.
Fair, a 64 entry ring is enough to hit it.
>
> Perhaps NAPI should only be told to stop polling if we either:
> a) Reach the clean tail of the ring (so we *know* there are no further
> packets for us)
> b) Run out of memory and have to arm the retry timer
>
> Thoughts?
Agreed, simpler than refill in the loop. If stmmac_rx() stopped at
dirty_rx and the refill worked, return the full budget so NAPI polls
again.
Anandu, could you fold that into v2?
> [...]
Regards
Nicolai
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads