git: 06ec065bede0 - stable/13 - bhyve nvme: Update v1.4 Identify Controller data

From: Chuck Tuffli <chuck_at_FreeBSD.org>
Date: Mon, 21 Feb 2022 21:58:00 UTC
The branch stable/13 has been updated by chuck:

URL: https://cgit.FreeBSD.org/src/commit/?id=06ec065bede041d2b35ae90aaf51d7641612d72c

commit 06ec065bede041d2b35ae90aaf51d7641612d72c
Author:     Chuck Tuffli <chuck@FreeBSD.org>
AuthorDate: 2022-01-30 07:09:10 +0000
Commit:     Chuck Tuffli <chuck@FreeBSD.org>
CommitDate: 2022-02-22 03:27:03 +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
    
    (cherry picked from commit 29241c96f75b38f09fb8752a18ac1ae1b864325e)
---
 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 94eb2137d1e6..29c5aec4f44c 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;
 }