xref: /linux-6.15/include/linux/dsa/8021q.h (revision 568a36a6)
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_port_setup_8021q_tagging(struct dsa_switch *ds, int index,
29 				 bool enabled);
30 
31 int dsa_8021q_crosschip_bridge_join(struct dsa_switch *ds, int port,
32 				    struct dsa_switch *other_ds,
33 				    int other_port,
34 				    struct list_head *crosschip_links);
35 
36 int dsa_8021q_crosschip_bridge_leave(struct dsa_switch *ds, int port,
37 				     struct dsa_switch *other_ds,
38 				     int other_port,
39 				     struct list_head *crosschip_links);
40 
41 struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev,
42 			       u16 tpid, u16 tci);
43 
44 u16 dsa_8021q_tx_vid(struct dsa_switch *ds, int port);
45 
46 u16 dsa_8021q_rx_vid(struct dsa_switch *ds, int port);
47 
48 u16 dsa_8021q_rx_vid_subvlan(struct dsa_switch *ds, int port, u16 subvlan);
49 
50 int dsa_8021q_rx_switch_id(u16 vid);
51 
52 int dsa_8021q_rx_source_port(u16 vid);
53 
54 u16 dsa_8021q_rx_subvlan(u16 vid);
55 
56 bool vid_is_dsa_8021q(u16 vid);
57 
58 #else
59 
60 int dsa_port_setup_8021q_tagging(struct dsa_switch *ds, int index,
61 				 bool enabled)
62 {
63 	return 0;
64 }
65 
66 int dsa_8021q_crosschip_bridge_join(struct dsa_switch *ds, int port,
67 				    struct dsa_switch *other_ds,
68 				    int other_port,
69 				    struct list_head *crosschip_links)
70 {
71 	return 0;
72 }
73 
74 int dsa_8021q_crosschip_bridge_leave(struct dsa_switch *ds, int port,
75 				     struct dsa_switch *other_ds,
76 				     int other_port,
77 				     struct list_head *crosschip_links)
78 {
79 	return 0;
80 }
81 
82 struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev,
83 			       u16 tpid, u16 tci)
84 {
85 	return NULL;
86 }
87 
88 u16 dsa_8021q_tx_vid(struct dsa_switch *ds, int port)
89 {
90 	return 0;
91 }
92 
93 u16 dsa_8021q_rx_vid(struct dsa_switch *ds, int port)
94 {
95 	return 0;
96 }
97 
98 u16 dsa_8021q_rx_vid_subvlan(struct dsa_switch *ds, int port, u16 subvlan)
99 {
100 	return 0;
101 }
102 
103 int dsa_8021q_rx_switch_id(u16 vid)
104 {
105 	return 0;
106 }
107 
108 int dsa_8021q_rx_source_port(u16 vid)
109 {
110 	return 0;
111 }
112 
113 u16 dsa_8021q_rx_subvlan(u16 vid)
114 {
115 	return 0;
116 }
117 
118 bool vid_is_dsa_8021q(u16 vid)
119 {
120 	return false;
121 }
122 
123 #endif /* IS_ENABLED(CONFIG_NET_DSA_TAG_8021Q) */
124 
125 #endif /* _NET_DSA_8021Q_H */
126