162306a36Sopenharmony_ci/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
262306a36Sopenharmony_ci/* Copyright (c) 2018 Mellanox Technologies. All rights reserved */
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci#ifndef _MLXSW_SPECTRUM_NVE_H
562306a36Sopenharmony_ci#define _MLXSW_SPECTRUM_NVE_H
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#include <linux/netlink.h>
862306a36Sopenharmony_ci#include <linux/rhashtable.h>
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#include "spectrum.h"
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_cistruct mlxsw_sp_nve_config {
1362306a36Sopenharmony_ci	enum mlxsw_sp_nve_type type;
1462306a36Sopenharmony_ci	u8 ttl;
1562306a36Sopenharmony_ci	u8 learning_en:1;
1662306a36Sopenharmony_ci	__be16 udp_dport;
1762306a36Sopenharmony_ci	__be32 flowlabel;
1862306a36Sopenharmony_ci	u32 ul_tb_id;
1962306a36Sopenharmony_ci	enum mlxsw_sp_l3proto ul_proto;
2062306a36Sopenharmony_ci	union mlxsw_sp_l3addr ul_sip;
2162306a36Sopenharmony_ci};
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_cistruct mlxsw_sp_nve {
2462306a36Sopenharmony_ci	struct mlxsw_sp_nve_config config;
2562306a36Sopenharmony_ci	struct rhashtable mc_list_ht;
2662306a36Sopenharmony_ci	struct rhashtable ipv6_ht;
2762306a36Sopenharmony_ci	struct list_head ipv6_addr_list; /* Saves hash table nodes. */
2862306a36Sopenharmony_ci	struct mlxsw_sp *mlxsw_sp;
2962306a36Sopenharmony_ci	const struct mlxsw_sp_nve_ops **nve_ops_arr;
3062306a36Sopenharmony_ci	unsigned int num_nve_tunnels;	/* Protected by RTNL */
3162306a36Sopenharmony_ci	unsigned int num_max_mc_entries[MLXSW_SP_L3_PROTO_MAX];
3262306a36Sopenharmony_ci	u32 tunnel_index;
3362306a36Sopenharmony_ci	u16 ul_rif_index;	/* Reserved for Spectrum */
3462306a36Sopenharmony_ci};
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_cistruct mlxsw_sp_nve_ops {
3762306a36Sopenharmony_ci	enum mlxsw_sp_nve_type type;
3862306a36Sopenharmony_ci	bool (*can_offload)(const struct mlxsw_sp_nve *nve,
3962306a36Sopenharmony_ci			    const struct mlxsw_sp_nve_params *params,
4062306a36Sopenharmony_ci			    struct netlink_ext_ack *extack);
4162306a36Sopenharmony_ci	void (*nve_config)(const struct mlxsw_sp_nve *nve,
4262306a36Sopenharmony_ci			   const struct mlxsw_sp_nve_params *params,
4362306a36Sopenharmony_ci			   struct mlxsw_sp_nve_config *config);
4462306a36Sopenharmony_ci	int (*init)(struct mlxsw_sp_nve *nve,
4562306a36Sopenharmony_ci		    const struct mlxsw_sp_nve_config *config);
4662306a36Sopenharmony_ci	void (*fini)(struct mlxsw_sp_nve *nve);
4762306a36Sopenharmony_ci	int (*fdb_replay)(const struct net_device *nve_dev, __be32 vni,
4862306a36Sopenharmony_ci			  struct netlink_ext_ack *extack);
4962306a36Sopenharmony_ci	void (*fdb_clear_offload)(const struct net_device *nve_dev, __be32 vni);
5062306a36Sopenharmony_ci};
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ciextern const struct mlxsw_sp_nve_ops mlxsw_sp1_nve_vxlan_ops;
5362306a36Sopenharmony_ciextern const struct mlxsw_sp_nve_ops mlxsw_sp2_nve_vxlan_ops;
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci#endif
56