From: Ivan Malov Date: Tue, 20 Oct 2020 09:13:25 +0000 (+0100) Subject: net/sfc: support flow item port ID in transfer rules X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=33d96ca564cffac72cf73cc491b95db031a63182;p=dpdk.git net/sfc: support flow item port ID in transfer rules Add support for this flow item to MAE-specific RTE flow implementation. The DPDK port must not relate to a different physical device. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst index 1718bb1c1f..e372627a50 100644 --- a/doc/guides/nics/sfc_efx.rst +++ b/doc/guides/nics/sfc_efx.rst @@ -190,6 +190,8 @@ Supported actions (***non-transfer*** rules): Supported pattern items (***transfer*** rules): +- PORT_ID (cannot repeat; conflicts with other traffic source items) + - PHY_PORT (cannot repeat; conflicts with other traffic source items) - PF (cannot repeat; conflicts with other traffic source items) diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index f309efa2cf..14e6d33c55 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -260,6 +260,71 @@ sfc_mae_flow_cleanup(struct sfc_adapter *sa, efx_mae_match_spec_fini(sa->nic, spec_mae->match_spec); } +static int +sfc_mae_rule_parse_item_port_id(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_port_id supp_mask = { + .id = 0xffffffff, + }; + const void *def_mask = &rte_flow_item_port_id_mask; + const struct rte_flow_item_port_id *spec = NULL; + const struct rte_flow_item_port_id *mask = NULL; + efx_mport_sel_t mport_sel; + int rc; + + if (ctx_mae->match_mport_set) { + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Can't handle multiple traffic source items"); + } + + rc = sfc_flow_parse_init(item, + (const void **)&spec, (const void **)&mask, + (const void *)&supp_mask, def_mask, + sizeof(struct rte_flow_item_port_id), error); + if (rc != 0) + return rc; + + if (mask->id != supp_mask.id) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Bad mask in the PORT_ID pattern item"); + } + + /* If "spec" is not set, could be any port ID */ + if (spec == NULL) + return 0; + + if (spec->id > UINT16_MAX) { + return rte_flow_error_set(error, EOVERFLOW, + RTE_FLOW_ERROR_TYPE_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); + 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"); + } + + rc = efx_mae_match_spec_mport_set(ctx_mae->match_spec_action, + &mport_sel, NULL); + if (rc != 0) { + return rte_flow_error_set(error, rc, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Failed to set MPORT for the port ID"); + } + + ctx_mae->match_mport_set = B_TRUE; + + return 0; +} + static int sfc_mae_rule_parse_item_phy_port(const struct rte_flow_item *item, struct sfc_flow_parse_ctx *ctx, @@ -521,6 +586,17 @@ sfc_mae_rule_parse_item_eth(const struct rte_flow_item *item, } static const struct sfc_flow_item sfc_flow_items[] = { + { + .type = RTE_FLOW_ITEM_TYPE_PORT_ID, + /* + * 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_port_id, + }, { .type = RTE_FLOW_ITEM_TYPE_PHY_PORT, /*