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