1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
2 /* Copyright (c) 2017-2018 Mellanox Technologies. All rights reserved */
7 #include "spectrum_router.h"
8 #include <net/ip_fib.h>
9 #include <linux/if_tunnel.h>
12 mlxsw_sp_ipip_netdev_parms4(const struct net_device *ol_dev);
14 mlxsw_sp_ipip_netdev_parms6(const struct net_device *ol_dev);
17 mlxsw_sp_ipip_netdev_saddr(enum mlxsw_sp_l3proto proto,
18 const struct net_device *ol_dev);
20 bool mlxsw_sp_l3addr_is_zero(union mlxsw_sp_l3addr addr);
22 enum mlxsw_sp_ipip_type {
23 MLXSW_SP_IPIP_TYPE_GRE4,
24 MLXSW_SP_IPIP_TYPE_MAX,
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;
34 struct ip_tunnel_parm parms4;
38 struct mlxsw_sp_ipip_ops {
40 enum mlxsw_sp_l3proto ul_proto; /* Underlay. */
42 int (*nexthop_update)(struct mlxsw_sp *mlxsw_sp, u32 adj_index,
43 struct mlxsw_sp_ipip_entry *ipip_entry);
45 bool (*can_offload)(const struct mlxsw_sp *mlxsw_sp,
46 const struct net_device *ol_dev,
47 enum mlxsw_sp_l3proto ol_proto);
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);
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,
59 int (*ol_netdev_change)(struct mlxsw_sp *mlxsw_sp,
60 struct mlxsw_sp_ipip_entry *ipip_entry,
61 struct netlink_ext_ack *extack);
64 extern const struct mlxsw_sp_ipip_ops *mlxsw_sp_ipip_ops_arr[];
66 #endif /* _MLXSW_IPIP_H_*/