nvme: introduce transport abstraction
This will allow factoring out PCIe-specific code into a swappable transport so that NVMe over Fabrics host support can be added. Change-Id: I4df74dd268d655e3b36e8d6114ebe7d79a24844d Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
b697d2809d
commit
d7b7dbfb78
@ -35,7 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
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_pcie.c nvme_qpair.c nvme.c nvme_intel.c
|
||||
LIBNAME = nvme
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk
|
||||
|
@ -58,6 +58,8 @@ nvme_attach(void *devhandle)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctrlr->transport = &spdk_nvme_transport_pcie;
|
||||
|
||||
status = nvme_ctrlr_construct(ctrlr, devhandle);
|
||||
if (status != 0) {
|
||||
spdk_free(ctrlr);
|
||||
|
@ -241,6 +241,10 @@ struct nvme_request {
|
||||
void *user_buffer;
|
||||
};
|
||||
|
||||
struct spdk_nvme_transport {
|
||||
int reserved;
|
||||
};
|
||||
|
||||
struct nvme_completion_poll_status {
|
||||
struct spdk_nvme_cpl cpl;
|
||||
bool done;
|
||||
@ -284,6 +288,8 @@ struct spdk_nvme_qpair {
|
||||
volatile uint32_t *sq_tdbl;
|
||||
volatile uint32_t *cq_hdbl;
|
||||
|
||||
const struct spdk_nvme_transport *transport;
|
||||
|
||||
/**
|
||||
* Submission queue
|
||||
*/
|
||||
@ -383,6 +389,8 @@ struct spdk_nvme_ctrlr {
|
||||
/** NVMe MMIO register space */
|
||||
volatile struct spdk_nvme_registers *regs;
|
||||
|
||||
const struct spdk_nvme_transport *transport;
|
||||
|
||||
/** I/O queue pairs */
|
||||
struct spdk_nvme_qpair *ioq;
|
||||
|
||||
@ -480,6 +488,8 @@ struct pci_id {
|
||||
|
||||
extern struct nvme_driver *g_spdk_nvme_driver;
|
||||
|
||||
extern const struct spdk_nvme_transport spdk_nvme_transport_pcie;
|
||||
|
||||
#define nvme_min(a,b) (((a)<(b))?(a):(b))
|
||||
|
||||
#define INTEL_DC_P3X00_DEVID 0x09538086
|
||||
|
41
lib/nvme/nvme_pcie.c
Normal file
41
lib/nvme/nvme_pcie.c
Normal file
@ -0,0 +1,41 @@
|
||||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* NVMe over PCIe transport
|
||||
*/
|
||||
|
||||
#include "nvme_internal.h"
|
||||
|
||||
const struct spdk_nvme_transport spdk_nvme_transport_pcie = {
|
||||
};
|
@ -546,6 +546,7 @@ nvme_qpair_construct(struct spdk_nvme_qpair *qpair, uint16_t id,
|
||||
qpair->sq_in_cmb = false;
|
||||
|
||||
qpair->ctrlr = ctrlr;
|
||||
qpair->transport = ctrlr->transport;
|
||||
|
||||
/* cmd and cpl rings must be aligned on 4KB boundaries. */
|
||||
if (ctrlr->opts.use_cmb_sqs) {
|
||||
|
@ -39,6 +39,9 @@
|
||||
|
||||
#include "lib/nvme/unit/test_env.c"
|
||||
|
||||
const struct spdk_nvme_transport spdk_nvme_transport_pcie = {
|
||||
};
|
||||
|
||||
int
|
||||
spdk_pci_enumerate(enum spdk_pci_device_type type,
|
||||
spdk_pci_enum_cb enum_cb,
|
||||
|
@ -39,6 +39,9 @@
|
||||
|
||||
struct nvme_request *g_request = NULL;
|
||||
|
||||
const struct spdk_nvme_transport spdk_nvme_transport_pcie = {
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
spdk_pci_enumerate(enum spdk_pci_device_type type,
|
||||
|
Loading…
Reference in New Issue
Block a user