DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/mlx5: fix sample and mirror use incorrect devices
@ 2020-11-16  2:31 Suanming Mou
  2020-11-19  1:19 ` [dpdk-dev] [PATCH v2] " Suanming Mou
  0 siblings, 1 reply; 3+ messages in thread
From: Suanming Mou @ 2020-11-16  2:31 UTC (permalink / raw)
  To: viacheslavo, matan; +Cc: rasland, dev

Currently, sample and mirror actions are added to sh(shared context)
level list. The ports belong to the same sh can share the sample and
mirror actions.

While creating the sample and mirror actions sh list in sh creation,
the port which creates sh will be added to the sample and mirror list
context. The port device saved in the list context will be used when
release the entries in the list. Since mirror and sample actions may
have hrxq sub-action which is port level not sh level, in this case,
the other ports in the sh which creates the sample and mirror action
will use the incorrect port devices to release the hrxq.

This commit saves the create device in the sample and mirror actions
struct to avoid using the incorrect port device in entry releasing.

Fixes: 19784141692e ("net/mlx5: make sample and mirror action thread safe")

Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
Reviewed-by: Jiawei Wang <jiaweiw@nvidia.com>
---
 drivers/net/mlx5/linux/mlx5_os.c |  6 ++----
 drivers/net/mlx5/mlx5_flow.h     |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c  | 14 ++++++++------
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index ce25108..59f37b6 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -250,15 +250,13 @@
 			     flow_dv_push_vlan_remove_cb);
 	/* Init sample action cache list. */
 	snprintf(s, sizeof(s), "%s_sample_action_cache", sh->ibdev_name);
-	mlx5_cache_list_init(&sh->sample_action_list, s, 0,
-			     &rte_eth_devices[priv->dev_data->port_id],
+	mlx5_cache_list_init(&sh->sample_action_list, s, 0, sh,
 			     flow_dv_sample_create_cb,
 			     flow_dv_sample_match_cb,
 			     flow_dv_sample_remove_cb);
 	/* Init dest array action cache list. */
 	snprintf(s, sizeof(s), "%s_dest_array_cache", sh->ibdev_name);
-	mlx5_cache_list_init(&sh->dest_array_list, s, 0,
-			     &rte_eth_devices[priv->dev_data->port_id],
+	mlx5_cache_list_init(&sh->dest_array_list, s, 0, sh,
 			     flow_dv_dest_array_create_cb,
 			     flow_dv_dest_array_match_cb,
 			     flow_dv_dest_array_remove_cb);
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 5fac867..aa068e9 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -575,6 +575,7 @@ struct mlx5_flow_dv_sample_resource {
 		void *verbs_action; /**< Verbs sample action object. */
 		void **sub_actions; /**< Sample sub-action array. */
 	};
+	struct rte_eth_dev *dev; /**< Device registers the action. */
 	uint32_t idx; /** Sample object index. */
 	uint8_t ft_type; /** Flow Table Type */
 	uint32_t ft_id; /** Flow Table Level */
@@ -596,6 +597,7 @@ struct mlx5_flow_dv_dest_array_resource {
 	uint32_t idx; /** Destination array action object index. */
 	uint8_t ft_type; /** Flow Table Type */
 	uint8_t num_of_dest; /**< Number of destination actions. */
+	struct rte_eth_dev *dev; /**< Device registers the action. */
 	void *action; /**< Pointer to the rdma core action. */
 	struct mlx5_flow_sub_actions_idx sample_idx[MLX5_MAX_DEST_NUM];
 	/**< Action index resources. */
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 62d9ca9..c38da14 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -8711,6 +8711,7 @@ struct mlx5_cache_entry *
 		goto error;
 	}
 	cache_resource->idx = idx;
+	cache_resource->dev = dev;
 	return &cache_resource->entry;
 error:
 	if (cache_resource->ft_type == MLX5DV_FLOW_TABLE_TYPE_FDB &&
@@ -8873,6 +8874,7 @@ struct mlx5_cache_entry *
 		goto error;
 	}
 	cache_resource->idx = res_idx;
+	cache_resource->dev = dev;
 	for (idx = 0; idx < resource->num_of_dest; idx++)
 		mlx5_free(dest_attr[idx]);
 	return &cache_resource->entry;
@@ -11008,13 +11010,13 @@ struct mlx5_cache_entry *
 }
 
 void
-flow_dv_sample_remove_cb(struct mlx5_cache_list *list,
+flow_dv_sample_remove_cb(struct mlx5_cache_list *list __rte_unused,
 			 struct mlx5_cache_entry *entry)
 {
-	struct rte_eth_dev *dev = list->ctx;
-	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_flow_dv_sample_resource *cache_resource =
 			container_of(entry, typeof(*cache_resource), entry);
+	struct rte_eth_dev *dev = cache_resource->dev;
+	struct mlx5_priv *priv = dev->data->dev_private;
 
 	if (cache_resource->verbs_action)
 		claim_zero(mlx5_glue->destroy_flow_action
@@ -11063,13 +11065,13 @@ struct mlx5_cache_entry *
 }
 
 void
-flow_dv_dest_array_remove_cb(struct mlx5_cache_list *list,
+flow_dv_dest_array_remove_cb(struct mlx5_cache_list *list __rte_unused,
 			     struct mlx5_cache_entry *entry)
 {
-	struct rte_eth_dev *dev = list->ctx;
-	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_flow_dv_dest_array_resource *cache_resource =
 			container_of(entry, typeof(*cache_resource), entry);
+	struct rte_eth_dev *dev = cache_resource->dev;
+	struct mlx5_priv *priv = dev->data->dev_private;
 	uint32_t i = 0;
 
 	MLX5_ASSERT(cache_resource->action);
-- 
1.8.3.1


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

* [dpdk-dev] [PATCH v2] net/mlx5: fix sample and mirror use incorrect devices
  2020-11-16  2:31 [dpdk-dev] [PATCH] net/mlx5: fix sample and mirror use incorrect devices Suanming Mou
@ 2020-11-19  1:19 ` Suanming Mou
  2020-11-19  8:24   ` Raslan Darawsheh
  0 siblings, 1 reply; 3+ messages in thread
From: Suanming Mou @ 2020-11-19  1:19 UTC (permalink / raw)
  To: viacheslavo, matan; +Cc: dev, rasland

The sample and mirror action objects are maintained on the list
shared between the ports belonging to the same multiport Infiniband
device(between representors).

The actions in the NIC steering domains might contain the references
to the sub-flow action objects created over the given port. The action
deletion might happen in the context of the different port and on the
deletion of referenced objects the incorrect port might be specified.
To avoid this we should save the port on what the sub-flow actions
were created and then use this saved port for sub-flow action release.

This commit saves the create device in the sample and mirror actions
struct to avoid using the incorrect port device in releasing.

Fixes: 19784141692e ("net/mlx5: make sample and mirror action thread safe")

Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
Reviewed-by: Jiawei Wang <jiaweiw@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---

v2:
 - Commit message updated.

---
 drivers/net/mlx5/linux/mlx5_os.c |  6 ++----
 drivers/net/mlx5/mlx5_flow.h     |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c  | 14 ++++++++------
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 4b7fff4..00f793b 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -250,15 +250,13 @@
 			     flow_dv_push_vlan_remove_cb);
 	/* Init sample action cache list. */
 	snprintf(s, sizeof(s), "%s_sample_action_cache", sh->ibdev_name);
-	mlx5_cache_list_init(&sh->sample_action_list, s, 0,
-			     &rte_eth_devices[priv->dev_data->port_id],
+	mlx5_cache_list_init(&sh->sample_action_list, s, 0, sh,
 			     flow_dv_sample_create_cb,
 			     flow_dv_sample_match_cb,
 			     flow_dv_sample_remove_cb);
 	/* Init dest array action cache list. */
 	snprintf(s, sizeof(s), "%s_dest_array_cache", sh->ibdev_name);
-	mlx5_cache_list_init(&sh->dest_array_list, s, 0,
-			     &rte_eth_devices[priv->dev_data->port_id],
+	mlx5_cache_list_init(&sh->dest_array_list, s, 0, sh,
 			     flow_dv_dest_array_create_cb,
 			     flow_dv_dest_array_match_cb,
 			     flow_dv_dest_array_remove_cb);
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index bccb973..70fa028 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -563,6 +563,7 @@ struct mlx5_flow_dv_sample_resource {
 		void *verbs_action; /**< Verbs sample action object. */
 		void **sub_actions; /**< Sample sub-action array. */
 	};
+	struct rte_eth_dev *dev; /**< Device registers the action. */
 	uint32_t idx; /** Sample object index. */
 	uint8_t ft_type; /** Flow Table Type */
 	uint32_t ft_id; /** Flow Table Level */
@@ -584,6 +585,7 @@ struct mlx5_flow_dv_dest_array_resource {
 	uint32_t idx; /** Destination array action object index. */
 	uint8_t ft_type; /** Flow Table Type */
 	uint8_t num_of_dest; /**< Number of destination actions. */
+	struct rte_eth_dev *dev; /**< Device registers the action. */
 	void *action; /**< Pointer to the rdma core action. */
 	struct mlx5_flow_sub_actions_idx sample_idx[MLX5_MAX_DEST_NUM];
 	/**< Action index resources. */
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 1f0a2ab..ee3a172 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -8757,6 +8757,7 @@ struct mlx5_cache_entry *
 		goto error;
 	}
 	cache_resource->idx = idx;
+	cache_resource->dev = dev;
 	return &cache_resource->entry;
 error:
 	if (cache_resource->ft_type == MLX5DV_FLOW_TABLE_TYPE_FDB &&
@@ -8919,6 +8920,7 @@ struct mlx5_cache_entry *
 		goto error;
 	}
 	cache_resource->idx = res_idx;
+	cache_resource->dev = dev;
 	for (idx = 0; idx < resource->num_of_dest; idx++)
 		mlx5_free(dest_attr[idx]);
 	return &cache_resource->entry;
@@ -11045,13 +11047,13 @@ struct mlx5_cache_entry *
 }
 
 void
-flow_dv_sample_remove_cb(struct mlx5_cache_list *list,
+flow_dv_sample_remove_cb(struct mlx5_cache_list *list __rte_unused,
 			 struct mlx5_cache_entry *entry)
 {
-	struct rte_eth_dev *dev = list->ctx;
-	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_flow_dv_sample_resource *cache_resource =
 			container_of(entry, typeof(*cache_resource), entry);
+	struct rte_eth_dev *dev = cache_resource->dev;
+	struct mlx5_priv *priv = dev->data->dev_private;
 
 	if (cache_resource->verbs_action)
 		claim_zero(mlx5_glue->destroy_flow_action
@@ -11100,13 +11102,13 @@ struct mlx5_cache_entry *
 }
 
 void
-flow_dv_dest_array_remove_cb(struct mlx5_cache_list *list,
+flow_dv_dest_array_remove_cb(struct mlx5_cache_list *list __rte_unused,
 			     struct mlx5_cache_entry *entry)
 {
-	struct rte_eth_dev *dev = list->ctx;
-	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_flow_dv_dest_array_resource *cache_resource =
 			container_of(entry, typeof(*cache_resource), entry);
+	struct rte_eth_dev *dev = cache_resource->dev;
+	struct mlx5_priv *priv = dev->data->dev_private;
 	uint32_t i = 0;
 
 	MLX5_ASSERT(cache_resource->action);
-- 
1.8.3.1


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

* Re: [dpdk-dev] [PATCH v2] net/mlx5: fix sample and mirror use incorrect devices
  2020-11-19  1:19 ` [dpdk-dev] [PATCH v2] " Suanming Mou
@ 2020-11-19  8:24   ` Raslan Darawsheh
  0 siblings, 0 replies; 3+ messages in thread
From: Raslan Darawsheh @ 2020-11-19  8:24 UTC (permalink / raw)
  To: Suanming Mou, Slava Ovsiienko, Matan Azrad; +Cc: dev

Hi,

> -----Original Message-----
> From: Suanming Mou <suanmingm@nvidia.com>
> Sent: Thursday, November 19, 2020 3:20 AM
> To: Slava Ovsiienko <viacheslavo@nvidia.com>; Matan Azrad
> <matan@nvidia.com>
> Cc: dev@dpdk.org; Raslan Darawsheh <rasland@nvidia.com>
> Subject: [PATCH v2] net/mlx5: fix sample and mirror use incorrect devices
> 
> The sample and mirror action objects are maintained on the list
> shared between the ports belonging to the same multiport Infiniband
> device(between representors).
> 
> The actions in the NIC steering domains might contain the references
> to the sub-flow action objects created over the given port. The action
> deletion might happen in the context of the different port and on the
> deletion of referenced objects the incorrect port might be specified.
> To avoid this we should save the port on what the sub-flow actions
> were created and then use this saved port for sub-flow action release.
> 
> This commit saves the create device in the sample and mirror actions
> struct to avoid using the incorrect port device in releasing.
> 
> Fixes: 19784141692e ("net/mlx5: make sample and mirror action thread
> safe")
> 
> Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
> Reviewed-by: Jiawei Wang <jiaweiw@nvidia.com>
> Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> ---
> 
> v2:
>  - Commit message updated.
> 
> ---

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

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

end of thread, other threads:[~2020-11-19  8:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-16  2:31 [dpdk-dev] [PATCH] net/mlx5: fix sample and mirror use incorrect devices Suanming Mou
2020-11-19  1:19 ` [dpdk-dev] [PATCH v2] " Suanming Mou
2020-11-19  8:24   ` Raslan Darawsheh

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git