From: Michael Baum <michaelba@nvidia.com>
To: <dev@dpdk.org>
Cc: Ori Kam <orika@nvidia.com>,
Aman Singh <aman.deep.singh@intel.com>,
"Yuying Zhang" <yuying.zhang@intel.com>,
Ferruh Yigit <ferruh.yigit@amd.com>,
"Thomas Monjalon" <thomas@monjalon.net>
Subject: [PATCH v2 2/2] app/testpmd: add random item support
Date: Mon, 11 Sep 2023 10:41:49 +0300 [thread overview]
Message-ID: <20230911074149.697944-3-michaelba@nvidia.com> (raw)
In-Reply-To: <20230911074149.697944-1-michaelba@nvidia.com>
Add support for random item, usage example:
pattern random spec value 0x1 mask value 0x3 / eth / end
Flow rule with above pattern matching 25% of the traffic, it hits only
when random value suffix is "01" and miss the others ("00", "10", "11").
Signed-off-by: Michael Baum <michaelba@nvidia.com>
---
app/test-pmd/cmdline_flow.c | 30 ++++++++++++++++++++-
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +++
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 94827bcc4a..55fb07ec91 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -417,6 +417,8 @@ enum index {
ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
ITEM_META,
ITEM_META_DATA,
+ ITEM_RANDOM,
+ ITEM_RANDOM_VALUE,
ITEM_GRE_KEY,
ITEM_GRE_KEY_VALUE,
ITEM_GRE_OPTION,
@@ -936,7 +938,8 @@ static const char *const modify_field_ids[] = {
"ipv6_proto",
"flex_item",
"hash_result",
- "geneve_opt_type", "geneve_opt_class", "geneve_opt_data", "mpls",
+ "geneve_opt_type", "geneve_opt_class", "geneve_opt_data",
+ "mpls", "random",
NULL
};
@@ -1535,6 +1538,7 @@ static const enum index next_item[] = {
ITEM_ICMP6_ND_OPT_SLA_ETH,
ITEM_ICMP6_ND_OPT_TLA_ETH,
ITEM_META,
+ ITEM_RANDOM,
ITEM_GRE_KEY,
ITEM_GRE_OPTION,
ITEM_GTP_PSC,
@@ -1842,6 +1846,12 @@ static const enum index item_meta[] = {
ZERO,
};
+static const enum index item_random[] = {
+ ITEM_RANDOM_VALUE,
+ ITEM_NEXT,
+ ZERO,
+};
+
static const enum index item_gtp_psc[] = {
ITEM_GTP_PSC_QFI,
ITEM_GTP_PSC_PDU_T,
@@ -5063,6 +5073,21 @@ static const struct token token_list[] = {
.args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
data, "\xff\xff\xff\xff")),
},
+ [ITEM_RANDOM] = {
+ .name = "random",
+ .help = "match random value",
+ .priv = PRIV_ITEM(RANDOM, sizeof(struct rte_flow_item_random)),
+ .next = NEXT(item_random),
+ .call = parse_vc,
+ },
+ [ITEM_RANDOM_VALUE] = {
+ .name = "value",
+ .help = "random value",
+ .next = NEXT(item_random, NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_random,
+ value, "\xff\xff")),
+ },
[ITEM_GRE_KEY] = {
.name = "gre_key",
.help = "match GRE key",
@@ -12634,6 +12659,9 @@ flow_item_default_mask(const struct rte_flow_item *item)
case RTE_FLOW_ITEM_TYPE_META:
mask = &rte_flow_item_meta_mask;
break;
+ case RTE_FLOW_ITEM_TYPE_RANDOM:
+ mask = &rte_flow_item_random_mask;
+ break;
case RTE_FLOW_ITEM_TYPE_FUZZY:
mask = &rte_flow_item_fuzzy_mask;
break;
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index a182479ab2..0b27a6fd97 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3724,6 +3724,10 @@ This section lists supported pattern items and their attributes, if any.
- ``data {unsigned}``: metadata value.
+- ``random``: match application specific random value.
+
+ - ``value {unsigned}``: random value.
+
- ``gtp_psc``: match GTP PDU extension header with type 0x85.
- ``pdu_type {unsigned}``: PDU type.
--
2.25.1
next prev parent reply other threads:[~2023-09-11 7:42 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-22 9:05 [PATCH v1 0/2] ethdev: " Michael Baum
2023-08-22 9:05 ` [PATCH v1 1/2] " Michael Baum
2023-08-22 9:05 ` [PATCH v1 2/2] app/testpmd: " Michael Baum
2023-08-22 12:41 ` [PATCH v1 0/2] ethdev: " Ivan Malov
2023-08-22 14:09 ` Michael Baum
2023-08-22 14:09 ` Stephen Hemminger
2023-09-11 7:41 ` [PATCH v2 " Michael Baum
2023-09-11 7:41 ` [PATCH v2 1/2] " Michael Baum
2023-09-11 15:59 ` Thomas Monjalon
2023-10-12 10:14 ` Michael Baum
2023-09-11 7:41 ` Michael Baum [this message]
2023-09-18 11:44 ` [PATCH v2 2/2] app/testpmd: " Ori Kam
2023-09-11 16:55 ` [PATCH v2 0/2] ethdev: " Morten Brørup
2023-09-11 17:53 ` Stephen Hemminger
2023-10-12 9:48 ` Michael Baum
2023-09-12 8:40 ` Michael Baum
2023-11-30 16:32 ` [PATCH v3 " Michael Baum
2023-11-30 16:32 ` [PATCH v3 1/2] " Michael Baum
2023-12-08 18:54 ` Dariusz Sosnowski
2023-12-14 10:32 ` Michael Baum
2023-12-14 10:54 ` Dariusz Sosnowski
2023-12-08 19:03 ` Dariusz Sosnowski
2023-11-30 16:32 ` [PATCH v3 2/2] app/testpmd: " Michael Baum
2023-12-08 18:52 ` Dariusz Sosnowski
2023-12-14 10:58 ` [PATCH v4 0/2] ethdev: " Michael Baum
2023-12-14 10:58 ` [PATCH v4 1/2] " Michael Baum
2023-12-14 11:12 ` Dariusz Sosnowski
2023-12-14 11:32 ` Ori Kam
2023-12-14 12:18 ` Ferruh Yigit
2023-12-14 13:43 ` Michael Baum
2023-12-14 15:55 ` Ferruh Yigit
2023-12-15 7:47 ` Michael Baum
2023-12-14 10:58 ` [PATCH v4 2/2] app/testpmd: " Michael Baum
2023-12-15 12:07 ` [PATCH v4 0/2] ethdev: " Ferruh Yigit
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=20230911074149.697944-3-michaelba@nvidia.com \
--to=michaelba@nvidia.com \
--cc=aman.deep.singh@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=orika@nvidia.com \
--cc=thomas@monjalon.net \
--cc=yuying.zhang@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).