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 03/15] net/mlx5e: psp: Remove unneeded ref counting for PSP steering
Date: Tue, 7 Jul 2026 16:08:46 +0300 [thread overview]
Message-ID: <20260707130858.969928-4-tariqt@nvidia.com> (raw)
In-Reply-To: <20260707130858.969928-1-tariqt@nvidia.com>
From: Cosmin Ratiu <cratiu@nvidia.com>
PSP steering uses reference counting for TX and RX steering tables, but
there's only a single reference for each acquired and thus the reference
counting is unnecessary.
Remove it and consolidate functions to simplify the code.
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 | 129 +++++-------------
1 file changed, 33 insertions(+), 96 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 d4686b5af776..a69c4e2821e9 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;
- u32 refcnt;
struct mlx5_fc *tx_counter;
};
@@ -46,7 +45,6 @@ struct mlx5e_accel_fs_psp_prot {
struct mlx5_modify_hdr *rx_modify_hdr;
struct mlx5_flow_destination default_dest;
struct mlx5e_psp_rx_err rx_err;
- u32 refcnt;
struct mlx5_flow_handle *def_rule;
};
@@ -469,75 +467,18 @@ static int accel_psp_fs_rx_create(struct mlx5e_psp_fs *fs, enum accel_fs_psp_typ
return err;
}
-static int accel_psp_fs_rx_ft_get(struct mlx5e_psp_fs *fs, enum accel_fs_psp_type type)
-{
- struct mlx5e_accel_fs_psp_prot *fs_prot;
- struct mlx5_flow_destination dest = {};
- struct mlx5e_accel_fs_psp *accel_psp;
- struct mlx5_ttc_table *ttc;
- int err = 0;
-
- if (!fs || !fs->rx_fs)
- return -EINVAL;
-
- ttc = mlx5e_fs_get_ttc(fs->fs, false);
- accel_psp = fs->rx_fs;
- fs_prot = &accel_psp->fs_prot[type];
- if (fs_prot->refcnt++)
- return 0;
-
- /* create FT */
- err = accel_psp_fs_rx_create(fs, type);
- if (err) {
- fs_prot->refcnt--;
- return err;
- }
-
- /* connect */
- dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
- dest.ft = fs_prot->ft;
- mlx5_ttc_fwd_dest(ttc, fs_psp2tt(type), &dest);
-
- return 0;
-}
-
-static void accel_psp_fs_rx_ft_put(struct mlx5e_psp_fs *fs, enum accel_fs_psp_type type)
-{
- struct mlx5_ttc_table *ttc = mlx5e_fs_get_ttc(fs->fs, false);
- struct mlx5e_accel_fs_psp_prot *fs_prot;
- struct mlx5e_accel_fs_psp *accel_psp;
-
- accel_psp = fs->rx_fs;
- fs_prot = &accel_psp->fs_prot[type];
- if (--fs_prot->refcnt)
- return;
-
- /* disconnect */
- mlx5_ttc_fwd_default_dest(ttc, fs_psp2tt(type));
-
- /* remove FT */
- accel_psp_fs_rx_destroy(fs, type);
-}
-
static void accel_psp_fs_cleanup_rx(struct mlx5e_psp_fs *fs)
{
- struct mlx5e_accel_fs_psp_prot *fs_prot;
- struct mlx5e_accel_fs_psp *accel_psp;
- enum accel_fs_psp_type i;
+ struct mlx5e_accel_fs_psp *accel_psp = fs->rx_fs;
- if (!fs->rx_fs)
+ if (!accel_psp)
return;
- accel_psp = fs->rx_fs;
mlx5_fc_destroy(fs->mdev, accel_psp->rx_bad_counter);
mlx5_fc_destroy(fs->mdev, accel_psp->rx_err_counter);
mlx5_fc_destroy(fs->mdev, accel_psp->rx_auth_fail_counter);
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];
- WARN_ON(fs_prot->refcnt);
- }
- kfree(fs->rx_fs);
+ kfree(accel_psp);
fs->rx_fs = NULL;
}
@@ -614,17 +555,27 @@ static int accel_psp_fs_init_rx(struct mlx5e_psp_fs *fs)
void mlx5_accel_psp_fs_cleanup_rx_tables(struct mlx5e_priv *priv)
{
+ struct mlx5_ttc_table *ttc;
+ struct mlx5e_psp_fs *fs;
int i;
if (!priv->psp)
return;
- for (i = 0; i < ACCEL_FS_PSP_NUM_TYPES; i++)
- accel_psp_fs_rx_ft_put(priv->psp->fs, i);
+ fs = priv->psp->fs;
+ ttc = mlx5e_fs_get_ttc(fs->fs, false);
+ for (i = 0; i < ACCEL_FS_PSP_NUM_TYPES; i++) {
+ /* disconnect */
+ mlx5_ttc_fwd_default_dest(ttc, fs_psp2tt(i));
+
+ /* remove FT */
+ accel_psp_fs_rx_destroy(fs, i);
+ }
}
int mlx5_accel_psp_fs_init_rx_tables(struct mlx5e_priv *priv)
{
+ struct mlx5_ttc_table *ttc;
struct mlx5e_psp_fs *fs;
int err, i;
@@ -632,19 +583,30 @@ int mlx5_accel_psp_fs_init_rx_tables(struct mlx5e_priv *priv)
return 0;
fs = priv->psp->fs;
+ ttc = mlx5e_fs_get_ttc(fs->fs, false);
+
for (i = 0; i < ACCEL_FS_PSP_NUM_TYPES; i++) {
- err = accel_psp_fs_rx_ft_get(fs, i);
+ struct mlx5e_accel_fs_psp_prot *fs_prot;
+ struct mlx5_flow_destination dest = {};
+
+ /* create FT */
+ err = accel_psp_fs_rx_create(fs, i);
if (err)
goto out_err;
+
+ /* connect */
+ dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
+ fs_prot = &fs->rx_fs->fs_prot[i];
+ dest.ft = fs_prot->ft;
+ mlx5_ttc_fwd_dest(ttc, fs_psp2tt(i), &dest);
}
return 0;
out_err:
- i--;
- while (i >= 0) {
- accel_psp_fs_rx_ft_put(fs, i);
- --i;
+ while (--i >= 0) {
+ mlx5_ttc_fwd_default_dest(ttc, fs_psp2tt(i));
+ accel_psp_fs_rx_destroy(fs, i);
}
return err;
@@ -739,30 +701,6 @@ static void accel_psp_fs_tx_destroy(struct mlx5e_psp_tx *tx_fs)
mlx5_destroy_flow_table(tx_fs->ft);
}
-static int accel_psp_fs_tx_ft_get(struct mlx5e_psp_fs *fs)
-{
- struct mlx5e_psp_tx *tx_fs = fs->tx_fs;
- int err;
-
- if (tx_fs->refcnt++)
- return 0;
-
- err = accel_psp_fs_tx_create_ft_table(fs);
- if (err)
- tx_fs->refcnt--;
- return err;
-}
-
-static void accel_psp_fs_tx_ft_put(struct mlx5e_psp_fs *fs)
-{
- struct mlx5e_psp_tx *tx_fs = fs->tx_fs;
-
- if (--tx_fs->refcnt)
- return;
-
- accel_psp_fs_tx_destroy(tx_fs);
-}
-
static void accel_psp_fs_cleanup_tx(struct mlx5e_psp_fs *fs)
{
struct mlx5e_psp_tx *tx_fs = fs->tx_fs;
@@ -771,7 +709,6 @@ static void accel_psp_fs_cleanup_tx(struct mlx5e_psp_fs *fs)
return;
mlx5_fc_destroy(fs->mdev, tx_fs->tx_counter);
- WARN_ON(tx_fs->refcnt);
kfree(tx_fs);
fs->tx_fs = NULL;
}
@@ -844,7 +781,7 @@ void mlx5_accel_psp_fs_cleanup_tx_tables(struct mlx5e_priv *priv)
if (!priv->psp)
return;
- accel_psp_fs_tx_ft_put(priv->psp->fs);
+ accel_psp_fs_tx_destroy(priv->psp->fs->tx_fs);
}
int mlx5_accel_psp_fs_init_tx_tables(struct mlx5e_priv *priv)
@@ -852,7 +789,7 @@ int mlx5_accel_psp_fs_init_tx_tables(struct mlx5e_priv *priv)
if (!priv->psp)
return 0;
- return accel_psp_fs_tx_ft_get(priv->psp->fs);
+ return accel_psp_fs_tx_create_ft_table(priv->psp->fs);
}
static void mlx5e_accel_psp_fs_cleanup(struct mlx5e_psp_fs *fs)
--
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 ` [PATCH net-next 02/15] net/mlx5e: psp: Remove PSP steering mutexes Tariq Toukan
2026-07-07 14:14 ` Loktionov, Aleksandr
2026-07-07 13:08 ` Tariq Toukan [this message]
2026-07-07 14:15 ` [PATCH net-next 03/15] net/mlx5e: psp: Remove unneeded ref counting for PSP steering 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-4-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