Skip to contentSkip to conversation

net: mv643xx_eth: implement descriptor cleanup in txq_submit_tso

PATCH In review Dheeraj Reddy Jonnalagadda 2 participants 2 messages Jan 24, 2025 – Jan 28, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: mv643xx_eth: implement descriptor cleanup in txq_submit_tso

Implement cleanup of used descriptors in the error path of txq_submit_tso.

Fixes 3ae8f4e0b98b ("net: mv643xx_eth: Implement software TSO")
---
 drivers/net/ethernet/marvell/mv643xx_eth.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/mv643xx_eth.c +11 -1
index 67a6ff07c83d..8d217f8d451e 100644
@@ -881,10 +881,20 @@ static int txq_submit_tso(struct tx_queue *txq, struct sk_buff *skb,
 	txq_enable(txq);
 	txq->tx_desc_count += desc_count;
 	return 0;
+
 err_release:
-	/* TODO: Release all used data descriptors; header descriptors must not
+	/* Release all used data descriptors; header descriptors must not
 	 * be DMA-unmapped.
 	 */
+	for (int i = 0; i < desc_count; i++) {
+		int desc_index = (txq->tx_curr_desc + i) % txq->tx_ring_size;
+		struct tx_desc *desc = &txq->tx_desc_area[desc_index];
+		desc->cmd_sts = 0; /* Reset the descriptor */
+	}
+
+	/* Adjust the descriptor count */
+	txq->tx_desc_count -= desc_count;
+
 	return ret;
 }
 
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 13 lines · Dheeraj Reddy Jonnalagadda

Implement cleanup of used descriptors in the error path of txq_submit_tso.

Fixes 3ae8f4e0b98b ("net: mv643xx_eth: Implement software TSO")
---
 drivers/net/ethernet/marvell/mv643xx_eth.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/mv643xx_eth.c +0 -0
index 67a6ff07c83d..8d217f8d451e 100644

drivers/net/ethernet/marvell/mv643xx_eth.c static int txq_submit_tso(struct tx_queue *txq, struct sk_buff *skb, · line 889

Quoted 10 lines
drivers/net/ethernet/marvell/mv643xx_eth.c +3 -1
@@ -881,10 +881,20 @@ static int txq_submit_tso(struct tx_queue *txq, struct sk_buff *skb,
 	txq_enable(txq);
 	txq->tx_desc_count += desc_count;
 	return 0;
+
 err_release:
-	/* TODO: Release all used data descriptors; header descriptors must not
+	/* Release all used data descriptors; header descriptors must not
 	 * be DMA-unmapped.
 	 */
+	for (int i = 0; i < desc_count; i++) {

Please move the 'i' variable definition into the initial definition for this function.

drivers/net/ethernet/marvell/mv643xx_eth.c static int txq_submit_tso(struct tx_queue *txq, struct sk_buff *skb, · line 890

Quoted 1 line
drivers/net/ethernet/marvell/mv643xx_eth.c +1 -0
+		int desc_index = (txq->tx_curr_desc + i) % txq->tx_ring_size;

AFAICS we reach here when the first desc_count - 1 descriptor for the current TSO packet has been filled and filling the desc_countth one, in the txq->tx_curr_desc index failed.

Given the above, you should free the previous desc_count - 1 descriptors, i.e. txq->tx_curr_desc - i.

drivers/net/ethernet/marvell/mv643xx_eth.c static int txq_submit_tso(struct tx_queue *txq, struct sk_buff *skb, · line 892

Quoted 2 lines
drivers/net/ethernet/marvell/mv643xx_eth.c +2 -0
+		struct tx_desc *desc = &txq->tx_desc_area[desc_index];
+		desc->cmd_sts = 0; /* Reset the descriptor */

It looks like you should still unmap data descriptor as done in txq_reclaim()

/P