[dpdk-dev] [PATCH v1 01/12] ethdev: add ethdev item to flow API
Andrew Rybchenko
andrew.rybchenko at oktetlabs.ru
Fri Oct 1 15:47:05 CEST 2021
From: Ivan Malov <ivan.malov at oktetlabs.ru>
For use with "transfer" flows. Supposed to match traffic transmitted
by the DPDK application via the specified ethdev, at e-switch level.
Must not be combined with attributes "ingress" / "egress".
Signed-off-by: Ivan Malov <ivan.malov at oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko at oktetlabs.ru>
---
app/test-pmd/cmdline_flow.c | 27 ++++++++++++++++
doc/guides/prog_guide/rte_flow.rst | 35 +++++++++++++++++++++
doc/guides/rel_notes/release_21_11.rst | 2 ++
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +++
lib/ethdev/rte_flow.c | 1 +
lib/ethdev/rte_flow.h | 27 ++++++++++++++++
6 files changed, 96 insertions(+)
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index bb22294dd3..e05b0d83d2 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -306,6 +306,8 @@ enum index {
ITEM_POL_PORT,
ITEM_POL_METER,
ITEM_POL_POLICY,
+ ITEM_ETHDEV,
+ ITEM_ETHDEV_ID,
/* Validate/create actions. */
ACTIONS,
@@ -1000,6 +1002,7 @@ static const enum index next_item[] = {
ITEM_GENEVE_OPT,
ITEM_INTEGRITY,
ITEM_CONNTRACK,
+ ITEM_ETHDEV,
END_SET,
ZERO,
};
@@ -1368,6 +1371,12 @@ static const enum index item_integrity_lv[] = {
ZERO,
};
+static const enum index item_ethdev[] = {
+ ITEM_ETHDEV_ID,
+ ITEM_NEXT,
+ ZERO,
+};
+
static const enum index next_action[] = {
ACTION_END,
ACTION_VOID,
@@ -3608,6 +3617,21 @@ static const struct token token_list[] = {
item_param),
.args = ARGS(ARGS_ENTRY(struct rte_flow_item_conntrack, flags)),
},
+ [ITEM_ETHDEV] = {
+ .name = "ethdev",
+ .help = "match traffic at e-switch going from (sent by) the given ethdev",
+ .priv = PRIV_ITEM(ETHDEV,
+ sizeof(struct rte_flow_item_ethdev)),
+ .next = NEXT(item_ethdev),
+ .call = parse_vc,
+ },
+ [ITEM_ETHDEV_ID] = {
+ .name = "id",
+ .help = "ethdev ID",
+ .next = NEXT(item_ethdev, NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, id)),
+ },
/* Validate/create actions. */
[ACTIONS] = {
.name = "actions",
@@ -8343,6 +8367,9 @@ flow_item_default_mask(const struct rte_flow_item *item)
case RTE_FLOW_ITEM_TYPE_PFCP:
mask = &rte_flow_item_pfcp_mask;
break;
+ case RTE_FLOW_ITEM_TYPE_ETHDEV:
+ mask = &rte_flow_item_ethdev_mask;
+ break;
default:
break;
}
diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index 2b42d5ec8c..ab628d9139 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -1425,6 +1425,41 @@ Matches a conntrack state after conntrack action.
- ``flags``: conntrack packet state flags.
- Default ``mask`` matches all state bits.
+Item: ``ETHDEV``
+^^^^^^^^^^^^^^^^
+
+Matches traffic at e-switch going from (sent by) the given ethdev.
+
+::
+
+ * (Ethdev) ~~~~~~~~~~~~ (Internal Port) >>>> [] ~~~~ (External Port)
+ * : SW : Logical Net / Guest :
+ * : : :
+ * | ---- PMD Layer ---- | ------------ E-Switch Layer ------------ |
+ *
+ * [] shows the effective ("transfer") standpoint, the match engine;
+ * >> shows the traffic flow in question hitting the match engine;
+ * ~~ shows logical interconnects between the endpoints.
+
+Use this with attribute **transfer**. Attributes **ingress** and
+**egress** (`Attribute: Traffic direction`_) must not be used.
+
+- Default ``mask`` provides exact match behaviour.
+
+.. _table_rte_flow_item_ethdev:
+
+.. table:: ETHDEV
+
+ +----------+----------+---------------------------+
+ | Field | Subfield | Value |
+ +==========+==========+===========================+
+ | ``spec`` | ``id`` | ethdev ID |
+ +----------+----------+---------------------------+
+ | ``last`` | ``id`` | upper range value |
+ +----------+----------+---------------------------+
+ | ``mask`` | ``id`` | zeroed for wildcard match |
+ +----------+----------+---------------------------+
+
Actions
~~~~~~~
diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index f099b1cca2..91631adb4e 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -167,6 +167,8 @@ API Changes
Also, make sure to start the actual text at the margin.
=======================================================
+* ethdev: Added item ``ETHDEV`` to flow API.
+
* cryptodev: The API rte_cryptodev_pmd_is_valid_dev is modified to
rte_cryptodev_is_valid_dev as it can be used by the application as
well as PMD to check whether the device is valid or not.
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index bbef706374..6d5de5457c 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3820,6 +3820,10 @@ This section lists supported pattern items and their attributes, if any.
- ``conntrack``: match conntrack state.
+- ``ethdev``: match traffic at e-switch going from (sent by) the given ethdev
+
+ - ``id {unsigned}``: ethdev ID
+
Actions list
^^^^^^^^^^^^
diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
index 8cb7a069c8..84eb61cb6c 100644
--- a/lib/ethdev/rte_flow.c
+++ b/lib/ethdev/rte_flow.c
@@ -100,6 +100,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {
MK_FLOW_ITEM(GENEVE_OPT, sizeof(struct rte_flow_item_geneve_opt)),
MK_FLOW_ITEM(INTEGRITY, sizeof(struct rte_flow_item_integrity)),
MK_FLOW_ITEM(CONNTRACK, sizeof(uint32_t)),
+ MK_FLOW_ITEM(ETHDEV, sizeof(struct rte_flow_item_ethdev)),
};
/** Generate flow_action[] entry. */
diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
index 7b1ed7f110..880502098e 100644
--- a/lib/ethdev/rte_flow.h
+++ b/lib/ethdev/rte_flow.h
@@ -574,6 +574,15 @@ enum rte_flow_item_type {
* @see struct rte_flow_item_conntrack.
*/
RTE_FLOW_ITEM_TYPE_CONNTRACK,
+
+ /**
+ * [META]
+ *
+ * Matches traffic at e-switch going from (sent by) the given ethdev.
+ *
+ * @see struct rte_flow_item_ethdev
+ */
+ RTE_FLOW_ITEM_TYPE_ETHDEV,
};
/**
@@ -1799,6 +1808,24 @@ static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = {
};
#endif
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * Provides an ethdev ID for use with items which are as follows:
+ * RTE_FLOW_ITEM_TYPE_ETHDEV.
+ */
+struct rte_flow_item_ethdev {
+ uint16_t id; /**< Ethdev ID */
+};
+
+/** Default mask for RTE_FLOW_ITEM_TYPE_ETHDEV */
+#ifndef __cplusplus
+static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = {
+ .id = 0xffff,
+};
+#endif
+
/**
* Matching pattern item definition.
*
--
2.30.2
More information about the dev
mailing list