git: 29241c96f75b - main - bhyve nvme: Update v1.4 Identify Controller data

From: Chuck Tuffli <chuck_at_FreeBSD.org>
Date: Sat, 29 Jan 2022 23:15:45 UTC
The branch main has been updated by chuck:

URL: https://cgit.FreeBSD.org/src/commit/?id=29241c96f75b38f09fb8752a18ac1ae1b864325e

commit 29241c96f75b38f09fb8752a18ac1ae1b864325e
Author:     Chuck Tuffli <chuck@FreeBSD.org>
AuthorDate: 2022-01-30 07:09:10 +0000
Commit:     Chuck Tuffli <chuck@FreeBSD.org>
CommitDate: 2022-01-30 07:09:10 +0000

    bhyve nvme: Update v1.4 Identify Controller data
    
    Compliant v1.4 Controllers must report a Controller Type (CNTRLTYPE).
    Also, do not advertise secure erase functionality in the Format NVM
    Attributes field of the Identify Controller data structure as the
    Controller does not implement secure erase.
    
    Fixes UNH ILO Test 1.1, Case 2
    
    Reviewed by:    imp, allanjude
    Tested by:      jason@tubnor.net
    MFC after:      1 month
    Differential Revision:  https://reviews.freebsd.org/D33573
---
 usr.sbin/bhyve/pci_nvme.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c
index 03338f6e0664..39d1827c2c96 100644
--- a/usr.sbin/bhyve/pci_nvme.c
+++ b/usr.sbin/bhyve/pci_nvme.c
@@ -287,6 +287,12 @@ struct pci_nvme_aen {
 	bool		posted;
 };
 
+typedef enum {
+	NVME_CNTRLTYPE_IO = 1,
+	NVME_CNTRLTYPE_DISCOVERY = 2,
+	NVME_CNTRLTYPE_ADMIN = 3,
+} pci_nvme_cntrl_type;
+
 struct pci_nvme_softc {
 	struct pci_devinst *nsc_pi;
 
@@ -517,6 +523,7 @@ pci_nvme_init_ctrldata(struct pci_nvme_softc *sc)
 
 	cd->ver = NVME_REV(1,4);
 
+	cd->cntrltype = NVME_CNTRLTYPE_IO;
 	cd->oacs = 1 << NVME_CTRLR_DATA_OACS_FORMAT_SHIFT;
 	cd->acl = 2;
 	cd->aerl = 4;
@@ -551,7 +558,8 @@ pci_nvme_init_ctrldata(struct pci_nvme_softc *sc)
 		break;
 	}
 
-	cd->fna = 0x03;
+	cd->fna = NVME_CTRLR_DATA_FNA_FORMAT_ALL_MASK <<
+	    NVME_CTRLR_DATA_FNA_FORMAT_ALL_SHIFT;
 
 	cd->power_state[0].mp = 10;
 }