net/bnxt: fix speed autonegotiation
[dpdk.git] / drivers / net / sfc / sfc_mae.c
index 455744c..f9b0a60 100644 (file)
@@ -23,7 +23,7 @@
 #include "sfc_service.h"
 
 static int
-sfc_mae_assign_entity_mport(struct sfc_adapter *sa,
+sfc_mae_assign_ethdev_mport(struct sfc_adapter *sa,
                            efx_mport_sel_t *mportp)
 {
        const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
@@ -32,6 +32,35 @@ sfc_mae_assign_entity_mport(struct sfc_adapter *sa,
                                              mportp);
 }
 
+static int
+sfc_mae_assign_entity_mport(struct sfc_adapter *sa,
+                           efx_mport_sel_t *mportp)
+{
+       const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+       int rc = 0;
+
+       if (encp->enc_mae_admin) {
+               /*
+                * This ethdev sits on MAE admin PF. The represented
+                * entity is the network port assigned to that PF.
+                */
+               rc = efx_mae_mport_by_phy_port(encp->enc_assigned_port, mportp);
+       } else {
+               /*
+                * This ethdev sits on unprivileged PF / VF. The entity
+                * represented by the ethdev can change dynamically
+                * as MAE admin changes default traffic rules.
+                *
+                * For the sake of simplicity, do not fill in the m-port
+                * and assume that flow rules should not be allowed to
+                * reference the entity represented by this ethdev.
+                */
+               efx_mae_mport_invalid(mportp);
+       }
+
+       return rc;
+}
+
 static int
 sfc_mae_counter_registry_init(struct sfc_mae_counter_registry *registry,
                              uint32_t nb_counters_max)
@@ -184,6 +213,7 @@ sfc_mae_attach(struct sfc_adapter *sa)
        struct sfc_adapter_shared * const sas = sfc_sa2shared(sa);
        struct sfc_mae_switch_port_request switch_port_request = {0};
        const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+       efx_mport_sel_t ethdev_mport;
        efx_mport_sel_t entity_mport;
        struct sfc_mae *mae = &sa->mae;
        struct sfc_mae_bounce_eh *bounce_eh = &mae->bounce_eh;
@@ -218,6 +248,11 @@ sfc_mae_attach(struct sfc_adapter *sa)
                }
        }
 
+       sfc_log_init(sa, "assign ethdev MPORT");
+       rc = sfc_mae_assign_ethdev_mport(sa, &ethdev_mport);
+       if (rc != 0)
+               goto fail_mae_assign_ethdev_mport;
+
        sfc_log_init(sa, "assign entity MPORT");
        rc = sfc_mae_assign_entity_mport(sa, &entity_mport);
        if (rc != 0)
@@ -230,9 +265,8 @@ sfc_mae_attach(struct sfc_adapter *sa)
 
        sfc_log_init(sa, "assign RTE switch port");
        switch_port_request.type = SFC_MAE_SWITCH_PORT_INDEPENDENT;
+       switch_port_request.ethdev_mportp = &ethdev_mport;
        switch_port_request.entity_mportp = &entity_mport;
-       /* RTE ethdev MPORT matches that of the entity for independent ports. */
-       switch_port_request.ethdev_mportp = &entity_mport;
        switch_port_request.ethdev_port_id = sas->port_id;
        switch_port_request.port_data.indep.mae_admin =
                encp->enc_mae_admin == B_TRUE;
@@ -256,6 +290,7 @@ sfc_mae_attach(struct sfc_adapter *sa)
        }
 
        TAILQ_INIT(&mae->outer_rules);
+       TAILQ_INIT(&mae->mac_addrs);
        TAILQ_INIT(&mae->encap_headers);
        TAILQ_INIT(&mae->action_sets);
 
@@ -272,6 +307,7 @@ fail_mae_alloc_bounce_eh:
 fail_mae_assign_switch_port:
 fail_mae_assign_switch_domain:
 fail_mae_assign_entity_mport:
+fail_mae_assign_ethdev_mport:
        if (encp->enc_mae_admin)
                sfc_mae_counter_registry_fini(&mae->counter_registry);
 
@@ -471,6 +507,189 @@ sfc_mae_outer_rule_disable(struct sfc_adapter *sa,
        --(fw_rsrc->refcnt);
 }
 
+static struct sfc_mae_mac_addr *
+sfc_mae_mac_addr_attach(struct sfc_adapter *sa,
+                       const uint8_t addr_bytes[EFX_MAC_ADDR_LEN])
+{
+       struct sfc_mae_mac_addr *mac_addr;
+       struct sfc_mae *mae = &sa->mae;
+
+       SFC_ASSERT(sfc_adapter_is_locked(sa));
+
+       TAILQ_FOREACH(mac_addr, &mae->mac_addrs, entries) {
+               if (memcmp(mac_addr->addr_bytes, addr_bytes,
+                          EFX_MAC_ADDR_LEN) == 0) {
+                       sfc_dbg(sa, "attaching to mac_addr=%p", mac_addr);
+                       ++(mac_addr->refcnt);
+                       return mac_addr;
+               }
+       }
+
+       return NULL;
+}
+
+static int
+sfc_mae_mac_addr_add(struct sfc_adapter *sa,
+                    const uint8_t addr_bytes[EFX_MAC_ADDR_LEN],
+                    struct sfc_mae_mac_addr **mac_addrp)
+{
+       struct sfc_mae_mac_addr *mac_addr;
+       struct sfc_mae *mae = &sa->mae;
+
+       SFC_ASSERT(sfc_adapter_is_locked(sa));
+
+       mac_addr = rte_zmalloc("sfc_mae_mac_addr", sizeof(*mac_addr), 0);
+       if (mac_addr == NULL)
+               return ENOMEM;
+
+       rte_memcpy(mac_addr->addr_bytes, addr_bytes, EFX_MAC_ADDR_LEN);
+
+       mac_addr->refcnt = 1;
+       mac_addr->fw_rsrc.mac_id.id = EFX_MAE_RSRC_ID_INVALID;
+
+       TAILQ_INSERT_TAIL(&mae->mac_addrs, mac_addr, entries);
+
+       *mac_addrp = mac_addr;
+
+       sfc_dbg(sa, "added mac_addr=%p", mac_addr);
+
+       return 0;
+}
+
+static void
+sfc_mae_mac_addr_del(struct sfc_adapter *sa, struct sfc_mae_mac_addr *mac_addr)
+{
+       struct sfc_mae *mae = &sa->mae;
+
+       if (mac_addr == NULL)
+               return;
+
+       SFC_ASSERT(sfc_adapter_is_locked(sa));
+       SFC_ASSERT(mac_addr->refcnt != 0);
+
+       --(mac_addr->refcnt);
+
+       if (mac_addr->refcnt != 0)
+               return;
+
+       if (mac_addr->fw_rsrc.mac_id.id != EFX_MAE_RSRC_ID_INVALID ||
+           mac_addr->fw_rsrc.refcnt != 0) {
+               sfc_err(sa, "deleting mac_addr=%p abandons its FW resource: MAC_ID=0x%08x, refcnt=%u",
+                       mac_addr, mac_addr->fw_rsrc.mac_id.id,
+                       mac_addr->fw_rsrc.refcnt);
+       }
+
+       TAILQ_REMOVE(&mae->mac_addrs, mac_addr, entries);
+       rte_free(mac_addr);
+
+       sfc_dbg(sa, "deleted mac_addr=%p", mac_addr);
+}
+
+enum sfc_mae_mac_addr_type {
+       SFC_MAE_MAC_ADDR_DST,
+       SFC_MAE_MAC_ADDR_SRC
+};
+
+static int
+sfc_mae_mac_addr_enable(struct sfc_adapter *sa,
+                       struct sfc_mae_mac_addr *mac_addr,
+                       enum sfc_mae_mac_addr_type type,
+                       efx_mae_actions_t *aset_spec)
+{
+       struct sfc_mae_fw_rsrc *fw_rsrc;
+       int rc = 0;
+
+       if (mac_addr == NULL)
+               return 0;
+
+       SFC_ASSERT(sfc_adapter_is_locked(sa));
+
+       fw_rsrc = &mac_addr->fw_rsrc;
+
+       if (fw_rsrc->refcnt == 0) {
+               SFC_ASSERT(fw_rsrc->mac_id.id == EFX_MAE_RSRC_ID_INVALID);
+
+               rc = efx_mae_mac_addr_alloc(sa->nic, mac_addr->addr_bytes,
+                                           &fw_rsrc->mac_id);
+               if (rc != 0) {
+                       sfc_err(sa, "failed to enable mac_addr=%p: %s",
+                               mac_addr, strerror(rc));
+                       return rc;
+               }
+       }
+
+       switch (type) {
+       case SFC_MAE_MAC_ADDR_DST:
+               rc = efx_mae_action_set_fill_in_dst_mac_id(aset_spec,
+                                                          &fw_rsrc->mac_id);
+               break;
+       case SFC_MAE_MAC_ADDR_SRC:
+               rc = efx_mae_action_set_fill_in_src_mac_id(aset_spec,
+                                                          &fw_rsrc->mac_id);
+               break;
+       default:
+               rc = EINVAL;
+               break;
+       }
+
+       if (rc != 0) {
+               if (fw_rsrc->refcnt == 0) {
+                       (void)efx_mae_mac_addr_free(sa->nic, &fw_rsrc->mac_id);
+                       fw_rsrc->mac_id.id = EFX_MAE_RSRC_ID_INVALID;
+               }
+
+               sfc_err(sa, "cannot fill in MAC address entry ID: %s",
+                       strerror(rc));
+
+               return rc;
+       }
+
+       if (fw_rsrc->refcnt == 0) {
+               sfc_dbg(sa, "enabled mac_addr=%p: MAC_ID=0x%08x",
+                       mac_addr, fw_rsrc->mac_id.id);
+       }
+
+       ++(fw_rsrc->refcnt);
+
+       return 0;
+}
+
+static void
+sfc_mae_mac_addr_disable(struct sfc_adapter *sa,
+                        struct sfc_mae_mac_addr *mac_addr)
+{
+       struct sfc_mae_fw_rsrc *fw_rsrc;
+       int rc;
+
+       if (mac_addr == NULL)
+               return;
+
+       SFC_ASSERT(sfc_adapter_is_locked(sa));
+
+       fw_rsrc = &mac_addr->fw_rsrc;
+
+       if (fw_rsrc->mac_id.id == EFX_MAE_RSRC_ID_INVALID ||
+           fw_rsrc->refcnt == 0) {
+               sfc_err(sa, "failed to disable mac_addr=%p: already disabled; MAC_ID=0x%08x, refcnt=%u",
+                       mac_addr, fw_rsrc->mac_id.id, fw_rsrc->refcnt);
+               return;
+       }
+
+       if (fw_rsrc->refcnt == 1) {
+               rc = efx_mae_mac_addr_free(sa->nic, &fw_rsrc->mac_id);
+               if (rc == 0) {
+                       sfc_dbg(sa, "disabled mac_addr=%p with MAC_ID=0x%08x",
+                               mac_addr, fw_rsrc->mac_id.id);
+               } else {
+                       sfc_err(sa, "failed to disable mac_addr=%p with MAC_ID=0x%08x: %s",
+                               mac_addr, fw_rsrc->mac_id.id, strerror(rc));
+               }
+               fw_rsrc->mac_id.id = EFX_MAE_RSRC_ID_INVALID;
+       }
+
+       --(fw_rsrc->refcnt);
+}
+
 static struct sfc_mae_encap_header *
 sfc_mae_encap_header_attach(struct sfc_adapter *sa,
                            const struct sfc_mae_bounce_eh *bounce_eh)
@@ -717,25 +936,39 @@ sfc_mae_counters_disable(struct sfc_adapter *sa,
        return sfc_mae_counter_disable(sa, &counters[0]);
 }
 
+struct sfc_mae_aset_ctx {
+       uint64_t                        *ft_group_hit_counter;
+       struct sfc_mae_encap_header     *encap_header;
+       struct sfc_flow_tunnel          *counter_ft;
+       unsigned int                    n_counters;
+       struct sfc_mae_mac_addr         *dst_mac;
+       struct sfc_mae_mac_addr         *src_mac;
+
+       efx_mae_actions_t               *spec;
+};
+
 static struct sfc_mae_action_set *
 sfc_mae_action_set_attach(struct sfc_adapter *sa,
-                         const struct sfc_mae_encap_header *encap_header,
-                         unsigned int n_count,
-                         const efx_mae_actions_t *spec)
+                         const struct sfc_mae_aset_ctx *ctx)
 {
        struct sfc_mae_action_set *action_set;
        struct sfc_mae *mae = &sa->mae;
 
        SFC_ASSERT(sfc_adapter_is_locked(sa));
 
+       /*
+        * Shared counters are not supported, hence, action
+        * sets with counters are not attachable.
+        */
+       if (ctx->n_counters != 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)) {
+               if (action_set->encap_header == ctx->encap_header &&
+                   action_set->dst_mac_addr == ctx->dst_mac &&
+                   action_set->src_mac_addr == ctx->src_mac &&
+                   efx_mae_action_set_specs_equal(action_set->spec,
+                                                  ctx->spec)) {
                        sfc_dbg(sa, "attaching to action_set=%p", action_set);
                        ++(action_set->refcnt);
                        return action_set;
@@ -748,11 +981,7 @@ sfc_mae_action_set_attach(struct sfc_adapter *sa,
 static int
 sfc_mae_action_set_add(struct sfc_adapter *sa,
                       const struct rte_flow_action actions[],
-                      efx_mae_actions_t *spec,
-                      struct sfc_mae_encap_header *encap_header,
-                      uint64_t *ft_group_hit_counter,
-                      struct sfc_flow_tunnel *ft,
-                      unsigned int n_counters,
+                      const struct sfc_mae_aset_ctx *ctx,
                       struct sfc_mae_action_set **action_setp)
 {
        struct sfc_mae_action_set *action_set;
@@ -767,30 +996,30 @@ sfc_mae_action_set_add(struct sfc_adapter *sa,
                return ENOMEM;
        }
 
-       if (n_counters > 0) {
+       if (ctx->n_counters > 0) {
                const struct rte_flow_action *action;
 
                action_set->counters = rte_malloc("sfc_mae_counter_ids",
-                       sizeof(action_set->counters[0]) * n_counters, 0);
+                       sizeof(action_set->counters[0]) * ctx->n_counters, 0);
                if (action_set->counters == NULL) {
                        rte_free(action_set);
                        sfc_err(sa, "failed to alloc counters");
                        return ENOMEM;
                }
 
-               for (i = 0; i < n_counters; ++i) {
+               for (i = 0; i < ctx->n_counters; ++i) {
                        action_set->counters[i].rte_id_valid = B_FALSE;
                        action_set->counters[i].mae_id.id =
                                EFX_MAE_RSRC_ID_INVALID;
 
                        action_set->counters[i].ft_group_hit_counter =
-                               ft_group_hit_counter;
-                       action_set->counters[i].ft = ft;
+                               ctx->ft_group_hit_counter;
+                       action_set->counters[i].ft = ctx->counter_ft;
                }
 
                for (action = actions, i = 0;
-                    action->type != RTE_FLOW_ACTION_TYPE_END && i < n_counters;
-                    ++action) {
+                    action->type != RTE_FLOW_ACTION_TYPE_END &&
+                    i < ctx->n_counters; ++action) {
                        const struct rte_flow_action_count *conf;
 
                        if (action->type != RTE_FLOW_ACTION_TYPE_COUNT)
@@ -802,12 +1031,14 @@ sfc_mae_action_set_add(struct sfc_adapter *sa,
                        action_set->counters[i].rte_id = conf->id;
                        i++;
                }
-               action_set->n_counters = n_counters;
+               action_set->n_counters = ctx->n_counters;
        }
 
        action_set->refcnt = 1;
-       action_set->spec = spec;
-       action_set->encap_header = encap_header;
+       action_set->spec = ctx->spec;
+       action_set->encap_header = ctx->encap_header;
+       action_set->dst_mac_addr = ctx->dst_mac;
+       action_set->src_mac_addr = ctx->src_mac;
 
        action_set->fw_rsrc.aset_id.id = EFX_MAE_RSRC_ID_INVALID;
 
@@ -843,6 +1074,8 @@ sfc_mae_action_set_del(struct sfc_adapter *sa,
 
        efx_mae_action_set_spec_fini(sa->nic, action_set->spec);
        sfc_mae_encap_header_del(sa, action_set->encap_header);
+       sfc_mae_mac_addr_del(sa, action_set->dst_mac_addr);
+       sfc_mae_mac_addr_del(sa, action_set->src_mac_addr);
        if (action_set->n_counters > 0) {
                SFC_ASSERT(action_set->n_counters == 1);
                SFC_ASSERT(action_set->counters[0].mae_id.id ==
@@ -860,6 +1093,8 @@ sfc_mae_action_set_enable(struct sfc_adapter *sa,
                          struct sfc_mae_action_set *action_set)
 {
        struct sfc_mae_encap_header *encap_header = action_set->encap_header;
+       struct sfc_mae_mac_addr *dst_mac_addr = action_set->dst_mac_addr;
+       struct sfc_mae_mac_addr *src_mac_addr = action_set->src_mac_addr;
        struct sfc_mae_counter_id *counters = action_set->counters;
        struct sfc_mae_fw_rsrc *fw_rsrc = &action_set->fw_rsrc;
        int rc;
@@ -870,10 +1105,27 @@ sfc_mae_action_set_enable(struct sfc_adapter *sa,
                SFC_ASSERT(fw_rsrc->aset_id.id == EFX_MAE_RSRC_ID_INVALID);
                SFC_ASSERT(action_set->spec != NULL);
 
+               rc = sfc_mae_mac_addr_enable(sa, dst_mac_addr,
+                                            SFC_MAE_MAC_ADDR_DST,
+                                            action_set->spec);
+               if (rc != 0)
+                       return rc;
+
+               rc = sfc_mae_mac_addr_enable(sa, src_mac_addr,
+                                            SFC_MAE_MAC_ADDR_SRC,
+                                            action_set->spec);
+               if (rc != 0) {
+                       sfc_mae_mac_addr_disable(sa, dst_mac_addr);
+                       return rc;
+               }
+
                rc = sfc_mae_encap_header_enable(sa, encap_header,
                                                 action_set->spec);
-               if (rc != 0)
+               if (rc != 0) {
+                       sfc_mae_mac_addr_disable(sa, src_mac_addr);
+                       sfc_mae_mac_addr_disable(sa, dst_mac_addr);
                        return rc;
+               }
 
                rc = sfc_mae_counters_enable(sa, counters,
                                             action_set->n_counters,
@@ -883,6 +1135,8 @@ sfc_mae_action_set_enable(struct sfc_adapter *sa,
                                action_set->n_counters, rte_strerror(rc));
 
                        sfc_mae_encap_header_disable(sa, encap_header);
+                       sfc_mae_mac_addr_disable(sa, src_mac_addr);
+                       sfc_mae_mac_addr_disable(sa, dst_mac_addr);
                        return rc;
                }
 
@@ -895,6 +1149,8 @@ sfc_mae_action_set_enable(struct sfc_adapter *sa,
                        (void)sfc_mae_counters_disable(sa, counters,
                                                       action_set->n_counters);
                        sfc_mae_encap_header_disable(sa, encap_header);
+                       sfc_mae_mac_addr_disable(sa, src_mac_addr);
+                       sfc_mae_mac_addr_disable(sa, dst_mac_addr);
                        return rc;
                }
 
@@ -942,6 +1198,8 @@ sfc_mae_action_set_disable(struct sfc_adapter *sa,
                }
 
                sfc_mae_encap_header_disable(sa, action_set->encap_header);
+               sfc_mae_mac_addr_disable(sa, action_set->src_mac_addr);
+               sfc_mae_mac_addr_disable(sa, action_set->dst_mac_addr);
        }
 
        --(fw_rsrc->refcnt);
@@ -951,18 +1209,12 @@ void
 sfc_mae_flow_cleanup(struct sfc_adapter *sa,
                     struct rte_flow *flow)
 {
-       struct sfc_flow_spec *spec;
        struct sfc_flow_spec_mae *spec_mae;
 
        if (flow == NULL)
                return;
 
-       spec = &flow->spec;
-
-       if (spec == NULL)
-               return;
-
-       spec_mae = &spec->mae;
+       spec_mae = &flow->spec.mae;
 
        if (spec_mae->ft != NULL) {
                if (spec_mae->ft_rule_type == SFC_FT_RULE_JUMP)
@@ -1276,12 +1528,12 @@ sfc_mae_rule_parse_item_port_id(const struct rte_flow_item *item,
                                          "The port ID is too large");
        }
 
-       rc = sfc_mae_switch_port_by_ethdev(ctx_mae->sa->mae.switch_domain_id,
-                                          spec->id, &mport_sel);
+       rc = sfc_mae_switch_get_ethdev_mport(ctx_mae->sa->mae.switch_domain_id,
+                                            spec->id, &mport_sel);
        if (rc != 0) {
                return rte_flow_error_set(error, rc,
                                RTE_FLOW_ERROR_TYPE_ITEM, item,
-                               "Can't find RTE ethdev by the port ID");
+                               "Can't get m-port for the given ethdev");
        }
 
        rc = efx_mae_match_spec_mport_set(ctx_mae->match_spec,
@@ -1298,9 +1550,9 @@ sfc_mae_rule_parse_item_port_id(const struct rte_flow_item *item,
 }
 
 static int
-sfc_mae_rule_parse_item_port_representor(const struct rte_flow_item *item,
-                                        struct sfc_flow_parse_ctx *ctx,
-                                        struct rte_flow_error *error)
+sfc_mae_rule_parse_item_ethdev_based(const struct rte_flow_item *item,
+                                    struct sfc_flow_parse_ctx *ctx,
+                                    struct rte_flow_error *error)
 {
        struct sfc_mae_parse_ctx *ctx_mae = ctx->mae;
        const struct rte_flow_item_ethdev supp_mask = {
@@ -1328,20 +1580,38 @@ sfc_mae_rule_parse_item_port_representor(const struct rte_flow_item *item,
        if (mask->port_id != supp_mask.port_id) {
                return rte_flow_error_set(error, EINVAL,
                                RTE_FLOW_ERROR_TYPE_ITEM, item,
-                               "Bad mask in the PORT_REPRESENTOR pattern item");
+                               "Bad mask in the ethdev-based pattern item");
        }
 
        /* If "spec" is not set, could be any port ID */
        if (spec == NULL)
                return 0;
 
-       rc = sfc_mae_switch_port_by_ethdev(
-                       ctx_mae->sa->mae.switch_domain_id,
-                       spec->port_id, &mport_sel);
-       if (rc != 0) {
-               return rte_flow_error_set(error, rc,
+       switch (item->type) {
+       case RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR:
+               rc = sfc_mae_switch_get_ethdev_mport(
+                               ctx_mae->sa->mae.switch_domain_id,
+                               spec->port_id, &mport_sel);
+               if (rc != 0) {
+                       return rte_flow_error_set(error, rc,
+                                       RTE_FLOW_ERROR_TYPE_ITEM, item,
+                                       "Can't get m-port for the given ethdev");
+               }
+               break;
+       case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT:
+               rc = sfc_mae_switch_get_entity_mport(
+                               ctx_mae->sa->mae.switch_domain_id,
+                               spec->port_id, &mport_sel);
+               if (rc != 0) {
+                       return rte_flow_error_set(error, rc,
+                                       RTE_FLOW_ERROR_TYPE_ITEM, item,
+                                       "Can't get m-port for the given ethdev");
+               }
+               break;
+       default:
+               return rte_flow_error_set(error, EINVAL,
                                RTE_FLOW_ERROR_TYPE_ITEM, item,
-                               "Can't find RTE ethdev by the port ID");
+                               "Unsupported ethdev-based flow item");
        }
 
        rc = efx_mae_match_spec_mport_set(ctx_mae->match_spec,
@@ -2294,7 +2564,19 @@ static const struct sfc_flow_item sfc_flow_items[] = {
                .prev_layer = SFC_FLOW_ITEM_ANY_LAYER,
                .layer = SFC_FLOW_ITEM_ANY_LAYER,
                .ctx_type = SFC_FLOW_PARSE_CTX_MAE,
-               .parse = sfc_mae_rule_parse_item_port_representor,
+               .parse = sfc_mae_rule_parse_item_ethdev_based,
+       },
+       {
+               .type = RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT,
+               .name = "REPRESENTED_PORT",
+               /*
+                * In terms of RTE flow, this item is a META one,
+                * and its position in the pattern is don't care.
+                */
+               .prev_layer = SFC_FLOW_ITEM_ANY_LAYER,
+               .layer = SFC_FLOW_ITEM_ANY_LAYER,
+               .ctx_type = SFC_FLOW_PARSE_CTX_MAE,
+               .parse = sfc_mae_rule_parse_item_ethdev_based,
        },
        {
                .type = RTE_FLOW_ITEM_TYPE_PHY_PORT,
@@ -2824,6 +3106,54 @@ fail_priority_check:
        return rc;
 }
 
+static int
+sfc_mae_rule_parse_action_set_mac(struct sfc_adapter *sa,
+                                 enum sfc_mae_mac_addr_type type,
+                                 const struct rte_flow_action_set_mac *conf,
+                                 struct sfc_mae_aset_ctx *ctx,
+                                 struct rte_flow_error *error)
+{
+       struct sfc_mae_mac_addr **mac_addrp;
+       int rc;
+
+       if (conf == NULL) {
+               return rte_flow_error_set(error, EINVAL,
+                               RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL,
+                               "the MAC address entry definition is NULL");
+       }
+
+       switch (type) {
+       case SFC_MAE_MAC_ADDR_DST:
+               rc = efx_mae_action_set_populate_set_dst_mac(ctx->spec);
+               mac_addrp = &ctx->dst_mac;
+               break;
+       case SFC_MAE_MAC_ADDR_SRC:
+               rc = efx_mae_action_set_populate_set_src_mac(ctx->spec);
+               mac_addrp = &ctx->src_mac;
+               break;
+       default:
+               rc = EINVAL;
+               break;
+       }
+
+       if (rc != 0)
+               goto error;
+
+       *mac_addrp = sfc_mae_mac_addr_attach(sa, conf->mac_addr);
+       if (*mac_addrp != NULL)
+               return 0;
+
+       rc = sfc_mae_mac_addr_add(sa, conf->mac_addr, mac_addrp);
+       if (rc != 0)
+               goto error;
+
+       return 0;
+
+error:
+       return rte_flow_error_set(error, rc, RTE_FLOW_ERROR_TYPE_ACTION,
+                                 NULL, "failed to request set MAC action");
+}
+
 /*
  * An action supported by MAE may correspond to a bundle of RTE flow actions,
  * in example, VLAN_PUSH = OF_PUSH_VLAN + OF_VLAN_SET_VID + OF_VLAN_SET_PCP.
@@ -3406,10 +3736,10 @@ sfc_mae_rule_parse_action_port_id(struct sfc_adapter *sa,
 
        port_id = (conf->original != 0) ? sas->port_id : conf->id;
 
-       rc = sfc_mae_switch_port_by_ethdev(mae->switch_domain_id,
-                                          port_id, &mport);
+       rc = sfc_mae_switch_get_ethdev_mport(mae->switch_domain_id,
+                                            port_id, &mport);
        if (rc != 0) {
-               sfc_err(sa, "failed to find MAE switch port SW entry for RTE ethdev port %u: %s",
+               sfc_err(sa, "failed to get m-port for the given ethdev (port_id=%u): %s",
                        port_id, strerror(rc));
                return rc;
        }
@@ -3423,19 +3753,78 @@ 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_SET_MAC_DST] = "SET_MAC_DST",
+       [RTE_FLOW_ACTION_TYPE_SET_MAC_SRC] = "SET_MAC_SRC",
+       [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",
 };
@@ -3445,11 +3834,12 @@ sfc_mae_rule_parse_action(struct sfc_adapter *sa,
                          const struct rte_flow_action *action,
                          const struct sfc_flow_spec_mae *spec_mae,
                          struct sfc_mae_actions_bundle *bundle,
-                         efx_mae_actions_t *spec,
+                         struct sfc_mae_aset_ctx *ctx,
                          struct rte_flow_error *error)
 {
        const struct sfc_mae_outer_rule *outer_rule = spec_mae->outer_rule;
        const uint64_t rx_metadata = sa->negotiated_rx_metadata;
+       efx_mae_actions_t *spec = ctx->spec;
        bool custom_error = B_FALSE;
        int rc = 0;
 
@@ -3468,6 +3858,30 @@ 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_SET_MAC_DST:
+               SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
+                                      bundle->actions_mask);
+               rc = sfc_mae_rule_parse_action_set_mac(sa, SFC_MAE_MAC_ADDR_DST,
+                                                      action->conf, ctx,
+                                                      error);
+               custom_error = B_TRUE;
+               break;
+       case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC:
+               SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
+                                      bundle->actions_mask);
+               rc = sfc_mae_rule_parse_action_set_mac(sa, SFC_MAE_MAC_ADDR_SRC,
+                                                      action->conf, ctx,
+                                                      error);
+               custom_error = B_TRUE;
+               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);
@@ -3544,6 +3958,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);
@@ -3608,14 +4034,10 @@ sfc_mae_rule_parse_actions(struct sfc_adapter *sa,
                           struct sfc_flow_spec_mae *spec_mae,
                           struct rte_flow_error *error)
 {
-       struct sfc_mae_encap_header *encap_header = NULL;
        struct sfc_mae_actions_bundle bundle = {0};
-       struct sfc_flow_tunnel *counter_ft = NULL;
-       uint64_t *ft_group_hit_counter = NULL;
        const struct rte_flow_action *action;
+       struct sfc_mae_aset_ctx ctx = {0};
        struct sfc_mae *mae = &sa->mae;
-       unsigned int n_count = 0;
-       efx_mae_actions_t *spec;
        int rc;
 
        rte_errno = 0;
@@ -3626,34 +4048,35 @@ sfc_mae_rule_parse_actions(struct sfc_adapter *sa,
                                "NULL actions");
        }
 
-       rc = efx_mae_action_set_spec_init(sa->nic, &spec);
+       rc = efx_mae_action_set_spec_init(sa->nic, &ctx.spec);
        if (rc != 0)
                goto fail_action_set_spec_init;
 
        for (action = actions;
             action->type != RTE_FLOW_ACTION_TYPE_END; ++action) {
                if (action->type == RTE_FLOW_ACTION_TYPE_COUNT)
-                       ++n_count;
+                       ++(ctx.n_counters);
        }
 
        if (spec_mae->ft_rule_type == SFC_FT_RULE_GROUP) {
                /* JUMP rules don't decapsulate packets. GROUP rules do. */
-               rc = efx_mae_action_set_populate_decap(spec);
+               rc = efx_mae_action_set_populate_decap(ctx.spec);
                if (rc != 0)
                        goto fail_enforce_ft_decap;
 
-               if (n_count == 0 && sfc_mae_counter_stream_enabled(sa)) {
+               if (ctx.n_counters == 0 &&
+                   sfc_mae_counter_stream_enabled(sa)) {
                        /*
                         * The user opted not to use action COUNT in this rule,
                         * but the counter should be enabled implicitly because
                         * packets hitting this rule contribute to the tunnel's
                         * total number of hits. See sfc_mae_counter_get().
                         */
-                       rc = efx_mae_action_set_populate_count(spec);
+                       rc = efx_mae_action_set_populate_count(ctx.spec);
                        if (rc != 0)
                                goto fail_enforce_ft_count;
 
-                       n_count = 1;
+                       ctx.n_counters = 1;
                }
        }
 
@@ -3662,27 +4085,30 @@ sfc_mae_rule_parse_actions(struct sfc_adapter *sa,
 
        for (action = actions;
             action->type != RTE_FLOW_ACTION_TYPE_END; ++action) {
-               rc = sfc_mae_actions_bundle_sync(action, &bundle, spec, error);
+               rc = sfc_mae_actions_bundle_sync(action, &bundle,
+                                                ctx.spec, error);
                if (rc != 0)
                        goto fail_rule_parse_action;
 
                rc = sfc_mae_rule_parse_action(sa, action, spec_mae,
-                                              &bundle, spec, error);
+                                              &bundle, &ctx, error);
                if (rc != 0)
                        goto fail_rule_parse_action;
        }
 
-       rc = sfc_mae_actions_bundle_sync(action, &bundle, spec, error);
+       rc = sfc_mae_actions_bundle_sync(action, &bundle, ctx.spec, error);
        if (rc != 0)
                goto fail_rule_parse_action;
 
-       rc = sfc_mae_process_encap_header(sa, &mae->bounce_eh, &encap_header);
+       rc = sfc_mae_process_encap_header(sa, &mae->bounce_eh,
+                                         &ctx.encap_header);
        if (rc != 0)
                goto fail_process_encap_header;
 
-       if (n_count > 1) {
+       if (ctx.n_counters > 1) {
                rc = ENOTSUP;
-               sfc_err(sa, "too many count actions requested: %u", n_count);
+               sfc_err(sa, "too many count actions requested: %u",
+                       ctx.n_counters);
                goto fail_nb_count;
        }
 
@@ -3691,11 +4117,11 @@ sfc_mae_rule_parse_actions(struct sfc_adapter *sa,
                break;
        case SFC_FT_RULE_JUMP:
                /* Workaround. See sfc_flow_parse_rte_to_mae() */
-               rc = sfc_mae_rule_parse_action_pf_vf(sa, NULL, spec);
+               rc = sfc_mae_rule_parse_action_pf_vf(sa, NULL, ctx.spec);
                if (rc != 0)
                        goto fail_workaround_jump_delivery;
 
-               counter_ft = spec_mae->ft;
+               ctx.counter_ft = spec_mae->ft;
                break;
        case SFC_FT_RULE_GROUP:
                /*
@@ -3704,25 +4130,22 @@ sfc_mae_rule_parse_actions(struct sfc_adapter *sa,
                 * packets. The user may have provided their own action
                 * MARK above, so don't check the return value here.
                 */
-               (void)efx_mae_action_set_populate_mark(spec, 0);
+               (void)efx_mae_action_set_populate_mark(ctx.spec, 0);
 
-               ft_group_hit_counter = &spec_mae->ft->group_hit_counter;
+               ctx.ft_group_hit_counter = &spec_mae->ft->group_hit_counter;
                break;
        default:
                SFC_ASSERT(B_FALSE);
        }
 
-       spec_mae->action_set = sfc_mae_action_set_attach(sa, encap_header,
-                                                        n_count, spec);
+       spec_mae->action_set = sfc_mae_action_set_attach(sa, &ctx);
        if (spec_mae->action_set != NULL) {
-               sfc_mae_encap_header_del(sa, encap_header);
-               efx_mae_action_set_spec_fini(sa->nic, spec);
+               sfc_mae_encap_header_del(sa, ctx.encap_header);
+               efx_mae_action_set_spec_fini(sa->nic, ctx.spec);
                return 0;
        }
 
-       rc = sfc_mae_action_set_add(sa, actions, spec, encap_header,
-                                   ft_group_hit_counter, counter_ft, n_count,
-                                   &spec_mae->action_set);
+       rc = sfc_mae_action_set_add(sa, actions, &ctx, &spec_mae->action_set);
        if (rc != 0)
                goto fail_action_set_add;
 
@@ -3731,11 +4154,13 @@ sfc_mae_rule_parse_actions(struct sfc_adapter *sa,
 fail_action_set_add:
 fail_workaround_jump_delivery:
 fail_nb_count:
-       sfc_mae_encap_header_del(sa, encap_header);
+       sfc_mae_encap_header_del(sa, ctx.encap_header);
 
 fail_process_encap_header:
 fail_rule_parse_action:
-       efx_mae_action_set_spec_fini(sa->nic, spec);
+       sfc_mae_mac_addr_del(sa, ctx.src_mac);
+       sfc_mae_mac_addr_del(sa, ctx.dst_mac);
+       efx_mae_action_set_spec_fini(sa->nic, ctx.spec);
 
 fail_enforce_ft_count:
 fail_enforce_ft_decap: