spectrum_ipip.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
  2. /* Copyright (c) 2017-2018 Mellanox Technologies. All rights reserved */
  3. #ifndef _MLXSW_IPIP_H_
  4. #define _MLXSW_IPIP_H_
  5. #include "spectrum_router.h"
  6. #include <net/ip_fib.h>
  7. #include <linux/if_tunnel.h>
  8. struct ip_tunnel_parm
  9. mlxsw_sp_ipip_netdev_parms4(const struct net_device *ol_dev);
  10. struct __ip6_tnl_parm
  11. mlxsw_sp_ipip_netdev_parms6(const struct net_device *ol_dev);
  12. union mlxsw_sp_l3addr
  13. mlxsw_sp_ipip_netdev_saddr(enum mlxsw_sp_l3proto proto,
  14. const struct net_device *ol_dev);
  15. bool mlxsw_sp_l3addr_is_zero(union mlxsw_sp_l3addr addr);
  16. enum mlxsw_sp_ipip_type {
  17. MLXSW_SP_IPIP_TYPE_GRE4,
  18. MLXSW_SP_IPIP_TYPE_MAX,
  19. };
  20. struct mlxsw_sp_ipip_entry {
  21. enum mlxsw_sp_ipip_type ipipt;
  22. struct net_device *ol_dev; /* Overlay. */
  23. struct mlxsw_sp_rif_ipip_lb *ol_lb;
  24. struct mlxsw_sp_fib_entry *decap_fib_entry;
  25. struct list_head ipip_list_node;
  26. union {
  27. struct ip_tunnel_parm parms4;
  28. };
  29. };
  30. struct mlxsw_sp_ipip_ops {
  31. int dev_type;
  32. enum mlxsw_sp_l3proto ul_proto; /* Underlay. */
  33. int (*nexthop_update)(struct mlxsw_sp *mlxsw_sp, u32 adj_index,
  34. struct mlxsw_sp_ipip_entry *ipip_entry);
  35. bool (*can_offload)(const struct mlxsw_sp *mlxsw_sp,
  36. const struct net_device *ol_dev,
  37. enum mlxsw_sp_l3proto ol_proto);
  38. /* Return a configuration for creating an overlay loopback RIF. */
  39. struct mlxsw_sp_rif_ipip_lb_config
  40. (*ol_loopback_config)(struct mlxsw_sp *mlxsw_sp,
  41. const struct net_device *ol_dev);
  42. int (*fib_entry_op)(struct mlxsw_sp *mlxsw_sp,
  43. struct mlxsw_sp_ipip_entry *ipip_entry,
  44. enum mlxsw_reg_ralue_op op,
  45. u32 tunnel_index);
  46. int (*ol_netdev_change)(struct mlxsw_sp *mlxsw_sp,
  47. struct mlxsw_sp_ipip_entry *ipip_entry,
  48. struct netlink_ext_ack *extack);
  49. };
  50. extern const struct mlxsw_sp_ipip_ops *mlxsw_sp_ipip_ops_arr[];
  51. #endif /* _MLXSW_IPIP_H_*/