Commit 84faf42b authored by Chaitanya Kulkarni's avatar Chaitanya Kulkarni Committed by Christoph Hellwig

nvmet: add error log support for fabrics-cmd

This patch adds the support to maintain error log page for the fabrics
prop get, prop set, and admin connect commands. Here we also update the
discovery.c and add update set/get features and parse functions to
support error log page.
Signed-off-by: default avatarChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent e81446af
...@@ -259,6 +259,8 @@ static void nvmet_execute_disc_set_features(struct nvmet_req *req) ...@@ -259,6 +259,8 @@ static void nvmet_execute_disc_set_features(struct nvmet_req *req)
NVMET_DISC_AEN_CFG_OPTIONAL); NVMET_DISC_AEN_CFG_OPTIONAL);
break; break;
default: default:
req->error_loc =
offsetof(struct nvme_common_command, cdw10);
stat = NVME_SC_INVALID_FIELD | NVME_SC_DNR; stat = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
break; break;
} }
...@@ -279,6 +281,8 @@ static void nvmet_execute_disc_get_features(struct nvmet_req *req) ...@@ -279,6 +281,8 @@ static void nvmet_execute_disc_get_features(struct nvmet_req *req)
nvmet_get_feat_async_event(req); nvmet_get_feat_async_event(req);
break; break;
default: default:
req->error_loc =
offsetof(struct nvme_common_command, cdw10);
stat = NVME_SC_INVALID_FIELD | NVME_SC_DNR; stat = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
break; break;
} }
...@@ -293,6 +297,8 @@ u16 nvmet_parse_discovery_cmd(struct nvmet_req *req) ...@@ -293,6 +297,8 @@ u16 nvmet_parse_discovery_cmd(struct nvmet_req *req)
if (unlikely(!(req->sq->ctrl->csts & NVME_CSTS_RDY))) { if (unlikely(!(req->sq->ctrl->csts & NVME_CSTS_RDY))) {
pr_err("got cmd %d while not ready\n", pr_err("got cmd %d while not ready\n",
cmd->common.opcode); cmd->common.opcode);
req->error_loc =
offsetof(struct nvme_common_command, opcode);
return NVME_SC_INVALID_OPCODE | NVME_SC_DNR; return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
} }
...@@ -323,6 +329,8 @@ u16 nvmet_parse_discovery_cmd(struct nvmet_req *req) ...@@ -323,6 +329,8 @@ u16 nvmet_parse_discovery_cmd(struct nvmet_req *req)
default: default:
pr_err("unsupported get_log_page lid %d\n", pr_err("unsupported get_log_page lid %d\n",
cmd->get_log_page.lid); cmd->get_log_page.lid);
req->error_loc =
offsetof(struct nvme_get_log_page_command, lid);
return NVME_SC_INVALID_OPCODE | NVME_SC_DNR; return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
} }
case nvme_admin_identify: case nvme_admin_identify:
...@@ -335,10 +343,12 @@ u16 nvmet_parse_discovery_cmd(struct nvmet_req *req) ...@@ -335,10 +343,12 @@ u16 nvmet_parse_discovery_cmd(struct nvmet_req *req)
default: default:
pr_err("unsupported identify cns %d\n", pr_err("unsupported identify cns %d\n",
cmd->identify.cns); cmd->identify.cns);
req->error_loc = offsetof(struct nvme_identify, cns);
return NVME_SC_INVALID_OPCODE | NVME_SC_DNR; return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
} }
default: default:
pr_err("unhandled cmd %d\n", cmd->common.opcode); pr_err("unhandled cmd %d\n", cmd->common.opcode);
req->error_loc = offsetof(struct nvme_common_command, opcode);
return NVME_SC_INVALID_OPCODE | NVME_SC_DNR; return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
} }
......
...@@ -17,23 +17,26 @@ ...@@ -17,23 +17,26 @@
static void nvmet_execute_prop_set(struct nvmet_req *req) static void nvmet_execute_prop_set(struct nvmet_req *req)
{ {
u64 val = le64_to_cpu(req->cmd->prop_set.value);
u16 status = 0; u16 status = 0;
if (!(req->cmd->prop_set.attrib & 1)) { if (req->cmd->prop_set.attrib & 1) {
u64 val = le64_to_cpu(req->cmd->prop_set.value); req->error_loc =
offsetof(struct nvmf_property_set_command, attrib);
switch (le32_to_cpu(req->cmd->prop_set.offset)) {
case NVME_REG_CC:
nvmet_update_cc(req->sq->ctrl, val);
break;
default:
status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
break;
}
} else {
status = NVME_SC_INVALID_FIELD | NVME_SC_DNR; status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
goto out;
} }
switch (le32_to_cpu(req->cmd->prop_set.offset)) {
case NVME_REG_CC:
nvmet_update_cc(req->sq->ctrl, val);
break;
default:
req->error_loc =
offsetof(struct nvmf_property_set_command, offset);
status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
}
out:
nvmet_req_complete(req, status); nvmet_req_complete(req, status);
} }
...@@ -69,6 +72,14 @@ static void nvmet_execute_prop_get(struct nvmet_req *req) ...@@ -69,6 +72,14 @@ static void nvmet_execute_prop_get(struct nvmet_req *req)
} }
} }
if (status && req->cmd->prop_get.attrib & 1) {
req->error_loc =
offsetof(struct nvmf_property_get_command, offset);
} else {
req->error_loc =
offsetof(struct nvmf_property_get_command, attrib);
}
req->rsp->result.u64 = cpu_to_le64(val); req->rsp->result.u64 = cpu_to_le64(val);
nvmet_req_complete(req, status); nvmet_req_complete(req, status);
} }
...@@ -89,6 +100,7 @@ u16 nvmet_parse_fabrics_cmd(struct nvmet_req *req) ...@@ -89,6 +100,7 @@ u16 nvmet_parse_fabrics_cmd(struct nvmet_req *req)
default: default:
pr_err("received unknown capsule type 0x%x\n", pr_err("received unknown capsule type 0x%x\n",
cmd->fabrics.fctype); cmd->fabrics.fctype);
req->error_loc = offsetof(struct nvmf_common_command, fctype);
return NVME_SC_INVALID_OPCODE | NVME_SC_DNR; return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
} }
...@@ -105,10 +117,12 @@ static u16 nvmet_install_queue(struct nvmet_ctrl *ctrl, struct nvmet_req *req) ...@@ -105,10 +117,12 @@ static u16 nvmet_install_queue(struct nvmet_ctrl *ctrl, struct nvmet_req *req)
old = cmpxchg(&req->sq->ctrl, NULL, ctrl); old = cmpxchg(&req->sq->ctrl, NULL, ctrl);
if (old) { if (old) {
pr_warn("queue already connected!\n"); pr_warn("queue already connected!\n");
req->error_loc = offsetof(struct nvmf_connect_command, opcode);
return NVME_SC_CONNECT_CTRL_BUSY | NVME_SC_DNR; return NVME_SC_CONNECT_CTRL_BUSY | NVME_SC_DNR;
} }
if (!sqsize) { if (!sqsize) {
pr_warn("queue size zero!\n"); pr_warn("queue size zero!\n");
req->error_loc = offsetof(struct nvmf_connect_command, sqsize);
return NVME_SC_CONNECT_INVALID_PARAM | NVME_SC_DNR; return NVME_SC_CONNECT_INVALID_PARAM | NVME_SC_DNR;
} }
...@@ -157,6 +171,7 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req) ...@@ -157,6 +171,7 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req)
if (c->recfmt != 0) { if (c->recfmt != 0) {
pr_warn("invalid connect version (%d).\n", pr_warn("invalid connect version (%d).\n",
le16_to_cpu(c->recfmt)); le16_to_cpu(c->recfmt));
req->error_loc = offsetof(struct nvmf_connect_command, recfmt);
status = NVME_SC_CONNECT_FORMAT | NVME_SC_DNR; status = NVME_SC_CONNECT_FORMAT | NVME_SC_DNR;
goto out; goto out;
} }
...@@ -171,8 +186,13 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req) ...@@ -171,8 +186,13 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req)
status = nvmet_alloc_ctrl(d->subsysnqn, d->hostnqn, req, status = nvmet_alloc_ctrl(d->subsysnqn, d->hostnqn, req,
le32_to_cpu(c->kato), &ctrl); le32_to_cpu(c->kato), &ctrl);
if (status) if (status) {
if (status == (NVME_SC_INVALID_FIELD | NVME_SC_DNR))
req->error_loc =
offsetof(struct nvme_common_command, opcode);
goto out; goto out;
}
uuid_copy(&ctrl->hostid, &d->hostid); uuid_copy(&ctrl->hostid, &d->hostid);
status = nvmet_install_queue(ctrl, req); status = nvmet_install_queue(ctrl, req);
...@@ -259,11 +279,13 @@ u16 nvmet_parse_connect_cmd(struct nvmet_req *req) ...@@ -259,11 +279,13 @@ u16 nvmet_parse_connect_cmd(struct nvmet_req *req)
if (cmd->common.opcode != nvme_fabrics_command) { if (cmd->common.opcode != nvme_fabrics_command) {
pr_err("invalid command 0x%x on unconnected queue.\n", pr_err("invalid command 0x%x on unconnected queue.\n",
cmd->fabrics.opcode); cmd->fabrics.opcode);
req->error_loc = offsetof(struct nvme_common_command, opcode);
return NVME_SC_INVALID_OPCODE | NVME_SC_DNR; return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
} }
if (cmd->fabrics.fctype != nvme_fabrics_type_connect) { if (cmd->fabrics.fctype != nvme_fabrics_type_connect) {
pr_err("invalid capsule type 0x%x on unconnected queue.\n", pr_err("invalid capsule type 0x%x on unconnected queue.\n",
cmd->fabrics.fctype); cmd->fabrics.fctype);
req->error_loc = offsetof(struct nvmf_common_command, fctype);
return NVME_SC_INVALID_OPCODE | NVME_SC_DNR; return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
} }
......
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