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