Skip to content

Commit 02aead4

Browse files
Dheeraj Reddy JonnalagaddaSherryYang1
authored andcommitted
net: fec: implement TSO descriptor cleanup
[ Upstream commit 61dc1fd ] 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]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 6ffa1908526e85f3c9753fc6a2d1f884727b0bbe) Signed-off-by: Sherry Yang <[email protected]>
1 parent 35c4822 commit 02aead4

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
@@ -732,6 +732,8 @@ static int fec_enet_txq_submit_tso(struct fec_enet_priv_tx_q *txq,
732732
int hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
733733
int total_len, data_left;
734734
struct bufdesc *bdp = txq->bd.cur;
735+
struct bufdesc *tmp_bdp;
736+
struct bufdesc_ex *ebdp;
735737
struct tso_t tso;
736738
unsigned int index = 0;
737739
int ret;
@@ -805,7 +807,34 @@ static int fec_enet_txq_submit_tso(struct fec_enet_priv_tx_q *txq,
805807
return 0;
806808

807809
err_release:
808-
/* TODO: Release all used data descriptors for TSO */
810+
/* Release all used data descriptors for TSO */
811+
tmp_bdp = txq->bd.cur;
812+
813+
while (tmp_bdp != bdp) {
814+
/* Unmap data buffers */
815+
if (tmp_bdp->cbd_bufaddr &&
816+
!IS_TSO_HEADER(txq, fec32_to_cpu(tmp_bdp->cbd_bufaddr)))
817+
dma_unmap_single(&fep->pdev->dev,
818+
fec32_to_cpu(tmp_bdp->cbd_bufaddr),
819+
fec16_to_cpu(tmp_bdp->cbd_datlen),
820+
DMA_TO_DEVICE);
821+
822+
/* Clear standard buffer descriptor fields */
823+
tmp_bdp->cbd_sc = 0;
824+
tmp_bdp->cbd_datlen = 0;
825+
tmp_bdp->cbd_bufaddr = 0;
826+
827+
/* Handle extended descriptor if enabled */
828+
if (fep->bufdesc_ex) {
829+
ebdp = (struct bufdesc_ex *)tmp_bdp;
830+
ebdp->cbd_esc = 0;
831+
}
832+
833+
tmp_bdp = fec_enet_get_nextdesc(tmp_bdp, &txq->bd);
834+
}
835+
836+
dev_kfree_skb_any(skb);
837+
809838
return ret;
810839
}
811840

0 commit comments

Comments
 (0)