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