[dpdk-dev] [PATCH 17/62] net/sfc: support flow item PHY PORT in MAE backend

Andrew Rybchenko arybchenko at solarflare.com
Tue Oct 20 10:47:44 CEST 2020


From: Ivan Malov <ivan.malov at oktetlabs.ru>

Add support for this flow item to MAE-specific RTE flow implementation.

Signed-off-by: Ivan Malov <ivan.malov at oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko at solarflare.com>
Reviewed-by: Andy Moreton <amoreton at xilinx.com>
---
 doc/guides/nics/sfc_efx.rst |  4 +++
 drivers/net/sfc/sfc_mae.c   | 69 +++++++++++++++++++++++++++++++++++++
 drivers/net/sfc/sfc_mae.h   |  1 +
 3 files changed, 74 insertions(+)

diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index 7a5aff79f9..b12e93180e 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -188,6 +188,10 @@ Supported actions (***non-transfer*** rules):
 
 - MARK (supported only with ef10_essb Rx datapath)
 
+Supported pattern items (***transfer*** rules):
+
+- PHY_PORT (cannot repeat; conflicts with other traffic source items)
+
 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 de2c6b26e4..87d2e15d29 100644
--- a/drivers/net/sfc/sfc_mae.c
+++ b/drivers/net/sfc/sfc_mae.c
@@ -163,7 +163,76 @@ 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_phy_port(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_phy_port supp_mask = {
+		.index = 0xffffffff,
+	};
+	const void *def_mask = &rte_flow_item_phy_port_mask;
+	const struct rte_flow_item_phy_port *spec = NULL;
+	const struct rte_flow_item_phy_port *mask = NULL;
+	efx_mport_sel_t mport_v;
+	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_phy_port), error);
+	if (rc != 0)
+		return rc;
+
+	if (mask->index != supp_mask.index) {
+		return rte_flow_error_set(error, EINVAL,
+				RTE_FLOW_ERROR_TYPE_ITEM, item,
+				"Bad mask in the PHY_PORT pattern item");
+	}
+
+	/* If "spec" is not set, could be any physical port */
+	if (spec == NULL)
+		return 0;
+
+	rc = efx_mae_mport_by_phy_port(spec->index, &mport_v);
+	if (rc != 0) {
+		return rte_flow_error_set(error, rc,
+				RTE_FLOW_ERROR_TYPE_ITEM, item,
+				"Failed to convert the PHY_PORT index");
+	}
+
+	rc = efx_mae_match_spec_mport_set(ctx_mae->match_spec_action,
+					  &mport_v, NULL);
+	if (rc != 0) {
+		return rte_flow_error_set(error, rc,
+				RTE_FLOW_ERROR_TYPE_ITEM, item,
+				"Failed to set MPORT for the PHY_PORT");
+	}
+
+	ctx_mae->match_mport_set = B_TRUE;
+
+	return 0;
+}
+
 static const struct sfc_flow_item sfc_flow_items[] = {
+	{
+		.type = RTE_FLOW_ITEM_TYPE_PHY_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_phy_port,
+	},
 };
 
 int
diff --git a/drivers/net/sfc/sfc_mae.h b/drivers/net/sfc/sfc_mae.h
index 5727962a0b..1ef582e82b 100644
--- a/drivers/net/sfc/sfc_mae.h
+++ b/drivers/net/sfc/sfc_mae.h
@@ -48,6 +48,7 @@ struct sfc_flow_spec;
 
 struct sfc_mae_parse_ctx {
 	efx_mae_match_spec_t		*match_spec_action;
+	bool				match_mport_set;
 };
 
 int sfc_mae_attach(struct sfc_adapter *sa);
-- 
2.17.1



More information about the dev mailing list