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