From 70f3cadce6fac767cd8c440c5217edc394f28425 Mon Sep 17 00:00:00 2001 From: Ivan Malov Date: Tue, 20 Oct 2020 10:13:17 +0100 Subject: [PATCH] net/sfc: support flow actions PF and VF in transfer rules The action handler will use MAE action DELIVER with MPORT of the PF/VF. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- doc/guides/nics/sfc_efx.rst | 4 ++++ drivers/net/sfc/sfc_mae.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst index f1489bea66..da4a096ac6 100644 --- a/doc/guides/nics/sfc_efx.rst +++ b/doc/guides/nics/sfc_efx.rst @@ -214,6 +214,10 @@ Supported actions (***transfer*** rules): - PHY_PORT +- PF + +- VF + 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 7d1a3b5999..ff21351152 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -734,6 +734,30 @@ sfc_mae_rule_parse_action_phy_port(struct sfc_adapter *sa, return efx_mae_action_set_populate_deliver(spec, &mport); } +static int +sfc_mae_rule_parse_action_pf_vf(struct sfc_adapter *sa, + const struct rte_flow_action_vf *vf_conf, + efx_mae_actions_t *spec) +{ + const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic); + efx_mport_sel_t mport; + uint32_t vf; + int rc; + + if (vf_conf == NULL) + vf = EFX_PCI_VF_INVALID; + else if (vf_conf->original != 0) + vf = encp->enc_vf; + else + vf = vf_conf->id; + + rc = efx_mae_mport_by_pcie_function(encp->enc_pf, vf, &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, @@ -779,6 +803,16 @@ sfc_mae_rule_parse_action(struct sfc_adapter *sa, bundle->actions_mask); rc = sfc_mae_rule_parse_action_phy_port(sa, action->conf, spec); break; + case RTE_FLOW_ACTION_TYPE_PF: + SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_PF, + bundle->actions_mask); + rc = sfc_mae_rule_parse_action_pf_vf(sa, NULL, spec); + break; + case RTE_FLOW_ACTION_TYPE_VF: + SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_VF, + bundle->actions_mask); + rc = sfc_mae_rule_parse_action_pf_vf(sa, action->conf, spec); + break; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL, -- 2.20.1