net/sfc: refine order of checks on MAE action set attach
[dpdk.git] / drivers / net / sfc / sfc_mae.c
index 8ec4036..73bedf5 100644 (file)
@@ -763,13 +763,15 @@ sfc_mae_action_set_attach(struct sfc_adapter *sa,
 
        SFC_ASSERT(sfc_adapter_is_locked(sa));
 
+       /*
+        * Shared counters are not supported, hence, action
+        * sets with counters are not attachable.
+        */
+       if (n_count != 0)
+               return NULL;
+
        TAILQ_FOREACH(action_set, &mae->action_sets, entries) {
-               /*
-                * Shared counters are not supported, hence action sets with
-                * COUNT are not attachable.
-                */
                if (action_set->encap_header == encap_header &&
-                   n_count == 0 &&
                    efx_mae_action_set_specs_equal(action_set->spec, spec)) {
                        sfc_dbg(sa, "attaching to action_set=%p", action_set);
                        ++(action_set->refcnt);
@@ -3488,19 +3490,76 @@ sfc_mae_rule_parse_action_port_id(struct sfc_adapter *sa,
        return rc;
 }
 
+static int
+sfc_mae_rule_parse_action_port_representor(struct sfc_adapter *sa,
+               const struct rte_flow_action_ethdev *conf,
+               efx_mae_actions_t *spec)
+{
+       struct sfc_mae *mae = &sa->mae;
+       efx_mport_sel_t mport;
+       int rc;
+
+       rc = sfc_mae_switch_get_ethdev_mport(mae->switch_domain_id,
+                                            conf->port_id, &mport);
+       if (rc != 0) {
+               sfc_err(sa, "failed to get m-port for the given ethdev (port_id=%u): %s",
+                       conf->port_id, strerror(rc));
+               return rc;
+       }
+
+       rc = efx_mae_action_set_populate_deliver(spec, &mport);
+       if (rc != 0) {
+               sfc_err(sa, "failed to request action DELIVER with m-port selector 0x%08x: %s",
+                       mport.sel, strerror(rc));
+       }
+
+       return rc;
+}
+
+static int
+sfc_mae_rule_parse_action_represented_port(struct sfc_adapter *sa,
+               const struct rte_flow_action_ethdev *conf,
+               efx_mae_actions_t *spec)
+{
+       struct sfc_mae *mae = &sa->mae;
+       efx_mport_sel_t mport;
+       int rc;
+
+       rc = sfc_mae_switch_get_entity_mport(mae->switch_domain_id,
+                                            conf->port_id, &mport);
+       if (rc != 0) {
+               sfc_err(sa, "failed to get m-port for the given ethdev (port_id=%u): %s",
+                       conf->port_id, strerror(rc));
+               return rc;
+       }
+
+       rc = efx_mae_action_set_populate_deliver(spec, &mport);
+       if (rc != 0) {
+               sfc_err(sa, "failed to request action DELIVER with m-port selector 0x%08x: %s",
+                       mport.sel, strerror(rc));
+       }
+
+       return rc;
+}
+
 static const char * const action_names[] = {
        [RTE_FLOW_ACTION_TYPE_VXLAN_DECAP] = "VXLAN_DECAP",
        [RTE_FLOW_ACTION_TYPE_OF_POP_VLAN] = "OF_POP_VLAN",
+       [RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL] = "OF_DEC_NW_TTL",
+       [RTE_FLOW_ACTION_TYPE_DEC_TTL] = "DEC_TTL",
        [RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN] = "OF_PUSH_VLAN",
        [RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID] = "OF_SET_VLAN_VID",
        [RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP] = "OF_SET_VLAN_PCP",
        [RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP] = "VXLAN_ENCAP",
+       [RTE_FLOW_ACTION_TYPE_COUNT] = "COUNT",
        [RTE_FLOW_ACTION_TYPE_FLAG] = "FLAG",
        [RTE_FLOW_ACTION_TYPE_MARK] = "MARK",
        [RTE_FLOW_ACTION_TYPE_PHY_PORT] = "PHY_PORT",
        [RTE_FLOW_ACTION_TYPE_PF] = "PF",
        [RTE_FLOW_ACTION_TYPE_VF] = "VF",
        [RTE_FLOW_ACTION_TYPE_PORT_ID] = "PORT_ID",
+       [RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR] = "PORT_REPRESENTOR",
+       [RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT] = "REPRESENTED_PORT",
        [RTE_FLOW_ACTION_TYPE_DROP] = "DROP",
        [RTE_FLOW_ACTION_TYPE_JUMP] = "JUMP",
 };
@@ -3533,6 +3592,14 @@ sfc_mae_rule_parse_action(struct sfc_adapter *sa,
                                       bundle->actions_mask);
                rc = efx_mae_action_set_populate_vlan_pop(spec);
                break;
+       case RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL:
+       case RTE_FLOW_ACTION_TYPE_DEC_TTL:
+               SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
+                                      bundle->actions_mask);
+               SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_DEC_TTL,
+                                      bundle->actions_mask);
+               rc = efx_mae_action_set_populate_decr_ip_ttl(spec);
+               break;
        case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN:
                SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
                                       bundle->actions_mask);
@@ -3609,6 +3676,18 @@ sfc_mae_rule_parse_action(struct sfc_adapter *sa,
                                       bundle->actions_mask);
                rc = sfc_mae_rule_parse_action_port_id(sa, action->conf, spec);
                break;
+       case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR:
+               SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
+                                      bundle->actions_mask);
+               rc = sfc_mae_rule_parse_action_port_representor(sa,
+                               action->conf, spec);
+               break;
+       case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT:
+               SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
+                                      bundle->actions_mask);
+               rc = sfc_mae_rule_parse_action_represented_port(sa,
+                               action->conf, spec);
+               break;
        case RTE_FLOW_ACTION_TYPE_DROP:
                SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_DROP,
                                       bundle->actions_mask);