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>, Paolo Abeni <pabeni@redhat.com>,
	Eric Dumazet <edumazet@google.com>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
	netdev@vger.kernel.org, Tariq Toukan <tariqt@nvidia.com>,
	Mark Bloch <mbloch@nvidia.com>, Roi Dayan <roid@nvidia.com>
Subject: [net-next 04/14] net/mlx5e: en_tc, re-factor query route port
Date: Wed, 31 May 2023 23:01:08 -0700	[thread overview]
Message-ID: <20230601060118.154015-5-saeed@kernel.org> (raw)
In-Reply-To: <20230601060118.154015-1-saeed@kernel.org>

From: Mark Bloch <mbloch@nvidia.com>

query for peer esw outside of if scope.
This is preparation for query route port over multiple peers.

Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../net/ethernet/mellanox/mlx5/core/en_tc.c   | 32 ++++++++-----------
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 6bf0fd3038bf..2135c0ef8560 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -1666,8 +1666,10 @@ int mlx5e_tc_query_route_vport(struct net_device *out_dev, struct net_device *ro
 {
 	struct mlx5e_priv *out_priv, *route_priv;
 	struct mlx5_core_dev *route_mdev;
+	struct mlx5_devcom *devcom;
 	struct mlx5_eswitch *esw;
 	u16 vhca_id;
+	int err;
 
 	out_priv = netdev_priv(out_dev);
 	esw = out_priv->mdev->priv.eswitch;
@@ -1675,28 +1677,20 @@ int mlx5e_tc_query_route_vport(struct net_device *out_dev, struct net_device *ro
 	route_mdev = route_priv->mdev;
 
 	vhca_id = MLX5_CAP_GEN(route_mdev, vhca_id);
-	if (mlx5_lag_is_active(out_priv->mdev)) {
-		struct mlx5_devcom *devcom;
-		int err;
-
-		/* In lag case we may get devices from different eswitch instances.
-		 * If we failed to get vport num, it means, mostly, that we on the wrong
-		 * eswitch.
-		 */
-		err = mlx5_eswitch_vhca_id_to_vport(esw, vhca_id, vport);
-		if (err != -ENOENT)
-			return err;
-
-		rcu_read_lock();
-		devcom = out_priv->mdev->priv.devcom;
-		esw = mlx5_devcom_get_peer_data_rcu(devcom, MLX5_DEVCOM_ESW_OFFLOADS);
-		err = esw ? mlx5_eswitch_vhca_id_to_vport(esw, vhca_id, vport) : -ENODEV;
-		rcu_read_unlock();
+	err = mlx5_eswitch_vhca_id_to_vport(esw, vhca_id, vport);
+	if (!err)
+		return err;
 
+	if (!mlx5_lag_is_active(out_priv->mdev))
 		return err;
-	}
 
-	return mlx5_eswitch_vhca_id_to_vport(esw, vhca_id, vport);
+	rcu_read_lock();
+	devcom = out_priv->mdev->priv.devcom;
+	esw = mlx5_devcom_get_peer_data_rcu(devcom, MLX5_DEVCOM_ESW_OFFLOADS);
+	err = esw ? mlx5_eswitch_vhca_id_to_vport(esw, vhca_id, vport) : -ENODEV;
+	rcu_read_unlock();
+
+	return err;
 }
 
 static int
-- 
2.40.1


  parent reply	other threads:[~2023-06-01  6:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-01  6:01 [pull request][net-next 00/14] mlx5 updates 2023-05-31 Saeed Mahameed
2023-06-01  6:01 ` [net-next 01/14] net/mlx5e: en_tc, Extend peer flows to a list Saeed Mahameed
2023-06-01  6:01 ` [net-next 02/14] net/mlx5e: tc, Refactor peer add/del flow Saeed Mahameed
2023-06-01  6:01 ` [net-next 03/14] net/mlx5e: rep, store send to vport rules per peer Saeed Mahameed
2023-06-02 16:02   ` Simon Horman
2023-06-02 18:46     ` Saeed Mahameed
2023-06-03  7:25       ` Simon Horman
2023-06-01  6:01 ` Saeed Mahameed [this message]
2023-06-01  6:01 ` [net-next 05/14] net/mlx5e: Handle offloads flows " Saeed Mahameed
2023-06-01  6:01 ` [net-next 06/14] net/mlx5: E-switch, enlarge peer miss group table Saeed Mahameed
2023-06-01  6:01 ` [net-next 07/14] net/mlx5: E-switch, refactor FDB miss rule add/remove Saeed Mahameed
2023-06-01  6:01 ` [net-next 08/14] net/mlx5: E-switch, Handle multiple master egress rules Saeed Mahameed
2023-06-01  6:01 ` [net-next 09/14] net/mlx5: E-switch, generalize shared FDB creation Saeed Mahameed
2023-06-01  6:01 ` [net-next 10/14] net/mlx5: DR, handle more than one peer domain Saeed Mahameed
2023-06-01  6:01 ` [net-next 11/14] net/mlx5: Devcom, Rename paired to ready Saeed Mahameed
2023-06-01  6:01 ` [net-next 12/14] net/mlx5: E-switch, mark devcom as not ready when all eswitches are unpaired Saeed Mahameed
2023-06-01  6:01 ` [net-next 13/14] net/mlx5: Devcom, introduce devcom_for_each_peer_entry Saeed Mahameed
2023-06-01  6:01 ` [net-next 14/14] net/mlx5: Devcom, extend mlx5_devcom_send_event to work with more than two devices Saeed Mahameed

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=20230601060118.154015-5-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=roid@nvidia.com \
    --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).