patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: Michael Baum <michaelba@nvidia.com>
Cc: Matan Azrad <matan@nvidia.com>, dpdk stable <stable@dpdk.org>
Subject: patch 'net/mlx5: fix GENEVE parser cleanup' has been queued to stable release 24.11.2
Date: Mon, 24 Mar 2025 16:16:30 +0000	[thread overview]
Message-ID: <20250324161731.63950-23-ktraynor@redhat.com> (raw)
In-Reply-To: <20250324161731.63950-1-ktraynor@redhat.com>

Hi,

FYI, your patch has been queued to stable release 24.11.2

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 03/28/25. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/699d7237b61ba8b7080ef1bfe92ea396bdb6cfea

Thanks.

Kevin

---
From 699d7237b61ba8b7080ef1bfe92ea396bdb6cfea Mon Sep 17 00:00:00 2001
From: Michael Baum <michaelba@nvidia.com>
Date: Thu, 13 Mar 2025 10:33:51 +0200
Subject: [PATCH] net/mlx5: fix GENEVE parser cleanup

[ upstream commit c8a6da8678c12bd4c7814a9b15c3cd05402d253f ]

The GENEVE parser is shared across ports on the same physical device. It
is created once for the first port and increments a reference counter
for each additional port. The parser is created using the InfiniBand
(IBV) context (CTX) of the first port, and cleanup should use the same
context.

Previously, if the port owning the context closed while another port
still used the parser, the port closure would fail due to the shared
parser dependency.

This patch addresses the issue by changing the approach: the physical
device now creates its own distinct context by importing the context
from the first initialized port. This ensures that parser creation and
cleanup use a consistent context, independent of individual port
lifecycles.

Fixes: f5177bdc8b76 ("net/mlx5: add GENEVE TLV options parser API")

Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5.c             | 21 ++++++------
 drivers/net/mlx5/mlx5.h             |  2 +-
 drivers/net/mlx5/mlx5_flow.h        |  2 --
 drivers/net/mlx5/mlx5_flow_geneve.c | 50 +++--------------------------
 4 files changed, 18 insertions(+), 57 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 5616cf4011..96269d4e8e 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -1732,4 +1732,14 @@ mlx5_get_physical_device(struct mlx5_common_device *cdev)
 		return NULL;
 	}
+	/*
+	 * The same CTX create the physical device objects should destroy them.
+	 * Since we can't be sure it will be done by same CTX, we prepare for
+	 * the physical device a special CTX used by objects creation.
+	 */
+	phdev->ctx = mlx5_os_get_physical_device_ctx(cdev);
+	if (!phdev->ctx) {
+		mlx5_free(phdev);
+		return NULL;
+	}
 	phdev->guid = attr->system_image_guid;
 	phdev->refcnt = 1;
@@ -1775,4 +1785,6 @@ mlx5_physical_device_destroy(struct mlx5_physical_device *phdev)
 	/* Remove physical device from the global device list. */
 	LIST_REMOVE(phdev, next);
+	MLX5_ASSERT(phdev->ctx);
+	claim_zero(mlx5_glue->close_device(phdev->ctx));
 	mlx5_free(phdev);
 }
@@ -2331,13 +2343,4 @@ mlx5_dev_close(struct rte_eth_dev *dev)
 		return -EBUSY;
 	}
-#ifdef HAVE_MLX5_HWS_SUPPORT
-	/* Check if shared GENEVE options created on context being closed. */
-	ret = mlx5_geneve_tlv_options_check_busy(priv);
-	if (ret) {
-		DRV_LOG(ERR, "port %u maintains shared GENEVE TLV options",
-			dev->data->port_id);
-		return ret;
-	}
-#endif
 	DRV_LOG(DEBUG, "port %u closing device \"%s\"",
 		dev->data->port_id, sh->ibdev_name);
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 21df917d6f..856d432c69 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -1514,5 +1514,5 @@ struct mlx5_common_nic_config {
 struct mlx5_physical_device {
 	LIST_ENTRY(mlx5_physical_device) next;
-	struct mlx5_dev_ctx_shared *sh; /* Created on sherd context. */
+	void *ctx; /* CTX for creation of options. */
 	uint64_t guid; /* System image guid, the uniq ID of physical device. */
 	struct mlx5_geneve_tlv_options *tlv_options;
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 72f6cf6a32..8c3daed7d0 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -3469,6 +3469,4 @@ int
 mlx5_geneve_tlv_options_destroy(struct mlx5_geneve_tlv_options *options,
 				struct mlx5_physical_device *phdev);
-int
-mlx5_geneve_tlv_options_check_busy(struct mlx5_priv *priv);
 void
 flow_hw_rxq_flag_set(struct rte_eth_dev *dev, bool enable);
diff --git a/drivers/net/mlx5/mlx5_flow_geneve.c b/drivers/net/mlx5/mlx5_flow_geneve.c
index 6bf53e1270..4d57bb763f 100644
--- a/drivers/net/mlx5/mlx5_flow_geneve.c
+++ b/drivers/net/mlx5/mlx5_flow_geneve.c
@@ -591,6 +591,6 @@ mlx5_geneve_tlv_option_copy(struct rte_pmd_mlx5_geneve_tlv *dst,
  * Create list of GENEVE TLV options according to user configuration list.
  *
- * @param sh
- *   Shared context the options are being created on.
+ * @param ctx
+ *   Context returned from mlx5 open_device() glue function.
  * @param tlv_list
  *   A list of GENEVE TLV options to create parser for them.
@@ -605,5 +605,5 @@ mlx5_geneve_tlv_option_copy(struct rte_pmd_mlx5_geneve_tlv *dst,
  */
 static struct mlx5_geneve_tlv_options *
-mlx5_geneve_tlv_options_create(struct mlx5_dev_ctx_shared *sh,
+mlx5_geneve_tlv_options_create(void *ctx,
 			       const struct rte_pmd_mlx5_geneve_tlv tlv_list[],
 			       uint8_t nb_options, uint8_t sample_id)
@@ -626,5 +626,5 @@ mlx5_geneve_tlv_options_create(struct mlx5_dev_ctx_shared *sh,
 	for (i = 0; i < nb_options; ++i) {
 		spec = &tlv_list[i];
-		ret = mlx5_geneve_tlv_option_create(sh->cdev->ctx, spec,
+		ret = mlx5_geneve_tlv_option_create(ctx, spec,
 						    &options->options[i], sample_id);
 		if (ret < 0)
@@ -634,6 +634,4 @@ mlx5_geneve_tlv_options_create(struct mlx5_dev_ctx_shared *sh,
 		mlx5_geneve_tlv_option_copy(&options->spec[i], spec, data_mask);
 	}
-	MLX5_ASSERT(sh->phdev->sh == NULL);
-	sh->phdev->sh = sh;
 	options->nb_options = nb_options;
 	options->refcnt = 1;
@@ -677,39 +675,7 @@ mlx5_geneve_tlv_options_destroy(struct mlx5_geneve_tlv_options *options,
 	mlx5_free(options);
 	phdev->tlv_options = NULL;
-	phdev->sh = NULL;
 	return 0;
 }
 
-/**
- * Check if GENEVE TLV options are hosted on the current port
- * and the port can be closed
- *
- * @param priv
- *   Device private data.
- *
- * @return
- *   0 on success, a negative EBUSY and rte_errno is set.
- */
-int
-mlx5_geneve_tlv_options_check_busy(struct mlx5_priv *priv)
-{
-	struct mlx5_physical_device *phdev = mlx5_get_locked_physical_device(priv);
-	struct mlx5_dev_ctx_shared *sh = priv->sh;
-
-	if (!phdev || phdev->sh != sh) {
-		mlx5_unlock_physical_device();
-		return 0;
-	}
-	if (!sh->phdev->tlv_options || sh->phdev->tlv_options->refcnt == 1) {
-		/* Mark port as being closed one */
-		sh->phdev->sh = NULL;
-		mlx5_unlock_physical_device();
-		return 0;
-	}
-	mlx5_unlock_physical_device();
-	rte_errno = EBUSY;
-	return -EBUSY;
-}
-
 /**
  * Validate GENEVE TLV option user request structure.
@@ -956,10 +922,4 @@ mlx5_geneve_tlv_parser_create(uint16_t port_id,
 			return NULL;
 		}
-		if (phdev->sh == NULL) {
-			mlx5_unlock_physical_device();
-			DRV_LOG(ERR, "GENEVE TLV options are hosted on port being closed.");
-			rte_errno = EBUSY;
-			return NULL;
-		}
 		/* Use existing options. */
 		options->refcnt++;
@@ -967,5 +927,5 @@ mlx5_geneve_tlv_parser_create(uint16_t port_id,
 	}
 	/* Create GENEVE TLV options for this physical device. */
-	options = mlx5_geneve_tlv_options_create(priv->sh, tlv_list, nb_options, sample_id);
+	options = mlx5_geneve_tlv_options_create(phdev->ctx, tlv_list, nb_options, sample_id);
 	if (!options) {
 		mlx5_unlock_physical_device();
-- 
2.48.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2025-03-24 16:15:15.669778137 +0000
+++ 0023-net-mlx5-fix-GENEVE-parser-cleanup.patch	2025-03-24 16:15:14.853735920 +0000
@@ -1 +1 @@
-From c8a6da8678c12bd4c7814a9b15c3cd05402d253f Mon Sep 17 00:00:00 2001
+From 699d7237b61ba8b7080ef1bfe92ea396bdb6cfea Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit c8a6da8678c12bd4c7814a9b15c3cd05402d253f ]
+
@@ -23 +24,0 @@
-Cc: stable@dpdk.org
@@ -35 +36 @@
-index e175f81031..646da8e846 100644
+index 5616cf4011..96269d4e8e 100644
@@ -38 +39 @@
-@@ -1731,4 +1731,14 @@ mlx5_get_physical_device(struct mlx5_common_device *cdev)
+@@ -1732,4 +1732,14 @@ mlx5_get_physical_device(struct mlx5_common_device *cdev)
@@ -53 +54 @@
-@@ -1774,4 +1784,6 @@ mlx5_physical_device_destroy(struct mlx5_physical_device *phdev)
+@@ -1775,4 +1785,6 @@ mlx5_physical_device_destroy(struct mlx5_physical_device *phdev)
@@ -60 +61 @@
-@@ -2330,13 +2342,4 @@ mlx5_dev_close(struct rte_eth_dev *dev)
+@@ -2331,13 +2343,4 @@ mlx5_dev_close(struct rte_eth_dev *dev)
@@ -75 +76 @@
-index 6df99c25e2..0194887a8b 100644
+index 21df917d6f..856d432c69 100644
@@ -78 +79 @@
-@@ -1528,5 +1528,5 @@ struct mlx5_common_nic_config {
+@@ -1514,5 +1514,5 @@ struct mlx5_common_nic_config {
@@ -86 +87 @@
-index a5bde158ca..9816ed9238 100644
+index 72f6cf6a32..8c3daed7d0 100644
@@ -89 +90 @@
-@@ -3470,6 +3470,4 @@ int
+@@ -3469,6 +3469,4 @@ int


  parent reply	other threads:[~2025-03-24 16:18 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-24 16:16 patch 'doc: fix year of final LTS release' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/bnxt: fix epoch bit calculation' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/iavf: fix mbuf release in Arm multi-process' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/ice: fix flow engines order' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/ice: fix dropped packets when using VRRP' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/iavf: check interrupt registration failure' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/iavf: fix crash on app exit on FreeBSD' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/mlx5: fix hairpin queue release' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/mlx5: fix LACP packet handling in isolated mode' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/mlx5/hws: fix crash using represented port without ID' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/mlx5: fix non-template set VLAN VID' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/mlx5: fix error info in actions construct' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/mlx5/hws: fix GTP flags matching' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/mlx5: fix non-template flow validation' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/mlx5: fix non-template flow validation on create' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/mlx5: fix flow group ID for action translation' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/mlx5: fix flow matching GENEVE options' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/mlx5: fix IPIP tunnel verification' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/mlx5: fix mark action validation in FDB mode' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/mlx5: fix NAT64 register selection' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/mlx5: fix GRE matching on root table' " Kevin Traynor
2025-03-24 16:16 ` patch 'common/mlx5: add device duplication function' " Kevin Traynor
2025-03-24 16:16 ` Kevin Traynor [this message]
2025-03-24 16:16 ` patch 'baseband/acc: fix queue setup failure clean up' " Kevin Traynor
2025-03-24 16:16 ` patch 'common/qat: fix devargs parsing' " Kevin Traynor
2025-03-24 16:16 ` patch 'dts: fix smoke tests docstring' " Kevin Traynor
2025-03-24 16:16 ` patch 'pdump: clear statistics when enabled' " Kevin Traynor
2025-03-24 16:16 ` patch 'examples/flow_filtering: fix IPv4 matching snippet' " Kevin Traynor
2025-03-24 16:16 ` patch 'examples/ipsec-secgw: fix cryptodev and eventdev IDs' " Kevin Traynor
2025-03-24 16:16 ` patch 'doc: add no-IOMMU mode in devbind tool guide' " Kevin Traynor
2025-03-24 16:16 ` patch 'eal: fix undetected NUMA nodes' " Kevin Traynor
2025-03-24 16:16 ` patch 'net/ixgbe: add checks for E610 VF' " Kevin Traynor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250324161731.63950-23-ktraynor@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=matan@nvidia.com \
    --cc=michaelba@nvidia.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).