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.

Dependency Surface

Detected Declarations

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

Implementation Notes