net: sparx5: fix RX ring stall on frames from inactive ports
Subsystems (4)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v5 1/2 net: sparx5: fix RX ring stall on frames from inactive ports
From: Zhang Hewei <[email protected]>
When the FDMA RX path receives a frame whose source port does not map to an active netdev, sparx5_fdma_rx_get_frame() logs an error, flushes the extraction FIFO and returns false - without advancing the FDMA software cursor and without releasing the skb, which has already been extended with skb_put().
The DCB for this frame still carries its hardware DONE bit, so the next NAPI poll picks up the same DCB, takes the same inactive-port branch and returns false again. The software cursor never moves past this DCB, so RX traffic on all ports stalls until the module is reloaded.
Treat a bogus frame as consumed: free the skb, clear its slot in the rx->skb[][] array and return true, so the NAPI loop advances past the DB the same way it does for any other received frame. The slot is refilled by sparx5_fdma_rx_dataptr_cb() when the DCB is recycled. The extraction FIFO flush is dropped since the frame is already consumed into the DB, and the error is ratelimited.
Testing: not tested on real hardware (no sparx5 system available); found by code inspection while auditing the RX error path.
--- drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c +5 -3
@@ -157,9 +157,11 @@ static bool sparx5_fdma_rx_get_frame(struct sparx5 *sparx5, struct sparx5_rx *rx sparx5->ports[fi.src_port] :NULL ;if (!port || !port->ndev) { -dev_err (sparx5->dev,"Data on inactive port %d\n" , fi.src_port); -sparx5_xtr_flush (sparx5,XTR_QUEUE ); -return false; +dev_err_ratelimited (sparx5->dev,"Data on inactive port %d\n" , + fi.src_port); +dev_kfree_skb_any (skb); + rx->skb[fdma->dcb_index][fdma->db_index] =NULL ; +return true; } skb->dev = port->ndev;skb_pull (skb,IFH_LEN *sizeof (u32));
Signature · 1 line
2.39.5 (Apple Git-154)
Daniel Machon
maintainerHi,
Quoted 34 lines
From: Zhang Hewei <[email protected]>
When the FDMA RX path receives a frame whose source port does not map to an active netdev,
sparx5_fdma_rx_get_frame()logs an error, flushes the extraction FIFO and returns false - without advancing the FDMA software cursor and without releasing the skb, which has already been extended withskb_put().The DCB for this frame still carries its hardware DONE bit, so the next NAPI poll picks up the same DCB, takes the same inactive-port branch and returns false again. The software cursor never moves past this DCB, so RX traffic on all ports stalls until the module is reloaded.
Treat a bogus frame as consumed: free the skb, clear its slot in the rx->skb[][] array and return true, so the NAPI loop advances past the DB the same way it does for any other received frame. The slot is refilled by
sparx5_fdma_rx_dataptr_cb()when the DCB is recycled. The extraction FIFO flush is dropped since the frame is already consumed into the DB, and the error is ratelimited.Testing: not tested on real hardware (no sparx5 system available); found by code inspection while auditing the RX error path.
Fixes 10615907e9b5 ("net: sparx5: switchdev: adding frame DMA functionality")Signed-off-by Zhang Hewei <[email protected]>--- drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c +0
-0
drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c static bool sparx5_fdma_rx_get_frame(struct sparx5 *sparx5, struct sparx5_rx *rx · line 162
Quoted 9 lines
drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c +3
-3@@ -157,9 +157,11 @@ static bool sparx5_fdma_rx_get_frame(struct sparx5 *sparx5, struct sparx5_rx *rx sparx5->ports[fi.src_port] :NULL ;if (!port || !port->ndev) { -dev_err (sparx5->dev,"Data on inactive port %d\n" , fi.src_port); -sparx5_xtr_flush (sparx5,XTR_QUEUE ); -return false; +dev_err_ratelimited (sparx5->dev,"Data on inactive port %d\n" , + fi.src_port); +dev_kfree_skb_any (skb);
I think kfree_skb is enough here.
drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c static bool sparx5_fdma_rx_get_frame(struct sparx5 *sparx5, struct sparx5_rx *rx · line 163
Quoted 1 line
drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c +1
-0+ rx->skb[fdma->dcb_index][fdma->db_index] =NULL ;
This store is not required.
Quoted 7 lines
drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c +1
-0+return true; } skb->dev = port->ndev;skb_pull (skb,IFH_LEN *sizeof (u32));Signature · 1 line
2.39.5 (Apple Git-154)
/Daniel
PATCH v5 2/2 net: lan969x: fix RX ring stall on frames from inactive ports
In reply to a message not in the archiveFrom: Zhang Hewei <[email protected]>
When a received frame's source port does not map to an active netdev, lan969x_fdma_rx_get_frame() recycles the page via the page pool and returns NULL, which makes lan969x_fdma_napi_poll() break out of the RX loop without advancing the FDMA software cursor.
As on sparx5, the DCB still carries its hardware DONE bit, so every following NAPI poll picks the same DCB, hits the same inactive-port branch and breaks again: RX traffic stalls on all ports until the module is reloaded.
Unify the NULL semantics: NULL always means "frame dropped, page recycled", covering both the inactive-port case and a failed build_skb(). The poll loop then advances past such a DB like it does for any other frame, dropping only the bogus frame and keeping RX alive. The WARN_ON() backtrace is also gone, which previously slowed RX to a crawl on every bad frame.
Testing: not tested on real hardware by the author (no lan969x system available). The drop-and-advance form was verified on lan969x hardware by Daniel Machon during review of v3.
--- .../microchip/sparx5/lan969x/lan969x_fdma.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/microchip/sparx5/lan969x/lan969x_fdma.c +8 -6
@@ -113,8 +113,12 @@ static struct sk_buff *lan969x_fdma_rx_get_frame(struct sparx5 *sparx5,sparx5_ifh_parse (sparx5,page_address (page), &fi); port = fi.src_port < consts->n_ports ? sparx5->ports[fi.src_port] :NULL ; -if (WARN_ON (!port)) - goto free_page; +if (!port) { +dev_err_ratelimited (sparx5->dev,"Data on inactive port %d\n" , + fi.src_port); +page_pool_recycle_direct (rx->page_pool, page); +return NULL ; + } skb =build_skb (page_address (page), fdma->db_size);if (unlikely (!skb))
@@ -258,10 +262,8 @@ int lan969x_fdma_napi_poll(struct napi_struct *napi, int weight)break ; skb =lan969x_fdma_rx_get_frame (sparx5, rx); -if (!skb) -break ; - -napi_gro_receive (&rx->napi, skb); +if (skb) +napi_gro_receive (&rx->napi, skb);fdma_db_advance (fdma); counter++;
Signature · 1 line
2.39.5 (Apple Git-154)
Daniel Machon
maintainerRe: [PATCH net v5 2/2] net: lan969x: fix RX ring stall on frames from inactive ports
Hi,
Quoted 34 lines
From: Zhang Hewei <[email protected]>
When a received frame's source port does not map to an active netdev,
lan969x_fdma_rx_get_frame()recycles the page via the page pool and returns NULL, which makeslan969x_fdma_napi_poll()break out of the RX loop without advancing the FDMA software cursor.As on sparx5, the DCB still carries its hardware DONE bit, so every following NAPI poll picks the same DCB, hits the same inactive-port branch and breaks again: RX traffic stalls on all ports until the module is reloaded.
Unify the NULL semantics: NULL always means "frame dropped, page recycled", covering both the inactive-port case and a failed
build_skb(). The poll loop then advances past such a DB like it does for any other frame, dropping only the bogus frame and keeping RX alive. TheWARN_ON()backtrace is also gone, which previously slowed RX to a crawl on every bad frame.Testing: not tested on real hardware by the author (no lan969x system available). The drop-and-advance form was verified on lan969x hardware by Daniel Machon during review of v3.
Fixes d84ad2c0d80c ("net: lan969x: add FDMA implementation")Signed-off-by Zhang Hewei <[email protected]>--- .../microchip/sparx5/lan969x/lan969x_fdma.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)drivers/net/ethernet/microchip/sparx5/lan969x/lan969x_fdma.c +0
-0
drivers/net/ethernet/microchip/sparx5/lan969x/lan969x_fdma.c static struct sk_buff *lan969x_fdma_rx_get_frame(struct sparx5 *sparx5, · line 120
Quoted 10 lines
drivers/net/ethernet/microchip/sparx5/lan969x/lan969x_fdma.c +5
-2@@ -113,8 +113,12 @@ static struct sk_buff *lan969x_fdma_rx_get_frame(struct sparx5 *sparx5,sparx5_ifh_parse (sparx5,page_address (page), &fi); port = fi.src_port < consts->n_ports ? sparx5->ports[fi.src_port] :NULL ; -if (WARN_ON (!port)) - goto free_page; +if (!port) { +dev_err_ratelimited (sparx5->dev,"Data on inactive port %d\n" , + fi.src_port); +page_pool_recycle_direct (rx->page_pool, page); +return NULL ;
As mentioned on v3, with the drop-and-advance in the poll loop the page_pool_recycle_direct() change is obsolete. The free_page label already does exactly this.
Quoted 20 lines
drivers/net/ethernet/microchip/sparx5/lan969x/lan969x_fdma.c +3
-4+ } skb =build_skb (page_address (page), fdma->db_size);if (unlikely (!skb))@@ -258,10 +262,8 @@ int lan969x_fdma_napi_poll(struct napi_struct *napi, int weight)break ; skb =lan969x_fdma_rx_get_frame (sparx5, rx); -if (!skb) -break ; - -napi_gro_receive (&rx->napi, skb); +if (skb) +napi_gro_receive (&rx->napi, skb);fdma_db_advance (fdma); counter++;Signature · 1 line
2.39.5 (Apple Git-154)
/Daniel