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