Commit 4c6e4d49 authored by Daniel Verkamp's avatar Daniel Verkamp Committed by Ben Walker
Browse files

nvmf: move acceptor poller into nvmf_tgt app



The NVMe over Fabrics target library now exposes a simple function call
that polls the acceptor once, and the application handles registration
of the poller.

Also rename the transport function pointers related to the acceptor so
they better reflect their purpose.

Change-Id: I5fa0d516586bf17e73afeb88ff3c2d5b0d46794d
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 47dde075
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -76,6 +76,8 @@ struct spdk_nvmf_probe_ctx {
#define SPDK_NVMF_CONFIG_MAX_IO_SIZE_MIN 4096
#define SPDK_NVMF_CONFIG_MAX_IO_SIZE_MAX 131072

struct spdk_nvmf_tgt_conf g_spdk_nvmf_tgt_conf;

static int
spdk_add_nvmf_discovery_subsystem(void)
{
@@ -146,9 +148,9 @@ spdk_nvmf_parse_nvmf_tgt(void)
	if (acceptor_lcore < 0) {
		acceptor_lcore = rte_lcore_id();
	}
	g_spdk_nvmf_tgt_conf.acceptor_lcore = acceptor_lcore;

	rc = nvmf_tgt_init(max_queue_depth, max_queues_per_sess, in_capsule_data_size, max_io_size,
			   acceptor_lcore);
	rc = nvmf_tgt_init(max_queue_depth, max_queues_per_sess, in_capsule_data_size, max_io_size);
	if (rc != 0) {
		SPDK_ERRLOG("nvmf_tgt_init() failed\n");
		return rc;
+6 −0
Original line number Diff line number Diff line
@@ -34,6 +34,12 @@
#ifndef NVMF_CONF_H
#define NVMF_CONF_H

struct spdk_nvmf_tgt_conf {
	uint32_t acceptor_lcore;
};

extern struct spdk_nvmf_tgt_conf g_spdk_nvmf_tgt_conf;

int
spdk_nvmf_parse_conf(void);

+29 −5
Original line number Diff line number Diff line
@@ -56,15 +56,30 @@ struct rte_mempool *request_mempool;
#define SPDK_NVMF_BUILD_ETC "/usr/local/etc/nvmf"
#define SPDK_NVMF_DEFAULT_CONFIG SPDK_NVMF_BUILD_ETC "/nvmf.conf"

#define ACCEPT_TIMEOUT_US		1000 /* 1ms */

static struct spdk_poller *g_acceptor_poller = NULL;

static void
spdk_nvmf_shutdown_cb(void)
acceptor_poller_unregistered_event(struct spdk_event *event)
{
	spdk_nvmf_acceptor_stop();
	spdk_nvmf_acceptor_fini();

	spdk_app_stop(0);
}

static void
spdk_nvmf_shutdown_cb(void)
{
	struct spdk_event *event;

	fprintf(stdout, "\n=========================\n");
	fprintf(stdout, "   NVMF shutdown signal\n");
	fprintf(stdout, "=========================\n");

	event = spdk_event_allocate(spdk_app_get_current_core(), acceptor_poller_unregistered_event,
				    NULL, NULL, NULL);
	spdk_poller_unregister(&g_acceptor_poller, event);
}

static void
@@ -92,6 +107,12 @@ usage(void)
	printf(" -d         - disable coredump file enabling\n");
}

static void
acceptor_poll(void *arg)
{
	spdk_nvmf_acceptor_poll();
}

static void
spdk_nvmf_startup(spdk_event_t event)
{
@@ -109,14 +130,17 @@ spdk_nvmf_startup(spdk_event_t event)
		goto initialize_error;
	}

	/* start the rdma poller that will listen
	   on all available ports */
	rc = spdk_nvmf_acceptor_start();
	rc = spdk_nvmf_acceptor_init();
	if (rc < 0) {
		SPDK_ERRLOG("spdk_nvmf_acceptor_start() failed\n");
		goto initialize_error;
	}

	spdk_poller_register(&g_acceptor_poller, acceptor_poll, NULL,
			     g_spdk_nvmf_tgt_conf.acceptor_lcore, NULL, ACCEPT_TIMEOUT_US);

	SPDK_NOTICELOG("Acceptor running on core %u\n", g_spdk_nvmf_tgt_conf.acceptor_lcore);

	if (getenv("MEMZONE_DUMP") != NULL) {
		rte_memzone_dump(stdout);
		fflush(stdout);
+1 −4
Original line number Diff line number Diff line
@@ -116,8 +116,7 @@ spdk_nvmf_check_pools(void)

int
nvmf_tgt_init(uint16_t max_queue_depth, uint16_t max_queues_per_sess,
	      uint32_t in_capsule_data_size, uint32_t max_io_size,
	      uint32_t acceptor_lcore)
	      uint32_t in_capsule_data_size, uint32_t max_io_size)
{
	int rc;

@@ -125,13 +124,11 @@ nvmf_tgt_init(uint16_t max_queue_depth, uint16_t max_queues_per_sess,
	g_nvmf_tgt.max_queue_depth = max_queue_depth;
	g_nvmf_tgt.in_capsule_data_size = in_capsule_data_size;
	g_nvmf_tgt.max_io_size = max_io_size;
	g_nvmf_tgt.acceptor_lcore = acceptor_lcore;

	SPDK_TRACELOG(SPDK_TRACE_NVMF, "Max Queues Per Session: %d\n", max_queues_per_sess);
	SPDK_TRACELOG(SPDK_TRACE_NVMF, "Max Queue Depth: %d\n", max_queue_depth);
	SPDK_TRACELOG(SPDK_TRACE_NVMF, "Max In Capsule Data: %d bytes\n", in_capsule_data_size);
	SPDK_TRACELOG(SPDK_TRACE_NVMF, "Max I/O Size: %d bytes\n", max_io_size);
	SPDK_TRACELOG(SPDK_TRACE_NVMF, "NVMf Acceptor lcore: %d \n", acceptor_lcore);

	/* init nvmf specific config options */
	if (!g_nvmf_tgt.sin_port) {
+1 −4
Original line number Diff line number Diff line
@@ -69,14 +69,11 @@ struct spdk_nvmf_globals {
	uint32_t in_capsule_data_size;
	uint32_t max_io_size;

	uint32_t acceptor_lcore;

	uint16_t	   sin_port;
};

int nvmf_tgt_init(uint16_t max_queue_depth, uint16_t max_conn_per_sess,
		  uint32_t in_capsule_data_size, uint32_t max_io_size,
		  uint32_t acceptor_lcore);
		  uint32_t in_capsule_data_size, uint32_t max_io_size);

static inline uint32_t
nvmf_u32log2(uint32_t x)
Loading