ib_rep.h 1.9 KB

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