From: Moshe Shemesh Date: Thu, 21 May 2026 11:08:43 +0000 (+0300) Subject: net/mlx5: Add SPF function type for page management X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=ea0dada7194e02ff9d2c785cc83949bd51496bf3;p=thirdparty%2Flinux.git net/mlx5: Add SPF function type for page management Add MLX5_SPF to enum mlx5_func_type so SPFs get their own page counter, and add the corresponding WARN check at page cleanup. Wait for SPF pages to be reclaimed during ECPF teardown, alongside the existing host PF and VF page waits. SPF page requests are always identified by vhca_id, so the legacy func_id_to_type() path is not reached for satellite PFs. Signed-off-by: Moshe Shemesh Signed-off-by: Tariq Toukan Link: https://patch.msgid.link/20260521110843.367329-13-tariqt@nvidia.com Signed-off-by: Jakub Kicinski --- diff --git a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c index 6347957fefcb..30be2b631e7c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c @@ -316,6 +316,8 @@ void mlx5_pages_by_func_type_debugfs_init(struct mlx5_core_dev *dev) &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_spfs", 0400, pages, + &dev->priv.page_counters[MLX5_SPF]); } void mlx5_pages_by_func_type_debugfs_cleanup(struct mlx5_core_dev *dev) @@ -329,6 +331,7 @@ void mlx5_pages_by_func_type_debugfs_cleanup(struct mlx5_core_dev *dev) 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); + debugfs_lookup_and_remove("fw_pages_spfs", pages); } static u64 qp_read_field(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ecpf.c b/drivers/net/ethernet/mellanox/mlx5/core/ecpf.c index 350c47d3643b..9839f1a58640 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/ecpf.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/ecpf.c @@ -102,6 +102,11 @@ void mlx5_ec_cleanup(struct mlx5_core_dev *dev) if (err) mlx5_core_warn(dev, "Timeout reclaiming external host PF pages err(%d)\n", err); + err = mlx5_wait_for_pages(dev, &dev->priv.page_counters[MLX5_SPF]); + if (err) + mlx5_core_warn(dev, "Timeout reclaiming SPF pages err(%d)\n", + err); + err = mlx5_wait_for_pages(dev, &dev->priv.page_counters[MLX5_VF]); if (err) mlx5_core_warn(dev, "Timeout reclaiming external host VFs pages err(%d)\n", err); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c index bc3c116f5327..f8cfbf76dd6a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c @@ -863,6 +863,8 @@ esw_vport_to_func_type(struct mlx5_eswitch *esw, struct mlx5_vport *vport) return MLX5_SF; if (xa_get_mark(&esw->vports, vport_num, MLX5_ESW_VPT_VF)) return MLX5_VF; + if (mlx5_esw_is_spf_vport(esw, vport_num)) + return MLX5_SPF; return MLX5_EC_VF; } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c index ce2f7fa9bd48..7fef3a7fee6e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c @@ -885,6 +885,9 @@ int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev) WARN(dev->priv.page_counters[MLX5_HOST_PF], "External host PF FW pages counter is %d after reclaiming all pages\n", dev->priv.page_counters[MLX5_HOST_PF]); + WARN(dev->priv.page_counters[MLX5_SPF], + "SPFs FW pages counter is %d after reclaiming all pages\n", + dev->priv.page_counters[MLX5_SPF]); WARN(dev->priv.page_counters[MLX5_EC_VF], "EC VFs FW pages counter is %d after reclaiming all pages\n", dev->priv.page_counters[MLX5_EC_VF]); diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h index 9a4bb25d8e0a..b1871c0821d0 100644 --- a/include/linux/mlx5/driver.h +++ b/include/linux/mlx5/driver.h @@ -557,6 +557,7 @@ enum mlx5_func_type { MLX5_VF, MLX5_SF, MLX5_HOST_PF, + MLX5_SPF, MLX5_EC_VF, MLX5_FUNC_TYPE_NUM, MLX5_FUNC_TYPE_NONE = MLX5_FUNC_TYPE_NUM,