From: Ivan Malov <ivan.ma...@oktetlabs.ru>

The action handler will use MAE action DELIVER with
MPORT of a given physical port.

Signed-off-by: Ivan Malov <ivan.ma...@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybche...@solarflare.com>
Reviewed-by: Andy Moreton <amore...@xilinx.com>
---
 doc/guides/nics/sfc_efx.rst |  4 ++++
 drivers/net/sfc/sfc_mae.c   | 40 +++++++++++++++++++++++++++++++++----
 2 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index 65d52d5551..e367ddd6e6 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -194,6 +194,10 @@ Supported pattern items (***transfer*** rules):
 
 - ETH
 
+Supported actions (***transfer*** rules):
+
+- PHY_PORT
+
 Validating flow rules depends on the firmware variant.
 
 The :ref:`flow_isolated_mode` is supported.
diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c
index 95f8cffc27..057eef537b 100644
--- a/drivers/net/sfc/sfc_mae.c
+++ b/drivers/net/sfc/sfc_mae.c
@@ -391,18 +391,50 @@ sfc_mae_rule_parse_pattern(struct sfc_adapter *sa,
 }
 
 static int
-sfc_mae_rule_parse_action(const struct rte_flow_action *action,
-                         __rte_unused efx_mae_actions_t *spec,
+sfc_mae_rule_parse_action_phy_port(struct sfc_adapter *sa,
+                                  const struct rte_flow_action_phy_port *conf,
+                                  efx_mae_actions_t *spec)
+{
+       efx_mport_sel_t mport;
+       uint32_t phy_port;
+       int rc;
+
+       if (conf->original != 0)
+               phy_port = efx_nic_cfg_get(sa->nic)->enc_assigned_port;
+       else
+               phy_port = conf->index;
+
+       rc = efx_mae_mport_by_phy_port(phy_port, &mport);
+       if (rc != 0)
+               return rc;
+
+       return efx_mae_action_set_populate_deliver(spec, &mport);
+}
+
+static int
+sfc_mae_rule_parse_action(struct sfc_adapter *sa,
+                         const struct rte_flow_action *action,
+                         efx_mae_actions_t *spec,
                          struct rte_flow_error *error)
 {
+       int rc;
+
        switch (action->type) {
+       case RTE_FLOW_ACTION_TYPE_PHY_PORT:
+               rc = sfc_mae_rule_parse_action_phy_port(sa, action->conf, spec);
+               break;
        default:
                return rte_flow_error_set(error, ENOTSUP,
                                RTE_FLOW_ERROR_TYPE_ACTION, NULL,
                                "Unsupported action");
        }
 
-       return 0;
+       if (rc != 0) {
+               rc = rte_flow_error_set(error, rc, RTE_FLOW_ERROR_TYPE_ACTION,
+                               NULL, "Failed to request the action");
+       }
+
+       return rc;
 }
 
 int
@@ -427,7 +459,7 @@ sfc_mae_rule_parse_actions(struct sfc_adapter *sa,
 
        for (action = actions;
             action->type != RTE_FLOW_ACTION_TYPE_END; ++action) {
-               rc = sfc_mae_rule_parse_action(action, spec, error);
+               rc = sfc_mae_rule_parse_action(sa, action, spec, error);
                if (rc != 0)
                        goto fail_rule_parse_action;
        }
-- 
2.17.1

Reply via email to