Date: Fri, 29 Mar 2013 20:34:28 +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: r248913 - head/sys/dev/nvme Message-ID: <201303292034.r2TKYS14028631@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jimharris Date: Fri Mar 29 20:34:28 2013 New Revision: 248913 URL: http://svnweb.freebsd.org/changeset/base/248913 Log: Add "type" to nvme_request, signifying if its payload is a VADDR, UIO, or NULL. This simplifies decisions around if/how requests are routed through busdma. It also paves the way for supporting unmapped bios. Sponsored by: Intel Modified: head/sys/dev/nvme/nvme_ctrlr.c head/sys/dev/nvme/nvme_ctrlr_cmd.c head/sys/dev/nvme/nvme_ns_cmd.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 Fri Mar 29 20:07:51 2013 (r248912) +++ head/sys/dev/nvme/nvme_ctrlr.c Fri Mar 29 20:34:28 2013 (r248913) @@ -701,7 +701,7 @@ nvme_ctrlr_construct_and_submit_aer(stru struct nvme_request *req; aer->ctrlr = ctrlr; - req = nvme_allocate_request(NULL, 0, nvme_ctrlr_async_event_cb, aer); + req = nvme_allocate_request_null(nvme_ctrlr_async_event_cb, aer); aer->req = req; /* Modified: head/sys/dev/nvme/nvme_ctrlr_cmd.c ============================================================================== --- head/sys/dev/nvme/nvme_ctrlr_cmd.c Fri Mar 29 20:07:51 2013 (r248912) +++ head/sys/dev/nvme/nvme_ctrlr_cmd.c Fri Mar 29 20:34:28 2013 (r248913) @@ -36,7 +36,7 @@ nvme_ctrlr_cmd_identify_controller(struc struct nvme_request *req; struct nvme_command *cmd; - req = nvme_allocate_request(payload, + req = nvme_allocate_request_vaddr(payload, sizeof(struct nvme_controller_data), cb_fn, cb_arg); cmd = &req->cmd; @@ -58,7 +58,7 @@ nvme_ctrlr_cmd_identify_namespace(struct struct nvme_request *req; struct nvme_command *cmd; - req = nvme_allocate_request(payload, + req = nvme_allocate_request_vaddr(payload, sizeof(struct nvme_namespace_data), cb_fn, cb_arg); cmd = &req->cmd; @@ -80,7 +80,7 @@ nvme_ctrlr_cmd_create_io_cq(struct nvme_ struct nvme_request *req; struct nvme_command *cmd; - req = nvme_allocate_request(NULL, 0, cb_fn, cb_arg); + req = nvme_allocate_request_null(cb_fn, cb_arg); cmd = &req->cmd; cmd->opc = NVME_OPC_CREATE_IO_CQ; @@ -104,7 +104,7 @@ nvme_ctrlr_cmd_create_io_sq(struct nvme_ struct nvme_request *req; struct nvme_command *cmd; - req = nvme_allocate_request(NULL, 0, cb_fn, cb_arg); + req = nvme_allocate_request_null(cb_fn, cb_arg); cmd = &req->cmd; cmd->opc = NVME_OPC_CREATE_IO_SQ; @@ -128,7 +128,7 @@ nvme_ctrlr_cmd_delete_io_cq(struct nvme_ struct nvme_request *req; struct nvme_command *cmd; - req = nvme_allocate_request(NULL, 0, cb_fn, cb_arg); + req = nvme_allocate_request_null(cb_fn, cb_arg); cmd = &req->cmd; cmd->opc = NVME_OPC_DELETE_IO_CQ; @@ -149,7 +149,7 @@ nvme_ctrlr_cmd_delete_io_sq(struct nvme_ struct nvme_request *req; struct nvme_command *cmd; - req = nvme_allocate_request(NULL, 0, cb_fn, cb_arg); + req = nvme_allocate_request_null(cb_fn, cb_arg); cmd = &req->cmd; cmd->opc = NVME_OPC_DELETE_IO_SQ; @@ -171,7 +171,7 @@ nvme_ctrlr_cmd_set_feature(struct nvme_c struct nvme_request *req; struct nvme_command *cmd; - req = nvme_allocate_request(NULL, 0, cb_fn, cb_arg); + req = nvme_allocate_request_null(cb_fn, cb_arg); cmd = &req->cmd; cmd->opc = NVME_OPC_SET_FEATURES; @@ -189,7 +189,7 @@ nvme_ctrlr_cmd_get_feature(struct nvme_c struct nvme_request *req; struct nvme_command *cmd; - req = nvme_allocate_request(NULL, 0, cb_fn, cb_arg); + req = nvme_allocate_request_null(cb_fn, cb_arg); cmd = &req->cmd; cmd->opc = NVME_OPC_GET_FEATURES; @@ -256,7 +256,7 @@ nvme_ctrlr_cmd_get_log_page(struct nvme_ struct nvme_request *req; struct nvme_command *cmd; - req = nvme_allocate_request(payload, payload_size, cb_fn, cb_arg); + req = nvme_allocate_request_vaddr(payload, payload_size, cb_fn, cb_arg); cmd = &req->cmd; cmd->opc = NVME_OPC_GET_LOG_PAGE; @@ -315,7 +315,7 @@ nvme_ctrlr_cmd_abort(struct nvme_control struct nvme_request *req; struct nvme_command *cmd; - req = nvme_allocate_request(NULL, 0, cb_fn, cb_arg); + req = nvme_allocate_request_null(cb_fn, cb_arg); cmd = &req->cmd; cmd->opc = NVME_OPC_ABORT; Modified: head/sys/dev/nvme/nvme_ns_cmd.c ============================================================================== --- head/sys/dev/nvme/nvme_ns_cmd.c Fri Mar 29 20:07:51 2013 (r248912) +++ head/sys/dev/nvme/nvme_ns_cmd.c Fri Mar 29 20:34:28 2013 (r248913) @@ -36,7 +36,7 @@ nvme_ns_cmd_read(struct nvme_namespace * struct nvme_request *req; struct nvme_command *cmd; - req = nvme_allocate_request(payload, lba_count*512, cb_fn, cb_arg); + req = nvme_allocate_request_vaddr(payload, lba_count*512, cb_fn, cb_arg); if (req == NULL) return (ENOMEM); @@ -60,7 +60,8 @@ nvme_ns_cmd_write(struct nvme_namespace struct nvme_request *req; struct nvme_command *cmd; - req = nvme_allocate_request(payload, lba_count*512, cb_fn, cb_arg); + req = nvme_allocate_request_vaddr(payload, lba_count*512, cb_fn, + cb_arg); if (req == NULL) return (ENOMEM); @@ -85,7 +86,7 @@ nvme_ns_cmd_deallocate(struct nvme_names struct nvme_request *req; struct nvme_command *cmd; - req = nvme_allocate_request(payload, + req = nvme_allocate_request_vaddr(payload, num_ranges * sizeof(struct nvme_dsm_range), cb_fn, cb_arg); if (req == NULL) @@ -110,7 +111,7 @@ nvme_ns_cmd_flush(struct nvme_namespace struct nvme_request *req; struct nvme_command *cmd; - req = nvme_allocate_request(NULL, 0, cb_fn, cb_arg); + req = nvme_allocate_request_null(cb_fn, cb_arg); if (req == NULL) return (ENOMEM); Modified: head/sys/dev/nvme/nvme_private.h ============================================================================== --- head/sys/dev/nvme/nvme_private.h Fri Mar 29 20:07:51 2013 (r248912) +++ head/sys/dev/nvme/nvme_private.h Fri Mar 29 20:34:28 2013 (r248913) @@ -123,14 +123,21 @@ struct nvme_completion_poll_status { boolean_t done; }; +#define NVME_REQUEST_VADDR 1 +#define NVME_REQUEST_NULL 2 /* For requests with no payload. */ +#define NVME_REQUEST_UIO 3 + struct nvme_request { struct nvme_command cmd; struct nvme_qpair *qpair; - void *payload; + union { + void *payload; + struct uio *uio; + } u; + uint32_t type; uint32_t payload_size; boolean_t timeout; - struct uio *uio; nvme_cb_fn_t cb_fn; void *cb_arg; int32_t retries; @@ -482,27 +489,41 @@ _nvme_allocate_request(nvme_cb_fn_t cb_f } static __inline struct nvme_request * -nvme_allocate_request(void *payload, uint32_t payload_size, nvme_cb_fn_t cb_fn, - void *cb_arg) +nvme_allocate_request_vaddr(void *payload, uint32_t payload_size, + nvme_cb_fn_t cb_fn, void *cb_arg) { struct nvme_request *req; req = _nvme_allocate_request(cb_fn, cb_arg); if (req != NULL) { - req->payload = payload; + req->type = NVME_REQUEST_VADDR; + req->u.payload = payload; req->payload_size = payload_size; } return (req); } static __inline struct nvme_request * -nvme_allocate_request_uio(struct uio *uio, nvme_cb_fn_t cb_fn, void *cb_arg) +nvme_allocate_request_null(nvme_cb_fn_t cb_fn, void *cb_arg) { struct nvme_request *req; req = _nvme_allocate_request(cb_fn, cb_arg); if (req != NULL) - req->uio = uio; + req->type = NVME_REQUEST_NULL; + return (req); +} + +static __inline struct nvme_request * +nvme_allocate_request_uio(struct uio *uio, nvme_cb_fn_t cb_fn, void *cb_arg) +{ + struct nvme_request *req; + + req = _nvme_allocate_request(cb_fn, cb_arg); + if (req != NULL) { + req->type = NVME_REQUEST_UIO; + req->u.uio = uio; + } return (req); } Modified: head/sys/dev/nvme/nvme_qpair.c ============================================================================== --- head/sys/dev/nvme/nvme_qpair.c Fri Mar 29 20:07:51 2013 (r248912) +++ head/sys/dev/nvme/nvme_qpair.c Fri Mar 29 20:34:28 2013 (r248913) @@ -336,7 +336,7 @@ nvme_qpair_complete_tracker(struct nvme_ req->retries++; nvme_qpair_submit_tracker(qpair, tr); } else { - if (req->payload_size > 0 || req->uio != NULL) + if (req->type != NVME_REQUEST_NULL) bus_dmamap_unload(qpair->dma_tag, tr->payload_dma_map); @@ -740,22 +740,26 @@ _nvme_qpair_submit_request(struct nvme_q TAILQ_INSERT_TAIL(&qpair->outstanding_tr, tr, tailq); 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_tracker(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); + switch (req->type) { + case NVME_REQUEST_VADDR: + err = bus_dmamap_load(tr->qpair->dma_tag, tr->payload_dma_map, + req->u.payload, req->payload_size, nvme_payload_map, tr, 0); if (err != 0) panic("bus_dmamap_load returned non-zero!\n"); + break; + case NVME_REQUEST_NULL: + nvme_qpair_submit_tracker(tr->qpair, tr); + break; + case NVME_REQUEST_UIO: + err = bus_dmamap_load_uio(tr->qpair->dma_tag, + tr->payload_dma_map, req->u.uio, nvme_payload_map_uio, + tr, 0); + if (err != 0) + panic("bus_dmamap_load_uio returned non-zero!\n"); + break; + default: + panic("unknown nvme request type 0x%x\n", req->type); + break; } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303292034.r2TKYS14028631>