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