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