nvme: Eliminate nvme_impl.h and use the swappable env lib.
Change-Id: Ibbc557b732d5b0858a2922a7a442c4b17a0d579a Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
e0196e8124
commit
bfdc02ab48
4
CONFIG
4
CONFIG
@ -53,10 +53,6 @@ CONFIG_ENV?=$(SPDK_ROOT_DIR)/lib/env
|
|||||||
# when using the default SPDK environment library.
|
# when using the default SPDK environment library.
|
||||||
CONFIG_DPDK_DIR?=/path/to/dpdk
|
CONFIG_DPDK_DIR?=/path/to/dpdk
|
||||||
|
|
||||||
# Header file to use for NVMe implementation specific functions.
|
|
||||||
# Defaults to depending on DPDK.
|
|
||||||
CONFIG_NVME_IMPL?=nvme_impl.h
|
|
||||||
|
|
||||||
# Build SPDK FIO plugin. Requires FIO_SOURCE_DIR set to a valid
|
# Build SPDK FIO plugin. Requires FIO_SOURCE_DIR set to a valid
|
||||||
# fio source code directory.
|
# fio source code directory.
|
||||||
CONFIG_FIO_PLUGIN?=n
|
CONFIG_FIO_PLUGIN?=n
|
||||||
|
@ -758,8 +758,7 @@ WARN_LOGFILE =
|
|||||||
# spaces.
|
# spaces.
|
||||||
# Note: If this tag is empty the current directory is searched.
|
# Note: If this tag is empty the current directory is searched.
|
||||||
|
|
||||||
INPUT = ../lib/nvme/nvme_impl.h \
|
INPUT = ../include/spdk \
|
||||||
../include/spdk \
|
|
||||||
mainpage.txt \
|
mainpage.txt \
|
||||||
ioat/index.txt \
|
ioat/index.txt \
|
||||||
nvme/index.txt \
|
nvme/index.txt \
|
||||||
|
@ -56,7 +56,7 @@ void *
|
|||||||
spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr);
|
spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free a memory buffer previously allocated with spdk_malloc.
|
* Free a memory buffer previously allocated with spdk_zmalloc.
|
||||||
* This call is never made from the performance path.
|
* This call is never made from the performance path.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
|
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
|
||||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||||
|
|
||||||
CFLAGS += $(ENV_CFLAGS) -include $(CONFIG_NVME_IMPL)
|
CFLAGS += $(ENV_CFLAGS)
|
||||||
C_SRCS = nvme_ctrlr_cmd.c nvme_ctrlr.c nvme_ns_cmd.c nvme_ns.c nvme_qpair.c nvme.c nvme_intel.c
|
C_SRCS = nvme_ctrlr_cmd.c nvme_ctrlr.c nvme_ns_cmd.c nvme_ns.c nvme_qpair.c nvme.c nvme_intel.c
|
||||||
LIBNAME = nvme
|
LIBNAME = nvme
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ nvme_attach(void *devhandle)
|
|||||||
int status;
|
int status;
|
||||||
uint64_t phys_addr = 0;
|
uint64_t phys_addr = 0;
|
||||||
|
|
||||||
ctrlr = nvme_malloc(sizeof(struct spdk_nvme_ctrlr),
|
ctrlr = spdk_zmalloc(sizeof(struct spdk_nvme_ctrlr),
|
||||||
64, &phys_addr);
|
64, &phys_addr);
|
||||||
if (ctrlr == NULL) {
|
if (ctrlr == NULL) {
|
||||||
SPDK_ERRLOG("could not allocate ctrlr\n");
|
SPDK_ERRLOG("could not allocate ctrlr\n");
|
||||||
@ -60,7 +60,7 @@ nvme_attach(void *devhandle)
|
|||||||
|
|
||||||
status = nvme_ctrlr_construct(ctrlr, devhandle);
|
status = nvme_ctrlr_construct(ctrlr, devhandle);
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
nvme_free(ctrlr);
|
spdk_free(ctrlr);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ spdk_nvme_detach(struct spdk_nvme_ctrlr *ctrlr)
|
|||||||
|
|
||||||
nvme_ctrlr_destruct(ctrlr);
|
nvme_ctrlr_destruct(ctrlr);
|
||||||
TAILQ_REMOVE(&g_spdk_nvme_driver->attached_ctrlrs, ctrlr, tailq);
|
TAILQ_REMOVE(&g_spdk_nvme_driver->attached_ctrlrs, ctrlr, tailq);
|
||||||
nvme_free(ctrlr);
|
spdk_free(ctrlr);
|
||||||
|
|
||||||
pthread_mutex_unlock(&g_spdk_nvme_driver->lock);
|
pthread_mutex_unlock(&g_spdk_nvme_driver->lock);
|
||||||
return 0;
|
return 0;
|
||||||
@ -100,7 +100,7 @@ nvme_allocate_request(const struct nvme_payload *payload, uint32_t payload_size,
|
|||||||
{
|
{
|
||||||
struct nvme_request *req = NULL;
|
struct nvme_request *req = NULL;
|
||||||
|
|
||||||
req = nvme_mempool_get(g_spdk_nvme_driver->request_mempool);
|
req = spdk_mempool_get(g_spdk_nvme_driver->request_mempool);
|
||||||
if (req == NULL) {
|
if (req == NULL) {
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ nvme_user_copy_cmd_complete(void *arg, const struct spdk_nvme_cpl *cpl)
|
|||||||
memcpy(req->user_buffer, req->payload.u.contig, req->payload_size);
|
memcpy(req->user_buffer, req->payload.u.contig, req->payload_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
nvme_free(req->payload.u.contig);
|
spdk_free(req->payload.u.contig);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call the user's original callback now that the buffer has been copied */
|
/* Call the user's original callback now that the buffer has been copied */
|
||||||
@ -178,7 +178,7 @@ nvme_allocate_request_user_copy(void *buffer, uint32_t payload_size, spdk_nvme_c
|
|||||||
uint64_t phys_addr;
|
uint64_t phys_addr;
|
||||||
|
|
||||||
if (buffer && payload_size) {
|
if (buffer && payload_size) {
|
||||||
contig_buffer = nvme_malloc(payload_size, 4096, &phys_addr);
|
contig_buffer = spdk_zmalloc(payload_size, 4096, &phys_addr);
|
||||||
if (!contig_buffer) {
|
if (!contig_buffer) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -190,7 +190,7 @@ nvme_allocate_request_user_copy(void *buffer, uint32_t payload_size, spdk_nvme_c
|
|||||||
|
|
||||||
req = nvme_allocate_request_contig(contig_buffer, payload_size, nvme_user_copy_cmd_complete, NULL);
|
req = nvme_allocate_request_contig(contig_buffer, payload_size, nvme_user_copy_cmd_complete, NULL);
|
||||||
if (!req) {
|
if (!req) {
|
||||||
nvme_free(buffer);
|
spdk_free(buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ nvme_free_request(struct nvme_request *req)
|
|||||||
assert(req != NULL);
|
assert(req != NULL);
|
||||||
assert(req->num_children == 0);
|
assert(req->num_children == 0);
|
||||||
|
|
||||||
nvme_mempool_put(g_spdk_nvme_driver->request_mempool, req);
|
spdk_mempool_put(g_spdk_nvme_driver->request_mempool, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -279,7 +279,7 @@ spdk_nvme_probe(void *cb_ctx, spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb a
|
|||||||
pthread_mutex_lock(&g_spdk_nvme_driver->lock);
|
pthread_mutex_lock(&g_spdk_nvme_driver->lock);
|
||||||
|
|
||||||
if (g_spdk_nvme_driver->request_mempool == NULL) {
|
if (g_spdk_nvme_driver->request_mempool == NULL) {
|
||||||
g_spdk_nvme_driver->request_mempool = nvme_mempool_create("nvme_request", 8192,
|
g_spdk_nvme_driver->request_mempool = spdk_mempool_create("nvme_request", 8192,
|
||||||
sizeof(struct nvme_request), -1);
|
sizeof(struct nvme_request), -1);
|
||||||
if (g_spdk_nvme_driver->request_mempool == NULL) {
|
if (g_spdk_nvme_driver->request_mempool == NULL) {
|
||||||
SPDK_ERRLOG("Unable to allocate pool of requests\n");
|
SPDK_ERRLOG("Unable to allocate pool of requests\n");
|
||||||
@ -316,7 +316,7 @@ spdk_nvme_probe(void *cb_ctx, spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb a
|
|||||||
/* Controller failed to initialize. */
|
/* Controller failed to initialize. */
|
||||||
TAILQ_REMOVE(&g_spdk_nvme_driver->init_ctrlrs, ctrlr, tailq);
|
TAILQ_REMOVE(&g_spdk_nvme_driver->init_ctrlrs, ctrlr, tailq);
|
||||||
nvme_ctrlr_destruct(ctrlr);
|
nvme_ctrlr_destruct(ctrlr);
|
||||||
nvme_free(ctrlr);
|
spdk_free(ctrlr);
|
||||||
rc = -1;
|
rc = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ static int nvme_ctrlr_set_intel_support_log_pages(struct spdk_nvme_ctrlr *ctrlr)
|
|||||||
struct nvme_completion_poll_status status;
|
struct nvme_completion_poll_status status;
|
||||||
struct spdk_nvme_intel_log_page_directory *log_page_directory;
|
struct spdk_nvme_intel_log_page_directory *log_page_directory;
|
||||||
|
|
||||||
log_page_directory = nvme_malloc(sizeof(struct spdk_nvme_intel_log_page_directory),
|
log_page_directory = spdk_zmalloc(sizeof(struct spdk_nvme_intel_log_page_directory),
|
||||||
64, &phys_addr);
|
64, &phys_addr);
|
||||||
if (log_page_directory == NULL) {
|
if (log_page_directory == NULL) {
|
||||||
SPDK_ERRLOG("could not allocate log_page_directory\n");
|
SPDK_ERRLOG("could not allocate log_page_directory\n");
|
||||||
@ -263,13 +263,13 @@ static int nvme_ctrlr_set_intel_support_log_pages(struct spdk_nvme_ctrlr *ctrlr)
|
|||||||
spdk_nvme_qpair_process_completions(&ctrlr->adminq, 0);
|
spdk_nvme_qpair_process_completions(&ctrlr->adminq, 0);
|
||||||
}
|
}
|
||||||
if (spdk_nvme_cpl_is_error(&status.cpl)) {
|
if (spdk_nvme_cpl_is_error(&status.cpl)) {
|
||||||
nvme_free(log_page_directory);
|
spdk_free(log_page_directory);
|
||||||
SPDK_ERRLOG("nvme_ctrlr_cmd_get_log_page failed!\n");
|
SPDK_ERRLOG("nvme_ctrlr_cmd_get_log_page failed!\n");
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
nvme_ctrlr_construct_intel_support_log_page_list(ctrlr, log_page_directory);
|
nvme_ctrlr_construct_intel_support_log_page_list(ctrlr, log_page_directory);
|
||||||
nvme_free(log_page_directory);
|
spdk_free(log_page_directory);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,7 +374,7 @@ nvme_ctrlr_construct_io_qpairs(struct spdk_nvme_ctrlr *ctrlr)
|
|||||||
*/
|
*/
|
||||||
num_trackers = nvme_min(NVME_IO_TRACKERS, (num_entries - 1));
|
num_trackers = nvme_min(NVME_IO_TRACKERS, (num_entries - 1));
|
||||||
|
|
||||||
ctrlr->ioq = nvme_malloc(ctrlr->opts.num_io_queues * sizeof(struct spdk_nvme_qpair),
|
ctrlr->ioq = spdk_zmalloc(ctrlr->opts.num_io_queues * sizeof(struct spdk_nvme_qpair),
|
||||||
64, &phys_addr);
|
64, &phys_addr);
|
||||||
|
|
||||||
if (ctrlr->ioq == NULL)
|
if (ctrlr->ioq == NULL)
|
||||||
@ -509,7 +509,7 @@ nvme_ctrlr_set_state(struct spdk_nvme_ctrlr *ctrlr, enum nvme_ctrlr_state state,
|
|||||||
if (timeout_in_ms == NVME_TIMEOUT_INFINITE) {
|
if (timeout_in_ms == NVME_TIMEOUT_INFINITE) {
|
||||||
ctrlr->state_timeout_tsc = NVME_TIMEOUT_INFINITE;
|
ctrlr->state_timeout_tsc = NVME_TIMEOUT_INFINITE;
|
||||||
} else {
|
} else {
|
||||||
ctrlr->state_timeout_tsc = nvme_get_tsc() + (timeout_in_ms * nvme_get_tsc_hz()) / 1000;
|
ctrlr->state_timeout_tsc = spdk_get_ticks() + (timeout_in_ms * spdk_get_ticks_hz()) / 1000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,13 +660,13 @@ nvme_ctrlr_destruct_namespaces(struct spdk_nvme_ctrlr *ctrlr)
|
|||||||
nvme_ns_destruct(&ctrlr->ns[i]);
|
nvme_ns_destruct(&ctrlr->ns[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
nvme_free(ctrlr->ns);
|
spdk_free(ctrlr->ns);
|
||||||
ctrlr->ns = NULL;
|
ctrlr->ns = NULL;
|
||||||
ctrlr->num_ns = 0;
|
ctrlr->num_ns = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctrlr->nsdata) {
|
if (ctrlr->nsdata) {
|
||||||
nvme_free(ctrlr->nsdata);
|
spdk_free(ctrlr->nsdata);
|
||||||
ctrlr->nsdata = NULL;
|
ctrlr->nsdata = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -688,13 +688,13 @@ nvme_ctrlr_construct_namespaces(struct spdk_nvme_ctrlr *ctrlr)
|
|||||||
if (nn != ctrlr->num_ns) {
|
if (nn != ctrlr->num_ns) {
|
||||||
nvme_ctrlr_destruct_namespaces(ctrlr);
|
nvme_ctrlr_destruct_namespaces(ctrlr);
|
||||||
|
|
||||||
ctrlr->ns = nvme_malloc(nn * sizeof(struct spdk_nvme_ns), 64,
|
ctrlr->ns = spdk_zmalloc(nn * sizeof(struct spdk_nvme_ns), 64,
|
||||||
&phys_addr);
|
&phys_addr);
|
||||||
if (ctrlr->ns == NULL) {
|
if (ctrlr->ns == NULL) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctrlr->nsdata = nvme_malloc(nn * sizeof(struct spdk_nvme_ns_data), 64,
|
ctrlr->nsdata = spdk_zmalloc(nn * sizeof(struct spdk_nvme_ns_data), 64,
|
||||||
&phys_addr);
|
&phys_addr);
|
||||||
if (ctrlr->nsdata == NULL) {
|
if (ctrlr->nsdata == NULL) {
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -907,7 +907,7 @@ nvme_ctrlr_process_init(struct spdk_nvme_ctrlr *ctrlr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ctrlr->state_timeout_tsc != NVME_TIMEOUT_INFINITE &&
|
if (ctrlr->state_timeout_tsc != NVME_TIMEOUT_INFINITE &&
|
||||||
nvme_get_tsc() > ctrlr->state_timeout_tsc) {
|
spdk_get_ticks() > ctrlr->state_timeout_tsc) {
|
||||||
SPDK_ERRLOG("Initialization timed out in state %d\n", ctrlr->state);
|
SPDK_ERRLOG("Initialization timed out in state %d\n", ctrlr->state);
|
||||||
nvme_ctrlr_fail(ctrlr);
|
nvme_ctrlr_fail(ctrlr);
|
||||||
return -1;
|
return -1;
|
||||||
@ -1163,7 +1163,7 @@ nvme_ctrlr_destruct(struct spdk_nvme_ctrlr *ctrlr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nvme_free(ctrlr->ioq);
|
spdk_free(ctrlr->ioq);
|
||||||
|
|
||||||
nvme_qpair_destroy(&ctrlr->adminq);
|
nvme_qpair_destroy(&ctrlr->adminq);
|
||||||
|
|
||||||
|
@ -1,140 +0,0 @@
|
|||||||
/*-
|
|
||||||
* BSD LICENSE
|
|
||||||
*
|
|
||||||
* Copyright (c) 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:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * 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.
|
|
||||||
* * Neither the name of Intel Corporation nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
|
|
||||||
* OWNER 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file
|
|
||||||
* NVMe driver integration callbacks
|
|
||||||
*
|
|
||||||
* This file describes the callback functions required to integrate
|
|
||||||
* the userspace NVMe driver for a specific implementation. This
|
|
||||||
* implementation is specific for DPDK. Users would
|
|
||||||
* revise it as necessary for their own particular environment if not
|
|
||||||
* using it within the DPDK framework.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __NVME_IMPL_H__
|
|
||||||
#define __NVME_IMPL_H__
|
|
||||||
|
|
||||||
#include "spdk/env.h"
|
|
||||||
#include "spdk/env.h"
|
|
||||||
#include "spdk/nvme_spec.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <rte_config.h>
|
|
||||||
#include <rte_mempool.h>
|
|
||||||
#include <rte_version.h>
|
|
||||||
#include <rte_eal.h>
|
|
||||||
|
|
||||||
#include "spdk/pci_ids.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \page nvme_driver_integration NVMe Driver Integration
|
|
||||||
*
|
|
||||||
* Users can integrate the userspace NVMe driver into their environment
|
|
||||||
* by implementing the callbacks in nvme_impl.h. These callbacks
|
|
||||||
* enable users to specify how to allocate pinned and physically
|
|
||||||
* contiguous memory, performance virtual to physical address
|
|
||||||
* translations, log messages, PCI configuration and register mapping,
|
|
||||||
* and a number of other facilities that may differ depending on the
|
|
||||||
* environment.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allocate a pinned, physically contiguous memory buffer with the
|
|
||||||
* given size and alignment.
|
|
||||||
* Note: these calls are only made during driver initialization.
|
|
||||||
*/
|
|
||||||
#define nvme_malloc spdk_zmalloc
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Free a memory buffer previously allocated with nvme_malloc.
|
|
||||||
*/
|
|
||||||
#define nvme_free spdk_free
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reserve a named, process shared memory zone with the given size,
|
|
||||||
* socket_id and flags.
|
|
||||||
* Return a pointer to the allocated memory address. If the allocation
|
|
||||||
* cannot be done, return NULL.
|
|
||||||
*/
|
|
||||||
#define nvme_memzone_reserve spdk_memzone_reserve
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lookup the memory zone identified by the given name.
|
|
||||||
* Return a pointer to the reserved memory address. If the reservation
|
|
||||||
* cannot be found, return NULL.
|
|
||||||
*/
|
|
||||||
#define nvme_memzone_lookup spdk_memzone_lookup
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Free the memory zone identified by the given name.
|
|
||||||
*/
|
|
||||||
#define nvme_memzone_free spdk_memzone_free
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true if the calling process is primary process
|
|
||||||
*/
|
|
||||||
#define nvme_process_is_primary spdk_process_is_primary
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the physical address for the specified virtual address.
|
|
||||||
*/
|
|
||||||
#define nvme_vtophys(buf) spdk_vtophys(buf)
|
|
||||||
#define NVME_VTOPHYS_ERROR SPDK_VTOPHYS_ERROR
|
|
||||||
|
|
||||||
typedef struct spdk_mempool nvme_mempool_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a mempool with the given configuration.
|
|
||||||
* Return a pointer to the allocated memory address. If the allocation
|
|
||||||
* cannot be done, return NULL.
|
|
||||||
*/
|
|
||||||
#define nvme_mempool_create spdk_mempool_create
|
|
||||||
#define nvme_mempool_free spdk_mempool_free
|
|
||||||
#define nvme_mempool_get spdk_mempool_get
|
|
||||||
#define nvme_mempool_put spdk_mempool_put
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a monotonic timestamp counter (used for measuring timeouts during initialization).
|
|
||||||
*/
|
|
||||||
#define nvme_get_tsc() spdk_get_ticks()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the tick rate of nvme_get_tsc() per second.
|
|
||||||
*/
|
|
||||||
#define nvme_get_tsc_hz() spdk_get_ticks_hz()
|
|
||||||
|
|
||||||
#endif /* __NVME_IMPL_H__ */
|
|
@ -465,7 +465,7 @@ struct nvme_driver {
|
|||||||
pthread_mutex_t lock;
|
pthread_mutex_t lock;
|
||||||
TAILQ_HEAD(, spdk_nvme_ctrlr) init_ctrlrs;
|
TAILQ_HEAD(, spdk_nvme_ctrlr) init_ctrlrs;
|
||||||
TAILQ_HEAD(, spdk_nvme_ctrlr) attached_ctrlrs;
|
TAILQ_HEAD(, spdk_nvme_ctrlr) attached_ctrlrs;
|
||||||
nvme_mempool_t *request_mempool;
|
struct spdk_mempool *request_mempool;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pci_id {
|
struct pci_id {
|
||||||
|
@ -556,7 +556,7 @@ nvme_qpair_construct(struct spdk_nvme_qpair *qpair, uint16_t id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (qpair->sq_in_cmb == false) {
|
if (qpair->sq_in_cmb == false) {
|
||||||
qpair->cmd = nvme_malloc(qpair->num_entries * sizeof(struct spdk_nvme_cmd),
|
qpair->cmd = spdk_zmalloc(qpair->num_entries * sizeof(struct spdk_nvme_cmd),
|
||||||
0x1000,
|
0x1000,
|
||||||
&qpair->cmd_bus_addr);
|
&qpair->cmd_bus_addr);
|
||||||
if (qpair->cmd == NULL) {
|
if (qpair->cmd == NULL) {
|
||||||
@ -565,7 +565,7 @@ nvme_qpair_construct(struct spdk_nvme_qpair *qpair, uint16_t id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qpair->cpl = nvme_malloc(qpair->num_entries * sizeof(struct spdk_nvme_cpl),
|
qpair->cpl = spdk_zmalloc(qpair->num_entries * sizeof(struct spdk_nvme_cpl),
|
||||||
0x1000,
|
0x1000,
|
||||||
&qpair->cpl_bus_addr);
|
&qpair->cpl_bus_addr);
|
||||||
if (qpair->cpl == NULL) {
|
if (qpair->cpl == NULL) {
|
||||||
@ -587,7 +587,7 @@ nvme_qpair_construct(struct spdk_nvme_qpair *qpair, uint16_t id,
|
|||||||
* This ensures the PRP list embedded in the nvme_tracker object will not span a
|
* This ensures the PRP list embedded in the nvme_tracker object will not span a
|
||||||
* 4KB boundary, while allowing access to trackers in tr[] via normal array indexing.
|
* 4KB boundary, while allowing access to trackers in tr[] via normal array indexing.
|
||||||
*/
|
*/
|
||||||
qpair->tr = nvme_malloc(num_trackers * sizeof(*tr), sizeof(*tr), &phys_addr);
|
qpair->tr = spdk_zmalloc(num_trackers * sizeof(*tr), sizeof(*tr), &phys_addr);
|
||||||
if (qpair->tr == NULL) {
|
if (qpair->tr == NULL) {
|
||||||
SPDK_ERRLOG("nvme_tr failed\n");
|
SPDK_ERRLOG("nvme_tr failed\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -640,15 +640,15 @@ nvme_qpair_destroy(struct spdk_nvme_qpair *qpair)
|
|||||||
_nvme_admin_qpair_destroy(qpair);
|
_nvme_admin_qpair_destroy(qpair);
|
||||||
}
|
}
|
||||||
if (qpair->cmd && !qpair->sq_in_cmb) {
|
if (qpair->cmd && !qpair->sq_in_cmb) {
|
||||||
nvme_free(qpair->cmd);
|
spdk_free(qpair->cmd);
|
||||||
qpair->cmd = NULL;
|
qpair->cmd = NULL;
|
||||||
}
|
}
|
||||||
if (qpair->cpl) {
|
if (qpair->cpl) {
|
||||||
nvme_free(qpair->cpl);
|
spdk_free(qpair->cpl);
|
||||||
qpair->cpl = NULL;
|
qpair->cpl = NULL;
|
||||||
}
|
}
|
||||||
if (qpair->tr) {
|
if (qpair->tr) {
|
||||||
nvme_free(qpair->tr);
|
spdk_free(qpair->tr);
|
||||||
qpair->tr = NULL;
|
qpair->tr = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -678,8 +678,8 @@ _nvme_qpair_build_contig_request(struct spdk_nvme_qpair *qpair, struct nvme_requ
|
|||||||
void *md_payload;
|
void *md_payload;
|
||||||
void *payload = req->payload.u.contig + req->payload_offset;
|
void *payload = req->payload.u.contig + req->payload_offset;
|
||||||
|
|
||||||
phys_addr = nvme_vtophys(payload);
|
phys_addr = spdk_vtophys(payload);
|
||||||
if (phys_addr == NVME_VTOPHYS_ERROR) {
|
if (phys_addr == SPDK_VTOPHYS_ERROR) {
|
||||||
_nvme_fail_request_bad_vtophys(qpair, tr);
|
_nvme_fail_request_bad_vtophys(qpair, tr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -692,8 +692,8 @@ _nvme_qpair_build_contig_request(struct spdk_nvme_qpair *qpair, struct nvme_requ
|
|||||||
|
|
||||||
if (req->payload.md) {
|
if (req->payload.md) {
|
||||||
md_payload = req->payload.md + req->md_offset;
|
md_payload = req->payload.md + req->md_offset;
|
||||||
tr->req->cmd.mptr = nvme_vtophys(md_payload);
|
tr->req->cmd.mptr = spdk_vtophys(md_payload);
|
||||||
if (tr->req->cmd.mptr == NVME_VTOPHYS_ERROR) {
|
if (tr->req->cmd.mptr == SPDK_VTOPHYS_ERROR) {
|
||||||
_nvme_fail_request_bad_vtophys(qpair, tr);
|
_nvme_fail_request_bad_vtophys(qpair, tr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -703,14 +703,14 @@ _nvme_qpair_build_contig_request(struct spdk_nvme_qpair *qpair, struct nvme_requ
|
|||||||
tr->req->cmd.dptr.prp.prp1 = phys_addr;
|
tr->req->cmd.dptr.prp.prp1 = phys_addr;
|
||||||
if (nseg == 2) {
|
if (nseg == 2) {
|
||||||
seg_addr = payload + PAGE_SIZE - unaligned;
|
seg_addr = payload + PAGE_SIZE - unaligned;
|
||||||
tr->req->cmd.dptr.prp.prp2 = nvme_vtophys(seg_addr);
|
tr->req->cmd.dptr.prp.prp2 = spdk_vtophys(seg_addr);
|
||||||
} else if (nseg > 2) {
|
} else if (nseg > 2) {
|
||||||
cur_nseg = 1;
|
cur_nseg = 1;
|
||||||
tr->req->cmd.dptr.prp.prp2 = (uint64_t)tr->prp_sgl_bus_addr;
|
tr->req->cmd.dptr.prp.prp2 = (uint64_t)tr->prp_sgl_bus_addr;
|
||||||
while (cur_nseg < nseg) {
|
while (cur_nseg < nseg) {
|
||||||
seg_addr = payload + cur_nseg * PAGE_SIZE - unaligned;
|
seg_addr = payload + cur_nseg * PAGE_SIZE - unaligned;
|
||||||
phys_addr = nvme_vtophys(seg_addr);
|
phys_addr = spdk_vtophys(seg_addr);
|
||||||
if (phys_addr == NVME_VTOPHYS_ERROR) {
|
if (phys_addr == SPDK_VTOPHYS_ERROR) {
|
||||||
_nvme_fail_request_bad_vtophys(qpair, tr);
|
_nvme_fail_request_bad_vtophys(qpair, tr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
|||||||
|
|
||||||
C_SRCS = $(TEST_FILE) $(OTHER_FILES)
|
C_SRCS = $(TEST_FILE) $(OTHER_FILES)
|
||||||
|
|
||||||
CFLAGS += -I$(SPDK_ROOT_DIR)/lib -include $(SPDK_ROOT_DIR)/test/lib/nvme/unit/nvme_impl.h
|
CFLAGS += -I$(SPDK_ROOT_DIR)/lib
|
||||||
CFLAGS += -I$(SPDK_ROOT_DIR)/test
|
CFLAGS += -I$(SPDK_ROOT_DIR)/test
|
||||||
|
|
||||||
SPDK_LIBS += $(SPDK_ROOT_DIR)/lib/log/libspdk_log.a
|
SPDK_LIBS += $(SPDK_ROOT_DIR)/lib/log/libspdk_log.a
|
||||||
|
@ -37,6 +37,8 @@
|
|||||||
|
|
||||||
#include "nvme/nvme.c"
|
#include "nvme/nvme.c"
|
||||||
|
|
||||||
|
#include "lib/nvme/unit/test_env.c"
|
||||||
|
|
||||||
int
|
int
|
||||||
spdk_pci_enumerate(enum spdk_pci_device_type type,
|
spdk_pci_enumerate(enum spdk_pci_device_type type,
|
||||||
spdk_pci_enum_cb enum_cb,
|
spdk_pci_enum_cb enum_cb,
|
||||||
@ -45,11 +47,6 @@ spdk_pci_enumerate(enum spdk_pci_device_type type,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t nvme_vtophys(void *buf)
|
|
||||||
{
|
|
||||||
return (uintptr_t)buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
nvme_ctrlr_construct(struct spdk_nvme_ctrlr *ctrlr, void *devhandle)
|
nvme_ctrlr_construct(struct spdk_nvme_ctrlr *ctrlr, void *devhandle)
|
||||||
{
|
{
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "lib/nvme/unit/test_env.c"
|
||||||
|
|
||||||
bool trace_flag = false;
|
bool trace_flag = false;
|
||||||
#define SPDK_TRACE_NVME trace_flag
|
#define SPDK_TRACE_NVME trace_flag
|
||||||
|
|
||||||
@ -154,7 +156,7 @@ nvme_qpair_submit_request(struct spdk_nvme_qpair *qpair, struct nvme_request *re
|
|||||||
* Free the request here so it does not leak.
|
* Free the request here so it does not leak.
|
||||||
* For the purposes of this unit test, we don't need to bother emulating request submission.
|
* For the purposes of this unit test, we don't need to bother emulating request submission.
|
||||||
*/
|
*/
|
||||||
nvme_mempool_put(_g_nvme_driver.request_mempool, req);
|
spdk_mempool_put(_g_nvme_driver.request_mempool, req);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -321,7 +323,7 @@ nvme_allocate_request(const struct nvme_payload *payload, uint32_t payload_size,
|
|||||||
void *cb_arg)
|
void *cb_arg)
|
||||||
{
|
{
|
||||||
struct nvme_request *req = NULL;
|
struct nvme_request *req = NULL;
|
||||||
req = nvme_mempool_get(_g_nvme_driver.request_mempool);
|
req = spdk_mempool_get(_g_nvme_driver.request_mempool);
|
||||||
|
|
||||||
if (req != NULL) {
|
if (req != NULL) {
|
||||||
memset(req, 0, offsetof(struct nvme_request, children));
|
memset(req, 0, offsetof(struct nvme_request, children));
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
|
|
||||||
#include "nvme/nvme_ns_cmd.c"
|
#include "nvme/nvme_ns_cmd.c"
|
||||||
|
|
||||||
|
#include "lib/nvme/unit/test_env.c"
|
||||||
|
|
||||||
struct nvme_request *g_request = NULL;
|
struct nvme_request *g_request = NULL;
|
||||||
|
|
||||||
|
|
||||||
@ -55,11 +57,6 @@ static int nvme_request_next_sge(void *cb_arg, uint64_t *address, uint32_t *leng
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t nvme_vtophys(void *buf)
|
|
||||||
{
|
|
||||||
return (uintptr_t)buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
nvme_ctrlr_construct(struct spdk_nvme_ctrlr *ctrlr, void *devhandle)
|
nvme_ctrlr_construct(struct spdk_nvme_ctrlr *ctrlr, void *devhandle)
|
||||||
{
|
{
|
||||||
@ -484,7 +481,7 @@ test_nvme_ns_cmd_dataset_management(void)
|
|||||||
CU_ASSERT(g_request->cmd.nsid == ns.id);
|
CU_ASSERT(g_request->cmd.nsid == ns.id);
|
||||||
CU_ASSERT(g_request->cmd.cdw10 == 0);
|
CU_ASSERT(g_request->cmd.cdw10 == 0);
|
||||||
CU_ASSERT(g_request->cmd.cdw11 == SPDK_NVME_DSM_ATTR_DEALLOCATE);
|
CU_ASSERT(g_request->cmd.cdw11 == SPDK_NVME_DSM_ATTR_DEALLOCATE);
|
||||||
nvme_free(g_request->payload.u.contig);
|
spdk_free(g_request->payload.u.contig);
|
||||||
nvme_free_request(g_request);
|
nvme_free_request(g_request);
|
||||||
|
|
||||||
/* TRIM 256 LBAs */
|
/* TRIM 256 LBAs */
|
||||||
@ -496,7 +493,7 @@ test_nvme_ns_cmd_dataset_management(void)
|
|||||||
CU_ASSERT(g_request->cmd.nsid == ns.id);
|
CU_ASSERT(g_request->cmd.nsid == ns.id);
|
||||||
CU_ASSERT(g_request->cmd.cdw10 == 255u);
|
CU_ASSERT(g_request->cmd.cdw10 == 255u);
|
||||||
CU_ASSERT(g_request->cmd.cdw11 == SPDK_NVME_DSM_ATTR_DEALLOCATE);
|
CU_ASSERT(g_request->cmd.cdw11 == SPDK_NVME_DSM_ATTR_DEALLOCATE);
|
||||||
nvme_free(g_request->payload.u.contig);
|
spdk_free(g_request->payload.u.contig);
|
||||||
nvme_free_request(g_request);
|
nvme_free_request(g_request);
|
||||||
|
|
||||||
rc = spdk_nvme_ns_cmd_dataset_management(&ns, &qpair, SPDK_NVME_DSM_ATTR_DEALLOCATE,
|
rc = spdk_nvme_ns_cmd_dataset_management(&ns, &qpair, SPDK_NVME_DSM_ATTR_DEALLOCATE,
|
||||||
@ -635,7 +632,7 @@ test_nvme_ns_cmd_reservation_register(void)
|
|||||||
|
|
||||||
CU_ASSERT(g_request->cmd.cdw10 == tmp_cdw10);
|
CU_ASSERT(g_request->cmd.cdw10 == tmp_cdw10);
|
||||||
|
|
||||||
nvme_free(g_request->payload.u.contig);
|
spdk_free(g_request->payload.u.contig);
|
||||||
nvme_free_request(g_request);
|
nvme_free_request(g_request);
|
||||||
free(payload);
|
free(payload);
|
||||||
}
|
}
|
||||||
@ -672,7 +669,7 @@ test_nvme_ns_cmd_reservation_release(void)
|
|||||||
|
|
||||||
CU_ASSERT(g_request->cmd.cdw10 == tmp_cdw10);
|
CU_ASSERT(g_request->cmd.cdw10 == tmp_cdw10);
|
||||||
|
|
||||||
nvme_free(g_request->payload.u.contig);
|
spdk_free(g_request->payload.u.contig);
|
||||||
nvme_free_request(g_request);
|
nvme_free_request(g_request);
|
||||||
free(payload);
|
free(payload);
|
||||||
}
|
}
|
||||||
@ -709,7 +706,7 @@ test_nvme_ns_cmd_reservation_acquire(void)
|
|||||||
|
|
||||||
CU_ASSERT(g_request->cmd.cdw10 == tmp_cdw10);
|
CU_ASSERT(g_request->cmd.cdw10 == tmp_cdw10);
|
||||||
|
|
||||||
nvme_free(g_request->payload.u.contig);
|
spdk_free(g_request->payload.u.contig);
|
||||||
nvme_free_request(g_request);
|
nvme_free_request(g_request);
|
||||||
free(payload);
|
free(payload);
|
||||||
}
|
}
|
||||||
@ -738,7 +735,7 @@ test_nvme_ns_cmd_reservation_report(void)
|
|||||||
|
|
||||||
CU_ASSERT(g_request->cmd.cdw10 == (0x1000 / 4));
|
CU_ASSERT(g_request->cmd.cdw10 == (0x1000 / 4));
|
||||||
|
|
||||||
nvme_free(g_request->payload.u.contig);
|
spdk_free(g_request->payload.u.contig);
|
||||||
nvme_free_request(g_request);
|
nvme_free_request(g_request);
|
||||||
free(payload);
|
free(payload);
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,8 @@
|
|||||||
|
|
||||||
#include "spdk_cunit.h"
|
#include "spdk_cunit.h"
|
||||||
|
|
||||||
|
#include "lib/nvme/unit/test_env.c"
|
||||||
|
|
||||||
bool trace_flag = false;
|
bool trace_flag = false;
|
||||||
#define SPDK_TRACE_NVME trace_flag
|
#define SPDK_TRACE_NVME trace_flag
|
||||||
|
|
||||||
@ -51,19 +53,10 @@ int32_t spdk_nvme_retry_count = 1;
|
|||||||
|
|
||||||
struct nvme_request *g_request = NULL;
|
struct nvme_request *g_request = NULL;
|
||||||
|
|
||||||
bool fail_vtophys = false;
|
extern bool ut_fail_vtophys;
|
||||||
|
|
||||||
bool fail_next_sge = false;
|
bool fail_next_sge = false;
|
||||||
|
|
||||||
uint64_t nvme_vtophys(void *buf)
|
|
||||||
{
|
|
||||||
if (fail_vtophys) {
|
|
||||||
return (uint64_t) - 1;
|
|
||||||
} else {
|
|
||||||
return (uintptr_t)buf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct io_request {
|
struct io_request {
|
||||||
uint64_t address_offset;
|
uint64_t address_offset;
|
||||||
bool invalid_addr;
|
bool invalid_addr;
|
||||||
@ -132,7 +125,7 @@ nvme_allocate_request(const struct nvme_payload *payload, uint32_t payload_size,
|
|||||||
{
|
{
|
||||||
struct nvme_request *req = NULL;
|
struct nvme_request *req = NULL;
|
||||||
|
|
||||||
req = nvme_mempool_get(_g_nvme_driver.request_mempool);
|
req = spdk_mempool_get(_g_nvme_driver.request_mempool);
|
||||||
|
|
||||||
if (req == NULL) {
|
if (req == NULL) {
|
||||||
return req;
|
return req;
|
||||||
@ -176,7 +169,7 @@ nvme_allocate_request_null(spdk_nvme_cmd_cb cb_fn, void *cb_arg)
|
|||||||
void
|
void
|
||||||
nvme_free_request(struct nvme_request *req)
|
nvme_free_request(struct nvme_request *req)
|
||||||
{
|
{
|
||||||
nvme_mempool_put(_g_nvme_driver.request_mempool, req);
|
spdk_mempool_put(_g_nvme_driver.request_mempool, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -208,7 +201,7 @@ prepare_submit_request_test(struct spdk_nvme_qpair *qpair,
|
|||||||
CU_ASSERT(qpair->sq_tail == 0);
|
CU_ASSERT(qpair->sq_tail == 0);
|
||||||
CU_ASSERT(qpair->cq_head == 0);
|
CU_ASSERT(qpair->cq_head == 0);
|
||||||
|
|
||||||
fail_vtophys = false;
|
ut_fail_vtophys = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -224,7 +217,7 @@ ut_insert_cq_entry(struct spdk_nvme_qpair *qpair, uint32_t slot)
|
|||||||
struct nvme_tracker *tr;
|
struct nvme_tracker *tr;
|
||||||
struct spdk_nvme_cpl *cpl;
|
struct spdk_nvme_cpl *cpl;
|
||||||
|
|
||||||
req = nvme_mempool_get(_g_nvme_driver.request_mempool);
|
req = spdk_mempool_get(_g_nvme_driver.request_mempool);
|
||||||
SPDK_CU_ASSERT_FATAL(req != NULL);
|
SPDK_CU_ASSERT_FATAL(req != NULL);
|
||||||
memset(req, 0, sizeof(*req));
|
memset(req, 0, sizeof(*req));
|
||||||
|
|
||||||
@ -310,7 +303,7 @@ test4(void)
|
|||||||
* the request with error status to signify
|
* the request with error status to signify
|
||||||
* a bad payload buffer.
|
* a bad payload buffer.
|
||||||
*/
|
*/
|
||||||
fail_vtophys = true;
|
ut_fail_vtophys = true;
|
||||||
|
|
||||||
CU_ASSERT(qpair.sq_tail == 0);
|
CU_ASSERT(qpair.sq_tail == 0);
|
||||||
|
|
||||||
|
@ -31,22 +31,15 @@
|
|||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __NVME_IMPL_H__
|
#include <stdbool.h>
|
||||||
#define __NVME_IMPL_H__
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#include "spdk/nvme_spec.h"
|
#include "spdk/env.h"
|
||||||
|
|
||||||
struct spdk_pci_device;
|
void *
|
||||||
|
spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr)
|
||||||
static inline void *
|
|
||||||
nvme_malloc(size_t size, unsigned align, uint64_t *phys_addr)
|
|
||||||
{
|
{
|
||||||
void *buf = NULL;
|
void *buf = NULL;
|
||||||
if (posix_memalign(&buf, align, size)) {
|
if (posix_memalign(&buf, align, size)) {
|
||||||
@ -56,58 +49,56 @@ nvme_malloc(size_t size, unsigned align, uint64_t *phys_addr)
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define nvme_free(buf) free(buf)
|
void spdk_free(void *buf)
|
||||||
#define nvme_get_num_ioq() 8
|
{
|
||||||
#define nvme_get_ioq_idx() 0
|
free(buf);
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t nvme_vtophys(void *buf);
|
bool ut_fail_vtophys = false;
|
||||||
#define NVME_VTOPHYS_ERROR (0xFFFFFFFFFFFFFFFFULL)
|
uint64_t spdk_vtophys(void *buf)
|
||||||
|
{
|
||||||
|
if (ut_fail_vtophys) {
|
||||||
|
return (uint64_t) - 1;
|
||||||
|
} else {
|
||||||
|
return (uintptr_t)buf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extern uint64_t g_ut_tsc;
|
void *
|
||||||
#define nvme_get_tsc() (g_ut_tsc)
|
spdk_memzone_reserve(const char *name, size_t len, int socket_id, unsigned flags)
|
||||||
#define nvme_get_tsc_hz() (1000000)
|
|
||||||
|
|
||||||
static inline void *
|
|
||||||
nvme_memzone_reserve(const char *name, size_t len, int socket_id, unsigned flags)
|
|
||||||
{
|
{
|
||||||
return malloc(len);
|
return malloc(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void *
|
void *
|
||||||
nvme_memzone_lookup(const char *name)
|
spdk_memzone_lookup(const char *name)
|
||||||
{
|
{
|
||||||
assert(0);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
int
|
||||||
nvme_memzone_free(const char *name)
|
spdk_memzone_free(const char *name)
|
||||||
{
|
{
|
||||||
assert(0);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
struct spdk_mempool *
|
||||||
nvme_process_is_primary(void)
|
spdk_mempool_create(const char *name, size_t count,
|
||||||
|
size_t ele_size, size_t cache_size)
|
||||||
{
|
{
|
||||||
return true;
|
static int mp = 0;
|
||||||
|
|
||||||
|
return (struct spdk_mempool *)∓
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NVME_SOCKET_ID_ANY -1
|
void
|
||||||
|
spdk_mempool_free(struct spdk_mempool *mp)
|
||||||
typedef unsigned nvme_mempool_t;
|
|
||||||
|
|
||||||
static inline nvme_mempool_t *
|
|
||||||
nvme_mempool_create(const char *name, size_t n,
|
|
||||||
size_t elt_size, size_t cache_size)
|
|
||||||
{
|
{
|
||||||
static int mp;
|
|
||||||
|
|
||||||
return ∓
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void *
|
void *
|
||||||
nvme_mempool_get(nvme_mempool_t *mp)
|
spdk_mempool_get(struct spdk_mempool *mp)
|
||||||
{
|
{
|
||||||
void *buf;
|
void *buf;
|
||||||
|
|
||||||
@ -118,10 +109,25 @@ nvme_mempool_get(nvme_mempool_t *mp)
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
void
|
||||||
nvme_mempool_put(nvme_mempool_t *mp, void *buf)
|
spdk_mempool_put(struct spdk_mempool *mp, void *ele)
|
||||||
{
|
{
|
||||||
free(buf);
|
free(ele);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __NVME_IMPL_H__ */
|
bool
|
||||||
|
spdk_process_is_primary(void)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t ut_tsc = 0;
|
||||||
|
uint64_t spdk_get_ticks(void)
|
||||||
|
{
|
||||||
|
return ut_tsc;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t spdk_get_ticks_hz(void)
|
||||||
|
{
|
||||||
|
return 1000000;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user