From nobody Mon Jan 29 19:03:13 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 4TNyPG30V3z59Dfn; Mon, 29 Jan 2024 19:03:14 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TNyPF4z6Jz40cG; Mon, 29 Jan 2024 19:03:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706554993; 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=OKfI44G+a5jdyI94TBTLC+rtxq7DjBGFpfcGjZVNF4g=; b=vUkCidEpqMEB7/41riK9r88/bFds2rITlcGN9v0ftrWz4F99WNAOIcinWp4+8i3RaYmf8J aahmw39tHViamHwWNpCpZlvcAlHORBOarLZxHKLVf4mBzp8Z8uhqoVomtW35H+eykWDnMS OXhUXjYwJwMl+UahSiWYo+ItsGI4dTGwXZYly8AVgjSJ+LEwfnSKp5qWuRopmfhODOltAn S6CvuaZqHGvYkX8A5riSZxpp1poSsmxk4hmyJXhaZ6V8gWJKx/lH56/DxaNQl/B9bxWwbk 92HBv0t66b3PuMYh8vfJBa3v0ZCUyjPxDoSOpk6VuSSzFlxibYCmp8+0WFHLdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706554993; 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=OKfI44G+a5jdyI94TBTLC+rtxq7DjBGFpfcGjZVNF4g=; b=EibMYav56Nh9ZTvbJ77SdKsnUnJd917nOhUj1FK8jEbfJwYpIWi/bmGHHYudTCFi1/Gr3r t82JdP9jUaiIHoJ5nYRVRXaE4LtiSUKqpsJEAR2XFuP06fou6VhNCo1Qn1ARDp9gchzU+c hyZIuclh/souIku1Qs+ITjD5cc8WGKttWJm7WkhJPcyZ0rNVkSqKU/U9SeK5BHxXm6RdT7 fC4M4p9vjZ3waTPfUtF+QChC8ZJzbrpMkuiCbtJDh3HKo4Z4TG/+c4pUhNfhOuYjk4kY0p eve+KzZXdlO5VEPvqhnTNfXr6fKRA5jhCCy9LablEPygptrzZEmFmbyZA3PG3Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706554993; a=rsa-sha256; cv=none; b=GETR1KPWRJp2DnZtgPtSmvfPxPZ3M8XKs7puFco59168wXuSdtqKZOprZcf+T5v6KBmkHh EwazxYbWFO/OYroA9qoCJscQW8l60B6h8VQHWnQN6yp78dALnrxhmj2F5iDaigVsFiOd1R XjX0Ojgfa0ixk4+hQEKsp4NE6o6DHG25pWLfSvp6NeFgdV8u6FSb8Faxo4VRlzvHlH8wCR 6Y0mDobHsAZa02sk0jalT7K0el5SAX7X4nBOPEUnrxgTjK07+DDpG3fTgHhunNfCJfQuiZ brCGmqT2pEf+Fm7TVwOSS1ZTp8pG7lny8T0xFHSDQhwOg5/MXdpnUYGcg3FFKw== 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 4TNyPF3tmQz13p2; Mon, 29 Jan 2024 19:03:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40TJ3DQG058964; Mon, 29 Jan 2024 19:03:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40TJ3DAb058959; Mon, 29 Jan 2024 19:03:13 GMT (envelope-from git) Date: Mon, 29 Jan 2024 19:03:13 GMT Message-Id: <202401291903.40TJ3DAb058959@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: c46860dbcb20 - main - 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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/main X-Git-Reftype: branch X-Git-Commit: c46860dbcb2037933575a260028325418b3e9789 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=c46860dbcb2037933575a260028325418b3e9789 commit c46860dbcb2037933575a260028325418b3e9789 Author: John Baldwin AuthorDate: 2024-01-29 19:02:07 +0000 Commit: John Baldwin CommitDate: 2024-01-29 19:02:07 +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 --- 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)