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