~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/networking/device_drivers/ethernet/ti/cpsw_switchdev.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 .. SPDX-License-Identifier: GPL-2.0
  2 
  3 ======================================================
  4 Texas Instruments CPSW switchdev based ethernet driver
  5 ======================================================
  6 
  7 :Version: 2.0
  8 
  9 Port renaming
 10 =============
 11 
 12 On older udev versions renaming of ethX to swXpY will not be automatically
 13 supported
 14 
 15 In order to rename via udev::
 16 
 17     ip -d link show dev sw0p1 | grep switchid
 18 
 19     SUBSYSTEM=="net", ACTION=="add", ATTR{phys_switch_id}==<switchid>, \
 20             ATTR{phys_port_name}!="", NAME="sw0$attr{phys_port_name}"
 21 
 22 
 23 Dual mac mode
 24 =============
 25 
 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
 28   driver are:
 29 
 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
 35    bridges.
 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.
 39 
 40    ::
 41 
 42         devlink dev show
 43                 platform/48484000.switch
 44 
 45         devlink dev param show
 46         platform/48484000.switch:
 47         name switch_mode type driver-specific
 48         values:
 49                 cmode runtime value false
 50         name ale_bypass type driver-specific
 51         values:
 52                 cmode runtime value false
 53 
 54 Devlink configuration parameters
 55 ================================
 56 
 57 See Documentation/networking/devlink/ti-cpsw-switch.rst
 58 
 59 Bridging in dual mac mode
 60 =========================
 61 
 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::
 65 
 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
 71 
 72 or::
 73 
 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
 80 
 81 Enabling "switch"
 82 =================
 83 
 84 The Switch mode can be enabled by configuring devlink driver parameter
 85 "switch_mode" to 1/true::
 86 
 87         devlink dev param set platform/48484000.switch \
 88         name switch_mode value 1 cmode runtime
 89 
 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.
 94 
 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"
 97 
 98 All configuration is implemented via switchdev API.
 99 
100 Bridge setup
101 ============
102 
103 ::
104 
105         devlink dev param set platform/48484000.switch \
106         name switch_mode value 1 cmode runtime
107 
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
114 
115         [*] bridge vlan add dev br0 vid 1 pvid untagged self
116 
117         [*] if vlan_filtering=1. where default_pvid=1
118 
119         Note. Steps [*] are mandatory.
120 
121 
122 On/off STP
123 ==========
124 
125 ::
126 
127         ip link set dev BRDEV type bridge stp_state 1/0
128 
129 VLAN configuration
130 ==================
131 
132 ::
133 
134   bridge vlan add dev br0 vid 1 pvid untagged self <---- add cpu port to VLAN 1
135 
136 Note. This step is mandatory for bridge/default_pvid.
137 
138 Add extra VLANs
139 ===============
140 
141  1. untagged::
142 
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
146 
147  2. tagged::
148 
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
152 
153 FDBs
154 ----
155 
156 FDBs are automatically added on the appropriate switch port upon detection
157 
158 Manually adding FDBs::
159 
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
162 
163 MDBs
164 ----
165 
166 MDBs are automatically added on the appropriate switch port upon detection
167 
168 Manually adding MDBs::
169 
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
172 
173 Multicast flooding
174 ==================
175 CPU port mcast_flooding is always on
176 
177 Turning flooding on/off on switch ports:
178 bridge link set dev sw0p1 mcast_flood on/off
179 
180 Access and Trunk port
181 =====================
182 
183 ::
184 
185  bridge vlan add dev sw0p1 vid 100 pvid untagged master
186  bridge vlan add dev sw0p2 vid 100 master
187 
188 
189  bridge vlan add dev br0 vid 100 self
190  ip link add link br0 name br0.100 type vlan id 100
191 
192 Note. Setting PVID on Bridge device itself working only for
193 default VLAN (default_pvid).
194 
195 NFS
196 ===
197 
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).
202 
203 setup.sh::
204 
205         #!/bin/sh
206         mkdir proc
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
214 
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
223                 udhchc -i br0
224         fi
225         umount /proc
226 
227 run_nfs.sh:::
228 
229         #!/bin/sh
230         mkdir /tmp/root/bin -p
231         mkdir /tmp/root/lib -p
232 
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
241 
242         run ./run_nfs.sh

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php