Commit 889a9c76 authored by Jim Harris's avatar Jim Harris Committed by Daniel Verkamp
Browse files

nvmf: break out config file reading into separate function



This prepares for skipping the config file if it doesn't
exist or there is no Nvmf section.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: Ib96c9c9e8bd462558240a2210150def1a950f1d1

Reviewed-on: https://review.gerrithub.io/385496


Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 33a14041
Loading
Loading
Loading
Loading
+30 −23
Original line number Diff line number Diff line
@@ -130,58 +130,65 @@ spdk_add_nvmf_discovery_subsystem(void)
	return 0;
}

static int
spdk_nvmf_parse_nvmf_tgt(void)
static void
spdk_nvmf_read_config_file_params(struct spdk_conf_section *sp,
				  struct spdk_nvmf_tgt_opts *opts)
{
	struct spdk_conf_section *sp;
	struct spdk_nvmf_tgt_opts opts;
	int max_queue_depth;
	int max_queues_per_sess;
	int in_capsule_data_size;
	int max_io_size;
	int acceptor_lcore;
	int acceptor_poll_rate;
	int rc;

	sp = spdk_conf_find_section(NULL, "Nvmf");
	if (sp == NULL) {
		SPDK_ERRLOG("No Nvmf section in configuration file.\n");
		return -1;
	}

	spdk_nvmf_tgt_opts_init(&opts);

	max_queue_depth = spdk_conf_section_get_intval(sp, "MaxQueueDepth");
	if (max_queue_depth >= 0) {
		opts.max_queue_depth = max_queue_depth;
		opts->max_queue_depth = max_queue_depth;
	}

	max_queues_per_sess = spdk_conf_section_get_intval(sp, "MaxQueuesPerSession");
	if (max_queues_per_sess >= 0) {
		opts.max_qpairs_per_ctrlr = max_queues_per_sess;
		opts->max_qpairs_per_ctrlr = max_queues_per_sess;
	}

	in_capsule_data_size = spdk_conf_section_get_intval(sp, "InCapsuleDataSize");
	if (in_capsule_data_size >= 0) {
		opts.in_capsule_data_size = in_capsule_data_size;
		opts->in_capsule_data_size = in_capsule_data_size;
	}

	max_io_size = spdk_conf_section_get_intval(sp, "MaxIOSize");
	if (max_io_size >= 0) {
		opts.max_io_size = max_io_size;
		opts->max_io_size = max_io_size;
	}

	acceptor_lcore = spdk_conf_section_get_intval(sp, "AcceptorCore");
	if (acceptor_lcore < 0) {
		acceptor_lcore = spdk_env_get_current_core();
	}
	if (acceptor_lcore >= 0) {
		g_spdk_nvmf_tgt_conf.acceptor_lcore = acceptor_lcore;
	}

	acceptor_poll_rate = spdk_conf_section_get_intval(sp, "AcceptorPollRate");
	if (acceptor_poll_rate < 0) {
		acceptor_poll_rate = ACCEPT_TIMEOUT_US;
	}
	if (acceptor_poll_rate >= 0) {
		g_spdk_nvmf_tgt_conf.acceptor_poll_rate = acceptor_poll_rate;
	}
}

static int
spdk_nvmf_parse_nvmf_tgt(void)
{
	struct spdk_conf_section *sp;
	struct spdk_nvmf_tgt_opts opts;
	int rc;

	sp = spdk_conf_find_section(NULL, "Nvmf");
	if (sp == NULL) {
		SPDK_ERRLOG("No Nvmf section in configuration file.\n");
		return -1;
	}

	spdk_nvmf_tgt_opts_init(&opts);
	g_spdk_nvmf_tgt_conf.acceptor_lcore = spdk_env_get_current_core();
	g_spdk_nvmf_tgt_conf.acceptor_poll_rate = ACCEPT_TIMEOUT_US;
	spdk_nvmf_read_config_file_params(sp, &opts);

	g_tgt = spdk_nvmf_tgt_create(&opts);
	if (!g_tgt) {