net: tsec: Improve receive error path
cover net: tsec: Improve receive error path
Currently, errors in the receive path of the TSEC Ethernet driver result in an exhaustion of packet buffer descriptors. This series fixes it.
---
J. Neuschäfer (2):
net: tsec: Reorder tsec_recv and tsec_free_pkt
net: tsec: Re-arm packet buffer in error case
drivers/net/tsec.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-)
---
base-commit: 5919f48b1c751b85453adca96493ab16f9098be0
change-id: 20250216-tsec-2acd62b9f844
Best regards,
Signature · 1 line
J. Neuschäfer <[email protected]>
PATCH 1/2 net: tsec: Reorder tsec_recv and tsec_free_pkt
This is necessary for the following patch. No functional change.
--- drivers/net/tsec.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/net/tsec.c +18 -18
@@ -278,6 +278,24 @@ static int tsec_send(struct udevice *dev, void *packet, int length)return result; } +static int tsec_free_pkt (struct udevice *dev,uchar *packet,int length) +{ +struct tsec_private *priv = (struct tsec_private *)dev_get_priv (dev); +u16 status; + +out_be16 (&priv->rxbd[priv->rx_idx].length,0 ); + + status =RXBD_EMPTY ; +/* Set the wrap bit if this is the last element in the list */ +if ((priv->rx_idx +1 ) ==PKTBUFSRX ) + status |=RXBD_WRAP ; +out_be16 (&priv->rxbd[priv->rx_idx].status, status); + + priv->rx_idx = (priv->rx_idx +1 ) %PKTBUFSRX ; + +return 0 ; +} +static int tsec_recv (struct udevice *dev,int flags,uchar **packetp) {struct tsec_private *priv = (struct tsec_private *)dev_get_priv (dev);
@@ -307,24 +325,6 @@ static int tsec_recv(struct udevice *dev, int flags, uchar **packetp)return ret; } -static int tsec_free_pkt (struct udevice *dev,uchar *packet,int length) -{ -struct tsec_private *priv = (struct tsec_private *)dev_get_priv (dev); -u16 status; - -out_be16 (&priv->rxbd[priv->rx_idx].length,0 ); - - status =RXBD_EMPTY ; -/* Set the wrap bit if this is the last element in the list */ -if ((priv->rx_idx +1 ) ==PKTBUFSRX ) - status |=RXBD_WRAP ; -out_be16 (&priv->rxbd[priv->rx_idx].status, status); - - priv->rx_idx = (priv->rx_idx +1 ) %PKTBUFSRX ; - -return 0 ; -} -static void tsec_halt (struct udevice *dev) {struct tsec_private *priv;
Signature · 1 line
2.48.0.rc1.219.gb6b6757d772
PATCH 2/2 net: tsec: Re-arm packet buffer in error case
In reply to J. NeuschäferWhen an error is detected in the TSEC receive path, the driver currently prints an error message, but leaves the corresponding packet descriptor in its old state (i.e. owned by the CPU side). As a result, the packet queue can be starved of available buffers if enough errors happen.
To recover from errors, re-arm the packet buffer descriptor after an error has been detected.
Errors can be provoked by changing a PHY with phy-mode = "rgmii-id" to phy-mode = "rgmii".
--- drivers/net/tsec.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/tsec.c +3 -0
@@ -314,6 +314,9 @@ static int tsec_recv(struct udevice *dev, int flags, uchar **packetp) ret = length -4 ; }else {printf ("Got error %x\n" , (status &RXBD_STATS )); + +/* Rearm the packet buffer */ +tsec_free_pkt (dev,NULL ,0 ); } }
Signature · 1 line
2.48.0.rc1.219.gb6b6757d772