All of lore.kernel.org
 help / color / mirror / Atom feed
From: chaitanya.kulkarni@wdc.com (Chaitanya Kulkarni)
Subject: [PATCH 10/12] nvmet: add error log support for admin-cmd
Date: Sun,  9 Dec 2018 21:50:09 -0800	[thread overview]
Message-ID: <20181210055011.3146-11-chaitanya.kulkarni@wdc.com> (raw)
In-Reply-To: <20181210055011.3146-1-chaitanya.kulkarni@wdc.com>

This patch adds the support to maintain the error log page for admin
commands.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 drivers/nvme/target/admin-cmd.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 721b041a6b3b..fa62db7a5e9e 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -47,6 +47,7 @@ static u16 nvmet_get_smart_log_nsid(struct nvmet_req *req,
 	if (!ns) {
 		pr_err("Could not find namespace id : %d\n",
 				le32_to_cpu(req->cmd->get_log_page.nsid));
+		req->error_loc = offsetof(struct nvme_rw_command, nsid);
 		return NVME_SC_INVALID_NS;
 	}
 
@@ -380,6 +381,7 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)
 	u16 status = 0;
 
 	if (le32_to_cpu(req->cmd->identify.nsid) == NVME_NSID_ALL) {
+		req->error_loc = offsetof(struct nvme_identify, nsid);
 		status = NVME_SC_INVALID_NS | NVME_SC_DNR;
 		goto out;
 	}
@@ -500,6 +502,7 @@ static void nvmet_execute_identify_desclist(struct nvmet_req *req)
 
 	ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->identify.nsid);
 	if (!ns) {
+		req->error_loc = offsetof(struct nvme_identify, nsid);
 		status = NVME_SC_INVALID_NS | NVME_SC_DNR;
 		goto out;
 	}
@@ -562,8 +565,10 @@ static u16 nvmet_set_feat_write_protect(struct nvmet_req *req)
 	u16 status = NVME_SC_FEATURE_NOT_CHANGEABLE;
 
 	req->ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->rw.nsid);
-	if (unlikely(!req->ns))
+	if (unlikely(!req->ns)) {
+		req->error_loc = offsetof(struct nvme_common_command, nsid);
 		return status;
+	}
 
 	mutex_lock(&subsys->lock);
 	switch (write_protect) {
@@ -602,8 +607,10 @@ u16 nvmet_set_feat_async_event(struct nvmet_req *req, u32 mask)
 {
 	u32 val32 = le32_to_cpu(req->cmd->common.cdw11);
 
-	if (val32 & ~mask)
+	if (val32 & ~mask) {
+		req->error_loc = offsetof(struct nvme_common_command, cdw11);
 		return NVME_SC_INVALID_FIELD | NVME_SC_DNR;
+	}
 
 	WRITE_ONCE(req->sq->ctrl->aen_enabled, val32);
 	nvmet_set_result(req, val32);
@@ -635,6 +642,7 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
 		status = nvmet_set_feat_write_protect(req);
 		break;
 	default:
+		req->error_loc = offsetof(struct nvme_common_command, cdw10);
 		status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
 		break;
 	}
@@ -648,9 +656,10 @@ static u16 nvmet_get_feat_write_protect(struct nvmet_req *req)
 	u32 result;
 
 	req->ns = nvmet_find_namespace(req->sq->ctrl, req->cmd->common.nsid);
-	if (!req->ns)
+	if (!req->ns)  {
+		req->error_loc = offsetof(struct nvme_common_command, nsid);
 		return NVME_SC_INVALID_NS | NVME_SC_DNR;
-
+	}
 	mutex_lock(&subsys->lock);
 	if (req->ns->readonly == true)
 		result = NVME_NS_WRITE_PROTECT;
@@ -716,6 +725,8 @@ static void nvmet_execute_get_features(struct nvmet_req *req)
 	case NVME_FEAT_HOST_ID:
 		/* need 128-bit host identifier flag */
 		if (!(req->cmd->common.cdw11 & cpu_to_le32(1 << 0))) {
+			req->error_loc =
+				offsetof(struct nvme_common_command, cdw11);
 			status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
 			break;
 		}
@@ -727,6 +738,8 @@ static void nvmet_execute_get_features(struct nvmet_req *req)
 		status = nvmet_get_feat_write_protect(req);
 		break;
 	default:
+		req->error_loc =
+			offsetof(struct nvme_common_command, cdw10);
 		status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
 		break;
 	}
@@ -848,5 +861,6 @@ u16 nvmet_parse_admin_cmd(struct nvmet_req *req)
 
 	pr_err("unhandled cmd %d on qid %d\n", cmd->common.opcode,
 	       req->sq->qid);
+	req->error_loc = offsetof(struct nvme_common_command, opcode);
 	return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
 }
-- 
2.17.0

  parent reply	other threads:[~2018-12-10  5:50 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-10  5:49 [PATCH 00/12] nvmet: add error log page support Chaitanya Kulkarni
2018-12-10  5:50 ` [PATCH 01/12] nvme: remove nvme_common command cdw10 array Chaitanya Kulkarni
2018-12-10 20:09   ` Sagi Grimberg
2018-12-10  5:50 ` [PATCH 02/12] nvme: add error log page slot definition Chaitanya Kulkarni
2018-12-10 20:10   ` Sagi Grimberg
2018-12-10  5:50 ` [PATCH 03/12] nvmet: add error-log definitions Chaitanya Kulkarni
2018-12-10 20:12   ` Sagi Grimberg
2018-12-10 22:47     ` Chaitanya Kulkarni
2018-12-10  5:50 ` [PATCH 04/12] nvmet: add interface to update error-log page Chaitanya Kulkarni
2018-12-10 20:18   ` Sagi Grimberg
2018-12-10 22:48     ` Chaitanya Kulkarni
2018-12-10  5:50 ` [PATCH 05/12] nvmet: add error log support in the core Chaitanya Kulkarni
2018-12-10 20:22   ` Sagi Grimberg
2018-12-10  5:50 ` [PATCH 06/12] nvmet: add error log support for bdev backend Chaitanya Kulkarni
2018-12-10 20:31   ` Sagi Grimberg
2018-12-10 22:52     ` Chaitanya Kulkarni
2018-12-10  5:50 ` [PATCH 07/12] nvmet: add error log support for file backend Chaitanya Kulkarni
2018-12-10 20:32   ` Sagi Grimberg
2018-12-10 22:53     ` Chaitanya Kulkarni
2018-12-10  5:50 ` [PATCH 08/12] nvmet: add error log support for fabrics-cmd Chaitanya Kulkarni
2018-12-10 20:36   ` Sagi Grimberg
2018-12-10  5:50 ` [PATCH 09/12] nvmet: add error log support for rdma backend Chaitanya Kulkarni
2018-12-10 20:37   ` Sagi Grimberg
2018-12-10  5:50 ` Chaitanya Kulkarni [this message]
2018-12-10 20:40   ` [PATCH 10/12] nvmet: add error log support for admin-cmd Sagi Grimberg
2018-12-10  5:50 ` [PATCH 11/12] nvmet: add error log page cmd handler Chaitanya Kulkarni
2018-12-10  5:50 ` [PATCH 12/12] nvmet: update smart log with num err log entries Chaitanya Kulkarni
     [not found] ` <BYAPR04MB4502206C5362955EF2F2014686A50@BYAPR04MB4502.namprd04.prod.outlook.com>
2018-12-11 14:15   ` [PATCH 10/12] nvmet: add error log support for admin-cmd hch
2018-12-11 23:59     ` Sagi Grimberg
2018-12-12  0:38       ` Chaitanya Kulkarni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181210055011.3146-11-chaitanya.kulkarni@wdc.com \
    --to=chaitanya.kulkarni@wdc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.