From: Tariq Toukan <tariqt@nvidia.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, <netdev@vger.kernel.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: Aleksandr Loktionov <aleksandr.loktionov@intel.com>,
Boris Pismenny <borisp@nvidia.com>, Chris Mi <cmi@nvidia.com>,
Cosmin Ratiu <cratiu@nvidia.com>,
Daniel Zahka <daniel.zahka@gmail.com>,
Dragos Tatulea <dtatulea@nvidia.com>,
Gal Pressman <gal@nvidia.com>,
Jacob Keller <jacob.e.keller@intel.com>,
Jianbo Liu <jianbol@nvidia.com>, Lama Kayal <lkayal@nvidia.com>,
Leon Romanovsky <leon@kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-rdma@vger.kernel.org>, Mark Bloch <mbloch@nvidia.com>,
Raed Salem <raeds@nvidia.com>,
Rahul Rameshbabu <rrameshbabu@nvidia.com>,
Saeed Mahameed <saeedm@nvidia.com>,
"Stanislav Fomichev" <sdf@fomichev.me>,
Stanislav Fomichev <sdf.kernel@gmail.com>,
"Tariq Toukan" <tariqt@nvidia.com>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Subject: [PATCH net-next 02/15] net/mlx5e: psp: Remove PSP steering mutexes
Date: Tue, 7 Jul 2026 16:08:45 +0300 [thread overview]
Message-ID: <20260707130858.969928-3-tariqt@nvidia.com> (raw)
In-Reply-To: <20260707130858.969928-1-tariqt@nvidia.com>
From: Cosmin Ratiu <cratiu@nvidia.com>
PSP steering uses three mutexes to serialize steering rule init/cleanup.
But init/cleanup are already serialized with the higher level devlink
lock (for both device init and esw mode changes), so there's no need for
multiple additional mutexes.
Remove them to make room for the new changes.
Later in the series, the netdev lock will be used to serialize PSP
steering changes from multiple sources, so don't bother adding
assertions now only for them to be overwritten later.
Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
.../mellanox/mlx5/core/en_accel/psp.c | 43 +++----------------
1 file changed, 7 insertions(+), 36 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp.c
index 4f2fa6756b82..d4686b5af776 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp.c
@@ -26,7 +26,6 @@ struct mlx5e_psp_tx {
struct mlx5_flow_table *ft;
struct mlx5_flow_group *fg;
struct mlx5_flow_handle *rule;
- struct mutex mutex; /* Protect PSP TX steering */
u32 refcnt;
struct mlx5_fc *tx_counter;
};
@@ -48,7 +47,6 @@ struct mlx5e_accel_fs_psp_prot {
struct mlx5_flow_destination default_dest;
struct mlx5e_psp_rx_err rx_err;
u32 refcnt;
- struct mutex prot_mutex; /* protect ESP4/ESP6 protocol */
struct mlx5_flow_handle *def_rule;
};
@@ -485,15 +483,14 @@ static int accel_psp_fs_rx_ft_get(struct mlx5e_psp_fs *fs, enum accel_fs_psp_typ
ttc = mlx5e_fs_get_ttc(fs->fs, false);
accel_psp = fs->rx_fs;
fs_prot = &accel_psp->fs_prot[type];
- mutex_lock(&fs_prot->prot_mutex);
if (fs_prot->refcnt++)
- goto out;
+ return 0;
/* create FT */
err = accel_psp_fs_rx_create(fs, type);
if (err) {
fs_prot->refcnt--;
- goto out;
+ return err;
}
/* connect */
@@ -501,9 +498,7 @@ static int accel_psp_fs_rx_ft_get(struct mlx5e_psp_fs *fs, enum accel_fs_psp_typ
dest.ft = fs_prot->ft;
mlx5_ttc_fwd_dest(ttc, fs_psp2tt(type), &dest);
-out:
- mutex_unlock(&fs_prot->prot_mutex);
- return err;
+ return 0;
}
static void accel_psp_fs_rx_ft_put(struct mlx5e_psp_fs *fs, enum accel_fs_psp_type type)
@@ -514,18 +509,14 @@ static void accel_psp_fs_rx_ft_put(struct mlx5e_psp_fs *fs, enum accel_fs_psp_ty
accel_psp = fs->rx_fs;
fs_prot = &accel_psp->fs_prot[type];
- mutex_lock(&fs_prot->prot_mutex);
if (--fs_prot->refcnt)
- goto out;
+ return;
/* disconnect */
mlx5_ttc_fwd_default_dest(ttc, fs_psp2tt(type));
/* remove FT */
accel_psp_fs_rx_destroy(fs, type);
-
-out:
- mutex_unlock(&fs_prot->prot_mutex);
}
static void accel_psp_fs_cleanup_rx(struct mlx5e_psp_fs *fs)
@@ -544,7 +535,6 @@ static void accel_psp_fs_cleanup_rx(struct mlx5e_psp_fs *fs)
mlx5_fc_destroy(fs->mdev, accel_psp->rx_counter);
for (i = 0; i < ACCEL_FS_PSP_NUM_TYPES; i++) {
fs_prot = &accel_psp->fs_prot[i];
- mutex_destroy(&fs_prot->prot_mutex);
WARN_ON(fs_prot->refcnt);
}
kfree(fs->rx_fs);
@@ -553,22 +543,15 @@ static void accel_psp_fs_cleanup_rx(struct mlx5e_psp_fs *fs)
static int accel_psp_fs_init_rx(struct mlx5e_psp_fs *fs)
{
- struct mlx5e_accel_fs_psp_prot *fs_prot;
struct mlx5e_accel_fs_psp *accel_psp;
struct mlx5_core_dev *mdev = fs->mdev;
struct mlx5_fc *flow_counter;
- enum accel_fs_psp_type i;
int err;
accel_psp = kzalloc_obj(*accel_psp);
if (!accel_psp)
return -ENOMEM;
- for (i = 0; i < ACCEL_FS_PSP_NUM_TYPES; i++) {
- fs_prot = &accel_psp->fs_prot[i];
- mutex_init(&fs_prot->prot_mutex);
- }
-
flow_counter = mlx5_fc_create(mdev, false);
if (IS_ERR(flow_counter)) {
mlx5_core_warn(mdev,
@@ -623,10 +606,6 @@ static int accel_psp_fs_init_rx(struct mlx5e_psp_fs *fs)
mlx5_fc_destroy(mdev, accel_psp->rx_counter);
accel_psp->rx_counter = NULL;
out_err:
- for (i = 0; i < ACCEL_FS_PSP_NUM_TYPES; i++) {
- fs_prot = &accel_psp->fs_prot[i];
- mutex_destroy(&fs_prot->prot_mutex);
- }
kfree(accel_psp);
fs->rx_fs = NULL;
@@ -763,17 +742,14 @@ static void accel_psp_fs_tx_destroy(struct mlx5e_psp_tx *tx_fs)
static int accel_psp_fs_tx_ft_get(struct mlx5e_psp_fs *fs)
{
struct mlx5e_psp_tx *tx_fs = fs->tx_fs;
- int err = 0;
+ int err;
- mutex_lock(&tx_fs->mutex);
if (tx_fs->refcnt++)
- goto out;
+ return 0;
err = accel_psp_fs_tx_create_ft_table(fs);
if (err)
tx_fs->refcnt--;
-out:
- mutex_unlock(&tx_fs->mutex);
return err;
}
@@ -781,13 +757,10 @@ static void accel_psp_fs_tx_ft_put(struct mlx5e_psp_fs *fs)
{
struct mlx5e_psp_tx *tx_fs = fs->tx_fs;
- mutex_lock(&tx_fs->mutex);
if (--tx_fs->refcnt)
- goto out;
+ return;
accel_psp_fs_tx_destroy(tx_fs);
-out:
- mutex_unlock(&tx_fs->mutex);
}
static void accel_psp_fs_cleanup_tx(struct mlx5e_psp_fs *fs)
@@ -798,7 +771,6 @@ static void accel_psp_fs_cleanup_tx(struct mlx5e_psp_fs *fs)
return;
mlx5_fc_destroy(fs->mdev, tx_fs->tx_counter);
- mutex_destroy(&tx_fs->mutex);
WARN_ON(tx_fs->refcnt);
kfree(tx_fs);
fs->tx_fs = NULL;
@@ -828,7 +800,6 @@ static int accel_psp_fs_init_tx(struct mlx5e_psp_fs *fs)
return PTR_ERR(flow_counter);
}
tx_fs->tx_counter = flow_counter;
- mutex_init(&tx_fs->mutex);
tx_fs->ns = ns;
fs->tx_fs = tx_fs;
return 0;
--
2.44.0
next prev parent reply other threads:[~2026-07-07 13:10 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 13:08 [PATCH net-next 00/15] net/mlx5e: PSP cleanups and improvements Tariq Toukan
2026-07-07 13:08 ` [PATCH net-next 01/15] net/mlx5e: psp: Rename the saved psp_dev to 'psd' Tariq Toukan
2026-07-07 14:11 ` Loktionov, Aleksandr
2026-07-07 13:08 ` Tariq Toukan [this message]
2026-07-07 14:14 ` [PATCH net-next 02/15] net/mlx5e: psp: Remove PSP steering mutexes Loktionov, Aleksandr
2026-07-07 13:08 ` [PATCH net-next 03/15] net/mlx5e: psp: Remove unneeded ref counting for PSP steering Tariq Toukan
2026-07-07 14:15 ` Loktionov, Aleksandr
2026-07-07 13:08 ` [PATCH net-next 04/15] net/mlx5e: psp: Merge rx_err rule add/delete with ft create/delete Tariq Toukan
2026-07-07 13:08 ` [PATCH net-next 05/15] net/mlx5e: psp: Use helpers for steering object manipulation Tariq Toukan
2026-07-07 13:08 ` [PATCH net-next 06/15] net/mlx5e: psp: Factor out drop rule creation code Tariq Toukan
2026-07-07 13:08 ` [PATCH net-next 07/15] net/mlx5e: psp: Remove unused PSP syndrome copy action Tariq Toukan
2026-07-07 13:08 ` [PATCH net-next 08/15] net/mlx5e: psp: Rename and consolidate steering functions Tariq Toukan
2026-07-07 13:08 ` [PATCH net-next 09/15] net/mlx5e: psp: Adjust rx_check FT size and use a drop_group Tariq Toukan
2026-07-07 13:08 ` [PATCH net-next 10/15] net/mlx5e: psp: Add an RX steering table Tariq Toukan
2026-07-07 13:08 ` [PATCH net-next 11/15] net/mlx5e: psp: Use a single rx_check table Tariq Toukan
2026-07-07 13:08 ` [PATCH net-next 12/15] net/mlx5e: psp: Flatten steering structures Tariq Toukan
2026-07-07 13:08 ` [PATCH net-next 13/15] net/mlx5e: psp: Make PSP steering config dynamic Tariq Toukan
2026-07-07 13:08 ` [PATCH net-next 14/15] net/mlx5e: Return errors from profile->enable Tariq Toukan
2026-07-07 13:08 ` [PATCH net-next 15/15] net/mlx5e: psp: Report PSP dev registration errors Tariq Toukan
2026-07-07 18:29 ` [PATCH net-next 00/15] net/mlx5e: PSP cleanups and improvements Daniel Zahka
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=20260707130858.969928-3-tariqt@nvidia.com \
--to=tariqt@nvidia.com \
--cc=aleksandr.loktionov@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=borisp@nvidia.com \
--cc=cmi@nvidia.com \
--cc=cratiu@nvidia.com \
--cc=daniel.zahka@gmail.com \
--cc=davem@davemloft.net \
--cc=dtatulea@nvidia.com \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=jacob.e.keller@intel.com \
--cc=jianbol@nvidia.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=lkayal@nvidia.com \
--cc=mbloch@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=raeds@nvidia.com \
--cc=rrameshbabu@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=sdf.kernel@gmail.com \
--cc=sdf@fomichev.me \
--cc=willemdebruijn.kernel@gmail.com \
/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