1 .. SPDX-License-Identifier: GPL-2.0
3 =======================================
4 DSA switch configuration from userspace
5 =======================================
7 The DSA switch configuration is not integrated into the main userspace
8 network configuration suites by now and has to be performed manualy.
10 .. _dsa-config-showcases:
12 Configuration showcases
13 -----------------------
15 To configure a DSA switch a couple of commands need to be executed. In this
16 documentation some common configuration scenarios are handled as showcases:
19 Every switch port acts as a different configurable Ethernet port
22 Every switch port is part of one configurable Ethernet bridge
25 Every switch port except one upstream port is part of a configurable
27 The upstream port acts as different configurable Ethernet port.
29 All configurations are performed with tools from iproute2, which is available
30 at https://www.kernel.org/pub/linux/utils/net/iproute2/
32 Through DSA every port of a switch is handled like a normal linux Ethernet
33 interface. The CPU port is the switch port connected to an Ethernet MAC chip.
34 The corresponding linux Ethernet interface is called the master interface.
35 All other corresponding linux interfaces are called slave interfaces.
37 The slave interfaces depend on the master interface. They can only brought up,
38 when the master interface is up.
40 In this documentation the following Ethernet interfaces are used:
49 another slave interface
52 a third slave interface
55 A slave interface dedicated for upstream traffic
57 Further Ethernet interfaces can be configured similar.
58 The configured IPs and networks are:
61 * lan1: 192.0.2.1/30 (192.0.2.0 - 192.0.2.3)
62 * lan2: 192.0.2.5/30 (192.0.2.4 - 192.0.2.7)
63 * lan3: 192.0.2.9/30 (192.0.2.8 - 192.0.2.11)
66 * br0: 192.0.2.129/25 (192.0.2.128 - 192.0.2.255)
69 * br0: 192.0.2.129/25 (192.0.2.128 - 192.0.2.255)
70 * wan: 192.0.2.1/30 (192.0.2.0 - 192.0.2.3)
72 .. _dsa-tagged-configuration:
74 Configuration with tagging support
75 ----------------------------------
77 The tagging based configuration is desired and supported by the majority of
78 DSA switches. These switches are capable to tag incoming and outgoing traffic
79 without using a VLAN based configuration.
84 # configure each interface
85 ip addr add 192.0.2.1/30 dev lan1
86 ip addr add 192.0.2.5/30 dev lan2
87 ip addr add 192.0.2.9/30 dev lan3
89 # The master interface needs to be brought up before the slave ports.
92 # bring up the slave interfaces
100 # The master interface needs to be brought up before the slave ports.
103 # bring up the slave interfaces
109 ip link add name br0 type bridge
111 # add ports to bridge
112 ip link set dev lan1 master br0
113 ip link set dev lan2 master br0
114 ip link set dev lan3 master br0
116 # configure the bridge
117 ip addr add 192.0.2.129/25 dev br0
119 # bring up the bridge
120 ip link set dev br0 up
125 # The master interface needs to be brought up before the slave ports.
128 # bring up the slave interfaces
133 # configure the upstream port
134 ip addr add 192.0.2.1/30 dev wan
137 ip link add name br0 type bridge
139 # add ports to bridge
140 ip link set dev lan1 master br0
141 ip link set dev lan2 master br0
143 # configure the bridge
144 ip addr add 192.0.2.129/25 dev br0
146 # bring up the bridge
147 ip link set dev br0 up
149 .. _dsa-vlan-configuration:
151 Configuration without tagging support
152 -------------------------------------
154 A minority of switches are not capable to use a taging protocol
155 (DSA_TAG_PROTO_NONE). These switches can be configured by a VLAN based
159 The configuration can only be set up via VLAN tagging and bridge setup.
163 # tag traffic on CPU port
164 ip link add link eth0 name eth0.1 type vlan id 1
165 ip link add link eth0 name eth0.2 type vlan id 2
166 ip link add link eth0 name eth0.3 type vlan id 3
168 # The master interface needs to be brought up before the slave ports.
170 ip link set eth0.1 up
171 ip link set eth0.2 up
172 ip link set eth0.3 up
174 # bring up the slave interfaces
180 ip link add name br0 type bridge
182 # activate VLAN filtering
183 ip link set dev br0 type bridge vlan_filtering 1
185 # add ports to bridges
186 ip link set dev lan1 master br0
187 ip link set dev lan2 master br0
188 ip link set dev lan3 master br0
190 # tag traffic on ports
191 bridge vlan add dev lan1 vid 1 pvid untagged
192 bridge vlan add dev lan2 vid 2 pvid untagged
193 bridge vlan add dev lan3 vid 3 pvid untagged
195 # configure the VLANs
196 ip addr add 192.0.2.1/30 dev eth0.1
197 ip addr add 192.0.2.5/30 dev eth0.2
198 ip addr add 192.0.2.9/30 dev eth0.3
200 # bring up the bridge devices
207 # tag traffic on CPU port
208 ip link add link eth0 name eth0.1 type vlan id 1
210 # The master interface needs to be brought up before the slave ports.
212 ip link set eth0.1 up
214 # bring up the slave interfaces
220 ip link add name br0 type bridge
222 # activate VLAN filtering
223 ip link set dev br0 type bridge vlan_filtering 1
225 # add ports to bridge
226 ip link set dev lan1 master br0
227 ip link set dev lan2 master br0
228 ip link set dev lan3 master br0
229 ip link set eth0.1 master br0
231 # tag traffic on ports
232 bridge vlan add dev lan1 vid 1 pvid untagged
233 bridge vlan add dev lan2 vid 1 pvid untagged
234 bridge vlan add dev lan3 vid 1 pvid untagged
236 # configure the bridge
237 ip addr add 192.0.2.129/25 dev br0
239 # bring up the bridge
240 ip link set dev br0 up
245 # tag traffic on CPU port
246 ip link add link eth0 name eth0.1 type vlan id 1
247 ip link add link eth0 name eth0.2 type vlan id 2
249 # The master interface needs to be brought up before the slave ports.
251 ip link set eth0.1 up
252 ip link set eth0.2 up
254 # bring up the slave interfaces
260 ip link add name br0 type bridge
262 # activate VLAN filtering
263 ip link set dev br0 type bridge vlan_filtering 1
265 # add ports to bridges
266 ip link set dev wan master br0
267 ip link set eth0.1 master br0
268 ip link set dev lan1 master br0
269 ip link set dev lan2 master br0
271 # tag traffic on ports
272 bridge vlan add dev lan1 vid 1 pvid untagged
273 bridge vlan add dev lan2 vid 1 pvid untagged
274 bridge vlan add dev wan vid 2 pvid untagged
276 # configure the VLANs
277 ip addr add 192.0.2.1/30 dev eth0.2
278 ip addr add 192.0.2.129/25 dev br0
280 # bring up the bridge devices