From 117eaa70584b73eebf6f648cf3ee6f2ab03264a0 Mon Sep 17 00:00:00 2001 From: Marko Kovacevic Date: Fri, 2 Feb 2018 14:51:28 +0000 Subject: [PATCH] eal: add error check for core options 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 --- 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 782be3e356..1a03e9c29f 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 08fb6172ec..9f2f8d25af 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -29,6 +29,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[] = @@ -1000,7 +1003,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': @@ -1008,7 +1020,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': @@ -1128,7 +1149,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 */ -- 2.20.1