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