From: Keith Busch <kbusch@meta.com>
To: <linux-nvme@lists.infradead.org>, <hch@lst.de>, <sagi@grimberg.me>
Cc: Keith Busch <kbusch@kernel.org>
Subject: [PATCHv3 2/3] nvme: define the remaining used sgls constants
Date: Mon, 18 Nov 2024 07:57:37 -0800 [thread overview]
Message-ID: <20241118155738.2737423-3-kbusch@meta.com> (raw)
In-Reply-To: <20241118155738.2737423-1-kbusch@meta.com>
From: Keith Busch <kbusch@kernel.org>
This provides a little more context when reading the code than hardcoded
magic numbers.
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
drivers/nvme/host/nvme.h | 3 ++-
drivers/nvme/host/rdma.c | 4 ++--
drivers/nvme/target/admin-cmd.c | 7 ++++---
include/linux/nvme.h | 4 ++++
4 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 5ef284a376cc7..611b02c8a8b37 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -1123,7 +1123,8 @@ static inline void nvme_start_request(struct request *rq)
static inline bool nvme_ctrl_sgl_supported(struct nvme_ctrl *ctrl)
{
- return ctrl->sgls & ((1 << 0) | (1 << 1));
+ return ctrl->sgls & (NVME_CTRL_SGLS_BYTE_ALIGNED |
+ NVME_CTRL_SGLS_DWORD_ALIGNED);
}
static inline bool nvme_ctrl_meta_sgl_supported(struct nvme_ctrl *ctrl)
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 24a2759798d01..baf7d24901528 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -1019,7 +1019,7 @@ static int nvme_rdma_setup_ctrl(struct nvme_rdma_ctrl *ctrl, bool new)
goto destroy_admin;
}
- if (!(ctrl->ctrl.sgls & (1 << 2))) {
+ if (!(ctrl->ctrl.sgls & NVME_CTRL_SGLS_KSDBDS)) {
ret = -EOPNOTSUPP;
dev_err(ctrl->ctrl.device,
"Mandatory keyed sgls are not supported!\n");
@@ -1051,7 +1051,7 @@ static int nvme_rdma_setup_ctrl(struct nvme_rdma_ctrl *ctrl, bool new)
ctrl->ctrl.sqsize = ctrl->ctrl.maxcmd - 1;
}
- if (ctrl->ctrl.sgls & (1 << 20))
+ if (ctrl->ctrl.sgls & NVME_CTRL_SGLS_SAOS)
ctrl->use_inline_data = true;
if (ctrl->ctrl.queue_count > 1) {
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 934b401fbc2ff..4fa8496a4d967 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -601,11 +601,12 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
id->awun = 0;
id->awupf = 0;
- id->sgls = cpu_to_le32(1 << 0); /* we always support SGLs */
+ /* we always support SGLs */
+ id->sgls = cpu_to_le32(NVME_CTRL_SGLS_BYTE_ALIGNED);
if (ctrl->ops->flags & NVMF_KEYED_SGLS)
- id->sgls |= cpu_to_le32(1 << 2);
+ id->sgls |= cpu_to_le32(NVME_CTRL_SGLS_KSDBDS);
if (req->port->inline_data_size)
- id->sgls |= cpu_to_le32(1 << 20);
+ id->sgls |= cpu_to_le32(NVME_CTRL_SGLS_SAOS);
strscpy(id->subnqn, ctrl->subsys->subsysnqn, sizeof(id->subnqn));
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 5873ce859cc8b..2baf9a80b470a 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -389,7 +389,11 @@ enum {
NVME_CTRL_CTRATT_PREDICTABLE_LAT = 1 << 5,
NVME_CTRL_CTRATT_NAMESPACE_GRANULARITY = 1 << 7,
NVME_CTRL_CTRATT_UUID_LIST = 1 << 9,
+ NVME_CTRL_SGLS_BYTE_ALIGNED = 1,
+ NVME_CTRL_SGLS_DWORD_ALIGNED = 2,
+ NVME_CTRL_SGLS_KSDBDS = 1 << 2,
NVME_CTRL_SGLS_MSDS = 1 << 19,
+ NVME_CTRL_SGLS_SAOS = 1 << 20,
};
struct nvme_lbaf {
--
2.43.5
next prev parent reply other threads:[~2024-11-18 15:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-18 15:57 [PATCHv3 0/3] meta sgl and userspace protection Keith Busch
2024-11-18 15:57 ` [PATCHv3 1/3] nvme-pci: add support for sgl metadata Keith Busch
2024-11-18 16:27 ` Christoph Hellwig
2024-11-18 15:57 ` Keith Busch [this message]
2024-11-18 16:28 ` [PATCHv3 2/3] nvme: define the remaining used sgls constants Christoph Hellwig
2024-11-18 15:57 ` [PATCHv3 3/3] nvme-pci: use sgls for all user requests if possible Keith Busch
2024-11-18 16:28 ` Christoph Hellwig
2024-12-02 7:56 ` New warning `nvme nvme0: using unchecked data buffer` (was: [PATCHv3 3/3] nvme-pci: use sgls for all user requests if possible) Paul Menzel
2024-12-02 15:05 ` Keith Busch
2024-12-02 15:15 ` New warning `nvme nvme0: using unchecked data buffer` Paul Menzel
2024-12-02 15:49 ` Keith Busch
2025-01-26 8:37 ` Paul Menzel
2025-01-29 19:00 ` Keith Busch
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=20241118155738.2737423-3-kbusch@meta.com \
--to=kbusch@meta.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--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