[PATCH RFC net-next 07/12] net: enic: publish partial receive descriptor batches

From: Satish Kharat

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


The receive queue only advanced posted_index at a 16-descriptor
boundary. If refill ran out of buffers before that boundary, the
descriptors already filled in this pass could remain invisible to the
device, including on the admin receive queue.

Publish a nonempty partial tail after each refill attempt, on success
or failure. Preserve the existing full-batch write in vnic_rq_post()
and order descriptor contents before advancing posted_index.

Signed-off-by: Satish Kharat <satishkh@xxxxxxxxx>
---
drivers/net/ethernet/cisco/enic/enic_admin.c | 8 +++++---
drivers/net/ethernet/cisco/enic/vnic_rq.h | 21 ++++++++++++++++++---
2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/cisco/enic/enic_admin.c b/drivers/net/ethernet/cisco/enic/enic_admin.c
index d4f3f58a0ec2..3ffd59bbc051 100644
--- a/drivers/net/ethernet/cisco/enic/enic_admin.c
+++ b/drivers/net/ethernet/cisco/enic/enic_admin.c
@@ -88,15 +88,17 @@ static int enic_admin_rq_post_one(struct enic *enic, gfp_t gfp)
static int enic_admin_rq_fill(struct enic *enic, gfp_t gfp)
{
struct vnic_rq *rq = &enic->admin_rq;
- int err;
+ struct vnic_rq_buf *first = rq->to_use;
+ int err = 0;

while (vnic_rq_desc_avail(rq) > 0) {
err = enic_admin_rq_post_one(enic, gfp);
if (err)
- return err;
+ break;
}

- return 0;
+ vnic_rq_publish_tail(rq, first);
+ return err;
}

static void enic_admin_rq_drain(struct enic *enic)
diff --git a/drivers/net/ethernet/cisco/enic/vnic_rq.h b/drivers/net/ethernet/cisco/enic/vnic_rq.h
index 9fc2090eac44..6c347599d233 100644
--- a/drivers/net/ethernet/cisco/enic/vnic_rq.h
+++ b/drivers/net/ethernet/cisco/enic/vnic_rq.h
@@ -140,6 +140,19 @@ static inline void vnic_rq_post(struct vnic_rq *rq,
}
}

+static inline void vnic_rq_publish_tail(struct vnic_rq *rq,
+ struct vnic_rq_buf *first)
+{
+ /* A full batch was already published by vnic_rq_post(). */
+ if (rq->to_use == first ||
+ !(rq->to_use->index & VNIC_RQ_RETURN_RATE))
+ return;
+
+ /* Make descriptor contents visible before advancing the device index. */
+ wmb();
+ iowrite32(rq->to_use->index, &rq->ctrl->posted_index);
+}
+
static inline void vnic_rq_return_descs(struct vnic_rq *rq, unsigned int count)
{
rq->ring.desc_avail += count;
@@ -181,16 +194,18 @@ static inline void vnic_rq_service(struct vnic_rq *rq,
static inline int vnic_rq_fill(struct vnic_rq *rq,
int (*buf_fill)(struct vnic_rq *rq))
{
- int err;
+ struct vnic_rq_buf *first = rq->to_use;
+ int err = 0;

while (vnic_rq_desc_avail(rq) > 0) {

err = (*buf_fill)(rq);
if (err)
- return err;
+ break;
}

- return 0;
+ vnic_rq_publish_tail(rq, first);
+ return err;
}

void vnic_rq_free(struct vnic_rq *rq);

--
2.43.0