0001
0002
0003
0004 #ifndef __LIB_MLX5_SF_H__
0005 #define __LIB_MLX5_SF_H__
0006
0007 #include <linux/mlx5/driver.h>
0008
0009 static inline u16 mlx5_sf_start_function_id(const struct mlx5_core_dev *dev)
0010 {
0011 return MLX5_CAP_GEN(dev, sf_base_id);
0012 }
0013
0014 #ifdef CONFIG_MLX5_SF
0015
0016 static inline bool mlx5_sf_supported(const struct mlx5_core_dev *dev)
0017 {
0018 return MLX5_CAP_GEN(dev, sf);
0019 }
0020
0021 static inline u16 mlx5_sf_max_functions(const struct mlx5_core_dev *dev)
0022 {
0023 if (!mlx5_sf_supported(dev))
0024 return 0;
0025 if (MLX5_CAP_GEN(dev, max_num_sf))
0026 return MLX5_CAP_GEN(dev, max_num_sf);
0027 else
0028 return 1 << MLX5_CAP_GEN(dev, log_max_sf);
0029 }
0030
0031 #else
0032
0033 static inline bool mlx5_sf_supported(const struct mlx5_core_dev *dev)
0034 {
0035 return false;
0036 }
0037
0038 static inline u16 mlx5_sf_max_functions(const struct mlx5_core_dev *dev)
0039 {
0040 return 0;
0041 }
0042
0043 #endif
0044
0045 #endif