提交 92decf11 编写于 作者: K Keith Busch 提交者: Jens Axboe

nvme: define constants for identification values

Improve code readability by defining the specification's constants that
the driver is using when decoding identification payloads.
Signed-off-by: NKeith Busch <kbusch@kernel.org>
Reviewed-by: NBart van Assche <bvanassche@acm.org>
Reviewed-by: NChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Acked-by: NSagi Grimberg <sagi@grimberg.me>
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
上级 d02abd19
...@@ -1859,13 +1859,13 @@ static void nvme_update_disk_info(struct gendisk *disk, ...@@ -1859,13 +1859,13 @@ static void nvme_update_disk_info(struct gendisk *disk,
* and whether it should be used instead of AWUPF. If NAWUPF == * and whether it should be used instead of AWUPF. If NAWUPF ==
* 0 then AWUPF must be used instead. * 0 then AWUPF must be used instead.
*/ */
if (id->nsfeat & (1 << 1) && id->nawupf) if (id->nsfeat & NVME_NS_FEAT_ATOMICS && id->nawupf)
atomic_bs = (1 + le16_to_cpu(id->nawupf)) * bs; atomic_bs = (1 + le16_to_cpu(id->nawupf)) * bs;
else else
atomic_bs = (1 + ns->ctrl->subsys->awupf) * bs; atomic_bs = (1 + ns->ctrl->subsys->awupf) * bs;
} }
if (id->nsfeat & (1 << 4)) { if (id->nsfeat & NVME_NS_FEAT_IO_OPT) {
/* NPWG = Namespace Preferred Write Granularity */ /* NPWG = Namespace Preferred Write Granularity */
phys_bs = bs * (1 + le16_to_cpu(id->npwg)); phys_bs = bs * (1 + le16_to_cpu(id->npwg));
/* NOWS = Namespace Optimal Write Size */ /* NOWS = Namespace Optimal Write Size */
...@@ -1894,7 +1894,7 @@ static void nvme_update_disk_info(struct gendisk *disk, ...@@ -1894,7 +1894,7 @@ static void nvme_update_disk_info(struct gendisk *disk,
nvme_config_discard(disk, ns); nvme_config_discard(disk, ns);
nvme_config_write_zeroes(disk, ns); nvme_config_write_zeroes(disk, ns);
if (id->nsattr & (1 << 0)) if (id->nsattr & NVME_NS_ATTR_RO)
set_disk_ro(disk, true); set_disk_ro(disk, true);
else else
set_disk_ro(disk, false); set_disk_ro(disk, false);
...@@ -2685,7 +2685,7 @@ static bool nvme_validate_cntlid(struct nvme_subsystem *subsys, ...@@ -2685,7 +2685,7 @@ static bool nvme_validate_cntlid(struct nvme_subsystem *subsys,
return false; return false;
} }
if ((id->cmic & (1 << 1)) || if ((id->cmic & NVME_CTRL_CMIC_MULTI_CTRL) ||
(ctrl->opts && ctrl->opts->discovery_nqn)) (ctrl->opts && ctrl->opts->discovery_nqn))
continue; continue;
...@@ -3497,7 +3497,7 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid, ...@@ -3497,7 +3497,7 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
struct nvme_id_ns *id) struct nvme_id_ns *id)
{ {
struct nvme_ctrl *ctrl = ns->ctrl; struct nvme_ctrl *ctrl = ns->ctrl;
bool is_shared = id->nmic & (1 << 0); bool is_shared = id->nmic & NVME_NS_NMIC_SHARED;
struct nvme_ns_head *head = NULL; struct nvme_ns_head *head = NULL;
struct nvme_ns_ids ids; struct nvme_ns_ids ids;
int ret = 0; int ret = 0;
......
...@@ -372,7 +372,7 @@ int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head) ...@@ -372,7 +372,7 @@ int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head)
* We also do this for private namespaces as the namespace sharing data could * We also do this for private namespaces as the namespace sharing data could
* change after a rescan. * change after a rescan.
*/ */
if (!(ctrl->subsys->cmic & (1 << 1)) || !multipath) if (!(ctrl->subsys->cmic & NVME_CTRL_CMIC_MULTI_CTRL) || !multipath)
return 0; return 0;
q = blk_alloc_queue(nvme_ns_head_make_request, ctrl->numa_node); q = blk_alloc_queue(nvme_ns_head_make_request, ctrl->numa_node);
...@@ -694,7 +694,8 @@ int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) ...@@ -694,7 +694,8 @@ int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
int error; int error;
/* check if multipath is enabled and we have the capability */ /* check if multipath is enabled and we have the capability */
if (!multipath || !ctrl->subsys || !(ctrl->subsys->cmic & (1 << 3))) if (!multipath || !ctrl->subsys ||
!(ctrl->subsys->cmic & NVME_CTRL_CMIC_ANA))
return 0; return 0;
ctrl->anacap = id->anacap; ctrl->anacap = id->anacap;
......
...@@ -301,6 +301,8 @@ struct nvme_id_ctrl { ...@@ -301,6 +301,8 @@ struct nvme_id_ctrl {
}; };
enum { enum {
NVME_CTRL_CMIC_MULTI_CTRL = 1 << 1,
NVME_CTRL_CMIC_ANA = 1 << 3,
NVME_CTRL_ONCS_COMPARE = 1 << 0, NVME_CTRL_ONCS_COMPARE = 1 << 0,
NVME_CTRL_ONCS_WRITE_UNCORRECTABLE = 1 << 1, NVME_CTRL_ONCS_WRITE_UNCORRECTABLE = 1 << 1,
NVME_CTRL_ONCS_DSM = 1 << 2, NVME_CTRL_ONCS_DSM = 1 << 2,
...@@ -396,8 +398,12 @@ enum { ...@@ -396,8 +398,12 @@ enum {
enum { enum {
NVME_NS_FEAT_THIN = 1 << 0, NVME_NS_FEAT_THIN = 1 << 0,
NVME_NS_FEAT_ATOMICS = 1 << 1,
NVME_NS_FEAT_IO_OPT = 1 << 4,
NVME_NS_ATTR_RO = 1 << 0,
NVME_NS_FLBAS_LBA_MASK = 0xf, NVME_NS_FLBAS_LBA_MASK = 0xf,
NVME_NS_FLBAS_META_EXT = 0x10, NVME_NS_FLBAS_META_EXT = 0x10,
NVME_NS_NMIC_SHARED = 1 << 0,
NVME_LBAF_RP_BEST = 0, NVME_LBAF_RP_BEST = 0,
NVME_LBAF_RP_BETTER = 1, NVME_LBAF_RP_BETTER = 1,
NVME_LBAF_RP_GOOD = 2, NVME_LBAF_RP_GOOD = 2,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册