linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
To: linux-nvme@lists.infradead.org
Cc: kbusch@kernel.org, hch@lst.de,
	Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>,
	sagi@grimberg.me
Subject: [PATCH 2/4] nvmet: add support for set-feat-timestamp cmd
Date: Tue, 18 Feb 2020 13:43:36 -0800	[thread overview]
Message-ID: <20200218214338.25088-3-chaitanya.kulkarni@wdc.com> (raw)
In-Reply-To: <20200218214338.25088-1-chaitanya.kulkarni@wdc.com>

This patch allows host to use set-feature command to set the timestamp
value in the target controller.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/target/admin-cmd.c | 20 ++++++++++++++++++++
 drivers/nvme/target/nvmet.h     |  3 +++
 2 files changed, 23 insertions(+)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index f6374cd5e938..ebb595480422 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -29,6 +29,8 @@ static u32 nvmet_feat_data_len(struct nvmet_req *req, u32 cdw10)
 	switch (cdw10 & 0xff) {
 	case NVME_FEAT_HOST_ID:
 		return sizeof(req->sq->ctrl->hostid);
+	case NVME_FEAT_TIMESTAMP:
+		return sizeof(req->sq->ctrl->ts);
 	default:
 		return 0;
 	}
@@ -729,6 +731,21 @@ u16 nvmet_set_feat_async_event(struct nvmet_req *req, u32 mask)
 	return 0;
 }
 
+static u16 nvmet_set_feat_ts(struct nvmet_req *req)
+{
+	u16 status;
+	__le64 ts;
+
+	status = nvmet_copy_from_sgl(req, 0, &ts, sizeof(ts));
+	if (status)
+		goto out;
+
+	req->sq->ctrl->ts = le64_to_cpu(ts);
+	req->sq->ctrl->local_ts = ktime_to_ms(ktime_get_real());
+out:
+	return status;
+}
+
 static void nvmet_execute_set_features(struct nvmet_req *req)
 {
 	struct nvmet_subsys *subsys = req->sq->ctrl->subsys;
@@ -755,6 +772,9 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
 	case NVME_FEAT_WRITE_PROTECT:
 		status = nvmet_set_feat_write_protect(req);
 		break;
+	case NVME_FEAT_TIMESTAMP:
+		status = nvmet_set_feat_ts(req);
+		break;
 	default:
 		req->error_loc = offsetof(struct nvme_common_command, cdw10);
 		status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 42ba2ddd9e96..a3ecc269ebb9 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -173,6 +173,9 @@ struct nvmet_ctrl {
 	u16			cntlid;
 	u32			kato;
 
+	u64			ts;
+	u64			local_ts;
+
 	struct nvmet_port	*port;
 
 	u32			aen_enabled;
-- 
2.22.1


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  parent reply	other threads:[~2020-02-18 21:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-18 21:43 [PATCH 0/4] nvmet: add set feature based timestamp support Chaitanya Kulkarni
2020-02-18 21:43 ` [PATCH 1/4] nvmet: use nvmet_feat_data_len consistently Chaitanya Kulkarni
2020-02-19 14:59   ` Christoph Hellwig
2020-02-18 21:43 ` Chaitanya Kulkarni [this message]
2020-02-18 21:43 ` [PATCH 3/4] nvmet: add support for get-feat-timestamp cmd Chaitanya Kulkarni
2020-02-18 21:43 ` [PATCH 4/4] nvmet: update ctrl oncs values for timestamp Chaitanya Kulkarni
2020-02-18 23:10 ` [PATCH 0/4] nvmet: add set feature based timestamp support Keith Busch
2020-02-19 14:59   ` Christoph Hellwig
2020-02-19 15:49     ` Chaitanya Kulkarni
2020-02-20  7:48       ` Sagi Grimberg
2020-02-20 16:36         ` 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=20200218214338.25088-3-chaitanya.kulkarni@wdc.com \
    --to=chaitanya.kulkarni@wdc.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).