drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c- Extension
.c- Size
- 117311 bytes
- Lines
- 4195
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/types.hlinux/netdevice.hlinux/etherdevice.hlinux/slab.hlinux/device.hlinux/skbuff.hlinux/if_vlan.hlinux/if_bridge.hlinux/workqueue.hlinux/jiffies.hlinux/rtnetlink.hlinux/netlink.hnet/switchdev.hnet/vxlan.hspectrum_span.hspectrum_switchdev.hspectrum.hcore.hreg.h
Detected Declarations
struct mlxsw_sp_bridge_opsstruct mlxsw_sp_bridgestruct mlxsw_sp_bridge_devicestruct mlxsw_sp_bridge_portstruct mlxsw_sp_bridge_vlanstruct mlxsw_sp_bridge_opsstruct mlxsw_sp_switchdev_opsstruct mlxsw_sp_mdb_entry_keystruct mlxsw_sp_mdb_entrystruct mlxsw_sp_mdb_entry_portstruct mlxsw_sp_bridge_port_replay_switchdev_objsstruct mlxsw_sp_switchdev_event_workfunction mlxsw_sp_bridge_device_findfunction mlxsw_sp_bridge_device_is_offloadedfunction mlxsw_sp_bridge_device_upper_rif_destroyfunction mlxsw_sp_bridge_device_rifs_destroyfunction mlxsw_sp_bridge_device_vxlan_initfunction netdev_for_each_lower_devfunction mlxsw_sp_bridge_device_vxlan_finifunction netdev_for_each_lower_devfunction mlxsw_sp_fdb_notify_work_schedulefunction mlxsw_sp_bridge_device_createfunction mlxsw_sp_bridge_device_destroyfunction mlxsw_sp_bridge_device_getfunction mlxsw_sp_bridge_device_putfunction __mlxsw_sp_bridge_port_findfunction list_for_each_entryfunction mlxsw_sp_bridge_port_findfunction mlxsw_sp_bridge_port_replay_switchdev_objsfunction mlxsw_sp_bridge_port_unreplay_switchdev_objsfunction mlxsw_sp_bridge_port_createfunction mlxsw_sp_bridge_port_destroyfunction mlxsw_sp_bridge_port_getfunction mlxsw_sp_bridge_port_putfunction mlxsw_sp_port_vlan_find_by_bridgefunction list_for_each_entryfunction mlxsw_sp_port_vlan_find_by_fidfunction list_for_each_entryfunction mlxsw_sp_bridge_vlan_findfunction list_for_each_entryfunction mlxsw_sp_bridge_vlan_createfunction mlxsw_sp_bridge_vlan_destroyfunction mlxsw_sp_bridge_vlan_getfunction mlxsw_sp_bridge_vlan_putfunction mlxsw_sp_port_bridge_vlan_stp_setfunction list_for_each_entryfunction mlxsw_sp_port_attr_stp_state_setfunction list_for_each_entry
Annotated Snippet
struct mlxsw_sp_bridge {
struct mlxsw_sp *mlxsw_sp;
struct {
struct delayed_work dw;
#define MLXSW_SP_DEFAULT_LEARNING_INTERVAL 100
unsigned int interval; /* ms */
} fdb_notify;
#define MLXSW_SP_MIN_AGEING_TIME 10
#define MLXSW_SP_MAX_AGEING_TIME 1000000
#define MLXSW_SP_DEFAULT_AGEING_TIME 300
u32 ageing_time;
bool vlan_enabled_exists;
struct list_head bridges_list;
DECLARE_BITMAP(mids_bitmap, MLXSW_SP_MID_MAX);
const struct mlxsw_sp_bridge_ops *bridge_8021q_ops;
const struct mlxsw_sp_bridge_ops *bridge_8021d_ops;
const struct mlxsw_sp_bridge_ops *bridge_8021ad_ops;
};
struct mlxsw_sp_bridge_device {
struct net_device *dev;
struct list_head list;
struct list_head ports_list;
struct list_head mdb_list;
struct rhashtable mdb_ht;
u8 vlan_enabled:1,
multicast_enabled:1,
mrouter:1;
const struct mlxsw_sp_bridge_ops *ops;
};
struct mlxsw_sp_bridge_port {
struct net_device *dev;
struct mlxsw_sp_bridge_device *bridge_device;
struct list_head list;
struct list_head vlans_list;
refcount_t ref_count;
u8 stp_state;
unsigned long flags;
bool mrouter;
bool lagged;
union {
u16 lag_id;
u16 system_port;
};
};
struct mlxsw_sp_bridge_vlan {
struct list_head list;
struct list_head port_vlan_list;
u16 vid;
};
struct mlxsw_sp_bridge_ops {
int (*port_join)(struct mlxsw_sp_bridge_device *bridge_device,
struct mlxsw_sp_bridge_port *bridge_port,
struct mlxsw_sp_port *mlxsw_sp_port,
struct netlink_ext_ack *extack);
void (*port_leave)(struct mlxsw_sp_bridge_device *bridge_device,
struct mlxsw_sp_bridge_port *bridge_port,
struct mlxsw_sp_port *mlxsw_sp_port);
int (*vxlan_join)(struct mlxsw_sp_bridge_device *bridge_device,
const struct net_device *vxlan_dev, u16 vid,
struct netlink_ext_ack *extack);
struct mlxsw_sp_fid *
(*fid_get)(struct mlxsw_sp_bridge_device *bridge_device,
u16 vid, struct netlink_ext_ack *extack);
struct mlxsw_sp_fid *
(*fid_lookup)(struct mlxsw_sp_bridge_device *bridge_device,
u16 vid);
u16 (*fid_vid)(struct mlxsw_sp_bridge_device *bridge_device,
const struct mlxsw_sp_fid *fid);
};
struct mlxsw_sp_switchdev_ops {
void (*init)(struct mlxsw_sp *mlxsw_sp);
};
struct mlxsw_sp_mdb_entry_key {
unsigned char addr[ETH_ALEN];
u16 fid;
};
struct mlxsw_sp_mdb_entry {
struct list_head list;
struct rhash_head ht_node;
struct mlxsw_sp_mdb_entry_key key;
u16 mid;
struct list_head ports_list;
u16 ports_count;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/types.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/slab.h`, `linux/device.h`, `linux/skbuff.h`, `linux/if_vlan.h`.
- Detected declarations: `struct mlxsw_sp_bridge_ops`, `struct mlxsw_sp_bridge`, `struct mlxsw_sp_bridge_device`, `struct mlxsw_sp_bridge_port`, `struct mlxsw_sp_bridge_vlan`, `struct mlxsw_sp_bridge_ops`, `struct mlxsw_sp_switchdev_ops`, `struct mlxsw_sp_mdb_entry_key`, `struct mlxsw_sp_mdb_entry`, `struct mlxsw_sp_mdb_entry_port`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.