86 lines · c
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_kern13mlxsw_sp_ipip_netdev_parms4(const struct net_device *ol_dev);14struct __ip6_tnl_parm15mlxsw_sp_ipip_netdev_parms6(const struct net_device *ol_dev);16 17union mlxsw_sp_l3addr18mlxsw_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 bool double_rif_entry;53 54 struct mlxsw_sp_ipip_parms55 (*parms_init)(const struct net_device *ol_dev);56 57 int (*nexthop_update)(struct mlxsw_sp *mlxsw_sp, u32 adj_index,58 struct mlxsw_sp_ipip_entry *ipip_entry,59 bool force, char *ratr_pl);60 61 bool (*can_offload)(const struct mlxsw_sp *mlxsw_sp,62 const struct net_device *ol_dev);63 64 /* Return a configuration for creating an overlay loopback RIF. */65 struct mlxsw_sp_rif_ipip_lb_config66 (*ol_loopback_config)(struct mlxsw_sp *mlxsw_sp,67 const struct net_device *ol_dev);68 69 int (*decap_config)(struct mlxsw_sp *mlxsw_sp,70 struct mlxsw_sp_ipip_entry *ipip_entry,71 u32 tunnel_index);72 73 int (*ol_netdev_change)(struct mlxsw_sp *mlxsw_sp,74 struct mlxsw_sp_ipip_entry *ipip_entry,75 struct netlink_ext_ack *extack);76 int (*rem_ip_addr_set)(struct mlxsw_sp *mlxsw_sp,77 struct mlxsw_sp_ipip_entry *ipip_entry);78 void (*rem_ip_addr_unset)(struct mlxsw_sp *mlxsw_sp,79 const struct mlxsw_sp_ipip_entry *ipip_entry);80};81 82extern const struct mlxsw_sp_ipip_ops *mlxsw_sp1_ipip_ops_arr[];83extern const struct mlxsw_sp_ipip_ops *mlxsw_sp2_ipip_ops_arr[];84 85#endif /* _MLXSW_IPIP_H_*/86