[dpdk-dev] [PATCH v1 03/12] ethdev: add ethdev action to flow API
Andrew Rybchenko
andrew.rybchenko at oktetlabs.ru
Fri Oct 1 15:47:07 CEST 2021
From: Ivan Malov <ivan.malov at oktetlabs.ru>
For use with "transfer" flows. Supposed to direct matching traffic
to the specified ethdev (to the application), at e-switch level.
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 | 24 ++++++++++++++++
doc/guides/prog_guide/rte_flow.rst | 31 +++++++++++++++++++++
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 | 18 ++++++++++++
6 files changed, 79 insertions(+), 1 deletion(-)
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 188d0ee39d..feaa61349e 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -460,6 +460,8 @@ enum index {
ACTION_POL_G,
ACTION_POL_Y,
ACTION_POL_R,
+ ACTION_ETHDEV,
+ ACTION_ETHDEV_ID,
};
/** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -1452,6 +1454,7 @@ static const enum index next_action[] = {
ACTION_MODIFY_FIELD,
ACTION_CONNTRACK,
ACTION_CONNTRACK_UPDATE,
+ ACTION_ETHDEV,
ZERO,
};
@@ -1733,6 +1736,12 @@ static const enum index action_update_conntrack[] = {
ZERO,
};
+static const enum index action_ethdev[] = {
+ ACTION_ETHDEV_ID,
+ ACTION_NEXT,
+ ZERO,
+};
+
static int parse_set_raw_encap_decap(struct context *, const struct token *,
const char *, unsigned int,
void *, unsigned int);
@@ -4820,6 +4829,21 @@ static const struct token token_list[] = {
.next = NEXT(action_update_conntrack),
.call = parse_vc_action_conntrack_update,
},
+ [ACTION_ETHDEV] = {
+ .name = "ethdev",
+ .help = "at e-switch level, direct matching packets to the given ethdev",
+ .priv = PRIV_ACTION(ETHDEV,
+ sizeof(struct rte_flow_action_ethdev)),
+ .next = NEXT(action_ethdev),
+ .call = parse_vc,
+ },
+ [ACTION_ETHDEV_ID] = {
+ .name = "id",
+ .help = "ethdev ID",
+ .next = NEXT(action_ethdev, NEXT_ENTRY(COMMON_UNSIGNED)),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev, id)),
+ .call = parse_vc_conf,
+ },
/* Indirect action destroy arguments. */
[INDIRECT_ACTION_DESTROY_ID] = {
.name = "action_id",
diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index 292bb42410..f633973181 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -3056,6 +3056,37 @@ which is set in the packet meta-data (i.e. struct ``rte_mbuf::sched::color``)
| ``meter_color`` | Packet color |
+-----------------+--------------+
+Action: ``ETHDEV``
+^^^^^^^^^^^^^^^^^^
+At e-switch level, directs matching packets to the given ethdev.
+
+These packets can originate from any of e-switch ports, not
+just the ones associated with the given ethdev. They come
+from the match engine in general, as per some criteria.
+
+::
+
+ * (Ethdev) ~~~~~~~~~~~~ (Internal Port) <<<< [] ~~~~ (External Port)
+ * : SW : Logical Net / Guest :
+ * : : :
+ * | ---- PMD Layer ---- | ------------ E-Switch Layer ------------ |
+ *
+ * [] shows the effective ("transfer") standpoint, the action engine;
+ * << shows the traffic flow in question established by the action;
+ * ~~ shows logical interconnects between the endpoints.
+
+See `Item: ETHDEV`_.
+
+.. _table_rte_flow_action_ethdev:
+
+.. table:: ETHDEV
+
+ +--------+-----------+
+ | Field | Value |
+ +========+===========+
+ | ``id`` | ethdev ID |
+ +--------+-----------+
+
Negative types
~~~~~~~~~~~~~~
diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index b2b27de3f0..d431dc3804 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -167,7 +167,7 @@ API Changes
Also, make sure to start the actual text at the margin.
=======================================================
-* ethdev: Added items ``ETHDEV``, ``ESWITCH_PORT`` to flow API.
+* ethdev: Added items ``ETHDEV``, ``ESWITCH_PORT`` and action ``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
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 9a5c2a2d82..79126e2f10 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -4103,6 +4103,10 @@ This section lists supported actions and their attributes, if any.
- ``type {value}``: Set color type with specified value(green/yellow/red)
+- ``ethdev``: at e-switch level, direct matching packets to the given ethdev
+
+ - ``id {unsigned}``: ethdev ID
+
Destroying flow rules
~~~~~~~~~~~~~~~~~~~~~
diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
index c4aea5625f..3cc84e2b43 100644
--- a/lib/ethdev/rte_flow.c
+++ b/lib/ethdev/rte_flow.c
@@ -191,6 +191,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
*/
MK_FLOW_ACTION(INDIRECT, 0),
MK_FLOW_ACTION(CONNTRACK, sizeof(struct rte_flow_action_conntrack)),
+ MK_FLOW_ACTION(ETHDEV, sizeof(struct rte_flow_action_ethdev)),
};
int
diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
index 1a7e4c2e3d..3724ebee35 100644
--- a/lib/ethdev/rte_flow.h
+++ b/lib/ethdev/rte_flow.h
@@ -2446,6 +2446,13 @@ enum rte_flow_action_type {
* See struct rte_flow_action_meter_color.
*/
RTE_FLOW_ACTION_TYPE_METER_COLOR,
+
+ /**
+ * At e-switch level, directs matching packets to the given ethdev.
+ *
+ * @see struct rte_flow_action_ethdev
+ */
+ RTE_FLOW_ACTION_TYPE_ETHDEV,
};
/**
@@ -3205,6 +3212,17 @@ struct rte_flow_action_meter_color {
enum rte_color color; /**< Packet color. */
};
+/**
+ * @warning
+ * @b EXPERIMENTAL: this structure may change without prior notice
+ *
+ * Provides an ethdev ID for use with actions which are as follows:
+ * RTE_FLOW_ACTION_TYPE_ETHDEV.
+ */
+struct rte_flow_action_ethdev {
+ uint16_t id; /**< Ethdev ID */
+};
+
/**
* Field IDs for MODIFY_FIELD action.
*/
--
2.30.2
More information about the dev
mailing list