From nobody Mon Aug 26 18:03:23 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Wsz7J5hclz5TM40; Mon, 26 Aug 2024 18:03:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Wsz7J19GWz44xm; Mon, 26 Aug 2024 18:03:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724695404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VxQHz1ECPprZODB7twYzb97FMALRHsfQQtlFmlSLfzQ=; b=o2UTIhnLn+oNUjVdMAhN7cagm6yqvzUOAppCHEIAvYarBNx+nKRF/+MI+HFvoDE6UoPKiO awvRWs5bvQVX4N5klU+rVr29uOhc4LHCr29n78LBD94x1cCA2OZ2/fpFy+qURxUHHUC8ko fn9dUR1fnTJ1ABuYUu26rTv3UR/+gQohcUM6s5RpxwWSrjZA7nodv8FQaGqccI3Ck8sUVB LUs7LMeoeUmq7HfPT/HTjDDoRFb/ZVMEvFYMiMwOotHNICDCqVaqXyCgSHc3LNuPw6xReb LHuf/RM1QXFZIIzMMx9aE5bpLF9ekD89eU60O/GTa+J7eERFy3WMxivvNRpJRQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724695404; a=rsa-sha256; cv=none; b=xznFxdX8IfkH/nPCQ1+b/MHC3zFKUnfjjKDdeQZIRiGi3WSX3RSU3ljbwQd10TlacigEhJ p57ejZmF/QWk9d6EgaNh1N1Mk/YOQlq9tye+xW9o8KIuhi0MqpVMVD8TKmZf97HRNIA5/m Rqq19smwILll8JPUy+0t++yWZLZhkpjMPNtCX/B2NmP5QvPRMI+Xq2Qd46Ak5HENo6PRNV Vh9BwCzdDZ68pFo6YLFkkHW8khYswc9+mveA6SdkdeiSiag9CC14v/z2Us/ticKU+QXGIM I688OoTURcsiXb5sMfhHt2rQJcnKqReUyQVrgCCx+U/ApzZFEprGNC4mCpzsBw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724695404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VxQHz1ECPprZODB7twYzb97FMALRHsfQQtlFmlSLfzQ=; b=SVYj1cOuQ8QkhED8q4FwjtHoKEF39fm8crJxlVhQ7StTVXs+2r6lQS2R9aNdMWDt/OI4Bz DxZ7ZRhuQ7goB/gbAcTTnWCNbzqSUwGx1VEtj2ff2MtnVcWR1RU6+SXzCM10MWsxEwuklM EALLX6w/FPnYmDXKQgoNRsopwtt7iqXul6LUipVbzu2RbH54r/hfjNXxft56raH2CVEei5 ChBndG5svTJXvY2Egog5dW0swnn6eHq746PgWYVZRvdG5gM2FHgPYC9jdGJ28HLU2grfm0 BBKZoAvjQL+bR5o9Pv+sP+ZJfgccgljhLlcsbhVb/IgU/ewxM3dGJz/kyyc0Bw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Wsz7J0RbNzHKL; Mon, 26 Aug 2024 18:03:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 47QI3Nlj042944; Mon, 26 Aug 2024 18:03:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47QI3NhC042941; Mon, 26 Aug 2024 18:03:23 GMT (envelope-from git) Date: Mon, 26 Aug 2024 18:03:23 GMT Message-Id: <202408261803.47QI3NhC042941@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: f314e46271f1 - stable/14 - bhyve: Use NVMEF macro to construct fields List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: f314e46271f1100c258a72aa8c0e072f0f3ef2e6 Auto-Submitted: auto-generated The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=f314e46271f1100c258a72aa8c0e072f0f3ef2e6 commit f314e46271f1100c258a72aa8c0e072f0f3ef2e6 Author: John Baldwin AuthorDate: 2024-01-29 19:02:07 +0000 Commit: John Baldwin CommitDate: 2024-08-26 17:27:53 +0000 bhyve: Use NVMEF macro to construct fields Reviewed by: corvink, chuck (older version) Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D43607 (cherry picked from commit c46860dbcb2037933575a260028325418b3e9789) --- usr.sbin/bhyve/pci_nvme.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c index cd81767d950b..45ab1b11fda4 100644 --- a/usr.sbin/bhyve/pci_nvme.c +++ b/usr.sbin/bhyve/pci_nvme.c @@ -393,11 +393,11 @@ static void pci_nvme_io_done(struct blockif_req *, int); #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 @@ pci_nvme_status_tc(uint16_t *status, uint16_t type, uint16_t code) { *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 @@ pci_nvme_init_ctrldata(struct pci_nvme_softc *sc) 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 @@ pci_nvme_init_ctrldata(struct pci_nvme_softc *sc) 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 @@ pci_nvme_init_ctrldata(struct pci_nvme_softc *sc) 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 @@ pci_nvme_init_nsdata(struct pci_nvme_softc *sc, 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 @@ pci_nvme_init_logpages(struct pci_nvme_softc *sc) 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 @@ pci_nvme_reset_locked(struct pci_nvme_softc *sc) 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 @@ pci_nvme_write_bar_0(struct pci_nvme_softc *sc, uint64_t offset, int size, 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)