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