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