@@ -66,34 +66,193 @@ reprogrammed with the updated static configuration.
6666Traffic support
6767===============
6868
69- The switches do not support switch tagging in hardware. But they do support
70- customizing the TPID by which VLAN traffic is identified as such. The switch
71- driver is leveraging ``CONFIG_NET_DSA_TAG_8021Q `` by requesting that special
72- VLANs (with a custom TPID of ``ETH_P_EDSA `` instead of ``ETH_P_8021Q ``) are
73- installed on its ports when not in ``vlan_filtering `` mode. This does not
74- interfere with the reception and transmission of real 802.1Q-tagged traffic,
75- because the switch does no longer parse those packets as VLAN after the TPID
76- change.
77- The TPID is restored when ``vlan_filtering `` is requested by the user through
78- the bridge layer, and general IP termination becomes no longer possible through
79- the switch netdevices in this mode.
80-
81- The switches have two programmable filters for link-local destination MACs.
69+ The switches do not have hardware support for DSA tags, except for "slow
70+ protocols" for switch control as STP and PTP. For these, the switches have two
71+ programmable filters for link-local destination MACs.
8272These are used to trap BPDUs and PTP traffic to the master netdevice, and are
8373further used to support STP and 1588 ordinary clock/boundary clock
84- functionality.
85-
86- The following traffic modes are supported over the switch netdevices:
87-
88- +--------------------+------------+------------------+------------------+
89- | | Standalone | Bridged with | Bridged with |
90- | | ports | vlan_filtering 0 | vlan_filtering 1 |
91- +====================+============+==================+==================+
92- | Regular traffic | Yes | Yes | No (use master) |
93- +--------------------+------------+------------------+------------------+
94- | Management traffic | Yes | Yes | Yes |
95- | (BPDU, PTP) | | | |
96- +--------------------+------------+------------------+------------------+
74+ functionality. For frames trapped to the CPU, source port and switch ID
75+ information is encoded by the hardware into the frames.
76+
77+ But by leveraging ``CONFIG_NET_DSA_TAG_8021Q `` (a software-defined DSA tagging
78+ format based on VLANs), general-purpose traffic termination through the network
79+ stack can be supported under certain circumstances.
80+
81+ Depending on VLAN awareness state, the following operating modes are possible
82+ with the switch:
83+
84+ - Mode 1 (VLAN-unaware): a port is in this mode when it is used as a standalone
85+ net device, or when it is enslaved to a bridge with ``vlan_filtering=0 ``.
86+ - Mode 2 (fully VLAN-aware): a port is in this mode when it is enslaved to a
87+ bridge with ``vlan_filtering=1 ``. Access to the entire VLAN range is given to
88+ the user through ``bridge vlan `` commands, but general-purpose (anything
89+ other than STP, PTP etc) traffic termination is not possible through the
90+ switch net devices. The other packets can be still by user space processed
91+ through the DSA master interface (similar to ``DSA_TAG_PROTO_NONE ``).
92+ - Mode 3 (best-effort VLAN-aware): a port is in this mode when enslaved to a
93+ bridge with ``vlan_filtering=1 ``, and the devlink property of its parent
94+ switch named ``best_effort_vlan_filtering `` is set to ``true ``. When
95+ configured like this, the range of usable VIDs is reduced (0 to 1023 and 3072
96+ to 4094), so is the number of usable VIDs (maximum of 7 non-pvid VLANs per
97+ port*), and shared VLAN learning is performed (FDB lookup is done only by
98+ DMAC, not also by VID).
99+
100+ To summarize, in each mode, the following types of traffic are supported over
101+ the switch net devices:
102+
103+ +-------------+-----------+--------------+------------+
104+ | | Mode 1 | Mode 2 | Mode 3 |
105+ +=============+===========+==============+============+
106+ | Regular | Yes | No | Yes |
107+ | traffic | | (use master) | |
108+ +-------------+-----------+--------------+------------+
109+ | Management | Yes | Yes | Yes |
110+ | traffic | | | |
111+ | (BPDU, PTP) | | | |
112+ +-------------+-----------+--------------+------------+
113+
114+ To configure the switch to operate in Mode 3, the following steps can be
115+ followed::
116+
117+ ip link add dev br0 type bridge
118+ # swp2 operates in Mode 1 now
119+ ip link set dev swp2 master br0
120+ # swp2 temporarily moves to Mode 2
121+ ip link set dev br0 type bridge vlan_filtering 1
122+ [ 61.204770] sja1105 spi0.1: Reset switch and programmed static config. Reason: VLAN filtering
123+ [ 61.239944] sja1105 spi0.1: Disabled switch tagging
124+ # swp3 now operates in Mode 3
125+ devlink dev param set spi/spi0.1 name best_effort_vlan_filtering value true cmode runtime
126+ [ 64.682927] sja1105 spi0.1: Reset switch and programmed static config. Reason: VLAN filtering
127+ [ 64.711925] sja1105 spi0.1: Enabled switch tagging
128+ # Cannot use VLANs in range 1024-3071 while in Mode 3.
129+ bridge vlan add dev swp2 vid 1025 untagged pvid
130+ RTNETLINK answers: Operation not permitted
131+ bridge vlan add dev swp2 vid 100
132+ bridge vlan add dev swp2 vid 101 untagged
133+ bridge vlan
134+ port vlan ids
135+ swp5 1 PVID Egress Untagged
136+
137+ swp2 1 PVID Egress Untagged
138+ 100
139+ 101 Egress Untagged
140+
141+ swp3 1 PVID Egress Untagged
142+
143+ swp4 1 PVID Egress Untagged
144+
145+ br0 1 PVID Egress Untagged
146+ bridge vlan add dev swp2 vid 102
147+ bridge vlan add dev swp2 vid 103
148+ bridge vlan add dev swp2 vid 104
149+ bridge vlan add dev swp2 vid 105
150+ bridge vlan add dev swp2 vid 106
151+ bridge vlan add dev swp2 vid 107
152+ # Cannot use mode than 7 VLANs per port while in Mode 3.
153+ [ 3885.216832] sja1105 spi0.1: No more free subvlans
154+
155+ \* "maximum of 7 non-pvid VLANs per port": Decoding VLAN-tagged packets on the
156+ CPU in mode 3 is possible through VLAN retagging of packets that go from the
157+ switch to the CPU. In cross-chip topologies, the port that goes to the CPU
158+ might also go to other switches. In that case, those other switches will see
159+ only a retagged packet (which only has meaning for the CPU). So if they are
160+ interested in this VLAN, they need to apply retagging in the reverse direction,
161+ to recover the original value from it. This consumes extra hardware resources
162+ for this switch. There is a maximum of 32 entries in the Retagging Table of
163+ each switch device.
164+
165+ As an example, consider this cross-chip topology::
166+
167+ +-------------------------------------------------+
168+ | Host SoC |
169+ | +-------------------------+ |
170+ | | DSA master for embedded | |
171+ | | switch (non-sja1105) | |
172+ | +--------+-------------------------+--------+ |
173+ | | embedded L2 switch | |
174+ | | | |
175+ | | +--------------+ +--------------+ | |
176+ | | |DSA master for| |DSA master for| | |
177+ | | | SJA1105 1 | | SJA1105 2 | | |
178+ +--+---+--------------+-----+--------------+---+--+
179+
180+ +-----------------------+ +-----------------------+
181+ | SJA1105 switch 1 | | SJA1105 switch 2 |
182+ +-----+-----+-----+-----+ +-----+-----+-----+-----+
183+ |sw1p0|sw1p1|sw1p2|sw1p3| |sw2p0|sw2p1|sw2p2|sw2p3|
184+ +-----+-----+-----+-----+ +-----+-----+-----+-----+
185+
186+ To reach the CPU, SJA1105 switch 1 (spi/spi2.1) uses the same port as is uses
187+ to reach SJA1105 switch 2 (spi/spi2.2), which would be port 4 (not drawn).
188+ Similarly for SJA1105 switch 2.
189+
190+ Also consider the following commands, that add VLAN 100 to every sja1105 user
191+ port::
192+
193+ devlink dev param set spi/spi2.1 name best_effort_vlan_filtering value true cmode runtime
194+ devlink dev param set spi/spi2.2 name best_effort_vlan_filtering value true cmode runtime
195+ ip link add dev br0 type bridge
196+ for port in sw1p0 sw1p1 sw1p2 sw1p3 \
197+ sw2p0 sw2p1 sw2p2 sw2p3; do
198+ ip link set dev $port master br0
199+ done
200+ ip link set dev br0 type bridge vlan_filtering 1
201+ for port in sw1p0 sw1p1 sw1p2 sw1p3 \
202+ sw2p0 sw2p1 sw2p2; do
203+ bridge vlan add dev $port vid 100
204+ done
205+ ip link add link br0 name br0.100 type vlan id 100 && ip link set dev br0.100 up
206+ ip addr add 192.168.100.3/24 dev br0.100
207+ bridge vlan add dev br0 vid 100 self
208+
209+ bridge vlan
210+ port vlan ids
211+ sw1p0 1 PVID Egress Untagged
212+ 100
213+
214+ sw1p1 1 PVID Egress Untagged
215+ 100
216+
217+ sw1p2 1 PVID Egress Untagged
218+ 100
219+
220+ sw1p3 1 PVID Egress Untagged
221+ 100
222+
223+ sw2p0 1 PVID Egress Untagged
224+ 100
225+
226+ sw2p1 1 PVID Egress Untagged
227+ 100
228+
229+ sw2p2 1 PVID Egress Untagged
230+ 100
231+
232+ sw2p3 1 PVID Egress Untagged
233+
234+ br0 1 PVID Egress Untagged
235+ 100
236+
237+ SJA1105 switch 1 consumes 1 retagging entry for each VLAN on each user port
238+ towards the CPU. It also consumes 1 retagging entry for each non-pvid VLAN that
239+ it is also interested in, which is configured on any port of any neighbor
240+ switch.
241+
242+ In this case, SJA1105 switch 1 consumes a total of 11 retagging entries, as
243+ follows:
244+ - 8 retagging entries for VLANs 1 and 100 installed on its user ports
245+ (``sw1p0 `` - ``sw1p3 ``)
246+ - 3 retagging entries for VLAN 100 installed on the user ports of SJA1105
247+ switch 2 (``sw2p0 `` - ``sw2p2 ``), because it also has ports that are
248+ interested in it. The VLAN 1 is a pvid on SJA1105 switch 2 and does not need
249+ reverse retagging.
250+
251+ SJA1105 switch 2 also consumes 11 retagging entries, but organized as follows:
252+ - 7 retagging entries for the bridge VLANs on its user ports (``sw2p0 `` -
253+ ``sw2p3 ``).
254+ - 4 retagging entries for VLAN 100 installed on the user ports of SJA1105
255+ switch 1 (``sw1p0 `` - ``sw1p3 ``).
97256
98257Switching features
99258==================
0 commit comments