1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2021 Mellanox Technologies Ltd */
4 #ifndef __LIB_MLX5_SF_H__
5 #define __LIB_MLX5_SF_H__
7 #include <linux/mlx5/driver.h>
9 static inline u16 mlx5_sf_start_function_id(const struct mlx5_core_dev *dev)
11 return MLX5_CAP_GEN(dev, sf_base_id);
16 static inline bool mlx5_sf_supported(const struct mlx5_core_dev *dev)
18 return MLX5_CAP_GEN(dev, sf);
21 static inline u16 mlx5_sf_max_functions(const struct mlx5_core_dev *dev)
23 if (!mlx5_sf_supported(dev))
25 if (MLX5_CAP_GEN(dev, max_num_sf))
26 return MLX5_CAP_GEN(dev, max_num_sf);
28 return 1 << MLX5_CAP_GEN(dev, log_max_sf);
33 static inline bool mlx5_sf_supported(const struct mlx5_core_dev *dev)
38 static inline u16 mlx5_sf_max_functions(const struct mlx5_core_dev *dev)