1 .. SPDX-License-Identifier: GPL-2.0
3 ======================================================
4 Texas Instruments CPSW switchdev based ethernet driver
5 ======================================================
12 On older udev versions renaming of ethX to swXpY will not be automatically
15 In order to rename via udev::
17 ip -d link show dev sw0p1 | grep switchid
19 SUBSYSTEM=="net", ACTION=="add", ATTR{phys_switch_id}==<switchid>, \
20 ATTR{phys_port_name}!="", NAME="sw0$attr{phys_port_name}"
26 - The new (cpsw_new.c) driver is operating in dual-emac mode by default, thus
27 working as 2 individual network interfaces. Main differences from legacy CPSW
30 - optimized promiscuous mode: The P0_UNI_FLOOD (both ports) is enabled in
31 addition to ALLMULTI (current port) instead of ALE_BYPASS.
32 So, Ports in promiscuous mode will keep possibility of mcast and vlan
33 filtering, which is provides significant benefits when ports are joined
34 to the same bridge, but without enabling "switch" mode, or to different
36 - learning disabled on ports as it make not too much sense for
37 segregated ports - no forwarding in HW.
38 - enabled basic support for devlink.
43 platform/48484000.switch
45 devlink dev param show
46 platform/48484000.switch:
47 name switch_mode type driver-specific
49 cmode runtime value false
50 name ale_bypass type driver-specific
52 cmode runtime value false
54 Devlink configuration parameters
55 ================================
57 See Documentation/networking/devlink/ti-cpsw-switch.rst
59 Bridging in dual mac mode
60 =========================
62 The dual_mac mode requires two vids to be reserved for internal purposes,
63 which, by default, equal CPSW Port numbers. As result, bridge has to be
64 configured in vlan unaware mode or default_pvid has to be adjusted::
66 ip link add name br0 type bridge
67 ip link set dev br0 type bridge vlan_filtering 0
68 echo 0 > /sys/class/net/br0/bridge/default_pvid
69 ip link set dev sw0p1 master br0
70 ip link set dev sw0p2 master br0
74 ip link add name br0 type bridge
75 ip link set dev br0 type bridge vlan_filtering 0
76 echo 100 > /sys/class/net/br0/bridge/default_pvid
77 ip link set dev br0 type bridge vlan_filtering 1
78 ip link set dev sw0p1 master br0
79 ip link set dev sw0p2 master br0
84 The Switch mode can be enabled by configuring devlink driver parameter
85 "switch_mode" to 1/true::
87 devlink dev param set platform/48484000.switch \
88 name switch_mode value 1 cmode runtime
90 This can be done regardless of the state of Port's netdev devices - UP/DOWN, but
91 Port's netdev devices have to be in UP before joining to the bridge to avoid
92 overwriting of bridge configuration as CPSW switch driver copletly reloads its
93 configuration when first Port changes its state to UP.
95 When the both interfaces joined the bridge - CPSW switch driver will enable
96 marking packets with offload_fwd_mark flag unless "ale_bypass=0"
98 All configuration is implemented via switchdev API.
105 devlink dev param set platform/48484000.switch \
106 name switch_mode value 1 cmode runtime
108 ip link add name br0 type bridge
109 ip link set dev br0 type bridge ageing_time 1000
110 ip link set dev sw0p1 up
111 ip link set dev sw0p2 up
112 ip link set dev sw0p1 master br0
113 ip link set dev sw0p2 master br0
115 [*] bridge vlan add dev br0 vid 1 pvid untagged self
117 [*] if vlan_filtering=1. where default_pvid=1
119 Note. Steps [*] are mandatory.
127 ip link set dev BRDEV type bridge stp_state 1/0
134 bridge vlan add dev br0 vid 1 pvid untagged self <---- add cpu port to VLAN 1
136 Note. This step is mandatory for bridge/default_pvid.
143 bridge vlan add dev sw0p1 vid 100 pvid untagged master
144 bridge vlan add dev sw0p2 vid 100 pvid untagged master
145 bridge vlan add dev br0 vid 100 pvid untagged self <---- Add cpu port to VLAN100
149 bridge vlan add dev sw0p1 vid 100 master
150 bridge vlan add dev sw0p2 vid 100 master
151 bridge vlan add dev br0 vid 100 pvid tagged self <---- Add cpu port to VLAN100
156 FDBs are automatically added on the appropriate switch port upon detection
158 Manually adding FDBs::
160 bridge fdb add aa:bb:cc:dd:ee:ff dev sw0p1 master vlan 100
161 bridge fdb add aa:bb:cc:dd:ee:fe dev sw0p2 master <---- Add on all VLANs
166 MDBs are automatically added on the appropriate switch port upon detection
168 Manually adding MDBs::
170 bridge mdb add dev br0 port sw0p1 grp 239.1.1.1 permanent vid 100
171 bridge mdb add dev br0 port sw0p1 grp 239.1.1.1 permanent <---- Add on all VLANs
175 CPU port mcast_flooding is always on
177 Turning flooding on/off on swithch ports:
178 bridge link set dev sw0p1 mcast_flood on/off
180 Access and Trunk port
181 =====================
185 bridge vlan add dev sw0p1 vid 100 pvid untagged master
186 bridge vlan add dev sw0p2 vid 100 master
189 bridge vlan add dev br0 vid 100 self
190 ip link add link br0 name br0.100 type vlan id 100
192 Note. Setting PVID on Bridge device itself working only for
193 default VLAN (default_pvid).
198 The only way for NFS to work is by chrooting to a minimal environment when
199 switch configuration that will affect connectivity is needed.
200 Assuming you are booting NFS with eth1 interface(the script is hacky and
201 it's just there to prove NFS is doable).
207 mount -t proc none /proc
208 ifconfig br0 > /dev/null
209 if [ $? -ne 0 ]; then
210 echo "Setting up bridge"
211 ip link add name br0 type bridge
212 ip link set dev br0 type bridge ageing_time 1000
213 ip link set dev br0 type bridge vlan_filtering 1
215 ip link set eth1 down
216 ip link set eth1 name sw0p1
217 ip link set dev sw0p1 up
218 ip link set dev sw0p2 up
219 ip link set dev sw0p2 master br0
220 ip link set dev sw0p1 master br0
221 bridge vlan add dev br0 vid 1 pvid untagged self
222 ifconfig sw0p1 0.0.0.0
230 mkdir /tmp/root/bin -p
231 mkdir /tmp/root/lib -p
233 cp -r /lib/ /tmp/root/
234 cp -r /bin/ /tmp/root/
235 cp /sbin/ip /tmp/root/bin
236 cp /sbin/bridge /tmp/root/bin
237 cp /sbin/ifconfig /tmp/root/bin
238 cp /sbin/udhcpc /tmp/root/bin
239 cp /path/to/setup.sh /tmp/root/bin
240 chroot /tmp/root/ busybox sh /bin/setup.sh