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.

Dependency Surface

Detected Declarations

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

Implementation Notes