Skip to content

Commit 5be1982

Browse files
committed
types: Add sz_u32 4-byte argument to LM CDQ args.
According to NVMe 2.1 Base Specificaiton, Controller Data Queue Size (CDQSIZE) occupies bits 31:00 of CDW12, so it should be using u32. Signed-off-by: Dmitry Sherstoboev <[email protected]>
1 parent 1302510 commit 5be1982

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

src/nvme/api-types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,8 @@ struct nvme_dim_args {
977977
* to delete.
978978
* @sel: Select (SEL): This field specifies the type of management operation to perform.
979979
* @sz: For Create CDQ, specifies the size of CDQ, in dwords
980+
* @rsvd1: Reserved
981+
* @sz_u32: For Create CDQ, specifies the size of CDQ, in dwords - 4 byte
980982
*/
981983
struct nvme_lm_cdq_args {
982984
__u32 *result;
@@ -989,6 +991,8 @@ struct nvme_lm_cdq_args {
989991
__u16 cdqid;
990992
__u8 sel;
991993
__u8 sz;
994+
__u8 rsvd1[4];
995+
__u32 sz_u32;
992996
};
993997

994998
/**

src/nvme/ioctl.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,15 +2353,28 @@ int nvme_dim_send(struct nvme_dim_args *args)
23532353

23542354
int nvme_lm_cdq(struct nvme_lm_cdq_args *args)
23552355
{
2356+
const size_t size_v1 = sizeof_args(struct nvme_lm_cdq_args, sz, __u64);
2357+
const size_t size_v2 = sizeof_args(struct nvme_lm_cdq_args, sz_u32, __u64);
23562358
__u32 cdw10 = NVME_SET(args->sel, LM_CDQ_SEL) |
23572359
NVME_SET(args->mos, LM_CDQ_MOS);
2358-
__u32 cdw11 = 0, data_len = 0;
2360+
__u32 cdw11 = 0, data_len = 0, sz_u32 = 0;
23592361
int err;
23602362

2363+
if (args->args_size < size_v1 || args->args_size > size_v2) {
2364+
errno = EINVAL;
2365+
return -1;
2366+
}
2367+
2368+
if (args->args_size == size_v1) {
2369+
sz_u32 = args->sz;
2370+
} else {
2371+
sz_u32 = args->sz_u32;
2372+
}
2373+
23612374
if (args->sel == NVME_LM_SEL_CREATE_CDQ) {
23622375
cdw11 = NVME_SET(args->cntlid, LM_CREATE_CDQ_CNTLID) |
23632376
NVME_LM_CREATE_CDQ_PC;
2364-
data_len = args->sz << 2;
2377+
data_len = sz_u32 << 2;
23652378
} else if (args->sel == NVME_LM_SEL_DELETE_CDQ) {
23662379
cdw11 = NVME_SET(args->cdqid, LM_DELETE_CDQ_CDQID);
23672380
}
@@ -2370,7 +2383,7 @@ int nvme_lm_cdq(struct nvme_lm_cdq_args *args)
23702383
.opcode = nvme_admin_ctrl_data_queue,
23712384
.cdw10 = cdw10,
23722385
.cdw11 = cdw11,
2373-
.cdw12 = args->sz,
2386+
.cdw12 = sz_u32,
23742387
.addr = (__u64)(uintptr_t)args->data,
23752388
.data_len = data_len,
23762389
.timeout_ms = args->timeout,

0 commit comments

Comments
 (0)