[PATCH RFC net-next 01/12] net: enic: bound skb TX rollback to current packet

From: Satish Kharat

Date: Mon Nov 30 2026 - 20:16:58 EST


A DMA mapping failure must unwind only descriptors posted for the
current skb. The old loop stopped at an os_buf marker, but an
outstanding AF_XDP descriptor has no os_buf. Save the producer position
before posting and return to that boundary, restoring one credit per
descriptor. If xmit_more deferred an earlier skb, ring the surviving
producer position before leaving the error path.

Code inspection during shared-WQ AF_XDP work identified this rollback
boundary. A test-only failure after a non-EOP TSO descriptor
exercised rollback with an outstanding XSK descriptor on an E2
VIC 1137:0043 vNIC. With this fix, all 16,000 XSK frames completed
and arrived once, and a concurrent 1 GiB TCP transfer finished.
The test did not force a real DMA mapping failure, ring wrap, or
deferred xmit_more.

Signed-off-by: Satish Kharat <satishkh@xxxxxxxxx>
---
drivers/net/ethernet/cisco/enic/enic_main.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index dde9098357d1..f88ae4bd85be 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -825,6 +825,7 @@ static inline int enic_queue_wq_skb_encap(struct enic *enic, struct vnic_wq *wq,
static inline int enic_queue_wq_skb(struct enic *enic,
struct vnic_wq *wq, struct sk_buff *skb)
{
+ struct vnic_wq_buf *first = wq->to_use;
unsigned int mss = skb_shinfo(skb)->gso_size;
unsigned int vlan_tag = 0;
int vlan_tag_insert = 0;
@@ -857,16 +858,12 @@ static inline int enic_queue_wq_skb(struct enic *enic,
if (unlikely(err)) {
struct vnic_wq_buf *buf;

- buf = wq->to_use->prev;
- /* while not EOP of previous pkt && queue not empty.
- * For all non EOP bufs, os_buf is NULL.
- */
- while (!buf->os_buf && (buf->next != wq->to_clean)) {
+ while (wq->to_use != first) {
+ buf = wq->to_use->prev;
enic_free_wq_buf(wq, buf);
wq->ring.desc_avail++;
- buf = buf->prev;
+ wq->to_use = buf;
}
- wq->to_use = buf->next;
dev_kfree_skb(skb);
}
return err;
@@ -917,8 +914,12 @@ static netdev_tx_t enic_hard_start_xmit(struct sk_buff *skb,
return NETDEV_TX_BUSY;
}

- if (enic_queue_wq_skb(enic, wq, skb))
+ if (enic_queue_wq_skb(enic, wq, skb)) {
+ /* Do not strand an earlier skb deferred by xmit_more. */
+ if (wq->to_use != wq->to_clean)
+ vnic_wq_doorbell(wq);
goto error;
+ }

if (vnic_wq_desc_avail(wq) < MAX_SKB_FRAGS + ENIC_DESC_MAX_SPLITS) {
netif_tx_stop_queue(txq);

--
2.43.0