spectrum_ipip.h (2444B)
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#include <net/ip6_tunnel.h> 11 12struct ip_tunnel_parm 13mlxsw_sp_ipip_netdev_parms4(const struct net_device *ol_dev); 14struct __ip6_tnl_parm 15mlxsw_sp_ipip_netdev_parms6(const struct net_device *ol_dev); 16 17union mlxsw_sp_l3addr 18mlxsw_sp_ipip_netdev_saddr(enum mlxsw_sp_l3proto proto, 19 const struct net_device *ol_dev); 20 21bool mlxsw_sp_l3addr_is_zero(union mlxsw_sp_l3addr addr); 22 23enum mlxsw_sp_ipip_type { 24 MLXSW_SP_IPIP_TYPE_GRE4, 25 MLXSW_SP_IPIP_TYPE_GRE6, 26 MLXSW_SP_IPIP_TYPE_MAX, 27}; 28 29struct mlxsw_sp_ipip_parms { 30 enum mlxsw_sp_l3proto proto; 31 union mlxsw_sp_l3addr saddr; 32 union mlxsw_sp_l3addr daddr; 33 int link; 34 u32 ikey; 35 u32 okey; 36}; 37 38struct mlxsw_sp_ipip_entry { 39 enum mlxsw_sp_ipip_type ipipt; 40 struct net_device *ol_dev; /* Overlay. */ 41 struct mlxsw_sp_rif_ipip_lb *ol_lb; 42 struct mlxsw_sp_fib_entry *decap_fib_entry; 43 struct list_head ipip_list_node; 44 struct mlxsw_sp_ipip_parms parms; 45 u32 dip_kvdl_index; 46}; 47 48struct mlxsw_sp_ipip_ops { 49 int dev_type; 50 enum mlxsw_sp_l3proto ul_proto; /* Underlay. */ 51 bool inc_parsing_depth; 52 53 struct mlxsw_sp_ipip_parms 54 (*parms_init)(const struct net_device *ol_dev); 55 56 int (*nexthop_update)(struct mlxsw_sp *mlxsw_sp, u32 adj_index, 57 struct mlxsw_sp_ipip_entry *ipip_entry, 58 bool force, char *ratr_pl); 59 60 bool (*can_offload)(const struct mlxsw_sp *mlxsw_sp, 61 const struct net_device *ol_dev); 62 63 /* Return a configuration for creating an overlay loopback RIF. */ 64 struct mlxsw_sp_rif_ipip_lb_config 65 (*ol_loopback_config)(struct mlxsw_sp *mlxsw_sp, 66 const struct net_device *ol_dev); 67 68 int (*decap_config)(struct mlxsw_sp *mlxsw_sp, 69 struct mlxsw_sp_ipip_entry *ipip_entry, 70 u32 tunnel_index); 71 72 int (*ol_netdev_change)(struct mlxsw_sp *mlxsw_sp, 73 struct mlxsw_sp_ipip_entry *ipip_entry, 74 struct netlink_ext_ack *extack); 75 int (*rem_ip_addr_set)(struct mlxsw_sp *mlxsw_sp, 76 struct mlxsw_sp_ipip_entry *ipip_entry); 77 void (*rem_ip_addr_unset)(struct mlxsw_sp *mlxsw_sp, 78 const struct mlxsw_sp_ipip_entry *ipip_entry); 79}; 80 81extern const struct mlxsw_sp_ipip_ops *mlxsw_sp1_ipip_ops_arr[]; 82extern const struct mlxsw_sp_ipip_ops *mlxsw_sp2_ipip_ops_arr[]; 83 84#endif /* _MLXSW_IPIP_H_*/