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