From ae5a522cae7e95790e84274c4ba23bbd1e4f3033 Mon Sep 17 00:00:00 2001 From: Allan Jude Date: Tue, 21 Sep 2021 21:14:20 +0000 Subject: [PATCH] nvmecontrol: Display Metadata and Sanitize capabilities of the device Determine if a device supports "Extended" or "Separate" metadata, and what the current metadata setting is (None, Extended, Separate) Also determine if the device supports: - Sanitize Crypto Erase - Sanitize Block Erase - Sanitize Overwrite Reviewed by: chuck Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. X-NetApp-PR: #49 Differential Revision: https://reviews.freebsd.org/D31067 --- sbin/nvmecontrol/identify.c | 12 +++++++++++- sbin/nvmecontrol/identify_ext.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/sbin/nvmecontrol/identify.c b/sbin/nvmecontrol/identify.c index 6cd7ad0fdc2d..0d4d8003e5d2 100644 --- a/sbin/nvmecontrol/identify.c +++ b/sbin/nvmecontrol/identify.c @@ -84,7 +84,17 @@ print_namespace(struct nvme_namespace_data *nsdata) printf("Thin Provisioning: %s\n", thin_prov ? "Supported" : "Not Supported"); printf("Number of LBA Formats: %d\n", nsdata->nlbaf+1); - printf("Current LBA Format: LBA Format #%02d\n", flbas_fmt); + printf("Current LBA Format: LBA Format #%02d", flbas_fmt); + if (nsdata->lbaf[flbas_fmt] >> NVME_NS_DATA_LBAF_MS_SHIFT & NVME_NS_DATA_LBAF_MS_MASK) + printf(" %s metadata\n", nsdata->flbas >> NVME_NS_DATA_FLBAS_EXTENDED_SHIFT & + NVME_NS_DATA_FLBAS_EXTENDED_MASK ? "Extended" : "Separate"); + else + printf("\n"); + printf("Metadata Capabilities\n"); + printf(" Extended: %s\n", + nsdata->mc >> NVME_NS_DATA_MC_EXTENDED_SHIFT & NVME_NS_DATA_MC_EXTENDED_MASK ? "Supported" : "Not Supported"); + printf(" Separate: %s\n", + nsdata->mc >> NVME_NS_DATA_MC_POINTER_SHIFT & NVME_NS_DATA_MC_POINTER_MASK ? "Supported" : "Not Supported"); printf("Data Protection Caps: %s%s%s%s%s%s\n", (nsdata->dpc == 0) ? "Not Supported" : "", ((nsdata->dpc >> NVME_NS_DATA_DPC_MD_END_SHIFT) & diff --git a/sbin/nvmecontrol/identify_ext.c b/sbin/nvmecontrol/identify_ext.c index 311c8cba09a9..50b8901b799e 100644 --- a/sbin/nvmecontrol/identify_ext.c +++ b/sbin/nvmecontrol/identify_ext.c @@ -124,6 +124,38 @@ nvme_print_controller(struct nvme_controller_data *cdata) printf("Unlimited\n"); else printf("%ld bytes\n", PAGE_SIZE * (1L << cdata->mdts)); + printf("Sanitize Crypto Erase: %s\n", + ((cdata->sanicap >> NVME_CTRLR_DATA_SANICAP_CES_SHIFT) & + NVME_CTRLR_DATA_SANICAP_CES_MASK) ? + "Supported" : "Not Supported"); + printf("Sanitize Block Erase: %s\n", + ((cdata->sanicap >> NVME_CTRLR_DATA_SANICAP_BES_SHIFT) & + NVME_CTRLR_DATA_SANICAP_BES_MASK) ? + "Supported" : "Not Supported"); + printf("Sanitize Overwrite: %s\n", + ((cdata->sanicap >> NVME_CTRLR_DATA_SANICAP_OWS_SHIFT) & + NVME_CTRLR_DATA_SANICAP_OWS_MASK) ? + "Supported" : "Not Supported"); + printf("Sanitize NDI: %s\n", + ((cdata->sanicap >> NVME_CTRLR_DATA_SANICAP_NDI_SHIFT) & + NVME_CTRLR_DATA_SANICAP_NDI_MASK) ? + "Supported" : "Not Supported"); + printf("Sanitize NODMMAS: "); + switch (((cdata->sanicap >> NVME_CTRLR_DATA_SANICAP_NODMMAS_SHIFT) & + NVME_CTRLR_DATA_SANICAP_NODMMAS_MASK)) { + case NVME_CTRLR_DATA_SANICAP_NODMMAS_UNDEF: + printf("Undefined\n"); + break; + case NVME_CTRLR_DATA_SANICAP_NODMMAS_NO: + printf("No\n"); + break; + case NVME_CTRLR_DATA_SANICAP_NODMMAS_YES: + printf("Yes\n"); + break; + default: + printf("Unknown\n"); + break; + } printf("Controller ID: 0x%04x\n", cdata->ctrlr_id); printf("Version: %d.%d.%d\n", (cdata->ver >> 16) & 0xffff, (cdata->ver >> 8) & 0xff,