From: Ivan Malov Date: Wed, 13 Oct 2021 17:34:38 +0000 (+0300) Subject: ethdev: add represented port item to flow API X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=49863ae2bf955a8dcba8dae734fe49b5e67a9f67;p=dpdk.git ethdev: add represented port item to flow API For use in "transfer" flows. Supposed to match traffic entering the embedded switch from the entity represented by the given ethdev. Such an entity can be a network (via a network port), a guest machine (via a VF) or another ethdev in the same application. Must not be combined with direction attributes. Signed-off-by: Ivan Malov Acked-by: Ori Kam Acked-by: Andrew Rybchenko --- diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 5c480db91d..354f0fb2d7 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -308,6 +308,8 @@ enum index { ITEM_POL_POLICY, ITEM_PORT_REPRESENTOR, ITEM_PORT_REPRESENTOR_PORT_ID, + ITEM_REPRESENTED_PORT, + ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID, /* Validate/create actions. */ ACTIONS, @@ -1002,6 +1004,7 @@ static const enum index next_item[] = { ITEM_INTEGRITY, ITEM_CONNTRACK, ITEM_PORT_REPRESENTOR, + ITEM_REPRESENTED_PORT, END_SET, ZERO, }; @@ -1376,6 +1379,12 @@ static const enum index item_port_representor[] = { ZERO, }; +static const enum index item_represented_port[] = { + ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID, + ITEM_NEXT, + ZERO, +}; + static const enum index next_action[] = { ACTION_END, ACTION_VOID, @@ -3630,6 +3639,21 @@ static const struct token token_list[] = { item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)), }, + [ITEM_REPRESENTED_PORT] = { + .name = "represented_port", + .help = "match traffic entering the embedded switch from the entity represented by the given ethdev", + .priv = PRIV_ITEM(REPRESENTED_PORT, + sizeof(struct rte_flow_item_ethdev)), + .next = NEXT(item_represented_port), + .call = parse_vc, + }, + [ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID] = { + .name = "ethdev_port_id", + .help = "ethdev port ID", + .next = NEXT(item_represented_port, NEXT_ENTRY(COMMON_UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)), + }, /* Validate/create actions. */ [ACTIONS] = { .name = "actions", @@ -8358,6 +8382,7 @@ flow_item_default_mask(const struct rte_flow_item *item) mask = &rte_flow_item_pfcp_mask; break; case RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR: + case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT: mask = &rte_flow_item_ethdev_mask; break; default: diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini index 560a13c1ce..419bffc66e 100644 --- a/doc/guides/nics/features/default.ini +++ b/doc/guides/nics/features/default.ini @@ -125,6 +125,7 @@ pppoed = pppoes = pppoe_proto_id = raw = +represented_port = sctp = tag = tcp = diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index d194640469..2da286dce8 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1484,6 +1484,52 @@ at the opposite end of the "wire" leading to the ethdev. - Default ``mask`` provides exact match behaviour. +Item: ``REPRESENTED_PORT`` +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Matches traffic entering the embedded switch from +the entity represented by the given ethdev. + +Term **ethdev** and the concept of **port representor** are synonymous. +The **represented port** is an *entity* plugged to the embedded switch +at the opposite end of the "wire" leading to the ethdev. + +:: + + .--------------------. + | PORT_REPRESENTOR | Ethdev (Application Port Referred to by its ID) + '--------------------' + : + : + .----------------. + | Logical Port | + '----------------' + : + : + : + : + .----------. + | Switch | + '----------' + /\ + || + || + || + .----------------. + | Logical Port | + '----------------' + /\ + || + .--------------------. + | REPRESENTED_PORT | Net / Guest / Another Ethdev (Same Application) + '--------------------' + + +- Incompatible with `Attribute: Traffic direction`_. +- Requires `Attribute: Transfer`_. + +This item is meant to use the same structure as `Item: PORT_REPRESENTOR`_. + Actions ~~~~~~~ diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index 6fb3164d17..a16d30e1f6 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -294,7 +294,7 @@ API Changes * net: Renamed ``s_addr`` and ``d_addr`` fields of ``rte_ether_hdr`` structure to ``src_addr`` and ``dst_addr``, respectively. -* ethdev: Added item ``PORT_REPRESENTOR`` to flow API. +* ethdev: Added items ``PORT_REPRESENTOR``, ``REPRESENTED_PORT`` 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 90765f9090..61669d1d5a 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3805,6 +3805,11 @@ This section lists supported pattern items and their attributes, if any. - ``port_id {unsigned}``: ethdev port ID +- ``represented_port``: match traffic entering the embedded switch from + the entity represented by the given ethdev + + - ``ethdev_port_id {unsigned}``: ethdev port ID + Actions list ^^^^^^^^^^^^ diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 5e9317c6d1..d4b654a2c6 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -101,6 +101,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(INTEGRITY, sizeof(struct rte_flow_item_integrity)), MK_FLOW_ITEM(CONNTRACK, sizeof(uint32_t)), MK_FLOW_ITEM(PORT_REPRESENTOR, sizeof(struct rte_flow_item_ethdev)), + MK_FLOW_ITEM(REPRESENTED_PORT, 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 1e3ef77ead..b50c3d38b5 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -583,6 +583,16 @@ enum rte_flow_item_type { * @see struct rte_flow_item_ethdev */ RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR, + + /** + * [META] + * + * Matches traffic entering the embedded switch from + * the entity represented by the given ethdev. + * + * @see struct rte_flow_item_ethdev + */ + RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT, }; /** @@ -1813,7 +1823,8 @@ static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = { * @b EXPERIMENTAL: this structure may change without prior notice * * Provides an ethdev port ID for use with the following items: - * RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR. + * RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR, + * RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT. */ struct rte_flow_item_ethdev { uint16_t port_id; /**< ethdev port ID */