18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* Copyright (c) 2017-2018 Mellanox Technologies. All rights reserved */ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#ifndef _MLXSW_IPIP_H_ 58c2ecf20Sopenharmony_ci#define _MLXSW_IPIP_H_ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include "spectrum_router.h" 88c2ecf20Sopenharmony_ci#include <net/ip_fib.h> 98c2ecf20Sopenharmony_ci#include <linux/if_tunnel.h> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_cistruct ip_tunnel_parm 128c2ecf20Sopenharmony_cimlxsw_sp_ipip_netdev_parms4(const struct net_device *ol_dev); 138c2ecf20Sopenharmony_cistruct __ip6_tnl_parm 148c2ecf20Sopenharmony_cimlxsw_sp_ipip_netdev_parms6(const struct net_device *ol_dev); 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ciunion mlxsw_sp_l3addr 178c2ecf20Sopenharmony_cimlxsw_sp_ipip_netdev_saddr(enum mlxsw_sp_l3proto proto, 188c2ecf20Sopenharmony_ci const struct net_device *ol_dev); 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_cibool mlxsw_sp_l3addr_is_zero(union mlxsw_sp_l3addr addr); 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cienum mlxsw_sp_ipip_type { 238c2ecf20Sopenharmony_ci MLXSW_SP_IPIP_TYPE_GRE4, 248c2ecf20Sopenharmony_ci MLXSW_SP_IPIP_TYPE_MAX, 258c2ecf20Sopenharmony_ci}; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cistruct mlxsw_sp_ipip_entry { 288c2ecf20Sopenharmony_ci enum mlxsw_sp_ipip_type ipipt; 298c2ecf20Sopenharmony_ci struct net_device *ol_dev; /* Overlay. */ 308c2ecf20Sopenharmony_ci struct mlxsw_sp_rif_ipip_lb *ol_lb; 318c2ecf20Sopenharmony_ci struct mlxsw_sp_fib_entry *decap_fib_entry; 328c2ecf20Sopenharmony_ci struct list_head ipip_list_node; 338c2ecf20Sopenharmony_ci union { 348c2ecf20Sopenharmony_ci struct ip_tunnel_parm parms4; 358c2ecf20Sopenharmony_ci }; 368c2ecf20Sopenharmony_ci}; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_cistruct mlxsw_sp_ipip_ops { 398c2ecf20Sopenharmony_ci int dev_type; 408c2ecf20Sopenharmony_ci enum mlxsw_sp_l3proto ul_proto; /* Underlay. */ 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci int (*nexthop_update)(struct mlxsw_sp *mlxsw_sp, u32 adj_index, 438c2ecf20Sopenharmony_ci struct mlxsw_sp_ipip_entry *ipip_entry); 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci bool (*can_offload)(const struct mlxsw_sp *mlxsw_sp, 468c2ecf20Sopenharmony_ci const struct net_device *ol_dev, 478c2ecf20Sopenharmony_ci enum mlxsw_sp_l3proto ol_proto); 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci /* Return a configuration for creating an overlay loopback RIF. */ 508c2ecf20Sopenharmony_ci struct mlxsw_sp_rif_ipip_lb_config 518c2ecf20Sopenharmony_ci (*ol_loopback_config)(struct mlxsw_sp *mlxsw_sp, 528c2ecf20Sopenharmony_ci const struct net_device *ol_dev); 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci int (*fib_entry_op)(struct mlxsw_sp *mlxsw_sp, 558c2ecf20Sopenharmony_ci struct mlxsw_sp_ipip_entry *ipip_entry, 568c2ecf20Sopenharmony_ci enum mlxsw_reg_ralue_op op, 578c2ecf20Sopenharmony_ci u32 tunnel_index); 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci int (*ol_netdev_change)(struct mlxsw_sp *mlxsw_sp, 608c2ecf20Sopenharmony_ci struct mlxsw_sp_ipip_entry *ipip_entry, 618c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 628c2ecf20Sopenharmony_ci}; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_ipip_ops *mlxsw_sp_ipip_ops_arr[]; 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci#endif /* _MLXSW_IPIP_H_*/ 67