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
This commit is contained in:
Allan Jude 2021-09-21 21:14:20 +00:00
parent 680ca73945
commit ae5a522cae
2 changed files with 43 additions and 1 deletions

View File

@ -84,7 +84,17 @@ print_namespace(struct nvme_namespace_data *nsdata)
printf("Thin Provisioning: %s\n", printf("Thin Provisioning: %s\n",
thin_prov ? "Supported" : "Not Supported"); thin_prov ? "Supported" : "Not Supported");
printf("Number of LBA Formats: %d\n", nsdata->nlbaf+1); 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", printf("Data Protection Caps: %s%s%s%s%s%s\n",
(nsdata->dpc == 0) ? "Not Supported" : "", (nsdata->dpc == 0) ? "Not Supported" : "",
((nsdata->dpc >> NVME_NS_DATA_DPC_MD_END_SHIFT) & ((nsdata->dpc >> NVME_NS_DATA_DPC_MD_END_SHIFT) &

View File

@ -124,6 +124,38 @@ nvme_print_controller(struct nvme_controller_data *cdata)
printf("Unlimited\n"); printf("Unlimited\n");
else else
printf("%ld bytes\n", PAGE_SIZE * (1L << cdata->mdts)); 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("Controller ID: 0x%04x\n", cdata->ctrlr_id);
printf("Version: %d.%d.%d\n", printf("Version: %d.%d.%d\n",
(cdata->ver >> 16) & 0xffff, (cdata->ver >> 8) & 0xff, (cdata->ver >> 16) & 0xffff, (cdata->ver >> 8) & 0xff,