be5d9ad95dd5635f2b10cdc2192a61cd1d17e68f
[openwrt/staging/mkresin.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 fritz4020|\
253 rb-450g)
254 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
255 ucidef_add_switch "switch0" \
256 "0@eth1" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
257 ;;
258 archer-c60-v1|\
259 archer-c60-v2)
260 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
261 ucidef_add_switch "switch0" \
262 "0@eth1" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
263 ;;
264 arduino-yun|\
265 dir-505-a1|\
266 tl-wa801nd-v3)
267 ucidef_set_interface_lan "eth1"
268 ;;
269 bsb)
270 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
271 ucidef_add_switch "switch0" \
272 "0@eth1" "1:lan" "3:lan"
273 ;;
274 c-60)
275 ucidef_add_switch "switch0" \
276 "0@eth0" "3:wan" "4:lan"
277 ;;
278 rme-eg200)
279 ucidef_set_interface_lan "eth0" "dhcp"
280 ;;
281 cf-e375ac|\
282 rb-map-2nd)
283 ucidef_add_switch "switch0" \
284 "0@eth0" "1:wan" "2:lan"
285 ;;
286 cf-e385ac)
287 ucidef_set_interfaces_lan_wan "eth0.1" "eth1.2"
288 ucidef_add_switch "switch0" \
289 "0@eth0" "2:lan" "1:wan" "6@eth1"
290 ;;
291 cpe210|\
292 cpe510|\
293 wbs210|\
294 wbs510)
295 ucidef_add_switch "switch0" \
296 "0@eth0" "5:lan" "4:wan"
297 ;;
298 cr3000)
299 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
300 ucidef_add_switch "switch0" \
301 "0@eth0" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
302 ;;
303 cr5000|\
304 dgl-5500-a1|\
305 dhp-1565-a1|\
306 dir-825-c1|\
307 dir-835-a1|\
308 esr900|\
309 mynet-n750|\
310 sr3200|\
311 tl-wr1043n-v5)
312 ucidef_add_switch "switch0" \
313 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
314 ;;
315 dap-2695-a1)
316 ucidef_add_switch "switch0" "0@eth0" "2:lan" "3:wan" "6@eth1"
317 ;;
318 rb-931-2nd)
319 ucidef_add_switch "switch0" \
320 "0@eth0" "1:lan:3" "2:lan:2" "3:wan:1"
321 ;;
322 rb-941-2nd)
323 ucidef_add_switch "switch0" \
324 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:wan:1"
325 ;;
326 db120|\
327 rb-2011il|\
328 rb-2011ils|\
329 rb-2011l|\
330 rb-2011uas|\
331 rb-2011uas-2hnd|\
332 rb-2011uias|\
333 rb-2011uias-2hnd)
334 case "$board" in
335 rb-2011ils|\
336 rb-2011uas*|\
337 rb-2011uias|\
338 rb-2011uias-2hnd)
339 ucidef_add_switch "switch0" \
340 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan" "6:sfp"
341 ;;
342 *)
343 ucidef_add_switch "switch0" \
344 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
345 ;;
346 esac
347
348 ucidef_add_switch "switch1" \
349 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:lan"
350 ;;
351 dir-615-i1|\
352 omy-g1|\
353 r6100|\
354 smart-300|\
355 tl-wdr6500-v2|\
356 tl-wr940n-v4|\
357 tl-wr940n-v6|\
358 tl-wr941nd-v6|\
359 wnr1000-v2|\
360 wnr2000-v4|\
361 wnr2200|\
362 wnr612-v2|\
363 wpn824n)
364 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
365 ucidef_add_switch "switch0" \
366 "0@eth1" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
367 ;;
368 tl-mr6400)
369 ucidef_set_interfaces_lan_wan "eth0.1 eth1" "usb0"
370 ucidef_add_switch "switch0" \
371 "0@eth0" "1:lan" "2:lan" "3:lan"
372 ;;
373 dir-825-b1|\
374 nbg460n_550n_550nh|\
375 tew-673gru|\
376 wzr-hp-g300nh)
377 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
378 ucidef_add_switch "switch0" \
379 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
380 ;;
381 dlan-pro-1200-ac)
382 ucidef_set_interface_lan "eth0"
383 ucidef_add_switch "switch0" \
384 "0u@eth0" "2:lan" "3:lan" "4:lan"
385 ucidef_add_switch_attr "switch0" "enable" "false"
386 ;;
387 e1700ac-v2|\
388 unifiac-pro|\
389 xd3200)
390 ucidef_add_switch "switch0" \
391 "0@eth0" "2:lan" "3:wan"
392 ;;
393 e558-v2)
394 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
395 ucidef_add_switch "switch0" \
396 "0@eth1" "4:lan" "5:lan" "6@eth0" "3:wan"
397 ;;
398 ebr-2310-c1)
399 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
400 ucidef_add_switch "switch0" \
401 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
402 ;;
403 el-m150)
404 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
405 ucidef_add_switch "switch0" \
406 "0:lan" "1:lan" "3@eth1"
407 ;;
408 dir-869-a1|\
409 epg5000|\
410 esr1750|\
411 tl-wr1043nd-v4|\
412 wndr3700v4|\
413 wndr4300)
414 ucidef_add_switch "switch0" \
415 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
416 ;;
417 ew-balin)
418 ucidef_set_interface "usb2" ifname "usb0" protocol "static"
419 ucidef_add_switch "switch0" \
420 "0@eth0" "5:lan:4" "4:lan:5" "3:wan"
421 ;;
422 ew-dorin)
423 ucidef_add_switch "switch0" \
424 "0@eth0" "1:lan" "2:lan" "3:wan"
425 ;;
426 ew-dorin-router)
427 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
428 ucidef_add_switch "switch0" \
429 "0@eth0" "2:lan" "3:lan"
430 ;;
431 dw33d|\
432 f9k1115v2)
433 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
434 ucidef_add_switch "switch0" \
435 "2:lan" "3:lan" "4:lan" "5:lan" "6@eth1" "0@eth0" "1:wan"
436 ;;
437 gl-ar300|\
438 wnr2000-v3)
439 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
440 ucidef_add_switch "switch0" \
441 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
442 ;;
443 gl-ar750|\
444 rb-435g)
445 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
446 ucidef_add_switch "switch0" \
447 "0@eth1" "1:lan" "2:lan"
448 ;;
449 gl-ar750s)
450 ucidef_add_switch "switch0" \
451 "0@eth0" "2:lan:2" "3:lan:1" "1:wan"
452 ;;
453 jwap230)
454 ucidef_set_interfaces_lan_wan "eth0.1" "eth1.2"
455 ucidef_add_switch "switch0" \
456 "0@eth0" "1:lan" "5:wan" "6@eth1"
457 ;;
458 nanostation-m-xw)
459 ucidef_add_switch "switch0" \
460 "0@eth0" "5:lan" "1:wan"
461 ;;
462 onion-omega)
463 ucidef_set_interface_lan "wlan0"
464 ;;
465 rb-450)
466 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
467 ucidef_add_switch "switch0" \
468 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5@eth1"
469 ;;
470 routerstation-pro)
471 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
472 ucidef_add_switch "switch0" \
473 "0@eth1" "2:lan:3" "3:lan:2" "4:lan:1"
474 ;;
475 rb-493g)
476 ucidef_set_interfaces_lan_wan "eth0.1 eth1.1" "eth1.2"
477 ucidef_add_switch "switch0" \
478 "0@eth0" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
479 ucidef_add_switch "switch1" \
480 "0@eth1" "1:lan:4" "2:lan:1" "3:lan:3" "4:lan:2" "5:wan"
481 ;;
482 rut900)
483 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
484 ucidef_add_switch "switch0" \
485 "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1"
486 ;;
487 tellstick-znet-lite)
488 ucidef_set_interface_wan "eth0"
489 ucidef_set_interface "wlan" ifname "wlan0" protocol "dhcp"
490 ;;
491 tl-mr3420-v2|\
492 tl-wr841n-v8|\
493 tl-wr842n-v2|\
494 tl-wr941nd-v5|\
495 tl-wr942n-v1)
496 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
497 ucidef_add_switch "switch0" \
498 "0@eth1" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
499 ;;
500 archer-c7-v4|\
501 archer-c7-v5|\
502 tl-wdr4300|\
503 tl-wr1041n-v2)
504 ucidef_add_switch "switch0" \
505 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
506 ;;
507 tl-wpa8630)
508 ucidef_add_switch "switch0" \
509 "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1" "5:lan:4"
510 ;;
511 tl-wr1043nd)
512 ucidef_add_switch "switch0" \
513 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
514 ;;
515 tl-wr2543n)
516 ucidef_add_switch "switch0" \
517 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
518 ;;
519 tl-wr841n-v1|\
520 tl-wr941nd)
521 ucidef_set_interface "eth" ifname "eth0"
522 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
523 ;;
524 tl-wr741nd|\
525 tl-wr841n-v7)
526 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
527 ucidef_add_switch "switch0" \
528 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
529 ;;
530 uap-pro|\
531 wpj342)
532 ucidef_add_switch "switch0" \
533 "0@eth0" "1:lan" "2:wan"
534 ;;
535 wndr3700|\
536 wndr3700v2|\
537 wndr3800|\
538 wndr3800ch)
539 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
540 ucidef_add_switch "switch0" \
541 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5@eth0"
542
543 ucidef_add_switch_attr "switch0" "blinkrate" 2
544 ucidef_add_switch_port_attr "switch0" 1 led 6
545 ucidef_add_switch_port_attr "switch0" 2 led 9
546 ucidef_add_switch_port_attr "switch0" 5 led 2
547 ;;
548 wpj344)
549 ucidef_add_switch "switch0" \
550 "0@eth0" "3:lan" "2:wan"
551 ;;
552 wpj558)
553 ucidef_add_switch "switch0" \
554 "5:lan" "1:wan" "6@eth0"
555 ;;
556 wpj563)
557 ucidef_add_switch "switch0" \
558 "0@eth0" "2:lan" "3:wan"
559 ;;
560 wrt160nl)
561 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
562 ucidef_add_switch "switch0" \
563 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4@eth0"
564 ;;
565 wzr-hp-g450h)
566 ucidef_add_switch "switch0" \
567 "0@eth0" "2:lan:1 3:lan:2 4:lan:3 5:lan:4" "1:wan"
568 ;;
569 z1)
570 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
571 ucidef_add_switch "switch0" \
572 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4" "5:wan"
573 ;;
574 *)
575 ucidef_set_interfaces_lan_wan "eth0" "eth1"
576 ;;
577 esac
578 }
579
580 ar71xx_setup_macs()
581 {
582 local board="$1"
583 local lan_mac=""
584 local wan_mac=""
585
586 case $board in
587 dgl-5500-a1|\
588 dir-825-c1)
589 wan_mac=$(mtd_get_mac_ascii nvram "wan_mac")
590 ;;
591 dhp-1565-a1|\
592 dir-835-a1|\
593 wndr3700v4|\
594 wndr4300)
595 lan_mac=$(mtd_get_mac_binary caldata 0)
596 wan_mac=$(mtd_get_mac_binary caldata 6)
597 ;;
598 fritz300e)
599 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
600 ;;
601 tl-wr1043n-v5|\
602 tl-wr1043nd-v4)
603 lan_mac=$(mtd_get_mac_binary product-info 8)
604 wan_mac=$(macaddr_add "$lan_mac" 1)
605 ;;
606 esr900)
607 wan_mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
608 ;;
609 dir-869-a1|\
610 mynet-n750)
611 wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
612 ;;
613 wlr8100)
614 lan_mac=$(mtd_get_mac_ascii u-boot-env "ethaddr")
615 wan_mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
616 ;;
617 wpj344|\
618 wpj558)
619 wan_mac=$(mtd_get_mac_binary u-boot 0x2e018)
620 ;;
621 esac
622
623 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
624 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
625 }
626
627 board_config_update
628 board=$(board_name)
629 ar71xx_setup_interfaces $board
630 ar71xx_setup_macs $board
631 board_config_flush
632
633 exit 0