From: Jakub Kicinski <kuba@kernel.org>
To: longli@microsoft.com
Cc: Jakub Kicinski <kuba@kernel.org>,
kotaranov@microsoft.com, davem@davemloft.net, pabeni@redhat.com,
edumazet@google.com, andrew+netdev@lunn.ch, jgg@ziepe.ca,
leon@kernel.org, haiyangz@microsoft.com, kys@microsoft.com,
wei.liu@kernel.org, decui@microsoft.com,
shradhagupta@linux.microsoft.com, horms@kernel.org,
ernis@linux.microsoft.com, stephen@networkplumber.org,
netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v6 2/7] net: mana: fix HWC RQ/SQ buffer size swap
Date: Wed, 12 Aug 2026 16:46:52 -0700 [thread overview]
Message-ID: <20260812234652.2193454-1-kuba@kernel.org> (raw)
In-Reply-To: <20260811023823.2391255-3-longli@microsoft.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
net: mana: fix HWC RQ/SQ buffer size swap
The patch swaps the message sizes used to allocate the HWC RQ and SQ so the
RQ (which receives responses) is sized by max_resp_msg_size and the SQ
(which sends requests) by max_req_msg_size. It also stores
max_resp_msg_size in struct hw_channel_context and uses it as the RX slot
stride in mana_hwc_rx_event_handler(). The commit message notes both sizes
are 0x1000 today, so the previous swap had no observable effect.
> diff --git a/drivers/net/ethernet/microsoft/mana/hw_channel.c b/drivers/net/ethernet/microsoft/mana/hw_channel.c
> index 409e20caeccdc..3f011ebbe7b3e 100644
> --- a/drivers/net/ethernet/microsoft/mana/hw_channel.c
> +++ b/drivers/net/ethernet/microsoft/mana/hw_channel.c
[ ... ]
> @@ -733,14 +733,14 @@ static int mana_hwc_init_queues(struct hw_channel_context *hwc, u16 q_depth,
> goto out;
> }
>
> - err = mana_hwc_create_wq(hwc, GDMA_RQ, q_depth, max_req_msg_size,
> + err = mana_hwc_create_wq(hwc, GDMA_RQ, q_depth, max_resp_msg_size,
> hwc->cq, &hwc->rxq);
> if (err) {
> dev_err(hwc->dev, "Failed to create HWC RQ: %d\n", err);
> goto out;
> }
>
> - err = mana_hwc_create_wq(hwc, GDMA_SQ, q_depth, max_resp_msg_size,
> + err = mana_hwc_create_wq(hwc, GDMA_SQ, q_depth, max_req_msg_size,
> hwc->cq, &hwc->txq);
> if (err) {
> dev_err(hwc->dev, "Failed to create HWC SQ: %d\n", err);
> @@ -749,6 +749,7 @@ static int mana_hwc_init_queues(struct hw_channel_context *hwc, u16 q_depth,
>
> hwc->num_inflight_msg = q_depth;
> hwc->max_req_msg_size = max_req_msg_size;
> + hwc->max_resp_msg_size = max_resp_msg_size;
[Severity: Medium]
This isn't a bug introduced by this patch, but while looking at how these
two fields are produced and consumed, the hardware-reported sizes appear to
be dead: is the negotiated-size half of this interface still expected to do
something?
mana_hwc_establish_channel() hands the device-reported values back to its
caller:
*q_depth = hwc->hwc_init_q_depth_max;
*max_req_msg_size = hwc->hwc_init_max_req_msg_size;
*max_resp_msg_size = hwc->hwc_init_max_resp_msg_size;
and mana_hwc_create_channel() forwards them:
err = mana_hwc_test_channel(gc->hwc.driver_data,
HW_CHANNEL_VF_BOOTSTRAP_QUEUE_DEPTH,
max_req_msg_size, max_resp_msg_size);
but the body of mana_hwc_test_channel() references neither
max_req_msg_size nor max_resp_msg_size, and nothing else applies them to
the already-created queues or to hw_channel_context. So the fields set
here in mana_hwc_init_queues() permanently hold the bootstrap constants
HW_CHANNEL_MAX_REQUEST_SIZE / HW_CHANNEL_MAX_RESPONSE_SIZE (both 0x1000),
which matches the commit message.
Two peer consumers do read hwc->max_req_msg_size as if it were the
hardware-negotiated request bound. mana_gd_create_dma_region() in
gdma_main.c uses it to reject oversized commands:
if (req_msg_size > hwc->max_req_msg_size)
return -EINVAL;
and mana_ib_gd_create_dma_region() in drivers/infiniband/hw/mana/main.c
sizes both its request buffer and its page-list capacity from it:
max_pgs_create_cmd =
(hwc->max_req_msg_size - sizeof(*create_req)) / sizeof(u64);
...
request_buf = kzalloc(hwc->max_req_msg_size, GFP_KERNEL);
If a device ever reported HWC_INIT_DATA_MAX_REQUEST smaller than 0x1000
(recorded into hwc->hwc_init_max_req_msg_size by
mana_hwc_init_event_handler()), would those callers keep building up to 4KB
commands that the hardware then rejects, and would a larger reported value
simply be ignored? There is no memory-safety consequence today since the
SQ buffer and that bound are the same 0x1000 value after this patch, but
would it be worth either applying the reported sizes or dropping the unused
mana_hwc_test_channel() parameters?
next prev parent reply other threads:[~2026-08-12 23:46 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 2:38 [PATCH net v6 0/7] net: mana: HW channel reliability and hardening fixes Long Li
2026-08-11 2:38 ` [PATCH net v6 1/7] net: mana: RCU-protect gc->cq_table lookups against concurrent CQ destroy Long Li
2026-08-11 8:18 ` Leon Romanovsky
2026-08-11 21:25 ` [EXTERNAL] " Long Li
2026-08-12 23:46 ` Jakub Kicinski
2026-08-13 0:25 ` [EXTERNAL] " Long Li
2026-08-11 2:38 ` [PATCH net v6 2/7] net: mana: fix HWC RQ/SQ buffer size swap Long Li
2026-08-12 23:46 ` Jakub Kicinski [this message]
2026-08-13 0:47 ` [EXTERNAL] " Long Li
2026-08-11 2:38 ` [PATCH net v6 3/7] net: mana: free HWC comp_buf after destroying the EQ Long Li
2026-08-12 23:46 ` Jakub Kicinski
2026-08-13 0:52 ` [EXTERNAL] " Long Li
2026-08-11 2:38 ` [PATCH net v6 4/7] net: mana: validate hardware-supplied values in the HWC RX path Long Li
2026-08-12 23:46 ` Jakub Kicinski
2026-08-13 1:20 ` [EXTERNAL] " Long Li
2026-08-11 2:38 ` [PATCH net v6 5/7] net: mana: fix HWC teardown safety with setup_active flag and destroy ordering Long Li
2026-08-12 23:46 ` Jakub Kicinski
2026-08-13 1:42 ` [EXTERNAL] " Long Li
2026-08-11 2:38 ` [PATCH net v6 6/7] net: mana: fix stale HWC response after command timeout Long Li
2026-08-12 23:46 ` Jakub Kicinski
2026-08-11 2:38 ` [PATCH net v6 7/7] net: mana: keep max_num_cqs immutable once cq_table is allocated Long Li
2026-08-12 23:47 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260812234652.2193454-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=edumazet@google.com \
--cc=ernis@linux.microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=horms@kernel.org \
--cc=jgg@ziepe.ca \
--cc=kotaranov@microsoft.com \
--cc=kys@microsoft.com \
--cc=leon@kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shradhagupta@linux.microsoft.com \
--cc=stephen@networkplumber.org \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox