From patchwork Fri Feb 2 14:51:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kovacevic, Marko" X-Patchwork-Id: 34890 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B62994D3A; Fri, 2 Feb 2018 15:51:53 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id AE0C529D6; Fri, 2 Feb 2018 15:51:51 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Feb 2018 06:51:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,448,1511856000"; d="scan'208";a="14863619" Received: from silpixa00399502.ir.intel.com (HELO silpixa00399502.ger.corp.intel.com) ([10.237.223.218]) by fmsmga007.fm.intel.com with ESMTP; 02 Feb 2018 06:51:48 -0800 From: Marko Kovacevic To: dev@dpdk.org Cc: anatoly.burakov@intel.com, vipin.varghese@intel.com, bruce.richardson@intel.com, stable@dpdk.org, Marko Kovacevic Date: Fri, 2 Feb 2018 14:51:28 +0000 Message-Id: <20180202145128.6331-1-marko.kovacevic@intel.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180201170732.3225-1-marko.kovacevic@intel.com> References: <20180201170732.3225-1-marko.kovacevic@intel.com> Subject: [dpdk-dev] [PATCH v3] eal: add error check for core options X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Error information on current core usage list, mask or map were incomplete. Added states to differentiate core usage and to inform user. Signed-off-by: Marko Kovacevic Reviewed-by: Anatoly Burakov Acked-by: Bruce Richardson --- V3: - Changed to reflect the coding guidelines - Bruce - update the documentation for better clarity - Bruce - Added back the reviewer information - Anatoly V2: - Cleaned up the logging for error cases - Anatoly --- doc/guides/testpmd_app_ug/run_app.rst | 4 ++++ lib/librte_eal/common/eal_common_options.c | 36 +++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index 46da1df..85e725f 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -62,6 +62,10 @@ See the DPDK Getting Started Guides for more information on these options. The grouping ``()`` can be omitted for single element group. The ``@`` can be omitted if cpus and lcores have the same value. +.. Note:: + At a given instance only one core option ``--lcores``, ``-l`` or ``-c`` can be used. + + * ``--master-lcore ID`` Core ID that is used as master. diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index b6d2762..66f0868 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -57,6 +57,9 @@ #include "eal_filesystem.h" #define BITS_PER_HEX 4 +#define LCORE_OPT_LST 1 +#define LCORE_OPT_MSK 2 +#define LCORE_OPT_MAP 3 const char eal_short_options[] = @@ -1028,7 +1031,16 @@ eal_parse_common_option(int opt, const char *optarg, RTE_LOG(ERR, EAL, "invalid coremask\n"); return -1; } - core_parsed = 1; + + if (core_parsed) { + RTE_LOG(ERR, EAL, "Option -c is ignored, because (%s) is set!\n", + (core_parsed == LCORE_OPT_LST) ? "-l" : + (core_parsed == LCORE_OPT_MAP) ? "--lcore" : + "-c"); + return -1; + } + + core_parsed = LCORE_OPT_MSK; break; /* corelist */ case 'l': @@ -1036,7 +1048,16 @@ eal_parse_common_option(int opt, const char *optarg, RTE_LOG(ERR, EAL, "invalid core list\n"); return -1; } - core_parsed = 1; + + if (core_parsed) { + RTE_LOG(ERR, EAL, "Option -l is ignored, because (%s) is set!\n", + (core_parsed == LCORE_OPT_MSK) ? "-c" : + (core_parsed == LCORE_OPT_MAP) ? "--lcore" : + "-l"); + return -1; + } + + core_parsed = LCORE_OPT_LST; break; /* service coremask */ case 's': @@ -1156,7 +1177,16 @@ eal_parse_common_option(int opt, const char *optarg, OPT_LCORES "\n"); return -1; } - core_parsed = 1; + + if (core_parsed) { + RTE_LOG(ERR, EAL, "Option --lcore is ignored, because (%s) is set!\n", + (core_parsed == LCORE_OPT_LST) ? "-l" : + (core_parsed == LCORE_OPT_MSK) ? "-c" : + "--lcore"); + return -1; + } + + core_parsed = LCORE_OPT_MAP; break; /* don't know what to do, leave this to caller */