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>,
Shay Drory <shayd@nvidia.com>, Moshe Shemesh <moshe@nvidia.com>
Subject: [net-next 12/15] net/mlx5: Split function_setup() to enable and open functions
Date: Fri, 9 Jun 2023 18:42:51 -0700 [thread overview]
Message-ID: <20230610014254.343576-13-saeed@kernel.org> (raw)
In-Reply-To: <20230610014254.343576-1-saeed@kernel.org>
From: Shay Drory <shayd@nvidia.com>
mlx5_cmd_init_hca() is taking ~0.2 seconds. In case of a user who
desire to disable some of the SF aux devices, and with large scale-1K
SFs for example, this user will waste more than 3 minutes on
mlx5_cmd_init_hca() which isn't needed at this stage.
Downstream patch will change SFs which are probe over the E-switch,
local SFs, to be probed without any aux dev. In order to support this,
split function_setup() to avoid executing mlx5_cmd_init_hca().
Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/main.c | 83 +++++++++++++------
1 file changed, 58 insertions(+), 25 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index fed8b48a5b20..0faae77d84e6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -1118,7 +1118,7 @@ static void mlx5_cleanup_once(struct mlx5_core_dev *dev)
mlx5_devcom_unregister_device(dev->priv.devcom);
}
-static int mlx5_function_setup(struct mlx5_core_dev *dev, bool boot, u64 timeout)
+static int mlx5_function_enable(struct mlx5_core_dev *dev, bool boot, u64 timeout)
{
int err;
@@ -1183,28 +1183,56 @@ static int mlx5_function_setup(struct mlx5_core_dev *dev, bool boot, u64 timeout
goto reclaim_boot_pages;
}
+ return 0;
+
+reclaim_boot_pages:
+ mlx5_reclaim_startup_pages(dev);
+err_disable_hca:
+ mlx5_core_disable_hca(dev, 0);
+stop_health_poll:
+ mlx5_stop_health_poll(dev, boot);
+err_cmd_cleanup:
+ mlx5_cmd_set_state(dev, MLX5_CMDIF_STATE_DOWN);
+ mlx5_cmd_cleanup(dev);
+
+ return err;
+}
+
+static void mlx5_function_disable(struct mlx5_core_dev *dev, bool boot)
+{
+ mlx5_reclaim_startup_pages(dev);
+ mlx5_core_disable_hca(dev, 0);
+ mlx5_stop_health_poll(dev, boot);
+ mlx5_cmd_set_state(dev, MLX5_CMDIF_STATE_DOWN);
+ mlx5_cmd_cleanup(dev);
+}
+
+static int mlx5_function_open(struct mlx5_core_dev *dev)
+{
+ int err;
+
err = set_hca_ctrl(dev);
if (err) {
mlx5_core_err(dev, "set_hca_ctrl failed\n");
- goto reclaim_boot_pages;
+ return err;
}
err = set_hca_cap(dev);
if (err) {
mlx5_core_err(dev, "set_hca_cap failed\n");
- goto reclaim_boot_pages;
+ return err;
}
err = mlx5_satisfy_startup_pages(dev, 0);
if (err) {
mlx5_core_err(dev, "failed to allocate init pages\n");
- goto reclaim_boot_pages;
+ return err;
}
err = mlx5_cmd_init_hca(dev, sw_owner_id);
if (err) {
mlx5_core_err(dev, "init hca failed\n");
- goto reclaim_boot_pages;
+ return err;
}
mlx5_set_driver_version(dev);
@@ -1212,26 +1240,13 @@ static int mlx5_function_setup(struct mlx5_core_dev *dev, bool boot, u64 timeout
err = mlx5_query_hca_caps(dev);
if (err) {
mlx5_core_err(dev, "query hca failed\n");
- goto reclaim_boot_pages;
+ return err;
}
mlx5_start_health_fw_log_up(dev);
-
return 0;
-
-reclaim_boot_pages:
- mlx5_reclaim_startup_pages(dev);
-err_disable_hca:
- mlx5_core_disable_hca(dev, 0);
-stop_health_poll:
- mlx5_stop_health_poll(dev, boot);
-err_cmd_cleanup:
- mlx5_cmd_set_state(dev, MLX5_CMDIF_STATE_DOWN);
- mlx5_cmd_cleanup(dev);
-
- return err;
}
-static int mlx5_function_teardown(struct mlx5_core_dev *dev, bool boot)
+static int mlx5_function_close(struct mlx5_core_dev *dev)
{
int err;
@@ -1240,15 +1255,33 @@ static int mlx5_function_teardown(struct mlx5_core_dev *dev, bool boot)
mlx5_core_err(dev, "tear_down_hca failed, skip cleanup\n");
return err;
}
- mlx5_reclaim_startup_pages(dev);
- mlx5_core_disable_hca(dev, 0);
- mlx5_stop_health_poll(dev, boot);
- mlx5_cmd_set_state(dev, MLX5_CMDIF_STATE_DOWN);
- mlx5_cmd_cleanup(dev);
return 0;
}
+static int mlx5_function_setup(struct mlx5_core_dev *dev, bool boot, u64 timeout)
+{
+ int err;
+
+ err = mlx5_function_enable(dev, boot, timeout);
+ if (err)
+ return err;
+
+ err = mlx5_function_open(dev);
+ if (err)
+ mlx5_function_disable(dev, boot);
+ return err;
+}
+
+static int mlx5_function_teardown(struct mlx5_core_dev *dev, bool boot)
+{
+ int err = mlx5_function_close(dev);
+
+ if (!err)
+ mlx5_function_disable(dev, boot);
+ return err;
+}
+
static int mlx5_load(struct mlx5_core_dev *dev)
{
int err;
--
2.40.1
next prev 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 ` [net-next 04/15] net/mlx5: Update vport caps query/set for EC VFs Saeed Mahameed
2023-06-10 1:42 ` [net-next 05/15] net/mlx5: Add management of EC VF vports 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 ` Saeed Mahameed [this message]
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-13-saeed@kernel.org \
--to=saeed@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=moshe@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--cc=shayd@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.