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