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