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