aboutsummaryrefslogtreecommitdiff
path: root/hw/nvme
diff options
context:
space:
mode:
authorKlaus Jensen <k.jensen@samsung.com>2021-10-06 09:40:15 +0200
committerKlaus Jensen <k.jensen@samsung.com>2022-03-03 09:28:49 +0100
commita6de6ed5092c1d6d33450e53bb8f4b711c0320ea (patch)
treeeace91c84ce6b8b66b7930c1428c8759d3fe9a46 /hw/nvme
parentd0c0697b9ef2045375e08aadb81f94b8d63ecf25 (diff)
hw/nvme: move format parameter parsing
There is no need to extract the format command parameters for each namespace. Move it to the entry point. Reviewed-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Diffstat (limited to 'hw/nvme')
-rw-r--r--hw/nvme/ctrl.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index 71c60482c7..d8701ebf2f 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -5452,6 +5452,11 @@ typedef struct NvmeFormatAIOCB {
uint32_t nsid;
bool broadcast;
int64_t offset;
+
+ uint8_t lbaf;
+ uint8_t mset;
+ uint8_t pi;
+ uint8_t pil;
} NvmeFormatAIOCB;
static void nvme_format_bh(void *opaque);
@@ -5471,14 +5476,9 @@ static const AIOCBInfo nvme_format_aiocb_info = {
.get_aio_context = nvme_get_aio_context,
};
-static void nvme_format_set(NvmeNamespace *ns, NvmeCmd *cmd)
+static void nvme_format_set(NvmeNamespace *ns, uint8_t lbaf, uint8_t mset,
+ uint8_t pi, uint8_t pil)
{
- uint32_t dw10 = le32_to_cpu(cmd->cdw10);
- uint8_t lbaf = dw10 & 0xf;
- uint8_t pi = (dw10 >> 5) & 0x7;
- uint8_t mset = (dw10 >> 4) & 0x1;
- uint8_t pil = (dw10 >> 8) & 0x1;
-
trace_pci_nvme_format_set(ns->params.nsid, lbaf, mset, pi, pil);
ns->id_ns.dps = (pil << 3) | pi;
@@ -5490,7 +5490,6 @@ static void nvme_format_set(NvmeNamespace *ns, NvmeCmd *cmd)
static void nvme_format_ns_cb(void *opaque, int ret)
{
NvmeFormatAIOCB *iocb = opaque;
- NvmeRequest *req = iocb->req;
NvmeNamespace *ns = iocb->ns;
int bytes;
@@ -5512,7 +5511,7 @@ static void nvme_format_ns_cb(void *opaque, int ret)
return;
}
- nvme_format_set(ns, &req->cmd);
+ nvme_format_set(ns, iocb->lbaf, iocb->mset, iocb->pi, iocb->pil);
ns->status = 0x0;
iocb->ns = NULL;
iocb->offset = 0;
@@ -5548,9 +5547,6 @@ static void nvme_format_bh(void *opaque)
NvmeFormatAIOCB *iocb = opaque;
NvmeRequest *req = iocb->req;
NvmeCtrl *n = nvme_ctrl(req);
- uint32_t dw10 = le32_to_cpu(req->cmd.cdw10);
- uint8_t lbaf = dw10 & 0xf;
- uint8_t pi = (dw10 >> 5) & 0x7;
uint16_t status;
int i;
@@ -5572,7 +5568,7 @@ static void nvme_format_bh(void *opaque)
goto done;
}
- status = nvme_format_check(iocb->ns, lbaf, pi);
+ status = nvme_format_check(iocb->ns, iocb->lbaf, iocb->pi);
if (status) {
req->status = status;
goto done;
@@ -5595,6 +5591,11 @@ static uint16_t nvme_format(NvmeCtrl *n, NvmeRequest *req)
{
NvmeFormatAIOCB *iocb;
uint32_t nsid = le32_to_cpu(req->cmd.nsid);
+ uint32_t dw10 = le32_to_cpu(req->cmd.cdw10);
+ uint8_t lbaf = dw10 & 0xf;
+ uint8_t mset = (dw10 >> 4) & 0x1;
+ uint8_t pi = (dw10 >> 5) & 0x7;
+ uint8_t pil = (dw10 >> 8) & 0x1;
uint16_t status;
iocb = qemu_aio_get(&nvme_format_aiocb_info, NULL, nvme_misc_cb, req);
@@ -5604,6 +5605,10 @@ static uint16_t nvme_format(NvmeCtrl *n, NvmeRequest *req)
iocb->ret = 0;
iocb->ns = NULL;
iocb->nsid = 0;
+ iocb->lbaf = lbaf;
+ iocb->mset = mset;
+ iocb->pi = pi;
+ iocb->pil = pil;
iocb->broadcast = (nsid == NVME_NSID_BROADCAST);
iocb->offset = 0;