From fb6c541d374a7437736603ce432240136f102607 Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Wed, 14 Jun 2017 15:31:55 +0800 Subject: [PATCH] app, opts: add a new dpdk configuration: no-pci In this patch, we also update perf and identify examples. If there is no local nvme device info parsing, we will set dpdk initialization with no-pci choice. Change-Id: I58b2d291b7b53894aeb194a16798ff1c72cf25b4 Signed-off-by: Ziye Yang Reviewed-on: https://review.gerrithub.io/365361 Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- examples/nvme/identify/identify.c | 3 +++ examples/nvme/perf/perf.c | 15 +++++++++++++++ include/spdk/env.h | 1 + include/spdk/event.h | 1 + lib/env_dpdk/init.c | 8 ++++++++ lib/event/app.c | 1 + 6 files changed, 29 insertions(+) diff --git a/examples/nvme/identify/identify.c b/examples/nvme/identify/identify.c index 915e94312..2995ba294 100644 --- a/examples/nvme/identify/identify.c +++ b/examples/nvme/identify/identify.c @@ -1077,6 +1077,9 @@ int main(int argc, char **argv) opts.dpdk_mem_channel = 1; opts.dpdk_master_core = g_master_core; opts.core_mask = g_core_mask; + if (g_trid.trtype != SPDK_NVME_TRANSPORT_PCIE) { + opts.no_pci = true; + } spdk_env_init(&opts); rc = 0; diff --git a/examples/nvme/perf/perf.c b/examples/nvme/perf/perf.c index 89cccec6a..defe72bba 100644 --- a/examples/nvme/perf/perf.c +++ b/examples/nvme/perf/perf.c @@ -166,6 +166,7 @@ static uint32_t g_max_completions; static int g_dpdk_mem; static int g_shm_id = -1; static uint32_t g_disable_sq_cmb; +static bool g_no_pci; static const char *g_core_mask; @@ -1090,6 +1091,17 @@ parse_args(int argc, char **argv) if (TAILQ_EMPTY(&g_trid_list)) { /* If no transport IDs specified, default to enumerating all local PCIe devices */ add_trid("trtype:PCIe"); + } else { + struct trid_entry *trid_entry, *trid_entry_tmp; + + g_no_pci = true; + /* check whether there is local PCIe type */ + TAILQ_FOREACH_SAFE(trid_entry, &g_trid_list, tailq, trid_entry_tmp) { + if (trid_entry->trid.trtype == SPDK_NVME_TRANSPORT_PCIE) { + g_no_pci = false; + break; + } + } } g_aio_optind = optind; @@ -1332,6 +1344,9 @@ int main(int argc, char **argv) if (g_dpdk_mem) { opts.dpdk_mem_size = g_dpdk_mem; } + if (g_no_pci) { + opts.no_pci = g_no_pci; + } spdk_env_init(&opts); g_tsc_rate = spdk_get_ticks_hz(); diff --git a/include/spdk/env.h b/include/spdk/env.h index 3261717df..878cb260d 100644 --- a/include/spdk/env.h +++ b/include/spdk/env.h @@ -59,6 +59,7 @@ struct spdk_env_opts { int dpdk_mem_channel; int dpdk_master_core; int dpdk_mem_size; + bool no_pci; }; /** diff --git a/include/spdk/event.h b/include/spdk/event.h index 7073fe311..f33d9fbcf 100644 --- a/include/spdk/event.h +++ b/include/spdk/event.h @@ -81,6 +81,7 @@ struct spdk_app_opts { int dpdk_mem_channel; int dpdk_master_core; int dpdk_mem_size; + bool no_pci; /* The maximum latency allowed when passing an event * from one core to another. A value of 0 diff --git a/lib/env_dpdk/init.c b/lib/env_dpdk/init.c index 160dc5098..20b4a6361 100644 --- a/lib/env_dpdk/init.c +++ b/lib/env_dpdk/init.c @@ -198,6 +198,14 @@ spdk_build_eal_cmdline(const struct spdk_env_opts *opts, char **out[]) } } + /* set no pci if enabled */ + if (opts->no_pci) { + args = spdk_push_arg(args, &argcount, _sprintf_alloc("--no-pci")); + if (args == NULL) { + return -1; + } + } + #ifdef __linux__ if (opts->shm_id < 0) { args = spdk_push_arg(args, &argcount, _sprintf_alloc("--file-prefix=spdk_pid%d", diff --git a/lib/event/app.c b/lib/event/app.c index e29da8f8a..951bf14d5 100644 --- a/lib/event/app.c +++ b/lib/event/app.c @@ -310,6 +310,7 @@ spdk_app_init(struct spdk_app_opts *opts) env_opts.dpdk_mem_channel = opts->dpdk_mem_channel; env_opts.dpdk_master_core = opts->dpdk_master_core; env_opts.dpdk_mem_size = opts->dpdk_mem_size; + env_opts.no_pci = opts->no_pci; spdk_env_init(&env_opts);