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