git: b631954ff079 - main - bhyve: initial PowerCycles value

From: Corvin Köhne <corvink_at_FreeBSD.org>
Date: Fri, 04 Nov 2022 09:14:01 UTC
The branch main has been updated by corvink:

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

commit b631954ff07989b83378bf5cd1af5fad7162c9f9
Author:     Wanpeng Qian <wanpengqian@gmail.com>
AuthorDate: 2022-11-04 07:48:00 +0000
Commit:     Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2022-11-04 09:13:01 +0000

    bhyve: initial PowerCycles value
    
    Currently PowerCycles field of Log Page is 0 and it is an invalid value.
    This patch will initial the PowerCycles data to 1.
    
    MFC after:              1 week
    Approved by:            manu (mentor)
    Reviewed By:            grehan (older version), chuck, corvink
    Differential Revision:  https://reviews.freebsd.org/D32558
---
 usr.sbin/bhyve/pci_nvme.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c
index 01b7649642a8..b341b70f4e48 100644
--- a/usr.sbin/bhyve/pci_nvme.c
+++ b/usr.sbin/bhyve/pci_nvme.c
@@ -688,6 +688,7 @@ pci_nvme_init_nsdata(struct pci_nvme_softc *sc,
 static void
 pci_nvme_init_logpages(struct pci_nvme_softc *sc)
 {
+	__uint128_t power_cycles = 1;
 
 	memset(&sc->err_log, 0, sizeof(sc->err_log));
 	memset(&sc->health_log, 0, sizeof(sc->health_log));
@@ -707,6 +708,9 @@ pci_nvme_init_logpages(struct pci_nvme_softc *sc)
 	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]));
+
+	memcpy(&sc->health_log.power_cycles, &power_cycles,
+	    sizeof(sc->health_log.power_cycles));
 }
 
 static void