ethdev: add physical port action to flow API
authorAdrien Mazarguil <adrien.mazarguil@6wind.com>
Wed, 25 Apr 2018 15:28:08 +0000 (17:28 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 27 Apr 2018 17:00:54 +0000 (18:00 +0100)
This patch adds the missing action counterpart to the PHY_PORT pattern
item, that is, the ability to directly inject matching traffic into a
physical port of the underlying device.

It breaks ABI compatibility for the following public functions:

- rte_flow_copy()
- rte_flow_create()
- rte_flow_query()
- rte_flow_validate()

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
Acked-by: Mohammad Abdul Awal <mohammad.abdul.awal@intel.com>
app/test-pmd/cmdline_flow.c
app/test-pmd/config.c
doc/guides/prog_guide/rte_flow.rst
doc/guides/rel_notes/release_18_05.rst
doc/guides/testpmd_app_ug/testpmd_funcs.rst
lib/librte_ether/rte_flow.c
lib/librte_ether/rte_flow.h

index f9f9372..3567148 100644 (file)
@@ -182,6 +182,9 @@ enum index {
        ACTION_VF,
        ACTION_VF_ORIGINAL,
        ACTION_VF_ID,
+       ACTION_PHY_PORT,
+       ACTION_PHY_PORT_ORIGINAL,
+       ACTION_PHY_PORT_INDEX,
        ACTION_METER,
        ACTION_METER_ID,
 };
@@ -623,6 +626,7 @@ static const enum index next_action[] = {
        ACTION_RSS,
        ACTION_PF,
        ACTION_VF,
+       ACTION_PHY_PORT,
        ACTION_METER,
        ZERO,
 };
@@ -657,6 +661,13 @@ static const enum index action_vf[] = {
        ZERO,
 };
 
+static const enum index action_phy_port[] = {
+       ACTION_PHY_PORT_ORIGINAL,
+       ACTION_PHY_PORT_INDEX,
+       ACTION_NEXT,
+       ZERO,
+};
+
 static const enum index action_meter[] = {
        ACTION_METER_ID,
        ACTION_NEXT,
@@ -1714,6 +1725,30 @@ static const struct token token_list[] = {
                .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
                .call = parse_vc_conf,
        },
+       [ACTION_PHY_PORT] = {
+               .name = "phy_port",
+               .help = "direct packets to physical port index",
+               .priv = PRIV_ACTION(PHY_PORT,
+                                   sizeof(struct rte_flow_action_phy_port)),
+               .next = NEXT(action_phy_port),
+               .call = parse_vc,
+       },
+       [ACTION_PHY_PORT_ORIGINAL] = {
+               .name = "original",
+               .help = "use original port index if possible",
+               .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
+               .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
+                                          original, 1)),
+               .call = parse_vc_conf,
+       },
+       [ACTION_PHY_PORT_INDEX] = {
+               .name = "index",
+               .help = "physical port index",
+               .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
+               .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
+                                       index)),
+               .call = parse_vc_conf,
+       },
        [ACTION_METER] = {
                .name = "meter",
                .help = "meter the directed packets at given id",
index 272e25f..7a954c5 100644 (file)
@@ -1091,6 +1091,7 @@ static const struct {
        MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)),
        MK_FLOW_ACTION(PF, 0),
        MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)),
+       MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)),
        MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)),
 };
 
index 4e053c2..a39c1e1 100644 (file)
@@ -1433,6 +1433,26 @@ See `Item: VF`_.
    | ``id``       | VF ID                          |
    +--------------+--------------------------------+
 
+Action: ``PHY_PORT``
+^^^^^^^^^^^^^^^^^^^^
+
+Directs matching traffic to a given physical port index of the underlying
+device.
+
+See `Item: PHY_PORT`_.
+
+.. _table_rte_flow_action_phy_port:
+
+.. table:: PHY_PORT
+
+   +--------------+-------------------------------------+
+   | Field        | Value                               |
+   +==============+=====================================+
+   | ``original`` | use original port index if possible |
+   +--------------+-------------------------------------+
+   | ``index``    | physical port index                 |
+   +--------------+-------------------------------------+
+
 Action: ``METER``
 ^^^^^^^^^^^^^^^^^
 
index 2a325ba..1308b8e 100644 (file)
@@ -288,6 +288,8 @@ API Changes
     consistency.
   * Pattern item PORT was renamed PHY_PORT to avoid confusion with DPDK port
     IDs.
+  * An action counterpart to the PHY_PORT pattern item was added in order to
+    redirect matching traffic to a specific physical port.
 
 
 ABI Changes
index 51d36d3..9733a72 100644 (file)
@@ -3447,6 +3447,11 @@ This section lists supported actions and their attributes, if any.
   - ``original {boolean}``: use original VF ID if possible.
   - ``id {unsigned}``: VF ID.
 
+- ``phy_port``: direct packets to physical port index.
+
+  - ``original {boolean}``: use original port index if possible.
+  - ``index {unsigned}``: physical port index.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
index 36e277a..00989c7 100644 (file)
@@ -76,6 +76,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
        MK_FLOW_ACTION(RSS, sizeof(struct rte_flow_action_rss)),
        MK_FLOW_ACTION(PF, 0),
        MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)),
+       MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)),
 };
 
 static int
index 2c7c4d0..58b75e9 100644 (file)
@@ -988,6 +988,14 @@ enum rte_flow_action_type {
         */
        RTE_FLOW_ACTION_TYPE_VF,
 
+       /**
+        * Directs packets to a given physical port index of the underlying
+        * device.
+        *
+        * See struct rte_flow_action_phy_port.
+        */
+       RTE_FLOW_ACTION_TYPE_PHY_PORT,
+
        /**
         * Traffic metering and policing (MTR).
         *
@@ -1111,6 +1119,20 @@ struct rte_flow_action_vf {
        uint32_t id; /**< VF ID. */
 };
 
+/**
+ * RTE_FLOW_ACTION_TYPE_PHY_PORT
+ *
+ * Directs packets to a given physical port index of the underlying
+ * device.
+ *
+ * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
+ */
+struct rte_flow_action_phy_port {
+       uint32_t original:1; /**< Use original port index if possible. */
+       uint32_t reserved:31; /**< Reserved, must be zero. */
+       uint32_t index; /**< Physical port index. */
+};
+
 /**
  * RTE_FLOW_ACTION_TYPE_METER
  *