2015-09-21 15:52:41 +00:00
|
|
|
/*-
|
|
|
|
* BSD LICENSE
|
|
|
|
*
|
2016-01-26 17:47:22 +00:00
|
|
|
* Copyright (c) Intel Corporation.
|
2015-09-21 15:52:41 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2016-04-29 18:04:33 +00:00
|
|
|
/**
|
|
|
|
* \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.
|
|
|
|
*/
|
|
|
|
|
2015-09-21 15:52:41 +00:00
|
|
|
#ifndef __NVME_IMPL_H__
|
|
|
|
#define __NVME_IMPL_H__
|
|
|
|
|
2016-08-10 17:21:45 +00:00
|
|
|
#include "spdk/env.h"
|
2016-08-10 17:41:12 +00:00
|
|
|
#include "spdk/env.h"
|
2016-01-25 12:34:14 +00:00
|
|
|
#include "spdk/nvme_spec.h"
|
2016-08-10 17:41:12 +00:00
|
|
|
|
2015-09-21 15:52:41 +00:00
|
|
|
#include <assert.h>
|
2016-08-10 23:12:59 +00:00
|
|
|
#include <string.h>
|
2016-04-14 17:59:06 +00:00
|
|
|
#include <unistd.h>
|
2016-08-05 02:59:38 +00:00
|
|
|
#include <stdbool.h>
|
2015-09-21 15:52:41 +00:00
|
|
|
#include <rte_config.h>
|
|
|
|
#include <rte_mempool.h>
|
2016-08-23 21:05:44 +00:00
|
|
|
#include <rte_version.h>
|
2016-08-05 02:59:38 +00:00
|
|
|
#include <rte_eal.h>
|
2015-09-21 15:52:41 +00:00
|
|
|
|
2016-02-09 16:31:09 +00:00
|
|
|
#include "spdk/pci_ids.h"
|
2016-01-29 20:15:29 +00:00
|
|
|
|
2015-09-21 15:52:41 +00:00
|
|
|
/**
|
|
|
|
* \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.
|
2016-08-09 08:17:09 +00:00
|
|
|
* Note: these calls are only made during driver initialization.
|
2015-09-21 15:52:41 +00:00
|
|
|
*/
|
2016-08-10 17:37:12 +00:00
|
|
|
#define nvme_malloc spdk_zmalloc
|
2015-09-21 15:52:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Free a memory buffer previously allocated with nvme_malloc.
|
|
|
|
*/
|
2016-08-10 17:37:12 +00:00
|
|
|
#define nvme_free spdk_free
|
2015-09-21 15:52:41 +00:00
|
|
|
|
2016-08-05 02:59:38 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2016-09-08 21:30:58 +00:00
|
|
|
#define nvme_memzone_reserve spdk_memzone_reserve
|
2016-08-05 02:59:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2016-09-08 21:30:58 +00:00
|
|
|
#define nvme_memzone_lookup spdk_memzone_lookup
|
2016-08-05 02:59:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Free the memory zone identified by the given name.
|
|
|
|
*/
|
2016-09-08 21:30:58 +00:00
|
|
|
#define nvme_memzone_free spdk_memzone_free
|
2016-08-05 02:59:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the calling process is primary process
|
|
|
|
*/
|
2016-09-08 21:30:58 +00:00
|
|
|
#define nvme_process_is_primary spdk_process_is_primary
|
2016-08-05 02:59:38 +00:00
|
|
|
|
2015-09-21 15:52:41 +00:00
|
|
|
/**
|
|
|
|
* Return the physical address for the specified virtual address.
|
|
|
|
*/
|
2016-02-08 21:17:04 +00:00
|
|
|
#define nvme_vtophys(buf) spdk_vtophys(buf)
|
|
|
|
#define NVME_VTOPHYS_ERROR SPDK_VTOPHYS_ERROR
|
2015-09-21 15:52:41 +00:00
|
|
|
|
2016-09-28 14:58:51 +00:00
|
|
|
typedef struct spdk_mempool nvme_mempool_t;
|
2015-09-21 15:52:41 +00:00
|
|
|
|
|
|
|
/**
|
2016-08-09 08:17:09 +00:00
|
|
|
* Create a mempool with the given configuration.
|
|
|
|
* Return a pointer to the allocated memory address. If the allocation
|
|
|
|
* cannot be done, return NULL.
|
2015-09-21 15:52:41 +00:00
|
|
|
*/
|
2016-09-28 14:58:51 +00:00
|
|
|
#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
|
2015-09-21 15:52:41 +00:00
|
|
|
|
2016-02-22 23:01:36 +00:00
|
|
|
/**
|
|
|
|
* Get a monotonic timestamp counter (used for measuring timeouts during initialization).
|
|
|
|
*/
|
2016-08-10 20:12:33 +00:00
|
|
|
#define nvme_get_tsc() spdk_get_ticks()
|
2016-02-22 23:01:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the tick rate of nvme_get_tsc() per second.
|
|
|
|
*/
|
2016-08-10 20:12:33 +00:00
|
|
|
#define nvme_get_tsc_hz() spdk_get_ticks_hz()
|
2016-02-22 23:01:36 +00:00
|
|
|
|
2015-09-21 15:52:41 +00:00
|
|
|
#endif /* __NVME_IMPL_H__ */
|