Commit 18d26e42 authored by Ben Walker's avatar Ben Walker Committed by Daniel Verkamp
Browse files

env: Move DPDK intialization into the env library.



Change-Id: Ie3a324f1523ffa0ddb0bd6a24a9a3cd0acbf64b0
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 25270f1d
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -372,9 +372,8 @@ This is the main file.

\msc

	c_runtime [label="C Runtime"], dpdk [label="DPDK"], nvmf [label="NVMf target"];
	c_runtime [label="C Runtime"], nvmf [label="NVMf target"];
	c_runtime=>nvmf [label="main()"];
	nvmf=> [label="rte_eal_init()"];
	nvmf=>nvmf [label="spdk_app_init()"];
	nvmf=>nvmf [label="spdk_event_allocate()"];
	nvmf=>nvmf [label="spdk_app_start()"];
+5 −15
Original line number Diff line number Diff line
@@ -398,22 +398,12 @@ work_fn(void *arg)
static int
init(void)
{
	char *core_mask_conf;
	struct spdk_env_opts opts;

	core_mask_conf = spdk_sprintf_alloc("-c %s", g_user_config.core_mask);
	if (!core_mask_conf) {
		return 1;
	}

	char *ealargs[] = {"perf", core_mask_conf, "-n 4"};

	if (rte_eal_init(sizeof(ealargs) / sizeof(ealargs[0]), ealargs) < 0) {
		free(core_mask_conf);
		fprintf(stderr, "Could not init eal\n");
		return 1;
	}

	free(core_mask_conf);
	spdk_env_opts_init(&opts);
	opts.name = "perf";
	opts.core_mask = g_user_config.core_mask;
	spdk_env_init(&opts);

	return 0;
}
+5 −14
Original line number Diff line number Diff line
@@ -379,21 +379,12 @@ init_src_buffer(void)
static int
init(void)
{
	char *core_mask_conf;
	struct spdk_env_opts opts;

	core_mask_conf = spdk_sprintf_alloc("-c %s", g_user_config.core_mask);
	if (!core_mask_conf) {
		return 1;
	}

	char *ealargs[] = {"verify", core_mask_conf, "-n 4"};
	if (rte_eal_init(sizeof(ealargs) / sizeof(ealargs[0]), ealargs) < 0) {
		free(core_mask_conf);
		fprintf(stderr, "Could not init eal\n");
		return 1;
	}

	free(core_mask_conf);
	spdk_env_opts_init(&opts);
	opts.name = "verify";
	opts.core_mask = g_user_config.core_mask;
	spdk_env_init(&opts);

	if (init_src_buffer() != 0) {
		fprintf(stderr, "Could not init src buffer\n");
+7 −45
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@ static struct arb_context g_arbitration = {
	.arbitration_config			= 0,
	.io_size_bytes				= 131072,
	.max_completions			= 0,
	/* Default 4 cores for urgent/high/medium/low */
	.core_mask				= "0xf",
	.workload_type				= "randrw",
};
@@ -1080,18 +1081,6 @@ set_arb_feature(struct spdk_nvme_ctrlr *ctrlr)
	return 0;
}


static char *ealargs[] = {
	"arb",
	"-c 0xf", /* This must be the second parameter. It is overwritten by index in main(). */
	"-n 4",
	"--proc-type=auto",
#ifdef __linux__
	"--base-virtaddr=0x1000000000",
	"", /* May be replaced by --file-prefix */
#endif
};

int
main(int argc, char **argv)
{
@@ -1099,45 +1088,18 @@ main(int argc, char **argv)
	struct worker_thread *worker;
	char task_pool_name[30];
	uint32_t task_count;
	size_t argcount;
	char *core_mask = NULL;
	char *file_prefix = NULL;
	struct spdk_env_opts opts;

	rc = parse_args(argc, argv);
	if (rc != 0) {
		return rc;
	}

	/* Default 4 cores for (urgent / high / medium / low) 4 kinds of queues respectively */
	ealargs[1] = core_mask = spdk_sprintf_alloc("-c %s", g_arbitration.core_mask);
	if (ealargs[1] == NULL) {
		perror("ealargs spdk_sprintf_alloc");
		return 1;
	}


	argcount = (sizeof(ealargs) / sizeof(ealargs[0])) - 1;

#ifdef __linux__
	if (g_arbitration.shm_id >= 0) {
		ealargs[5] = file_prefix = spdk_sprintf_alloc("--file-prefix=spdk%d",
					   g_arbitration.shm_id);
		argcount++;
	}
#endif

	rc = rte_eal_init(argcount, ealargs);

	free(core_mask);

	if (file_prefix) {
		free(file_prefix);
	}

	if (rc < 0) {
		fprintf(stderr, "could not initialize dpdk\n");
		return 1;
	}
	spdk_env_opts_init(&opts);
	opts.name = "arb";
	opts.core_mask = g_arbitration.core_mask;
	opts.shm_id = g_arbitration.shm_id;
	spdk_env_init(&opts);

	g_arbitration.tsc_rate = spdk_get_ticks_hz();

+4 −15
Original line number Diff line number Diff line
@@ -37,9 +37,6 @@
#include <assert.h>
#include <pthread.h>

#include "rte_config.h"
#include "rte_eal.h"

#include "spdk/nvme.h"
#include "spdk/env.h"
#include "spdk/string.h"
@@ -175,19 +172,13 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
	}
}

static char *ealargs[] = {
	"fio",
	"-n 4",
	"--proc-type=auto",
};

/* Called once at initialization. This is responsible for gathering the size of
 * each "file", which in our case are in the form
 * "05:00.0/0" (PCI bus:device.function/NVMe NSID) */
static int spdk_fio_setup(struct thread_data *td)
{
	int rc;
	struct spdk_fio_thread *fio_thread;
	struct spdk_env_opts opts;

	fio_thread = calloc(1, sizeof(*fio_thread));
	assert(fio_thread != NULL);
@@ -198,11 +189,9 @@ static int spdk_fio_setup(struct thread_data *td)
	fio_thread->iocq = calloc(td->o.iodepth + 1, sizeof(struct io_u *));
	assert(fio_thread->iocq != NULL);

	rc = rte_eal_init(sizeof(ealargs) / sizeof(ealargs[0]), ealargs);
	if (rc < 0) {
		fprintf(stderr, "could not initialize dpdk\n");
		return 1;
	}
	spdk_env_opts_init(&opts);
	opts.name = "fio";
	spdk_env_init(&opts);

	/* Enumerate all of the controllers */
	if (spdk_nvme_probe(NULL, td, probe_cb, attach_cb, NULL) != 0) {
Loading