net: fec: implement TSO descriptor cleanup
PATCH v4 1/1 net: fec: implement TSO descriptor cleanup
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
---
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(-)
drivers/net/ethernet/freescale/fec_main.c +30 -1
@@ -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; }
Signature · 1 line
2.34.1
Quoted 76 lines
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 clearingcbd_escwhen enabledFixes 79f339125ea3 ("net: fec: Add software TSO support")Signed-off-by Dheeraj Reddy Jonnalagadda <[email protected]>---
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 scopedrivers/net/ethernet/freescale/fec_main.c| 31 ++++++++++++++++++++++-1 file changed, 30 insertions(+), 1 deletion(-)drivers/net/ethernet/freescale/fec_main.c +2
-0@@ -840,6 +840,8 @@ static int fec_enet_txq_submit_tso(structfec_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 ;drivers/net/ethernet/freescale/fec_main.c +28
-2int ret;@@ -913,7 +915,34 @@ static int fec_enet_txq_submit_tso(structfec_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; } --
Quoted 1 line
2.34.1
Thanks for fixing this issue.
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 8 lines · 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 clearingcbd_escwhen 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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html