net: mana: Use the HWC destination queues reported by the hardware
Subsystems (5)
PATCH v2 1/1 net: mana: Use the HWC destination queues reported by the hardware
The hardware provides valid HWC destination vRQ and vRCQ IDs for all PFs and VFs. Use these IDs unconditionally in mana_hwc_send_request(), as the PF-specific gate is not required.
---
Changes in v2:
- State that the hardware supplies valid destination IDs for all PFs and VFs, so the PF-specific gate is unnecessary.
- Drop the PF prefix from the context fields and init-event constants.
v1:
https://lore.kernel.org/netdev/[email protected]/
drivers/net/ethernet/microsoft/mana/hw_channel.c | 24 +++++++++++++----------- include/net/mana/hw_channel.h | 8 ++++---- 2 files changed, 17 insertions(+), 15 deletions(-)
drivers/net/ethernet/microsoft/mana/hw_channel.c +13 -11
@@ -170,12 +170,12 @@ static void mana_hwc_init_event_handler(void *ctx, struct gdma_queue *q_self, hwc->txq->msg_buf->gpa_mkey = val;break ; -case HWC_INIT_DATA_PF_DEST_RQ_ID : - hwc->pf_dest_vrq_id = val; +case HWC_INIT_DATA_DEST_RQ_ID : + hwc->dest_vrq_id = val;break ; -case HWC_INIT_DATA_PF_DEST_CQ_ID : - hwc->pf_dest_vrcq_id = val; +case HWC_INIT_DATA_DEST_CQ_ID : + hwc->dest_vrcq_id = val;break ; }
@@ -855,13 +855,12 @@ void mana_hwc_destroy_channel(struct gdma_context *gc)int mana_hwc_send_request (struct hw_channel_context *hwc,u32 req_len,const void *req,u32 resp_len,void *resp) { -struct gdma_context *gc = hwc->gdma_dev->gdma_context;struct hwc_work_request *tx_wr;struct hwc_wq *txq = hwc->txq;struct gdma_req_hdr *req_msg;struct hwc_caller_ctx *ctx; -u32 dest_vrcq =0 ; -u32 dest_vrq =0 ; +u32 dest_vrcq; +u32 dest_vrq;u32 command;u16 msg_id;int err;
@@ -890,10 +889,13 @@ int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len, tx_wr->msg_size = req_len; command = req_msg->req.msg_type; -if (gc->is_pf) { - dest_vrq = hwc->pf_dest_vrq_id; - dest_vrcq = hwc->pf_dest_vrcq_id; - } +/* The hardware reports the HWC destination queues through +* HWC_INIT_DATA_DEST_RQ_ID and HWC_INIT_DATA_DEST_CQ_ID, and +* always supplies values that are valid for this function, so no +* PF-specific handling is needed here. +*/ + dest_vrq = hwc->dest_vrq_id; + dest_vrcq = hwc->dest_vrcq_id; err =mana_hwc_post_tx_wqe (txq, tx_wr, dest_vrq, dest_vrcq, false);if (err) {
include/net/mana/hw_channel.h +4 -4
@@ -20,8 +20,8 @@#define HWC_INIT_DATA_MAX_NUM_CQS 7#define HWC_INIT_DATA_PDID 8#define HWC_INIT_DATA_GPA_MKEY 9 -#define HWC_INIT_DATA_PF_DEST_RQ_ID 10 -#define HWC_INIT_DATA_PF_DEST_CQ_ID 11 +#define HWC_INIT_DATA_DEST_RQ_ID 10 +#define HWC_INIT_DATA_DEST_CQ_ID 11#define HWC_DATA_CFG_HWC_TIMEOUT 1#define HWC_DATA_HW_LINK_CONNECT 2
@@ -195,8 +195,8 @@ struct hw_channel_context {struct semaphore sema;struct gdma_resource inflight_msg_res; -u32 pf_dest_vrq_id; -u32 pf_dest_vrcq_id; +u32 dest_vrq_id; +u32 dest_vrcq_id;u32 hwc_timeout;struct hwc_caller_ctx *caller_ctx;
base-commit: ce48a0fdc56464b1afb03471dbdf38a5e0d571ad
Signature · 1 line
2.54.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] When mana_hwc_send_request() times out, it releases the msg_id back to the pool immediately without waiting for late hardware responses or clearing the completion state. This allows delayed hardware responses to corrupt memory of new requests reusing the msg_id, or falsely trigger stale completions. --
commit 57ce74bdb654c3d07799a1543f2838a5e3407388
Author: Manish Awasthi <[email protected]>
net: mana: Use the HWC destination queues reported by the hardware
The hardware provides valid HWC destination vRQ and vRCQ IDs for all PFs and VFs. Use these IDs unconditionally in mana_hwc_send_request(), as the PF-specific gate is not required.
Quoted 4 lines
drivers/net/ethernet/microsoft/mana/hw_channel.c +0
-0
[ ... ]
Quoted 7 lines
drivers/net/ethernet/microsoft/mana/hw_channel.c +0
-3@@ -890,10 +889,13 @@ int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len, tx_wr->msg_size = req_len; command = req_msg->req.msg_type; -if (gc->is_pf) { - dest_vrq = hwc->pf_dest_vrq_id; - dest_vrcq = hwc->pf_dest_vrcq_id;
drivers/net/ethernet/microsoft/mana/hw_channel.c int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len, · line 900
Quoted 10 lines
drivers/net/ethernet/microsoft/mana/hw_channel.c +7
-1- } +/* The hardware reports the HWC destination queues through +* HWC_INIT_DATA_DEST_RQ_ID and HWC_INIT_DATA_DEST_CQ_ID, and +* always supplies values that are valid for this function, so no +* PF-specific handling is needed here. +*/ + dest_vrq = hwc->dest_vrq_id; + dest_vrcq = hwc->dest_vrcq_id; err =mana_hwc_post_tx_wqe (txq, tx_wr, dest_vrq, dest_vrcq, false);
[Severity: High]
This is a pre-existing issue, but should there be a call to reinit_completion(&ctx->comp_event) here before posting the WQE to the hardware to ensure stale completions are cleared?
When mana_hwc_send_request() times out, it appears to jump to the out label and immediately release the msg_id back to the pool via mana_hwc_put_msg_index(). If a delayed hardware response arrives later, mana_hwc_handle_resp() will process it:
mana_hwc_handle_resp() {
...
ctx->status_code = resp_msg->status;
memcpy(ctx->output_buf, resp_msg, resp_len);
out:
ctx->error = err;
...
complete(&ctx->comp_event);
}If another thread calls mana_hwc_send_request() and reuses the same msg_id, could this late response write to a stale ctx->output_buf and cause stack corruption or overwrite the new request's data?
Furthermore, without clearing the completion state, wouldn't the delayed complete() call leave the completion marked as done, causing the new request's wait_for_completion_timeout() to falsely complete immediately?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Thu, 10 Sep 2026 01:44:27 +0000 you wrote:
The hardware provides valid HWC destination vRQ and vRCQ IDs for all PFs and VFs. Use these IDs unconditionally in
mana_hwc_send_request(), as the PF-specific gate is not required.Signed-off-by Manish Awasthi <[email protected]>Reviewed-by Long Li <[email protected]>Reviewed-by Haiyang Zhang <[email protected]>[...]
Here is the summary with links:
- [net-next,v2] net: mana: Use the HWC destination queues reported by the hardware
https://git.kernel.org/netdev/net-next/c/4e8b65ecb64c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html