nvmf: Adjust the data structure of spdk_nvmf_subsystem.
Move the ctrlr and io_qpair out of spdk_nvmf_subsystem, package them as a new data structure. Union the direct and virtual mode namespaces. Change-Id: I839aee3372c6c57aa03a0be76f8aaeb5045ecdaf Signed-off-by: Cunyin Chang <cunyin.chang@intel.com>
This commit is contained in:
parent
594c19bf69
commit
8c094266ac
@ -53,6 +53,7 @@ SPDK_LIBS = \
|
|||||||
$(SPDK_ROOT_DIR)/lib/conf/libspdk_conf.a \
|
$(SPDK_ROOT_DIR)/lib/conf/libspdk_conf.a \
|
||||||
$(SPDK_ROOT_DIR)/lib/util/libspdk_util.a \
|
$(SPDK_ROOT_DIR)/lib/util/libspdk_util.a \
|
||||||
$(SPDK_ROOT_DIR)/lib/memory/libspdk_memory.a \
|
$(SPDK_ROOT_DIR)/lib/memory/libspdk_memory.a \
|
||||||
|
$(SPDK_ROOT_DIR)/lib/bdev/libspdk_bdev.a \
|
||||||
|
|
||||||
LIBS += $(SPDK_LIBS) $(PCIACCESS_LIB)
|
LIBS += $(SPDK_LIBS) $(PCIACCESS_LIB)
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ nvmf_process_admin_cmd(struct spdk_nvmf_request *req)
|
|||||||
default:
|
default:
|
||||||
passthrough:
|
passthrough:
|
||||||
SPDK_TRACELOG(SPDK_TRACE_NVMF, "admin_cmd passthrough: opc 0x%02x\n", cmd->opc);
|
SPDK_TRACELOG(SPDK_TRACE_NVMF, "admin_cmd passthrough: opc 0x%02x\n", cmd->opc);
|
||||||
rc = spdk_nvme_ctrlr_cmd_admin_raw(subsystem->ctrlr,
|
rc = spdk_nvme_ctrlr_cmd_admin_raw(subsystem->ctrlr.direct.ctrlr,
|
||||||
cmd,
|
cmd,
|
||||||
req->data, req->length,
|
req->data, req->length,
|
||||||
nvmf_complete_cmd,
|
nvmf_complete_cmd,
|
||||||
@ -249,6 +249,7 @@ passthrough:
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@ -257,7 +258,7 @@ nvmf_process_io_cmd(struct spdk_nvmf_request *req)
|
|||||||
struct spdk_nvmf_subsystem *subsystem = req->conn->sess->subsys;
|
struct spdk_nvmf_subsystem *subsystem = req->conn->sess->subsys;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = spdk_nvme_ctrlr_cmd_io_raw(subsystem->ctrlr, subsystem->io_qpair,
|
rc = spdk_nvme_ctrlr_cmd_io_raw(subsystem->ctrlr.direct.ctrlr, subsystem->ctrlr.direct.io_qpair,
|
||||||
&req->cmd->nvme_cmd,
|
&req->cmd->nvme_cmd,
|
||||||
req->data, req->length,
|
req->data, req->length,
|
||||||
nvmf_complete_cmd,
|
nvmf_complete_cmd,
|
||||||
|
@ -90,7 +90,7 @@ nvmf_init_nvme_session_properties(struct nvmf_session *session)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Init the virtual controller details using actual HW details */
|
/* Init the virtual controller details using actual HW details */
|
||||||
cdata = spdk_nvme_ctrlr_get_data(session->subsys->ctrlr);
|
cdata = spdk_nvme_ctrlr_get_data(session->subsys->ctrlr.direct.ctrlr);
|
||||||
memcpy(&session->vcdata, cdata, sizeof(struct spdk_nvme_ctrlr_data));
|
memcpy(&session->vcdata, cdata, sizeof(struct spdk_nvme_ctrlr_data));
|
||||||
|
|
||||||
session->vcdata.aerl = 0;
|
session->vcdata.aerl = 0;
|
||||||
|
@ -85,8 +85,8 @@ spdk_nvmf_subsystem_poller(void *arg)
|
|||||||
|
|
||||||
/* For NVMe subsystems, check the backing physical device for completions. */
|
/* For NVMe subsystems, check the backing physical device for completions. */
|
||||||
if (subsystem->subtype == SPDK_NVMF_SUBTYPE_NVME) {
|
if (subsystem->subtype == SPDK_NVMF_SUBTYPE_NVME) {
|
||||||
spdk_nvme_ctrlr_process_admin_completions(subsystem->ctrlr);
|
spdk_nvme_ctrlr_process_admin_completions(subsystem->ctrlr.direct.ctrlr);
|
||||||
spdk_nvme_qpair_process_completions(subsystem->io_qpair, 0);
|
spdk_nvme_qpair_process_completions(subsystem->ctrlr.direct.io_qpair, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For each connection in the session, check for RDMA completions */
|
/* For each connection in the session, check for RDMA completions */
|
||||||
@ -153,8 +153,8 @@ nvmf_delete_subsystem(struct spdk_nvmf_subsystem *subsystem)
|
|||||||
spdk_nvmf_session_destruct(subsystem->session);
|
spdk_nvmf_session_destruct(subsystem->session);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subsystem->ctrlr) {
|
if (subsystem->ctrlr.direct.ctrlr) {
|
||||||
spdk_nvme_detach(subsystem->ctrlr);
|
spdk_nvme_detach(subsystem->ctrlr.direct.ctrlr);
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_REMOVE(&g_subsystems, subsystem, entries);
|
TAILQ_REMOVE(&g_subsystems, subsystem, entries);
|
||||||
@ -199,11 +199,10 @@ int
|
|||||||
nvmf_subsystem_add_ctrlr(struct spdk_nvmf_subsystem *subsystem,
|
nvmf_subsystem_add_ctrlr(struct spdk_nvmf_subsystem *subsystem,
|
||||||
struct spdk_nvme_ctrlr *ctrlr)
|
struct spdk_nvme_ctrlr *ctrlr)
|
||||||
{
|
{
|
||||||
subsystem->ctrlr = ctrlr;
|
subsystem->ctrlr.direct.ctrlr = ctrlr;
|
||||||
|
|
||||||
/* Assume that all I/O will be handled on one thread for now */
|
/* Assume that all I/O will be handled on one thread for now */
|
||||||
subsystem->io_qpair = spdk_nvme_ctrlr_alloc_io_qpair(ctrlr, 0);
|
subsystem->ctrlr.direct.io_qpair = spdk_nvme_ctrlr_alloc_io_qpair(ctrlr, 0);
|
||||||
if (subsystem->io_qpair == NULL) {
|
if (subsystem->ctrlr.direct.io_qpair == NULL) {
|
||||||
SPDK_ERRLOG("spdk_nvme_ctrlr_alloc_io_qpair() failed\n");
|
SPDK_ERRLOG("spdk_nvme_ctrlr_alloc_io_qpair() failed\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -39,10 +39,13 @@
|
|||||||
#include "spdk/event.h"
|
#include "spdk/event.h"
|
||||||
#include "spdk/nvme.h"
|
#include "spdk/nvme.h"
|
||||||
#include "spdk/queue.h"
|
#include "spdk/queue.h"
|
||||||
|
#include "spdk/bdev.h"
|
||||||
|
|
||||||
struct spdk_nvmf_conn;
|
struct spdk_nvmf_conn;
|
||||||
|
struct spdk_nvmf_subsystem;
|
||||||
|
|
||||||
#define MAX_NQN_SIZE 255
|
#define MAX_NQN_SIZE 255
|
||||||
|
#define MAX_VIRTUAL_NAMESPACE 16
|
||||||
|
|
||||||
enum spdk_nvmf_subsystem_mode {
|
enum spdk_nvmf_subsystem_mode {
|
||||||
NVMF_SUBSYSTEM_MODE_DIRECT = 0,
|
NVMF_SUBSYSTEM_MODE_DIRECT = 0,
|
||||||
@ -61,6 +64,27 @@ struct spdk_nvmf_host {
|
|||||||
TAILQ_ENTRY(spdk_nvmf_host) link;
|
TAILQ_ENTRY(spdk_nvmf_host) link;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct spdk_nvmf_ns {
|
||||||
|
uint32_t nsid;
|
||||||
|
struct spdk_bdev *bdev;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
union spdk_nvmf_controller {
|
||||||
|
struct {
|
||||||
|
struct nvmf_session *session;
|
||||||
|
struct spdk_nvme_ctrlr *ctrlr;
|
||||||
|
struct spdk_nvme_qpair *io_qpair;
|
||||||
|
} direct;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
struct nvmf_session *session;
|
||||||
|
struct spdk_nvmf_ns *ns_list[MAX_VIRTUAL_NAMESPACE];
|
||||||
|
uint16_t ns_count;
|
||||||
|
} virtual;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The NVMf subsystem, as indicated in the specification, is a collection
|
* The NVMf subsystem, as indicated in the specification, is a collection
|
||||||
* of virtual controller sessions. Any individual controller session has
|
* of virtual controller sessions. Any individual controller session has
|
||||||
@ -72,8 +96,7 @@ struct spdk_nvmf_subsystem {
|
|||||||
enum spdk_nvmf_subsystem_mode mode;
|
enum spdk_nvmf_subsystem_mode mode;
|
||||||
enum spdk_nvmf_subtype subtype;
|
enum spdk_nvmf_subtype subtype;
|
||||||
struct nvmf_session *session;
|
struct nvmf_session *session;
|
||||||
struct spdk_nvme_ctrlr *ctrlr;
|
union spdk_nvmf_controller ctrlr;
|
||||||
struct spdk_nvme_qpair *io_qpair;
|
|
||||||
|
|
||||||
struct spdk_poller poller;
|
struct spdk_poller poller;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user