18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* Copyright (c) 2018 Mellanox Technologies. All rights reserved */ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#ifndef _MLXSW_SPECTRUM_NVE_H 58c2ecf20Sopenharmony_ci#define _MLXSW_SPECTRUM_NVE_H 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include <linux/netlink.h> 88c2ecf20Sopenharmony_ci#include <linux/rhashtable.h> 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include "spectrum.h" 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_cistruct mlxsw_sp_nve_config { 138c2ecf20Sopenharmony_ci enum mlxsw_sp_nve_type type; 148c2ecf20Sopenharmony_ci u8 ttl; 158c2ecf20Sopenharmony_ci u8 learning_en:1; 168c2ecf20Sopenharmony_ci __be16 udp_dport; 178c2ecf20Sopenharmony_ci __be32 flowlabel; 188c2ecf20Sopenharmony_ci u32 ul_tb_id; 198c2ecf20Sopenharmony_ci enum mlxsw_sp_l3proto ul_proto; 208c2ecf20Sopenharmony_ci union mlxsw_sp_l3addr ul_sip; 218c2ecf20Sopenharmony_ci}; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_cistruct mlxsw_sp_nve { 248c2ecf20Sopenharmony_ci struct mlxsw_sp_nve_config config; 258c2ecf20Sopenharmony_ci struct rhashtable mc_list_ht; 268c2ecf20Sopenharmony_ci struct mlxsw_sp *mlxsw_sp; 278c2ecf20Sopenharmony_ci const struct mlxsw_sp_nve_ops **nve_ops_arr; 288c2ecf20Sopenharmony_ci unsigned int num_nve_tunnels; /* Protected by RTNL */ 298c2ecf20Sopenharmony_ci unsigned int num_max_mc_entries[MLXSW_SP_L3_PROTO_MAX]; 308c2ecf20Sopenharmony_ci u32 tunnel_index; 318c2ecf20Sopenharmony_ci u16 ul_rif_index; /* Reserved for Spectrum */ 328c2ecf20Sopenharmony_ci unsigned int inc_parsing_depth_refs; 338c2ecf20Sopenharmony_ci}; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistruct mlxsw_sp_nve_ops { 368c2ecf20Sopenharmony_ci enum mlxsw_sp_nve_type type; 378c2ecf20Sopenharmony_ci bool (*can_offload)(const struct mlxsw_sp_nve *nve, 388c2ecf20Sopenharmony_ci const struct net_device *dev, 398c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 408c2ecf20Sopenharmony_ci void (*nve_config)(const struct mlxsw_sp_nve *nve, 418c2ecf20Sopenharmony_ci const struct net_device *dev, 428c2ecf20Sopenharmony_ci struct mlxsw_sp_nve_config *config); 438c2ecf20Sopenharmony_ci int (*init)(struct mlxsw_sp_nve *nve, 448c2ecf20Sopenharmony_ci const struct mlxsw_sp_nve_config *config); 458c2ecf20Sopenharmony_ci void (*fini)(struct mlxsw_sp_nve *nve); 468c2ecf20Sopenharmony_ci int (*fdb_replay)(const struct net_device *nve_dev, __be32 vni, 478c2ecf20Sopenharmony_ci struct netlink_ext_ack *extack); 488c2ecf20Sopenharmony_ci void (*fdb_clear_offload)(const struct net_device *nve_dev, __be32 vni); 498c2ecf20Sopenharmony_ci}; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_nve_ops mlxsw_sp1_nve_vxlan_ops; 528c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_nve_ops mlxsw_sp2_nve_vxlan_ops; 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#endif 55