nvmecontrol: Use NVMEF macro to construct fields

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D43606
This commit is contained in:
John Baldwin 2024-01-29 11:01:46 -08:00
parent 5650bd3fe8
commit c68ec278de

View File

@ -579,14 +579,12 @@ nscreate(const struct cmd *f, int argc, char *argv[])
/* Default to the first format, whatever it is. */ /* Default to the first format, whatever it is. */
nsdata.flbas = 0; nsdata.flbas = 0;
if (create_opt.lbaf != NONE) { if (create_opt.lbaf != NONE) {
nsdata.flbas |= (create_opt.lbaf & nsdata.flbas |= NVMEF(NVME_NS_DATA_FLBAS_FORMAT,
NVME_NS_DATA_FLBAS_FORMAT_MASK) create_opt.lbaf);
<< NVME_NS_DATA_FLBAS_FORMAT_SHIFT;
} }
if (create_opt.mset != NONE) { if (create_opt.mset != NONE) {
nsdata.flbas |= (create_opt.mset & nsdata.flbas |= NVMEF(NVME_NS_DATA_FLBAS_EXTENDED,
NVME_NS_DATA_FLBAS_EXTENDED_MASK) create_opt.mset);
<< NVME_NS_DATA_FLBAS_EXTENDED_SHIFT;
} }
} }
if (create_opt.dps != NONE) { if (create_opt.dps != NONE) {
@ -595,22 +593,19 @@ nscreate(const struct cmd *f, int argc, char *argv[])
/* Default to protection disabled. */ /* Default to protection disabled. */
nsdata.dps = 0; nsdata.dps = 0;
if (create_opt.pi != NONE) { if (create_opt.pi != NONE) {
nsdata.dps |= (create_opt.pi & nsdata.dps |= NVMEF(NVME_NS_DATA_DPS_MD_START,
NVME_NS_DATA_DPS_MD_START_MASK) create_opt.pi);
<< NVME_NS_DATA_DPS_MD_START_SHIFT;
} }
if (create_opt.pil != NONE) { if (create_opt.pil != NONE) {
nsdata.dps |= (create_opt.pil & nsdata.dps |= NVMEF(NVME_NS_DATA_DPS_PIT,
NVME_NS_DATA_DPS_PIT_MASK) create_opt.pil);
<< NVME_NS_DATA_DPS_PIT_SHIFT;
} }
} }
if (create_opt.nmic != NONE) { if (create_opt.nmic != NONE) {
nsdata.nmic = create_opt.nmic; nsdata.nmic = create_opt.nmic;
} else { } else {
/* Allow namespaces sharing if Multi-Path I/O is supported. */ /* Allow namespaces sharing if Multi-Path I/O is supported. */
nsdata.nmic = cd.mic ? (NVME_NS_DATA_NMIC_MAY_BE_SHARED_MASK << nsdata.nmic = NVMEF(NVME_NS_DATA_NMIC_MAY_BE_SHARED, !!cd.mic);
NVME_NS_DATA_NMIC_MAY_BE_SHARED_SHIFT) : 0;
} }
nvme_namespace_data_swapbytes(&nsdata); nvme_namespace_data_swapbytes(&nsdata);