All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] net/mlx5/hws: fix rule resize status check
@ 2024-03-21 14:24 Yevgeny Kliteynik
  2024-03-21 14:24 ` [PATCH 2/2] net/mlx5/hws: fix port ID for root table Yevgeny Kliteynik
  2024-03-24 22:12 ` [PATCH 1/2] net/mlx5/hws: fix rule resize status check Thomas Monjalon
  0 siblings, 2 replies; 4+ messages in thread
From: Yevgeny Kliteynik @ 2024-03-21 14:24 UTC (permalink / raw)
  To: kliteyn, viacheslavo, thomas, suanmingm, Dariusz Sosnowski,
	Ori Kam, Matan Azrad
  Cc: dev, valex, igozlan, erezsh

The check to detect if a rule is in resize was done incorrectly,
this can lead to an incorrect function call upon completion for
rules which are not in resize (move).
Since the resize_info is in a union we cannot rely only on the
pointer value but also need to make sure the matcher is in resize
process, this assures us the resize info is valid.

Fixes: 762feceb8294 ("net/mlx5/hws: support resizable matchers")

Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: Alex Vesker <valex@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_rule.c | 7 +++++++
 drivers/net/mlx5/hws/mlx5dr_rule.h | 6 +-----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/mlx5/hws/mlx5dr_rule.c b/drivers/net/mlx5/hws/mlx5dr_rule.c
index f14e1e6ecd..784f614d87 100644
--- a/drivers/net/mlx5/hws/mlx5dr_rule.c
+++ b/drivers/net/mlx5/hws/mlx5dr_rule.c
@@ -350,6 +350,13 @@ static void mlx5dr_rule_move_init(struct mlx5dr_rule *rule,
 	rule->resize_info->state = MLX5DR_RULE_RESIZE_STATE_WRITING;
 }
 
+bool mlx5dr_rule_move_in_progress(struct mlx5dr_rule *rule)
+{
+	return mlx5dr_matcher_is_in_resize(rule->matcher) &&
+	       rule->resize_info &&
+	       rule->resize_info->state != MLX5DR_RULE_RESIZE_STATE_IDLE;
+}
+
 static int mlx5dr_rule_create_hws_fw_wqe(struct mlx5dr_rule *rule,
 					 struct mlx5dr_rule_attr *attr,
 					 uint8_t mt_idx,
diff --git a/drivers/net/mlx5/hws/mlx5dr_rule.h b/drivers/net/mlx5/hws/mlx5dr_rule.h
index 07adf9c5ad..dffaec1c0f 100644
--- a/drivers/net/mlx5/hws/mlx5dr_rule.h
+++ b/drivers/net/mlx5/hws/mlx5dr_rule.h
@@ -72,10 +72,6 @@ int mlx5dr_rule_move_hws_remove(struct mlx5dr_rule *rule,
 int mlx5dr_rule_move_hws_add(struct mlx5dr_rule *rule,
 			     struct mlx5dr_rule_attr *attr);
 
-static inline bool mlx5dr_rule_move_in_progress(struct mlx5dr_rule *rule)
-{
-	return rule->resize_info &&
-	       rule->resize_info->state != MLX5DR_RULE_RESIZE_STATE_IDLE;
-}
+bool mlx5dr_rule_move_in_progress(struct mlx5dr_rule *rule);
 
 #endif /* MLX5DR_RULE_H_ */
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] net/mlx5/hws: fix port ID for root table
  2024-03-21 14:24 [PATCH 1/2] net/mlx5/hws: fix rule resize status check Yevgeny Kliteynik
@ 2024-03-21 14:24 ` Yevgeny Kliteynik
  2024-03-21 14:48   ` [PATCH v2] " Yevgeny Kliteynik
  2024-03-24 22:12 ` [PATCH 1/2] net/mlx5/hws: fix rule resize status check Thomas Monjalon
  1 sibling, 1 reply; 4+ messages in thread
From: Yevgeny Kliteynik @ 2024-03-21 14:24 UTC (permalink / raw)
  To: kliteyn, viacheslavo, thomas, suanmingm, Dariusz Sosnowski,
	Ori Kam, Matan Azrad, Erez Shitrit, Alex Vesker
  Cc: dev, igozlan, stable

From: Erez Shitrit <erezsh@nvidia.com>

In root tables matcher and rule need to have their port-id, otherwise
the translate function that done in dpdk layer will not get the right
attributes.
For that whenever the matcher is matching the source-port we need to get
the relevant port-id before calling the translate function.

Fixes: 405242c52dd5 ("net/mlx5/hws: add rule object")
Cc: stable@dpdk.org

Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: Erez Shitrit <erezsh@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_matcher.c | 17 +++++++++++++++++
 drivers/net/mlx5/hws/mlx5dr_rule.c    | 18 ++++++++++++++++++
 drivers/net/mlx5/mlx5_flow.h          | 22 ++++++++++++++++++++++
 3 files changed, 57 insertions(+)

diff --git a/drivers/net/mlx5/hws/mlx5dr_matcher.c b/drivers/net/mlx5/hws/mlx5dr_matcher.c
index 1c64abfa57..aeff300467 100644
--- a/drivers/net/mlx5/hws/mlx5dr_matcher.c
+++ b/drivers/net/mlx5/hws/mlx5dr_matcher.c
@@ -1220,6 +1220,7 @@ static int mlx5dr_matcher_init_root(struct mlx5dr_matcher *matcher)
 	struct mlx5dv_flow_match_parameters *mask;
 	struct mlx5_flow_attr flow_attr = {0};
 	struct rte_flow_error rte_error;
+	struct rte_flow_item *item;
 	uint8_t match_criteria;
 	int ret;
 
@@ -1248,6 +1249,22 @@ static int mlx5dr_matcher_init_root(struct mlx5dr_matcher *matcher)
 		return rte_errno;
 	}
 
+	/* We need the port id in case of matching representor */
+	item = matcher->mt[0].items;
+	while (item->type != RTE_FLOW_ITEM_TYPE_END) {
+		if (item->type == RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR ||
+		    item->type == RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT) {
+			ret = flow_hw_get_port_id_from_ctx(ctx, &flow_attr.port_id);
+			if (ret) {
+				DR_LOG(ERR, "Failed to get port id for dev %s",
+				       ctx->ibv_ctx->device->name);
+				rte_errno = EINVAL;
+				return rte_errno;
+			}
+		}
+		++item;
+	}
+
 	mask = simple_calloc(1, MLX5_ST_SZ_BYTES(fte_match_param) +
 			     offsetof(struct mlx5dv_flow_match_parameters, match_buf));
 	if (!mask) {
diff --git a/drivers/net/mlx5/hws/mlx5dr_rule.c b/drivers/net/mlx5/hws/mlx5dr_rule.c
index 784f614d87..022263eb1d 100644
--- a/drivers/net/mlx5/hws/mlx5dr_rule.c
+++ b/drivers/net/mlx5/hws/mlx5dr_rule.c
@@ -687,10 +687,28 @@ static int mlx5dr_rule_create_root(struct mlx5dr_rule *rule,
 	struct mlx5dv_flow_match_parameters *value;
 	struct mlx5_flow_attr flow_attr = {0};
 	struct mlx5dv_flow_action_attr *attr;
+	const struct rte_flow_item *cur_item;
 	struct rte_flow_error error;
 	uint8_t match_criteria;
 	int ret;
 
+	/* We need the port id in case of matching representor */
+	cur_item = items;
+	while (cur_item->type != RTE_FLOW_ITEM_TYPE_END) {
+		if (cur_item->type == RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR ||
+		    cur_item->type == RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT) {
+			ret = flow_hw_get_port_id_from_ctx(rule->matcher->tbl->ctx,
+							   &flow_attr.port_id);
+			if (ret) {
+				DR_LOG(ERR, "Failed to get port id for dev %s",
+				       rule->matcher->tbl->ctx->ibv_ctx->device->name);
+				rte_errno = EINVAL;
+				return rte_errno;
+			}
+		}
+		++cur_item;
+	}
+
 	attr = simple_calloc(num_actions, sizeof(*attr));
 	if (!attr) {
 		rte_errno = ENOMEM;
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 34b5e0f45b..0065727a67 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -2001,6 +2001,28 @@ flow_hw_get_reg_id(struct rte_eth_dev *dev,
 #endif
 }
 
+static __rte_always_inline int
+flow_hw_get_port_id_from_ctx(void *dr_ctx, uint32_t *port_val)
+{
+#if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
+	uint32_t port;
+
+	MLX5_ETH_FOREACH_DEV(port, NULL) {
+		struct mlx5_priv *priv;
+		priv = rte_eth_devices[port].data->dev_private;
+
+		if (priv->dr_ctx == dr_ctx) {
+			*port_val = port;
+			return 0;
+		}
+	}
+#else
+	RTE_SET_USED(dr_ctx);
+	RTE_SET_USED(port_val);
+#endif
+	return -EINVAL;
+}
+
 /**
  * Get GENEVE TLV option FW information according type and class.
  *
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2] net/mlx5/hws: fix port ID for root table
  2024-03-21 14:24 ` [PATCH 2/2] net/mlx5/hws: fix port ID for root table Yevgeny Kliteynik
@ 2024-03-21 14:48   ` Yevgeny Kliteynik
  0 siblings, 0 replies; 4+ messages in thread
From: Yevgeny Kliteynik @ 2024-03-21 14:48 UTC (permalink / raw)
  To: kliteyn, viacheslavo, thomas, suanmingm, Dariusz Sosnowski,
	Ori Kam, Matan Azrad, Erez Shitrit, Alex Vesker
  Cc: dev, igozlan, stable

From: Erez Shitrit <erezsh@nvidia.com>

In root tables matcher and rule need to have their port-id, otherwise
the translate function that done in dpdk layer will not get the right
attributes.
For that whenever the matcher is matching the source-port we need to get
the relevant port-id before calling the translate function.

Fixes: 405242c52dd5 ("net/mlx5/hws: add rule object")
Cc: stable@dpdk.org

Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: Erez Shitrit <erezsh@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
V2 - removed duplicated sign-off line

drivers/net/mlx5/hws/mlx5dr_matcher.c | 17 +++++++++++++++++
 drivers/net/mlx5/hws/mlx5dr_rule.c    | 18 ++++++++++++++++++
 drivers/net/mlx5/mlx5_flow.h          | 22 ++++++++++++++++++++++
 3 files changed, 57 insertions(+)

diff --git a/drivers/net/mlx5/hws/mlx5dr_matcher.c b/drivers/net/mlx5/hws/mlx5dr_matcher.c
index 1c64abfa57..aeff300467 100644
--- a/drivers/net/mlx5/hws/mlx5dr_matcher.c
+++ b/drivers/net/mlx5/hws/mlx5dr_matcher.c
@@ -1220,6 +1220,7 @@ static int mlx5dr_matcher_init_root(struct mlx5dr_matcher *matcher)
 	struct mlx5dv_flow_match_parameters *mask;
 	struct mlx5_flow_attr flow_attr = {0};
 	struct rte_flow_error rte_error;
+	struct rte_flow_item *item;
 	uint8_t match_criteria;
 	int ret;
 
@@ -1248,6 +1249,22 @@ static int mlx5dr_matcher_init_root(struct mlx5dr_matcher *matcher)
 		return rte_errno;
 	}
 
+	/* We need the port id in case of matching representor */
+	item = matcher->mt[0].items;
+	while (item->type != RTE_FLOW_ITEM_TYPE_END) {
+		if (item->type == RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR ||
+		    item->type == RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT) {
+			ret = flow_hw_get_port_id_from_ctx(ctx, &flow_attr.port_id);
+			if (ret) {
+				DR_LOG(ERR, "Failed to get port id for dev %s",
+				       ctx->ibv_ctx->device->name);
+				rte_errno = EINVAL;
+				return rte_errno;
+			}
+		}
+		++item;
+	}
+
 	mask = simple_calloc(1, MLX5_ST_SZ_BYTES(fte_match_param) +
 			     offsetof(struct mlx5dv_flow_match_parameters, match_buf));
 	if (!mask) {
diff --git a/drivers/net/mlx5/hws/mlx5dr_rule.c b/drivers/net/mlx5/hws/mlx5dr_rule.c
index 784f614d87..022263eb1d 100644
--- a/drivers/net/mlx5/hws/mlx5dr_rule.c
+++ b/drivers/net/mlx5/hws/mlx5dr_rule.c
@@ -687,10 +687,28 @@ static int mlx5dr_rule_create_root(struct mlx5dr_rule *rule,
 	struct mlx5dv_flow_match_parameters *value;
 	struct mlx5_flow_attr flow_attr = {0};
 	struct mlx5dv_flow_action_attr *attr;
+	const struct rte_flow_item *cur_item;
 	struct rte_flow_error error;
 	uint8_t match_criteria;
 	int ret;
 
+	/* We need the port id in case of matching representor */
+	cur_item = items;
+	while (cur_item->type != RTE_FLOW_ITEM_TYPE_END) {
+		if (cur_item->type == RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR ||
+		    cur_item->type == RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT) {
+			ret = flow_hw_get_port_id_from_ctx(rule->matcher->tbl->ctx,
+							   &flow_attr.port_id);
+			if (ret) {
+				DR_LOG(ERR, "Failed to get port id for dev %s",
+				       rule->matcher->tbl->ctx->ibv_ctx->device->name);
+				rte_errno = EINVAL;
+				return rte_errno;
+			}
+		}
+		++cur_item;
+	}
+
 	attr = simple_calloc(num_actions, sizeof(*attr));
 	if (!attr) {
 		rte_errno = ENOMEM;
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 34b5e0f45b..0065727a67 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -2001,6 +2001,28 @@ flow_hw_get_reg_id(struct rte_eth_dev *dev,
 #endif
 }
 
+static __rte_always_inline int
+flow_hw_get_port_id_from_ctx(void *dr_ctx, uint32_t *port_val)
+{
+#if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
+	uint32_t port;
+
+	MLX5_ETH_FOREACH_DEV(port, NULL) {
+		struct mlx5_priv *priv;
+		priv = rte_eth_devices[port].data->dev_private;
+
+		if (priv->dr_ctx == dr_ctx) {
+			*port_val = port;
+			return 0;
+		}
+	}
+#else
+	RTE_SET_USED(dr_ctx);
+	RTE_SET_USED(port_val);
+#endif
+	return -EINVAL;
+}
+
 /**
  * Get GENEVE TLV option FW information according type and class.
  *
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] net/mlx5/hws: fix rule resize status check
  2024-03-21 14:24 [PATCH 1/2] net/mlx5/hws: fix rule resize status check Yevgeny Kliteynik
  2024-03-21 14:24 ` [PATCH 2/2] net/mlx5/hws: fix port ID for root table Yevgeny Kliteynik
@ 2024-03-24 22:12 ` Thomas Monjalon
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2024-03-24 22:12 UTC (permalink / raw)
  To: Yevgeny Kliteynik
  Cc: viacheslavo, suanmingm, Dariusz Sosnowski, Ori Kam, Matan Azrad,
	dev, valex, igozlan, erezsh

21/03/2024 15:24, Yevgeny Kliteynik:
> The check to detect if a rule is in resize was done incorrectly,
> this can lead to an incorrect function call upon completion for
> rules which are not in resize (move).
> Since the resize_info is in a union we cannot rely only on the
> pointer value but also need to make sure the matcher is in resize
> process, this assures us the resize info is valid.
> 
> Fixes: 762feceb8294 ("net/mlx5/hws: support resizable matchers")
> 
> Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
> Signed-off-by: Alex Vesker <valex@nvidia.com>
> Acked-by: Matan Azrad <matan@nvidia.com>

Series applied, thanks.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-03-24 22:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-21 14:24 [PATCH 1/2] net/mlx5/hws: fix rule resize status check Yevgeny Kliteynik
2024-03-21 14:24 ` [PATCH 2/2] net/mlx5/hws: fix port ID for root table Yevgeny Kliteynik
2024-03-21 14:48   ` [PATCH v2] " Yevgeny Kliteynik
2024-03-24 22:12 ` [PATCH 1/2] net/mlx5/hws: fix rule resize status check Thomas Monjalon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.