Skip to contentSkip to conversation

net/mlx5: forbid direction attributes in transfer flow rules

PATCH In review Dariusz Sosnowski 2 participants 2 messages Nov 3, 2022 – Nov 6, 2022 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: forbid direction attributes in transfer flow rules

Since [1] flow API forbids usage of direction attributes in transfer flow rules. This patch adapts mlx5 PMD to this requirement.

From this patch, flow rule validation in mxl5 PMD will reject transfer flow rules with any of the direction attributes set
(i.e. 'ingress' or 'egress').
As a result flow rule can only have one of 'ingress', 'egress' or 'transfer' attributes set.

This patch also changes the following:

- Control flow rules used in FDB are 'transfer' only.
- Checks which assumed that 'transfer' can be used
with 'ingress' and 'egress' are reduced to just checking for direction attributes, since all attributes are exclusive.
- Flow rules for updating flow_tag are created for both ingress and transfer flow rules which have MARK action.
- Moves mlx5_flow_validate_attributes() function from generic flow implementation to legacy Verbs flow engine implementation, since it was used only there. Function is renamed accordingly. Also removes checking if E-Switch uses DV in that function, since if legacy Verbs flow engine is used, then that is always not the case.

[1] commit bd2a4d4b2e3a ("ethdev: forbid direction attribute in transfer flow rules")

---
 drivers/net/mlx5/mlx5_flow.c       | 59 +++---------------------------
 drivers/net/mlx5/mlx5_flow.h       |  3 --
 drivers/net/mlx5/mlx5_flow_dv.c    | 42 ++++++++-------------
 drivers/net/mlx5/mlx5_flow_verbs.c | 50 ++++++++++++++++++++++++-
 4 files changed, 71 insertions(+), 83 deletions(-)
drivers/net/mlx5/mlx5_flow.c +6 -53
index 8e7d649d15..921e419d05 100644
@@ -2299,53 +2299,6 @@ mlx5_validate_action_ct(struct rte_eth_dev *dev,
 	return 0;
 }
 
-/**
- * Verify the @p attributes will be correctly understood by the NIC and store
- * them in the @p flow if everything is correct.
- *
- * @param[in] dev
- *   Pointer to the Ethernet device structure.
- * @param[in] attributes
- *   Pointer to flow attributes
- * @param[out] error
- *   Pointer to error structure.
- *
- * @return
- *   0 on success, a negative errno value otherwise and rte_errno is set.
- */
-int
-mlx5_flow_validate_attributes(struct rte_eth_dev *dev,
-			      const struct rte_flow_attr *attributes,
-			      struct rte_flow_error *error)
-{
-	struct mlx5_priv *priv = dev->data->dev_private;
-	uint32_t priority_max = priv->sh->flow_max_priority - 1;
-
-	if (attributes->group)
-		return rte_flow_error_set(error, ENOTSUP,
-					  RTE_FLOW_ERROR_TYPE_ATTR_GROUP,
-					  NULL, "groups is not supported");
-	if (attributes->priority != MLX5_FLOW_LOWEST_PRIO_INDICATOR &&
-	    attributes->priority >= priority_max)
-		return rte_flow_error_set(error, ENOTSUP,
-					  RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
-					  NULL, "priority out of range");
-	if (attributes->egress)
-		return rte_flow_error_set(error, ENOTSUP,
-					  RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL,
-					  "egress is not supported");
-	if (attributes->transfer && !priv->sh->config.dv_esw_en)
-		return rte_flow_error_set(error, ENOTSUP,
-					  RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER,
-					  NULL, "transfer is not supported");
-	if (!attributes->ingress)
-		return rte_flow_error_set(error, EINVAL,
-					  RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
-					  NULL,
-					  "ingress attribute is mandatory");
-	return 0;
-}
-
 /**
  * Validate ICMP6 item.
  *
@@ -6342,7 +6295,7 @@ flow_create_split_metadata(struct rte_eth_dev *dev,
 			ret = -rte_errno;
 			goto exit;
 		}
-	} else if (attr->egress && !attr->transfer) {
+	} else if (attr->egress) {
 		/*
 		 * All the actions on NIC Tx should have a metadata register
 		 * copy action to copy reg_a from WQE to reg_c[meta]
@@ -7061,7 +7014,7 @@ flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,
 		    flow->drv_type < MLX5_FLOW_TYPE_MAX);
 	memset(rss_desc, 0, offsetof(struct mlx5_flow_rss_desc, queue));
 	/* RSS Action only works on NIC RX domain */
-	if (attr->ingress && !attr->transfer)
+	if (attr->ingress)
 		rss = flow_get_rss_action(dev, p_actions_rx);
 	if (rss) {
 		if (flow_rss_workspace_adjust(wks, rss_desc, rss->queue_num))
@@ -7159,11 +7112,11 @@ flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,
 	 * we might create the extra rte_flow for each unique
 	 * MARK/FLAG action ID.
 	 *
-	 * The table is updated for ingress Flows only, because
+	 * The table is updated for ingress and transfer flows only, because
 	 * the egress Flows belong to the different device and
 	 * copy table should be updated in peer NIC Rx domain.
 	 */
-	if (attr->ingress &&
+	if ((attr->ingress || attr->transfer) &&
 	    (external || attr->group != MLX5_FLOW_MREG_CP_TABLE_GROUP)) {
 		ret = flow_mreg_update_copy_table(dev, flow, actions, error);
 		if (ret)
@@ -7235,7 +7188,7 @@ mlx5_flow_create_esw_table_zero_flow(struct rte_eth_dev *dev)
 	const struct rte_flow_attr attr = {
 		.group = 0,
 		.priority = 0,
-		.ingress = 1,
+		.ingress = 0,
 		.egress = 0,
 		.transfer = 1,
 	};
@@ -7279,7 +7232,7 @@ mlx5_flow_create_devx_sq_miss_flow(struct rte_eth_dev *dev, uint32_t sq_num)
 	struct rte_flow_attr attr = {
 		.group = 0,
 		.priority = MLX5_FLOW_LOWEST_PRIO_INDICATOR,
-		.ingress = 1,
+		.ingress = 0,
 		.egress = 0,
 		.transfer = 1,
 	};
drivers/net/mlx5/mlx5_flow.h +0 -3
index da9b65d8fe..2398e44ea0 100644
@@ -2228,9 +2228,6 @@ int mlx5_flow_validate_action_rss(const struct rte_flow_action *action,
 int mlx5_flow_validate_action_default_miss(uint64_t action_flags,
 				const struct rte_flow_attr *attr,
 				struct rte_flow_error *error);
-int mlx5_flow_validate_attributes(struct rte_eth_dev *dev,
-				  const struct rte_flow_attr *attributes,
-				  struct rte_flow_error *error);
 int mlx5_flow_item_acceptable(const struct rte_flow_item *item,
 			      const uint8_t *mask,
 			      const uint8_t *nic_mask,
drivers/net/mlx5/mlx5_flow_dv.c +16 -26

102 lines not on this page · raw message

drivers/net/mlx5/mlx5_flow_verbs.c +49 -1

62 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw

Hi,

Quoted 32 lines

-----Original Message-----
From: Dariusz Sosnowski <[email protected]>
Sent: Thursday, November 3, 2022 12:10 PM
To: Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>
Subject: [PATCH] net/mlx5: forbid direction attributes in transfer flow rules

Since [1] flow API forbids usage of direction attributes in transfer flow rules. This patch adapts mlx5 PMD to this requirement.

From this patch, flow rule validation in mxl5 PMD will reject transfer flow rules with any of the direction attributes set
(i.e. 'ingress' or 'egress').
As a result flow rule can only have one of 'ingress', 'egress' or 'transfer' attributes set.

This patch also changes the following:

- Control flow rules used in FDB are 'transfer' only.
- Checks which assumed that 'transfer' can be used
with 'ingress' and 'egress' are reduced to just checking for direction attributes, since all attributes are exclusive.
- Flow rules for updating flow_tag are created for both ingress and transfer flow rules which have MARK action.
- Moves mlx5_flow_validate_attributes() function from generic flow implementation to legacy Verbs flow engine implementation, since it was used only there. Function is renamed accordingly. Also removes checking if E-Switch uses DV in that function, since if legacy Verbs flow engine is used, then that is always not the case.

Quoted 5 lines

[1] commit bd2a4d4b2e3a ("ethdev: forbid direction attribute in transfer flow rules")

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh