Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
0002 /* Copyright (c) 2017-2018 Mellanox Technologies. All rights reserved */
0003 
0004 #ifndef _MLXSW_IPIP_H_
0005 #define _MLXSW_IPIP_H_
0006 
0007 #include "spectrum_router.h"
0008 #include <net/ip_fib.h>
0009 #include <linux/if_tunnel.h>
0010 #include <net/ip6_tunnel.h>
0011 
0012 struct ip_tunnel_parm
0013 mlxsw_sp_ipip_netdev_parms4(const struct net_device *ol_dev);
0014 struct __ip6_tnl_parm
0015 mlxsw_sp_ipip_netdev_parms6(const struct net_device *ol_dev);
0016 
0017 union mlxsw_sp_l3addr
0018 mlxsw_sp_ipip_netdev_saddr(enum mlxsw_sp_l3proto proto,
0019                const struct net_device *ol_dev);
0020 
0021 bool mlxsw_sp_l3addr_is_zero(union mlxsw_sp_l3addr addr);
0022 
0023 enum mlxsw_sp_ipip_type {
0024     MLXSW_SP_IPIP_TYPE_GRE4,
0025     MLXSW_SP_IPIP_TYPE_GRE6,
0026     MLXSW_SP_IPIP_TYPE_MAX,
0027 };
0028 
0029 struct mlxsw_sp_ipip_parms {
0030     enum mlxsw_sp_l3proto proto;
0031     union mlxsw_sp_l3addr saddr;
0032     union mlxsw_sp_l3addr daddr;
0033     int link;
0034     u32 ikey;
0035     u32 okey;
0036 };
0037 
0038 struct mlxsw_sp_ipip_entry {
0039     enum mlxsw_sp_ipip_type ipipt;
0040     struct net_device *ol_dev; /* Overlay. */
0041     struct mlxsw_sp_rif_ipip_lb *ol_lb;
0042     struct mlxsw_sp_fib_entry *decap_fib_entry;
0043     struct list_head ipip_list_node;
0044     struct mlxsw_sp_ipip_parms parms;
0045     u32 dip_kvdl_index;
0046 };
0047 
0048 struct mlxsw_sp_ipip_ops {
0049     int dev_type;
0050     enum mlxsw_sp_l3proto ul_proto; /* Underlay. */
0051     bool inc_parsing_depth;
0052 
0053     struct mlxsw_sp_ipip_parms
0054     (*parms_init)(const struct net_device *ol_dev);
0055 
0056     int (*nexthop_update)(struct mlxsw_sp *mlxsw_sp, u32 adj_index,
0057                   struct mlxsw_sp_ipip_entry *ipip_entry,
0058                   bool force, char *ratr_pl);
0059 
0060     bool (*can_offload)(const struct mlxsw_sp *mlxsw_sp,
0061                 const struct net_device *ol_dev);
0062 
0063     /* Return a configuration for creating an overlay loopback RIF. */
0064     struct mlxsw_sp_rif_ipip_lb_config
0065     (*ol_loopback_config)(struct mlxsw_sp *mlxsw_sp,
0066                   const struct net_device *ol_dev);
0067 
0068     int (*decap_config)(struct mlxsw_sp *mlxsw_sp,
0069                 struct mlxsw_sp_ipip_entry *ipip_entry,
0070                 u32 tunnel_index);
0071 
0072     int (*ol_netdev_change)(struct mlxsw_sp *mlxsw_sp,
0073                 struct mlxsw_sp_ipip_entry *ipip_entry,
0074                 struct netlink_ext_ack *extack);
0075     int (*rem_ip_addr_set)(struct mlxsw_sp *mlxsw_sp,
0076                    struct mlxsw_sp_ipip_entry *ipip_entry);
0077     void (*rem_ip_addr_unset)(struct mlxsw_sp *mlxsw_sp,
0078                   const struct mlxsw_sp_ipip_entry *ipip_entry);
0079 };
0080 
0081 extern const struct mlxsw_sp_ipip_ops *mlxsw_sp1_ipip_ops_arr[];
0082 extern const struct mlxsw_sp_ipip_ops *mlxsw_sp2_ipip_ops_arr[];
0083 
0084 #endif /* _MLXSW_IPIP_H_*/