include/net/dsa.h
Source file repositories/reference/linux-study-clean/include/net/dsa.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/dsa.h- Extension
.h- Size
- 43169 bytes
- Lines
- 1418
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/if.hlinux/if_ether.hlinux/list.hlinux/notifier.hlinux/timer.hlinux/workqueue.hlinux/of.hlinux/ethtool.hlinux/net_tstamp.hlinux/phy.hlinux/platform_data/dsa.hlinux/phylink.hnet/devlink.hnet/switchdev.h
Detected Declarations
struct dsa_8021q_contextstruct tc_actionstruct dsa_switchstruct dsa_device_opsstruct dsa_lagstruct dsa_switch_treestruct dsa_mall_mirror_tc_entrystruct dsa_mall_tc_entrystruct dsa_bridgestruct dsa_portstruct dsa_linkstruct dsa_dbstruct dsa_mac_addrstruct dsa_vlanstruct dsa_switchstruct dsa_switch_opsstruct dsa_devlink_privenum dsa_tag_protocolenum dsa_port_mall_action_typeenum dsa_db_typefunction dsa_lag_idfunction dsa_lags_foreach_idfunction dsa_phylink_to_portfunction dsa_port_is_dsafunction dsa_port_is_cpufunction dsa_port_is_userfunction dsa_port_is_unusedfunction dsa_port_conduit_is_operationalfunction dsa_is_unused_portfunction dsa_is_cpu_portfunction dsa_is_dsa_portfunction dsa_is_user_portfunction dsa_cpu_portsfunction dsa_routing_portfunction dsa_towards_portfunction dsa_upstream_portfunction dsa_is_upstream_portfunction dsa_is_downstream_portfunction dsa_switch_upstream_portfunction dsa_switch_for_each_available_portfunction dsa_switch_is_upstream_offunction dsa_port_is_vlan_filteringfunction dsa_port_lag_id_getfunction dsa_port_offloads_lagfunction dsa_port_bridge_dev_getfunction dsa_port_bridge_num_getfunction dsa_port_bridge_samefunction dsa_port_offloads_bridge_port
Annotated Snippet
struct dsa_device_ops {
struct sk_buff *(*xmit)(struct sk_buff *skb, struct net_device *dev);
struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev);
void (*flow_dissect)(const struct sk_buff *skb, __be16 *proto,
int *offset);
int (*connect)(struct dsa_switch *ds);
void (*disconnect)(struct dsa_switch *ds);
unsigned int needed_headroom;
unsigned int needed_tailroom;
const char *name;
enum dsa_tag_protocol proto;
/* Some tagging protocols either mangle or shift the destination MAC
* address, in which case the DSA conduit would drop packets on ingress
* if what it understands out of the destination MAC address is not in
* its RX filter.
*/
bool promisc_on_conduit;
};
struct dsa_lag {
struct net_device *dev;
unsigned int id;
struct mutex fdb_lock;
struct list_head fdbs;
refcount_t refcount;
};
struct dsa_switch_tree {
struct list_head list;
/* List of switch ports */
struct list_head ports;
/* Notifier chain for switch-wide events */
struct raw_notifier_head nh;
/* Tree identifier */
unsigned int index;
/* Number of switches attached to this tree */
struct kref refcount;
/* Maps offloaded LAG netdevs to a zero-based linear ID for
* drivers that need it.
*/
struct dsa_lag **lags;
/* Tagging protocol operations */
const struct dsa_device_ops *tag_ops;
/* Default tagging protocol preferred by the switches in this
* tree.
*/
enum dsa_tag_protocol default_proto;
/* Has this tree been applied to the hardware? */
bool setup;
/*
* Configuration data for the platform device that owns
* this dsa switch tree instance.
*/
struct dsa_platform_data *pd;
/* List of DSA links composing the routing table */
struct list_head rtable;
/* Length of "lags" array */
unsigned int lags_len;
/* Track the largest switch index within a tree */
unsigned int last_switch;
};
/* LAG IDs are one-based, the dst->lags array is zero-based */
#define dsa_lags_foreach_id(_id, _dst) \
for ((_id) = 1; (_id) <= (_dst)->lags_len; (_id)++) \
if ((_dst)->lags[(_id) - 1])
#define dsa_lag_foreach_port(_dp, _dst, _lag) \
list_for_each_entry((_dp), &(_dst)->ports, list) \
if (dsa_port_offloads_lag((_dp), (_lag)))
#define dsa_hsr_foreach_port(_dp, _ds, _hsr) \
list_for_each_entry((_dp), &(_ds)->dst->ports, list) \
if ((_dp)->ds == (_ds) && (_dp)->hsr_dev == (_hsr))
static inline struct dsa_lag *dsa_lag_by_id(struct dsa_switch_tree *dst,
unsigned int id)
{
Annotation
- Immediate include surface: `linux/if.h`, `linux/if_ether.h`, `linux/list.h`, `linux/notifier.h`, `linux/timer.h`, `linux/workqueue.h`, `linux/of.h`, `linux/ethtool.h`.
- Detected declarations: `struct dsa_8021q_context`, `struct tc_action`, `struct dsa_switch`, `struct dsa_device_ops`, `struct dsa_lag`, `struct dsa_switch_tree`, `struct dsa_mall_mirror_tc_entry`, `struct dsa_mall_tc_entry`, `struct dsa_bridge`, `struct dsa_port`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- 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.