Skip to content

Commit 6399a0d

Browse files
committed
nvme: define the remaining used sgls constants
This provides a little more context when reading the code than hardcoded magic numbers. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent 979c634 commit 6399a0d

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

drivers/nvme/host/nvme.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,8 @@ static inline void nvme_start_request(struct request *rq)
11231123

11241124
static inline bool nvme_ctrl_sgl_supported(struct nvme_ctrl *ctrl)
11251125
{
1126-
return ctrl->sgls & ((1 << 0) | (1 << 1));
1126+
return ctrl->sgls & (NVME_CTRL_SGLS_BYTE_ALIGNED |
1127+
NVME_CTRL_SGLS_DWORD_ALIGNED);
11271128
}
11281129

11291130
static inline bool nvme_ctrl_meta_sgl_supported(struct nvme_ctrl *ctrl)

drivers/nvme/host/rdma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ static int nvme_rdma_setup_ctrl(struct nvme_rdma_ctrl *ctrl, bool new)
10191019
goto destroy_admin;
10201020
}
10211021

1022-
if (!(ctrl->ctrl.sgls & (1 << 2))) {
1022+
if (!(ctrl->ctrl.sgls & NVME_CTRL_SGLS_KSDBDS)) {
10231023
ret = -EOPNOTSUPP;
10241024
dev_err(ctrl->ctrl.device,
10251025
"Mandatory keyed sgls are not supported!\n");
@@ -1051,7 +1051,7 @@ static int nvme_rdma_setup_ctrl(struct nvme_rdma_ctrl *ctrl, bool new)
10511051
ctrl->ctrl.sqsize = ctrl->ctrl.maxcmd - 1;
10521052
}
10531053

1054-
if (ctrl->ctrl.sgls & (1 << 20))
1054+
if (ctrl->ctrl.sgls & NVME_CTRL_SGLS_SAOS)
10551055
ctrl->use_inline_data = true;
10561056

10571057
if (ctrl->ctrl.queue_count > 1) {

drivers/nvme/target/admin-cmd.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,11 +601,12 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
601601
id->awun = 0;
602602
id->awupf = 0;
603603

604-
id->sgls = cpu_to_le32(1 << 0); /* we always support SGLs */
604+
/* we always support SGLs */
605+
id->sgls = cpu_to_le32(NVME_CTRL_SGLS_BYTE_ALIGNED);
605606
if (ctrl->ops->flags & NVMF_KEYED_SGLS)
606-
id->sgls |= cpu_to_le32(1 << 2);
607+
id->sgls |= cpu_to_le32(NVME_CTRL_SGLS_KSDBDS);
607608
if (req->port->inline_data_size)
608-
id->sgls |= cpu_to_le32(1 << 20);
609+
id->sgls |= cpu_to_le32(NVME_CTRL_SGLS_SAOS);
609610

610611
strscpy(id->subnqn, ctrl->subsys->subsysnqn, sizeof(id->subnqn));
611612

include/linux/nvme.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,11 @@ enum {
389389
NVME_CTRL_CTRATT_PREDICTABLE_LAT = 1 << 5,
390390
NVME_CTRL_CTRATT_NAMESPACE_GRANULARITY = 1 << 7,
391391
NVME_CTRL_CTRATT_UUID_LIST = 1 << 9,
392+
NVME_CTRL_SGLS_BYTE_ALIGNED = 1,
393+
NVME_CTRL_SGLS_DWORD_ALIGNED = 2,
394+
NVME_CTRL_SGLS_KSDBDS = 1 << 2,
392395
NVME_CTRL_SGLS_MSDS = 1 << 19,
396+
NVME_CTRL_SGLS_SAOS = 1 << 20,
393397
};
394398

395399
struct nvme_lbaf {

0 commit comments

Comments
 (0)