From: Tariq Toukan <tariqt@nvidia.com>
To: Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
Leon Romanovsky <leon@kernel.org>,
Tariq Toukan <tariqt@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
"Simon Horman" <horms@kernel.org>,
Adithya Jayachandran <ajayachandra@nvidia.com>,
Jiri Pirko <jiri@resnulli.us>, Moshe Shemesh <moshe@nvidia.com>,
Or Har-Toov <ohartoov@nvidia.com>, Shay Drori <shayd@nvidia.com>,
Parav Pandit <parav@nvidia.com>,
Daniel Jurgens <danielj@nvidia.com>, Kees Cook <kees@kernel.org>,
Cosmin Ratiu <cratiu@nvidia.com>,
Carolina Jubran <cjubran@nvidia.com>, <netdev@vger.kernel.org>,
<linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Gal Pressman <gal@nvidia.com>
Subject: [PATCH net-next 02/12] net/mlx5: Introduce generic helper for PF SFs info
Date: Thu, 21 May 2026 14:08:33 +0300 [thread overview]
Message-ID: <20260521110843.367329-3-tariqt@nvidia.com> (raw)
In-Reply-To: <20260521110843.367329-1-tariqt@nvidia.com>
From: Moshe Shemesh <moshe@nvidia.com>
Introduce mlx5_esw_sf_max_pf_functions() that queries a PF's max_num_sf
and sf_base_id using mlx5_vport_get_other_func_general_cap(), which
supports both function_id and vhca_id based addressing.
Refactor mlx5_esw_sf_max_hpf_functions() into a thin wrapper that adds
the host PF precondition checks and calls the new generic helper. Remove
mlx5_query_hca_cap_host_pf() as it is not used anymore.
This prepares for querying SFs info of Satellite PFs.
Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/eswitch.c | 38 +++++++++----------
1 file changed, 17 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index e75925a99852..815538ba754f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -2023,37 +2023,20 @@ void mlx5_eswitch_disable(struct mlx5_eswitch *esw)
mlx5_lag_enable_change(esw->dev);
}
-static int mlx5_query_hca_cap_host_pf(struct mlx5_core_dev *dev, void *out)
-{
- u16 opmod = (MLX5_CAP_GENERAL << 1) | (HCA_CAP_OPMOD_GET_MAX & 0x01);
- u8 in[MLX5_ST_SZ_BYTES(query_hca_cap_in)] = {};
-
- 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, MLX5_VPORT_HOST_PF);
- MLX5_SET(query_hca_cap_in, in, other_function, true);
- return mlx5_cmd_exec_inout(dev, query_hca_cap, in, out);
-}
-
-int mlx5_esw_sf_max_hpf_functions(struct mlx5_core_dev *dev, u16 *max_sfs, u16 *sf_base_id)
-
+static int mlx5_esw_sf_max_pf_functions(struct mlx5_core_dev *dev,
+ u16 vport_num, u16 *max_sfs,
+ u16 *sf_base_id)
{
int query_out_sz = MLX5_ST_SZ_BYTES(query_hca_cap_out);
void *query_ctx;
void *hca_caps;
int err;
- if (!mlx5_core_is_ecpf(dev) ||
- !mlx5_esw_host_functions_enabled(dev)) {
- *max_sfs = 0;
- return 0;
- }
-
query_ctx = kzalloc(query_out_sz, GFP_KERNEL);
if (!query_ctx)
return -ENOMEM;
- err = mlx5_query_hca_cap_host_pf(dev, query_ctx);
+ err = mlx5_vport_get_other_func_general_cap(dev, vport_num, query_ctx);
if (err)
goto out_free;
@@ -2066,6 +2049,19 @@ int mlx5_esw_sf_max_hpf_functions(struct mlx5_core_dev *dev, u16 *max_sfs, u16 *
return err;
}
+int mlx5_esw_sf_max_hpf_functions(struct mlx5_core_dev *dev, u16 *max_sfs,
+ u16 *sf_base_id)
+{
+ if (!mlx5_core_is_ecpf(dev) ||
+ !mlx5_esw_host_functions_enabled(dev)) {
+ *max_sfs = 0;
+ return 0;
+ }
+
+ return mlx5_esw_sf_max_pf_functions(dev, MLX5_VPORT_HOST_PF, max_sfs,
+ sf_base_id);
+}
+
int mlx5_esw_vport_alloc(struct mlx5_eswitch *esw, int index, u16 vport_num)
{
struct mlx5_vport *vport;
--
2.44.0
next prev parent reply other threads:[~2026-05-21 11:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 11:08 [PATCH net-next 00/12] net/mlx5: Add satellite PF support Tariq Toukan
2026-05-21 11:08 ` [PATCH net-next 01/12] net/mlx5: Add satellite PF vport support Tariq Toukan
2026-05-21 11:08 ` Tariq Toukan [this message]
2026-05-21 11:08 ` [PATCH net-next 03/12] net/mlx5: Initialize host PF host number earlier Tariq Toukan
2026-05-21 11:08 ` [PATCH net-next 04/12] net/mlx5: Initialize satellite PF SF vports Tariq Toukan
2026-05-21 11:08 ` [PATCH net-next 05/12] net/mlx5: Support SPF SFs in SF hardware table Tariq Toukan
2026-05-21 11:08 ` [PATCH net-next 06/12] net/mlx5: Expose PF number from query_esw_functions Tariq Toukan
2026-05-21 11:08 ` [PATCH net-next 07/12] net/mlx5: Map SF controller to pfnum for satellite PFs Tariq Toukan
2026-05-21 11:08 ` [PATCH net-next 08/12] net/mlx5: Register devlink ports " Tariq Toukan
2026-05-21 11:08 ` [PATCH net-next 09/12] net/mlx5: Register SF resource on satellite PF ports Tariq Toukan
2026-05-21 11:08 ` [PATCH net-next 10/12] net/mlx5: Support state get/set for " Tariq Toukan
2026-05-21 11:08 ` [PATCH net-next 11/12] net/mlx5: Add FDB peer miss rules for satellite PFs Tariq Toukan
2026-05-21 11:08 ` [PATCH net-next 12/12] net/mlx5: Add SPF function type for page management Tariq Toukan
2026-05-25 21:10 ` [PATCH net-next 00/12] net/mlx5: Add satellite PF support patchwork-bot+netdevbpf
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=20260521110843.367329-3-tariqt@nvidia.com \
--to=tariqt@nvidia.com \
--cc=ajayachandra@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=cjubran@nvidia.com \
--cc=cratiu@nvidia.com \
--cc=danielj@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=moshe@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=ohartoov@nvidia.com \
--cc=pabeni@redhat.com \
--cc=parav@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=shayd@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