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