Loading app/nvmf_tgt/nvmf_tgt.c +2 −14 Original line number Diff line number Diff line Loading @@ -47,7 +47,6 @@ #include "spdk/event.h" #include "spdk/log.h" #include "spdk/nvme.h" #include "spdk/io_channel.h" #define SPDK_NVMF_BUILD_ETC "/usr/local/etc/nvmf" #define SPDK_NVMF_DEFAULT_CONFIG SPDK_NVMF_BUILD_ETC "/nvmf.conf" Loading Loading @@ -177,20 +176,9 @@ _nvmf_tgt_start_subsystem(void *arg1, void *arg2) { struct nvmf_tgt_subsystem *app_subsys = arg1; struct spdk_nvmf_subsystem *subsystem = app_subsys->subsystem; struct spdk_bdev *bdev; struct spdk_io_channel *ch; int lcore = spdk_app_get_current_core(); int i; if (subsystem->subtype == SPDK_NVMF_SUBTYPE_NVME && subsystem->mode == NVMF_SUBSYSTEM_MODE_VIRTUAL) { for (i = 0; i < subsystem->dev.virt.ns_count; i++) { bdev = subsystem->dev.virt.ns_list[i]; ch = spdk_bdev_get_io_channel(bdev, SPDK_IO_PRIORITY_DEFAULT); assert(ch != NULL); subsystem->dev.virt.ch[i] = ch; } } spdk_nvmf_subsystem_start(subsystem); spdk_poller_register(&app_subsys->poller, subsystem_poll, app_subsys, lcore, 0); } Loading include/spdk/nvmf.h +12 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,11 @@ struct spdk_nvmf_host { }; struct spdk_nvmf_ctrlr_ops { /** * Initialize the controller. */ int (*attach)(struct spdk_nvmf_subsystem *subsystem); /** * Set NVMe ctrlr AER. */ Loading Loading @@ -165,6 +170,13 @@ struct spdk_nvmf_subsystem *spdk_nvmf_create_subsystem(const char *nqn, spdk_nvmf_subsystem_connect_fn connect_cb, spdk_nvmf_subsystem_disconnect_fn disconnect_cb); /** * Initialize the subsystem on the thread that will be used to poll it. * * \param subsystem Subsystem that will be polled on this core. */ int spdk_nvmf_subsystem_start(struct spdk_nvmf_subsystem *subsystem); void spdk_nvmf_delete_subsystem(struct spdk_nvmf_subsystem *subsystem); struct spdk_nvmf_subsystem * Loading lib/nvmf/direct.c +7 −0 Original line number Diff line number Diff line Loading @@ -261,6 +261,12 @@ nvmf_direct_ctrlr_complete_aer(void *arg, const struct spdk_nvme_cpl *cpl) } } static int nvmf_direct_ctrlr_attach(struct spdk_nvmf_subsystem *subsystem) { return 0; } static void nvmf_direct_ctrlr_set_aer_callback(struct spdk_nvmf_subsystem *subsys) { Loading @@ -269,6 +275,7 @@ nvmf_direct_ctrlr_set_aer_callback(struct spdk_nvmf_subsystem *subsys) } const struct spdk_nvmf_ctrlr_ops spdk_nvmf_direct_ctrlr_ops = { .attach = nvmf_direct_ctrlr_attach, .set_aer_callback = nvmf_direct_ctrlr_set_aer_callback, .ctrlr_get_data = nvmf_direct_ctrlr_get_data, .process_admin_cmd = nvmf_direct_ctrlr_process_admin_cmd, Loading lib/nvmf/subsystem.c +10 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,16 @@ spdk_nvmf_subsystem_host_allowed(struct spdk_nvmf_subsystem *subsystem, const ch return false; } int spdk_nvmf_subsystem_start(struct spdk_nvmf_subsystem *subsystem) { if (subsystem->subtype == SPDK_NVMF_SUBTYPE_NVME) { return subsystem->ops->attach(subsystem); } return 0; } void spdk_nvmf_subsystem_poll(struct spdk_nvmf_subsystem *subsystem) { Loading lib/nvmf/virtual.c +21 −0 Original line number Diff line number Diff line Loading @@ -520,6 +520,26 @@ nvmf_virtual_ctrlr_process_io_cmd(struct spdk_nvmf_request *req) } } static int nvmf_virtual_ctrlr_attach(struct spdk_nvmf_subsystem *subsystem) { struct spdk_bdev *bdev; struct spdk_io_channel *ch; uint32_t i; for (i = 0; i < subsystem->dev.virt.ns_count; i++) { bdev = subsystem->dev.virt.ns_list[i]; ch = spdk_bdev_get_io_channel(bdev, SPDK_IO_PRIORITY_DEFAULT); if (ch == NULL) { SPDK_ERRLOG("io_channel allocation failed\n"); return -1; } subsystem->dev.virt.ch[i] = ch; } return 0; } static void nvmf_virtual_ctrlr_detach(struct spdk_nvmf_subsystem *subsystem) { Loading @@ -542,6 +562,7 @@ nvmf_virtual_ctrlr_set_aer_callback(struct spdk_nvmf_subsystem *subsys) } const struct spdk_nvmf_ctrlr_ops spdk_nvmf_virtual_ctrlr_ops = { .attach = nvmf_virtual_ctrlr_attach, .set_aer_callback = nvmf_virtual_ctrlr_set_aer_callback, .ctrlr_get_data = nvmf_virtual_ctrlr_get_data, .process_admin_cmd = nvmf_virtual_ctrlr_process_admin_cmd, Loading Loading
app/nvmf_tgt/nvmf_tgt.c +2 −14 Original line number Diff line number Diff line Loading @@ -47,7 +47,6 @@ #include "spdk/event.h" #include "spdk/log.h" #include "spdk/nvme.h" #include "spdk/io_channel.h" #define SPDK_NVMF_BUILD_ETC "/usr/local/etc/nvmf" #define SPDK_NVMF_DEFAULT_CONFIG SPDK_NVMF_BUILD_ETC "/nvmf.conf" Loading Loading @@ -177,20 +176,9 @@ _nvmf_tgt_start_subsystem(void *arg1, void *arg2) { struct nvmf_tgt_subsystem *app_subsys = arg1; struct spdk_nvmf_subsystem *subsystem = app_subsys->subsystem; struct spdk_bdev *bdev; struct spdk_io_channel *ch; int lcore = spdk_app_get_current_core(); int i; if (subsystem->subtype == SPDK_NVMF_SUBTYPE_NVME && subsystem->mode == NVMF_SUBSYSTEM_MODE_VIRTUAL) { for (i = 0; i < subsystem->dev.virt.ns_count; i++) { bdev = subsystem->dev.virt.ns_list[i]; ch = spdk_bdev_get_io_channel(bdev, SPDK_IO_PRIORITY_DEFAULT); assert(ch != NULL); subsystem->dev.virt.ch[i] = ch; } } spdk_nvmf_subsystem_start(subsystem); spdk_poller_register(&app_subsys->poller, subsystem_poll, app_subsys, lcore, 0); } Loading
include/spdk/nvmf.h +12 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,11 @@ struct spdk_nvmf_host { }; struct spdk_nvmf_ctrlr_ops { /** * Initialize the controller. */ int (*attach)(struct spdk_nvmf_subsystem *subsystem); /** * Set NVMe ctrlr AER. */ Loading Loading @@ -165,6 +170,13 @@ struct spdk_nvmf_subsystem *spdk_nvmf_create_subsystem(const char *nqn, spdk_nvmf_subsystem_connect_fn connect_cb, spdk_nvmf_subsystem_disconnect_fn disconnect_cb); /** * Initialize the subsystem on the thread that will be used to poll it. * * \param subsystem Subsystem that will be polled on this core. */ int spdk_nvmf_subsystem_start(struct spdk_nvmf_subsystem *subsystem); void spdk_nvmf_delete_subsystem(struct spdk_nvmf_subsystem *subsystem); struct spdk_nvmf_subsystem * Loading
lib/nvmf/direct.c +7 −0 Original line number Diff line number Diff line Loading @@ -261,6 +261,12 @@ nvmf_direct_ctrlr_complete_aer(void *arg, const struct spdk_nvme_cpl *cpl) } } static int nvmf_direct_ctrlr_attach(struct spdk_nvmf_subsystem *subsystem) { return 0; } static void nvmf_direct_ctrlr_set_aer_callback(struct spdk_nvmf_subsystem *subsys) { Loading @@ -269,6 +275,7 @@ nvmf_direct_ctrlr_set_aer_callback(struct spdk_nvmf_subsystem *subsys) } const struct spdk_nvmf_ctrlr_ops spdk_nvmf_direct_ctrlr_ops = { .attach = nvmf_direct_ctrlr_attach, .set_aer_callback = nvmf_direct_ctrlr_set_aer_callback, .ctrlr_get_data = nvmf_direct_ctrlr_get_data, .process_admin_cmd = nvmf_direct_ctrlr_process_admin_cmd, Loading
lib/nvmf/subsystem.c +10 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,16 @@ spdk_nvmf_subsystem_host_allowed(struct spdk_nvmf_subsystem *subsystem, const ch return false; } int spdk_nvmf_subsystem_start(struct spdk_nvmf_subsystem *subsystem) { if (subsystem->subtype == SPDK_NVMF_SUBTYPE_NVME) { return subsystem->ops->attach(subsystem); } return 0; } void spdk_nvmf_subsystem_poll(struct spdk_nvmf_subsystem *subsystem) { Loading
lib/nvmf/virtual.c +21 −0 Original line number Diff line number Diff line Loading @@ -520,6 +520,26 @@ nvmf_virtual_ctrlr_process_io_cmd(struct spdk_nvmf_request *req) } } static int nvmf_virtual_ctrlr_attach(struct spdk_nvmf_subsystem *subsystem) { struct spdk_bdev *bdev; struct spdk_io_channel *ch; uint32_t i; for (i = 0; i < subsystem->dev.virt.ns_count; i++) { bdev = subsystem->dev.virt.ns_list[i]; ch = spdk_bdev_get_io_channel(bdev, SPDK_IO_PRIORITY_DEFAULT); if (ch == NULL) { SPDK_ERRLOG("io_channel allocation failed\n"); return -1; } subsystem->dev.virt.ch[i] = ch; } return 0; } static void nvmf_virtual_ctrlr_detach(struct spdk_nvmf_subsystem *subsystem) { Loading @@ -542,6 +562,7 @@ nvmf_virtual_ctrlr_set_aer_callback(struct spdk_nvmf_subsystem *subsys) } const struct spdk_nvmf_ctrlr_ops spdk_nvmf_virtual_ctrlr_ops = { .attach = nvmf_virtual_ctrlr_attach, .set_aer_callback = nvmf_virtual_ctrlr_set_aer_callback, .ctrlr_get_data = nvmf_virtual_ctrlr_get_data, .process_admin_cmd = nvmf_virtual_ctrlr_process_admin_cmd, Loading