ethdev: add port representor item to flow API
authorIvan Malov <ivan.malov@oktetlabs.ru>
Wed, 13 Oct 2021 17:34:37 +0000 (20:34 +0300)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 13 Oct 2021 20:59:25 +0000 (22:59 +0200)
For use in "transfer" flows. Supposed to match traffic
entering the embedded switch from the given ethdev.

Must not be combined with direction attributes.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Acked-by: Ori Kam <orika@nvidia.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
app/test-pmd/cmdline_flow.c
doc/guides/nics/features/default.ini
doc/guides/prog_guide/rte_flow.rst
doc/guides/rel_notes/release_21_11.rst
doc/guides/testpmd_app_ug/testpmd_funcs.rst
lib/ethdev/rte_flow.c
lib/ethdev/rte_flow.h

index 0b5856c..5c480db 100644 (file)
@@ -306,6 +306,8 @@ enum index {
        ITEM_POL_PORT,
        ITEM_POL_METER,
        ITEM_POL_POLICY,
+       ITEM_PORT_REPRESENTOR,
+       ITEM_PORT_REPRESENTOR_PORT_ID,
 
        /* Validate/create actions. */
        ACTIONS,
@@ -999,6 +1001,7 @@ static const enum index next_item[] = {
        ITEM_GENEVE_OPT,
        ITEM_INTEGRITY,
        ITEM_CONNTRACK,
+       ITEM_PORT_REPRESENTOR,
        END_SET,
        ZERO,
 };
@@ -1367,6 +1370,12 @@ static const enum index item_integrity_lv[] = {
        ZERO,
 };
 
+static const enum index item_port_representor[] = {
+       ITEM_PORT_REPRESENTOR_PORT_ID,
+       ITEM_NEXT,
+       ZERO,
+};
+
 static const enum index next_action[] = {
        ACTION_END,
        ACTION_VOID,
@@ -3606,6 +3615,21 @@ static const struct token token_list[] = {
                             item_param),
                .args = ARGS(ARGS_ENTRY(struct rte_flow_item_conntrack, flags)),
        },
+       [ITEM_PORT_REPRESENTOR] = {
+               .name = "port_representor",
+               .help = "match traffic entering the embedded switch from the given ethdev",
+               .priv = PRIV_ITEM(PORT_REPRESENTOR,
+                                 sizeof(struct rte_flow_item_ethdev)),
+               .next = NEXT(item_port_representor),
+               .call = parse_vc,
+       },
+       [ITEM_PORT_REPRESENTOR_PORT_ID] = {
+               .name = "port_id",
+               .help = "ethdev port ID",
+               .next = NEXT(item_port_representor, NEXT_ENTRY(COMMON_UNSIGNED),
+                            item_param),
+               .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
+       },
        /* Validate/create actions. */
        [ACTIONS] = {
                .name = "actions",
@@ -8333,6 +8357,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_PORT_REPRESENTOR:
+               mask = &rte_flow_item_ethdev_mask;
+               break;
        default:
                break;
        }
index d473b94..560a13c 100644 (file)
@@ -120,6 +120,7 @@ pf                   =
 pfcp                 =
 phy_port             =
 port_id              =
+port_representor     =
 pppoed               =
 pppoes               =
 pppoe_proto_id       =
index 3cb014c..d194640 100644 (file)
@@ -1425,6 +1425,65 @@ Matches a conntrack state after conntrack action.
 - ``flags``: conntrack packet state flags.
 - Default ``mask`` matches all state bits.
 
+Item: ``PORT_REPRESENTOR``
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Matches traffic entering the embedded switch from 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`_.
+
+.. _table_rte_flow_item_ethdev:
+
+.. table:: ``struct rte_flow_item_ethdev``
+
+   +----------+-------------+---------------------------+
+   | Field    | Subfield    | Value                     |
+   +==========+=============+===========================+
+   | ``spec`` | ``port_id`` | ethdev port ID            |
+   +----------+-------------+---------------------------+
+   | ``last`` | ``port_id`` | upper range value         |
+   +----------+-------------+---------------------------+
+   | ``mask`` | ``port_id`` | zeroed for wildcard match |
+   +----------+-------------+---------------------------+
+
+- Default ``mask`` provides exact match behaviour.
+
 Actions
 ~~~~~~~
 
index d434e33..6fb3164 100644 (file)
@@ -294,6 +294,8 @@ 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.
+
 * 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.
index a0efb7d..90765f9 100644 (file)
@@ -3801,6 +3801,10 @@ This section lists supported pattern items and their attributes, if any.
 
 - ``conntrack``: match conntrack state.
 
+- ``port_representor``: match traffic entering the embedded switch from the given ethdev
+
+  - ``port_id {unsigned}``: ethdev port ID
+
 Actions list
 ^^^^^^^^^^^^
 
index 8cb7a06..5e9317c 100644 (file)
@@ -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(PORT_REPRESENTOR, sizeof(struct rte_flow_item_ethdev)),
 };
 
 /** Generate flow_action[] entry. */
index 5f87851..1e3ef77 100644 (file)
@@ -574,6 +574,15 @@ enum rte_flow_item_type {
         * @see struct rte_flow_item_conntrack.
         */
        RTE_FLOW_ITEM_TYPE_CONNTRACK,
+
+       /**
+        * [META]
+        *
+        * Matches traffic entering the embedded switch from the given ethdev.
+        *
+        * @see struct rte_flow_item_ethdev
+        */
+       RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
 };
 
 /**
@@ -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 port ID for use with the following items:
+ * RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR.
+ */
+struct rte_flow_item_ethdev {
+       uint16_t port_id; /**< ethdev port ID */
+};
+
+/** Default mask for items based on struct rte_flow_item_ethdev */
+#ifndef __cplusplus
+static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = {
+       .port_id = 0xffff,
+};
+#endif
+
 /**
  * Matching pattern item definition.
  *