1 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ 2 /* 3 * Copyright (c) 2018 Mellanox Technologies. All rights reserved. 4 */ 5 6 #ifndef __MLX5_IB_REP_H__ 7 #define __MLX5_IB_REP_H__ 8 9 #include <linux/mlx5/eswitch.h> 10 #include "mlx5_ib.h" 11 12 #ifdef CONFIG_MLX5_ESWITCH 13 u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw); 14 struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw, 15 int vport_index); 16 struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, 17 int vport_index); 18 void mlx5_ib_register_vport_reps(struct mlx5_ib_dev *dev); 19 void mlx5_ib_unregister_vport_reps(struct mlx5_ib_dev *dev); 20 struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw, 21 int vport_index); 22 #else /* CONFIG_MLX5_ESWITCH */ 23 static inline u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw) 24 { 25 return SRIOV_NONE; 26 } 27 28 static inline 29 struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw, 30 int vport_index) 31 { 32 return NULL; 33 } 34 35 static inline 36 struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, 37 int vport_index) 38 { 39 return NULL; 40 } 41 42 static inline void mlx5_ib_register_vport_reps(struct mlx5_ib_dev *dev) {} 43 static inline void mlx5_ib_unregister_vport_reps(struct mlx5_ib_dev *dev) {} 44 static inline 45 struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw, 46 int vport_index) 47 { 48 return NULL; 49 } 50 #endif 51 52 static inline 53 struct mlx5_ib_dev *mlx5_ib_rep_to_dev(struct mlx5_eswitch_rep *rep) 54 { 55 return (struct mlx5_ib_dev *)rep->rep_if[REP_IB].priv; 56 } 57 #endif /* __MLX5_IB_REP_H__ */ 58