From: Guixin Liu <kanie@linux.alibaba.com>
To: hch@lst.de, sagi@grimberg.me, kbusch@kernel.org, kch@nvidia.com,
axboe@kernel.dk
Cc: linux-nvme@lists.infradead.org
Subject: [RFC PATCH V2 1/2] nvmet: rdma: utilize ib_device capability for setting max_queue_size
Date: Tue, 19 Dec 2023 15:32:24 +0800 [thread overview]
Message-ID: <1702971145-111009-2-git-send-email-kanie@linux.alibaba.com> (raw)
In-Reply-To: <1702971145-111009-1-git-send-email-kanie@linux.alibaba.com>
Respond with the smaller value between 1024 and the ib_device's
max_qp_wr as the RDMA max queue size.
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
---
drivers/nvme/target/rdma.c | 17 ++++++++++++++++-
include/linux/nvme-rdma.h | 2 ++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
index 4597bca..d546203 100644
--- a/drivers/nvme/target/rdma.c
+++ b/drivers/nvme/target/rdma.c
@@ -2002,7 +2002,22 @@ static u8 nvmet_rdma_get_mdts(const struct nvmet_ctrl *ctrl)
static u16 nvmet_rdma_get_max_queue_size(const struct nvmet_ctrl *ctrl)
{
- return NVME_RDMA_MAX_QUEUE_SIZE;
+ struct nvmet_rdma_queue *queue;
+ struct nvmet_port *nport = ctrl->port;
+ int max_qp_wr = 0;
+
+ /* Here nvmet_ctrl's port is already set. */
+ mutex_lock(&nvmet_rdma_queue_mutex);
+ list_for_each_entry(queue, &nvmet_rdma_queue_list, queue_list) {
+ if (queue->port == nport) {
+ max_qp_wr = queue->dev->device->attrs.max_qp_wr;
+ break;
+ }
+ }
+ mutex_unlock(&nvmet_rdma_queue_mutex);
+
+ return (u16)min_t(int, NVMET_QUEUE_SIZE,
+ max_qp_wr / (NVME_RDMA_SEND_WR_FACTOR + 1));
}
static const struct nvmet_fabrics_ops nvmet_rdma_ops = {
diff --git a/include/linux/nvme-rdma.h b/include/linux/nvme-rdma.h
index 4dd7e6f..c19858b 100644
--- a/include/linux/nvme-rdma.h
+++ b/include/linux/nvme-rdma.h
@@ -8,6 +8,8 @@
#define NVME_RDMA_MAX_QUEUE_SIZE 128
+#define NVME_RDMA_SEND_WR_FACTOR 3 /* MR, SEND, INV */
+
enum nvme_rdma_cm_fmt {
NVME_RDMA_CM_FMT_1_0 = 0x0,
};
--
1.8.3.1
next prev parent reply other threads:[~2023-12-19 7:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-19 7:32 [RFC PATCH V2 0/2] *** use rdma device capability to limit queue size *** Guixin Liu
2023-12-19 7:32 ` Guixin Liu [this message]
2023-12-19 7:32 ` [RFC PATCH V2 2/2] nvme: rdma: use ib_device's max_qp_wr to limit sqsize Guixin Liu
2023-12-20 9:17 ` Sagi Grimberg
2023-12-20 10:52 ` Max Gurtovoy
2023-12-20 19:27 ` Sagi Grimberg
2023-12-22 6:58 ` Guixin Liu
2023-12-24 1:37 ` Max Gurtovoy
2023-12-25 8:40 ` Guixin Liu
2023-12-25 8:59 ` Sagi Grimberg
2023-12-25 12:36 ` Max Gurtovoy
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=1702971145-111009-2-git-send-email-kanie@linux.alibaba.com \
--to=kanie@linux.alibaba.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=kch@nvidia.com \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/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