Documentation: networking: dsa: demote subsections to simple emphasized words
[platform/kernel/linux-starfive.git] / Documentation / networking / dsa / configuration.rst
1 .. SPDX-License-Identifier: GPL-2.0
2
3 =======================================
4 DSA switch configuration from userspace
5 =======================================
6
7 The DSA switch configuration is not integrated into the main userspace
8 network configuration suites by now and has to be performed manualy.
9
10 .. _dsa-config-showcases:
11
12 Configuration showcases
13 -----------------------
14
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:
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
29 All configurations are performed with tools from iproute2, which is available
30 at https://www.kernel.org/pub/linux/utils/net/iproute2/
31
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.
36
37 The slave interfaces depend on the master interface. They can only brought up,
38 when the master interface is up.
39
40 In 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
57 Further Ethernet interfaces can be configured similar.
58 The 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
74 Configuration with tagging support
75 ----------------------------------
76
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.
80
81 *single port*
82   .. code-block:: sh
83
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
88
89     # The master interface needs to be brought up before the slave ports.
90     ip link set eth0 up
91
92     # bring up the slave interfaces
93     ip link set lan1 up
94     ip link set lan2 up
95     ip link set lan3 up
96
97 *bridge*
98   .. code-block:: sh
99
100     # The master interface needs to be brought up before the slave ports.
101     ip link set eth0 up
102
103     # bring up the slave interfaces
104     ip link set lan1 up
105     ip link set lan2 up
106     ip link set lan3 up
107
108     # create bridge
109     ip link add name br0 type bridge
110
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
115
116     # configure the bridge
117     ip addr add 192.0.2.129/25 dev br0
118
119     # bring up the bridge
120     ip link set dev br0 up
121
122 *gateway*
123   .. code-block:: sh
124
125     # The master interface needs to be brought up before the slave ports.
126     ip link set eth0 up
127
128     # bring up the slave interfaces
129     ip link set wan up
130     ip link set lan1 up
131     ip link set lan2 up
132
133     # configure the upstream port
134     ip addr add 192.0.2.1/30 dev wan
135
136     # create bridge
137     ip link add name br0 type bridge
138
139     # add ports to bridge
140     ip link set dev lan1 master br0
141     ip link set dev lan2 master br0
142
143     # configure the bridge
144     ip addr add 192.0.2.129/25 dev br0
145
146     # bring up the bridge
147     ip link set dev br0 up
148
149 .. _dsa-vlan-configuration:
150
151 Configuration without tagging support
152 -------------------------------------
153
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
156 configuration.
157
158 *single port*
159   The configuration can only be set up via VLAN tagging and bridge setup.
160
161   .. code-block:: sh
162
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
167
168     # The master interface needs to be brought up before the slave ports.
169     ip link set eth0 up
170     ip link set eth0.1 up
171     ip link set eth0.2 up
172     ip link set eth0.3 up
173
174     # bring up the slave interfaces
175     ip link set lan1 up
176     ip link set lan2 up
177     ip link set lan3 up
178
179     # create bridge
180     ip link add name br0 type bridge
181
182     # activate VLAN filtering
183     ip link set dev br0 type bridge vlan_filtering 1
184
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
189
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
194
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
199
200     # bring up the bridge devices
201     ip link set br0 up
202
203
204 *bridge*
205   .. code-block:: sh
206
207     # tag traffic on CPU port
208     ip link add link eth0 name eth0.1 type vlan id 1
209
210     # The master interface needs to be brought up before the slave ports.
211     ip link set eth0 up
212     ip link set eth0.1 up
213
214     # bring up the slave interfaces
215     ip link set lan1 up
216     ip link set lan2 up
217     ip link set lan3 up
218
219     # create bridge
220     ip link add name br0 type bridge
221
222     # activate VLAN filtering
223     ip link set dev br0 type bridge vlan_filtering 1
224
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
230
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
235
236     # configure the bridge
237     ip addr add 192.0.2.129/25 dev br0
238
239     # bring up the bridge
240     ip link set dev br0 up
241
242 *gateway*
243   .. code-block:: sh
244
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
248
249     # The master interface needs to be brought up before the slave ports.
250     ip link set eth0 up
251     ip link set eth0.1 up
252     ip link set eth0.2 up
253
254     # bring up the slave interfaces
255     ip link set wan up
256     ip link set lan1 up
257     ip link set lan2 up
258
259     # create bridge
260     ip link add name br0 type bridge
261
262     # activate VLAN filtering
263     ip link set dev br0 type bridge vlan_filtering 1
264
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
270
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
275
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
279
280     # bring up the bridge devices
281     ip link set br0 up