1 * Texas Instruments CPSW switchdev based ethernet driver 2.0
4 On older udev versions renaming of ethX to swXpY will not be automatically
6 In order to rename via udev:
7 ip -d link show dev sw0p1 | grep switchid
9 SUBSYSTEM=="net", ACTION=="add", ATTR{phys_switch_id}==<switchid>, \
10 ATTR{phys_port_name}!="", NAME="sw0$attr{phys_port_name}"
16 - The new (cpsw_new.c) driver is operating in dual-emac mode by default, thus
17 working as 2 individual network interfaces. Main differences from legacy CPSW
19 - optimized promiscuous mode: The P0_UNI_FLOOD (both ports) is enabled in
20 addition to ALLMULTI (current port) instead of ALE_BYPASS.
21 So, Ports in promiscuous mode will keep possibility of mcast and vlan filtering,
22 which is provides significant benefits when ports are joined to the same bridge,
23 but without enabling "switch" mode, or to different bridges.
24 - learning disabled on ports as it make not too much sense for
25 segregated ports - no forwarding in HW.
26 - enabled basic support for devlink.
29 platform/48484000.switch
31 devlink dev param show
32 platform/48484000.switch:
33 name switch_mode type driver-specific
35 cmode runtime value false
36 name ale_bypass type driver-specific
38 cmode runtime value false
40 Devlink configuration parameters
42 See Documentation/networking/devlink-params-ti-cpsw-switch.txt
45 # Bridging in dual mac mode
47 The dual_mac mode requires two vids to be reserved for internal purposes,
48 which, by default, equal CPSW Port numbers. As result, bridge has to be
49 configured in vlan unaware mode or default_pvid has to be adjusted.
51 ip link add name br0 type bridge
52 ip link set dev br0 type bridge vlan_filtering 0
53 echo 0 > /sys/class/net/br0/bridge/default_pvid
54 ip link set dev sw0p1 master br0
55 ip link set dev sw0p2 master br0
57 ip link add name br0 type bridge
58 ip link set dev br0 type bridge vlan_filtering 0
59 echo 100 > /sys/class/net/br0/bridge/default_pvid
60 ip link set dev br0 type bridge vlan_filtering 1
61 ip link set dev sw0p1 master br0
62 ip link set dev sw0p2 master br0
67 The Switch mode can be enabled by configuring devlink driver parameter
68 "switch_mode" to 1/true:
69 devlink dev param set platform/48484000.switch \
70 name switch_mode value 1 cmode runtime
72 This can be done regardless of the state of Port's netdev devices - UP/DOWN, but
73 Port's netdev devices have to be in UP before joining to the bridge to avoid
74 overwriting of bridge configuration as CPSW switch driver copletly reloads its
75 configuration when first Port changes its state to UP.
77 When the both interfaces joined the bridge - CPSW switch driver will enable
78 marking packets with offload_fwd_mark flag unless "ale_bypass=0"
80 All configuration is implemented via switchdev API.
85 devlink dev param set platform/48484000.switch \
86 name switch_mode value 1 cmode runtime
88 ip link add name br0 type bridge
89 ip link set dev br0 type bridge ageing_time 1000
90 ip link set dev sw0p1 up
91 ip link set dev sw0p2 up
92 ip link set dev sw0p1 master br0
93 ip link set dev sw0p2 master br0
94 [*] bridge vlan add dev br0 vid 1 pvid untagged self
96 [*] if vlan_filtering=1. where default_pvid=1
101 ip link set dev BRDEV type bridge stp_state 1/0
103 Note. Steps [*] are mandatory.
108 bridge vlan add dev br0 vid 1 pvid untagged self <---- add cpu port to VLAN 1
110 Note. This step is mandatory for bridge/default_pvid.
116 bridge vlan add dev sw0p1 vid 100 pvid untagged master
117 bridge vlan add dev sw0p2 vid 100 pvid untagged master
118 bridge vlan add dev br0 vid 100 pvid untagged self <---- Add cpu port to VLAN100
121 bridge vlan add dev sw0p1 vid 100 master
122 bridge vlan add dev sw0p2 vid 100 master
123 bridge vlan add dev br0 vid 100 pvid tagged self <---- Add cpu port to VLAN100
128 FDBs are automatically added on the appropriate switch port upon detection
130 Manually adding FDBs:
131 bridge fdb add aa:bb:cc:dd:ee:ff dev sw0p1 master vlan 100
132 bridge fdb add aa:bb:cc:dd:ee:fe dev sw0p2 master <---- Add on all VLANs
137 MDBs are automatically added on the appropriate switch port upon detection
139 Manually adding MDBs:
140 bridge mdb add dev br0 port sw0p1 grp 239.1.1.1 permanent vid 100
141 bridge mdb add dev br0 port sw0p1 grp 239.1.1.1 permanent <---- Add on all VLANs
146 CPU port mcast_flooding is always on
148 Turning flooding on/off on swithch ports:
149 bridge link set dev sw0p1 mcast_flood on/off
152 Access and Trunk port
154 bridge vlan add dev sw0p1 vid 100 pvid untagged master
155 bridge vlan add dev sw0p2 vid 100 master
158 bridge vlan add dev br0 vid 100 self
159 ip link add link br0 name br0.100 type vlan id 100
161 Note. Setting PVID on Bridge device itself working only for
162 default VLAN (default_pvid).
164 =====================
166 =====================
167 The only way for NFS to work is by chrooting to a minimal environment when
168 switch configuration that will affect connectivity is needed.
169 Assuming you are booting NFS with eth1 interface(the script is hacky and
170 it's just there to prove NFS is doable).
175 mount -t proc none /proc
176 ifconfig br0 > /dev/null
177 if [ $? -ne 0 ]; then
178 echo "Setting up bridge"
179 ip link add name br0 type bridge
180 ip link set dev br0 type bridge ageing_time 1000
181 ip link set dev br0 type bridge vlan_filtering 1
183 ip link set eth1 down
184 ip link set eth1 name sw0p1
185 ip link set dev sw0p1 up
186 ip link set dev sw0p2 up
187 ip link set dev sw0p2 master br0
188 ip link set dev sw0p1 master br0
189 bridge vlan add dev br0 vid 1 pvid untagged self
190 ifconfig sw0p1 0.0.0.0
197 mkdir /tmp/root/bin -p
198 mkdir /tmp/root/lib -p
200 cp -r /lib/ /tmp/root/
201 cp -r /bin/ /tmp/root/
202 cp /sbin/ip /tmp/root/bin
203 cp /sbin/bridge /tmp/root/bin
204 cp /sbin/ifconfig /tmp/root/bin
205 cp /sbin/udhcpc /tmp/root/bin
206 cp /path/to/setup.sh /tmp/root/bin
207 chroot /tmp/root/ busybox sh /bin/setup.sh