Skip to content

Commit 8e613b8

Browse files
sc108-leedwsuse
authored andcommitted
ioctl: Modify identify command argument based on spec
CNS Specific identifier presents all names below for DWORD11 bits [15:00] NVM Set Identifier(NVM Set List (04h)) Domain Identifier(Domain List (18h)) Endurance Group Identifier(Endurance Group List (19h)) Signed-off-by: Steven Seungcheol Lee <[email protected]>
1 parent 524941a commit 8e613b8

3 files changed

Lines changed: 33 additions & 53 deletions

File tree

src/nvme/ioctl.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,12 @@ enum nvme_cmd_dword_fields {
240240
NVME_LOG_CDW14_OT_MASK = 0x1,
241241
NVME_IDENTIFY_CDW10_CNS_SHIFT = 0,
242242
NVME_IDENTIFY_CDW10_CNTID_SHIFT = 16,
243-
NVME_IDENTIFY_CDW11_NVMSETID_SHIFT = 0,
244-
NVME_IDENTIFY_CDW11_DOMID_SHIFT = 0,
243+
NVME_IDENTIFY_CDW11_CNSSPECID_SHIFT = 0,
245244
NVME_IDENTIFY_CDW14_UUID_SHIFT = 0,
246245
NVME_IDENTIFY_CDW11_CSI_SHIFT = 24,
247246
NVME_IDENTIFY_CDW10_CNS_MASK = 0xff,
248247
NVME_IDENTIFY_CDW10_CNTID_MASK = 0xffff,
249-
NVME_IDENTIFY_CDW11_NVMSETID_MASK = 0xffff,
250-
NVME_IDENTIFY_CDW11_DOMID_MASK = 0xffff,
248+
NVME_IDENTIFY_CDW11_CNSSPECID_MASK = 0xffff,
251249
NVME_IDENTIFY_CDW14_UUID_MASK = 0x7f,
252250
NVME_IDENTIFY_CDW11_CSI_MASK = 0xff,
253251
NVME_NAMESPACE_ATTACH_CDW10_SEL_SHIFT = 0,
@@ -369,8 +367,7 @@ int nvme_identify(struct nvme_identify_args *args)
369367
{
370368
__u32 cdw10 = NVME_SET(args->cntid, IDENTIFY_CDW10_CNTID) |
371369
NVME_SET(args->cns, IDENTIFY_CDW10_CNS);
372-
__u32 cdw11 = NVME_SET(args->nvmsetid, IDENTIFY_CDW11_NVMSETID) |
373-
NVME_SET(args->domid, IDENTIFY_CDW11_DOMID) |
370+
__u32 cdw11 = NVME_SET(args->cns_specific_id, IDENTIFY_CDW11_CNSSPECID) |
374371
NVME_SET(args->csi, IDENTIFY_CDW11_CSI);
375372
__u32 cdw14 = NVME_SET(args->uuidx, IDENTIFY_CDW14_UUID);
376373

src/nvme/ioctl.h

Lines changed: 27 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -381,18 +381,17 @@ int nvme_get_nsid(int fd, __u32 *nsid);
381381

382382
/**
383383
* struct nvme_identify_args - Arguments for the NVMe Identify command
384-
* @result: The command completion result from CQE dword0
385-
* @data: User space destination address to transfer the data
386-
* @args_size: Size of &struct nvme_identify_args
387-
* @fd: File descriptor of nvme device
388-
* @timeout: Timeout in ms (0 for default timeout)
389-
* @cns: The Controller or Namespace structure, see @enum nvme_identify_cns
390-
* @csi: Command Set Identifier
391-
* @nsid: Namespace identifier, if applicable
392-
* @cntid: The Controller Identifier, if applicable
393-
* @nvmsetid: The NVMe Set ID if CNS is 04h
394-
* @domid: Domain identifier, if applicable
395-
* @uuidx: UUID Index if controller supports this id selection method
384+
* @result: The command completion result from CQE dword0
385+
* @data: User space destination address to transfer the data
386+
* @args_size: Size of &struct nvme_identify_args
387+
* @fd: File descriptor of nvme device
388+
* @timeout: Timeout in ms (0 for default timeout)
389+
* @cns: The Controller or Namespace structure, see @enum nvme_identify_cns
390+
* @csi: Command Set Identifier
391+
* @nsid: Namespace identifier, if applicable
392+
* @cntid: The Controller Identifier, if applicable
393+
* @cns_specific_id: Identifier that is required for a particular CNS value
394+
* @uuidx: UUID Index if controller supports this id selection method
396395
*/
397396
struct nvme_identify_args {
398397
__u32 *result;
@@ -404,8 +403,7 @@ struct nvme_identify_args {
404403
enum nvme_csi csi;
405404
__u32 nsid;
406405
__u16 cntid;
407-
__u16 nvmsetid;
408-
__u16 domid;
406+
__u16 cns_specific_id;
409407
__u8 uuidx;
410408
} __attribute__((packed, aligned(__alignof__(__u32*))));
411409

@@ -434,8 +432,7 @@ static int nvme_identify_cns_nsid(int fd, enum nvme_identify_cns cns,
434432
.csi = NVME_CSI_NVM,
435433
.nsid = nsid,
436434
.cntid = NVME_CNTLID_NONE,
437-
.nvmsetid = NVME_NVMSETID_NONE,
438-
.domid = NVME_DOMID_NONE,
435+
.cns_specific_id = NVME_CNSSPECID_NONE,
439436
.uuidx = NVME_UUID_NONE,
440437
};
441438

@@ -574,8 +571,7 @@ static inline int nvme_identify_ctrl_list(int fd, __u16 cntid,
574571
.csi = NVME_CSI_NVM,
575572
.nsid = NVME_NSID_NONE,
576573
.cntid = cntid,
577-
.nvmsetid = NVME_NVMSETID_NONE,
578-
.domid = NVME_DOMID_NONE,
574+
.cns_specific_id = NVME_CNSSPECID_NONE,
579575
.uuidx = NVME_UUID_NONE,
580576
};
581577

@@ -611,8 +607,7 @@ static inline int nvme_identify_nsid_ctrl_list(int fd, __u32 nsid, __u16 cntid,
611607
.csi = NVME_CSI_NVM,
612608
.nsid = nsid,
613609
.cntid = cntid,
614-
.nvmsetid = NVME_NVMSETID_NONE,
615-
.domid = NVME_DOMID_NONE,
610+
.cns_specific_id = NVME_CNSSPECID_NONE,
616611
.uuidx = NVME_UUID_NONE,
617612
};
618613

@@ -672,8 +667,7 @@ static inline int nvme_identify_nvmset_list(int fd, __u16 nvmsetid,
672667
.csi = NVME_CSI_NVM,
673668
.nsid = NVME_NSID_NONE,
674669
.cntid = NVME_CNTLID_NONE,
675-
.nvmsetid = nvmsetid,
676-
.domid = NVME_DOMID_NONE,
670+
.cns_specific_id = nvmsetid,
677671
.uuidx = NVME_UUID_NONE,
678672
};
679673

@@ -705,8 +699,7 @@ static inline int nvme_identify_primary_ctrl(int fd, __u16 cntid,
705699
.csi = NVME_CSI_NVM,
706700
.nsid = NVME_NSID_NONE,
707701
.cntid = cntid,
708-
.nvmsetid = NVME_NVMSETID_NONE,
709-
.domid = NVME_DOMID_NONE,
702+
.cns_specific_id = NVME_CNSSPECID_NONE,
710703
.uuidx = NVME_UUID_NONE,
711704
};
712705

@@ -744,8 +737,7 @@ static inline int nvme_identify_secondary_ctrl_list(int fd, __u32 nsid,
744737
.csi = NVME_CSI_NVM,
745738
.nsid = nsid,
746739
.cntid = cntid,
747-
.nvmsetid = NVME_NVMSETID_NONE,
748-
.domid = NVME_DOMID_NONE,
740+
.cns_specific_id = NVME_CNSSPECID_NONE,
749741
.uuidx = NVME_UUID_NONE,
750742
};
751743

@@ -817,8 +809,7 @@ static inline int nvme_identify_ns_csi(int fd, __u32 nsid,
817809
.csi = csi,
818810
.nsid = nsid,
819811
.cntid = NVME_CNTLID_NONE,
820-
.nvmsetid = NVME_NVMSETID_NONE,
821-
.domid = NVME_DOMID_NONE,
812+
.cns_specific_id = NVME_CNSSPECID_NONE,
822813
.uuidx = NVME_UUID_NONE,
823814
};
824815

@@ -846,8 +837,7 @@ static inline int nvme_identify_ctrl_csi(int fd, enum nvme_csi csi, void *data)
846837
.csi = csi,
847838
.nsid = NVME_NSID_NONE,
848839
.cntid = NVME_CNTLID_NONE,
849-
.nvmsetid = NVME_NVMSETID_NONE,
850-
.domid = NVME_DOMID_NONE,
840+
.cns_specific_id = NVME_CNSSPECID_NONE,
851841
.uuidx = NVME_UUID_NONE,
852842
};
853843

@@ -884,8 +874,7 @@ static inline int nvme_identify_active_ns_list_csi(int fd, __u32 nsid,
884874
.csi = csi,
885875
.nsid = nsid,
886876
.cntid = NVME_CNTLID_NONE,
887-
.nvmsetid = NVME_NVMSETID_NONE,
888-
.domid = NVME_DOMID_NONE,
877+
.cns_specific_id = NVME_CNSSPECID_NONE,
889878
.uuidx = NVME_UUID_NONE,
890879
};
891880

@@ -922,8 +911,7 @@ static inline int nvme_identify_allocated_ns_list_csi(int fd, __u32 nsid,
922911
.csi = csi,
923912
.nsid = nsid,
924913
.cntid = NVME_CNTLID_NONE,
925-
.nvmsetid = NVME_NVMSETID_NONE,
926-
.domid = NVME_DOMID_NONE,
914+
.cns_specific_id = NVME_CNSSPECID_NONE,
927915
.uuidx = NVME_UUID_NONE,
928916
};
929917

@@ -953,8 +941,7 @@ static inline int nvme_identify_independent_identify_ns(int fd, __u32 nsid,
953941
.csi = NVME_CSI_NVM,
954942
.nsid = nsid,
955943
.cntid = NVME_CNTLID_NONE,
956-
.nvmsetid = NVME_NVMSETID_NONE,
957-
.domid = NVME_DOMID_NONE,
944+
.cns_specific_id = NVME_CNSSPECID_NONE,
958945
.uuidx = NVME_UUID_NONE,
959946
};
960947

@@ -1003,8 +990,7 @@ static inline int nvme_identify_domain_list(int fd, __u16 domid,
1003990
.csi = NVME_CSI_NVM,
1004991
.nsid = NVME_NSID_NONE,
1005992
.cntid = NVME_CNTLID_NONE,
1006-
.nvmsetid = NVME_NVMSETID_NONE,
1007-
.domid = domid,
993+
.cns_specific_id = domid,
1008994
.uuidx = NVME_UUID_NONE,
1009995
};
1010996

@@ -1033,8 +1019,7 @@ static inline int nvme_identify_endurance_group_list(int fd, __u16 endgrp_id,
10331019
.csi = NVME_CSI_NVM,
10341020
.nsid = NVME_NSID_NONE,
10351021
.cntid = NVME_CNTLID_NONE,
1036-
.nvmsetid = NVME_NVMSETID_NONE,
1037-
.domid = endgrp_id,
1022+
.cns_specific_id = endgrp_id,
10381023
.uuidx = NVME_UUID_NONE,
10391024
};
10401025

@@ -1066,8 +1051,7 @@ static inline int nvme_identify_iocs(int fd, __u16 cntlid,
10661051
.csi = NVME_CSI_NVM,
10671052
.nsid = NVME_NSID_NONE,
10681053
.cntid = cntlid,
1069-
.nvmsetid = NVME_NVMSETID_NONE,
1070-
.domid = NVME_DOMID_NONE,
1054+
.cns_specific_id = NVME_CNSSPECID_NONE,
10711055
.uuidx = NVME_UUID_NONE,
10721056
};
10731057

@@ -1096,8 +1080,7 @@ static inline int nvme_zns_identify_ns(int fd, __u32 nsid,
10961080
.csi = NVME_CSI_ZNS,
10971081
.nsid = nsid,
10981082
.cntid = NVME_CNTLID_NONE,
1099-
.nvmsetid = NVME_NVMSETID_NONE,
1100-
.domid = NVME_DOMID_NONE,
1083+
.cns_specific_id = NVME_CNSSPECID_NONE,
11011084
};
11021085

11031086
return nvme_identify(&args);

src/nvme/types.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
* parameter is not used in a command
5454
* @NVME_UUID_NONE: Use to omit a uuid command parameter
5555
* @NVME_CNTLID_NONE: Use to omit a cntlid command parameter
56-
* @NVME_NVMSETID_NONE: Use to omit a nvmsetid command parameter
56+
* @NVME_CNSSPECID_NONE: Use to omit a cns_specific_id command parameter
5757
* @NVME_DOMID_NONE: Use to omit a domid command parameter
5858
* @NVME_LOG_LSP_NONE: Use to omit a log lsp command parameter
5959
* @NVME_LOG_LSI_NONE: Use to omit a log lsi command parameter
@@ -98,8 +98,8 @@ enum nvme_constants {
9898
NVME_NSID_NONE = 0,
9999
NVME_UUID_NONE = 0,
100100
NVME_CNTLID_NONE = 0,
101-
NVME_NVMSETID_NONE = 0,
102-
NVME_DOMID_NONE = 0,
101+
NVME_CNSSPECID_NONE = 0,
102+
NVME_DOMID_NONE = 0,
103103
NVME_LOG_LSP_NONE = 0,
104104
NVME_LOG_LSI_NONE = 0,
105105
NVME_LOG_LPO_NONE = 0,

0 commit comments

Comments
 (0)