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