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