git: 073f2076fea4 - main - bhyve nvme: Add Select support to Get Features

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

URL: https://cgit.FreeBSD.org/src/commit/?id=073f2076fea4748b457b15dbd1d6e11b802b76f3

commit 073f2076fea4748b457b15dbd1d6e11b802b76f3
Author:     Chuck Tuffli <chuck@FreeBSD.org>
AuthorDate: 2022-01-30 07:09:35 +0000
Commit:     Chuck Tuffli <chuck@FreeBSD.org>
CommitDate: 2022-01-30 07:09:35 +0000

    bhyve nvme: Add Select support to Get Features
    
    Implement basic support for the SEL field of Get Features. This returns
    information about Namespace Specific features.
    
    Fixes UNH ILO 16.0 Test 1.2, Case 13
    
    Reviewed by:    imp, allanjude
    Tested by:      jason@tubnor.net
    MFC after:      1 month
    Differential Revision:  https://reviews.freebsd.org/D33574
---
 usr.sbin/bhyve/pci_nvme.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c
index 39d1827c2c96..ea3503bdbfc0 100644
--- a/usr.sbin/bhyve/pci_nvme.c
+++ b/usr.sbin/bhyve/pci_nvme.c
@@ -1798,12 +1798,16 @@ nvme_opc_set_features(struct pci_nvme_softc *sc, struct nvme_command *command,
 	return (0);
 }
 
+#define NVME_FEATURES_SEL_SUPPORTED	0x3
+#define NVME_FEATURES_NS_SPECIFIC	(1 << 1)
+
 static int
 nvme_opc_get_features(struct pci_nvme_softc* sc, struct nvme_command* command,
 	struct nvme_completion* compl)
 {
 	struct nvme_feature_obj *feat;
 	uint8_t fid = command->cdw10 & 0xFF;
+	uint8_t sel = (command->cdw10 >> 8) & 0x7;
 
 	DPRINTF("%s: Feature ID 0x%x (%s)", __func__, fid, nvme_fid_to_name(fid));
 
@@ -1822,7 +1826,10 @@ nvme_opc_get_features(struct pci_nvme_softc* sc, struct nvme_command* command,
 	}
 
 	if (compl->status == NVME_SC_SUCCESS) {
-		compl->cdw0 = feat->cdw11;
+		if ((sel == NVME_FEATURES_SEL_SUPPORTED) && feat->namespace_specific)
+			compl->cdw0 = NVME_FEATURES_NS_SPECIFIC;
+		else
+			compl->cdw0 = feat->cdw11;
 	}
 
 	return (0);