Merge branch 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / Documentation / networking / device_drivers / ti / cpsw_switchdev.txt
1 * Texas Instruments CPSW switchdev based ethernet driver 2.0
2
3 - Port renaming
4 On older udev versions renaming of ethX to swXpY will not be automatically
5 supported
6 In order to rename via udev:
7 ip -d link show dev sw0p1 | grep switchid
8
9 SUBSYSTEM=="net", ACTION=="add", ATTR{phys_switch_id}==<switchid>, \
10         ATTR{phys_port_name}!="", NAME="sw0$attr{phys_port_name}"
11
12
13 ====================
14 # Dual mac mode
15 ====================
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
18 driver are:
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.
27
28         devlink dev show
29                 platform/48484000.switch
30
31         devlink dev param show
32         platform/48484000.switch:
33         name switch_mode type driver-specific
34         values:
35                 cmode runtime value false
36         name ale_bypass type driver-specific
37         values:
38                 cmode runtime value false
39
40 Devlink configuration parameters
41 ====================
42 See Documentation/networking/devlink-params-ti-cpsw-switch.txt
43
44 ====================
45 # Bridging in dual mac mode
46 ====================
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.
50
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
56  - or -
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
63
64 ====================
65 # Enabling "switch"
66 ====================
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
71
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.
76
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"
79
80 All configuration is implemented via switchdev API.
81
82 ====================
83 # Bridge setup
84 ====================
85         devlink dev param set platform/48484000.switch \
86         name switch_mode value 1 cmode runtime
87
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
95
96 [*] if vlan_filtering=1. where default_pvid=1
97
98 =================
99 # On/off STP
100 =================
101 ip link set dev BRDEV type bridge stp_state 1/0
102
103 Note. Steps [*] are mandatory.
104
105 ====================
106 # VLAN configuration
107 ====================
108 bridge vlan add dev br0 vid 1 pvid untagged self <---- add cpu port to VLAN 1
109
110 Note. This step is mandatory for bridge/default_pvid.
111
112 =================
113 # Add extra VLANs
114 =================
115  1. untagged:
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
119
120  2. tagged:
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
124
125 ====
126 FDBs
127 ====
128 FDBs are automatically added on the appropriate switch port upon detection
129
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
133
134 ====
135 MDBs
136 ====
137 MDBs are automatically added on the appropriate switch port upon detection
138
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
142
143 ==================
144 Multicast flooding
145 ==================
146 CPU port mcast_flooding is always on
147
148 Turning flooding on/off on swithch ports:
149 bridge link set dev sw0p1 mcast_flood on/off
150
151 ==================
152 Access and Trunk port
153 ==================
154  bridge vlan add dev sw0p1 vid 100 pvid untagged master
155  bridge vlan add dev sw0p2 vid 100 master
156
157
158  bridge vlan add dev br0 vid 100 self
159  ip link add link br0 name br0.100 type vlan id 100
160
161  Note. Setting PVID on Bridge device itself working only for
162  default VLAN (default_pvid).
163
164 =====================
165  NFS
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).
171
172 setup.sh:
173 #!/bin/sh
174 mkdir proc
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
182
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
191         udhchc -i br0
192 fi
193 umount /proc
194
195 run_nfs.sh:
196 #!/bin/sh
197 mkdir /tmp/root/bin -p
198 mkdir /tmp/root/lib -p
199
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
208
209 run ./run_nfs.sh