[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 03/17] hw/block/nvme: add support for the abort command
From: |
Klaus Jensen |
Subject: |
[PATCH 03/17] hw/block/nvme: add support for the abort command |
Date: |
Mon, 29 Jun 2020 20:26:28 +0200 |
From: Klaus Jensen <k.jensen@samsung.com>
Required for compliance with NVMe revision 1.3d. See NVM Express 1.3d,
Section 5.1 ("Abort command").
The Abort command is a best effort command; for now, the device always
fails to abort the given command.
Signed-off-by: Klaus Jensen <klaus.jensen@cnexlabs.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Acked-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
---
hw/block/nvme.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index f5d9148f0936..b7037a7d3504 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -761,6 +761,18 @@ static uint16_t nvme_identify(NvmeCtrl *n, NvmeCmd *cmd)
}
}
+static uint16_t nvme_abort(NvmeCtrl *n, NvmeCmd *cmd, NvmeRequest *req)
+{
+ uint16_t sqid = le32_to_cpu(cmd->cdw10) & 0xffff;
+
+ req->cqe.result = 1;
+ if (nvme_check_sqid(n, sqid)) {
+ return NVME_INVALID_FIELD | NVME_DNR;
+ }
+
+ return NVME_SUCCESS;
+}
+
static inline void nvme_set_timestamp(NvmeCtrl *n, uint64_t ts)
{
trace_pci_nvme_setfeat_timestamp(ts);
@@ -897,6 +909,8 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeCmd *cmd,
NvmeRequest *req)
return nvme_create_cq(n, cmd);
case NVME_ADM_CMD_IDENTIFY:
return nvme_identify(n, cmd);
+ case NVME_ADM_CMD_ABORT:
+ return nvme_abort(n, cmd, req);
case NVME_ADM_CMD_SET_FEATURES:
return nvme_set_feature(n, cmd, req);
case NVME_ADM_CMD_GET_FEATURES:
@@ -1582,6 +1596,19 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice
*pci_dev)
id->ieee[1] = 0x02;
id->ieee[2] = 0xb3;
id->oacs = cpu_to_le16(0);
+
+ /*
+ * Because the controller always completes the Abort command immediately,
+ * there can never be more than one concurrently executing Abort command,
+ * so this value is never used for anything. Note that there can easily be
+ * many Abort commands in the queues, but they are not considered
+ * "executing" until processed by nvme_abort.
+ *
+ * The specification recommends a value of 3 for Abort Command Limit (four
+ * concurrently outstanding Abort commands), so lets use that though it is
+ * inconsequential.
+ */
+ id->acl = 3;
id->frmw = 7 << 1;
id->lpa = 1 << 0;
id->sqes = (0x6 << 4) | 0x6;
--
2.27.0
- [PATCH 00/17] hw/block/nvme: bump to v1.3, Klaus Jensen, 2020/06/29
- [PATCH 03/17] hw/block/nvme: add support for the abort command,
Klaus Jensen <=
- [PATCH 04/17] hw/block/nvme: add temperature threshold feature, Klaus Jensen, 2020/06/29
- [PATCH 01/17] hw/block/nvme: bump spec data structures to v1.3, Klaus Jensen, 2020/06/29
- [PATCH 05/17] hw/block/nvme: mark fw slot 1 as read-only, Klaus Jensen, 2020/06/29
- [PATCH 02/17] hw/block/nvme: additional tracing, Klaus Jensen, 2020/06/29
- [PATCH 08/17] hw/block/nvme: move NvmeFeatureVal into hw/block/nvme.h, Klaus Jensen, 2020/06/29
- [PATCH 10/17] hw/block/nvme: fix missing endian conversion, Klaus Jensen, 2020/06/29
- [PATCH 06/17] hw/block/nvme: add support for the get log page command, Klaus Jensen, 2020/06/29
- [PATCH 07/17] hw/block/nvme: add support for the asynchronous event request command, Klaus Jensen, 2020/06/29
- [PATCH 09/17] hw/block/nvme: flush write cache when disabled, Klaus Jensen, 2020/06/29
- [PATCH 15/17] hw/block/nvme: enforce valid queue creation sequence, Klaus Jensen, 2020/06/29