Commit 28dd5cf7 authored by Omri Mann's avatar Omri Mann Committed by Christoph Hellwig

nvmet: add support for reporting the host identifier

And fix the Get/Set Log Page implementation to take all 8 bits of the
feature identifier into account.
Signed-off-by: default avatarOmri Mann <omri@excelero.com>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
[hch: used the UUID API, updated changelog]
parent 63263d60
...@@ -443,7 +443,7 @@ static void nvmet_execute_set_features(struct nvmet_req *req) ...@@ -443,7 +443,7 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
u32 val32; u32 val32;
u16 status = 0; u16 status = 0;
switch (cdw10 & 0xf) { switch (cdw10 & 0xff) {
case NVME_FEAT_NUM_QUEUES: case NVME_FEAT_NUM_QUEUES:
nvmet_set_result(req, nvmet_set_result(req,
(subsys->max_qid - 1) | ((subsys->max_qid - 1) << 16)); (subsys->max_qid - 1) | ((subsys->max_qid - 1) << 16));
...@@ -453,6 +453,9 @@ static void nvmet_execute_set_features(struct nvmet_req *req) ...@@ -453,6 +453,9 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
req->sq->ctrl->kato = DIV_ROUND_UP(val32, 1000); req->sq->ctrl->kato = DIV_ROUND_UP(val32, 1000);
nvmet_set_result(req, req->sq->ctrl->kato); nvmet_set_result(req, req->sq->ctrl->kato);
break; break;
case NVME_FEAT_HOST_ID:
status = NVME_SC_CMD_SEQ_ERROR | NVME_SC_DNR;
break;
default: default:
status = NVME_SC_INVALID_FIELD | NVME_SC_DNR; status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
break; break;
...@@ -467,7 +470,7 @@ static void nvmet_execute_get_features(struct nvmet_req *req) ...@@ -467,7 +470,7 @@ static void nvmet_execute_get_features(struct nvmet_req *req)
u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10[0]); u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10[0]);
u16 status = 0; u16 status = 0;
switch (cdw10 & 0xf) { switch (cdw10 & 0xff) {
/* /*
* These features are mandatory in the spec, but we don't * These features are mandatory in the spec, but we don't
* have a useful way to implement them. We'll eventually * have a useful way to implement them. We'll eventually
...@@ -501,6 +504,16 @@ static void nvmet_execute_get_features(struct nvmet_req *req) ...@@ -501,6 +504,16 @@ static void nvmet_execute_get_features(struct nvmet_req *req)
case NVME_FEAT_KATO: case NVME_FEAT_KATO:
nvmet_set_result(req, req->sq->ctrl->kato * 1000); nvmet_set_result(req, req->sq->ctrl->kato * 1000);
break; break;
case NVME_FEAT_HOST_ID:
/* need 128-bit host identifier flag */
if (!(req->cmd->common.cdw10[1] & cpu_to_le32(1 << 0))) {
status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
break;
}
status = nvmet_copy_to_sgl(req, 0, &req->sq->ctrl->hostid,
sizeof(req->sq->ctrl->hostid));
break;
default: default:
status = NVME_SC_INVALID_FIELD | NVME_SC_DNR; status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
break; break;
......
...@@ -154,6 +154,7 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req) ...@@ -154,6 +154,7 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req)
le32_to_cpu(c->kato), &ctrl); le32_to_cpu(c->kato), &ctrl);
if (status) if (status)
goto out; goto out;
uuid_copy(&ctrl->hostid, &d->hostid);
status = nvmet_install_queue(ctrl, req); status = nvmet_install_queue(ctrl, req);
if (status) { if (status) {
......
...@@ -115,6 +115,7 @@ struct nvmet_ctrl { ...@@ -115,6 +115,7 @@ struct nvmet_ctrl {
u32 cc; u32 cc;
u32 csts; u32 csts;
uuid_t hostid;
u16 cntlid; u16 cntlid;
u32 kato; u32 kato;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment