diff mbox

[ovs-dev,v12,5/6] netdev-dpdk: Allow arbitrary eal arguments

Message ID 1461699769-8496-6-git-send-email-aconole@redhat.com
State Superseded
Headers show

Commit Message

Aaron Conole April 26, 2016, 7:42 p.m. UTC
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 <aconole@redhat.com>
Tested-by: Sean K Mooney <sean.k.mooney@intel.com>
Tested-by: RobertX Wojciechowicz <robertx.wojciechowicz@intel.com>
Tested-by: Kevin Traynor <kevin.traynor@intel.com>
Acked-by: Panu Matilainen <pmatilai@redhat.com>
Acked-by: Kevin Traynor <kevin.traynor@intel.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
---
Previous: http://openvswitch.org/pipermail/dev/2016-April/069031.html

v12:
* Squashed NEWS related change into this patch
* Dropped a useless assignment hunk

 INSTALL.DPDK.md      |  5 +++++
 NEWS                 |  3 ++-
 lib/netdev-dpdk.c    | 37 +++++++++++++++++++++++++++++++++++++
 utilities/ovs-dev.py |  7 +++++--
 vswitchd/vswitch.xml | 11 +++++++++++
 5 files changed, 60 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/INSTALL.DPDK.md b/INSTALL.DPDK.md
index 3cc283a..9f907f8 100644
--- a/INSTALL.DPDK.md
+++ b/INSTALL.DPDK.md
@@ -173,6 +173,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/NEWS b/NEWS
index f349819..e819438 100644
--- a/NEWS
+++ b/NEWS
@@ -30,7 +30,8 @@  Post-v2.5.0
      * Sensible defaults have been introduced for many of the required
        configuration options
      * DB entries have been added for many of the DPDK EAL command line
-       arguments
+       arguments. Additional arguments can be passed via the dpdk-extra
+       entry.
    - ovs-benchmark: This utility has been removed due to lack of use and
      bitrot.
    - ovs-appctl:
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index e7951df..d676a3e 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -39,6 +39,7 @@ 
 #include "netdev-provider.h"
 #include "netdev-vport.h"
 #include "odp-util.h"
+#include "openvswitch/dynamic-string.h"
 #include "openvswitch/list.h"
 #include "openvswitch/ofp-print.h"
 #include "openvswitch/vlog.h"
@@ -2774,6 +2775,23 @@  dpdk_option_extend(char ***argv, int argc, const char *option,
 }
 
 static int
+extra_dpdk_args(const char *ovs_extra_config, char ***argv, int argc)
+{
+    int ret = argc;
+    char *release_tok = xstrdup(ovs_extra_config);
+    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;
+        newarg[ret++] = xstrdup(tok);
+    }
+    free(release_tok);
+    return ret;
+}
+
+static int
 construct_dpdk_options(const struct ovsrec_open_vswitch *ovs_cfg,
                        char ***argv, const int initial_size)
 {
@@ -2871,8 +2889,14 @@  static int
 get_dpdk_args(const struct ovsrec_open_vswitch *ovs_cfg, char ***argv,
               int argc)
 {
+    const char *extra_configuration;
     int i = construct_dpdk_options(ovs_cfg, argv, argc);
     i = construct_dpdk_mutex_options(ovs_cfg, argv, i);
+
+    extra_configuration = smap_get(&ovs_cfg->other_config, "dpdk-extra");
+    if (extra_configuration) {
+        i = extra_dpdk_args(extra_configuration, argv, i);
+    }
     return i;
 }
 
@@ -2979,6 +3003,19 @@  dpdk_init__(const struct ovsrec_open_vswitch *ovs_cfg)
 
     optind = 1;
 
+    if (VLOG_IS_INFO_ENABLED()) {
+        struct ds eal_args;
+        int opt;
+        ds_init(&eal_args);
+        ds_put_cstr(&eal_args, "EAL ARGS:");
+        for (opt = 0; opt < argc; ++opt) {
+            ds_put_cstr(&eal_args, " ");
+            ds_put_cstr(&eal_args, argv[opt]);
+        }
+        VLOG_INFO("%s", ds_cstr_ro(&eal_args));
+        ds_destroy(&eal_args);
+    }
+
     /* 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 a74b528..524f574 100755
--- a/utilities/ovs-dev.py
+++ b/utilities/ovs-dev.py
@@ -267,6 +267,8 @@  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, ' '.join(options.dpdk)))
     else:
         _sh("ovs-vsctl --no-wait set Open_vSwitch %s " \
             "other_config:dpdk-init=false" % root_uuid)
@@ -423,8 +425,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 e6d7359..2212aef 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -287,6 +287,17 @@ 
         </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. Changing this value requires restarting the
+          daemon
+        </p>
+      </column>
+
       <column name="other_config" key="cuse-dev-name"
               type='{"type": "string"}'>
         <p>