drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c- Extension
.c- Size
- 70118 bytes
- Lines
- 2500
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/bitops.hlinux/if_vlan.hlinux/if_bridge.hlinux/netdevice.hlinux/rhashtable.hlinux/rtnetlink.hlinux/refcount.hspectrum.hspectrum_router.hreg.h
Detected Declarations
struct mlxsw_sp_fid_familystruct mlxsw_sp_fid_corestruct mlxsw_sp_fid_port_vidstruct mlxsw_sp_fidstruct mlxsw_sp_fid_8021qstruct mlxsw_sp_fid_8021dstruct mlxsw_sp_flood_tablestruct mlxsw_sp_fid_opsstruct mlxsw_sp_fid_flood_profilestruct mlxsw_sp_fid_familyenum mlxsw_sp_fid_flood_profile_idfunction mlxsw_sp_fid_nve_ifindexfunction mlxsw_sp_fid_nve_typefunction mlxsw_sp_fid_vnifunction mlxsw_sp_fid_nve_flood_index_setfunction mlxsw_sp_fid_nve_flood_index_clearfunction mlxsw_sp_fid_nve_flood_index_is_setfunction mlxsw_sp_fid_vni_setfunction mlxsw_sp_fid_vni_clearfunction mlxsw_sp_fid_vni_is_setfunction mlxsw_sp_fid_fdb_clear_offloadfunction mlxsw_sp_fid_flood_table_lookupfunction mlxsw_sp_fid_family_num_fidsfunction mlxsw_sp_fid_8021d_pgt_sizefunction mlxsw_sp_fid_rfid_port_offset_cfffunction mlxsw_sp_fid_rfid_pgt_size_cfffunction mlxsw_sp_fid_pgt_base_ctlfunction mlxsw_sp_fid_fid_mid_ctlfunction mlxsw_sp_fid_flood_setfunction mlxsw_sp_fid_port_vid_mapfunction mlxsw_sp_fid_port_vid_unmapfunction mlxsw_sp_fid_indexfunction mlxsw_sp_fid_typefunction mlxsw_sp_fid_type_rif_typefunction mlxsw_sp_fid_8021q_fidfunction mlxsw_sp_fid_8021q_vidfunction mlxsw_sp_fid_8021q_setupfunction mlxsw_sp_sfmr_opfunction mlxsw_sp_fid_packfunction mlxsw_sp_fid_pack_ctlfunction mlxsw_sp_fid_off_pgt_base_cfffunction mlxsw_sp_fid_pgt_base_cfffunction mlxsw_sp_fid_fid_pack_cfffunction mlxsw_sp_fid_rfid_fid_offset_cfffunction mlxsw_sp_fid_opfunction mlxsw_sp_fid_edit_opfunction mlxsw_sp_fid_vni_to_fid_mapfunction mlxsw_sp_fid_to_fid_rif_update
Annotated Snippet
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_port_vid {
struct list_head list;
u16 local_port;
u16 vid;
};
struct mlxsw_sp_fid {
struct list_head list;
struct mlxsw_sp_rif *rif;
refcount_t ref_count;
u16 fid_index;
u16 fid_offset;
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 list_head port_vid_list; /* Ordered by local port. */
};
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_flood_table_type table_type; /* For flood_mode!=CFF. */
int table_index;
};
struct mlxsw_sp_fid_ops {
int (*setup)(struct mlxsw_sp_fid *fid, const void *arg);
int (*configure)(struct mlxsw_sp_fid *fid);
void (*deconfigure)(struct mlxsw_sp_fid *fid);
int (*index_alloc)(struct mlxsw_sp_fid *fid, const void *arg,
u16 *p_fid_index);
bool (*compare)(const struct mlxsw_sp_fid *fid,
const void *arg);
int (*port_vid_map)(struct mlxsw_sp_fid *fid,
struct mlxsw_sp_port *port, u16 vid);
void (*port_vid_unmap)(struct mlxsw_sp_fid *fid,
struct mlxsw_sp_port *port, u16 vid);
int (*vni_set)(struct mlxsw_sp_fid *fid);
void (*vni_clear)(struct mlxsw_sp_fid *fid);
int (*nve_flood_index_set)(struct mlxsw_sp_fid *fid);
void (*nve_flood_index_clear)(struct mlxsw_sp_fid *fid);
void (*fdb_clear_offload)(const struct mlxsw_sp_fid *fid,
const struct net_device *nve_dev);
int (*vid_to_fid_rif_update)(const struct mlxsw_sp_fid *fid,
const struct mlxsw_sp_rif *rif);
int (*flood_table_init)(struct mlxsw_sp_fid_family *fid_family,
const struct mlxsw_sp_flood_table *flood_table);
int (*pgt_size)(const struct mlxsw_sp_fid_family *fid_family,
u16 *p_pgt_size);
u16 (*fid_mid)(const struct mlxsw_sp_fid *fid,
const struct mlxsw_sp_flood_table *flood_table);
void (*fid_pack)(char *sfmr_pl, const struct mlxsw_sp_fid *fid,
enum mlxsw_reg_sfmr_op op);
/* These are specific to RFID families and we assume are only
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/bitops.h`, `linux/if_vlan.h`, `linux/if_bridge.h`, `linux/netdevice.h`, `linux/rhashtable.h`, `linux/rtnetlink.h`, `linux/refcount.h`.
- Detected declarations: `struct mlxsw_sp_fid_family`, `struct mlxsw_sp_fid_core`, `struct mlxsw_sp_fid_port_vid`, `struct mlxsw_sp_fid`, `struct mlxsw_sp_fid_8021q`, `struct mlxsw_sp_fid_8021d`, `struct mlxsw_sp_flood_table`, `struct mlxsw_sp_fid_ops`, `struct mlxsw_sp_fid_flood_profile`, `struct mlxsw_sp_fid_family`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.