ar71xx: Backport support for Onion Omega
[15.05/openwrt.git] / target / linux / ar71xx / base-files / etc / uci-defaults / 02_network
1 #!/bin/sh
2 #
3 # Copyright (C) 2011 OpenWrt.org
4 #
5
6 [ -e /etc/config/network ] && exit 0
7
8 touch /etc/config/network
9
10 . /lib/functions/uci-defaults.sh
11 . /lib/ar71xx.sh
12
13 ucidef_set_interface_loopback
14
15 board=$(ar71xx_board_name)
16
17 case "$board" in
18 all0315n |\
19 all0258n |\
20 ja76pf2|\
21 ubnt-unifi-outdoor)
22         ucidef_set_interface_lan "eth0 eth1"
23         ;;
24
25 ap132 |\
26 wlr8100)
27         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
28         ucidef_add_switch "switch0" "1" "1"
29         ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
30         ucidef_add_switch_vlan "switch0" "2" "0t 1"
31         ;;
32
33 esr1750 |\
34 epg5000)
35         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
36         ucidef_add_switch "switch0" "1" "1"
37         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
38         ucidef_add_switch_vlan "switch0" "2" "0t 5"
39         ;;
40
41 ap136-010)
42         ucidef_set_interfaces_lan_wan "eth0" "eth1"
43         ucidef_add_switch "switch0" "1" "1"
44         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
45         ucidef_add_switch_vlan "switch0" "2" "5 6"
46         ;;
47
48 ap136-020 |\
49 ap135-020 |\
50 tl-wr1043nd-v2 |\
51 wzr-450hp2)
52         ucidef_set_interfaces_lan_wan "eth1" "eth0"
53         ucidef_add_switch "switch0" "1" "1"
54         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
55         ucidef_add_switch_vlan "switch0" "2" "5 6"
56         ;;
57
58 archer-c5 |\
59 archer-c7 |\
60 tl-wdr4900-v2)
61         ucidef_set_interfaces_lan_wan "eth1" "eth0"
62         ucidef_add_switch "switch0" "1" "1"
63         ucidef_add_switch_vlan "switch0" "1" "0 2 3 4 5"
64         ucidef_add_switch_vlan "switch0" "2" "1 6"
65         ;;
66
67 cpe510)
68         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
69         ucidef_add_switch "switch0" "1" "1"
70         ucidef_add_switch_vlan "switch0" "1" "0t 5"
71         ucidef_add_switch_vlan "switch0" "2" "0t 4"
72         ;;
73
74 db120 |\
75 rb-2011l | \
76 rb-2011uas |\
77 rb-2011uias |\
78 rb-2011uas-2hnd|\
79 rb-2011uias-2hnd)
80         ucidef_set_interfaces_lan_wan "eth0.1 eth1" "eth0.2"
81         ucidef_add_switch "switch0" "1" "1"
82         ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
83         ucidef_add_switch_vlan "switch0" "2" "0t 1"
84         ucidef_add_switch "switch1" "1" "1"
85         ucidef_add_switch_vlan "switch1" "1" "0 1 2 3 4 5"
86
87         case "$board" in
88         rb-2011uas* | rb-2011uias | rb-2011uias-2hnd)
89                 ucidef_set_interface_raw "sfp" "eth0.3"
90                 ucidef_add_switch_vlan "switch0" "3" "0t 6"
91                 ;;
92         esac
93         ;;
94
95 dir-825-b1|\
96 tew-673gru)
97         ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
98         ucidef_add_switch "switch0" "1" "1"
99         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
100         ;;
101
102 f9k1115v2)
103         ucidef_set_interfaces_lan_wan "eth1" "eth0"
104         ucidef_add_switch "switch0" "1" "1"
105         ucidef_add_switch_vlan "switch0" "1" "2 3 4 5 6"
106         ucidef_add_switch_vlan "switch0" "2" "0 1"
107         ;;
108
109 nbg460n_550n_550nh)
110         ucidef_set_interfaces_lan_wan "eth0" "eth1"
111         ucidef_add_switch "switch0" "1" "1"
112         ucidef_add_switch_vlan "switch0" "0" "0 1 2 3 5"
113         ;;
114
115 nbg6716)
116         ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
117         ucidef_add_switch "switch0" "1" "1"
118         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
119         ucidef_add_switch_vlan "switch0" "2" "5 6"
120         ;;
121
122 rb-433 |\
123 rb-433u)
124         ucidef_set_interfaces_lan_wan "eth1" "eth0"
125         ucidef_add_switch "switch0" "1" "1"
126         ucidef_add_switch_vlan "switch0" "1" "1 2 5"
127         ;;
128
129 rb-435g)
130         ucidef_set_interfaces_lan_wan "eth1" "eth0"
131         ucidef_add_switch "switch0" "1" "1"
132         ucidef_add_switch_vlan "switch0" "1" "0 1 2"
133         ;;
134
135 rb-450)
136         ucidef_set_interfaces_lan_wan "eth1" "eth0"
137         ucidef_add_switch "switch0" "1" "1"
138         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5"
139         ;;
140
141 rb-450g |\
142 routerstation-pro)
143         ucidef_set_interfaces_lan_wan "eth1" "eth0"
144         ucidef_add_switch "switch0" "1" "1"
145         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
146         ;;
147
148 ap136 |\
149 rb-750gl |\
150 rb-751g |\
151 rb-951g-2hnd |\
152 wzr-hp-g450h)
153         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
154         ucidef_add_switch "switch0" "1" "1"
155         ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
156         ucidef_add_switch_vlan "switch0" "2" "0t 1"
157         ;;
158
159 rb-951ui-2hnd)
160         ucidef_set_interfaces_lan_wan "eth1" "eth0"
161         ;;
162
163 rb-493g)
164         ucidef_set_interfaces_lan_wan "eth0 eth1.1" "eth1.2"
165         ucidef_add_switch "switch0" "1" "1"
166         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
167         ucidef_add_switch "switch1" "1" "1"
168         ucidef_add_switch_vlan "switch1" "1" "0t 1 2 3 4"
169         ucidef_add_switch_vlan "switch1" "2" "0t 5"
170         ;;
171
172 wzr-hp-g300nh2 |\
173 pb92 |\
174 ap113)
175         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
176         ucidef_add_switch "switch0" "1" "1"
177         ucidef_add_switch_vlan "switch0" "1" "0t 1 3 4 5"
178         ucidef_add_switch_vlan "switch0" "2" "0t 2"
179         ;;
180
181 el-m150)
182         ucidef_set_interfaces_lan_wan "eth1" "eth0"
183         ucidef_add_switch "switch0" "1" "1"
184         ucidef_add_switch_vlan "switch0" "1" "0 1 3"
185         ;;
186
187 tl-wdr4300|\
188 tl-wr1041n-v2)
189         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
190         ucidef_add_switch "switch0" "1" "1"
191         ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
192         ucidef_add_switch_vlan "switch0" "2" "0t 1"
193         ;;
194
195 tl-wr1043nd)
196         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
197         ucidef_add_switch "switch0" "1" "1"
198         ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
199         ucidef_add_switch_vlan "switch0" "2" "0 5t"
200         ;;
201
202 tl-wr2543n)
203         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
204         ucidef_add_switch "switch0" "1" "1"
205         ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 9t"
206         ucidef_add_switch_vlan "switch0" "2" "0 9t"
207         ;;
208
209 tl-wr841n-v1|\
210 tl-wr941nd)
211         ucidef_set_interface_raw "eth" "eth0"
212         ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
213         ;;
214
215 r6100 |\
216 smart-300 |\
217 tl-mr3420-v2 |\
218 tl-wr841n-v8 |\
219 tl-wr842n-v2 |\
220 tl-wr941nd-v5 |\
221 wnr2000-v3 |\
222 wnr2000-v4 |\
223 wnr2200 |\
224 wnr612-v2 |\
225 wnr1000-v2)
226         ucidef_set_interfaces_lan_wan "eth1" "eth0"
227         ucidef_add_switch "switch0" "1" "1"
228         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
229         ;;
230
231 uap-pro)
232         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
233         ucidef_add_switch "switch0" "1" "1"
234         ucidef_add_switch_vlan "switch0" "1" "0t 1"
235         ucidef_add_switch_vlan "switch0" "2" "0t 2"
236         ;;
237
238 nanostation-m-xw)
239         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
240         ucidef_add_switch "switch0" "1" "1"
241         ucidef_add_switch_vlan "switch0" "1" "0t 5"
242         ucidef_add_switch_vlan "switch0" "2" "0t 1"
243         ;;
244
245 wrt160nl)
246         ucidef_set_interfaces_lan_wan "eth0" "eth1"
247         ucidef_add_switch "switch0" "1" "1"
248         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4 5"
249         ;;
250
251 wzr-hp-g300nh)
252         ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
253         ucidef_add_switch "switch0" "1" "1"
254         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
255         ;;
256
257 dgl-5500-a1 |\
258 dir-825-c1)
259         local mac
260         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
261         ucidef_add_switch "switch0" "1" "1"
262         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
263         ucidef_add_switch_vlan "switch0" "2" "0t 5"
264         mac=$(mtd_get_mac_ascii nvram "wan_mac")
265         [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
266         ;;
267
268 mynet-n750)
269         local mac
270         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
271         ucidef_add_switch "switch0" "1" "1"
272         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
273         ucidef_add_switch_vlan "switch0" "2" "0t 5"
274         mac=$(mtd_get_mac_ascii devdata "wanmac")
275         [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
276         ;;
277
278 onion-omega)
279         ucidef_set_interface_lan "wlan0"
280         ;;
281
282 dhp-1565-a1 |\
283 dir-835-a1 |\
284 wndr3700v4 | \
285 wndr4300)
286         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
287         ucidef_add_switch "switch0" "1" "1"
288         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
289         ucidef_add_switch_vlan "switch0" "2" "0t 5"
290         mac_lan=$(mtd_get_mac_binary caldata 0)
291         [ -n "$mac_lan" ] && ucidef_set_interface_macaddr "lan" "$mac_lan"
292         mac_wan=$(mtd_get_mac_binary caldata 6)
293         [ -n "$mac_wan" ] && ucidef_set_interface_macaddr "wan" "$mac_wan"
294         ;;
295
296 esr900)
297         local mac
298         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
299         ucidef_add_switch "switch0" "1" "1"
300         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
301         ucidef_add_switch_vlan "switch0" "2" "0t 5"
302         mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
303         [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
304         ;;
305
306 dlan-pro-500-wp)
307         ucidef_set_interface_lan "eth0 eth1"
308         ;;
309
310 dlan-pro-1200-ac)
311         ucidef_set_interface_lan "eth0"
312         ucidef_add_switch "switch0" "1" "0"
313         ucidef_add_switch_vlan "switch0" "0" "0 2 3 4"
314         ;;
315
316 all0305 |\
317 aw-nr580 |\
318 bullet-m |\
319 cap4200ag |\
320 eap300v2 |\
321 eap7660d |\
322 el-mini |\
323 loco-m-xw |\
324 mr600 |\
325 mr600v2 |\
326 mr900 |\
327 mr900v2 |\
328 rb-411 |\
329 rb-911g-2hpnd |\
330 rb-911g-5hpacd |\
331 rb-911g-5hpnd |\
332 rb-912uag-2hpnd |\
333 rb-912uag-5hpnd |\
334 rb-sxt2n |\
335 rb-sxt5n |\
336 rocket-m-xw |\
337 tl-mr10u |\
338 tl-mr11u |\
339 tl-mr12u |\
340 tl-mr13u |\
341 tl-mr3020 |\
342 tl-mr3040 |\
343 tl-mr3040-v2 |\
344 tl-wa701nd-v2 |\
345 tl-wa7210n-v2 |\
346 tl-wa750re |\
347 tl-wa850re |\
348 tl-wa830re-v2 |\
349 tl-wa801nd-v2 |\
350 tl-wa901nd |\
351 tl-wa901nd-v2 |\
352 tl-wa901nd-v3 |\
353 tl-wr703n |\
354 tube2h |\
355 wndap360 |\
356 mynet-rext |\
357 wp543)
358         ucidef_set_interface_lan "eth0"
359         ;;
360
361 antminer-s1 |\
362 antminer-s3 |\
363 dir-505-a1)
364         ucidef_set_interface_lan "eth1"
365         ;;
366
367 alfa-ap96 |\
368 alfa-nx |\
369 ap83 |\
370 gl-inet |\
371 jwap003 |\
372 pb42 |\
373 pb44 |\
374 routerstation|\
375 tl-wr710n |\
376 tl-wr720n-v3|\
377 wpe72)
378         ucidef_set_interfaces_lan_wan "eth1" "eth0"
379         ;;
380
381 wpj344)
382         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
383         ucidef_add_switch "switch0" "1" "1"
384         ucidef_add_switch_vlan "switch0" "1" "0t 3"
385         ucidef_add_switch_vlan "switch0" "2" "0t 2"
386         ;;
387
388 wpj531)
389         ucidef_set_interfaces_lan_wan "eth0" "eth1"
390         ;;
391
392 wpj558)
393         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
394         ucidef_add_switch "switch0" "1" "1"
395         ucidef_add_switch_vlan "switch0" "1" "5 6t"
396         ucidef_add_switch_vlan "switch0" "2" "1 6t"
397         ;;
398
399 ap121 |\
400 ap121-mini |\
401 ap96 |\
402 airrouter |\
403 dir-600-a1 |\
404 dir-615-c1 |\
405 dir-615-e1 |\
406 dir-615-e4 |\
407 hiwifi-hc6361 |\
408 ja76pf |\
409 mc-mac1200r|\
410 mynet-n600 |\
411 oolite |\
412 qihoo-c301 |\
413 rb-750 |\
414 rb-751 |\
415 tew-632brp |\
416 tew-712br |\
417 tl-mr3220 |\
418 tl-mr3220-v2 |\
419 tl-mr3420 |\
420 tl-wdr3500 |\
421 tl-wr741nd |\
422 tl-wr741nd-v4 |\
423 tl-wr841n-v7 |\
424 tl-wr841n-v9 |\
425 whr-g301n |\
426 whr-hp-g300n |\
427 whr-hp-gn |\
428 wzr-hp-ag300h)
429         ucidef_set_interfaces_lan_wan "eth0" "eth1"
430         ucidef_add_switch "switch0" "1" "1"
431         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
432         ;;
433
434 wzr-hp-g450h)
435         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
436         ucidef_add_switch "switch0" "1" "1"
437         ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
438         ucidef_add_switch_vlan "switch0" "2" "0t 1"
439         ;;
440
441 ew-dorin)
442         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
443         ucidef_add_switch "switch0" "1" "1"
444         ucidef_add_switch_vlan "switch0" "1" "0t 1 2"
445         ucidef_add_switch_vlan "switch0" "2" "0t 3"
446         ;;
447
448 ew-dorin-router)
449         ucidef_set_interfaces_lan_wan "eth0" "eth1"
450         ucidef_add_switch "switch0" "1" "1"
451         ucidef_add_switch_vlan "switch0" "1" "0 2 3"
452         ;;
453
454 wndr3700)
455         ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
456         ucidef_add_switch "switch0" "1" "1"
457         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
458         # Blinkrate: 0=43ms; 1=84ms; 2=120ms; 3=170ms; 4=340ms; 5=670ms
459         uci set network.@switch[-1].blinkrate='2'
460
461         ucidef_add_switch_port "switch0" "1"
462         # Port 1 controls the GREEN configuration of LEDs for
463         # the switch and the section does not correspond to a real
464         # switch port.
465         #
466         # 0=LED off; 1=Collision/FDX; 2=Link/activity; 3=1000 Mb/s;
467         # 4=100 Mb/s; 5=10 Mb/s; 6=1000 Mb/s+activity; 7=100 Mb/s+activity;
468         # 8=10 Mb/s+activity; 9=10/100 Mb/s+activity; 10: Fiber;
469         # 11: Fault; 12: Link/activity(tx); 13: Link/activity(rx);
470         # 14: Link (master); 15: separate register
471         uci set network.@switch_port[-1].led='6'
472
473         ucidef_add_switch_port "switch0" "2"
474         # Port 2 controls the ORANGE configuration of LEDs for
475         # the switch and the section does not correspond to a real
476         # switch port.
477         #
478         # See the key above for switch port 1 for the meaning of the
479         # 'led' setting below.
480         uci set network.@switch_port[-1].led='9'
481
482         ucidef_add_switch_port "switch0" "5"
483         # Port 5 controls the configuration of the WAN LED and the
484         # section does not correspond to a real switch port.
485         #
486         # To toggle the use of green or orange LEDs for the WAN port,
487         # see the LED setting for wndr3700:green:wan in /etc/config/system.
488         #
489         # See the key above for switch port 1 for the meaning of the
490         # 'led' setting below.
491         uci set network.@switch_port[-1].led='2'
492         ;;
493
494 *)
495         ucidef_set_interfaces_lan_wan "eth0" "eth1"
496         ;;
497 esac
498
499 uci commit network
500
501 exit 0