d8039fdf6cfd6ecf4ee5642a89ac758a1bdfe7a2
[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.sh
8
9 ar71xx_setup_interfaces()
10 {
11 local board="$1"
12
13 case "$board" in
14 airgatewaypro)
15 ucidef_add_switch "switch0" \
16 "0@eth0" "4:lan" "5:wan"
17 ;;
18 airrouter|\
19 ap121|\
20 ap121-mini|\
21 ap96|\
22 dir-600-a1|\
23 dir-615-c1|\
24 dir-615-e1|\
25 dir-615-e4|\
26 hiwifi-hc6361|\
27 ja76pf|\
28 mc-mac1200r|\
29 minibox-v1|\
30 mynet-n600|\
31 oolite-v1|\
32 oolite-v5.2|\
33 oolite-v5.2-dev|\
34 qihoo-c301|\
35 r602n|\
36 rb-750|\
37 rb-751|\
38 som9331|\
39 t830|\
40 tew-632brp|\
41 tew-712br|\
42 tew-732br|\
43 tl-mr3220|\
44 tl-mr3220-v2|\
45 tl-mr3420|\
46 tl-wdr3320-v2|\
47 tl-wdr3500|\
48 tl-wr740n-v6|\
49 tl-wr741nd-v4|\
50 tl-wr840n-v2|\
51 tl-wr840n-v3|\
52 tl-wr841n-v11|\
53 tl-wr841n-v9|\
54 tl-wr842n-v3|\
55 whr-g301n|\
56 whr-hp-g300n|\
57 whr-hp-gn|\
58 wzr-hp-ag300h|\
59 zbt-we1526)
60 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
61 ucidef_add_switch "switch0" \
62 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
63 ;;
64 alfa-ap120c|\
65 all0305|\
66 antminer-s1|\
67 antminer-s3|\
68 antrouter-r1|\
69 ap121f|\
70 ap91-5g|\
71 aw-nr580|\
72 bullet-m|\
73 c-55|\
74 cap4200ag|\
75 cf-e380ac-v1|\
76 cf-e380ac-v2|\
77 dr342|\
78 eap120|\
79 eap300v2|\
80 eap7660d|\
81 el-mini|\
82 fritz300e|\
83 fritz450e|\
84 gl-usb150|\
85 hiveap-121|\
86 koala|\
87 lbe-m5|\
88 loco-m-xw|\
89 mr12|\
90 mr16|\
91 mr1750|\
92 mr1750v2|\
93 mr18|\
94 mr600|\
95 mr600v2|\
96 mr900|\
97 mr900v2|\
98 mynet-rext|\
99 pqi-air-pen|\
100 rb-411|\
101 rb-411u|\
102 rb-911-2hn|\
103 rb-911-5hn|\
104 rb-911g-2hpnd|\
105 rb-911g-5hpacd|\
106 rb-911g-5hpnd|\
107 rb-912uag-2hpnd|\
108 rb-912uag-5hpnd|\
109 rb-921gs-5hpacd-r2|\
110 rb-lhg-5nd|\
111 rb-mapl-2nd|\
112 rb-sxt2n|\
113 rb-sxt5n|\
114 rb-wap-2nd|\
115 rb-wapr-2nd|\
116 rb-wapg-5hact2hnd|\
117 re355|\
118 re450|\
119 rocket-m-xw|\
120 sc300m |\
121 tl-mr10u|\
122 tl-mr11u|\
123 tl-mr12u|\
124 tl-mr13u|\
125 tl-mr3020|\
126 tl-mr3040|\
127 tl-mr3040-v2|\
128 tl-wa701nd-v2|\
129 tl-wa7210n-v2|\
130 tl-wa750re|\
131 tl-wa801nd-v2|\
132 tl-wa830re-v2|\
133 tl-wa850re|\
134 tl-wa850re-v2|\
135 tl-wa855re-v1|\
136 tl-wa901nd|\
137 tl-wa901nd-v2|\
138 tl-wa901nd-v3|\
139 tl-wa901nd-v4|\
140 tl-wa901nd-v5|\
141 tl-wr703n|\
142 tl-wr802n-v1|\
143 tl-wr802n-v2|\
144 tl-wr902ac-v1|\
145 ts-d084|\
146 tube2h|\
147 unifi|\
148 unifiac-lite|\
149 wi2a-ac200i|\
150 wifi-pineapple-nano|\
151 wndap360|\
152 wp543)
153 ucidef_set_interface_lan "eth0"
154 ;;
155 a40|\
156 a60|\
157 alfa-ap96|\
158 alfa-nx|\
159 archer-c25-v1|\
160 dr344|\
161 gl-ar150|\
162 gl-ar300m|\
163 gl-domino|\
164 gl-inet|\
165 gl-mifi|\
166 jwap003|\
167 om2p-hsv4|\
168 om2pv4|\
169 pb42|\
170 pb44|\
171 rb-951ui-2hnd|\
172 rb-952ui-5ac2nd|\
173 routerstation|\
174 tl-wr710n|\
175 tl-wr720n-v3|\
176 tl-wr810n|\
177 tl-wr810n-v2|\
178 wpe72|\
179 wrtnode2q)
180 ucidef_set_interfaces_lan_wan "eth1" "eth0"
181 ;;
182 rb-750-r2|\
183 rb-750p-pbr2|\
184 rb-750up-r2|\
185 rb-951ui-2nd)
186 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
187 ucidef_add_switch "switch0" \
188 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
189 ;;
190 all0258n|\
191 all0315n|\
192 dlan-hotspot|\
193 dlan-pro-500-wp|\
194 ens202ext|\
195 ja76pf2|\
196 rocket-m-ti|\
197 ubnt-unifi-outdoor)
198 ucidef_set_interface_lan "eth0 eth1"
199 ;;
200 wzr-hp-g300nh2)
201 ucidef_add_switch "switch0" \
202 "0@eth0" "1:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "2:wan"
203 ;;
204 ap132|\
205 ap136|\
206 ap152|\
207 rb-750gl|\
208 rb-751g|\
209 rb-951g-2hnd|\
210 rb-962uigs-5hact2hnt|\
211 wlr8100|\
212 wzr-hp-g450h)
213 ucidef_add_switch "switch0" \
214 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
215 ;;
216 ap135-020|\
217 ap136-020|\
218 bhr-4grv2|\
219 tew-823dru|\
220 tl-wr1043nd-v2|\
221 wzr-450hp2)
222 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
223 ucidef_add_switch "switch0" \
224 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
225 ;;
226 ap136-010|\
227 ap147-010|\
228 nbg6616|\
229 nbg6716)
230 ucidef_set_interfaces_lan_wan "eth0.1" "eth1.2"
231 ucidef_add_switch "switch0" \
232 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth1"
233 ;;
234 ap143|\
235 rb-433|\
236 rb-433u)
237 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
238 ucidef_add_switch "switch0" \
239 "1:lan" "2:lan" "5@eth1"
240 ;;
241 archer-c5|\
242 archer-c7|\
243 tl-wdr4900-v2)
244 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
245 ucidef_add_switch "switch0" \
246 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
247 ;;
248 archer-c58-v1|\
249 archer-c59-v1|\
250 fritz4020|\
251 rb-450g)
252 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
253 ucidef_add_switch "switch0" \
254 "0@eth1" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
255 ;;
256 archer-c60-v1|\
257 archer-c60-v2)
258 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
259 ucidef_add_switch "switch0" \
260 "0@eth1" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
261 ;;
262 arduino-yun|\
263 dir-505-a1|\
264 tl-wa801nd-v3)
265 ucidef_set_interface_lan "eth1"
266 ;;
267 bsb)
268 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
269 ucidef_add_switch "switch0" \
270 "0@eth1" "1:lan" "3:lan"
271 ;;
272 c-60)
273 ucidef_add_switch "switch0" \
274 "0@eth0" "3:wan" "4:lan"
275 ;;
276 cap324|\
277 rme-eg200)
278 ucidef_set_interface_lan "eth0" "dhcp"
279 ;;
280 cf-e375ac|\
281 rb-map-2nd)
282 ucidef_add_switch "switch0" \
283 "0@eth0" "1:wan" "2:lan"
284 ;;
285 cf-e385ac)
286 ucidef_set_interfaces_lan_wan "eth0.1" "eth1.2"
287 ucidef_add_switch "switch0" \
288 "0@eth0" "2:lan" "1:wan" "6@eth1"
289 ;;
290 cpe210|\
291 cpe510|\
292 wbs210|\
293 wbs510)
294 ucidef_add_switch "switch0" \
295 "0@eth0" "5:lan" "4:wan"
296 ;;
297 cr3000)
298 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
299 ucidef_add_switch "switch0" \
300 "0@eth0" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
301 ;;
302 cr5000|\
303 dgl-5500-a1|\
304 dhp-1565-a1|\
305 dir-825-c1|\
306 dir-835-a1|\
307 esr900|\
308 mynet-n750|\
309 sr3200|\
310 tl-wr1043n-v5)
311 ucidef_add_switch "switch0" \
312 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
313 ;;
314 dap-2695-a1)
315 ucidef_add_switch "switch0" "0@eth0" "2:lan" "3:wan" "6@eth1"
316 ;;
317 rb-941-2nd)
318 ucidef_add_switch "switch0" \
319 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:wan:1"
320 ;;
321 db120|\
322 rb-2011il|\
323 rb-2011ils|\
324 rb-2011l|\
325 rb-2011uas|\
326 rb-2011uas-2hnd|\
327 rb-2011uias|\
328 rb-2011uias-2hnd)
329 case "$board" in
330 rb-2011ils|\
331 rb-2011uas*|\
332 rb-2011uias|\
333 rb-2011uias-2hnd)
334 ucidef_add_switch "switch0" \
335 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan" "6:sfp"
336 ;;
337 *)
338 ucidef_add_switch "switch0" \
339 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
340 ;;
341 esac
342
343 ucidef_add_switch "switch1" \
344 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:lan"
345 ;;
346 dir-615-i1|\
347 omy-g1|\
348 r6100|\
349 smart-300|\
350 tl-wdr6500-v2|\
351 tl-wr940n-v4|\
352 tl-wr940n-v6|\
353 tl-wr941nd-v6|\
354 wnr1000-v2|\
355 wnr2000-v4|\
356 wnr2200|\
357 wnr612-v2|\
358 wpn824n)
359 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
360 ucidef_add_switch "switch0" \
361 "0@eth1" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
362 ;;
363 tl-mr6400)
364 ucidef_set_interfaces_lan_wan "eth0.1 eth1" "usb0"
365 ucidef_add_switch "switch0" \
366 "0@eth0" "1:lan" "2:lan" "3:lan"
367 ;;
368 dir-825-b1|\
369 nbg460n_550n_550nh|\
370 tew-673gru|\
371 wzr-hp-g300nh)
372 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
373 ucidef_add_switch "switch0" \
374 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
375 ;;
376 dlan-pro-1200-ac)
377 ucidef_set_interface_lan "eth0"
378 ucidef_add_switch "switch0" \
379 "0u@eth0" "2:lan" "3:lan" "4:lan"
380 ucidef_add_switch_attr "switch0" "enable" "false"
381 ;;
382 e1700ac-v2|\
383 unifiac-pro|\
384 xd3200)
385 ucidef_add_switch "switch0" \
386 "0@eth0" "2:lan" "3:wan"
387 ;;
388 ebr-2310-c1)
389 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
390 ucidef_add_switch "switch0" \
391 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
392 ;;
393 el-m150)
394 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
395 ucidef_add_switch "switch0" \
396 "0:lan" "1:lan" "3@eth1"
397 ;;
398 dir-869-a1|\
399 epg5000|\
400 esr1750|\
401 tl-wr1043nd-v4|\
402 wndr3700v4|\
403 wndr4300)
404 ucidef_add_switch "switch0" \
405 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
406 ;;
407 ew-balin)
408 ucidef_set_interface "usb2" ifname "usb0" protocol "static"
409 ucidef_add_switch "switch0" \
410 "0@eth0" "5:lan:4" "4:lan:5" "3:wan"
411 ;;
412 ew-dorin)
413 ucidef_add_switch "switch0" \
414 "0@eth0" "1:lan" "2:lan" "3:wan"
415 ;;
416 ew-dorin-router)
417 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
418 ucidef_add_switch "switch0" \
419 "0@eth0" "2:lan" "3:lan"
420 ;;
421 dw33d|\
422 f9k1115v2)
423 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
424 ucidef_add_switch "switch0" \
425 "2:lan" "3:lan" "4:lan" "5:lan" "6@eth1" "0@eth0" "1:wan"
426 ;;
427 gl-ar300|\
428 wnr2000-v3)
429 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
430 ucidef_add_switch "switch0" \
431 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
432 ;;
433 gl-ar750|\
434 rb-435g)
435 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
436 ucidef_add_switch "switch0" \
437 "0@eth1" "1:lan" "2:lan"
438 ;;
439 gl-ar750s)
440 ucidef_add_switch "switch0" \
441 "0@eth0" "2:lan:2" "3:lan:1" "1:wan"
442 ;;
443 jwap230)
444 ucidef_set_interfaces_lan_wan "eth0.1" "eth1.2"
445 ucidef_add_switch "switch0" \
446 "0@eth0" "1:lan" "5:wan" "6@eth1"
447 ;;
448 nanostation-m-xw)
449 ucidef_add_switch "switch0" \
450 "0@eth0" "5:lan" "1:wan"
451 ;;
452 onion-omega)
453 ucidef_set_interface_lan "wlan0"
454 ;;
455 rb-450)
456 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
457 ucidef_add_switch "switch0" \
458 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5@eth1"
459 ;;
460 routerstation-pro)
461 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
462 ucidef_add_switch "switch0" \
463 "0@eth1" "2:lan:3" "3:lan:2" "4:lan:1"
464 ;;
465 rb-493g)
466 ucidef_set_interfaces_lan_wan "eth0.1 eth1.1" "eth1.2"
467 ucidef_add_switch "switch0" \
468 "0@eth0" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
469 ucidef_add_switch "switch1" \
470 "0@eth1" "1:lan:4" "2:lan:1" "3:lan:3" "4:lan:2" "5:wan"
471 ;;
472 rut900)
473 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
474 ucidef_add_switch "switch0" \
475 "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1"
476 ;;
477 tellstick-znet-lite)
478 ucidef_set_interface_wan "eth0"
479 ucidef_set_interface "wlan" ifname "wlan0" protocol "dhcp"
480 ;;
481 tl-mr3420-v2|\
482 tl-wr841n-v8|\
483 tl-wr842n-v2|\
484 tl-wr941nd-v5|\
485 tl-wr942n-v1)
486 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
487 ucidef_add_switch "switch0" \
488 "0@eth1" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
489 ;;
490 archer-c7-v4|\
491 archer-c7-v5|\
492 tl-wdr4300|\
493 tl-wr1041n-v2)
494 ucidef_add_switch "switch0" \
495 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
496 ;;
497 tl-wpa8630)
498 ucidef_add_switch "switch0" \
499 "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1" "5:lan:4"
500 ;;
501 tl-wr1043nd)
502 ucidef_add_switch "switch0" \
503 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
504 ;;
505 tl-wr2543n)
506 ucidef_add_switch "switch0" \
507 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
508 ;;
509 tl-wr841n-v1|\
510 tl-wr941nd)
511 ucidef_set_interface "eth" ifname "eth0"
512 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
513 ;;
514 tl-wr741nd|\
515 tl-wr841n-v7)
516 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
517 ucidef_add_switch "switch0" \
518 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
519 ;;
520 uap-pro|\
521 wpj342)
522 ucidef_add_switch "switch0" \
523 "0@eth0" "1:lan" "2:wan"
524 ;;
525 wndr3700|\
526 wndr3700v2|\
527 wndr3800|\
528 wndr3800ch)
529 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
530 ucidef_add_switch "switch0" \
531 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5@eth0"
532
533 ucidef_add_switch_attr "switch0" "blinkrate" 2
534 ucidef_add_switch_port_attr "switch0" 1 led 6
535 ucidef_add_switch_port_attr "switch0" 2 led 9
536 ucidef_add_switch_port_attr "switch0" 5 led 2
537 ;;
538 wpj344)
539 ucidef_add_switch "switch0" \
540 "0@eth0" "3:lan" "2:wan"
541 ;;
542 wpj558)
543 ucidef_add_switch "switch0" \
544 "5:lan" "1:wan" "6@eth0"
545 ;;
546 wpj563)
547 ucidef_add_switch "switch0" \
548 "0@eth0" "2:lan" "3:wan"
549 ;;
550 wrt160nl)
551 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
552 ucidef_add_switch "switch0" \
553 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4@eth0"
554 ;;
555 wzr-hp-g450h)
556 ucidef_add_switch "switch0" \
557 "0@eth0" "2:lan:1 3:lan:2 4:lan:3 5:lan:4" "1:wan"
558 ;;
559 z1)
560 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
561 ucidef_add_switch "switch0" \
562 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4" "5:wan"
563 ;;
564 *)
565 ucidef_set_interfaces_lan_wan "eth0" "eth1"
566 ;;
567 esac
568 }
569
570 ar71xx_setup_macs()
571 {
572 local board="$1"
573 local lan_mac=""
574 local wan_mac=""
575
576 case $board in
577 dgl-5500-a1|\
578 dir-825-c1)
579 wan_mac=$(mtd_get_mac_ascii nvram "wan_mac")
580 ;;
581 dhp-1565-a1|\
582 dir-835-a1|\
583 wndr3700v4|\
584 wndr4300)
585 lan_mac=$(mtd_get_mac_binary caldata 0)
586 wan_mac=$(mtd_get_mac_binary caldata 6)
587 ;;
588 fritz300e)
589 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
590 ;;
591 tl-wr1043n-v5|\
592 tl-wr1043nd-v4)
593 lan_mac=$(mtd_get_mac_binary product-info 8)
594 wan_mac=$(macaddr_add "$lan_mac" 1)
595 ;;
596 esr900)
597 wan_mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
598 ;;
599 dir-869-a1|\
600 mynet-n750)
601 wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
602 ;;
603 wlr8100)
604 lan_mac=$(mtd_get_mac_ascii u-boot-env "ethaddr")
605 wan_mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
606 ;;
607 wpj344|\
608 wpj558)
609 wan_mac=$(mtd_get_mac_binary u-boot 0x2e018)
610 ;;
611 esac
612
613 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
614 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
615 }
616
617 board_config_update
618 board=$(board_name)
619 ar71xx_setup_interfaces $board
620 ar71xx_setup_macs $board
621 board_config_flush
622
623 exit 0