net/sfc: support flow action drop in transfer rules
[dpdk.git] / drivers / net / sfc / sfc_mae.c
index 7d1a3b5..a5800ae 100644 (file)
@@ -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,21 @@ 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;
+       case RTE_FLOW_ACTION_TYPE_DROP:
+               SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_DROP,
+                                      bundle->actions_mask);
+               rc = efx_mae_action_set_populate_drop(spec);
+               break;
        default:
                return rte_flow_error_set(error, ENOTSUP,
                                RTE_FLOW_ERROR_TYPE_ACTION, NULL,