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