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