From c4799f93b1f433fa89bc025d115ebfab7642becc Mon Sep 17 00:00:00 2001 From: jimharris Date: Mon, 1 Apr 2013 16:23:34 +0000 Subject: Add unmapped bio support to nvme(4) and nvd(4). Sponsored by: Intel --- sys/dev/nvme/nvme_private.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'sys/dev/nvme/nvme_private.h') diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h index d9946b6..fe3a110 100644 --- a/sys/dev/nvme/nvme_private.h +++ b/sys/dev/nvme/nvme_private.h @@ -30,6 +30,7 @@ #define __NVME_PRIVATE_H__ #include +#include #include #include #include @@ -114,6 +115,16 @@ MALLOC_DECLARE(M_NVME); #define CACHE_LINE_SIZE (64) #endif +/* + * Use presence of the BIO_UNMAPPED flag to determine whether unmapped I/O + * support and the bus_dmamap_load_bio API are available on the target + * kernel. This will ease porting back to earlier stable branches at a + * later point. + */ +#ifdef BIO_UNMAPPED +#define NVME_UNMAPPED_BIO_SUPPORT +#endif + extern uma_zone_t nvme_request_zone; extern int32_t nvme_retry_count; @@ -126,6 +137,9 @@ struct nvme_completion_poll_status { #define NVME_REQUEST_VADDR 1 #define NVME_REQUEST_NULL 2 /* For requests with no payload. */ #define NVME_REQUEST_UIO 3 +#ifdef NVME_UNMAPPED_BIO_SUPPORT +#define NVME_REQUEST_BIO 4 +#endif struct nvme_request { @@ -134,6 +148,7 @@ struct nvme_request { union { void *payload; struct uio *uio; + struct bio *bio; } u; uint32_t type; uint32_t payload_size; @@ -527,6 +542,25 @@ nvme_allocate_request_uio(struct uio *uio, nvme_cb_fn_t cb_fn, void *cb_arg) return (req); } +static __inline struct nvme_request * +nvme_allocate_request_bio(struct bio *bio, nvme_cb_fn_t cb_fn, void *cb_arg) +{ + struct nvme_request *req; + + req = _nvme_allocate_request(cb_fn, cb_arg); + if (req != NULL) { +#ifdef NVME_UNMAPPED_BIO_SUPPORT + req->type = NVME_REQUEST_BIO; + req->u.bio = bio; +#else + req->type = NVME_REQUEST_VADDR; + req->u.payload = bio->bio_data; + req->payload_size = bio->bio_bcount; +#endif + } + return (req); +} + #define nvme_free_request(req) uma_zfree(nvme_request_zone, req) void nvme_notify_async_consumers(struct nvme_controller *ctrlr, -- cgit v1.1