🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24959

[PATCH net-next v13 5/5] net: mana: use the reported HWC queue depth

#24959
From: Wei Hu
Date: Tue, 01 Dec 2026 04:04
574 lines
27162 bytes
From: Long Li <longli@microsoft.com>
Date: Mon, 24 Aug 2026 20:04:01 +0000

The bootstrap channel handles one request at a time. Rebuild it at the
PF-reported depth if the descriptors fit in the fixed 4 KiB rings and
the reported message sizes match the bootstrap allocations. Otherwise
keep the bootstrap queues. MAX_RESPONSE limits what the VF can send;
MAX_REQUEST limits what it can receive.

Test the rebuilt channel before publishing it. If the test fails,
restore and test a depth-one channel without overwriting the firmware
timeout. Reuse no queue memory until the PF acknowledges teardown.

Signed-off-by: Long Li <longli@microsoft.com>
Signed-off-by: Wei Hu <weh@microsoft.com>
---
 drivers/infiniband/hw/mana/main.c             |  12 +-
 .../net/ethernet/microsoft/mana/gdma_main.c   |   2 +-
 .../net/ethernet/microsoft/mana/hw_channel.c  | 295 +++++++++++++++---
 include/net/mana/hw_channel.h                 |  15 +-
 4 files changed, 266 insertions(+), 58 deletions(-)

diff --git a/drivers/infiniband/hw/mana/main.c b/drivers/infiniband/hw/mana/main.c
index 60a9f15e5e8c1d0c807ded7177d8da909a0626da..baf894342c156d1e4e71ec0476c829ee90957c82 100644
--- a/drivers/infiniband/hw/mana/main.c
+++ b/drivers/infiniband/hw/mana/main.c
@@ -415,28 +415,31 @@ static int mana_ib_gd_create_dma_region(struct mana_ib_dev *dev, struct ib_umem
 	unsigned int create_req_msg_size;
 	struct hw_channel_context *hwc;
 	struct ib_block_iter biter;
-	size_t max_pgs_add_cmd = 0;
+	size_t max_pgs_add_cmd;
 	size_t max_pgs_create_cmd;
 	struct gdma_context *gc;
 	size_t num_pages_total;
 	unsigned int tail = 0;
+	u32 req_limit;
 	u64 *page_addr_list;
 	void *request_buf;
 	int err = 0;
 
 	gc = mdev_to_gc(dev);
 	hwc = gc->hwc.driver_data;
+	req_limit = mana_hwc_get_max_req_size(hwc);
 
 	num_pages_total = ib_umem_num_dma_blocks(umem, page_sz);
 
 	max_pgs_create_cmd =
-		(hwc->max_req_msg_size - sizeof(*create_req)) / sizeof(u64);
+		(req_limit - sizeof(*create_req)) / sizeof(u64);
+	max_pgs_add_cmd = (req_limit - sizeof(*add_req)) / sizeof(u64);
 	num_pages_to_handle =
 		min_t(size_t, num_pages_total, max_pgs_create_cmd);
 	create_req_msg_size =
 		struct_size(create_req, page_addr_list, num_pages_to_handle);
 
-	request_buf = kzalloc(hwc->max_req_msg_size, GFP_KERNEL);
+	request_buf = kzalloc(req_limit, GFP_KERNEL);
 	if (!request_buf)
 		return -ENOMEM;
 
@@ -479,9 +482,6 @@ static int mana_ib_gd_create_dma_region(struct mana_ib_dev *dev, struct ib_umem
 			if (err)
 				goto out;
 
-			max_pgs_add_cmd = (hwc->max_req_msg_size -
-				sizeof(*add_req)) / sizeof(u64);
-
 			add_req = request_buf;
 			add_req->dma_region_handle = *gdma_region;
 			add_req->reserved3 = 0;
diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c
index c921a4065daf98c11accdaa2daaee923144cba18..470ee6f08a195b2e34880be0be13b5c148fe86e3 100644
--- a/drivers/net/ethernet/microsoft/mana/gdma_main.c
+++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c
@@ -1360,7 +1360,7 @@ static int mana_gd_create_dma_region(struct gdma_dev *gd,
 	/* The caller must keep the HWC alive throughout queue creation. */
 	hwc = gc->hwc.driver_data;
 	req_msg_size = struct_size(req, page_addr_list, num_page);
-	if (req_msg_size > hwc->max_req_msg_size)
+	if (req_msg_size > mana_hwc_get_max_req_size(hwc))
 		return -EINVAL;
 
 	req = kzalloc(req_msg_size, GFP_KERNEL);
diff --git a/drivers/net/ethernet/microsoft/mana/hw_channel.c b/drivers/net/ethernet/microsoft/mana/hw_channel.c
index 5c2385c4e162078fcbc9c12b14eac079d189cb25..34987ee19a31eddc770831c9b141858ac47207cc 100644
--- a/drivers/net/ethernet/microsoft/mana/hw_channel.c
+++ b/drivers/net/ethernet/microsoft/mana/hw_channel.c
@@ -4,6 +4,7 @@
 #include <net/mana/gdma.h>
 #include <net/mana/mana.h>
 #include <net/mana/hw_channel.h>
+#include <linux/sizes.h>
 #include <linux/vmalloc.h>
 
 /* Only this private result permits local teardown without a PF response. */
@@ -67,12 +68,12 @@ static void mana_hwc_check_timeouts(struct hw_channel_context *hwc, ktime_t now)
 }
 
 static int mana_hwc_try_get_msg_index(struct hw_channel_context *hwc,
-				      void *resp, u32 resp_len,
+				      u32 req_len, void *resp, u32 resp_len,
 				      struct hwc_caller_ctx **caller_ctx)
 {
 	struct gdma_resource *r = &hwc->inflight_msg_res;
 	struct hwc_caller_ctx *ctx;
-	u32 index;
+	u32 req_limit, resp_limit, index;
 
 	guard(spinlock_irqsave)(&r->lock);
 	if (hwc->state == HWC_TIMED_OUT)
@@ -80,6 +81,15 @@ static int mana_hwc_try_get_msg_index(struct hw_channel_context *hwc,
 	if (hwc->state != HWC_READY)
 		return -ENODEV;
 
+	req_limit = mana_hwc_get_max_req_size(hwc);
+	resp_limit = min(hwc->rx_msg_size_limit, hwc->max_req_msg_size);
+	if (req_len > req_limit || resp_len > resp_limit) {
+		dev_err(hwc->dev,
+			"HWC: message sizes req=%u/%u resp=%u/%u exceed channel maxima\n",
+			req_len, req_limit, resp_len, resp_limit);
+		return -EMSGSIZE;
+	}
+
 	index = find_first_zero_bit(r->map, r->size);
 	if (index >= r->size)
 		return -EBUSY;
@@ -228,7 +238,8 @@ static void mana_hwc_init_event_handler(void *ctx, struct gdma_queue *q_self,
 			break;
 
 		case HWC_INIT_DATA_QUEUE_DEPTH:
-			hwc->hwc_init_q_depth_max = (u16)val;
+			/* Preserve the full 24-bit report for validation. */
+			hwc->hwc_init_q_depth_max = val;
 			break;
 
 		case HWC_INIT_DATA_MAX_REQUEST:
@@ -605,7 +616,8 @@ static int mana_hwc_alloc_dma_buf(struct hw_channel_context *hwc, u16 q_depth,
 
 	dma_buf->num_reqs = q_depth;
 
-	buf_size = MANA_PAGE_ALIGN(q_depth * max_msg_size);
+	/* mana_gd_alloc_memory() requires a power-of-two length. */
+	buf_size = roundup_pow_of_two(MANA_PAGE_ALIGN(q_depth * max_msg_size));
 
 	gmi = &dma_buf->mem_info;
 	err = mana_gd_alloc_memory(gc, buf_size, gmi, false);
@@ -804,10 +816,15 @@ static int mana_hwc_test_channel(struct hw_channel_context *hwc)
 	return err;
 }
 
-static int mana_hwc_establish_channel(struct hw_channel_context *hwc,
-				      u16 *q_depth,
-				      u32 *max_req_msg_size,
-				      u32 *max_resp_msg_size)
+struct mana_hwc_init_report {
+	u32 queue_depth;
+	u32 max_req_msg_size;
+	u32 max_resp_msg_size;
+};
+
+static int
+mana_hwc_establish_channel(struct hw_channel_context *hwc,
+			   struct mana_hwc_init_report *report)
 {
 	struct gdma_context *gc = hwc->gdma_dev->gdma_context;
 	struct gdma_queue *rq = hwc->rxq->gdma_wq;
@@ -819,6 +836,15 @@ static int mana_hwc_establish_channel(struct hw_channel_context *hwc,
 	u32 cq_id;
 	int err;
 
+	hwc->hwc_init_q_depth_max = 0;
+	hwc->hwc_init_max_req_msg_size = 0;
+	hwc->hwc_init_max_resp_msg_size = 0;
+	hwc->hwc_init_max_num_cqs = 0;
+	hwc->hwc_init_cq_id = 0;
+	gc->hwc.pdid = INVALID_PDID;
+	hwc->dest_vrq_id = 0;
+	hwc->dest_vrcq_id = 0;
+
 	gc->hwc.doorbell = INVALID_DOORBELL;
 	WRITE_ONCE(hwc->hwc_init_error, 0);
 	init_completion(&hwc->hwc_init_eqe_comp);
@@ -839,9 +865,9 @@ static int mana_hwc_establish_channel(struct hw_channel_context *hwc,
 	if (err)
 		return err;
 
-	*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;
+	report->queue_depth = hwc->hwc_init_q_depth_max;
+	report->max_req_msg_size = hwc->hwc_init_max_req_msg_size;
+	report->max_resp_msg_size = hwc->hwc_init_max_resp_msg_size;
 
 	/* Snapshot the device-reported count and id once, so the same value
 	 * sizes, bounds and indexes cq_table even across the sleeping
@@ -891,6 +917,9 @@ static int mana_hwc_init_queues(struct hw_channel_context *hwc, u16 q_depth,
 {
 	int err;
 
+	if (q_depth > U16_MAX / 2)
+		return -EINVAL;
+
 	err = mana_hwc_init_inflight_msg(hwc, q_depth);
 	if (err)
 		return err;
@@ -923,10 +952,11 @@ 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;
 
 	return 0;
 out:
-	/* mana_hwc_create_channel() will do the cleanup.*/
+	/* The setup path tears down any partially initialized queues. */
 	return err;
 }
 
@@ -942,6 +972,33 @@ static void mana_hwc_clear_cq_table(struct gdma_context *gc)
 	vfree(cq_table);
 }
 
+/* Setup is private; runtime teardown has unpublished and drained senders. */
+static void mana_hwc_destroy_queues(struct hw_channel_context *hwc)
+{
+	struct gdma_context *gc = hwc->gdma_dev->gdma_context;
+
+	mana_hwc_clear_cq_table(gc);
+
+	if (hwc->cq) {
+		mana_hwc_destroy_cq(gc, hwc->cq);
+		hwc->cq = NULL;
+	}
+
+	if (hwc->txq) {
+		mana_hwc_destroy_wq(hwc, hwc->txq);
+		hwc->txq = NULL;
+	}
+	if (hwc->rxq) {
+		mana_hwc_destroy_wq(hwc, hwc->rxq);
+		hwc->rxq = NULL;
+	}
+
+	kfree(hwc->caller_ctx);
+	hwc->caller_ctx = NULL;
+	mana_gd_free_res_map(&hwc->inflight_msg_res);
+	hwc->num_inflight_msg = 0;
+}
+
 static int mana_hwc_publish_channel(struct hw_channel_context *hwc)
 {
 	struct gdma_context *gc = hwc->gdma_dev->gdma_context;
@@ -1028,45 +1085,39 @@ static void mana_hwc_fence_channel(struct gdma_context *gc,
 		mana_hwc_unpublish_cq(gc, hwc->cq->gdma_cq);
 }
 
-static bool mana_hwc_release_channel(struct hw_channel_context *hwc)
+static int mana_hwc_teardown_queues(struct hw_channel_context *hwc)
 {
 	struct gdma_context *gc = hwc->gdma_dev->gdma_context;
 	int err;
 
-	mana_hwc_stop_channel(hwc);
-
-	/* An unacknowledged destroy leaves the PF's mappings live.  Fence
-	 * software dispatch, but retain every PF-visible allocation.
-	 */
 	err = mana_smc_teardown_hwc(&gc->shm_channel, false,
 				    &hwc->setup_active);
 	if (err) {
+		hwc->teardown_failed = true;
 		dev_err(hwc->dev,
 			"HWC teardown failed: %d, retaining PF-visible resources\n",
 			err);
 		mana_hwc_fence_channel(gc, hwc);
-		mana_hwc_retain_channel(hwc);
-		return false;
+		return err;
 	}
 
-	mana_hwc_clear_cq_table(gc);
-
-	/* Fence the EQ before releasing the remaining HWC state. */
-	if (hwc->cq)
-		mana_hwc_destroy_cq(hwc->gdma_dev->gdma_context, hwc->cq);
+	mana_hwc_destroy_queues(hwc);
 
-	if (hwc->txq)
-		mana_hwc_destroy_wq(hwc, hwc->txq);
-
-	if (hwc->rxq)
-		mana_hwc_destroy_wq(hwc, hwc->rxq);
+	return 0;
+}
 
-	kfree(hwc->caller_ctx);
-	hwc->caller_ctx = NULL;
+static bool mana_hwc_release_channel(struct hw_channel_context *hwc)
+{
+	struct gdma_context *gc = hwc->gdma_dev->gdma_context;
 
-	mana_gd_free_res_map(&hwc->inflight_msg_res);
+	mana_hwc_stop_channel(hwc);
 
-	hwc->num_inflight_msg = 0;
+	if (hwc->teardown_failed || mana_hwc_teardown_queues(hwc)) {
+		/* Leave any retry to the next destroy, not this unwind. */
+		hwc->teardown_failed = false;
+		mana_hwc_retain_channel(hwc);
+		return false;
+	}
 
 	hwc->gdma_dev->doorbell = INVALID_DOORBELL;
 	hwc->gdma_dev->pdid = INVALID_PDID;
@@ -1115,32 +1166,176 @@ void mana_hwc_free_retained_channel(struct gdma_context *gc)
 	gc->hwc.gdma_context = NULL;
 }
 
-static int mana_hwc_create_bootstrap_channel(struct hw_channel_context *hwc)
+static int
+mana_hwc_validate_report(struct hw_channel_context *hwc,
+			 const struct mana_hwc_init_report *report,
+			 u32 expected_depth, bool check_depth,
+			 bool require_exact_msg_sizes)
+{
+	if (!report->queue_depth || !report->max_req_msg_size ||
+	    !report->max_resp_msg_size) {
+		dev_err(hwc->dev,
+			"HWC: invalid maxima depth=%u req=%u resp=%u\n",
+			report->queue_depth, report->max_req_msg_size,
+			report->max_resp_msg_size);
+		return -EPROTO;
+	}
+
+	if (require_exact_msg_sizes &&
+	    (report->max_req_msg_size != HW_CHANNEL_MAX_REQUEST_SIZE ||
+	     report->max_resp_msg_size != HW_CHANNEL_MAX_RESPONSE_SIZE)) {
+		dev_err(hwc->dev,
+			"HWC: rebuilt message maxima req=%u resp=%u, expected %u/%u\n",
+			report->max_req_msg_size, report->max_resp_msg_size,
+			HW_CHANNEL_MAX_REQUEST_SIZE,
+			HW_CHANNEL_MAX_RESPONSE_SIZE);
+		return -EPROTO;
+	}
+
+	if (check_depth && report->queue_depth != expected_depth) {
+		dev_err(hwc->dev, "HWC: rebuilt depth %u, expected %u\n",
+			report->queue_depth, expected_depth);
+		return -EPROTO;
+	}
+
+	return 0;
+}
+
+static int mana_hwc_finish_channel(struct hw_channel_context *hwc,
+				   const struct mana_hwc_init_report *report)
+{
+	int err;
+
+	/* The VF receives up to MAX_REQUEST and sends up to MAX_RESPONSE. */
+	hwc->rx_msg_size_limit = report->max_req_msg_size;
+	hwc->tx_msg_size_limit = report->max_resp_msg_size;
+
+	err = mana_hwc_test_channel(hwc);
+	if (err)
+		dev_err(hwc->dev, "Failed to test HWC: %d\n", err);
+
+	return err;
+}
+
+static int mana_hwc_build_channel(struct hw_channel_context *hwc, u16 q_depth,
+				  struct mana_hwc_init_report *report)
 {
-	u32 max_req_msg_size, max_resp_msg_size;
-	u16 q_depth_max;
 	int err;
 
-	err = mana_hwc_init_queues(hwc, HW_CHANNEL_VF_BOOTSTRAP_QUEUE_DEPTH,
+	err = mana_hwc_init_queues(hwc, q_depth,
 				   HW_CHANNEL_MAX_REQUEST_SIZE,
 				   HW_CHANNEL_MAX_RESPONSE_SIZE);
 	if (err) {
-		dev_err(hwc->dev, "Failed to initialize HWC: %d\n", err);
+		dev_err(hwc->dev, "Failed to initialize HWC depth %u: %d\n",
+			q_depth, err);
 		return err;
 	}
 
-	err = mana_hwc_establish_channel(hwc, &q_depth_max, &max_req_msg_size,
-					 &max_resp_msg_size);
-	if (err) {
-		dev_err(hwc->dev, "Failed to establish HWC: %d\n", err);
+	err = mana_hwc_establish_channel(hwc, report);
+	if (err)
+		dev_err(hwc->dev, "Failed to establish HWC depth %u: %d\n",
+			q_depth, err);
+
+	return err;
+}
+
+static int
+mana_hwc_restore_bootstrap(struct hw_channel_context *hwc,
+			   struct mana_hwc_init_report *report)
+{
+	int err;
+
+	err = mana_hwc_build_channel(hwc,
+				     HW_CHANNEL_VF_BOOTSTRAP_QUEUE_DEPTH,
+				     report);
+	if (err)
 		return err;
-	}
 
-	err = mana_hwc_test_channel(hwc);
+	err = mana_hwc_validate_report(hwc, report, 0, false, false);
 	if (err)
-		dev_err(hwc->dev, "Failed to test HWC: %d\n", err);
+		return err;
 
-	return err;
+	return mana_hwc_finish_channel(hwc, report);
+}
+
+static int mana_hwc_rebuild_channel(struct hw_channel_context *hwc,
+				    u16 q_depth,
+				    struct mana_hwc_init_report *report)
+{
+	int cleanup_err;
+	int err;
+
+	err = mana_hwc_teardown_queues(hwc);
+	if (err)
+		return err;
+
+	err = mana_hwc_build_channel(hwc, q_depth, report);
+	if (!err)
+		err = mana_hwc_validate_report(hwc, report, q_depth,
+					       true, true);
+	if (!err)
+		err = mana_hwc_finish_channel(hwc, report);
+	if (!err)
+		return 0;
+
+	dev_warn(hwc->dev,
+		 "HWC depth %u rebuild failed, restoring bootstrap: %d\n",
+		 q_depth, err);
+
+	cleanup_err = mana_hwc_teardown_queues(hwc);
+	if (cleanup_err)
+		return cleanup_err;
+
+	return mana_hwc_restore_bootstrap(hwc, report);
+}
+
+static bool mana_hwc_depth_fits(u32 depth)
+{
+	/* ESTABLISH_HWC supplies addresses, not ring sizes. The PF keeps the
+	 * same 4 KiB descriptor ring wrap points when the depth changes.
+	 */
+	return depth <= SZ_4K / GDMA_MAX_SQE_SIZE &&
+	       depth <= SZ_4K / GDMA_MAX_RQE_SIZE &&
+	       depth <= SZ_4K / (2 * GDMA_CQE_SIZE) &&
+	       depth <= SZ_4K / (2 * GDMA_EQE_SIZE);
+}
+
+static int mana_hwc_prepare_channel(struct hw_channel_context *hwc)
+{
+	struct mana_hwc_init_report report;
+	u16 rebuild_depth;
+	int err;
+
+	err = mana_hwc_build_channel(hwc,
+				     HW_CHANNEL_VF_BOOTSTRAP_QUEUE_DEPTH,
+				     &report);
+	if (err)
+		return err;
+
+	err = mana_hwc_validate_report(hwc, &report, 0, false, false);
+	if (err)
+		return err;
+
+	if (!mana_hwc_depth_fits(report.queue_depth)) {
+		dev_warn(hwc->dev,
+			 "HWC depth %u exceeds ring capacity, keeping bootstrap\n",
+			 report.queue_depth);
+	} else if (report.queue_depth >
+		   HW_CHANNEL_VF_BOOTSTRAP_QUEUE_DEPTH &&
+		   (report.max_req_msg_size != HW_CHANNEL_MAX_REQUEST_SIZE ||
+		    report.max_resp_msg_size != HW_CHANNEL_MAX_RESPONSE_SIZE)) {
+		dev_warn(hwc->dev,
+			 "HWC maxima req=%u resp=%u differ from rebuild policy %u/%u, keeping bootstrap\n",
+			 report.max_req_msg_size, report.max_resp_msg_size,
+			 HW_CHANNEL_MAX_REQUEST_SIZE,
+			 HW_CHANNEL_MAX_RESPONSE_SIZE);
+	} else if (report.queue_depth >
+		   HW_CHANNEL_VF_BOOTSTRAP_QUEUE_DEPTH) {
+		rebuild_depth = report.queue_depth;
+		return mana_hwc_rebuild_channel(hwc, rebuild_depth, &report);
+	}
+
+	return mana_hwc_finish_channel(hwc, &report);
 }
 
 int mana_hwc_create_channel(struct gdma_context *gc)
@@ -1173,7 +1368,7 @@ int mana_hwc_create_channel(struct gdma_context *gc)
 	gd->pdid = INVALID_PDID;
 	gd->doorbell = INVALID_DOORBELL;
 
-	err = mana_hwc_create_bootstrap_channel(hwc);
+	err = mana_hwc_prepare_channel(hwc);
 	if (err) {
 		mana_hwc_release_channel(hwc);
 		return err;
@@ -1301,8 +1496,8 @@ int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len,
 	int err;
 
 	wait_event(hwc->admission_waitq,
-		   (err = mana_hwc_try_get_msg_index(hwc, resp, resp_len,
-						    &ctx)) != -EBUSY);
+		   (err = mana_hwc_try_get_msg_index(hwc, req_len, resp,
+						    resp_len, &ctx)) != -EBUSY);
 	if (err)
 		goto out;
 
diff --git a/include/net/mana/hw_channel.h b/include/net/mana/hw_channel.h
index 6ff445da89f443f06eec4d95fbab33eab0486f3e..c8261609161058e736fe4a3833e3b172ac845e12 100644
--- a/include/net/mana/hw_channel.h
+++ b/include/net/mana/hw_channel.h
@@ -5,6 +5,7 @@
 #define _HW_CHANNEL_H
 
 #include <linux/ktime.h>
+#include <linux/minmax.h>
 
 #define DEFAULT_LOG2_THROTTLING_FOR_ERROR_EQ  4
 
@@ -195,8 +196,12 @@ struct hw_channel_context {
 
 	u16 num_inflight_msg;
 	u32 max_req_msg_size;
+	u32 max_resp_msg_size;
+	/* Immutable reported maxima for the final RQ and SQ directions. */
+	u32 rx_msg_size_limit;
+	u32 tx_msg_size_limit;
 
-	u16 hwc_init_q_depth_max;
+	u32 hwc_init_q_depth_max;
 	u32 hwc_init_max_req_msg_size;
 	u32 hwc_init_max_resp_msg_size;
 	u32 hwc_init_max_num_cqs;
@@ -224,6 +229,7 @@ struct hw_channel_context {
 
 	/* The PF may own the HWC queues while this is true. */
 	bool setup_active;
+	bool teardown_failed;
 
 	/* mana_gd_send_request() callers, including waiters; under hwc_lock. */
 	unsigned int active_senders;
@@ -231,6 +237,13 @@ struct hw_channel_context {
 	struct hwc_caller_ctx *caller_ctx;
 };
 
+/* Host-to-PF requests are bounded by the negotiated TX limit and SQ stride. */
+static inline u32
+mana_hwc_get_max_req_size(const struct hw_channel_context *hwc)
+{
+	return min(hwc->tx_msg_size_limit, hwc->max_resp_msg_size);
+}
+
 int mana_hwc_create_channel(struct gdma_context *gc);
 void mana_hwc_destroy_channel(struct gdma_context *gc);
 void mana_hwc_free_retained_channel(struct gdma_context *gc);
Technical Details
Message-ID: <hwc-v13.ab4ca86c3bf24a51ad8a84cc8a0220d1.5@linux.microsoft.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374691-linux-kernel-netdev=dewy.ru
References: <hwc-v13.ab4ca86c3bf24a51ad8a84cc8a0220d1.0@linux.microsoft.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374691-linux-kernel-netdev=dewy.ru
From: weh@linux.microsoft.com (Wei Hu)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v13 5/5] net: mana: use the reported HWC queue depth
Date: Tue,  1 Dec 2026 04:04:01 +0000
Organization: Usenet Network
Message-ID: <hwc-v13.ab4ca86c3bf24a51ad8a84cc8a0220d1.5@linux.microsoft.com>
References: <hwc-v13.ab4ca86c3bf24a51ad8a84cc8a0220d1.0@linux.microsoft.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1609757"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:b16ZJF5w2iiVChoHOEQMbIUWOb0= sha256:jpP6JIZuVm9BIuXmySsYMUEkfghjOidcAAjCSapMP68=
	sha1:qAJrogysYpcG9VLXlki2JimKN7M= sha256:CJcVwWQTgkZ2W9x6wWJCYgbfLxxlpsG0ghuSnQhhPTA=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id D6BE4C9997; Tue,  1 Dec 2026 07:05:11 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=linux.microsoft.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id u3cNIU8W0oDY;
	Tue,  1 Dec 2026 07:05:08 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374691-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.microsoft.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 02AD2117221; Tue,  1 Dec 2026 07:04:59 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 89E06289A1; Tue,  1 Dec 2026 04:04:40 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail;
	t=1796097879;
	b=duHPse3PmRSGuIS9YgHmkeIKSXqwEW5TzLl7JsqGWwm6ghBUsFDol3NLkw1BzjMKqWAL
	 hfkwNP1jcXU7rg97cm8O8gKfGIS1lRTUPVolKt54J6DYmMYEz8M0S9zCLbU7H77aH/+oD
	 p3uT+Fs8dmDDs1XHmnI+pk7WG3ZK1wLy/jxrTu52AutCPDUkml0e6/oMInEQ2R33s5JDZ
	 nU4jKF5zdwHzGUshZ3NY3umMJPOAz6VoxBT67WXs4WV2Viaf9VSq9MN/vEAyOKQQvcleA
	 hhy1nFqCaZIIuqvLqALJQ111Qo8FkuOQOlQ+VXDuGq0aD3b41G9jz8gDw3a2RYe1q6A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796097879;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Filter:
	 DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=fG6e32uqEtRwpRdZqb2zCOZz9g1QsChc5vOCA7VMrJ8=;
	b=m5dxHTvBtONzCzznGSc5G1vlczWTurWVXFNqX7jxVIaQXPaDDIpWHO4Aj1wvCUKBo5fo
	 TuAutmHflvo0vvYRW39g3dsCusJBPYDc5UqK1tQAFVUI79ck7M9ZCHoByckd9JWQmZuJo
	 iLRHotTwEE00myemTxbuS7aNFdoWEoWcuntjVssjrRwbI8OgXaryfZ/ZKuj9GeFvDFcB/
	 bCywwMmpweyopfHsOdNm8Ko2nioIjur2LUa/EZ/kT8T5ZdD38dylqVN9wrdwdAL3lJrY9
	 8lcBzaMzczflv+4TdKSruKUIERH1xui6i3SWmQTS3pde03da415U0Qhw3yDUNAiFttw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.microsoft.com header.i=@linux.microsoft.com header.a=rsa-sha256 header.s=default header.b=Tc3Wanwf;
	dmarc=pass header.from=linux.microsoft.com;
	spf=pass smtp.mailfrom=linux.microsoft.com;
	arc=fail smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id D0181606A320;
	Tue,  1 Dec 2026 04:04:39 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.a=rsa-sha256 header.s=default header.b=Tc3Wanwf
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=13.77.154.182
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796097869;
	b=42dIjFGMfLsQvPSaA4AwhuaH8yF7+9FogtAF/cTVa3eK+NH0iQLlMNTV5gK/hP+7zWSk
	 sXQM70oY4CGGFLbd4gSEPR6YaxxjBNvWaxfwoEglMkVLx2X3j4h/WTq7SqQLEajGYW3zH
	 U2L8lCFLQ4ZOdOlC5TIKNhfSOWOkvritv5FNkSnm20nt97y05AbWbcfyGQnZKO6uJNRkk
	 IZaF1Nsjt16y+OhBWddwmfX9i0haqma1RyAYhLUDhMHtl46tq4rFxez1HyfjrdMkwp3IC
	 O8BJFkwnP2y6FNmTmZr2PrteW4q5i+cNcHPyQJrtuVONV85RyRmmncmCFTTgJK/w8KQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796097869;
	h=DMARC-Filter:Received:DKIM-Filter:DKIM-Signature:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding:X-Spam-Status:X-Spam-Checker-Version;
	bh=fG6e32uqEtRwpRdZqb2zCOZz9g1QsChc5vOCA7VMrJ8=;
	b=tJM9ss+cBI/WEzEA5YVWJqkkdMCK+Za6x4Xd+Nrr5STR8+7GEkPjAjmjIghGl7qVHcdH
	 oTJ+gTJIYz+0fzx++WPGwFD6KKZ05tNzTjJb6EyhwUyNjwJtSQyEs0Ac1waTc/d4JzHr+
	 GuKvj6GMDAHXfyY7QbuBKouw2pmVtiPbCcPHoZ3yuMNpmZueUK7WT3d3LZTzlZj/HODaO
	 Id13jJtcHG2LdAiqefV1ufuvcl5zMMw2MapMqEV6eBIbptVN7WnkLGQ11tseE+PW4/7fZ
	 cAACkaDYS+s7Nefw5ubpwjUWPZcKWvs4D5M/tyuLTol9zyxb/rUE/4sFOqGtpfBSW4g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.microsoft.com;
	spf=pass smtp.mailfrom=linux.microsoft.com;
	dkim=pass header.d=linux.microsoft.com header.i=@linux.microsoft.com header.a=rsa-sha256 header.s=default header.b=Tc3Wanwf;
	arc=none smtp.remote-ip=13.77.154.182
X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 74075606A68B;
	Tue,  1 Dec 2026 04:04:28 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 74075606A68B
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com
X-Received: from weh-cvm-dev-vm.y50bckvjo0hefgfnzfztsfttff.phxx.internal.cloudapp.net (unknown [20.169.55.37])
	by linux.microsoft.com (Postfix) with ESMTPSA id 22E9720B7168;
	Mon, 30 Nov 2026 20:04:17 -0800 (PST)
X-DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 22E9720B7168
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com;
	s=default; t=1796097858;
	bh=fG6e32uqEtRwpRdZqb2zCOZz9g1QsChc5vOCA7VMrJ8=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
	b=Tc3WanwfD//xki/3dEeLS+5qN3GSp7sAx79JTIwcKgeTzjgghjiGBvm8E3hND/TPV
	 vUXEcgbHfu+1Q/XulTgOybLcOFlLd7P7RF8OCR8utUBoUGiNEq8PmKZ4KqahlmQh5r
	 yipLJejX7jSnEt7PaQ4zR1duyAynAu4CxN3jCKrA=
X-Cc: netdev@vger.kernel.org,
	linux-rdma@vger.kernel.org,
	linux-hyperv@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	gargaditya@linux.microsoft.com,
	kees+treewide@kernel.org,
	kees@kernel.org,
	mawasthi@linux.microsoft.com,
	weh@microsoft.com,
	edumazet@kernel.org
X-Mailer: git-send-email 2.43.0
X-In-Reply-To: <hwc-v13.ab4ca86c3bf24a51ad8a84cc8a0220d1.0@linux.microsoft.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list