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