From: Euan Bourke <euan.bourke@intel.com>
To: dev@dpdk.org
Cc: Euan Bourke <euan.bourke@intel.com>
Subject: [PATCH v4 4/8] eal: update to service core related parsers
Date: Fri, 15 Dec 2023 17:26:28 +0000 [thread overview]
Message-ID: <20231215172632.3102502-5-euan.bourke@intel.com> (raw)
In-Reply-To: <20231215172632.3102502-1-euan.bourke@intel.com>
Updates to the parse service cores functions in EAL to call the arg
parser API instead of implementing its own versions.
Signed-off-by: Euan Bourke <euan.bourke@intel.com>
---
lib/eal/common/eal_common_options.c | 171 +++++++---------------------
1 file changed, 41 insertions(+), 130 deletions(-)
diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index 60ba12a368..d44654f621 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -573,97 +573,49 @@ eal_plugins_init(void)
* the global configuration (core role and core count) with the parsed
* value.
*/
-static int xdigit2val(unsigned char c)
-{
- int val;
-
- if (isdigit(c))
- val = c - '0';
- else if (isupper(c))
- val = c - 'A' + 10;
- else
- val = c - 'a' + 10;
- return val;
-}
-
static int
eal_parse_service_coremask(const char *coremask)
{
struct rte_config *cfg = rte_eal_get_configuration();
- int i, j, idx = 0;
- unsigned int count = 0;
- char c;
- int val;
+ uint16_t cores[RTE_MAX_LCORE];
+ int64_t count;
uint32_t taken_lcore_count = 0;
- if (coremask == NULL)
- return -1;
- /* Remove all blank characters ahead and after .
- * Remove 0x/0X if exists.
- */
- while (isblank(*coremask))
- coremask++;
- if (coremask[0] == '0' && ((coremask[1] == 'x')
- || (coremask[1] == 'X')))
- coremask += 2;
- i = strlen(coremask);
- while ((i > 0) && isblank(coremask[i - 1]))
- i--;
-
- if (i == 0)
+ count = rte_arg_parse_coremask(coremask, cores, RTE_DIM(cores));
+
+ if (count == 0 || count == -1)
return -1;
- for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) {
- c = coremask[i];
- if (isxdigit(c) == 0) {
- /* invalid characters */
+ for (int i = 0; i < count; i++) {
+ uint32_t lcore = cores[i];
+ if (main_lcore_parsed &&
+ cfg->main_lcore == lcore) {
+ RTE_LOG(ERR, EAL,
+ "lcore %u is main lcore, cannot use as service core\n",
+ cores[i]);
return -1;
}
- val = xdigit2val(c);
- for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE;
- j++, idx++) {
- if ((1 << j) & val) {
- /* handle main lcore already parsed */
- uint32_t lcore = idx;
- if (main_lcore_parsed &&
- cfg->main_lcore == lcore) {
- RTE_LOG(ERR, EAL,
- "lcore %u is main lcore, cannot use as service core\n",
- idx);
- return -1;
- }
- if (eal_cpu_detected(idx) == 0) {
- RTE_LOG(ERR, EAL,
- "lcore %u unavailable\n", idx);
- return -1;
- }
-
- if (cfg->lcore_role[idx] == ROLE_RTE)
- taken_lcore_count++;
-
- lcore_config[idx].core_role = ROLE_SERVICE;
- count++;
- }
- }
- }
-
- for (; i >= 0; i--)
- if (coremask[i] != '0')
+ if (eal_cpu_detected(cores[i]) == 0) {
+ RTE_LOG(ERR, EAL,
+ "lcore %u unavailable\n", cores[i]);
return -1;
+ }
- for (; idx < RTE_MAX_LCORE; idx++)
- lcore_config[idx].core_index = -1;
-
- if (count == 0)
- return -1;
+ if (cfg->lcore_role[cores[i]] == ROLE_RTE)
+ taken_lcore_count++;
+ lcore_config[cores[i]].core_role = ROLE_SERVICE;
+ }
if (core_parsed && taken_lcore_count != count) {
RTE_LOG(WARNING, EAL,
- "Not all service cores are in the coremask. "
+ "Not all service cores were in the coremask. "
"Please ensure -c or -l includes service cores\n");
}
+ for (uint16_t j = count*4; j < RTE_MAX_LCORE; j++)
+ lcore_config[j].core_index = -1;
+
cfg->service_lcore_count = count;
return 0;
}
@@ -780,70 +732,29 @@ static int
eal_parse_service_corelist(const char *corelist)
{
struct rte_config *cfg = rte_eal_get_configuration();
- int i;
- unsigned count = 0;
- char *end = NULL;
- uint32_t min, max, idx;
+ int64_t i, count;
+ uint16_t cores[RTE_MAX_LCORE];
uint32_t taken_lcore_count = 0;
- if (corelist == NULL)
- return -1;
+ count = rte_arg_parse_corelist(corelist, cores, RTE_DIM(cores));
- /* Remove all blank characters ahead and after */
- while (isblank(*corelist))
- corelist++;
- i = strlen(corelist);
- while ((i > 0) && isblank(corelist[i - 1]))
- i--;
+ if (count == 0 || count == -1)
+ return -1;
- /* Get list of cores */
- min = RTE_MAX_LCORE;
- do {
- while (isblank(*corelist))
- corelist++;
- if (*corelist == '\0')
- return -1;
- errno = 0;
- idx = strtoul(corelist, &end, 10);
- if (errno || end == NULL)
- return -1;
- if (idx >= RTE_MAX_LCORE)
- return -1;
- while (isblank(*end))
- end++;
- if (*end == '-') {
- min = idx;
- } else if ((*end == ',') || (*end == '\0')) {
- max = idx;
- if (min == RTE_MAX_LCORE)
- min = idx;
- for (idx = min; idx <= max; idx++) {
- if (cfg->lcore_role[idx] != ROLE_SERVICE) {
- /* handle main lcore already parsed */
- uint32_t lcore = idx;
- if (cfg->main_lcore == lcore &&
- main_lcore_parsed) {
- RTE_LOG(ERR, EAL,
- "Error: lcore %u is main lcore, cannot use as service core\n",
- idx);
- return -1;
- }
- if (cfg->lcore_role[idx] == ROLE_RTE)
- taken_lcore_count++;
-
- lcore_config[idx].core_role =
- ROLE_SERVICE;
- count++;
- }
- }
- min = RTE_MAX_LCORE;
- } else
+ for (i = 0; i < count; i++) {
+ uint32_t lcore = cores[i];
+ if (cfg->main_lcore == lcore &&
+ main_lcore_parsed) {
+ RTE_LOG(ERR, EAL,
+ "Error: lcore %u is main lcore, cannot use as service core\n",
+ cores[i]);
return -1;
- corelist = end + 1;
- } while (*end != '\0');
+ }
+ if (cfg->lcore_role[cores[i]] == ROLE_RTE)
+ taken_lcore_count++;
- if (count == 0)
- return -1;
+ lcore_config[cores[i]].core_role = ROLE_SERVICE;
+ }
if (core_parsed && taken_lcore_count != count) {
RTE_LOG(WARNING, EAL,
--
2.34.1
next prev parent reply other threads:[~2023-12-15 17:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <https://inbox.dpdk.org/dev/20231207161818.2590661-1-euan.bourke@intel.com/>
2023-12-15 17:26 ` [PATCH v4 0/8] add new command line argument parsing library Euan Bourke
2023-12-15 17:26 ` [PATCH v4 1/8] arg_parser: new library for command line parsing Euan Bourke
2024-01-24 13:16 ` Morten Brørup
2024-01-24 13:31 ` Bruce Richardson
2023-12-15 17:26 ` [PATCH v4 2/8] arg_parser: add new coremask parsing API Euan Bourke
2023-12-15 17:26 ` [PATCH v4 3/8] eal: add support for new arg parsing library Euan Bourke
2023-12-15 17:26 ` Euan Bourke [this message]
2023-12-15 17:26 ` [PATCH v4 5/8] event/dlb2: add new arg parsing library API support Euan Bourke
2023-12-15 17:26 ` [PATCH v4 6/8] arg_parser: added common core string and heuristic parsers Euan Bourke
2023-12-15 17:26 ` [PATCH v4 7/8] examples/eventdev_pipeline: update to call arg parser API Euan Bourke
2023-12-15 17:26 ` [PATCH v4 8/8] examples/l3fwd-power: " Euan Bourke
2023-12-18 3:14 ` Tummala, Sivaprasad
2024-10-04 16:05 ` Stephen Hemminger
2023-12-15 21:53 ` [PATCH v4 0/8] add new command line argument parsing library Stephen Hemminger
2023-12-18 9:18 ` Bruce Richardson
2024-01-24 13:33 ` Thomas Monjalon
2024-02-14 17:01 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231215172632.3102502-5-euan.bourke@intel.com \
--to=euan.bourke@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).