netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, Maxim Mikityanskiy <maximmi@nvidia.com>,
	Lama Kayal <lkayal@nvidia.com>, Tariq Toukan <tariqt@nvidia.com>,
	Saeed Mahameed <saeedm@nvidia.com>
Subject: [net 08/10] net/mlx5e: Add activate/deactivate stage to XDPSQ
Date: Fri, 19 Nov 2021 11:58:11 -0800	[thread overview]
Message-ID: <20211119195813.739586-9-saeed@kernel.org> (raw)
In-Reply-To: <20211119195813.739586-1-saeed@kernel.org>

From: Maxim Mikityanskiy <maximmi@nvidia.com>

Normally, the lifecycle of a queue in mlx5e has four transitions: open,
activate, deactivate and close. However, XDPSQs combine open with
activate and close with deactivate. This patch cleans it up by properly
separating these stages in order to make it possible to move
synchronize_net in the following fix.

Fixes: 0a06382fa406 ("net/mlx5e: Encapsulate open/close queues into a function"
Signed-off-by: Maxim Mikityanskiy <maximmi@nvidia.com>
Signed-off-by: Lama Kayal <lkayal@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en.h  |  2 ++
 .../mellanox/mlx5/core/en/xsk/setup.c         |  4 ++--
 .../net/ethernet/mellanox/mlx5/core/en_main.c | 20 +++++++++++++++----
 3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index f0ac6b0d9653..a0a5d6321098 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -1020,6 +1020,8 @@ void mlx5e_close_icosq(struct mlx5e_icosq *sq);
 int mlx5e_open_xdpsq(struct mlx5e_channel *c, struct mlx5e_params *params,
 		     struct mlx5e_sq_param *param, struct xsk_buff_pool *xsk_pool,
 		     struct mlx5e_xdpsq *sq, bool is_redirect);
+void mlx5e_activate_xdpsq(struct mlx5e_xdpsq *sq);
+void mlx5e_deactivate_xdpsq(struct mlx5e_xdpsq *sq);
 void mlx5e_close_xdpsq(struct mlx5e_xdpsq *sq);
 
 struct mlx5e_create_cq_param {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c
index 538bc2419bd8..39873e834766 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c
@@ -171,7 +171,7 @@ void mlx5e_close_xsk(struct mlx5e_channel *c)
 void mlx5e_activate_xsk(struct mlx5e_channel *c)
 {
 	set_bit(MLX5E_RQ_STATE_ENABLED, &c->xskrq.state);
-	/* TX queue is created active. */
+	mlx5e_activate_xdpsq(&c->xsksq);
 
 	spin_lock_bh(&c->async_icosq_lock);
 	mlx5e_trigger_irq(&c->async_icosq);
@@ -180,6 +180,6 @@ void mlx5e_activate_xsk(struct mlx5e_channel *c)
 
 void mlx5e_deactivate_xsk(struct mlx5e_channel *c)
 {
+	mlx5e_deactivate_xdpsq(&c->xsksq);
 	mlx5e_deactivate_rq(&c->xskrq);
-	/* TX queue is disabled on close. */
 }
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 65571593ec5c..6914fc17277a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -1647,7 +1647,6 @@ int mlx5e_open_xdpsq(struct mlx5e_channel *c, struct mlx5e_params *params,
 	csp.cqn             = sq->cq.mcq.cqn;
 	csp.wq_ctrl         = &sq->wq_ctrl;
 	csp.min_inline_mode = sq->min_inline_mode;
-	set_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
 	err = mlx5e_create_sq_rdy(c->mdev, param, &csp, 0, &sq->sqn);
 	if (err)
 		goto err_free_xdpsq;
@@ -1687,18 +1686,25 @@ int mlx5e_open_xdpsq(struct mlx5e_channel *c, struct mlx5e_params *params,
 	return 0;
 
 err_free_xdpsq:
-	clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
 	mlx5e_free_xdpsq(sq);
 
 	return err;
 }
 
-void mlx5e_close_xdpsq(struct mlx5e_xdpsq *sq)
+void mlx5e_activate_xdpsq(struct mlx5e_xdpsq *sq)
 {
-	struct mlx5e_channel *c = sq->channel;
+	set_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
+}
 
+void mlx5e_deactivate_xdpsq(struct mlx5e_xdpsq *sq)
+{
 	clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
 	synchronize_net(); /* Sync with NAPI. */
+}
+
+void mlx5e_close_xdpsq(struct mlx5e_xdpsq *sq)
+{
+	struct mlx5e_channel *c = sq->channel;
 
 	mlx5e_destroy_sq(c->mdev, sq->sqn);
 	mlx5e_free_xdpsq_descs(sq);
@@ -2249,7 +2255,10 @@ static void mlx5e_activate_channel(struct mlx5e_channel *c)
 		mlx5e_activate_txqsq(&c->sq[tc]);
 	mlx5e_activate_icosq(&c->icosq);
 	mlx5e_activate_icosq(&c->async_icosq);
+	if (c->xdp)
+		mlx5e_activate_xdpsq(&c->rq_xdpsq);
 	mlx5e_activate_rq(&c->rq);
+	mlx5e_activate_xdpsq(&c->xdpsq);
 
 	if (test_bit(MLX5E_CHANNEL_STATE_XSK, c->state))
 		mlx5e_activate_xsk(c);
@@ -2262,7 +2271,10 @@ static void mlx5e_deactivate_channel(struct mlx5e_channel *c)
 	if (test_bit(MLX5E_CHANNEL_STATE_XSK, c->state))
 		mlx5e_deactivate_xsk(c);
 
+	mlx5e_deactivate_xdpsq(&c->xdpsq);
 	mlx5e_deactivate_rq(&c->rq);
+	if (c->xdp)
+		mlx5e_deactivate_xdpsq(&c->rq_xdpsq);
 	mlx5e_deactivate_icosq(&c->async_icosq);
 	mlx5e_deactivate_icosq(&c->icosq);
 	for (tc = 0; tc < c->num_tc; tc++)
-- 
2.31.1


  parent reply	other threads:[~2021-11-19 19:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-19 19:58 [pull request][net 00/10] mlx5 fixes 2021-11-19 Saeed Mahameed
2021-11-19 19:58 ` [net 01/10] net/mlx5: E-switch, Respect BW share of the new group Saeed Mahameed
2021-11-19 19:58 ` [net 02/10] net/mlx5e: IPsec: Fix Software parser inner l3 type setting in case of encapsulation Saeed Mahameed
2021-11-19 19:58 ` [net 03/10] net/mlx5: Fix too early queueing of log timestamp work Saeed Mahameed
2021-11-19 19:58 ` [net 04/10] net/mlx5: Fix access to a non-supported register Saeed Mahameed
2021-11-19 19:58 ` [net 05/10] net/mlx5e: SHAMPO, Fix constant expression result Saeed Mahameed
2021-11-19 19:58 ` [net 06/10] net/mlx5: E-Switch, fix single FDB creation on BlueField Saeed Mahameed
2021-11-19 19:58 ` [net 07/10] net/mlx5e: Fix missing IPsec statistics on uplink representor Saeed Mahameed
2021-11-19 19:58 ` Saeed Mahameed [this message]
2021-11-20  4:00   ` [net 08/10] net/mlx5e: Add activate/deactivate stage to XDPSQ Jakub Kicinski
2021-11-19 19:58 ` [net 09/10] net/mlx5e: Call synchronize_net outside of deactivating a queue Saeed Mahameed
2021-11-19 19:58 ` [net 10/10] net/mlx5e: Do synchronize_net only once when deactivating channels Saeed Mahameed
2021-11-20  4:03   ` Jakub Kicinski

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=20211119195813.739586-9-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=lkayal@nvidia.com \
    --cc=maximmi@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.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;
as well as URLs for NNTP newsgroup(s).