Date: Mon, 26 Aug 2024 18:03:10 GMT From: John Baldwin <jhb@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 215c3766945a - stable/14 - nvme: Use the NVMEV macro instead of expanded versions Message-ID: <202408261803.47QI3AYx042279@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=215c3766945abf085c580b73bb409fd4afe5ff09 commit 215c3766945abf085c580b73bb409fd4afe5ff09 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2024-01-29 18:30:54 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2024-08-26 17:25:49 +0000 nvme: Use the NVMEV macro instead of expanded versions Reviewed by: chuck Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D43595 (cherry picked from commit 479680f235dd89cdabe0503312b3d23f322f4000) --- sys/dev/nvme/nvme.h | 72 +++++++++++++++++++++++++---------------------- sys/dev/nvme/nvme_ctrlr.c | 11 ++++---- sys/dev/nvme/nvme_ns.c | 16 ++++------- sys/dev/nvme/nvme_qpair.c | 2 +- 4 files changed, 51 insertions(+), 50 deletions(-) diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h index 315dbdd5a3c8..cb5e1a5f1118 100644 --- a/sys/dev/nvme/nvme.h +++ b/sys/dev/nvme/nvme.h @@ -73,13 +73,13 @@ #define NVME_CAP_LO_REG_TO_SHIFT (24) #define NVME_CAP_LO_REG_TO_MASK (0xFF) #define NVME_CAP_LO_MQES(x) \ - (((x) >> NVME_CAP_LO_REG_MQES_SHIFT) & NVME_CAP_LO_REG_MQES_MASK) + NVMEV(NVME_CAP_LO_REG_MQES, x) #define NVME_CAP_LO_CQR(x) \ - (((x) >> NVME_CAP_LO_REG_CQR_SHIFT) & NVME_CAP_LO_REG_CQR_MASK) + NVMEV(NVME_CAP_LO_REG_CQR, x) #define NVME_CAP_LO_AMS(x) \ - (((x) >> NVME_CAP_LO_REG_AMS_SHIFT) & NVME_CAP_LO_REG_AMS_MASK) + NVMEV(NVME_CAP_LO_REG_AMS, x) #define NVME_CAP_LO_TO(x) \ - (((x) >> NVME_CAP_LO_REG_TO_SHIFT) & NVME_CAP_LO_REG_TO_MASK) + NVMEV(NVME_CAP_LO_REG_TO, x) #define NVME_CAP_HI_REG_DSTRD_SHIFT (0) #define NVME_CAP_HI_REG_DSTRD_MASK (0xF) @@ -108,31 +108,31 @@ #define NVME_CAP_HI_REG_CRIMS_SHIFT (28) #define NVME_CAP_HI_REG_CRIMS_MASK (0x1) #define NVME_CAP_HI_DSTRD(x) \ - (((x) >> NVME_CAP_HI_REG_DSTRD_SHIFT) & NVME_CAP_HI_REG_DSTRD_MASK) + NVMEV(NVME_CAP_HI_REG_DSTRD, x) #define NVME_CAP_HI_NSSRS(x) \ - (((x) >> NVME_CAP_HI_REG_NSSRS_SHIFT) & NVME_CAP_HI_REG_NSSRS_MASK) + NVMEV(NVME_CAP_HI_REG_NSSRS, x) #define NVME_CAP_HI_CSS(x) \ - (((x) >> NVME_CAP_HI_REG_CSS_SHIFT) & NVME_CAP_HI_REG_CSS_MASK) + NVMEV(NVME_CAP_HI_REG_CSS, x) #define NVME_CAP_HI_CSS_NVM(x) \ - (((x) >> NVME_CAP_HI_REG_CSS_NVM_SHIFT) & NVME_CAP_HI_REG_CSS_NVM_MASK) + NVMEV(NVME_CAP_HI_REG_CSS_NVM, x) #define NVME_CAP_HI_BPS(x) \ - (((x) >> NVME_CAP_HI_REG_BPS_SHIFT) & NVME_CAP_HI_REG_BPS_MASK) + NVMEV(NVME_CAP_HI_REG_BPS, x) #define NVME_CAP_HI_CPS(x) \ - (((x) >> NVME_CAP_HI_REG_CPS_SHIFT) & NVME_CAP_HI_REG_CPS_MASK) + NVMEV(NVME_CAP_HI_REG_CPS, x) #define NVME_CAP_HI_MPSMIN(x) \ - (((x) >> NVME_CAP_HI_REG_MPSMIN_SHIFT) & NVME_CAP_HI_REG_MPSMIN_MASK) + NVMEV(NVME_CAP_HI_REG_MPSMIN, x) #define NVME_CAP_HI_MPSMAX(x) \ - (((x) >> NVME_CAP_HI_REG_MPSMAX_SHIFT) & NVME_CAP_HI_REG_MPSMAX_MASK) + NVMEV(NVME_CAP_HI_REG_MPSMAX, x) #define NVME_CAP_HI_PMRS(x) \ - (((x) >> NVME_CAP_HI_REG_PMRS_SHIFT) & NVME_CAP_HI_REG_PMRS_MASK) + NVMEV(NVME_CAP_HI_REG_PMRS, x) #define NVME_CAP_HI_CMBS(x) \ - (((x) >> NVME_CAP_HI_REG_CMBS_SHIFT) & NVME_CAP_HI_REG_CMBS_MASK) + NVMEV(NVME_CAP_HI_REG_CMBS, x) #define NVME_CAP_HI_NSSS(x) \ - (((x) >> NVME_CAP_HI_REG_NSSS_SHIFT) & NVME_CAP_HI_REG_NSSS_MASK) + NVMEV(NVME_CAP_HI_REG_NSSS, x) #define NVME_CAP_HI_CRWMS(x) \ - (((x) >> NVME_CAP_HI_REG_CRWMS_SHIFT) & NVME_CAP_HI_REG_CRWMS_MASK) + NVMEV(NVME_CAP_HI_REG_CRWMS, x) #define NVME_CAP_HI_CRIMS(x) \ - (((x) >> NVME_CAP_HI_REG_CRIMS_SHIFT) & NVME_CAP_HI_REG_CRIMS_MASK) + NVMEV(NVME_CAP_HI_REG_CRIMS, x) #define NVME_CC_REG_EN_SHIFT (0) #define NVME_CC_REG_EN_MASK (0x1) @@ -164,7 +164,8 @@ #define NVME_CSTS_REG_ST_SHIFT (6) #define NVME_CSTS_REG_ST_MASK (0x1) -#define NVME_CSTS_GET_SHST(csts) (((csts) >> NVME_CSTS_REG_SHST_SHIFT) & NVME_CSTS_REG_SHST_MASK) +#define NVME_CSTS_GET_SHST(csts) \ + NVMEV(NVME_CSTS_REG_SHST, csts) #define NVME_AQA_REG_ASQS_SHIFT (0) #define NVME_AQA_REG_ASQS_MASK (0xFFF) @@ -187,19 +188,19 @@ #define NVME_PMRCAP_REG_CMSS_MASK (0x1) #define NVME_PMRCAP_RDS(x) \ - (((x) >> NVME_PMRCAP_REG_RDS_SHIFT) & NVME_PMRCAP_REG_RDS_MASK) + NVMEV(NVME_PMRCAP_REG_RDS, x) #define NVME_PMRCAP_WDS(x) \ - (((x) >> NVME_PMRCAP_REG_WDS_SHIFT) & NVME_PMRCAP_REG_WDS_MASK) + NVMEV(NVME_PMRCAP_REG_WDS, x) #define NVME_PMRCAP_BIR(x) \ - (((x) >> NVME_PMRCAP_REG_BIR_SHIFT) & NVME_PMRCAP_REG_BIR_MASK) + NVMEV(NVME_PMRCAP_REG_BIR, x) #define NVME_PMRCAP_PMRTU(x) \ - (((x) >> NVME_PMRCAP_REG_PMRTU_SHIFT) & NVME_PMRCAP_REG_PMRTU_MASK) + NVMEV(NVME_PMRCAP_REG_PMRTU, x) #define NVME_PMRCAP_PMRWBM(x) \ - (((x) >> NVME_PMRCAP_REG_PMRWBM_SHIFT) & NVME_PMRCAP_REG_PMRWBM_MASK) + NVMEV(NVME_PMRCAP_REG_PMRWBM, x) #define NVME_PMRCAP_PMRTO(x) \ - (((x) >> NVME_PMRCAP_REG_PMRTO_SHIFT) & NVME_PMRCAP_REG_PMRTO_MASK) + NVMEV(NVME_PMRCAP_REG_PMRTO, x) #define NVME_PMRCAP_CMSS(x) \ - (((x) >> NVME_PMRCAP_REG_CMSS_SHIFT) & NVME_PMRCAP_REG_CMSS_MASK) + NVMEV(NVME_PMRCAP_REG_CMSS, x) /* Command field definitions */ @@ -219,12 +220,18 @@ #define NVME_STATUS_DNR_SHIFT (15) #define NVME_STATUS_DNR_MASK (0x1) -#define NVME_STATUS_GET_P(st) (((st) >> NVME_STATUS_P_SHIFT) & NVME_STATUS_P_MASK) -#define NVME_STATUS_GET_SC(st) (((st) >> NVME_STATUS_SC_SHIFT) & NVME_STATUS_SC_MASK) -#define NVME_STATUS_GET_SCT(st) (((st) >> NVME_STATUS_SCT_SHIFT) & NVME_STATUS_SCT_MASK) -#define NVME_STATUS_GET_CRD(st) (((st) >> NVME_STATUS_CRD_SHIFT) & NVME_STATUS_CRD_MASK) -#define NVME_STATUS_GET_M(st) (((st) >> NVME_STATUS_M_SHIFT) & NVME_STATUS_M_MASK) -#define NVME_STATUS_GET_DNR(st) (((st) >> NVME_STATUS_DNR_SHIFT) & NVME_STATUS_DNR_MASK) +#define NVME_STATUS_GET_P(st) \ + NVMEV(NVME_STATUS_P, st) +#define NVME_STATUS_GET_SC(st) \ + NVMEV(NVME_STATUS_SC, st) +#define NVME_STATUS_GET_SCT(st) \ + NVMEV(NVME_STATUS_SCT, st) +#define NVME_STATUS_GET_CRD(st) \ + NVMEV(NVME_STATUS_CRD, st) +#define NVME_STATUS_GET_M(st) \ + NVMEV(NVME_STATUS_M, st) +#define NVME_STATUS_GET_DNR(st) \ + NVMEV(NVME_STATUS_DNR, st) #define NVME_PWR_ST_MPS_SHIFT (0) #define NVME_PWR_ST_MPS_MASK (0x1) @@ -1752,8 +1759,7 @@ static inline bool nvme_ctrlr_has_dataset_mgmt(const struct nvme_controller_data *cd) { /* Assumes cd was byte swapped by nvme_controller_data_swapbytes() */ - return ((cd->oncs >> NVME_CTRLR_DATA_ONCS_DSM_SHIFT) & - NVME_CTRLR_DATA_ONCS_DSM_MASK); + return (NVMEV(NVME_CTRLR_DATA_ONCS_DSM, cd->oncs) != 0); } /* Namespace helper functions */ diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c index e659a3776957..7096f0443f1d 100644 --- a/sys/dev/nvme/nvme_ctrlr.c +++ b/sys/dev/nvme/nvme_ctrlr.c @@ -278,8 +278,7 @@ nvme_ctrlr_wait_for_ready(struct nvme_controller *ctrlr, int desired_val) csts = nvme_mmio_read_4(ctrlr, csts); if (csts == NVME_GONE) /* Hot unplug. */ return (ENXIO); - if (((csts >> NVME_CSTS_REG_RDY_SHIFT) & NVME_CSTS_REG_RDY_MASK) - == desired_val) + if (NVMEV(NVME_CSTS_REG_RDY, csts) == desired_val) break; if (timeout - ticks < 0) { nvme_printf(ctrlr, "controller ready did not become %d " @@ -305,8 +304,8 @@ nvme_ctrlr_disable(struct nvme_controller *ctrlr) cc = nvme_mmio_read_4(ctrlr, cc); csts = nvme_mmio_read_4(ctrlr, csts); - en = (cc >> NVME_CC_REG_EN_SHIFT) & NVME_CC_REG_EN_MASK; - rdy = (csts >> NVME_CSTS_REG_RDY_SHIFT) & NVME_CSTS_REG_RDY_MASK; + en = NVMEV(NVME_CC_REG_EN, cc); + rdy = NVMEV(NVME_CSTS_REG_RDY, csts); /* * Per 3.1.5 in NVME 1.3 spec, transitioning CC.EN from 0 to 1 @@ -352,8 +351,8 @@ nvme_ctrlr_enable(struct nvme_controller *ctrlr) cc = nvme_mmio_read_4(ctrlr, cc); csts = nvme_mmio_read_4(ctrlr, csts); - en = (cc >> NVME_CC_REG_EN_SHIFT) & NVME_CC_REG_EN_MASK; - rdy = (csts >> NVME_CSTS_REG_RDY_SHIFT) & NVME_CSTS_REG_RDY_MASK; + en = NVMEV(NVME_CC_REG_EN, cc); + rdy = NVMEV(NVME_CSTS_REG_RDY, csts); /* * See note in nvme_ctrlr_disable. Short circuit if we're already enabled. diff --git a/sys/dev/nvme/nvme_ns.c b/sys/dev/nvme/nvme_ns.c index 55f607c96e59..329b8d583898 100644 --- a/sys/dev/nvme/nvme_ns.c +++ b/sys/dev/nvme/nvme_ns.c @@ -181,10 +181,8 @@ nvme_ns_get_sector_size(struct nvme_namespace *ns) { uint8_t flbas_fmt, lbads; - flbas_fmt = (ns->data.flbas >> NVME_NS_DATA_FLBAS_FORMAT_SHIFT) & - NVME_NS_DATA_FLBAS_FORMAT_MASK; - lbads = (ns->data.lbaf[flbas_fmt] >> NVME_NS_DATA_LBAF_LBADS_SHIFT) & - NVME_NS_DATA_LBAF_LBADS_MASK; + flbas_fmt = NVMEV(NVME_NS_DATA_FLBAS_FORMAT, ns->data.flbas); + lbads = NVMEV(NVME_NS_DATA_LBAF_LBADS, ns->data.lbaf[flbas_fmt]); return (1 << lbads); } @@ -231,8 +229,7 @@ nvme_ns_get_stripesize(struct nvme_namespace *ns) { uint32_t ss; - if (((ns->data.nsfeat >> NVME_NS_DATA_NSFEAT_NPVALID_SHIFT) & - NVME_NS_DATA_NSFEAT_NPVALID_MASK) != 0) { + if (NVMEV(NVME_NS_DATA_NSFEAT_NPVALID, ns->data.nsfeat) != 0) { ss = nvme_ns_get_sector_size(ns); if (ns->data.npwa != 0) return ((ns->data.npwa + 1) * ss); @@ -552,8 +549,8 @@ nvme_ns_construct(struct nvme_namespace *ns, uint32_t id, if (ns->data.nsze == 0) return (ENXIO); - flbas_fmt = (ns->data.flbas >> NVME_NS_DATA_FLBAS_FORMAT_SHIFT) & - NVME_NS_DATA_FLBAS_FORMAT_MASK; + flbas_fmt = NVMEV(NVME_NS_DATA_FLBAS_FORMAT, ns->data.flbas); + /* * Note: format is a 0-based value, so > is appropriate here, * not >=. @@ -585,8 +582,7 @@ nvme_ns_construct(struct nvme_namespace *ns, uint32_t id, if (nvme_ctrlr_has_dataset_mgmt(&ctrlr->cdata)) ns->flags |= NVME_NS_DEALLOCATE_SUPPORTED; - vwc_present = (ctrlr->cdata.vwc >> NVME_CTRLR_DATA_VWC_PRESENT_SHIFT) & - NVME_CTRLR_DATA_VWC_PRESENT_MASK; + vwc_present = NVMEV(NVME_CTRLR_DATA_VWC_PRESENT, ctrlr->cdata.vwc); if (vwc_present) ns->flags |= NVME_NS_FLUSH_SUPPORTED; diff --git a/sys/dev/nvme/nvme_qpair.c b/sys/dev/nvme/nvme_qpair.c index 2e9af4310a15..e087abcb2654 100644 --- a/sys/dev/nvme/nvme_qpair.c +++ b/sys/dev/nvme/nvme_qpair.c @@ -1041,7 +1041,7 @@ nvme_qpair_timeout(void *arg) * usually doesn't). */ csts = nvme_mmio_read_4(ctrlr, csts); - cfs = (csts >> NVME_CSTS_REG_CFS_SHIFT) & NVME_CSTS_REG_CFS_MASK; + cfs = NVMEV(NVME_CSTS_REG_CFS, csts); if (csts == NVME_GONE || cfs == 1) goto do_reset;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202408261803.47QI3AYx042279>