Skip to content

Commit 61dc1fd

Browse files
Dheeraj Reddy JonnalagaddaPaolo Abeni
authored andcommitted
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 Fixes: 79f3391 ("net: fec: Add software TSO support") Signed-off-by: Dheeraj Reddy Jonnalagadda <[email protected]> Reviewed-by: Wei Fang <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent a197004 commit 61dc1fd

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

drivers/net/ethernet/freescale/fec_main.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,8 @@ static int fec_enet_txq_submit_tso(struct fec_enet_priv_tx_q *txq,
840840
struct fec_enet_private *fep = netdev_priv(ndev);
841841
int hdr_len, total_len, data_left;
842842
struct bufdesc *bdp = txq->bd.cur;
843+
struct bufdesc *tmp_bdp;
844+
struct bufdesc_ex *ebdp;
843845
struct tso_t tso;
844846
unsigned int index = 0;
845847
int ret;
@@ -913,7 +915,34 @@ static int fec_enet_txq_submit_tso(struct fec_enet_priv_tx_q *txq,
913915
return 0;
914916

915917
err_release:
916-
/* TODO: Release all used data descriptors for TSO */
918+
/* Release all used data descriptors for TSO */
919+
tmp_bdp = txq->bd.cur;
920+
921+
while (tmp_bdp != bdp) {
922+
/* Unmap data buffers */
923+
if (tmp_bdp->cbd_bufaddr &&
924+
!IS_TSO_HEADER(txq, fec32_to_cpu(tmp_bdp->cbd_bufaddr)))
925+
dma_unmap_single(&fep->pdev->dev,
926+
fec32_to_cpu(tmp_bdp->cbd_bufaddr),
927+
fec16_to_cpu(tmp_bdp->cbd_datlen),
928+
DMA_TO_DEVICE);
929+
930+
/* Clear standard buffer descriptor fields */
931+
tmp_bdp->cbd_sc = 0;
932+
tmp_bdp->cbd_datlen = 0;
933+
tmp_bdp->cbd_bufaddr = 0;
934+
935+
/* Handle extended descriptor if enabled */
936+
if (fep->bufdesc_ex) {
937+
ebdp = (struct bufdesc_ex *)tmp_bdp;
938+
ebdp->cbd_esc = 0;
939+
}
940+
941+
tmp_bdp = fec_enet_get_nextdesc(tmp_bdp, &txq->bd);
942+
}
943+
944+
dev_kfree_skb_any(skb);
945+
917946
return ret;
918947
}
919948

0 commit comments

Comments
 (0)