* [PATCH] ethdev: add packet type matching item
@ 2023-08-10 16:14 Alexander Kozyrev
2023-09-19 10:02 ` Ori Kam
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Kozyrev @ 2023-08-10 16:14 UTC (permalink / raw)
To: dev; +Cc: orika, olivier.matz, matan, thomas
Add RTE_FLOW_ITEM_TYPE_PTYPE to allow matching on
L2/L3/L4 and tunnel information as defined in mbuf.
Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
---
app/test-pmd/cmdline_flow.c | 27 +++++++++++++++++++++
doc/guides/nics/features/default.ini | 1 +
doc/guides/prog_guide/rte_flow.rst | 7 ++++++
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +++
lib/ethdev/rte_flow.c | 1 +
lib/ethdev/rte_flow.h | 25 +++++++++++++++++++
6 files changed, 65 insertions(+)
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 94827bcc4a..853a6d25e0 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -524,6 +524,8 @@ enum index {
ITEM_IB_BTH_PSN,
ITEM_IPV6_PUSH_REMOVE_EXT,
ITEM_IPV6_PUSH_REMOVE_EXT_TYPE,
+ ITEM_PTYPE,
+ ITEM_PTYPE_VALUE,
/* Validate/create actions. */
ACTIONS,
@@ -1561,6 +1563,7 @@ static const enum index next_item[] = {
ITEM_AGGR_AFFINITY,
ITEM_TX_QUEUE,
ITEM_IB_BTH,
+ ITEM_PTYPE,
END_SET,
ZERO,
};
@@ -2079,6 +2082,12 @@ static const enum index item_ib_bth[] = {
ZERO,
};
+static const enum index item_ptype[] = {
+ ITEM_PTYPE_VALUE,
+ ITEM_NEXT,
+ ZERO,
+};
+
static const enum index next_action[] = {
ACTION_END,
ACTION_VOID,
@@ -5827,6 +5836,21 @@ static const struct token token_list[] = {
.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ib_bth,
hdr.psn)),
},
+ [ITEM_PTYPE] = {
+ .name = "ptype",
+ .help = "match L2/L3/L4 and tunnel information",
+ .priv = PRIV_ITEM(PTYPE,
+ sizeof(struct rte_flow_item_ptype)),
+ .next = NEXT(item_ptype),
+ .call = parse_vc,
+ },
+ [ITEM_PTYPE_VALUE] = {
+ .name = "packet_type",
+ .help = "packet type as defined in rte_mbuf_ptype",
+ .next = NEXT(item_ptype, NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ptype, packet_type)),
+ },
/* Validate/create actions. */
[ACTIONS] = {
.name = "actions",
@@ -12689,6 +12713,9 @@ flow_item_default_mask(const struct rte_flow_item *item)
case RTE_FLOW_ITEM_TYPE_IB_BTH:
mask = &rte_flow_item_ib_bth_mask;
break;
+ case RTE_FLOW_ITEM_TYPE_PTYPE:
+ mask = &rte_flow_item_ptype_mask;
+ break;
default:
break;
}
diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini
index 2011e97127..e41a97b3bb 100644
--- a/doc/guides/nics/features/default.ini
+++ b/doc/guides/nics/features/default.ini
@@ -137,6 +137,7 @@ ppp =
pppoed =
pppoes =
pppoe_proto_id =
+ptype =
quota =
raw =
represented_port =
diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index 5bc998a433..62a6dbb7f9 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -1566,6 +1566,13 @@ Matches an InfiniBand base transport header in RoCE packet.
- ``hdr``: InfiniBand base transport header definition (``rte_ib.h``).
+Item: ``PTYPE``
+^^^^^^^^^^^^^^^
+
+Matches the packet type as defined in rte_mbuf_ptype.
+
+- ``packet_type``: L2/L3/L4 and tunnel information.
+
Actions
~~~~~~~
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index a182479ab2..8dc711bfc4 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3805,6 +3805,10 @@ This section lists supported pattern items and their attributes, if any.
- ``send_to_kernel``: send packets to kernel.
+- ``ptype``: match the packet type (L2/L3/L4 and tunnel information).
+
+ - ``packet_type {unsigned}``: packet type.
+
Actions list
^^^^^^^^^^^^
diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
index 271d854f78..71583bc174 100644
--- a/lib/ethdev/rte_flow.c
+++ b/lib/ethdev/rte_flow.c
@@ -166,6 +166,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {
MK_FLOW_ITEM(AGGR_AFFINITY, sizeof(struct rte_flow_item_aggr_affinity)),
MK_FLOW_ITEM(TX_QUEUE, sizeof(struct rte_flow_item_tx_queue)),
MK_FLOW_ITEM(IB_BTH, sizeof(struct rte_flow_item_ib_bth)),
+ MK_FLOW_ITEM(PTYPE, sizeof(struct rte_flow_item_ptype)),
};
/** Generate flow_action[] entry. */
diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
index 86ed98c562..de941a5867 100644
--- a/lib/ethdev/rte_flow.h
+++ b/lib/ethdev/rte_flow.h
@@ -688,6 +688,14 @@ enum rte_flow_item_type {
* @see struct rte_flow_item_ib_bth.
*/
RTE_FLOW_ITEM_TYPE_IB_BTH,
+
+ /**
+ * Matches the packet type as defined in rte_mbuf_ptype.
+ *
+ * See struct rte_flow_item_ptype.
+ *
+ */
+ RTE_FLOW_ITEM_TYPE_PTYPE,
};
/**
@@ -2311,6 +2319,23 @@ static const struct rte_flow_item_tx_queue rte_flow_item_tx_queue_mask = {
};
#endif
+/**
+ *
+ * RTE_FLOW_ITEM_TYPE_PTYPE
+ *
+ * Matches the packet type as defined in rte_mbuf_ptype.
+ */
+struct rte_flow_item_ptype {
+ uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */
+};
+
+/** Default mask for RTE_FLOW_ITEM_TYPE_PTYPE. */
+#ifndef __cplusplus
+static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
+ .packet_type = 0xffffffff,
+};
+#endif
+
/**
* Action types.
*
--
2.18.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] ethdev: add packet type matching item
2023-08-10 16:14 [PATCH] ethdev: add packet type matching item Alexander Kozyrev
@ 2023-09-19 10:02 ` Ori Kam
2023-09-21 15:39 ` Ferruh Yigit
0 siblings, 1 reply; 3+ messages in thread
From: Ori Kam @ 2023-09-19 10:02 UTC (permalink / raw)
To: Alexander Kozyrev, dev
Cc: olivier.matz, Matan Azrad, NBU-Contact-Thomas Monjalon (EXTERNAL)
Hi Alex,
> -----Original Message-----
> From: Alexander Kozyrev <akozyrev@nvidia.com>
> Sent: Thursday, August 10, 2023 7:15 PM
> Subject: [PATCH] ethdev: add packet type matching item
>
> Add RTE_FLOW_ITEM_TYPE_PTYPE to allow matching on
> L2/L3/L4 and tunnel information as defined in mbuf.
>
Please add testpmd example line.
> Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
> ---
Acked-by: Ori Kam <orika@nvidia.com>
Thanks,
Ori
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ethdev: add packet type matching item
2023-09-19 10:02 ` Ori Kam
@ 2023-09-21 15:39 ` Ferruh Yigit
0 siblings, 0 replies; 3+ messages in thread
From: Ferruh Yigit @ 2023-09-21 15:39 UTC (permalink / raw)
To: Ori Kam, Alexander Kozyrev, dev
Cc: olivier.matz, Matan Azrad, NBU-Contact-Thomas Monjalon (EXTERNAL)
On 9/19/2023 11:02 AM, Ori Kam wrote:
> Hi Alex,
>
>
>
>> -----Original Message-----
>> From: Alexander Kozyrev <akozyrev@nvidia.com>
>> Sent: Thursday, August 10, 2023 7:15 PM
>> Subject: [PATCH] ethdev: add packet type matching item
>>
>> Add RTE_FLOW_ITEM_TYPE_PTYPE to allow matching on
>> L2/L3/L4 and tunnel information as defined in mbuf.
>>
>
> Please add testpmd example line.
>
Hi Alexander,
Can you please send a v2 with the commit log update to have the sample
testpmd command? Please keep Ori's ack in v2.
>> Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
>> ---
>
> Acked-by: Ori Kam <orika@nvidia.com>
> Thanks,
> Ori
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-21 15:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-10 16:14 [PATCH] ethdev: add packet type matching item Alexander Kozyrev
2023-09-19 10:02 ` Ori Kam
2023-09-21 15:39 ` Ferruh Yigit
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).