From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0084246468 for ; Mon, 24 Mar 2025 17:18:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E77F440B99; Mon, 24 Mar 2025 17:18:38 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id A74D240BA5 for ; Mon, 24 Mar 2025 17:18:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742833117; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YLfLW6oHl7ZtBb5SKnkNCFixt0vUZ0d3vNcv2/LCbYo=; b=Po7qJRl2YplFdk4h644C9oXj7/OvZVCJDoe8fWQoekoUHJlyd/7KapHTk/yZwmGyKAiWkb QulJt3SZdNegndygyFVi6L8RDyRyIXODkVT0EcklioGXwIur98Cpae1k6haNDtIMmhZZ2n d29eEiVL0GBt7fgs4luqPlL0OBpvPgY= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-619-gaCVbu6XM7mG9wluYBL-GQ-1; Mon, 24 Mar 2025 12:18:34 -0400 X-MC-Unique: gaCVbu6XM7mG9wluYBL-GQ-1 X-Mimecast-MFC-AGG-ID: gaCVbu6XM7mG9wluYBL-GQ_1742833112 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CF4C618011C0; Mon, 24 Mar 2025 16:18:32 +0000 (UTC) Received: from rh.redhat.com (unknown [10.44.32.16]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 44C5D30001A1; Mon, 24 Mar 2025 16:18:30 +0000 (UTC) From: Kevin Traynor To: Michael Baum Cc: Matan Azrad , dpdk stable 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 Message-ID: <20250324161731.63950-23-ktraynor@redhat.com> In-Reply-To: <20250324161731.63950-1-ktraynor@redhat.com> References: <20250324161731.63950-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: hzM-6MyvrHgH1VicGFPNuzrfWcXCwsUvsHYeh1moLbE_1742833112 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org 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 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 Acked-by: Matan Azrad --- 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