xref: /linux-6.15/include/linux/dsa/8021q.h (revision 7e092af2)
1 /* SPDX-License-Identifier: GPL-2.0
2  * Copyright (c) 2019, Vladimir Oltean <[email protected]>
3  */
4 
5 #ifndef _NET_DSA_8021Q_H
6 #define _NET_DSA_8021Q_H
7 
8 #include <linux/refcount.h>
9 #include <linux/types.h>
10 
11 struct dsa_switch;
12 struct sk_buff;
13 struct net_device;
14 struct packet_type;
15 
16 struct dsa_8021q_crosschip_link {
17 	struct list_head list;
18 	int port;
19 	struct dsa_switch *other_ds;
20 	int other_port;
21 	refcount_t refcount;
22 };
23 
24 #define DSA_8021Q_N_SUBVLAN			8
25 
26 #if IS_ENABLED(CONFIG_NET_DSA_TAG_8021Q)
27 
28 int dsa_8021q_setup(struct dsa_switch *ds, bool enabled);
29 
30 int dsa_8021q_crosschip_bridge_join(struct dsa_switch *ds, int port,
31 				    struct dsa_switch *other_ds,
32 				    int other_port,
33 				    struct list_head *crosschip_links);
34 
35 int dsa_8021q_crosschip_bridge_leave(struct dsa_switch *ds, int port,
36 				     struct dsa_switch *other_ds,
37 				     int other_port,
38 				     struct list_head *crosschip_links);
39 
40 struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev,
41 			       u16 tpid, u16 tci);
42 
43 u16 dsa_8021q_tx_vid(struct dsa_switch *ds, int port);
44 
45 u16 dsa_8021q_rx_vid(struct dsa_switch *ds, int port);
46 
47 u16 dsa_8021q_rx_vid_subvlan(struct dsa_switch *ds, int port, u16 subvlan);
48 
49 int dsa_8021q_rx_switch_id(u16 vid);
50 
51 int dsa_8021q_rx_source_port(u16 vid);
52 
53 u16 dsa_8021q_rx_subvlan(u16 vid);
54 
55 bool vid_is_dsa_8021q(u16 vid);
56 
57 #else
58 
59 int dsa_8021q_setup(struct dsa_switch *ds, bool enabled)
60 {
61 	return 0;
62 }
63 
64 int dsa_8021q_crosschip_bridge_join(struct dsa_switch *ds, int port,
65 				    struct dsa_switch *other_ds,
66 				    int other_port,
67 				    struct list_head *crosschip_links)
68 {
69 	return 0;
70 }
71 
72 int dsa_8021q_crosschip_bridge_leave(struct dsa_switch *ds, int port,
73 				     struct dsa_switch *other_ds,
74 				     int other_port,
75 				     struct list_head *crosschip_links)
76 {
77 	return 0;
78 }
79 
80 struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev,
81 			       u16 tpid, u16 tci)
82 {
83 	return NULL;
84 }
85 
86 u16 dsa_8021q_tx_vid(struct dsa_switch *ds, int port)
87 {
88 	return 0;
89 }
90 
91 u16 dsa_8021q_rx_vid(struct dsa_switch *ds, int port)
92 {
93 	return 0;
94 }
95 
96 u16 dsa_8021q_rx_vid_subvlan(struct dsa_switch *ds, int port, u16 subvlan)
97 {
98 	return 0;
99 }
100 
101 int dsa_8021q_rx_switch_id(u16 vid)
102 {
103 	return 0;
104 }
105 
106 int dsa_8021q_rx_source_port(u16 vid)
107 {
108 	return 0;
109 }
110 
111 u16 dsa_8021q_rx_subvlan(u16 vid)
112 {
113 	return 0;
114 }
115 
116 bool vid_is_dsa_8021q(u16 vid)
117 {
118 	return false;
119 }
120 
121 #endif /* IS_ENABLED(CONFIG_NET_DSA_TAG_8021Q) */
122 
123 #endif /* _NET_DSA_8021Q_H */
124