Page MenuHomeFreeBSD

D43607.diff
No OneTemporary

D43607.diff

diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c
--- a/usr.sbin/bhyve/pci_nvme.c
+++ b/usr.sbin/bhyve/pci_nvme.c
@@ -393,11 +393,11 @@
#define NVME_CSTS_GET_RDY(sts) \
NVMEV(NVME_CSTS_REG_RDY, sts)
-#define NVME_CSTS_RDY (1 << NVME_CSTS_REG_RDY_SHIFT)
-#define NVME_CSTS_CFS (1 << NVME_CSTS_REG_CFS_SHIFT)
+#define NVME_CSTS_RDY (NVMEF(NVME_CSTS_REG_RDY, 1))
+#define NVME_CSTS_CFS (NVMEF(NVME_CSTS_REG_CFS, 1))
/* Completion Queue status word utils */
-#define NVME_STATUS_P (1 << NVME_STATUS_P_SHIFT)
+#define NVME_STATUS_P (NVMEF(NVME_STATUS_P, 1))
#define NVME_STATUS_MASK \
(NVMEM(NVME_STATUS_SCT) | \
NVMEM(NVME_STATUS_SC))
@@ -442,8 +442,7 @@
{
*status &= ~NVME_STATUS_MASK;
- *status |= (type & NVME_STATUS_SCT_MASK) << NVME_STATUS_SCT_SHIFT |
- (code & NVME_STATUS_SC_MASK) << NVME_STATUS_SC_SHIFT;
+ *status |= NVMEF(NVME_STATUS_SCT, type) | NVMEF(NVME_STATUS_SC, code);
}
static __inline void
@@ -536,14 +535,14 @@
cd->ver = NVME_REV(1,4);
cd->cntrltype = NVME_CNTRLTYPE_IO;
- cd->oacs = 1 << NVME_CTRLR_DATA_OACS_FORMAT_SHIFT;
+ cd->oacs = NVMEF(NVME_CTRLR_DATA_OACS_FORMAT, 1);
cd->oaes = NVMEM(NVME_CTRLR_DATA_OAES_NS_ATTR);
cd->acl = 2;
cd->aerl = 4;
/* Advertise 1, Read-only firmware slot */
cd->frmw = NVMEM(NVME_CTRLR_DATA_FRMW_SLOT1_RO) |
- (1 << NVME_CTRLR_DATA_FRMW_NUM_SLOTS_SHIFT);
+ NVMEF(NVME_CTRLR_DATA_FRMW_NUM_SLOTS, 1);
cd->lpa = 0; /* TODO: support some simple things like SMART */
cd->elpe = 0; /* max error log page entries */
/*
@@ -557,13 +556,13 @@
cd->cctemp = 0x0157;
/* SANICAP must not be 0 for Revision 1.4 and later NVMe Controllers */
- cd->sanicap = (NVME_CTRLR_DATA_SANICAP_NODMMAS_NO <<
- NVME_CTRLR_DATA_SANICAP_NODMMAS_SHIFT);
+ cd->sanicap = NVMEF(NVME_CTRLR_DATA_SANICAP_NODMMAS,
+ NVME_CTRLR_DATA_SANICAP_NODMMAS_NO);
- cd->sqes = (6 << NVME_CTRLR_DATA_SQES_MAX_SHIFT) |
- (6 << NVME_CTRLR_DATA_SQES_MIN_SHIFT);
- cd->cqes = (4 << NVME_CTRLR_DATA_CQES_MAX_SHIFT) |
- (4 << NVME_CTRLR_DATA_CQES_MIN_SHIFT);
+ cd->sqes = NVMEF(NVME_CTRLR_DATA_SQES_MAX, 6) |
+ NVMEF(NVME_CTRLR_DATA_SQES_MIN, 6);
+ cd->cqes = NVMEF(NVME_CTRLR_DATA_CQES_MAX, 4) |
+ NVMEF(NVME_CTRLR_DATA_CQES_MIN, 4);
cd->nn = 1; /* number of namespaces */
cd->oncs = 0;
@@ -581,7 +580,7 @@
cd->fna = NVMEM(NVME_CTRLR_DATA_FNA_FORMAT_ALL);
- cd->vwc = NVME_CTRLR_DATA_VWC_ALL_NO << NVME_CTRLR_DATA_VWC_ALL_SHIFT;
+ cd->vwc = NVMEF(NVME_CTRLR_DATA_VWC_ALL, NVME_CTRLR_DATA_VWC_ALL_NO);
ret = snprintf(cd->subnqn, sizeof(cd->subnqn),
"nqn.2013-12.org.freebsd:bhyve-%s-%u-%u-%u",
@@ -634,7 +633,7 @@
be64enc(nd->eui64, nvstore->eui64);
/* LBA data-sz = 2^lbads */
- nd->lbaf[0] = nvstore->sectsz_bits << NVME_NS_DATA_LBAF_LBADS_SHIFT;
+ nd->lbaf[0] = NVMEF(NVME_NS_DATA_LBAF_LBADS, nvstore->sectsz_bits);
}
static void
@@ -657,7 +656,7 @@
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);
+ sc->fw_log.afi = NVMEF(NVME_FIRMWARE_PAGE_AFI_SLOT, 1);
memcpy(&sc->fw_log.revision[0], sc->ctrldata.fr,
sizeof(sc->fw_log.revision[0]));
@@ -1003,10 +1002,10 @@
DPRINTF("%s", __func__);
sc->regs.cap_lo = (ZERO_BASED(sc->max_qentries) & NVME_CAP_LO_REG_MQES_MASK) |
- (1 << NVME_CAP_LO_REG_CQR_SHIFT) |
- (60 << NVME_CAP_LO_REG_TO_SHIFT);
+ NVMEF(NVME_CAP_LO_REG_CQR, 1) |
+ NVMEF(NVME_CAP_LO_REG_TO, 60);
- sc->regs.cap_hi = 1 << NVME_CAP_HI_REG_CSS_NVM_SHIFT;
+ sc->regs.cap_hi = NVMEF(NVME_CAP_HI_REG_CSS_NVM, 1);
sc->regs.vs = NVME_REV(1,4); /* NVMe v1.4 */
@@ -2955,8 +2954,8 @@
if (NVME_CC_GET_SHN(ccreg)) {
/* perform shutdown - flush out data to backend */
sc->regs.csts &= ~NVMEM(NVME_CSTS_REG_SHST);
- sc->regs.csts |= NVME_SHST_COMPLETE <<
- NVME_CSTS_REG_SHST_SHIFT;
+ sc->regs.csts |= NVMEF(NVME_CSTS_REG_SHST,
+ NVME_SHST_COMPLETE);
}
if (NVME_CC_GET_EN(ccreg) != NVME_CC_GET_EN(sc->regs.cc)) {
if (NVME_CC_GET_EN(ccreg) == 0)

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 8, 12:44 PM (20 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14535146
Default Alt Text
D43607.diff (3 KB)

Event Timeline