xref: /linux/Documentation/networking/dsa/configuration.rst (revision ec8a42e7343234802b9054874fe01810880289ce)
1.. SPDX-License-Identifier: GPL-2.0
2
3=======================================
4DSA switch configuration from userspace
5=======================================
6
7The DSA switch configuration is not integrated into the main userspace
8network configuration suites by now and has to be performed manualy.
9
10.. _dsa-config-showcases:
11
12Configuration showcases
13-----------------------
14
15To configure a DSA switch a couple of commands need to be executed. In this
16documentation some common configuration scenarios are handled as showcases:
17
18*single port*
19  Every switch port acts as a different configurable Ethernet port
20
21*bridge*
22  Every switch port is part of one configurable Ethernet bridge
23
24*gateway*
25  Every switch port except one upstream port is part of a configurable
26  Ethernet bridge.
27  The upstream port acts as different configurable Ethernet port.
28
29All configurations are performed with tools from iproute2, which is available
30at https://www.kernel.org/pub/linux/utils/net/iproute2/
31
32Through DSA every port of a switch is handled like a normal linux Ethernet
33interface. The CPU port is the switch port connected to an Ethernet MAC chip.
34The corresponding linux Ethernet interface is called the master interface.
35All other corresponding linux interfaces are called slave interfaces.
36
37The slave interfaces depend on the master interface. They can only brought up,
38when the master interface is up.
39
40In this documentation the following Ethernet interfaces are used:
41
42*eth0*
43  the master interface
44
45*lan1*
46  a slave interface
47
48*lan2*
49  another slave interface
50
51*lan3*
52  a third slave interface
53
54*wan*
55  A slave interface dedicated for upstream traffic
56
57Further Ethernet interfaces can be configured similar.
58The configured IPs and networks are:
59
60*single port*
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)
64
65*bridge*
66  * br0: 192.0.2.129/25 (192.0.2.128 - 192.0.2.255)
67
68*gateway*
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)
71
72.. _dsa-tagged-configuration:
73
74Configuration with tagging support
75----------------------------------
76
77The tagging based configuration is desired and supported by the majority of
78DSA switches. These switches are capable to tag incoming and outgoing traffic
79without using a VLAN based configuration.
80
81single port
82~~~~~~~~~~~
83
84.. code-block:: sh
85
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
90
91  # The master interface needs to be brought up before the slave ports.
92  ip link set eth0 up
93
94  # bring up the slave interfaces
95  ip link set lan1 up
96  ip link set lan2 up
97  ip link set lan3 up
98
99bridge
100~~~~~~
101
102.. code-block:: sh
103
104  # The master interface needs to be brought up before the slave ports.
105  ip link set eth0 up
106
107  # bring up the slave interfaces
108  ip link set lan1 up
109  ip link set lan2 up
110  ip link set lan3 up
111
112  # create bridge
113  ip link add name br0 type bridge
114
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
119
120  # configure the bridge
121  ip addr add 192.0.2.129/25 dev br0
122
123  # bring up the bridge
124  ip link set dev br0 up
125
126gateway
127~~~~~~~
128
129.. code-block:: sh
130
131  # The master interface needs to be brought up before the slave ports.
132  ip link set eth0 up
133
134  # bring up the slave interfaces
135  ip link set wan up
136  ip link set lan1 up
137  ip link set lan2 up
138
139  # configure the upstream port
140  ip addr add 192.0.2.1/30 dev wan
141
142  # create bridge
143  ip link add name br0 type bridge
144
145  # add ports to bridge
146  ip link set dev lan1 master br0
147  ip link set dev lan2 master br0
148
149  # configure the bridge
150  ip addr add 192.0.2.129/25 dev br0
151
152  # bring up the bridge
153  ip link set dev br0 up
154
155.. _dsa-vlan-configuration:
156
157Configuration without tagging support
158-------------------------------------
159
160A 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
162configuration.
163
164single port
165~~~~~~~~~~~
166The configuration can only be set up via VLAN tagging and bridge setup.
167
168.. code-block:: sh
169
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
174
175  # The master interface needs to be brought up before the slave ports.
176  ip link set eth0 up
177  ip link set eth0.1 up
178  ip link set eth0.2 up
179  ip link set eth0.3 up
180
181  # bring up the slave interfaces
182  ip link set lan1 up
183  ip link set lan2 up
184  ip link set lan3 up
185
186  # create bridge
187  ip link add name br0 type bridge
188
189  # activate VLAN filtering
190  ip link set dev br0 type bridge vlan_filtering 1
191
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
196
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
201
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
206
207  # bring up the bridge devices
208  ip link set br0 up
209
210
211bridge
212~~~~~~
213
214.. code-block:: sh
215
216  # tag traffic on CPU port
217  ip link add link eth0 name eth0.1 type vlan id 1
218
219  # The master interface needs to be brought up before the slave ports.
220  ip link set eth0 up
221  ip link set eth0.1 up
222
223  # bring up the slave interfaces
224  ip link set lan1 up
225  ip link set lan2 up
226  ip link set lan3 up
227
228  # create bridge
229  ip link add name br0 type bridge
230
231  # activate VLAN filtering
232  ip link set dev br0 type bridge vlan_filtering 1
233
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
239
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
244
245  # configure the bridge
246  ip addr add 192.0.2.129/25 dev br0
247
248  # bring up the bridge
249  ip link set dev br0 up
250
251gateway
252~~~~~~~
253
254.. code-block:: sh
255
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
259
260  # The master interface needs to be brought up before the slave ports.
261  ip link set eth0 up
262  ip link set eth0.1 up
263  ip link set eth0.2 up
264
265  # bring up the slave interfaces
266  ip link set wan up
267  ip link set lan1 up
268  ip link set lan2 up
269
270  # create bridge
271  ip link add name br0 type bridge
272
273  # activate VLAN filtering
274  ip link set dev br0 type bridge vlan_filtering 1
275
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
281
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
286
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
290
291  # bring up the bridge devices
292  ip link set br0 up
293