nvmet: set maxcmd to be per controller
authorMax Gurtovoy <mgurtovoy@nvidia.com>
Tue, 23 Jan 2024 14:40:27 +0000 (16:40 +0200)
committerKeith Busch <kbusch@kernel.org>
Sat, 2 Mar 2024 23:18:08 +0000 (15:18 -0800)
This is a preparation for having a dynamic configuration of max queue
size for a controller. Make sure that the maxcmd field stays the same as
the MQES (+1) value as we do today.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Israel Rukshin <israelr@nvidia.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/target/admin-cmd.c
drivers/nvme/target/discovery.c
drivers/nvme/target/nvmet.h
drivers/nvme/target/passthru.c

index 39cb570f833dde9ec57ed406547ffbbf705e546f..f5b7054a4a05e38f25c0a3a0a831458138bebcca 100644 (file)
@@ -428,7 +428,7 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
        id->cqes = (0x4 << 4) | 0x4;
 
        /* no enforcement soft-limit for maxcmd - pick arbitrary high value */
-       id->maxcmd = cpu_to_le16(NVMET_MAX_CMD);
+       id->maxcmd = cpu_to_le16(NVMET_MAX_CMD(ctrl));
 
        id->nn = cpu_to_le32(NVMET_MAX_NAMESPACES);
        id->mnan = cpu_to_le32(NVMET_MAX_NAMESPACES);
index 68e82ccc0e4e38ffcb2018cce0080741a5984925..ce54da8c6b3661e3a83e4cf53ac101f9262b7176 100644 (file)
@@ -282,7 +282,7 @@ static void nvmet_execute_disc_identify(struct nvmet_req *req)
        id->lpa = (1 << 2);
 
        /* no enforcement soft-limit for maxcmd - pick arbitrary high value */
-       id->maxcmd = cpu_to_le16(NVMET_MAX_CMD);
+       id->maxcmd = cpu_to_le16(NVMET_MAX_CMD(ctrl));
 
        id->sgls = cpu_to_le32(1 << 0); /* we always support SGLs */
        if (ctrl->ops->flags & NVMF_KEYED_SGLS)
index 6c8acebe1a1a61b8742d892c1ba2f7eb5d1e9364..144aca2fa6ad65b6a0072c8012f8b42fae50497d 100644 (file)
@@ -545,7 +545,7 @@ void nvmet_add_async_event(struct nvmet_ctrl *ctrl, u8 event_type,
 
 #define NVMET_QUEUE_SIZE       1024
 #define NVMET_NR_QUEUES                128
-#define NVMET_MAX_CMD          NVMET_QUEUE_SIZE
+#define NVMET_MAX_CMD(ctrl)    (NVME_CAP_MQES(ctrl->cap) + 1)
 
 /*
  * Nice round number that makes a list of nsids fit into a page.
index f2d963e1fe94e1a88cc7fa4aa6ef9b4d18c16054..bb4a69d538fd101087b34d55021f71559f302b84 100644 (file)
@@ -132,7 +132,7 @@ static u16 nvmet_passthru_override_id_ctrl(struct nvmet_req *req)
 
        id->sqes = min_t(__u8, ((0x6 << 4) | 0x6), id->sqes);
        id->cqes = min_t(__u8, ((0x4 << 4) | 0x4), id->cqes);
-       id->maxcmd = cpu_to_le16(NVMET_MAX_CMD);
+       id->maxcmd = cpu_to_le16(NVMET_MAX_CMD(ctrl));
 
        /* don't support fuse commands */
        id->fuses = 0;