From patchwork Fri Apr 29 17:44:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Conole X-Patchwork-Id: 616929 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3qxLgn5pT2z9s48 for ; Sat, 30 Apr 2016 03:45:09 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id E46291091D; Fri, 29 Apr 2016 10:44:20 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 182551090C for ; Fri, 29 Apr 2016 10:44:17 -0700 (PDT) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id 996DE1E01C4 for ; Fri, 29 Apr 2016 11:44:16 -0600 (MDT) X-ASG-Debug-ID: 1461951856-09eadd4bd446db0001-byXFYA Received: from mx3-pf1.cudamail.com ([192.168.14.2]) by bar5.cudamail.com with ESMTP id ev4CYl1uRCQzCFZF (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 29 Apr 2016 11:44:16 -0600 (MDT) X-Barracuda-Envelope-From: aconole@redhat.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.2 Received: from unknown (HELO mx1.redhat.com) (209.132.183.28) by mx3-pf1.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 29 Apr 2016 17:44:15 -0000 Received-SPF: pass (mx3-pf1.cudamail.com: SPF record at _spf1.redhat.com designates 209.132.183.28 as permitted sender) X-Barracuda-Apparent-Source-IP: 209.132.183.28 X-Barracuda-RBL-IP: 209.132.183.28 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1CC7C7822C; Fri, 29 Apr 2016 17:44:15 +0000 (UTC) Received: from aconole-fed23.bos.redhat.com (dhcp-25-211.bos.redhat.com [10.18.25.211]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3THi5VX012103; Fri, 29 Apr 2016 13:44:13 -0400 X-CudaMail-Envelope-Sender: aconole@redhat.com From: Aaron Conole To: dev@openvswitch.org, Flavio Leitner , Kevin Traynor , Panu Matilainen , RobertX Wojciechowicz , Sean K Mooney , Andy Zhou , Daniele Di Proietto , Zoltan Kiss , Christian Ehrhardt , Ben Pfaff X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V1-428035298 X-CudaMail-DTE: 042916 X-CudaMail-Originating-IP: 209.132.183.28 Date: Fri, 29 Apr 2016 13:44:05 -0400 X-ASG-Orig-Subj: [##CM-V1-428035298##][PATCH v13 6/6] netdev-dpdk: Check dpdk-extra when reading db Message-Id: <1461951845-11682-7-git-send-email-aconole@redhat.com> In-Reply-To: <1461951845-11682-1-git-send-email-aconole@redhat.com> References: <1461951845-11682-1-git-send-email-aconole@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Barracuda-Connect: UNKNOWN[192.168.14.2] X-Barracuda-Start-Time: 1461951856 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Subject: [ovs-dev] [PATCH v13 6/6] netdev-dpdk: Check dpdk-extra when reading db X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" A previous patch introduced the ability to pass arbitrary EAL command line options via the dpdk_extras database entry. This commit enhances that by warning the user when such a configuration is detected and prefering the value in the database. Suggested-by: Sean K Mooney Signed-off-by: Aaron Conole Tested-by: Sean K Mooney Tested-by: Kevin Traynor Acked-by: Panu Matilainen Acked-by: Flavio Leitner --- v13: * Fix a sparse warning lib/netdev-dpdk.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 57 insertions(+), 11 deletions(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index db41103..b488c60 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -2773,6 +2773,17 @@ dpdk_option_extend(char ***argv, int argc, const char *option, newargv[argc+1] = xstrdup(value); } +static char ** +move_argv(char ***argv, size_t cur_size, char **src_argv, size_t src_argc) +{ + char **newargv = grow_argv(argv, cur_size, src_argc); + while (src_argc--) { + newargv[cur_size+src_argc] = src_argv[src_argc]; + src_argv[src_argc] = NULL; + } + return newargv; +} + static int extra_dpdk_args(const char *ovs_extra_config, char ***argv, int argc) { @@ -2790,9 +2801,21 @@ extra_dpdk_args(const char *ovs_extra_config, char ***argv, int argc) return ret; } +static bool +argv_contains(char **argv_haystack, const size_t argc_haystack, + const char *needle) +{ + for (size_t i = 0; i < argc_haystack; ++i) { + if (!strcmp(argv_haystack[i], needle)) + return true; + } + return false; +} + static int construct_dpdk_options(const struct smap *ovs_other_config, - char ***argv, const int initial_size) + char ***argv, const int initial_size, + char **extra_args, const size_t extra_argc) { struct dpdk_options_map { const char *ovs_configuration; @@ -2815,8 +2838,13 @@ construct_dpdk_options(const struct smap *ovs_other_config, } if (lookup) { - dpdk_option_extend(argv, ret, opts[i].dpdk_option, lookup); - ret += 2; + if (!argv_contains(extra_args, extra_argc, opts[i].dpdk_option)) { + dpdk_option_extend(argv, ret, opts[i].dpdk_option, lookup); + ret += 2; + } else { + VLOG_WARN("Ignoring database defined option '%s' due to " + "dpdk_extras config", opts[i].dpdk_option); + } } } @@ -2827,7 +2855,8 @@ construct_dpdk_options(const struct smap *ovs_other_config, static int construct_dpdk_mutex_options(const struct smap *ovs_other_config, - char ***argv, const int initial_size) + char ***argv, const int initial_size, + char **extra_args, const size_t extra_argc) { struct dpdk_exclusive_options_map { const char *category; @@ -2875,9 +2904,15 @@ construct_dpdk_mutex_options(const struct smap *ovs_other_config, popt->category); } - dpdk_option_extend(argv, ret, popt->eal_dpdk_options[found_pos], - found_value); - ret += 2; + if (!argv_contains(extra_args, extra_argc, + popt->eal_dpdk_options[found_pos])) { + dpdk_option_extend(argv, ret, popt->eal_dpdk_options[found_pos], + found_value); + ret += 2; + } else { + VLOG_WARN("Ignoring database defined option '%s' due to " + "dpdk_extras config", popt->eal_dpdk_options[found_pos]); + } } return ret; @@ -2888,14 +2923,25 @@ get_dpdk_args(const struct smap *ovs_other_config, char ***argv, int argc) { const char *extra_configuration; - int i = construct_dpdk_options(ovs_other_config, argv, argc); - i = construct_dpdk_mutex_options(ovs_other_config, argv, i); + char **extra_args = NULL; + int i; + size_t extra_argc = 0; extra_configuration = smap_get(ovs_other_config, "dpdk-extra"); if (extra_configuration) { - i = extra_dpdk_args(extra_configuration, argv, i); + extra_argc = extra_dpdk_args(extra_configuration, &extra_args, 0); } - return i; + + i = construct_dpdk_options(ovs_other_config, argv, argc, extra_args, + extra_argc); + i = construct_dpdk_mutex_options(ovs_other_config, argv, i, extra_args, + extra_argc); + + if (extra_configuration) { + *argv = move_argv(argv, i, extra_args, extra_argc); + } + + return i + extra_argc; } static char **dpdk_argv;