From: Euan Bourke <euan.bourke@intel.com>
To: dev@dpdk.org
Cc: Euan Bourke <euan.bourke@intel.com>,
Harry van Haaren <harry.van.haaren@intel.com>
Subject: [PATCH v3 7/8] examples/eventdev_pipeline: update to call arg parser API
Date: Thu, 7 Dec 2023 16:18:17 +0000 [thread overview]
Message-ID: <20231207161818.2590661-8-euan.bourke@intel.com> (raw)
In-Reply-To: <20231207161818.2590661-1-euan.bourke@intel.com>
Update to the eventdev_pipeline example application to call the arg parser
library for its 'combined core string parser' instead of implementing its
own coremask parser. The default_type passed into the function call is
a coremask.
Signed-off-by: Euan Bourke <euan.bourke@intel.com>
---
examples/eventdev_pipeline/main.c | 65 +++-----------------
examples/eventdev_pipeline/pipeline_common.h | 1 +
2 files changed, 10 insertions(+), 56 deletions(-)
diff --git a/examples/eventdev_pipeline/main.c b/examples/eventdev_pipeline/main.c
index 0c995d1a70..c59d01e7a5 100644
--- a/examples/eventdev_pipeline/main.c
+++ b/examples/eventdev_pipeline/main.c
@@ -56,69 +56,22 @@ core_in_use(unsigned int lcore_id) {
fdata->tx_core[lcore_id] || fdata->worker_core[lcore_id]);
}
-/*
- * Parse the coremask given as argument (hexadecimal string) and fill
- * 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 uint64_t
parse_coremask(const char *coremask)
{
- int i, j, idx = 0;
- unsigned int count = 0;
- char c;
- int val;
+ int count;
+ uint16_t i;
uint64_t mask = 0;
- const int32_t BITS_HEX = 4;
+ uint16_t cores[RTE_MAX_LCORE];
- 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)
- return -1;
+ count = rte_arg_parse_core_string(coremask, cores, RTE_DIM(cores), 0);
- for (i = i - 1; i >= 0 && idx < MAX_NUM_CORE; i--) {
- c = coremask[i];
- if (isxdigit(c) == 0) {
- /* invalid characters */
- return -1;
- }
- val = xdigit2val(c);
- for (j = 0; j < BITS_HEX && idx < MAX_NUM_CORE; j++, idx++) {
- if ((1 << j) & val) {
- mask |= (1ULL << idx);
- count++;
- }
- }
- }
- for (; i >= 0; i--)
- if (coremask[i] != '0')
- return -1;
- if (count == 0)
+ if (count == 0 || count == -1)
return -1;
+
+ for (i = 0; i < count; i++)
+ mask |= 1ULL << cores[i];
+
return mask;
}
diff --git a/examples/eventdev_pipeline/pipeline_common.h b/examples/eventdev_pipeline/pipeline_common.h
index 28b6ab85ff..2b97a29bfc 100644
--- a/examples/eventdev_pipeline/pipeline_common.h
+++ b/examples/eventdev_pipeline/pipeline_common.h
@@ -6,6 +6,7 @@
#include <stdbool.h>
+#include <rte_arg_parser.h>
#include <rte_eal.h>
#include <rte_mempool.h>
#include <rte_mbuf.h>
--
2.34.1
next prev parent reply other threads:[~2023-12-07 16:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-07 16:18 [PATCH v3 0/8] add new command line argument parsing library Euan Bourke
2023-12-07 16:18 ` [PATCH v3 1/8] arg_parser: new library for command line parsing Euan Bourke
2023-12-07 16:44 ` Bruce Richardson
2023-12-07 19:32 ` Tyler Retzlaff
2023-12-07 16:18 ` [PATCH v3 2/8] arg_parser: add new coremask parsing API Euan Bourke
2023-12-07 16:18 ` [PATCH v3 3/8] eal: add support for new arg parsing library Euan Bourke
2023-12-07 16:18 ` [PATCH v3 4/8] eal: update to service core related parsers Euan Bourke
2023-12-07 16:18 ` [PATCH v3 5/8] event/dlb2: add new arg parsing library API support Euan Bourke
2023-12-07 16:18 ` [PATCH v3 6/8] arg_parser: added common core string and heuristic parsers Euan Bourke
2023-12-07 16:58 ` Bruce Richardson
2023-12-07 16:18 ` Euan Bourke [this message]
2023-12-07 16:18 ` [PATCH v3 8/8] examples/l3fwd-power: update to call arg parser API Euan Bourke
2023-12-11 12:01 ` Hunt, David
2023-12-11 16:50 ` Tummala, Sivaprasad
2023-12-07 17:34 ` [PATCH v3 0/8] add new command line argument parsing library Stephen Hemminger
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=20231207161818.2590661-8-euan.bourke@intel.com \
--to=euan.bourke@intel.com \
--cc=dev@dpdk.org \
--cc=harry.van.haaren@intel.com \
/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).