1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 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 extern const struct mlx5_ib_profile uplink_rep_profile; 14 15 u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw); 16 struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw, 17 int vport_index); 18 struct mlx5_ib_dev *mlx5_ib_get_uplink_ibdev(struct mlx5_eswitch *esw); 19 struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, 20 int vport_index); 21 void mlx5_ib_register_vport_reps(struct mlx5_core_dev *mdev); 22 void mlx5_ib_unregister_vport_reps(struct mlx5_core_dev *mdev); 23 int create_flow_rule_vport_sq(struct mlx5_ib_dev *dev, 24 struct mlx5_ib_sq *sq); 25 struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw, 26 int vport_index); 27 #else /* CONFIG_MLX5_ESWITCH */ 28 static inline u8 mlx5_ib_eswitch_mode(struct mlx5_eswitch *esw) 29 { 30 return SRIOV_NONE; 31 } 32 33 static inline 34 struct mlx5_ib_dev *mlx5_ib_get_rep_ibdev(struct mlx5_eswitch *esw, 35 int vport_index) 36 { 37 return NULL; 38 } 39 40 static inline 41 struct mlx5_ib_dev *mlx5_ib_get_uplink_ibdev(struct mlx5_eswitch *esw) 42 { 43 return NULL; 44 } 45 46 static inline 47 struct mlx5_eswitch_rep *mlx5_ib_vport_rep(struct mlx5_eswitch *esw, 48 int vport_index) 49 { 50 return NULL; 51 } 52 53 static inline void mlx5_ib_register_vport_reps(struct mlx5_core_dev *mdev) {} 54 static inline void mlx5_ib_unregister_vport_reps(struct mlx5_core_dev *mdev) {} 55 static inline int create_flow_rule_vport_sq(struct mlx5_ib_dev *dev, 56 struct mlx5_ib_sq *sq) 57 { 58 return 0; 59 } 60 61 static inline 62 struct net_device *mlx5_ib_get_rep_netdev(struct mlx5_eswitch *esw, 63 int vport_index) 64 { 65 return NULL; 66 } 67 #endif 68 69 static inline 70 struct mlx5_ib_dev *mlx5_ib_rep_to_dev(struct mlx5_eswitch_rep *rep) 71 { 72 return (struct mlx5_ib_dev *)rep->rep_if[REP_IB].priv; 73 } 74 #endif /* __MLX5_IB_REP_H__ */ 75