xref: /kernel/linux/linux-6.6/net/dsa/switch.h (revision 62306a36)
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2
3#ifndef __DSA_SWITCH_H
4#define __DSA_SWITCH_H
5
6#include <net/dsa.h>
7
8struct netlink_ext_ack;
9
10enum {
11	DSA_NOTIFIER_AGEING_TIME,
12	DSA_NOTIFIER_BRIDGE_JOIN,
13	DSA_NOTIFIER_BRIDGE_LEAVE,
14	DSA_NOTIFIER_FDB_ADD,
15	DSA_NOTIFIER_FDB_DEL,
16	DSA_NOTIFIER_HOST_FDB_ADD,
17	DSA_NOTIFIER_HOST_FDB_DEL,
18	DSA_NOTIFIER_LAG_FDB_ADD,
19	DSA_NOTIFIER_LAG_FDB_DEL,
20	DSA_NOTIFIER_LAG_CHANGE,
21	DSA_NOTIFIER_LAG_JOIN,
22	DSA_NOTIFIER_LAG_LEAVE,
23	DSA_NOTIFIER_MDB_ADD,
24	DSA_NOTIFIER_MDB_DEL,
25	DSA_NOTIFIER_HOST_MDB_ADD,
26	DSA_NOTIFIER_HOST_MDB_DEL,
27	DSA_NOTIFIER_VLAN_ADD,
28	DSA_NOTIFIER_VLAN_DEL,
29	DSA_NOTIFIER_HOST_VLAN_ADD,
30	DSA_NOTIFIER_HOST_VLAN_DEL,
31	DSA_NOTIFIER_MTU,
32	DSA_NOTIFIER_TAG_PROTO,
33	DSA_NOTIFIER_TAG_PROTO_CONNECT,
34	DSA_NOTIFIER_TAG_PROTO_DISCONNECT,
35	DSA_NOTIFIER_TAG_8021Q_VLAN_ADD,
36	DSA_NOTIFIER_TAG_8021Q_VLAN_DEL,
37	DSA_NOTIFIER_MASTER_STATE_CHANGE,
38};
39
40/* DSA_NOTIFIER_AGEING_TIME */
41struct dsa_notifier_ageing_time_info {
42	unsigned int ageing_time;
43};
44
45/* DSA_NOTIFIER_BRIDGE_* */
46struct dsa_notifier_bridge_info {
47	const struct dsa_port *dp;
48	struct dsa_bridge bridge;
49	bool tx_fwd_offload;
50	struct netlink_ext_ack *extack;
51};
52
53/* DSA_NOTIFIER_FDB_* */
54struct dsa_notifier_fdb_info {
55	const struct dsa_port *dp;
56	const unsigned char *addr;
57	u16 vid;
58	struct dsa_db db;
59};
60
61/* DSA_NOTIFIER_LAG_FDB_* */
62struct dsa_notifier_lag_fdb_info {
63	struct dsa_lag *lag;
64	const unsigned char *addr;
65	u16 vid;
66	struct dsa_db db;
67};
68
69/* DSA_NOTIFIER_MDB_* */
70struct dsa_notifier_mdb_info {
71	const struct dsa_port *dp;
72	const struct switchdev_obj_port_mdb *mdb;
73	struct dsa_db db;
74};
75
76/* DSA_NOTIFIER_LAG_* */
77struct dsa_notifier_lag_info {
78	const struct dsa_port *dp;
79	struct dsa_lag lag;
80	struct netdev_lag_upper_info *info;
81	struct netlink_ext_ack *extack;
82};
83
84/* DSA_NOTIFIER_VLAN_* */
85struct dsa_notifier_vlan_info {
86	const struct dsa_port *dp;
87	const struct switchdev_obj_port_vlan *vlan;
88	struct netlink_ext_ack *extack;
89};
90
91/* DSA_NOTIFIER_MTU */
92struct dsa_notifier_mtu_info {
93	const struct dsa_port *dp;
94	int mtu;
95};
96
97/* DSA_NOTIFIER_TAG_PROTO_* */
98struct dsa_notifier_tag_proto_info {
99	const struct dsa_device_ops *tag_ops;
100};
101
102/* DSA_NOTIFIER_TAG_8021Q_VLAN_* */
103struct dsa_notifier_tag_8021q_vlan_info {
104	const struct dsa_port *dp;
105	u16 vid;
106};
107
108/* DSA_NOTIFIER_MASTER_STATE_CHANGE */
109struct dsa_notifier_master_state_info {
110	const struct net_device *master;
111	bool operational;
112};
113
114struct dsa_vlan *dsa_vlan_find(struct list_head *vlan_list,
115			       const struct switchdev_obj_port_vlan *vlan);
116
117int dsa_tree_notify(struct dsa_switch_tree *dst, unsigned long e, void *v);
118int dsa_broadcast(unsigned long e, void *v);
119
120int dsa_switch_register_notifier(struct dsa_switch *ds);
121void dsa_switch_unregister_notifier(struct dsa_switch *ds);
122
123#endif
124