A previous change moved some commonly used arguments from commandline to the database. This change allows arbitrary eal arguments to be provided via a new db entry 'other_config:dpdk-extra' which will tokenize the string and add it to the argument list.
This patch removes 'defaulting' of socket-mem as it will conflict with attempts to pass --no-huge via the eal command line Signed-off-by: Aaron Conole <acon...@redhat.com> Suggested-by: Panu Matilainen <pmati...@redhat.com> --- v4: * Added by suggestion of Panu INSTALL.DPDK.md | 4 ++++ lib/netdev-dpdk.c | 52 ++++++++++++++++++++++++++++++++++++---------------- vswitchd/vswitch.xml | 10 ++++++++++ 3 files changed, 50 insertions(+), 16 deletions(-) diff --git a/INSTALL.DPDK.md b/INSTALL.DPDK.md index 46bd1a8..d0b78f5 100644 --- a/INSTALL.DPDK.md +++ b/INSTALL.DPDK.md @@ -178,6 +178,10 @@ Using the DPDK with ovs-vswitchd: * dpdk-hugepage-dir Directory where hugetlbfs is mounted + * dpdk-extra + Extra arguments to provide to DPDK EAL, as previously specified on the + command line. + * cuse-dev-name Option to set the vhost_cuse character device name. diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 29b3db2..48c20f2 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -2166,13 +2166,34 @@ static char ** grow_argv(char ***argv, size_t cur_siz, size_t grow_by) { char **new_argv = realloc(*argv, sizeof(char *) * (cur_siz + grow_by)); + if (!new_argv) { + ovs_abort(0, "grow_argv() failed to allocate memory."); + } return new_argv; } static int +extra_dpdk_args(const char *ovs_cfg, char ***argv, int argc) +{ + int ret = argc; + char *release_tok = xstrdup(ovs_cfg); + char *tok = release_tok, *endptr = NULL; + + for(tok = strtok_r(release_tok, " ", &endptr); tok != NULL; + tok = strtok_r(NULL, " ", &endptr)) { + char **newarg = grow_argv(argv, ret, 1); + *argv = newarg; + (*argv)[ret++] = xstrdup(tok); + } + free(release_tok); + return ret; +} + +static int get_dpdk_args(const struct ovsrec_open_vswitch *ovs_cfg, char ***argv, int argc) { + const char *extra_configuration; struct dpdk_options_map { const char *ovs_configuration; const char *dpdk_option; @@ -2183,7 +2204,7 @@ get_dpdk_args(const struct ovsrec_open_vswitch *ovs_cfg, char ***argv, /* XXX: DPDK 2.2.0 support, the true should become false for -n */ {"dpdk-mem-channels", "-n", true, "4"}, {"dpdk-alloc-mem", "-m", false, NULL}, - {"dpdk-socket-mem", "--socket-mem", true, "1024,0"}, + {"dpdk-socket-mem", "--socket-mem", false, "1024,0"}, {"dpdk-hugepage-dir", "--huge-dir", false, NULL}, }; int i, ret = argc; @@ -2196,17 +2217,17 @@ get_dpdk_args(const struct ovsrec_open_vswitch *ovs_cfg, char ***argv, if(lookup) { char **newargv = grow_argv(argv, ret, 2); - - if (!newargv) { - ovs_abort(0, "grow_argv() failed to allocate memory."); - } - *argv = newargv; (*argv)[ret++] = xstrdup(opts[i].dpdk_option); (*argv)[ret++] = xstrdup(lookup); } } + extra_configuration = smap_get(&ovs_cfg->other_config, "dpdk-extra"); + if (extra_configuration) { + ret = extra_dpdk_args(extra_configuration, argv, ret); + } + return ret; } @@ -2265,17 +2286,15 @@ __dpdk_init(const struct ovsrec_open_vswitch *ovs_cfg) } argv = grow_argv(&argv, argc, argc+1); - if (!argv) { - ovs_abort(0, "Unable to allocate an initial argv."); - } argv[argc++] = xstrdup("ovs"); /* TODO use prctl to get process name */ argc_tmp = get_dpdk_args(ovs_cfg, &argv, argc); while(argc_tmp != argc) { - if (!strcmp("-c", argv[argc++])) { + if (!strcmp("-c", argv[argc]) || !strcmp("-l", argv[argc])) { auto_determine = false; break; } + argc++; } argc = argc_tmp; @@ -2290,9 +2309,6 @@ __dpdk_init(const struct ovsrec_open_vswitch *ovs_cfg) char buf[MAX_BUFSIZ]; snprintf(buf, MAX_BUFSIZ, "0x%08llX", (1ULL<<i)); argv = grow_argv(&argv, argc, 2); - if (!argv) { - ovs_abort(0, "Unable to grow argv for coremask"); - } argv[argc++] = xstrdup("-c"); argv[argc++] = xstrdup(buf); i = CPU_SETSIZE; @@ -2301,13 +2317,17 @@ __dpdk_init(const struct ovsrec_open_vswitch *ovs_cfg) } argv = grow_argv(&argv, argc, 1); - if (!argv) { - ovs_abort(0, "Unable to make final argv allocation."); - } argv[argc] = 0; optind = 1; + if (VLOG_IS_DBG_ENABLED()) { + int opt; + for(opt = 0; opt < argc; ++opt) { + VLOG_DBG("EAL CMDLINE ARG: %s", argv[opt]); + } + } + /* Make sure things are initialized ... */ result = rte_eal_init(argc, argv); if (result < 0) { diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml index f388dbf..1fc17ac 100644 --- a/vswitchd/vswitch.xml +++ b/vswitchd/vswitch.xml @@ -272,9 +272,6 @@ socket (ex: 1024,2048,4096,8192 would set socket 0 to preallocate 1024MB, socket 1 to preallocate 2048MB, etc.) </p> - <p> - If not specified, the default value is 1024,0. - </p> </column> <column name="other_config" key="dpdk-hugepage-dir" @@ -288,6 +285,16 @@ </p> </column> + <column name="other_config" key="dpdk-extra" + type='{"type": "string"}'> + <p> + Specifies additional eal command line arguments for DPDK. + </p> + <p> + The default is empty. + </p> + </column> + <column name="other_config" key="cuse-dev-name" type='{"type": "string"}'> <p> -- 2.5.0 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev