ar71xx: fix switch port mapping for tl-wdr4300/3600
[openwrt/openwrt.git] / target / linux / ar71xx / base-files / etc / board.d / 02_network
1 #!/bin/sh
2 #
3 # Copyright (C) 2011-2015 OpenWrt.org
4 #
5
6 . /lib/functions/system.sh
7 . /lib/functions/uci-defaults-new.sh
8 . /lib/ar71xx.sh
9
10 board_config_update
11
12 board=$(ar71xx_board_name)
13
14
15 case "$board" in
16 all0315n |\
17 all0258n |\
18 ja76pf2|\
19 rocket-m-ti |\
20 ubnt-unifi-outdoor)
21 ucidef_set_interface_lan "eth0 eth1"
22 ;;
23
24 ap132 |\
25 wlr8100)
26 ucidef_add_switch "switch0" \
27 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
28 ;;
29
30 esr1750 |\
31 epg5000)
32 ucidef_add_switch "switch0" \
33 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
34 ;;
35
36 ap136-010 |\
37 ap147-010)
38 ucidef_set_interfaces_lan_wan "eth0" "eth1"
39 ucidef_add_switch "switch0" \
40 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth1"
41 ;;
42
43 ap136-020 |\
44 ap135-020 |\
45 tl-wr1043nd-v2 |\
46 wzr-450hp2)
47 ucidef_set_interfaces_lan_wan "eth1" "eth0"
48 ucidef_add_switch "switch0" \
49 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
50 ;;
51
52 archer-c5 |\
53 archer-c7 |\
54 tl-wdr4900-v2)
55 ucidef_set_interfaces_lan_wan "eth1" "eth0"
56 ucidef_add_switch "switch0" \
57 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
58 ;;
59
60 bsb)
61 ucidef_set_interfaces_lan_wan "eth1" "eth0"
62 ucidef_add_switch "switch0" \
63 "0@eth1" "1:lan" "3:lan" # XXX: confirm cpu port!
64 ucidef_set_interface_wlan
65 ;;
66
67 cpe510)
68 ucidef_add_switch "switch0" \
69 "0@eth0" "5:lan" "4:wan"
70 ;;
71
72 airgatewaypro)
73 ucidef_add_switch "switch0" \
74 "0@eth0" "4:lan" "5:wan"
75 ;;
76
77 db120 |\
78 rb-2011l | \
79 rb-2011uas |\
80 rb-2011uias |\
81 rb-2011uas-2hnd|\
82 rb-2011uias-2hnd)
83 case "$board" in
84 rb-2011uas* | rb-2011uias | rb-2011uias-2hnd)
85 ucidef_add_switch "switch0" \
86 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan" "6:sfp"
87 ;;
88 *)
89 ucidef_add_switch "switch0" \
90 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
91 ;;
92 esac
93
94 ucidef_add_switch "switch1" \
95 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:lan"
96 ;;
97
98 dir-825-b1|\
99 tew-673gru)
100 ucidef_set_interfaces_lan_wan "eth0" "eth1"
101 ucidef_add_switch "switch0" \
102 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
103 ;;
104
105 f9k1115v2)
106 ucidef_set_interfaces_lan_wan "eth1" "eth0"
107 ucidef_add_switch "switch0" \
108 "2:lan" "3:lan" "4:lan" "5:lan" "6@eth1" \
109 "0@eth0" "1:wan" # XXX: confirm cpu ports!
110 ;;
111
112 nbg460n_550n_550nh)
113 ucidef_set_interfaces_lan_wan "eth0" "eth1"
114 ucidef_add_switch "switch0" \
115 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
116 ;;
117
118 nbg6616 |\
119 nbg6716)
120 ucidef_set_interfaces_lan_wan "eth0" "eth1"
121 ucidef_add_switch "switch0" \
122 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" \
123 "5:wan" "6@eth1"
124 ;;
125
126 ap143 |\
127 rb-433 |\
128 rb-433u)
129 ucidef_set_interfaces_lan_wan "eth1" "eth0"
130 ucidef_add_switch "switch0" \
131 "1:lan" "2:lan" "5@eth1"
132 ;;
133
134 rb-435g)
135 ucidef_set_interfaces_lan_wan "eth1" "eth0"
136 ucidef_add_switch "switch0" \
137 "0@eth1" "1:lan" "2:lan" # XXX: confirm!
138 ;;
139
140 rb-450)
141 ucidef_set_interfaces_lan_wan "eth1" "eth0"
142 ucidef_add_switch "switch0" \
143 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth1"
144 ;;
145
146 rb-450g |\
147 routerstation-pro)
148 ucidef_set_interfaces_lan_wan "eth1" "eth0"
149 ucidef_add_switch "switch0" \
150 "0@eth1" "2:lan:3" "3:lan:2" "4:lan:1"
151 ;;
152
153 ap136 |\
154 rb-750gl |\
155 rb-751g |\
156 rb-951g-2hnd |\
157 wzr-hp-g450h)
158 ucidef_add_switch "switch0" \
159 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
160 ;;
161
162 rb-951ui-2hnd)
163 ucidef_set_interfaces_lan_wan "eth1" "eth0"
164 ;;
165
166 rb-493g)
167 ucidef_set_interfaces_lan_wan "eth0 eth1.1" "eth1.2"
168 ucidef_add_switch "switch0" \
169 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
170 ucidef_add_switch "switch1" \
171 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
172 ;;
173
174 wzr-hp-g300nh2 |\
175 pb92 |\
176 ap113)
177 ucidef_add_switch "switch0" \
178 "0@eth0" "1:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "2:wan"
179 ;;
180
181 el-m150)
182 ucidef_set_interfaces_lan_wan "eth1" "eth0"
183 ucidef_add_switch "switch0" \
184 "0:lan" "1:lan" "3@eth1" # XXX: confirm!
185 ;;
186
187 tl-wdr4300|\
188 tl-wr1041n-v2)
189 ucidef_add_switch "switch0" \
190 "0@eth0" "1:wan" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4"
191 ;;
192
193 tl-wr1043nd)
194 ucidef_add_switch "switch0" \
195 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
196 ;;
197
198 tl-wr2543n)
199 ucidef_add_switch "switch0" \
200 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
201 ;;
202
203 tl-wr841n-v1|\
204 tl-wr941nd)
205 ucidef_set_interface_raw "eth" "eth0"
206 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
207 ;;
208
209 dir-615-i1 |\
210 r6100 |\
211 smart-300 |\
212 tl-mr3420-v2 |\
213 tl-wr841n-v8 |\
214 tl-wr842n-v2 |\
215 tl-wr941nd-v5 |\
216 tl-wr941nd-v6 |\
217 tl-wdr6500-v2 |\
218 wnr2000-v3 |\
219 wnr2000-v4 |\
220 wnr2200 |\
221 wnr612-v2 |\
222 wnr1000-v2)
223 ucidef_set_interfaces_lan_wan "eth1" "eth0"
224 ucidef_add_switch "switch0" \
225 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4@eth1" # XXX: confirm!
226 ;;
227
228 uap-pro)
229 ucidef_add_switch "switch0" \
230 "0@eth0" "1:lan" "2:wan"
231 ;;
232
233 nanostation-m-xw)
234 ucidef_add_switch "switch0" \
235 "0@eth0" "5:lan" "1:wan"
236 ;;
237
238 wrt160nl)
239 ucidef_set_interfaces_lan_wan "eth0" "eth1"
240 ucidef_add_switch "switch0" \
241 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4@eth0"
242 ;;
243
244 wzr-hp-g300nh)
245 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
246 ucidef_add_switch "switch0" \
247 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
248 ;;
249
250 dgl-5500-a1 |\
251 dir-825-c1)
252 local mac
253 ucidef_add_switch "switch0" \
254 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
255 mac=$(mtd_get_mac_ascii nvram "wan_mac")
256 [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
257 ;;
258
259 mynet-n750)
260 local mac
261 ucidef_add_switch "switch0" \
262 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
263 mac=$(mtd_get_mac_ascii devdata "wanmac")
264 [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
265 ;;
266
267 onion-omega)
268 ucidef_set_interface_lan "wlan0"
269 ;;
270
271 dhp-1565-a1 |\
272 dir-835-a1 |\
273 wndr3700v4 | \
274 wndr4300)
275 ucidef_add_switch "switch0" \
276 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
277 mac_lan=$(mtd_get_mac_binary caldata 0)
278 [ -n "$mac_lan" ] && ucidef_set_interface_macaddr "lan" "$mac_lan"
279 mac_wan=$(mtd_get_mac_binary caldata 6)
280 [ -n "$mac_wan" ] && ucidef_set_interface_macaddr "wan" "$mac_wan"
281 ;;
282
283 esr900)
284 local mac
285 ucidef_add_switch "switch0" \
286 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
287 mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
288 [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
289 ;;
290
291 dlan-hotspot |\
292 dlan-pro-500-wp)
293 ucidef_set_interface_lan "eth0 eth1"
294 ;;
295
296 dlan-pro-1200-ac)
297 ucidef_set_interface_lan "eth0"
298 ucidef_add_switch "switch0"
299 ucidef_add_switch_attr "switch0" "reset" "false"
300 ucidef_add_switch_ports "switch0" \
301 "0@eth0" "2:lan" "3:lan" "4:lan"
302 ;;
303
304 all0305 |\
305 antminer-s1 |\
306 antminer-s3 |\
307 aw-nr580 |\
308 bullet-m |\
309 cap4200ag |\
310 eap300v2 |\
311 eap7660d |\
312 el-mini |\
313 loco-m-xw |\
314 mr1750 |\
315 mr600 |\
316 mr600v2 |\
317 mr900 |\
318 mr900v2 |\
319 rb-411 |\
320 rb-911g-2hpnd |\
321 rb-911g-5hpacd |\
322 rb-911g-5hpnd |\
323 rb-912uag-2hpnd |\
324 rb-912uag-5hpnd |\
325 rb-sxt2n |\
326 rb-sxt5n |\
327 rocket-m-xw |\
328 tl-mr10u |\
329 tl-mr11u |\
330 tl-mr12u |\
331 tl-mr13u |\
332 tl-mr3020 |\
333 tl-mr3040 |\
334 tl-mr3040-v2 |\
335 tl-wa701nd-v2 |\
336 tl-wa7210n-v2 |\
337 tl-wa750re |\
338 tl-wa850re |\
339 tl-wa830re-v2 |\
340 tl-wa801nd-v2 |\
341 tl-wa901nd |\
342 tl-wa901nd-v2 |\
343 tl-wa901nd-v3 |\
344 tl-wr703n |\
345 tube2h |\
346 wndap360 |\
347 mynet-rext |\
348 wp543)
349 ucidef_set_interface_lan "eth0"
350 ;;
351
352 arduino-yun | \
353 dir-505-a1)
354 ucidef_set_interface_lan "eth1"
355 ;;
356
357 alfa-ap96 |\
358 alfa-nx |\
359 ap83 |\
360 gl-ar150 |\
361 gl-domino |\
362 gl-inet |\
363 jwap003 |\
364 pb42 |\
365 pb44 |\
366 routerstation|\
367 tl-wr710n |\
368 tl-wr720n-v3|\
369 wpe72)
370 ucidef_set_interfaces_lan_wan "eth1" "eth0"
371 ;;
372
373 gl-ar300)
374 ucidef_set_interfaces_lan_wan "eth1" "eth0"
375 ucidef_add_switch "switch0" \
376 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
377 ;;
378
379 wpj344)
380 ucidef_add_switch "switch0" \
381 "0@eth0" "3:lan" "2:wan"
382 ;;
383
384 wpj531)
385 ucidef_set_interfaces_lan_wan "eth0" "eth1"
386 ;;
387
388 wpj558)
389 ucidef_add_switch "switch0" \
390 "5:lan" "1:wan" "6@eth0"
391 ;;
392
393 ap121 |\
394 ap121-mini |\
395 ap96 |\
396 airrouter |\
397 dir-600-a1 |\
398 dir-615-c1 |\
399 dir-615-e1 |\
400 dir-615-e4 |\
401 hiwifi-hc6361 |\
402 ja76pf |\
403 mc-mac1200r|\
404 minibox-v1 |\
405 mynet-n600 |\
406 oolite |\
407 qihoo-c301 |\
408 rb-750 |\
409 rb-751 |\
410 tew-632brp |\
411 tew-712br |\
412 tew-732br |\
413 tl-mr3220 |\
414 tl-mr3220-v2 |\
415 tl-mr3420 |\
416 tl-wdr3320-v2 |\
417 tl-wdr3500 |\
418 tl-wr741nd |\
419 tl-wr741nd-v4 |\
420 tl-wr841n-v7 |\
421 tl-wr841n-v9 |\
422 whr-g301n |\
423 whr-hp-g300n |\
424 whr-hp-gn |\
425 wzr-hp-ag300h)
426 ucidef_set_interfaces_lan_wan "eth0" "eth1"
427 ucidef_add_switch "switch0" \
428 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
429 ;;
430
431 wzr-hp-g450h)
432 ucidef_add_switch "switch0" \
433 "0@eth0" "2:lan:1 3:lan:2 4:lan:3 5:lan:4" "1:wan"
434 ;;
435
436 ew-dorin)
437 ucidef_add_switch "switch0" \
438 "0@eth0" "1:lan" "2:lan" "3:wan"
439 ;;
440
441 ew-dorin-router)
442 ucidef_set_interfaces_lan_wan "eth0" "eth1"
443 ucidef_add_switch "switch0" "0@eth0" "2:lan" "3:lan"
444 ;;
445
446 wndr3700)
447 ucidef_set_interfaces_lan_wan "eth0" "eth1"
448 ucidef_add_switch "switch0" \
449 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
450
451 # Blinkrate: 0=43ms; 1=84ms; 2=120ms; 3=170ms; 4=340ms; 5=670ms
452 ucidef_add_switch_attr "switch0" "blinkrate" 2
453
454 # Port 1 controls the GREEN configuration of LEDs for
455 # the switch and the section does not correspond to a real
456 # switch port.
457 #
458 # 0=LED off; 1=Collision/FDX; 2=Link/activity; 3=1000 Mb/s;
459 # 4=100 Mb/s; 5=10 Mb/s; 6=1000 Mb/s+activity; 7=100 Mb/s+activity;
460 # 8=10 Mb/s+activity; 9=10/100 Mb/s+activity; 10: Fiber;
461 # 11: Fault; 12: Link/activity(tx); 13: Link/activity(rx);
462 # 14: Link (master); 15: separate register
463 ucidef_add_switch_port_attr "switch0" 1 led 6
464
465 # Port 2 controls the ORANGE configuration of LEDs for
466 # the switch and the section does not correspond to a real
467 # switch port.
468 #
469 # See the key above for switch port 1 for the meaning of the
470 # 'led' setting below.
471 ucidef_add_switch_port_attr "switch0" 2 led 9
472
473 # Port 5 controls the configuration of the WAN LED and the
474 # section does not correspond to a real switch port.
475 #
476 # To toggle the use of green or orange LEDs for the WAN port,
477 # see the LED setting for wndr3700:green:wan in /etc/config/system.
478 #
479 # See the key above for switch port 1 for the meaning of the
480 # 'led' setting below.
481 ucidef_add_switch_port_attr "switch0" 5 led 2
482 ;;
483
484 *)
485 ucidef_set_interfaces_lan_wan "eth0" "eth1"
486 ;;
487 esac
488
489 board_config_flush
490
491 exit 0