Commit d7b7dbfb authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

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: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent b697d280
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+2 −0
Original line number Diff line number Diff line
@@ -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);
+10 −0
Original line number Diff line number Diff line
@@ -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

lib/nvme/nvme_pcie.c

0 → 100644
+41 −0
Original line number Diff line number Diff line
/*-
 *   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 = {
};
+1 −0
Original line number Diff line number Diff line
@@ -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) {
Loading