Date: Thu, 18 Oct 2012 00:43:25 +0000 (UTC) From: Jim Harris <jimharris@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r241663 - head/sys/dev/nvme Message-ID: <201210180043.q9I0hPhZ001767@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jimharris Date: Thu Oct 18 00:43:25 2012 New Revision: 241663 URL: http://svn.freebsd.org/changeset/base/241663 Log: Create nvme_qpair_submit_request() which eliminates all of the code duplication between the admin and io controller-level submit functions. Sponsored by: Intel Modified: head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_private.h head/sys/dev/nvme/nvme_qpair.c Modified: head/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr.c Thu Oct 18 00:41:31 2012 (r241662) +++ head/sys/dev/nvme/nvme_ctrlr.c Thu Oct 18 00:43:25 2012 (r241663) @@ -796,28 +796,8 @@ void nvme_ctrlr_submit_admin_request(struct nvme_controller *ctrlr, struct nvme_request *req) { - struct nvme_qpair *qpair; - struct nvme_tracker *tr; - int err; - - qpair = &ctrlr->adminq; - - mtx_lock(&qpair->lock); - - tr = nvme_qpair_allocate_tracker(qpair); - - tr->req = req; - if (req->payload_size > 0) { - err = bus_dmamap_load(tr->qpair->dma_tag, tr->payload_dma_map, - req->payload, req->payload_size, - nvme_payload_map, tr, 0); - if (err != 0) - panic("bus_dmamap_load returned non-zero!\n"); - } else - nvme_qpair_submit_cmd(tr->qpair, tr); - - mtx_unlock(&qpair->lock); + nvme_qpair_submit_request(&ctrlr->adminq, req); } void @@ -825,37 +805,11 @@ nvme_ctrlr_submit_io_request(struct nvme struct nvme_request *req) { struct nvme_qpair *qpair; - struct nvme_tracker *tr; - int err; if (ctrlr->per_cpu_io_queues) qpair = &ctrlr->ioq[curcpu]; else qpair = &ctrlr->ioq[0]; - mtx_lock(&qpair->lock); - - tr = nvme_qpair_allocate_tracker(qpair); - - tr->req = req; - - if (req->uio == NULL) { - if (req->payload_size > 0) { - err = bus_dmamap_load(tr->qpair->dma_tag, - tr->payload_dma_map, req->payload, - req->payload_size, - nvme_payload_map, tr, 0); - if (err != 0) - panic("bus_dmamap_load returned non-zero!\n"); - } else - nvme_qpair_submit_cmd(tr->qpair, tr); - } else { - err = bus_dmamap_load_uio(tr->qpair->dma_tag, - tr->payload_dma_map, req->uio, - nvme_payload_map_uio, tr, 0); - if (err != 0) - panic("bus_dmamap_load returned non-zero!\n"); - } - - mtx_unlock(&qpair->lock); + nvme_qpair_submit_request(qpair, req); } Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Thu Oct 18 00:41:31 2012 (r241662) +++ head/sys/dev/nvme/nvme_private.h Thu Oct 18 00:43:25 2012 (r241663) @@ -354,6 +354,8 @@ void nvme_qpair_submit_cmd(struct nvme_q struct nvme_tracker *tr); void nvme_qpair_process_completions(struct nvme_qpair *qpair); struct nvme_tracker * nvme_qpair_allocate_tracker(struct nvme_qpair *qpair); +void nvme_qpair_submit_request(struct nvme_qpair *qpair, + struct nvme_request *req); void nvme_admin_qpair_destroy(struct nvme_qpair *qpair); Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Thu Oct 18 00:41:31 2012 (r241662) +++ head/sys/dev/nvme/nvme_qpair.c Thu Oct 18 00:43:25 2012 (r241663) @@ -406,3 +406,35 @@ nvme_qpair_submit_cmd(struct nvme_qpair qpair->num_cmds++; } + +void +nvme_qpair_submit_request(struct nvme_qpair *qpair, struct nvme_request *req) +{ + struct nvme_tracker *tr; + int err; + + mtx_lock(&qpair->lock); + + tr = nvme_qpair_allocate_tracker(qpair); + tr->req = req; + + if (req->uio == NULL) { + if (req->payload_size > 0) { + err = bus_dmamap_load(tr->qpair->dma_tag, + tr->payload_dma_map, req->payload, + req->payload_size, + nvme_payload_map, tr, 0); + if (err != 0) + panic("bus_dmamap_load returned non-zero!\n"); + } else + nvme_qpair_submit_cmd(tr->qpair, tr); + } else { + err = bus_dmamap_load_uio(tr->qpair->dma_tag, + tr->payload_dma_map, req->uio, + nvme_payload_map_uio, tr, 0); + if (err != 0) + panic("bus_dmamap_load returned non-zero!\n"); + } + + mtx_unlock(&qpair->lock); +}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210180043.q9I0hPhZ001767>