net/mana: fix Tx stall from send queue free-space unit mismatch
PATCH 1/1 net/mana: fix Tx stall from send queue free-space unit mismatch
gdma_post_work_request() subtracted a unit count from an entry count:
queue_free_units = queue->count - (queue->head - queue->tail);
queue->count is in entries, while head and tail are in WQE alignment units. On a 512-entry, 128KB send queue the check saw 512 units of capacity instead of queue->size / GDMA_WQE_ALIGNMENT_UNIT_SIZE = 4096, and returned -EBUSY with the queue one eighth full. A workload that fills that window faster than it drains makes rte_eth_tx_burst() return 0 for long enough to look like a dead port.
Derive the capacity from queue->size, which is also what the ring wrap in gdma_get_wqe_pointer() uses. Rx is unaffected: its WQEs occupy exactly one unit, so entries and units coincide.
---
Independent of patchwork 167383 and 167384 (net/mana MR length truncation / Rx WQE double free) from the same author, currently in
awaiting-upstream: this touches gdma.c only and applies cleanly with or without them.
drivers/net/mana/gdma.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/mana/gdma.c +6 -1
@@ -138,7 +138,12 @@ gdma_post_work_request(struct mana_gdma_queue *queue, client_oob_size + sgl_data_size, GDMA_WQE_ALIGNMENT_UNIT_SIZE);uint8_t *wq_buffer_pointer; -uint32_t queue_free_units = queue->count - (queue->head - queue->tail); +/* head/tail count WQE alignment units, so the capacity they are compared +* against must too: queue->count is in entries and undercounts the +* queue, stalling Tx well below capacity. +*/ +uint32_t queue_free_units = queue->size /GDMA_WQE_ALIGNMENT_UNIT_SIZE - + (queue->head - queue->tail);if (wqe_size /GDMA_WQE_ALIGNMENT_UNIT_SIZE > queue_free_units) { DP_LOG(DEBUG, "WQE size %u queue count %u head %u tail %u",
Signature · 1 line
2.43.0
Stephen Hemminger
AppliedQuoted 15 lines · On Mon, 14 Sep 2026 13:58:08 +0300 Rita Ruvinsky <[email protected]> wrote:
gdma_post_work_request()subtracted a unit count from an entry count:queue_free_units = queue->count - (queue->head - queue->tail);
queue->countis in entries, while head and tail are in WQE alignment units. On a 512-entry, 128KB send queue the check saw 512 units of capacity instead ofqueue->size/GDMA_WQE_ALIGNMENT_UNIT_SIZE= 4096, and returned-EBUSYwith the queue one eighth full. A workload that fills that window faster than it drains makesrte_eth_tx_burst()return 0 for long enough to look like a dead port.Derive the capacity from
queue->size, which is also what the ring wrap ingdma_get_wqe_pointer()uses. Rx is unaffected: its WQEs occupy exactly one unit, so entries and units coincide.
Quoted 5 lines
Fixes 56dd45c0ce7b ("net/mana: implement hardware layer operations")Signed-off-by Rita Ruvinsky <[email protected]>---
Applied to next-net
The long form AI review had some observations worth including:
Quoted 1 line · On Mon, 14 Sep 2026 13:58:08 +0300 Rita Ruvinsky <[email protected]> wrote:
gdma_post_work_request()subtracted a unit count from an entry count:
The unit analysis is right. head/tail are advanced in alignment units (queue->head += wqe_size / GDMA_WQE_ALIGNMENT_UNIT_SIZE, and gdma_get_wqe_pointer() multiplies head by the same constant), while sq_count comes from rdma-core as attr->cap.max_send_wr and sq_size as align_hw_size(max_send_wr * get_wqe_size(max_send_sge)). Deriving the capacity from size is the only self-consistent choice, and it is what mana_gd_wq_avail_space() in the kernel driver does.
Info:
1. The debug line in the -EBUSY path still reports queue->count:
DP_LOG(DEBUG, "WQE size %u queue count %u head %u tail %u", wqe_size, queue->count, queue->head, queue->tail);
After this patch count no longer takes part in the decision for the send or receive queue; only gdma_poll_completion_queue() still uses it, for the CQ. The one line printed when a post is rejected no longer shows what it was rejected against. Suggest:
DP_LOG(DEBUG, "WQE size %u queue size %u free %u head %u tail %u", wqe_size, queue->size, queue_free_units, queue->head, queue->tail);
2. The comment describes the old bug rather than the invariant:
/* head/tail count WQE alignment units, so the capacity they are * compared against must too: queue->count is in entries and * undercounts the queue, stalling Tx well below capacity. */
The stall belongs in the commit message, where it already is. In the source the invariant is enough:
/* head and tail are in WQE alignment units, so the capacity must * come from the queue size in bytes, not the entry count. */
3. Worth a sentence in the commit message that the kernel mana driver computes the same limit in mana_gd_wq_avail_space(), in bytes:
u32 used_space = (wq->head - wq->tail) * GDMA_WQE_BU_SIZE; return wq->queue_size - used_space;
It is independent confirmation of the unit convention and tells anyone backporting this that the two drivers now agree.
Quoted 85 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, September 15, 2026 12:14 AM
To: Rita Ruvinsky <[email protected]>
Cc: [email protected]; [email protected]; Wei Hu <[email protected]>; [email protected]
Subject: [EXTERNAL] Re: [PATCH] net/mana: fix Tx stall from send queue free- space unit mismatchQuoted 7 lines · On Mon, 14 Sep 2026 13:58:08 +0300 Rita Ruvinsky <[email protected]> wrote:
gdma_post_work_request()subtracted a unit count from an entry count:queue_free_units = queue->count - (queue->head - queue->tail);
queue->countis in entries, while head and tail are in WQE alignment units. On a 512-entry, 128KB send queue the check saw 512 units of capacity instead ofqueue->size/GDMA_WQE_ALIGNMENT_UNIT_SIZE=4096,
Quoted 9 lines
and returned
-EBUSYwith the queue one eighth full. A workload that fills that window faster than it drains makesrte_eth_tx_burst()return
0 for long enough to look like a dead port.Derive the capacity from
queue->size, which is also what the ring wrap ingdma_get_wqe_pointer()uses. Rx is unaffected: its WQEs occupy exactly one unit, so entries and units coincide.Quoted 5 lines
Fixes 56dd45c0ce7b ("net/mana: implement hardware layer operations")Signed-off-by Rita Ruvinsky <[email protected]>---
Applied to next-net
The long form AI review had some observations worth including:
Quoted 1 line · On Mon, 14 Sep 2026 13:58:08 +0300 Rita Ruvinsky <[email protected]> wrote:
gdma_post_work_request()subtracted a unit count from an entry count:The unit analysis is right. head/tail are advanced in alignment units (queue-
Quoted 1 line
head +=
wqe_size/GDMA_WQE_ALIGNMENT_UNIT_SIZE, and
gdma_get_wqe_pointer()multiplies head by the same constant), whilesq_countcomes from rdma-core asattr->cap.max_send_wrandsq_sizeasalign_hw_size(max_send_wr * get_wqe_size(max_send_sge)). Deriving the capacity from size is the only self-consistent choice, and it is whatmana_gd_wq_avail_space()in the kernel driver does.Info:
1. The debug line in the
-EBUSYpath still reportsqueue->count:DP_LOG(DEBUG, "WQE size %u queue count %u head %u tail %u", wqe_size, queue->count, queue->head, queue->tail);After this patch count no longer takes part in the decision for the send or receive queue; only
gdma_poll_completion_queue()still uses it, for the CQ. The one line printed when a post is rejected no longer shows what it was rejected against. Suggest:DP_LOG(DEBUG, "WQE size %u queue size %u free %u head %u
tail %u",wqe_size, queue->size, queue_free_units, queue->head, queue->tail);2. The comment describes the old bug rather than the invariant:
/* head/tail count WQE alignment units, so the capacity they are * compared against must too: queue->count is in entries and * undercounts the queue, stalling Tx well below capacity. */The stall belongs in the commit message, where it already is. In the source the invariant is enough:
/* head and tail are in WQE alignment units, so the capacity must * come from the queue size in bytes, not the entry count. */
Quoted 8 lines
3. Worth a sentence in the commit message that the kernel mana driver computes the same limit in
mana_gd_wq_avail_space(), in bytes:u32 used_space = (wq->head - wq->tail) * GDMA_WQE_BU_SIZE; return wq->queue_size - used_space;It is independent confirmation of the unit convention and tells anyone backporting this that the two drivers now agree.
I was about to say the same. The change in DP_LOG and code comments all make a lot of sense. Thanks for fixing this.
Wei
Hi Stephen,
I am happy to send these as a follow-up if you've already committed v1 or create a v2 patch.
Thanks,
Rita
Quoted 104 lines · Wei Hu
Quoted 9 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, September 15, 2026 12:14 AM
To: Rita Ruvinsky <[email protected]>
Cc: [email protected]; [email protected]; Wei Hu <[email protected]>; [email protected]
Subject: [EXTERNAL] Re: [PATCH] net/mana: fix Tx stall from send queuefree-
Quoted 30 lines
space unit mismatch
Quoted 7 lines · On Mon, 14 Sep 2026 13:58:08 +0300 Rita Ruvinsky <[email protected]> wrote:
gdma_post_work_request()subtracted a unit count from an entry count:queue_free_units = queue->count - (queue->head - queue->tail);
queue->countis in entries, while head and tail are in WQE alignment units. On a 512-entry, 128KB send queue the check saw 512 units of capacity instead ofqueue->size/GDMA_WQE_ALIGNMENT_UNIT_SIZE=4096,
Quoted 9 lines
and returned
-EBUSYwith the queue one eighth full. A workload that fills that window faster than it drains makesrte_eth_tx_burst()return
0 for long enough to look like a dead port.Derive the capacity from
queue->size, which is also what the ring wrap ingdma_get_wqe_pointer()uses. Rx is unaffected: its WQEs occupy exactly one unit, so entries and units coincide.Quoted 5 lines
Fixes 56dd45c0ce7b ("net/mana: implement hardware layer operations")Signed-off-by Rita Ruvinsky <[email protected]>---
Applied to next-net
Quoted 8 lines
The long form AI review had some observations worth including:
Quoted 1 line · On Mon, 14 Sep 2026 13:58:08 +0300 Rita Ruvinsky <[email protected]> wrote:
gdma_post_work_request()subtracted a unit count from an entry count:The unit analysis is right. head/tail are advanced in alignment units
(queue-
Quoted 7 lines
Quoted 1 line
head +=
wqe_size/GDMA_WQE_ALIGNMENT_UNIT_SIZE, and
gdma_get_wqe_pointer()multiplies head by the same constant), whilesq_countcomes from rdma-core asattr->cap.max_send_wrandsq_sizeasalign_hw_size(max_send_wr * get_wqe_size(max_send_sge)). Deriving the capacity from size is the only self-consistent choice, and it is whatmana_gd_wq_avail_space()in the kernel driver does.Quoted 8 lines
Info:
1. The debug line in the
-EBUSYpath still reportsqueue->count:DP_LOG(DEBUG, "WQE size %u queue count %u head %u tail %u",
wqe_size,queue->count,queue->head,queue->tail);After this patch count no longer takes part in the decision for the send
or
Quoted 1 line
receive queue; only
gdma_poll_completion_queue()still uses it, for theCQ.
Quoted 8 lines
The one line printed when a post is rejected no longer shows what it was rejected against. Suggest:
DP_LOG(DEBUG, "WQE size %u queue size %u free %u head %u
tail %u",wqe_size, queue->size, queue_free_units, queue->head, queue->tail);Quoted 8 lines
2. The comment describes the old bug rather than the invariant:
/* head/tail count WQE alignment units, so the capacity they are
* compared against must too:queue->countis in entries and
* undercounts the queue, stalling Tx well below capacity. */The stall belongs in the commit message, where it already is. In the
source the
Quoted 6 lines
invariant is enough:
/* head and tail are in WQE alignment units, so the capacity must * come from the queue size in bytes, not the entry count. */Quoted 8 lines
3. Worth a sentence in the commit message that the kernel mana driver computes the same limit in
mana_gd_wq_avail_space(), in bytes:u32 used_space = (wq->head - wq->tail) * GDMA_WQE_BU_SIZE; return wq->queue_size - used_space;It is independent confirmation of the unit convention and tells anyone backporting this that the two drivers now agree.
I was about to say the same. The change in
DP_LOGand code comments all make a lot of sense. Thanks for fixing this.Wei
Quoted 6 lines · On Wed, 16 Sep 2026 14:12:12 +0300 Rita Ruvinsky <[email protected]> wrote:
Hi Stephen,
I am happy to send these as a follow-up if you've already committed v1 or create a v2 patch.Thanks,
Rita
It is in next-net branch now. But if you send V2 I can swap to new version.
PATCH v2 1/1 net/mana: fix Tx stall from send queue free-space unit mismatch
In reply to Rita Ruvinskygdma_post_work_request() subtracted a unit count from an entry count:
queue_free_units = queue->count - (queue->head - queue->tail);
queue->count is in entries, while head and tail are in WQE alignment units. On a 512-entry, 128KB send queue the check saw 512 units of capacity instead of queue->size / GDMA_WQE_ALIGNMENT_UNIT_SIZE = 4096, and returned -EBUSY with the queue one eighth full. A workload that fills that window faster than it drains makes rte_eth_tx_burst() return 0 for long enough to look like a dead port.
The size is the authoritative capacity: rdma-core derives sq_size from sq_count as align_hw_size(max_send_wr * get_wqe_size(max_send_sge)), and the kernel mana driver computes the same limit in bytes in mana_gd_wq_avail_space(). Derive it from queue->size, which is also what the ring wrap in gdma_get_wqe_pointer() uses. Rx is unaffected: its WQEs occupy exactly one unit, so entries and units coincide.
Also report the size and computed free space in the -EBUSY debug line, since queue->count no longer takes part in the decision.
---
v2:
- comment states the invariant rather than the old bug (Stephen Hemminger)
- report queue->size and the computed free space in the -EBUSY debug line (Stephen Hemminger, Wei Hu)
- reference mana_gd_wq_avail_space() in the commit message (Stephen Hemminger)
Independent of patchwork 167383 and 167384 from the same author.
drivers/net/mana/gdma.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/mana/gdma.c +8 -3
@@ -138,11 +138,16 @@ gdma_post_work_request(struct mana_gdma_queue *queue, client_oob_size + sgl_data_size, GDMA_WQE_ALIGNMENT_UNIT_SIZE);uint8_t *wq_buffer_pointer; -uint32_t queue_free_units = queue->count - (queue->head - queue->tail); +/* head and tail are in WQE alignment units, so the capacity must +* come from the queue size in bytes, not the entry count. +*/ +uint32_t queue_free_units = queue->size /GDMA_WQE_ALIGNMENT_UNIT_SIZE - + (queue->head - queue->tail);if (wqe_size /GDMA_WQE_ALIGNMENT_UNIT_SIZE > queue_free_units) { -DP_LOG (DEBUG ,"WQE size %u queue count %u head %u tail %u" , - wqe_size, queue->count, queue->head, queue->tail); +DP_LOG (DEBUG ,"WQE size %u queue size %u free %u head %u tail %u" , + wqe_size, queue->size, queue_free_units, + queue->head, queue->tail);return -EBUSY ; }
Signature · 1 line
2.43.0