// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
/* Copyright (c) 2017-2018 Mellanox Technologies. All rights reserved */
#include <linux/kernel.h>
#include <linux/bitops.h>
#include <linux/if_vlan.h>
#include <linux/if_bridge.h>
#include <linux/netdevice.h>
#include <linux/rhashtable.h>
#include <linux/rtnetlink.h>
#include "spectrum.h"
#include "reg.h"
struct mlxsw_sp_fid_family;
struct mlxsw_sp_fid_core {
struct rhashtable fid_ht;
struct rhashtable vni_ht;
struct mlxsw_sp_fid_family *fid_family_arr[MLXSW_SP_FID_TYPE_MAX];
unsigned int *port_fid_mappings;
};
struct mlxsw_sp_fid {
struct list_head list;
struct mlxsw_sp_rif *rif;
unsigned int ref_count;
u16 fid_index;
struct mlxsw_sp_fid_family *fid_family;
struct rhash_head ht_node;
struct rhash_head vni_ht_node;
enum mlxsw_sp_nve_type nve_type;
__be32 vni;
u32 nve_flood_index;
int nve_ifindex;
u8 vni_valid:1,
nve_flood_index_valid:1;
};
struct mlxsw_sp_fid_8021q {
struct mlxsw_sp_fid common;
u16 vid;
};
struct mlxsw_sp_fid_8021d {
struct mlxsw_sp_fid common;
int br_ifindex;
};
static const struct rhashtable_params mlxsw_sp_fid_ht_params = {
.key_len = sizeof_field(struct mlxsw_sp_fid, fid_index),
.key_offset = offsetof(struct mlxsw_sp_fid, fid_index),
.head_offset = offsetof(struct mlxsw_sp_fid, ht_node),
};
static const struct rhashtable_params mlxsw_sp_fid_vni_ht_params = {
.key_len = sizeof_field(struct mlxsw_sp_fid, vni),
.key_offset = offsetof(struct mlxsw_sp_fid, vni),
.head_offset = offsetof(struct mlxsw_sp_fid, vni_ht_node),
};
struct mlxsw_sp_flood_table {
enum mlxsw_sp_flood_type packet_type;
enum mlxsw_reg_sfgc_bridge_type bridge_type;
enum mlxsw_flood_table_type table_type;
int table_index;
};
struct mlxsw_sp_fid_ops {
void (*setup)(struct mlxsw_sp_fid *fid, const void *arg);
int (*configure)(struct mlxsw_sp_fid *fid);
void