include/net/switchdev.h
Source file repositories/reference/linux-study-clean/include/net/switchdev.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/switchdev.h- Extension
.h- Size
- 15504 bytes
- Lines
- 530
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/netdevice.hlinux/notifier.hlinux/list.hnet/ip_fib.h
Detected Declarations
struct switchdev_mst_statestruct switchdev_brport_flagsstruct switchdev_vlan_mstistruct switchdev_attrstruct switchdev_objstruct switchdev_obj_port_vlanstruct switchdev_obj_port_mdbstruct switchdev_obj_mrpstruct switchdev_obj_ring_test_mrpstruct switchdev_obj_ring_role_mrpstruct switchdev_obj_ring_state_mrpstruct switchdev_obj_in_test_mrpstruct switchdev_obj_in_role_mrpstruct switchdev_obj_in_state_mrpstruct switchdev_brportstruct switchdev_notifier_infostruct switchdev_notifier_fdb_infostruct switchdev_notifier_port_obj_infostruct switchdev_notifier_port_attr_infostruct switchdev_notifier_brport_infoenum switchdev_attr_idenum switchdev_obj_idenum switchdev_notifier_typefunction switchdev_notifier_info_to_devfunction switchdev_notifier_info_to_extackfunction switchdev_fdb_is_dynamically_learnedfunction switchdev_bridge_port_offloadfunction switchdev_bridge_port_unoffloadfunction switchdev_port_obj_addfunction switchdev_port_obj_delfunction register_switchdev_notifierfunction unregister_switchdev_notifierfunction call_switchdev_notifiersfunction register_switchdev_blocking_notifierfunction unregister_switchdev_blocking_notifierfunction call_switchdev_blocking_notifiersfunction switchdev_handle_fdb_event_to_devicefunction switchdev_handle_port_obj_addfunction switchdev_handle_port_obj_add_foreignfunction switchdev_handle_port_obj_delfunction switchdev_handle_port_obj_del_foreignfunction switchdev_handle_port_attr_set
Annotated Snippet
struct switchdev_mst_state {
u16 msti;
u8 state;
};
struct switchdev_brport_flags {
unsigned long val;
unsigned long mask;
};
struct switchdev_vlan_msti {
u16 vid;
u16 msti;
};
struct switchdev_attr {
struct net_device *orig_dev;
enum switchdev_attr_id id;
u32 flags;
void *complete_priv;
void (*complete)(struct net_device *dev, int err, void *priv);
union {
u8 stp_state; /* PORT_STP_STATE */
struct switchdev_mst_state mst_state; /* PORT_MST_STATE */
struct switchdev_brport_flags brport_flags; /* PORT_BRIDGE_FLAGS */
bool mrouter; /* PORT_MROUTER */
clock_t ageing_time; /* BRIDGE_AGEING_TIME */
bool vlan_filtering; /* BRIDGE_VLAN_FILTERING */
u16 vlan_protocol; /* BRIDGE_VLAN_PROTOCOL */
bool mst; /* BRIDGE_MST */
bool mc_disabled; /* MC_DISABLED */
u8 mrp_port_role; /* MRP_PORT_ROLE */
struct switchdev_vlan_msti vlan_msti; /* VLAN_MSTI */
} u;
};
enum switchdev_obj_id {
SWITCHDEV_OBJ_ID_UNDEFINED,
SWITCHDEV_OBJ_ID_PORT_VLAN,
SWITCHDEV_OBJ_ID_PORT_MDB,
SWITCHDEV_OBJ_ID_HOST_MDB,
SWITCHDEV_OBJ_ID_MRP,
SWITCHDEV_OBJ_ID_RING_TEST_MRP,
SWITCHDEV_OBJ_ID_RING_ROLE_MRP,
SWITCHDEV_OBJ_ID_RING_STATE_MRP,
SWITCHDEV_OBJ_ID_IN_TEST_MRP,
SWITCHDEV_OBJ_ID_IN_ROLE_MRP,
SWITCHDEV_OBJ_ID_IN_STATE_MRP,
};
struct switchdev_obj {
struct list_head list;
struct net_device *orig_dev;
enum switchdev_obj_id id;
u32 flags;
void *complete_priv;
void (*complete)(struct net_device *dev, int err, void *priv);
};
/* SWITCHDEV_OBJ_ID_PORT_VLAN */
struct switchdev_obj_port_vlan {
struct switchdev_obj obj;
u16 flags;
u16 vid;
/* If set, the notifier signifies a change of one of the following
* flags for a VLAN that already exists:
* - BRIDGE_VLAN_INFO_PVID
* - BRIDGE_VLAN_INFO_UNTAGGED
* Entries with BRIDGE_VLAN_INFO_BRENTRY unset are not notified at all.
*/
bool changed;
};
#define SWITCHDEV_OBJ_PORT_VLAN(OBJ) \
container_of((OBJ), struct switchdev_obj_port_vlan, obj)
/* SWITCHDEV_OBJ_ID_PORT_MDB */
struct switchdev_obj_port_mdb {
struct switchdev_obj obj;
unsigned char addr[ETH_ALEN];
u16 vid;
};
#define SWITCHDEV_OBJ_PORT_MDB(OBJ) \
container_of((OBJ), struct switchdev_obj_port_mdb, obj)
/* SWITCHDEV_OBJ_ID_MRP */
struct switchdev_obj_mrp {
struct switchdev_obj obj;
Annotation
- Immediate include surface: `linux/netdevice.h`, `linux/notifier.h`, `linux/list.h`, `net/ip_fib.h`.
- Detected declarations: `struct switchdev_mst_state`, `struct switchdev_brport_flags`, `struct switchdev_vlan_msti`, `struct switchdev_attr`, `struct switchdev_obj`, `struct switchdev_obj_port_vlan`, `struct switchdev_obj_port_mdb`, `struct switchdev_obj_mrp`, `struct switchdev_obj_ring_test_mrp`, `struct switchdev_obj_ring_role_mrp`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- 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.