A previous change moved some commonly used arguments from commandline to
the database, and with it the ability to pass arbitrary arguments to
EAL. 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. The only argument which will not
be supported with this change is '--no-huge', which appears to break the
system in other ways.

Signed-off-by: Aaron Conole <acon...@redhat.com>
Suggested-by: Panu Matilainen <pmati...@redhat.com>
---
v4:
* Added by suggestion of Panu, making socket-mem non-default

v5:
* Keep the socket-mem as default parameter, and mention that we
  do not support --no-huge
* Update ovs-dev.py with the new mechanism for passing arbitrary dpdk
  options

 INSTALL.DPDK.md      |  5 +++++
 lib/netdev-dpdk.c    | 50 +++++++++++++++++++++++++++++++++++---------------
 utilities/ovs-dev.py |  6 ++++--
 vswitchd/vswitch.xml | 10 ++++++++++
 4 files changed, 54 insertions(+), 17 deletions(-)

diff --git a/INSTALL.DPDK.md b/INSTALL.DPDK.md
index 46bd1a8..e2d001a 100644
--- a/INSTALL.DPDK.md
+++ b/INSTALL.DPDK.md
@@ -178,6 +178,11 @@ 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. Do not pass '--no-huge' to the system in this way. Support
+   for running the system without hugepages is nonexistent.
+
    * 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..e8b6b4b 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;
@@ -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/utilities/ovs-dev.py b/utilities/ovs-dev.py
index f2368c2..78e6d0b 100755
--- a/utilities/ovs-dev.py
+++ b/utilities/ovs-dev.py
@@ -266,6 +266,7 @@ def run():
 
     if options.dpdk:
         _sh("ovs-vsctl --no-wait set Open_vSwitch %s 
other_config:dpdk-init=true" % root_uuid)
+        _sh("ovs-vsctl --no-wait set Open_vSwitch %s 
other_config:dpdk-extra=%s" % (root_uuid, options.dpdk))
     else:
         _sh("ovs-vsctl --no-wait set Open_vSwitch %s 
other_config:dpdk-init=false" % root_uuid)
 
@@ -421,8 +422,9 @@ def main():
                      help="run ovs-vswitchd under gdb")
     group.add_option("--valgrind", dest="valgrind", action="store_true",
                      help="run ovs-vswitchd under valgrind")
-    group.add_option("--dpdk", dest="dpdk", action="store_true",
-                     help="run ovs-vswitchd with dpdk")
+    group.add_option("--dpdk", dest="dpdk", action="callback",
+                     callback=parse_subargs,
+                     help="run ovs-vswitchd with dpdk subopts (ended by --)")
     group.add_option("--clang", dest="clang", action="store_true",
                      help="Use binaries built by clang")
     group.add_option("--user", dest="user", action="store", default="",
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index f388dbf..8559fdf 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -288,6 +288,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

Reply via email to