git: 3cae10048d27 - main - bhyve nvme: Fix Active Firmware Info

From: Chuck Tuffli <chuck_at_FreeBSD.org>
Date: Sun, 14 Aug 2022 18:18:29 UTC
The branch main has been updated by chuck:

URL: https://cgit.FreeBSD.org/src/commit/?id=3cae10048d27f805d7fc909b123ddee34be0268e

commit 3cae10048d27f805d7fc909b123ddee34be0268e
Author:     WanpengQian <wanpengqian@gmail.com>
AuthorDate: 2022-08-14 15:28:05 +0000
Commit:     Chuck Tuffli <chuck@FreeBSD.org>
CommitDate: 2022-08-14 16:59:36 +0000

    bhyve nvme: Fix Active Firmware Info
    
    Summary:
    Currently Active Firmware Info is not initialized.
    
    Fix is to initialize the Active Firmware Info to Slot 1.
    
    Test Plan: Within FreeBSD/Linux guests, show the Firmware Logpage to confirm.
    
    Reviewed By:    chuck
    MFC after:      2 weeks
    Differential Revision: https://reviews.freebsd.org/D32658
---
 usr.sbin/bhyve/pci_nvme.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c
index 93edd96a0d0d..afb5327ecd20 100644
--- a/usr.sbin/bhyve/pci_nvme.c
+++ b/usr.sbin/bhyve/pci_nvme.c
@@ -698,6 +698,11 @@ pci_nvme_init_logpages(struct pci_nvme_softc *sc)
 	sc->health_log.temperature = NVME_TEMPERATURE;
 	sc->health_log.available_spare = 100;
 	sc->health_log.available_spare_threshold = 10;
+
+	/* Set Active Firmware Info to slot 1 */
+	sc->fw_log.afi = (1 << NVME_FIRMWARE_PAGE_AFI_SLOT_SHIFT);
+	memcpy(&sc->fw_log.revision[0], sc->ctrldata.fr,
+	    sizeof(sc->fw_log.revision[0]));
 }
 
 static void