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.
86 # configure each interface
87 ip addr add 192.0.2.1/30 dev lan1
88 ip addr add 192.0.2.5/30 dev lan2
89 ip addr add 192.0.2.9/30 dev lan3
91 # The master interface needs to be brought up before the slave ports.
94 # bring up the slave interfaces
104 # The master interface needs to be brought up before the slave ports.
107 # bring up the slave interfaces
113 ip link add name br0 type bridge
115 # add ports to bridge
116 ip link set dev lan1 master br0
117 ip link set dev lan2 master br0
118 ip link set dev lan3 master br0
120 # configure the bridge
121 ip addr add 192.0.2.129/25 dev br0
123 # bring up the bridge
124 ip link set dev br0 up
131 # The master interface needs to be brought up before the slave ports.
134 # bring up the slave interfaces
139 # configure the upstream port
140 ip addr add 192.0.2.1/30 dev wan
143 ip link add name br0 type bridge
145 # add ports to bridge
146 ip link set dev lan1 master br0
147 ip link set dev lan2 master br0
149 # configure the bridge
150 ip addr add 192.0.2.129/25 dev br0
152 # bring up the bridge
153 ip link set dev br0 up
155 .. _dsa-vlan-configuration:
157 Configuration without tagging support
158 -------------------------------------
160 A minority of switches are not capable to use a taging protocol
161 (DSA_TAG_PROTO_NONE). These switches can be configured by a VLAN based
166 The configuration can only be set up via VLAN tagging and bridge setup.
170 # tag traffic on CPU port
171 ip link add link eth0 name eth0.1 type vlan id 1
172 ip link add link eth0 name eth0.2 type vlan id 2
173 ip link add link eth0 name eth0.3 type vlan id 3
175 # The master interface needs to be brought up before the slave ports.
177 ip link set eth0.1 up
178 ip link set eth0.2 up
179 ip link set eth0.3 up
181 # bring up the slave interfaces
187 ip link add name br0 type bridge
189 # activate VLAN filtering
190 ip link set dev br0 type bridge vlan_filtering 1
192 # add ports to bridges
193 ip link set dev lan1 master br0
194 ip link set dev lan2 master br0
195 ip link set dev lan3 master br0
197 # tag traffic on ports
198 bridge vlan add dev lan1 vid 1 pvid untagged
199 bridge vlan add dev lan2 vid 2 pvid untagged
200 bridge vlan add dev lan3 vid 3 pvid untagged
202 # configure the VLANs
203 ip addr add 192.0.2.1/30 dev eth0.1
204 ip addr add 192.0.2.5/30 dev eth0.2
205 ip addr add 192.0.2.9/30 dev eth0.3
207 # bring up the bridge devices
216 # tag traffic on CPU port
217 ip link add link eth0 name eth0.1 type vlan id 1
219 # The master interface needs to be brought up before the slave ports.
221 ip link set eth0.1 up
223 # bring up the slave interfaces
229 ip link add name br0 type bridge
231 # activate VLAN filtering
232 ip link set dev br0 type bridge vlan_filtering 1
234 # add ports to bridge
235 ip link set dev lan1 master br0
236 ip link set dev lan2 master br0
237 ip link set dev lan3 master br0
238 ip link set eth0.1 master br0
240 # tag traffic on ports
241 bridge vlan add dev lan1 vid 1 pvid untagged
242 bridge vlan add dev lan2 vid 1 pvid untagged
243 bridge vlan add dev lan3 vid 1 pvid untagged
245 # configure the bridge
246 ip addr add 192.0.2.129/25 dev br0
248 # bring up the bridge
249 ip link set dev br0 up
256 # tag traffic on CPU port
257 ip link add link eth0 name eth0.1 type vlan id 1
258 ip link add link eth0 name eth0.2 type vlan id 2
260 # The master interface needs to be brought up before the slave ports.
262 ip link set eth0.1 up
263 ip link set eth0.2 up
265 # bring up the slave interfaces
271 ip link add name br0 type bridge
273 # activate VLAN filtering
274 ip link set dev br0 type bridge vlan_filtering 1
276 # add ports to bridges
277 ip link set dev wan master br0
278 ip link set eth0.1 master br0
279 ip link set dev lan1 master br0
280 ip link set dev lan2 master br0
282 # tag traffic on ports
283 bridge vlan add dev lan1 vid 1 pvid untagged
284 bridge vlan add dev lan2 vid 1 pvid untagged
285 bridge vlan add dev wan vid 2 pvid untagged
287 # configure the VLANs
288 ip addr add 192.0.2.1/30 dev eth0.2
289 ip addr add 192.0.2.129/25 dev br0
291 # bring up the bridge devices