[dpdk-dev,v2] eal: add error check for core options
Checks
Commit Message
Error information on the current core
usage list,mask and map were incomplete.
Added states to differentiate core usage
and to inform user.
Signed-off-by: Marko Kovacevic <marko.kovacevic@intel.com>
---
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 | 33 +++++++++++++++++++++++++++---
2 files changed, 34 insertions(+), 3 deletions(-)
Comments
On 01-Feb-18 5:07 PM, Marko Kovacevic wrote:
> Error information on the current core
> usage list,mask and map were incomplete.
> Added states to differentiate core usage
> and to inform user.
>
> Signed-off-by: Marko Kovacevic <marko.kovacevic@intel.com>
>
> ---
Should've kept my Reviewed-by tag, but no harm done.
Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
@@ -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::
+ When ``--lcores`` is in use, the options ``-l`` and ``-c`` cannot be used.
+
+
* ``--master-lcore ID``
Core ID that is used as master.
@@ -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,15 @@ 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" : "Unknown");
+ return -1;
+ }
+
+ core_parsed = LCORE_OPT_MSK;
break;
/* corelist */
case 'l':
@@ -1036,7 +1047,15 @@ 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" : "Unknown");
+ return -1;
+ }
+
+ core_parsed = LCORE_OPT_LST;
break;
/* service coremask */
case 's':
@@ -1156,7 +1175,15 @@ 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" : "Unknown");
+ return -1;
+ }
+
+ core_parsed = LCORE_OPT_MAP;
break;
/* don't know what to do, leave this to caller */