nvme-cli: add Get LBA Status command for 1.4
cover nvme-cli: add Get LBA Status command for 1.4
Hi All,
This series adds Get LBA Status command which has been introduced in NVMe 1.4 spec. Also it covers new fields in Identify controller data.
Github PR: https://github.com/linux-nvme/nvme-cli/pull/546
Thanks,
Minwoo Im (3):
id-ctrl: add an indicator for get lba status capability
id-ctrl: add 1.4 features to OAES
get-lba-status: add Get LBA Status command
linux/nvme.h | 16 ++++++++++ nvme-builtin.h | 1 + nvme-ioctl.c | 15 +++++++++ nvme-ioctl.h | 2 ++ nvme-print.c | 49 ++++++++++++++++++++++++++++-- nvme-print.h | 1 + nvme.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 164 insertions(+), 2 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/3 id-ctrl: add an indicator for get lba status capability
NVMe 1.4 supports for the Get LBA Status Capability which can be referred to 8.22. The Identify Controller is now able to indicate whether or not the Get LBA Status Capability is supported.
--- nvme-print.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
nvme-print.c +4 -1
@@ -169,7 +169,8 @@ static void show_nvme_id_ctrl_ctratt(__le32 ctrl_ctratt)static void show_nvme_id_ctrl_oacs (__le16 ctrl_oacs) {__u16 oacs =le16_to_cpu (ctrl_oacs); -__u16 rsvd = (oacs &0xFE00 ) >>9 ; +__u16 rsvd = (oacs &0xFC00 ) >>10 ; +__u16 glbas = (oacs &0x200 ) >>9 ;__u16 dbc = (oacs &0x100 ) >>8 ;__u16 vir = (oacs &0x80 ) >>7 ;__u16 nmi = (oacs &0x40 ) >>6 ;
@@ -182,6 +183,8 @@ static void show_nvme_id_ctrl_oacs(__le16 ctrl_oacs)if (rsvd)printf (" [15:9] : %#x\tReserved\n" , rsvd); +printf (" [9:9] : %#x\tGet LBA Status Capability %sSupported\n" , + glbas, glbas ?"" :"Not " );printf (" [8:8] : %#x\tDoorbell Buffer Config %sSupported\n" , dbc, dbc ?"" :"Not " ); printf(" [7:7] : %#x\tVirtualization Management %sSupported\n",
Signature · 1 line
2.17.1
PATCH 2/3 id-ctrl: add 1.4 features to OAES
In reply to Minwoo ImOptional Asynchronous Events Supported now has few more fields from 1.4.
--- nvme-print.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
nvme-print.c +15 -1
@@ -122,13 +122,27 @@ static void show_nvme_id_ctrl_cmic(__u8 cmic)static void show_nvme_id_ctrl_oaes (__le32 ctrl_oaes) {__u32 oaes =le32_to_cpu (ctrl_oaes); -__u32 rsvd0 = (oaes &0xFFFFFC00 ) >>10 ; +__u32 rsvd0 = (oaes &0xFFFF8000 ) >>15 ;__u32 nace = (oaes &0x100 ) >>8 ;__u32 fan = (oaes &0x200 ) >>9 ; +__u32 anacn = (oaes &800 ) >>11 ; +__u32 plealcn = (oaes &0x1000 ) >>12 ; +__u32 lbasin = (oaes &0x2000 ) >>13 ; +__u32 egealpcn = (oaes &0x4000 ) >>14 ;__u32 rsvd1 = oaes &0xFF ;if (rsvd0)printf (" [31:10] : %#x\tReserved\n" , rsvd0); +printf ("[14:14] : %#x\tEndurance Group Event Aggregate Log Page" \ +" Change Notice %sSupported\n" , + egealpcn, egealpcn ?"" :"Not " ); +printf ("[13:13] : %#x\tLBA Status Information Notices %sSupported\n" , + lbasin, lbasin ?"" :"Not " ); +printf ("[12:12] : %#x\tPredictable Latency Event Aggregate Log Change" \ +" Notices %sSupported\n" , + plealcn, plealcn ?"" :"Not " ); +printf ("[11:11] : %#x\tAsymmetric Namespace Access Change Notices" \ +" %sSupported\n" , anacn, anacn ?"" :"Not " );printf (" [9:9] : %#x\tFirmware Activation Notices %sSupported\n" , fan, fan ?"" :"Not " ); printf(" [8:8] : %#x\tNamespace Attribute Changed Event %sSupported\n",
Signature · 1 line
2.17.1
PATCH 3/3 get-lba-status: add Get LBA Status command
In reply to Minwoo ImThis command has been added in NVMe 1.4 spec. This command can retrieve some information about the unrecoverable LBAs from the device.
--- linux/nvme.h | 16 ++++++++++ nvme-builtin.h | 1 + nvme-ioctl.c | 15 +++++++++ nvme-ioctl.h | 2 ++ nvme-print.c | 28 +++++++++++++++++ nvme-print.h | 1 + nvme.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 145 insertions(+)
linux/nvme.h +16 -0
@@ -526,6 +526,21 @@ struct nvme_fw_slot_info_log {__u8 rsvd64[448 ]; }; +struct nvme_lba_status_desc { +__u64 dslba; +__u32 nlb; +__u8 rsvd_12; +__u8 status; +__u8 rsvd_15_14[2 ]; +}; + +struct nvme_lba_status { +__u32 nlsd; +__u8 cmpc; +__u8 rsvd_7_5[3 ]; +struct nvme_lba_status_desc descs[0 ]; +}; +/* NVMe Namespace Write Protect State */ enum {NVME_NS_NO_WRITE_PROTECT =0 ,
@@ -904,6 +919,7 @@ enum nvme_admin_opcode { nvme_admin_security_send =0x81 , nvme_admin_security_recv =0x82 , nvme_admin_sanitize_nvm =0x84 , + nvme_admin_get_lba_status = 0x86, }; enum {
nvme-builtin.h +1 -0
@@ -43,6 +43,7 @@ COMMAND_LIST( ENTRY("io-passthru", "Submit an arbitrary IO command, return results", io_passthru) ENTRY("security-send", "Submit a Security Send command, return results", sec_send) ENTRY("security-recv", "Submit a Security Receive command, return results", sec_recv) + ENTRY("get-lba-status", "Submit a Get LBA Status command, return results", get_lba_status) ENTRY("resv-acquire", "Submit a Reservation Acquire, return results", resv_acquire) ENTRY("resv-register", "Submit a Reservation Register, return results", resv_register)ENTRY ("resv-release" ,"Submit a Reservation Release, return results" , resv_release)
nvme-ioctl.c +15 -0
@@ -820,6 +820,21 @@ int nvme_sec_recv(int fd, __u32 nsid, __u8 nssf, __u16 spsp,return err; } +int nvme_get_lba_status (int fd,__u64 slba,__u32 mndw,__u8 atype,__u16 rl, +void *data) +{ +struct nvme_admin_cmd cmd = { + .opcode = nvme_admin_get_lba_status, + .addr = (__u64 )(uintptr_t ) data, + .cdw10 = slba &0xffffffff , + .cdw11 = slba >>32 , + .cdw12 = mndw, + .cdw13 = (atype <<24 ) | rl, + }; + +return nvme_submit_admin_passthru (fd, &cmd); +} +int nvme_dir_send (int fd,__u32 nsid,__u16 dspec,__u8 dtype,__u8 doper,__u32 data_len,__u32 dw12,void *data,__u32 *result) {
nvme-ioctl.h +2 -0
@@ -131,6 +131,8 @@ int nvme_subsystem_reset(int fd);int nvme_reset_controller (int fd);int nvme_ns_rescan (int fd); +int nvme_get_lba_status (int fd,__u64 slba,__u32 mndw,__u8 atype,__u16 rl, +void *data);int nvme_dir_send (int fd,__u32 nsid,__u16 dspec,__u8 dtype,__u8 doper,__u32 data_len,__u32 dw12,void *data,__u32 *result); int nvme_dir_recv(int fd, __u32 nsid, __u16 dspec, __u8 dtype, __u8 doper,
nvme-print.c +28 -0
@@ -2169,6 +2169,34 @@ void nvme_feature_show_fields(__u32 fid, unsigned int result, unsigned char *buf } } +void show_lba_status (struct nvme_lba_status *list) +{ +int idx; + +printf ("Number of LBA Status Descriptors(NLSD): %lu\n" , +le64_to_cpu (list->nlsd)); +printf ("Completion Condition(CMPC): %u\n" , list->cmpc); +switch (list->cmpc) { +case 1 : +printf ("\tCompleted due to transferring the amount of data" \ +" specified in the MNDW field\n" ); +break ; +case 2 : +printf ("\tCompleted due to having performed the action\n" \ +"\tspecified in the Action Type field over the\n" \ +"\tnumber of logical blocks specified in the\n" \ +"\tRange Length field\n" ); +break ; + } + +for (idx =0 ; idx < list->nlsd; idx++) { +struct nvme_lba_status_desc *e = &list->descs[idx]; +printf ("{ DSLBA: 0x%016" PRIu64", NLB: 0x%08x, Status: 0x%02x }\n" , +le64_to_cpu (e->dslba),le32_to_cpu (e->nlb), + e->status); + } +} +static void show_list_item (struct list_item list_item) {long long int lba =1 << list_item.ns.lbaf[(list_item.ns.flbas &0x0f )].ds;
nvme-print.h +1 -0
@@ -36,6 +36,7 @@ void show_sanitize_log(struct nvme_sanitize_log_page *sanitize, unsigned int modvoid show_ctrl_registers (void *bar,unsigned int mode,bool fabrics);void show_single_property (int offset,uint64_t prop,int human);void show_nvme_id_ns_descs (void *data); +void show_lba_status (struct nvme_lba_status *list);void show_list_items (struct list_item *list_items,unsigned len);void show_nvme_subsystem_list (struct subsys_list_item *slist,int n);void show_nvme_id_nvmset (struct nvme_id_nvmset *nvmset);
nvme.c +82 -0
88 lines not on this page · raw message
Signature · 1 line
2.17.1