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