0001 .. SPDX-License-Identifier: GPL-2.0
0002
0003 ======================================================
0004 Texas Instruments CPSW switchdev based ethernet driver
0005 ======================================================
0006
0007 :Version: 2.0
0008
0009 Port renaming
0010 =============
0011
0012 On older udev versions renaming of ethX to swXpY will not be automatically
0013 supported
0014
0015 In order to rename via udev::
0016
0017 ip -d link show dev sw0p1 | grep switchid
0018
0019 SUBSYSTEM=="net", ACTION=="add", ATTR{phys_switch_id}==<switchid>, \
0020 ATTR{phys_port_name}!="", NAME="sw0$attr{phys_port_name}"
0021
0022
0023 Dual mac mode
0024 =============
0025
0026 - The new (cpsw_new.c) driver is operating in dual-emac mode by default, thus
0027 working as 2 individual network interfaces. Main differences from legacy CPSW
0028 driver are:
0029
0030 - optimized promiscuous mode: The P0_UNI_FLOOD (both ports) is enabled in
0031 addition to ALLMULTI (current port) instead of ALE_BYPASS.
0032 So, Ports in promiscuous mode will keep possibility of mcast and vlan
0033 filtering, which is provides significant benefits when ports are joined
0034 to the same bridge, but without enabling "switch" mode, or to different
0035 bridges.
0036 - learning disabled on ports as it make not too much sense for
0037 segregated ports - no forwarding in HW.
0038 - enabled basic support for devlink.
0039
0040 ::
0041
0042 devlink dev show
0043 platform/48484000.switch
0044
0045 devlink dev param show
0046 platform/48484000.switch:
0047 name switch_mode type driver-specific
0048 values:
0049 cmode runtime value false
0050 name ale_bypass type driver-specific
0051 values:
0052 cmode runtime value false
0053
0054 Devlink configuration parameters
0055 ================================
0056
0057 See Documentation/networking/devlink/ti-cpsw-switch.rst
0058
0059 Bridging in dual mac mode
0060 =========================
0061
0062 The dual_mac mode requires two vids to be reserved for internal purposes,
0063 which, by default, equal CPSW Port numbers. As result, bridge has to be
0064 configured in vlan unaware mode or default_pvid has to be adjusted::
0065
0066 ip link add name br0 type bridge
0067 ip link set dev br0 type bridge vlan_filtering 0
0068 echo 0 > /sys/class/net/br0/bridge/default_pvid
0069 ip link set dev sw0p1 master br0
0070 ip link set dev sw0p2 master br0
0071
0072 or::
0073
0074 ip link add name br0 type bridge
0075 ip link set dev br0 type bridge vlan_filtering 0
0076 echo 100 > /sys/class/net/br0/bridge/default_pvid
0077 ip link set dev br0 type bridge vlan_filtering 1
0078 ip link set dev sw0p1 master br0
0079 ip link set dev sw0p2 master br0
0080
0081 Enabling "switch"
0082 =================
0083
0084 The Switch mode can be enabled by configuring devlink driver parameter
0085 "switch_mode" to 1/true::
0086
0087 devlink dev param set platform/48484000.switch \
0088 name switch_mode value 1 cmode runtime
0089
0090 This can be done regardless of the state of Port's netdev devices - UP/DOWN, but
0091 Port's netdev devices have to be in UP before joining to the bridge to avoid
0092 overwriting of bridge configuration as CPSW switch driver copletly reloads its
0093 configuration when first Port changes its state to UP.
0094
0095 When the both interfaces joined the bridge - CPSW switch driver will enable
0096 marking packets with offload_fwd_mark flag unless "ale_bypass=0"
0097
0098 All configuration is implemented via switchdev API.
0099
0100 Bridge setup
0101 ============
0102
0103 ::
0104
0105 devlink dev param set platform/48484000.switch \
0106 name switch_mode value 1 cmode runtime
0107
0108 ip link add name br0 type bridge
0109 ip link set dev br0 type bridge ageing_time 1000
0110 ip link set dev sw0p1 up
0111 ip link set dev sw0p2 up
0112 ip link set dev sw0p1 master br0
0113 ip link set dev sw0p2 master br0
0114
0115 [*] bridge vlan add dev br0 vid 1 pvid untagged self
0116
0117 [*] if vlan_filtering=1. where default_pvid=1
0118
0119 Note. Steps [*] are mandatory.
0120
0121
0122 On/off STP
0123 ==========
0124
0125 ::
0126
0127 ip link set dev BRDEV type bridge stp_state 1/0
0128
0129 VLAN configuration
0130 ==================
0131
0132 ::
0133
0134 bridge vlan add dev br0 vid 1 pvid untagged self <---- add cpu port to VLAN 1
0135
0136 Note. This step is mandatory for bridge/default_pvid.
0137
0138 Add extra VLANs
0139 ===============
0140
0141 1. untagged::
0142
0143 bridge vlan add dev sw0p1 vid 100 pvid untagged master
0144 bridge vlan add dev sw0p2 vid 100 pvid untagged master
0145 bridge vlan add dev br0 vid 100 pvid untagged self <---- Add cpu port to VLAN100
0146
0147 2. tagged::
0148
0149 bridge vlan add dev sw0p1 vid 100 master
0150 bridge vlan add dev sw0p2 vid 100 master
0151 bridge vlan add dev br0 vid 100 pvid tagged self <---- Add cpu port to VLAN100
0152
0153 FDBs
0154 ----
0155
0156 FDBs are automatically added on the appropriate switch port upon detection
0157
0158 Manually adding FDBs::
0159
0160 bridge fdb add aa:bb:cc:dd:ee:ff dev sw0p1 master vlan 100
0161 bridge fdb add aa:bb:cc:dd:ee:fe dev sw0p2 master <---- Add on all VLANs
0162
0163 MDBs
0164 ----
0165
0166 MDBs are automatically added on the appropriate switch port upon detection
0167
0168 Manually adding MDBs::
0169
0170 bridge mdb add dev br0 port sw0p1 grp 239.1.1.1 permanent vid 100
0171 bridge mdb add dev br0 port sw0p1 grp 239.1.1.1 permanent <---- Add on all VLANs
0172
0173 Multicast flooding
0174 ==================
0175 CPU port mcast_flooding is always on
0176
0177 Turning flooding on/off on swithch ports:
0178 bridge link set dev sw0p1 mcast_flood on/off
0179
0180 Access and Trunk port
0181 =====================
0182
0183 ::
0184
0185 bridge vlan add dev sw0p1 vid 100 pvid untagged master
0186 bridge vlan add dev sw0p2 vid 100 master
0187
0188
0189 bridge vlan add dev br0 vid 100 self
0190 ip link add link br0 name br0.100 type vlan id 100
0191
0192 Note. Setting PVID on Bridge device itself working only for
0193 default VLAN (default_pvid).
0194
0195 NFS
0196 ===
0197
0198 The only way for NFS to work is by chrooting to a minimal environment when
0199 switch configuration that will affect connectivity is needed.
0200 Assuming you are booting NFS with eth1 interface(the script is hacky and
0201 it's just there to prove NFS is doable).
0202
0203 setup.sh::
0204
0205 #!/bin/sh
0206 mkdir proc
0207 mount -t proc none /proc
0208 ifconfig br0 > /dev/null
0209 if [ $? -ne 0 ]; then
0210 echo "Setting up bridge"
0211 ip link add name br0 type bridge
0212 ip link set dev br0 type bridge ageing_time 1000
0213 ip link set dev br0 type bridge vlan_filtering 1
0214
0215 ip link set eth1 down
0216 ip link set eth1 name sw0p1
0217 ip link set dev sw0p1 up
0218 ip link set dev sw0p2 up
0219 ip link set dev sw0p2 master br0
0220 ip link set dev sw0p1 master br0
0221 bridge vlan add dev br0 vid 1 pvid untagged self
0222 ifconfig sw0p1 0.0.0.0
0223 udhchc -i br0
0224 fi
0225 umount /proc
0226
0227 run_nfs.sh:::
0228
0229 #!/bin/sh
0230 mkdir /tmp/root/bin -p
0231 mkdir /tmp/root/lib -p
0232
0233 cp -r /lib/ /tmp/root/
0234 cp -r /bin/ /tmp/root/
0235 cp /sbin/ip /tmp/root/bin
0236 cp /sbin/bridge /tmp/root/bin
0237 cp /sbin/ifconfig /tmp/root/bin
0238 cp /sbin/udhcpc /tmp/root/bin
0239 cp /path/to/setup.sh /tmp/root/bin
0240 chroot /tmp/root/ busybox sh /bin/setup.sh
0241
0242 run ./run_nfs.sh