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