diff options
author | Klaus Jensen <k.jensen@samsung.com> | 2020-02-23 09:39:58 -0800 |
---|---|---|
committer | Klaus Jensen <k.jensen@samsung.com> | 2020-09-02 08:48:50 +0200 |
commit | 6d1257f973e2be5c98650147f6cc89a5a05699e3 (patch) | |
tree | a1a064b9f59a10029437f359f918bd7633704645 /hw | |
parent | 19012fb898d0a4b3e5999212d01923a5e45cb399 (diff) | |
download | qemu-6d1257f973e2be5c98650147f6cc89a5a05699e3.zip qemu-6d1257f973e2be5c98650147f6cc89a5a05699e3.tar.gz qemu-6d1257f973e2be5c98650147f6cc89a5a05699e3.tar.bz2 |
hw/block/nvme: add request mapping helper
Introduce the nvme_map helper to remove some noise in the main nvme_rw
function.
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Minwoo Im <minwoo.im.dev@gmail.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/block/nvme.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 2c9fea8..78b4873 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -430,6 +430,15 @@ static uint16_t nvme_dma_prp(NvmeCtrl *n, uint8_t *ptr, uint32_t len, return status; } +static uint16_t nvme_map_dptr(NvmeCtrl *n, NvmeCmd *cmd, size_t len, + NvmeRequest *req) +{ + uint64_t prp1 = le64_to_cpu(cmd->dptr.prp1); + uint64_t prp2 = le64_to_cpu(cmd->dptr.prp2); + + return nvme_map_prp(&req->qsg, &req->iov, prp1, prp2, len, n); +} + static void nvme_post_cqes(void *opaque) { NvmeCQueue *cq = opaque; @@ -617,8 +626,6 @@ static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRwCmd *rw = (NvmeRwCmd *)cmd; uint32_t nlb = le32_to_cpu(rw->nlb) + 1; uint64_t slba = le64_to_cpu(rw->slba); - uint64_t prp1 = le64_to_cpu(rw->dptr.prp1); - uint64_t prp2 = le64_to_cpu(rw->dptr.prp2); uint8_t lba_index = NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas); uint8_t data_shift = ns->id_ns.lbaf[lba_index].ds; @@ -635,7 +642,7 @@ static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, return NVME_LBA_RANGE | NVME_DNR; } - if (nvme_map_prp(&req->qsg, &req->iov, prp1, prp2, data_size, n)) { + if (nvme_map_dptr(n, cmd, data_size, req)) { block_acct_invalid(blk_get_stats(n->conf.blk), acct); return NVME_INVALID_FIELD | NVME_DNR; } |