netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 net] net: fec: implement TSO descriptor cleanup
@ 2025-01-20  8:54 Dheeraj Reddy Jonnalagadda
  2025-01-20  9:02 ` Wei Fang
  2025-01-23  9:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Dheeraj Reddy Jonnalagadda @ 2025-01-20  8:54 UTC (permalink / raw)
  To: wei.fang, shenwei.wang, xiaoning.wang
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, imx, netdev,
	linux-kernel, Dheeraj Reddy Jonnalagadda

Implement cleanup of descriptors in the TSO error path of
fec_enet_txq_submit_tso(). The cleanup

- Unmaps DMA buffers for data descriptors skipping TSO header
- Clears all buffer descriptors
- Handles extended descriptors by clearing cbd_esc when enabled

Fixes: 79f339125ea3 ("net: fec: Add software TSO support")
Signed-off-by: Dheeraj Reddy Jonnalagadda <dheeraj.linuxdev@gmail.com>
---
Changelog:
v4
	- Add a blank line before return
v3
        - Update DMA unmapping logic to skip all TSO headers
        - Use proper endianness conversion for DMA unmapping
v2
        - Add DMA unmapping for data descriptors
        - Handle extended descriptor (bufdesc_ex) cleanup
        - Move variable declarations to function scope
 drivers/net/ethernet/freescale/fec_main.c | 31 ++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 68725506a095..f7c4ce8e9a26 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -840,6 +840,8 @@ static int fec_enet_txq_submit_tso(struct fec_enet_priv_tx_q *txq,
 	struct fec_enet_private *fep = netdev_priv(ndev);
 	int hdr_len, total_len, data_left;
 	struct bufdesc *bdp = txq->bd.cur;
+	struct bufdesc *tmp_bdp;
+	struct bufdesc_ex *ebdp;
 	struct tso_t tso;
 	unsigned int index = 0;
 	int ret;
@@ -913,7 +915,34 @@ static int fec_enet_txq_submit_tso(struct fec_enet_priv_tx_q *txq,
 	return 0;
 
 err_release:
-	/* TODO: Release all used data descriptors for TSO */
+	/* Release all used data descriptors for TSO */
+	tmp_bdp = txq->bd.cur;
+
+	while (tmp_bdp != bdp) {
+		/* Unmap data buffers */
+		if (tmp_bdp->cbd_bufaddr &&
+		    !IS_TSO_HEADER(txq, fec32_to_cpu(tmp_bdp->cbd_bufaddr)))
+			dma_unmap_single(&fep->pdev->dev,
+					 fec32_to_cpu(tmp_bdp->cbd_bufaddr),
+					 fec16_to_cpu(tmp_bdp->cbd_datlen),
+					 DMA_TO_DEVICE);
+
+		/* Clear standard buffer descriptor fields */
+		tmp_bdp->cbd_sc = 0;
+		tmp_bdp->cbd_datlen = 0;
+		tmp_bdp->cbd_bufaddr = 0;
+
+		/* Handle extended descriptor if enabled */
+		if (fep->bufdesc_ex) {
+			ebdp = (struct bufdesc_ex *)tmp_bdp;
+			ebdp->cbd_esc = 0;
+		}
+
+		tmp_bdp = fec_enet_get_nextdesc(tmp_bdp, &txq->bd);
+	}
+
+	dev_kfree_skb_any(skb);
+
 	return ret;
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH v4 net] net: fec: implement TSO descriptor cleanup
  2025-01-20  8:54 [PATCH v4 net] net: fec: implement TSO descriptor cleanup Dheeraj Reddy Jonnalagadda
@ 2025-01-20  9:02 ` Wei Fang
  2025-01-23  9:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Wei Fang @ 2025-01-20  9:02 UTC (permalink / raw)
  To: Dheeraj Reddy Jonnalagadda, Shenwei Wang, Clark Wang
  Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, imx@lists.linux.dev,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org

> Implement cleanup of descriptors in the TSO error path of
> fec_enet_txq_submit_tso(). The cleanup
> 
> - Unmaps DMA buffers for data descriptors skipping TSO header
> - Clears all buffer descriptors
> - Handles extended descriptors by clearing cbd_esc when enabled
> 
> Fixes: 79f339125ea3 ("net: fec: Add software TSO support")
> Signed-off-by: Dheeraj Reddy Jonnalagadda <dheeraj.linuxdev@gmail.com>
> ---
> Changelog:
> v4
> 	- Add a blank line before return
> v3
>         - Update DMA unmapping logic to skip all TSO headers
>         - Use proper endianness conversion for DMA unmapping
> v2
>         - Add DMA unmapping for data descriptors
>         - Handle extended descriptor (bufdesc_ex) cleanup
>         - Move variable declarations to function scope
> drivers/net/ethernet/freescale/fec_main.c | 31 ++++++++++++++++++++++-
>  1 file changed, 30 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/freescale/fec_main.c
> b/drivers/net/ethernet/freescale/fec_main.c
> index 68725506a095..f7c4ce8e9a26 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -840,6 +840,8 @@ static int fec_enet_txq_submit_tso(struct
> fec_enet_priv_tx_q *txq,
>  	struct fec_enet_private *fep = netdev_priv(ndev);
>  	int hdr_len, total_len, data_left;
>  	struct bufdesc *bdp = txq->bd.cur;
> +	struct bufdesc *tmp_bdp;
> +	struct bufdesc_ex *ebdp;
>  	struct tso_t tso;
>  	unsigned int index = 0;
>  	int ret;
> @@ -913,7 +915,34 @@ static int fec_enet_txq_submit_tso(struct
> fec_enet_priv_tx_q *txq,
>  	return 0;
> 
>  err_release:
> -	/* TODO: Release all used data descriptors for TSO */
> +	/* Release all used data descriptors for TSO */
> +	tmp_bdp = txq->bd.cur;
> +
> +	while (tmp_bdp != bdp) {
> +		/* Unmap data buffers */
> +		if (tmp_bdp->cbd_bufaddr &&
> +		    !IS_TSO_HEADER(txq, fec32_to_cpu(tmp_bdp->cbd_bufaddr)))
> +			dma_unmap_single(&fep->pdev->dev,
> +					 fec32_to_cpu(tmp_bdp->cbd_bufaddr),
> +					 fec16_to_cpu(tmp_bdp->cbd_datlen),
> +					 DMA_TO_DEVICE);
> +
> +		/* Clear standard buffer descriptor fields */
> +		tmp_bdp->cbd_sc = 0;
> +		tmp_bdp->cbd_datlen = 0;
> +		tmp_bdp->cbd_bufaddr = 0;
> +
> +		/* Handle extended descriptor if enabled */
> +		if (fep->bufdesc_ex) {
> +			ebdp = (struct bufdesc_ex *)tmp_bdp;
> +			ebdp->cbd_esc = 0;
> +		}
> +
> +		tmp_bdp = fec_enet_get_nextdesc(tmp_bdp, &txq->bd);
> +	}
> +
> +	dev_kfree_skb_any(skb);
> +
>  	return ret;
>  }
> 
> --
> 2.34.1

Thanks for fixing this issue.

Reviewed-by: Wei Fang <wei.fang@nxp.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v4 net] net: fec: implement TSO descriptor cleanup
  2025-01-20  8:54 [PATCH v4 net] net: fec: implement TSO descriptor cleanup Dheeraj Reddy Jonnalagadda
  2025-01-20  9:02 ` Wei Fang
@ 2025-01-23  9:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-01-23  9:30 UTC (permalink / raw)
  To: Dheeraj Reddy Jonnalagadda
  Cc: wei.fang, shenwei.wang, xiaoning.wang, andrew+netdev, davem,
	edumazet, kuba, pabeni, imx, netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Mon, 20 Jan 2025 14:24:30 +0530 you wrote:
> Implement cleanup of descriptors in the TSO error path of
> fec_enet_txq_submit_tso(). The cleanup
> 
> - Unmaps DMA buffers for data descriptors skipping TSO header
> - Clears all buffer descriptors
> - Handles extended descriptors by clearing cbd_esc when enabled
> 
> [...]

Here is the summary with links:
  - [v4,net] net: fec: implement TSO descriptor cleanup
    https://git.kernel.org/netdev/net/c/61dc1fd9205b

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-23  9:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-20  8:54 [PATCH v4 net] net: fec: implement TSO descriptor cleanup Dheeraj Reddy Jonnalagadda
2025-01-20  9:02 ` Wei Fang
2025-01-23  9:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).