From 72eb2cf9e36619cc7b1dcbf99fd83a5cbf8d0ca4 Mon Sep 17 00:00:00 2001 From: jimharris Date: Fri, 12 Apr 2013 17:48:45 +0000 Subject: [PATCH] Move the busdma mapping functions to nvme_qpair.c. This removes nvme_uio.c completely. Sponsored by: Intel --- sys/dev/nvme/nvme.c | 37 ------------------------------ sys/dev/nvme/nvme_private.h | 4 ---- sys/dev/nvme/nvme_qpair.c | 45 +++++++++++++++++++++++++++++++++++++ sys/dev/nvme/nvme_uio.c | 43 ----------------------------------- sys/modules/nvme/Makefile | 1 - 5 files changed, 45 insertions(+), 85 deletions(-) delete mode 100644 sys/dev/nvme/nvme_uio.c diff --git a/sys/dev/nvme/nvme.c b/sys/dev/nvme/nvme.c index 616b84c6ef6..bd8c89727ba 100644 --- a/sys/dev/nvme/nvme.c +++ b/sys/dev/nvme/nvme.c @@ -229,43 +229,6 @@ nvme_dump_completion(struct nvme_completion *cpl) cpl->status.m, cpl->status.dnr); } -void -nvme_payload_map(void *arg, bus_dma_segment_t *seg, int nseg, int error) -{ - struct nvme_tracker *tr = arg; - uint32_t cur_nseg; - - /* - * If the mapping operation failed, return immediately. The caller - * is responsible for detecting the error status and failing the - * tracker manually. - */ - if (error != 0) - return; - - /* - * Note that we specified PAGE_SIZE for alignment and max - * segment size when creating the bus dma tags. So here - * we can safely just transfer each segment to its - * associated PRP entry. - */ - tr->req->cmd.prp1 = seg[0].ds_addr; - - if (nseg == 2) { - tr->req->cmd.prp2 = seg[1].ds_addr; - } else if (nseg > 2) { - cur_nseg = 1; - tr->req->cmd.prp2 = (uint64_t)tr->prp_bus_addr; - while (cur_nseg < nseg) { - tr->prp[cur_nseg-1] = - (uint64_t)seg[cur_nseg].ds_addr; - cur_nseg++; - } - } - - nvme_qpair_submit_tracker(tr->qpair, tr); -} - static int nvme_attach(device_t dev) { diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h index c78b1eab9d8..12d8691faea 100644 --- a/sys/dev/nvme/nvme_private.h +++ b/sys/dev/nvme/nvme_private.h @@ -429,10 +429,6 @@ void nvme_ctrlr_cmd_set_async_event_config(struct nvme_controller *ctrlr, void nvme_ctrlr_cmd_abort(struct nvme_controller *ctrlr, uint16_t cid, uint16_t sqid, nvme_cb_fn_t cb_fn, void *cb_arg); -void nvme_payload_map(void *arg, bus_dma_segment_t *seg, int nseg, - int error); -void nvme_payload_map_uio(void *arg, bus_dma_segment_t *seg, int nseg, - bus_size_t mapsize, int error); void nvme_completion_poll_cb(void *arg, const struct nvme_completion *cpl); int nvme_ctrlr_construct(struct nvme_controller *ctrlr, device_t dev); diff --git a/sys/dev/nvme/nvme_qpair.c b/sys/dev/nvme/nvme_qpair.c index 9a73bd29e85..b9bc027f05e 100644 --- a/sys/dev/nvme/nvme_qpair.c +++ b/sys/dev/nvme/nvme_qpair.c @@ -698,6 +698,51 @@ nvme_qpair_submit_tracker(struct nvme_qpair *qpair, struct nvme_tracker *tr) qpair->num_cmds++; } +static void +nvme_payload_map(void *arg, bus_dma_segment_t *seg, int nseg, int error) +{ + struct nvme_tracker *tr = arg; + uint32_t cur_nseg; + + /* + * If the mapping operation failed, return immediately. The caller + * is responsible for detecting the error status and failing the + * tracker manually. + */ + if (error != 0) + return; + + /* + * Note that we specified PAGE_SIZE for alignment and max + * segment size when creating the bus dma tags. So here + * we can safely just transfer each segment to its + * associated PRP entry. + */ + tr->req->cmd.prp1 = seg[0].ds_addr; + + if (nseg == 2) { + tr->req->cmd.prp2 = seg[1].ds_addr; + } else if (nseg > 2) { + cur_nseg = 1; + tr->req->cmd.prp2 = (uint64_t)tr->prp_bus_addr; + while (cur_nseg < nseg) { + tr->prp[cur_nseg-1] = + (uint64_t)seg[cur_nseg].ds_addr; + cur_nseg++; + } + } + + nvme_qpair_submit_tracker(tr->qpair, tr); +} + +static void +nvme_payload_map_uio(void *arg, bus_dma_segment_t *seg, int nseg, + bus_size_t mapsize, int error) +{ + + nvme_payload_map(arg, seg, nseg, error); +} + static void _nvme_qpair_submit_request(struct nvme_qpair *qpair, struct nvme_request *req) { diff --git a/sys/dev/nvme/nvme_uio.c b/sys/dev/nvme/nvme_uio.c deleted file mode 100644 index 08f7c6f5b3c..00000000000 --- a/sys/dev/nvme/nvme_uio.c +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * Copyright (C) 2012 Intel Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include - -#include "nvme_private.h" - -void -nvme_payload_map_uio(void *arg, bus_dma_segment_t *seg, int nseg, - bus_size_t mapsize, int error) -{ - - nvme_payload_map(arg, seg, nseg, error); -} diff --git a/sys/modules/nvme/Makefile b/sys/modules/nvme/Makefile index 8c1210a5eeb..17004bca5f3 100644 --- a/sys/modules/nvme/Makefile +++ b/sys/modules/nvme/Makefile @@ -12,7 +12,6 @@ SRCS = nvme.c \ nvme_qpair.c \ nvme_sysctl.c \ nvme_test.c \ - nvme_uio.c \ \ bus_if.h \ device_if.h \ -- 2.45.0