git: c3c15ed7fc2d - stable/13 - bhyve: initial PowerCycles value

From: Corvin Köhne <corvink_at_FreeBSD.org>
Date: Mon, 14 Nov 2022 08:25:59 UTC
The branch stable/13 has been updated by corvink:

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

commit c3c15ed7fc2d72e8b3ab20615691571d170c0f55
Author:     Wanpeng Qian <wanpengqian@gmail.com>
AuthorDate: 2022-11-04 07:48:00 +0000
Commit:     Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2022-11-14 08:23:12 +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
    
    (cherry picked from commit b631954ff07989b83378bf5cd1af5fad7162c9f9)
---
 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 15d6ae777cc6..bc7b82bda619 100644
--- a/usr.sbin/bhyve/pci_nvme.c
+++ b/usr.sbin/bhyve/pci_nvme.c
@@ -681,6 +681,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));
@@ -700,6 +701,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