aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorParav Pandit <parav@mellanox.com>2017-01-26 10:17:28 -0500
committerJens Axboe <axboe@fb.com>2017-02-22 15:34:00 -0500
commit986994a27587efd8ce4c595cab89b570f7475359 (patch)
treed15adc87e0864d0a79c1a1cfc01bd16edc076710
parent778f067c185ce56d06aedb5fba5a0e98bb464f7b (diff)
nvme: Use CNS as 8-bit field and avoid endianness conversion
This patch defines CNS field as 8-bit field and avoids cpu_to/from_le conversions. Also initialize nvme_command cns value explicitly to NVME_ID_CNS_NS for readability (don't rely on the fact that NVME_ID_CNS_NS = 0). Reviewed-by: Max Gurtovoy <maxg@mellanox.com> Signed-off-by: Parav Pandit <parav@mellanox.com> Reviewed-by: Keith Busch <keith.busch@intel.com> Signed-off-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--drivers/nvme/host/core.c5
-rw-r--r--drivers/nvme/target/admin-cmd.c2
-rw-r--r--drivers/nvme/target/discovery.c4
-rw-r--r--include/linux/nvme.h4
4 files changed, 9 insertions, 6 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index a68bf6954ead..8b1be128b66e 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -560,7 +560,7 @@ int nvme_identify_ctrl(struct nvme_ctrl *dev, struct nvme_id_ctrl **id)
560 560
561 /* gcc-4.4.4 (at least) has issues with initializers and anon unions */ 561 /* gcc-4.4.4 (at least) has issues with initializers and anon unions */
562 c.identify.opcode = nvme_admin_identify; 562 c.identify.opcode = nvme_admin_identify;
563 c.identify.cns = cpu_to_le32(NVME_ID_CNS_CTRL); 563 c.identify.cns = NVME_ID_CNS_CTRL;
564 564
565 *id = kmalloc(sizeof(struct nvme_id_ctrl), GFP_KERNEL); 565 *id = kmalloc(sizeof(struct nvme_id_ctrl), GFP_KERNEL);
566 if (!*id) 566 if (!*id)
@@ -578,7 +578,7 @@ static int nvme_identify_ns_list(struct nvme_ctrl *dev, unsigned nsid, __le32 *n
578 struct nvme_command c = { }; 578 struct nvme_command c = { };
579 579
580 c.identify.opcode = nvme_admin_identify; 580 c.identify.opcode = nvme_admin_identify;
581 c.identify.cns = cpu_to_le32(NVME_ID_CNS_NS_ACTIVE_LIST); 581 c.identify.cns = NVME_ID_CNS_NS_ACTIVE_LIST;
582 c.identify.nsid = cpu_to_le32(nsid); 582 c.identify.nsid = cpu_to_le32(nsid);
583 return nvme_submit_sync_cmd(dev->admin_q, &c, ns_list, 0x1000); 583 return nvme_submit_sync_cmd(dev->admin_q, &c, ns_list, 0x1000);
584} 584}
@@ -592,6 +592,7 @@ int nvme_identify_ns(struct nvme_ctrl *dev, unsigned nsid,
592 /* gcc-4.4.4 (at least) has issues with initializers and anon unions */ 592 /* gcc-4.4.4 (at least) has issues with initializers and anon unions */
593 c.identify.opcode = nvme_admin_identify; 593 c.identify.opcode = nvme_admin_identify;
594 c.identify.nsid = cpu_to_le32(nsid); 594 c.identify.nsid = cpu_to_le32(nsid);
595 c.identify.cns = NVME_ID_CNS_NS;
595 596
596 *id = kmalloc(sizeof(struct nvme_id_ns), GFP_KERNEL); 597 *id = kmalloc(sizeof(struct nvme_id_ns), GFP_KERNEL);
597 if (!*id) 598 if (!*id)
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 204e85efebab..94e524fea568 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -509,7 +509,7 @@ int nvmet_parse_admin_cmd(struct nvmet_req *req)
509 break; 509 break;
510 case nvme_admin_identify: 510 case nvme_admin_identify:
511 req->data_len = 4096; 511 req->data_len = 4096;
512 switch (le32_to_cpu(cmd->identify.cns)) { 512 switch (cmd->identify.cns) {
513 case NVME_ID_CNS_NS: 513 case NVME_ID_CNS_NS:
514 req->execute = nvmet_execute_identify_ns; 514 req->execute = nvmet_execute_identify_ns;
515 return 0; 515 return 0;
diff --git a/drivers/nvme/target/discovery.c b/drivers/nvme/target/discovery.c
index 12f39eea569f..af8aabf05335 100644
--- a/drivers/nvme/target/discovery.c
+++ b/drivers/nvme/target/discovery.c
@@ -186,14 +186,14 @@ int nvmet_parse_discovery_cmd(struct nvmet_req *req)
186 } 186 }
187 case nvme_admin_identify: 187 case nvme_admin_identify:
188 req->data_len = 4096; 188 req->data_len = 4096;
189 switch (le32_to_cpu(cmd->identify.cns)) { 189 switch (cmd->identify.cns) {
190 case NVME_ID_CNS_CTRL: 190 case NVME_ID_CNS_CTRL:
191 req->execute = 191 req->execute =
192 nvmet_execute_identify_disc_ctrl; 192 nvmet_execute_identify_disc_ctrl;
193 return 0; 193 return 0;
194 default: 194 default:
195 pr_err("nvmet: unsupported identify cns %d\n", 195 pr_err("nvmet: unsupported identify cns %d\n",
196 le32_to_cpu(cmd->identify.cns)); 196 cmd->identify.cns);
197 return NVME_SC_INVALID_OPCODE | NVME_SC_DNR; 197 return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
198 } 198 }
199 default: 199 default:
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 0b676a02cf3e..5b32521456d6 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -644,7 +644,9 @@ struct nvme_identify {
644 __le32 nsid; 644 __le32 nsid;
645 __u64 rsvd2[2]; 645 __u64 rsvd2[2];
646 union nvme_data_ptr dptr; 646 union nvme_data_ptr dptr;
647 __le32 cns; 647 __u8 cns;
648 __u8 rsvd3;
649 __le16 ctrlid;
648 __u32 rsvd11[5]; 650 __u32 rsvd11[5];
649}; 651};
650 652