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 v4 7/8] examples/eventdev_pipeline: update to call arg parser API
Date: Fri, 15 Dec 2023 17:26:31 +0000 [thread overview]
Message-ID: <20231215172632.3102502-8-euan.bourke@intel.com> (raw)
In-Reply-To: <20231215172632.3102502-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 | 66 +++-----------------
examples/eventdev_pipeline/pipeline_common.h | 1 +
2 files changed, 11 insertions(+), 56 deletions(-)
diff --git a/examples/eventdev_pipeline/main.c b/examples/eventdev_pipeline/main.c
index 0c995d1a70..edd0e2c843 100644
--- a/examples/eventdev_pipeline/main.c
+++ b/examples/eventdev_pipeline/main.c
@@ -56,69 +56,23 @@ 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),
+ RTE_ARG_PARSE_TYPE_COREMASK);
- 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-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 ` [PATCH v4 4/8] eal: update to service core related parsers Euan Bourke
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 ` Euan Bourke [this message]
2023-12-15 17:26 ` [PATCH v4 8/8] examples/l3fwd-power: update to call arg parser API 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-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).