1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 2 /* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ 3 4 #ifndef __MLX5_LIB_SD_H__ 5 #define __MLX5_LIB_SD_H__ 6 7 #define MLX5_SD_MAX_GROUP_SZ 2 8 9 struct mlx5_sd; 10 11 struct mlx5_core_dev *mlx5_sd_primary_get_peer(struct mlx5_core_dev *primary, int idx); 12 int mlx5_sd_ch_ix_get_dev_ix(struct mlx5_core_dev *dev, int ch_ix); 13 int mlx5_sd_ch_ix_get_vec_ix(struct mlx5_core_dev *dev, int ch_ix); 14 struct mlx5_core_dev *mlx5_sd_ch_ix_get_dev(struct mlx5_core_dev *primary, int ch_ix); 15 struct auxiliary_device *mlx5_sd_get_adev(struct mlx5_core_dev *dev, 16 struct auxiliary_device *adev, 17 int idx); 18 19 int mlx5_sd_init(struct mlx5_core_dev *dev); 20 void mlx5_sd_cleanup(struct mlx5_core_dev *dev); 21 22 #define mlx5_sd_for_each_dev_from_to(i, primary, ix_from, to, pos) \ 23 for (i = ix_from; \ 24 (pos = mlx5_sd_primary_get_peer(primary, i)) && pos != (to); i++) 25 26 #define mlx5_sd_for_each_dev(i, primary, pos) \ 27 mlx5_sd_for_each_dev_from_to(i, primary, 0, NULL, pos) 28 29 #define mlx5_sd_for_each_dev_to(i, primary, to, pos) \ 30 mlx5_sd_for_each_dev_from_to(i, primary, 0, to, pos) 31 32 #define mlx5_sd_for_each_secondary(i, primary, pos) \ 33 mlx5_sd_for_each_dev_from_to(i, primary, 1, NULL, pos) 34 35 #define mlx5_sd_for_each_secondary_to(i, primary, to, pos) \ 36 mlx5_sd_for_each_dev_from_to(i, primary, 1, to, pos) 37 38 #endif /* __MLX5_LIB_SD_H__ */ 39