]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net/mlx5: Make debugfs page counters by function type dynamic
authorMoshe Shemesh <moshe@nvidia.com>
Wed, 6 May 2026 13:32:38 +0000 (16:32 +0300)
committerJakub Kicinski <kuba@kernel.org>
Sat, 9 May 2026 01:50:34 +0000 (18:50 -0700)
Make the per function type debugfs page counters dynamically added after
mlx5_eswitch_init(). When page management operates in vhca_id mode, only
the function acting as either eSwitch or vport manager can initialize
the eSwitch structure and translate the vhca_id to function type for the
functions to which it supplies pages. The next patch will add support
for page management in vhca_id mode.

Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Akiva Goldberger <agoldberger@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20260506133239.276237-3-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/debugfs.c
drivers/net/ethernet/mellanox/mlx5/core/main.c
include/linux/mlx5/driver.h

index 8fe263190d38ac2e78dea0c04a8adf89a2ce758e..6347957fefcbe42c7fc36065ff5cfcd838f1d4fe 100644 (file)
@@ -285,10 +285,6 @@ void mlx5_pages_debugfs_init(struct mlx5_core_dev *dev)
        pages = dev->priv.dbg.pages_debugfs;
 
        debugfs_create_u32("fw_pages_total", 0400, pages, &dev->priv.fw_pages);
-       debugfs_create_u32("fw_pages_vfs", 0400, pages, &dev->priv.page_counters[MLX5_VF]);
-       debugfs_create_u32("fw_pages_ec_vfs", 0400, pages, &dev->priv.page_counters[MLX5_EC_VF]);
-       debugfs_create_u32("fw_pages_sfs", 0400, pages, &dev->priv.page_counters[MLX5_SF]);
-       debugfs_create_u32("fw_pages_host_pf", 0400, pages, &dev->priv.page_counters[MLX5_HOST_PF]);
        debugfs_create_u32("fw_pages_alloc_failed", 0400, pages, &dev->priv.fw_pages_alloc_failed);
        debugfs_create_u32("fw_pages_give_dropped", 0400, pages, &dev->priv.give_pages_dropped);
        debugfs_create_u32("fw_pages_reclaim_discard", 0400, pages,
@@ -300,6 +296,41 @@ void mlx5_pages_debugfs_cleanup(struct mlx5_core_dev *dev)
        debugfs_remove_recursive(dev->priv.dbg.pages_debugfs);
 }
 
+void mlx5_pages_by_func_type_debugfs_init(struct mlx5_core_dev *dev)
+{
+       struct dentry *pages = dev->priv.dbg.pages_debugfs;
+
+       if (!pages)
+               return;
+
+       if (!dev->priv.eswitch &&
+           MLX5_CAP_GEN(dev, icm_mng_function_id_mode) ==
+           MLX5_ID_MODE_FUNCTION_VHCA_ID)
+               return;
+
+       debugfs_create_u32("fw_pages_vfs", 0400, pages,
+                          &dev->priv.page_counters[MLX5_VF]);
+       debugfs_create_u32("fw_pages_ec_vfs", 0400, pages,
+                          &dev->priv.page_counters[MLX5_EC_VF]);
+       debugfs_create_u32("fw_pages_sfs", 0400, pages,
+                          &dev->priv.page_counters[MLX5_SF]);
+       debugfs_create_u32("fw_pages_host_pf", 0400, pages,
+                          &dev->priv.page_counters[MLX5_HOST_PF]);
+}
+
+void mlx5_pages_by_func_type_debugfs_cleanup(struct mlx5_core_dev *dev)
+{
+       struct dentry *pages = dev->priv.dbg.pages_debugfs;
+
+       if (!pages)
+               return;
+
+       debugfs_lookup_and_remove("fw_pages_vfs", pages);
+       debugfs_lookup_and_remove("fw_pages_ec_vfs", pages);
+       debugfs_lookup_and_remove("fw_pages_sfs", pages);
+       debugfs_lookup_and_remove("fw_pages_host_pf", pages);
+}
+
 static u64 qp_read_field(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp,
                         int index, int *is_str)
 {
index b1b9ebfd38660e48f0eb0121d301ad20a65b5e05..0c1c906b60fa18959a43b90387afcf12276fde25 100644 (file)
@@ -987,11 +987,12 @@ static int mlx5_init_once(struct mlx5_core_dev *dev)
                mlx5_core_err(dev, "Failed to init eswitch %d\n", err);
                goto err_sriov_cleanup;
        }
+       mlx5_pages_by_func_type_debugfs_init(dev);
 
        err = mlx5_fpga_init(dev);
        if (err) {
                mlx5_core_err(dev, "Failed to init fpga device %d\n", err);
-               goto err_eswitch_cleanup;
+               goto err_page_debugfs_cleanup;
        }
 
        err = mlx5_vhca_event_init(dev);
@@ -1034,7 +1035,8 @@ err_sf_hw_table_cleanup:
        mlx5_vhca_event_cleanup(dev);
 err_fpga_cleanup:
        mlx5_fpga_cleanup(dev);
-err_eswitch_cleanup:
+err_page_debugfs_cleanup:
+       mlx5_pages_by_func_type_debugfs_cleanup(dev);
        mlx5_eswitch_cleanup(dev->priv.eswitch);
 err_sriov_cleanup:
        mlx5_sriov_cleanup(dev);
@@ -1072,6 +1074,7 @@ static void mlx5_cleanup_once(struct mlx5_core_dev *dev)
        mlx5_sf_hw_table_cleanup(dev);
        mlx5_vhca_event_cleanup(dev);
        mlx5_fpga_cleanup(dev);
+       mlx5_pages_by_func_type_debugfs_cleanup(dev);
        mlx5_eswitch_cleanup(dev->priv.eswitch);
        mlx5_sriov_cleanup(dev);
        mlx5_mpfs_cleanup(dev);
index 531ce66fc8ef4ca079d8cc48d35771fc123ab508..d1751c5d01c70c5905522df80d9245b900f9af09 100644 (file)
@@ -1039,6 +1039,8 @@ void mlx5_pagealloc_start(struct mlx5_core_dev *dev);
 void mlx5_pagealloc_stop(struct mlx5_core_dev *dev);
 void mlx5_pages_debugfs_init(struct mlx5_core_dev *dev);
 void mlx5_pages_debugfs_cleanup(struct mlx5_core_dev *dev);
+void mlx5_pages_by_func_type_debugfs_init(struct mlx5_core_dev *dev);
+void mlx5_pages_by_func_type_debugfs_cleanup(struct mlx5_core_dev *dev);
 int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev, int boot);
 int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev);
 void mlx5_register_debugfs(void);