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 9687E43C60 for ; Thu, 7 Mar 2024 02:37:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8F77F42F0E; Thu, 7 Mar 2024 02:37:16 +0100 (CET) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by mails.dpdk.org (Postfix) with ESMTP id 7041A42F27 for ; Thu, 7 Mar 2024 02:37:15 +0100 (CET) Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4130db63380so2450245e9.3 for ; Wed, 06 Mar 2024 17:37:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709775435; x=1710380235; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NmMrqeHLgHTwcVt2DUToTnq/5q6CDDBSo1jNU2b/70Y=; b=N9ZkJ4/DX/WC+C0clUAQHWartr4l0EJ7Yu21RxUwJSiECfZvWwyYPVRsFYpJwZgWA+ bkXyl4YhzJ4JsPrvmIOYLwSMF8uQ5tU/5LP31QLo0CcIct4F39Jwn5jYm2ZDbbA2ywOv ZrbbSOt7FO6PJvRg2Cryl9ryEBK+tcMwr7mzpGxs2ncyy96Gc6YEdtS/g0oU2t6o481s l/wifjiOz5n6YSBOUIiByT3+LxMO1wbibJwpji03oTbcCBA2Nq8lesMbq+lbJRLSOUoB S+HsbfKgqpEWUxPtC5KOEhV/OYLejAYYedqIQbAOYvtBd/+rc0dpoG75q3a8tp9eFmZ0 rVxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709775435; x=1710380235; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NmMrqeHLgHTwcVt2DUToTnq/5q6CDDBSo1jNU2b/70Y=; b=JnazD0hwe6csYygvGpa8kBEp7awFYNTS6zgDdIfr8s1eLUGnQ15v8BuxBUsmP+UdM5 leT5oNtmBfckgkFF5id3CzA8xx6ro5POHl2PLudXh72YXctF1QDvpFs1XMaOn+auCQJD mu7FbzD750suDNqDhZLEFY05bklXHLsO2ZbfRJko8RB1Cug17VZTU667J659RNVLefwI kAceKRZUHD+8FY3JbKo4AAg7bTAoRqDo1X3jNr0iYo6L3+a4//CwPNCPVYUQlfZriJFJ +2h8cXQ/yoTzd3ehRUt7mJe/0gPQcp+/ioAmj+KCvTRJa/DGBAZDdgcpBMc1cg7cy3Ki xaog== X-Forwarded-Encrypted: i=1; AJvYcCXAh1XqkQGr348syUkdDpO7v1USAOhGk4iI+JOwu0z3lS1K5TmNdCRdb72nQsrV3eXwLg24J0bEV/8rDjP5rp8= X-Gm-Message-State: AOJu0Yz30pGhSTRXaI4jVvTxwkgiCAdTUc96AcvlcvLzQvgl5zPQfXor f8S3pSjpcBVq2b4k9UFsbtzF2zCRIq6CAI/MDDzdumz2jVbLISfBn37ml9DAgYI= X-Google-Smtp-Source: AGHT+IHRDDeIdn8dpoL6hj+4k5VQQVodOeyYaGaBElTvWAISZnNT/0lxQcdbGzTrKNBH/5lMhzYKEA== X-Received: by 2002:a05:600c:5105:b0:412:dbf7:4cec with SMTP id o5-20020a05600c510500b00412dbf74cecmr9490865wms.3.1709775435111; Wed, 06 Mar 2024 17:37:15 -0800 (PST) Received: from localhost ([137.220.120.171]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4ed400b00412f679bae1sm889316wmq.26.2024.03.06.17.37.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 17:37:14 -0800 (PST) From: luca.boccassi@gmail.com To: Ajit Khaparde Cc: Peter Spreadborough , dpdk stable Subject: patch 'net/bnxt: modify locking for representor Tx' has been queued to stable release 22.11.5 Date: Thu, 7 Mar 2024 01:31:46 +0000 Message-Id: <20240307013159.1735343-89-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240307013159.1735343-1-luca.boccassi@gmail.com> References: <20240307013159.1735343-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 22.11.5 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/09/24. 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/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/d71a7702314a605d86c761d72bbf857504e59752 Thanks. Luca Boccassi --- >From d71a7702314a605d86c761d72bbf857504e59752 Mon Sep 17 00:00:00 2001 From: Ajit Khaparde Date: Thu, 8 Feb 2024 09:13:25 -0800 Subject: [PATCH] net/bnxt: modify locking for representor Tx [ upstream commit d46406c7070724c8cfd04b805849339d1178f528 ] Currently the representor Tx function is synchronized using a per device lock. But that is not sufficient when there is simultaneous traffic on the parent Tx ring and the representor rings. Moreover the representor Tx is not protected from incursions by the parent transmits. This can cause parent Tx threads to crossover into the representor Tx contexts. Prevent this by using per TxQ locking and protect not just representor Tx, but also the parent Tx using the lock. Fixes: 6dc83230b43b ("net/bnxt: support port representor data path") Signed-off-by: Ajit Khaparde Reviewed-by: Peter Spreadborough --- drivers/net/bnxt/bnxt.h | 1 - drivers/net/bnxt/bnxt_ethdev.c | 11 +---------- drivers/net/bnxt/bnxt_reps.c | 6 +++--- drivers/net/bnxt/bnxt_txq.c | 6 ++++++ drivers/net/bnxt/bnxt_txq.h | 1 + drivers/net/bnxt/bnxt_txr.c | 13 +++++++++++++ drivers/net/bnxt/bnxt_txr.h | 4 +++- 7 files changed, 27 insertions(+), 15 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 5ea6f9b69a..3044c9e079 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -542,7 +542,6 @@ struct bnxt_mark_info { struct bnxt_rep_info { struct rte_eth_dev *vfr_eth_dev; - pthread_mutex_t vfr_lock; pthread_mutex_t vfr_start_lock; bool conduit_valid; }; diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index c89a31592a..cb52ef2f84 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -1648,10 +1648,8 @@ bnxt_uninit_locks(struct bnxt *bp) pthread_mutex_destroy(&bp->def_cp_lock); pthread_mutex_destroy(&bp->health_check_lock); pthread_mutex_destroy(&bp->err_recovery_lock); - if (bp->rep_info) { - pthread_mutex_destroy(&bp->rep_info->vfr_lock); + if (bp->rep_info) pthread_mutex_destroy(&bp->rep_info->vfr_start_lock); - } } static void bnxt_drv_uninit(struct bnxt *bp) @@ -6099,13 +6097,6 @@ static int bnxt_init_rep_info(struct bnxt *bp) for (i = 0; i < BNXT_MAX_CFA_CODE; i++) bp->cfa_code_map[i] = BNXT_VF_IDX_INVALID; - rc = pthread_mutex_init(&bp->rep_info->vfr_lock, NULL); - if (rc) { - PMD_DRV_LOG(ERR, "Unable to initialize vfr_lock\n"); - bnxt_free_rep_info(bp); - return rc; - } - rc = pthread_mutex_init(&bp->rep_info->vfr_start_lock, NULL); if (rc) { PMD_DRV_LOG(ERR, "Unable to initialize vfr_start_lock\n"); diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c index 8a5b777793..4e09cd3e4a 100644 --- a/drivers/net/bnxt/bnxt_reps.c +++ b/drivers/net/bnxt/bnxt_reps.c @@ -124,8 +124,8 @@ bnxt_rep_tx_burst(void *tx_queue, qid = vfr_txq->txq->queue_id; vf_rep_bp = vfr_txq->bp; parent = vf_rep_bp->parent_dev->data->dev_private; - pthread_mutex_lock(&parent->rep_info->vfr_lock); ptxq = parent->tx_queues[qid]; + pthread_mutex_lock(&ptxq->txq_lock); ptxq->vfr_tx_cfa_action = vf_rep_bp->vfr_tx_cfa_action; @@ -134,9 +134,9 @@ bnxt_rep_tx_burst(void *tx_queue, vf_rep_bp->tx_pkts[qid]++; } - rc = bnxt_xmit_pkts(ptxq, tx_pkts, nb_pkts); + rc = _bnxt_xmit_pkts(ptxq, tx_pkts, nb_pkts); ptxq->vfr_tx_cfa_action = 0; - pthread_mutex_unlock(&parent->rep_info->vfr_lock); + pthread_mutex_unlock(&ptxq->txq_lock); return rc; } diff --git a/drivers/net/bnxt/bnxt_txq.c b/drivers/net/bnxt/bnxt_txq.c index c8745add5e..0f41193038 100644 --- a/drivers/net/bnxt/bnxt_txq.c +++ b/drivers/net/bnxt/bnxt_txq.c @@ -111,6 +111,7 @@ void bnxt_tx_queue_release_op(struct rte_eth_dev *dev, uint16_t queue_idx) txq->mz = NULL; rte_free(txq->free); + pthread_mutex_destroy(&txq->txq_lock); rte_free(txq); dev->data->tx_queues[queue_idx] = NULL; } @@ -194,6 +195,11 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev, goto err; } + rc = pthread_mutex_init(&txq->txq_lock, NULL); + if (rc != 0) { + PMD_DRV_LOG(ERR, "TxQ mutex init failed!"); + goto err; + } return 0; err: bnxt_tx_queue_release_op(eth_dev, queue_idx); diff --git a/drivers/net/bnxt/bnxt_txq.h b/drivers/net/bnxt/bnxt_txq.h index f3a03812ad..6e2d87de09 100644 --- a/drivers/net/bnxt/bnxt_txq.h +++ b/drivers/net/bnxt/bnxt_txq.h @@ -26,6 +26,7 @@ struct bnxt_tx_queue { int index; int tx_wake_thresh; uint32_t vfr_tx_cfa_action; + pthread_mutex_t txq_lock; struct bnxt_tx_ring_info *tx_ring; unsigned int cp_nr_rings; diff --git a/drivers/net/bnxt/bnxt_txr.c b/drivers/net/bnxt/bnxt_txr.c index 21c2217092..60bb3eea0c 100644 --- a/drivers/net/bnxt/bnxt_txr.c +++ b/drivers/net/bnxt/bnxt_txr.c @@ -515,6 +515,19 @@ static int bnxt_handle_tx_cp(struct bnxt_tx_queue *txq) uint16_t bnxt_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) +{ + struct bnxt_tx_queue *txq = tx_queue; + uint16_t rc; + + pthread_mutex_lock(&txq->txq_lock); + rc = _bnxt_xmit_pkts(tx_queue, tx_pkts, nb_pkts); + pthread_mutex_unlock(&txq->txq_lock); + + return rc; +} + +uint16_t _bnxt_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts) { int rc; uint16_t nb_tx_pkts = 0; diff --git a/drivers/net/bnxt/bnxt_txr.h b/drivers/net/bnxt/bnxt_txr.h index e11343c082..2be3ba4cac 100644 --- a/drivers/net/bnxt/bnxt_txr.h +++ b/drivers/net/bnxt/bnxt_txr.h @@ -46,7 +46,9 @@ void bnxt_free_tx_rings(struct bnxt *bp); int bnxt_init_one_tx_ring(struct bnxt_tx_queue *txq); int bnxt_init_tx_ring_struct(struct bnxt_tx_queue *txq, unsigned int socket_id); uint16_t bnxt_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, - uint16_t nb_pkts); + uint16_t nb_pkts); +uint16_t _bnxt_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts); #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64) uint16_t bnxt_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-03-07 01:05:42.291055114 +0000 +++ 0089-net-bnxt-modify-locking-for-representor-Tx.patch 2024-03-07 01:05:34.990944091 +0000 @@ -1 +1 @@ -From d46406c7070724c8cfd04b805849339d1178f528 Mon Sep 17 00:00:00 2001 +From d71a7702314a605d86c761d72bbf857504e59752 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit d46406c7070724c8cfd04b805849339d1178f528 ] + @@ -15 +16,0 @@ -Cc: stable@dpdk.org @@ -30 +31 @@ -index b604284256..23b0829e9e 100644 +index 5ea6f9b69a..3044c9e079 100644 @@ -33 +34 @@ -@@ -623,7 +623,6 @@ struct bnxt_mark_info { +@@ -542,7 +542,6 @@ struct bnxt_mark_info { @@ -42 +43 @@ -index 74064e8971..72debaca64 100644 +index c89a31592a..cb52ef2f84 100644 @@ -45 +46 @@ -@@ -1802,10 +1802,8 @@ bnxt_uninit_locks(struct bnxt *bp) +@@ -1648,10 +1648,8 @@ bnxt_uninit_locks(struct bnxt *bp) @@ -57 +58 @@ -@@ -6523,13 +6521,6 @@ static int bnxt_init_rep_info(struct bnxt *bp) +@@ -6099,13 +6097,6 @@ static int bnxt_init_rep_info(struct bnxt *bp) @@ -72 +73 @@ -index d96d972904..3a4720bc3c 100644 +index 8a5b777793..4e09cd3e4a 100644 @@ -98 +99 @@ -index 7d91e88c9d..05032f7807 100644 +index c8745add5e..0f41193038 100644 @@ -101 +102 @@ -@@ -114,6 +114,7 @@ void bnxt_tx_queue_release_op(struct rte_eth_dev *dev, uint16_t queue_idx) +@@ -111,6 +111,7 @@ void bnxt_tx_queue_release_op(struct rte_eth_dev *dev, uint16_t queue_idx) @@ -109 +110 @@ -@@ -197,6 +198,11 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev, +@@ -194,6 +195,11 @@ int bnxt_tx_queue_setup_op(struct rte_eth_dev *eth_dev, @@ -122 +123 @@ -index 3a483ad5c3..9e54985c4c 100644 +index f3a03812ad..6e2d87de09 100644 @@ -134 +135 @@ -index d74d271d91..7fc44e989d 100644 +index 21c2217092..60bb3eea0c 100644 @@ -137 +138 @@ -@@ -567,6 +567,19 @@ static int bnxt_handle_tx_cp(struct bnxt_tx_queue *txq) +@@ -515,6 +515,19 @@ static int bnxt_handle_tx_cp(struct bnxt_tx_queue *txq) @@ -158 +159 @@ -index e64ea2c7d1..09078d545d 100644 +index e11343c082..2be3ba4cac 100644 @@ -161 +162 @@ -@@ -47,7 +47,9 @@ void bnxt_free_tx_rings(struct bnxt *bp); +@@ -46,7 +46,9 @@ void bnxt_free_tx_rings(struct bnxt *bp);