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>,
	Daniel Jurgens <danielj@nvidia.com>, William Tu <witu@nvidia.com>
Subject: [net-next 04/15] net/mlx5: Update vport caps query/set for EC VFs
Date: Fri,  9 Jun 2023 18:42:43 -0700	[thread overview]
Message-ID: <20230610014254.343576-5-saeed@kernel.org> (raw)
In-Reply-To: <20230610014254.343576-1-saeed@kernel.org>

From: Daniel Jurgens <danielj@nvidia.com>

These functions are for query/set by vport, there was an underlying
assumption that vport was equal to function ID. That's not the case for
EC VF functions. Set the ec_vf_function bit accordingly.

Signed-off-by: Daniel Jurgens <danielj@nvidia.com>
Reviewed-by: William Tu <witu@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../ethernet/mellanox/mlx5/core/mlx5_core.h   |  6 +++---
 .../net/ethernet/mellanox/mlx5/core/vport.c   | 19 +++++++++++++++----
 include/linux/mlx5/vport.h                    |  2 +-
 3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
index 0e7b5c6e4020..7ca0c7a547aa 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
@@ -325,10 +325,10 @@ void mlx5_unload_one_devl_locked(struct mlx5_core_dev *dev, bool suspend);
 int mlx5_load_one(struct mlx5_core_dev *dev, bool recovery);
 int mlx5_load_one_devl_locked(struct mlx5_core_dev *dev, bool recovery);
 
-int mlx5_vport_set_other_func_cap(struct mlx5_core_dev *dev, const void *hca_cap, u16 function_id,
+int mlx5_vport_set_other_func_cap(struct mlx5_core_dev *dev, const void *hca_cap, u16 vport,
 				  u16 opmod);
-#define mlx5_vport_get_other_func_general_cap(dev, fid, out)		\
-	mlx5_vport_get_other_func_cap(dev, fid, out, MLX5_CAP_GENERAL)
+#define mlx5_vport_get_other_func_general_cap(dev, vport, out)		\
+	mlx5_vport_get_other_func_cap(dev, vport, out, MLX5_CAP_GENERAL)
 
 void mlx5_events_work_enqueue(struct mlx5_core_dev *dev, struct work_struct *work);
 static inline u32 mlx5_sriov_get_vf_total_msix(struct pci_dev *pdev)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vport.c b/drivers/net/ethernet/mellanox/mlx5/core/vport.c
index bc66b078a8a1..6d3984dd5b21 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/vport.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/vport.c
@@ -1161,23 +1161,32 @@ u64 mlx5_query_nic_system_image_guid(struct mlx5_core_dev *mdev)
 }
 EXPORT_SYMBOL_GPL(mlx5_query_nic_system_image_guid);
 
-int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 function_id, void *out,
+static int mlx5_vport_to_func_id(const struct mlx5_core_dev *dev, u16 vport, bool ec_vf_func)
+{
+	return ec_vf_func ? vport - mlx5_core_ec_vf_vport_base(dev)
+			  : vport;
+}
+
+int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 vport, void *out,
 				  u16 opmod)
 {
+	bool ec_vf_func = mlx5_core_is_ec_vf_vport(dev, vport);
 	u8 in[MLX5_ST_SZ_BYTES(query_hca_cap_in)] = {};
 
 	opmod = (opmod << 1) | (HCA_CAP_OPMOD_GET_MAX & 0x01);
 	MLX5_SET(query_hca_cap_in, in, opcode, MLX5_CMD_OP_QUERY_HCA_CAP);
 	MLX5_SET(query_hca_cap_in, in, op_mod, opmod);
-	MLX5_SET(query_hca_cap_in, in, function_id, function_id);
+	MLX5_SET(query_hca_cap_in, in, function_id, mlx5_vport_to_func_id(dev, vport, ec_vf_func));
 	MLX5_SET(query_hca_cap_in, in, other_function, true);
+	MLX5_SET(query_hca_cap_in, in, ec_vf_function, ec_vf_func);
 	return mlx5_cmd_exec_inout(dev, query_hca_cap, in, out);
 }
 EXPORT_SYMBOL_GPL(mlx5_vport_get_other_func_cap);
 
 int mlx5_vport_set_other_func_cap(struct mlx5_core_dev *dev, const void *hca_cap,
-				  u16 function_id, u16 opmod)
+				  u16 vport, u16 opmod)
 {
+	bool ec_vf_func = mlx5_core_is_ec_vf_vport(dev, vport);
 	int set_sz = MLX5_ST_SZ_BYTES(set_hca_cap_in);
 	void *set_hca_cap;
 	void *set_ctx;
@@ -1191,8 +1200,10 @@ int mlx5_vport_set_other_func_cap(struct mlx5_core_dev *dev, const void *hca_cap
 	MLX5_SET(set_hca_cap_in, set_ctx, op_mod, opmod << 1);
 	set_hca_cap = MLX5_ADDR_OF(set_hca_cap_in, set_ctx, capability);
 	memcpy(set_hca_cap, hca_cap, MLX5_ST_SZ_BYTES(cmd_hca_cap));
-	MLX5_SET(set_hca_cap_in, set_ctx, function_id, function_id);
+	MLX5_SET(set_hca_cap_in, set_ctx, function_id,
+		 mlx5_vport_to_func_id(dev, vport, ec_vf_func));
 	MLX5_SET(set_hca_cap_in, set_ctx, other_function, true);
+	MLX5_SET(set_hca_cap_in, set_ctx, ec_vf_function, ec_vf_func);
 	ret = mlx5_cmd_exec_in(dev, set_hca_cap, set_ctx);
 
 	kfree(set_ctx);
diff --git a/include/linux/mlx5/vport.h b/include/linux/mlx5/vport.h
index 7f31432f44c2..fbb9bf447889 100644
--- a/include/linux/mlx5/vport.h
+++ b/include/linux/mlx5/vport.h
@@ -132,6 +132,6 @@ int mlx5_nic_vport_affiliate_multiport(struct mlx5_core_dev *master_mdev,
 int mlx5_nic_vport_unaffiliate_multiport(struct mlx5_core_dev *port_mdev);
 
 u64 mlx5_query_nic_system_image_guid(struct mlx5_core_dev *mdev);
-int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 function_id, void *out,
+int mlx5_vport_get_other_func_cap(struct mlx5_core_dev *dev, u16 vport, void *out,
 				  u16 opmod);
 #endif /* __MLX5_VPORT_H__ */
-- 
2.40.1


  parent reply	other threads:[~2023-06-10  1:43 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-10  1:42 [pull request][net-next 00/15] mlx5 updates 2023-06-09 Saeed Mahameed
2023-06-10  1:42 ` [net-next 01/15] net/mlx5: Simplify unload all rep code Saeed Mahameed
2023-06-12 11:00   ` patchwork-bot+netdevbpf
2023-06-10  1:42 ` [net-next 02/15] net/mlx5: mlx5_ifc updates for embedded CPU SRIOV Saeed Mahameed
2023-06-10  1:42 ` [net-next 03/15] net/mlx5: Enable devlink port for embedded cpu VF vports Saeed Mahameed
2023-06-10  1:42 ` Saeed Mahameed [this message]
2023-06-10  1:42 ` [net-next 05/15] net/mlx5: Add management of EC " Saeed Mahameed
2023-06-10  1:42 ` [net-next 06/15] net/mlx5: Add/remove peer miss rules for EC VFs Saeed Mahameed
2023-06-10  1:42 ` [net-next 07/15] net/mlx5: Add new page type for EC VF pages Saeed Mahameed
2023-06-10  1:42 ` [net-next 08/15] net/mlx5: Use correct vport when restoring GUIDs Saeed Mahameed
2023-06-10  1:42 ` [net-next 09/15] net/mlx5: Query correct caps for min msix vectors Saeed Mahameed
2023-06-10  1:42 ` [net-next 10/15] net/mlx5: Update SRIOV enable/disable to handle EC/VFs Saeed Mahameed
2023-06-10  1:42 ` [net-next 11/15] net/mlx5: Set max number of embedded CPU VFs Saeed Mahameed
2023-06-10  1:42 ` [net-next 12/15] net/mlx5: Split function_setup() to enable and open functions Saeed Mahameed
2023-06-10  1:42 ` [net-next 13/15] net/mlx5: Move esw multiport devlink param to eswitch code Saeed Mahameed
2023-06-10  1:42 ` [net-next 14/15] net/mlx5: Light probe local SFs Saeed Mahameed
2023-06-10  7:01   ` Jakub Kicinski
2023-06-11  4:15     ` Saeed Mahameed
2023-06-11  5:10       ` Samudrala, Sridhar
2023-06-13 23:41         ` Saeed Mahameed
2023-06-12 17:51       ` Jakub Kicinski
2023-06-13 23:32         ` Saeed Mahameed
2023-06-14  2:05           ` Jakub Kicinski
2023-06-15 10:51             ` Jiri Pirko
2023-06-15 16:37               ` Jakub Kicinski
2023-06-15 17:37                 ` Jiri Pirko
2023-06-15 19:33                   ` Jakub Kicinski
2023-06-21 13:14                     ` Jiri Pirko
2023-06-21 18:23                       ` Jakub Kicinski
2023-06-22  6:42                         ` Jiri Pirko
2023-06-22  6:38                       ` Jiri Pirko
2023-06-22 16:35                         ` Jakub Kicinski
2023-06-23  9:27                           ` Jiri Pirko
2023-06-23 15:21                             ` Jakub Kicinski
2023-06-24  9:33                               ` Jiri Pirko
2023-06-24 20:47                                 ` Jakub Kicinski
2023-06-27 10:12                                   ` Jiri Pirko
2023-06-27 15:24                                     ` Jakub Kicinski
2023-06-27 17:16                                       ` Jiri Pirko
2023-06-27 17:35                                         ` Jakub Kicinski
2023-06-10  1:42 ` [net-next 15/15] net/mlx5e: Remove a useless function call 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=20230610014254.343576-5-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=danielj@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    --cc=witu@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).