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