board.d: merge ucidef_add_switch() and ucidef_add_switch_ports()
[openwrt/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/uci-defaults-new.sh
7 . /lib/ar71xx.sh
8
9 board_config_update
10
11 ucidef_set_interface_loopback
12
13 board=$(ar71xx_board_name)
14
15
16 case "$board" in
17 all0315n |\
18 all0258n |\
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_set_interfaces_lan_wan "eth0.1" "eth0.2"
28 ucidef_add_switch "switch0" \
29 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
30 ;;
31
32 esr1750 |\
33 epg5000)
34 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
35 ucidef_add_switch "switch0" \
36 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
37 ;;
38
39 ap136-010 |\
40 ap147-010)
41 ucidef_set_interfaces_lan_wan "eth0" "eth1"
42 ucidef_add_switch "switch0" \
43 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth1"
44 ;;
45
46 ap136-020 |\
47 ap135-020 |\
48 tl-wr1043nd-v2 |\
49 wzr-450hp2)
50 ucidef_set_interfaces_lan_wan "eth1" "eth0"
51 ucidef_add_switch "switch0" \
52 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
53 ;;
54
55 archer-c5 |\
56 archer-c7 |\
57 tl-wdr4900-v2)
58 ucidef_set_interfaces_lan_wan "eth1" "eth0"
59 ucidef_add_switch "switch0" \
60 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
61 ;;
62
63 bsb)
64 ucidef_set_interfaces_lan_wan "eth1" "eth0"
65 ucidef_add_switch "switch0" \
66 "0@eth1" "1:lan" "3:lan" # XXX: confirm cpu port!
67 ucidef_set_interface_wlan
68 ;;
69
70 cpe510)
71 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
72 ucidef_add_switch "switch0" \
73 "0@eth0" "5:lan" "4:wan"
74 ;;
75
76 airgatewaypro)
77 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
78 ucidef_add_switch "switch0" \
79 "0@eth0" "4:lan" "5:wan"
80 ;;
81
82 db120 |\
83 rb-2011l | \
84 rb-2011uas |\
85 rb-2011uias |\
86 rb-2011uas-2hnd|\
87 rb-2011uias-2hnd)
88 ucidef_set_interfaces_lan_wan "eth0.1 eth1" "eth0.2"
89
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_set_interfaces_lan_wan "eth0.1" "eth0.2"
166 ucidef_add_switch "switch0" \
167 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
168 ;;
169
170 rb-951ui-2hnd)
171 ucidef_set_interfaces_lan_wan "eth1" "eth0"
172 ;;
173
174 rb-493g)
175 ucidef_set_interfaces_lan_wan "eth0 eth1.1" "eth1.2"
176 ucidef_add_switch "switch0" \
177 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
178 ucidef_add_switch "switch1" \
179 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
180 ;;
181
182 wzr-hp-g300nh2 |\
183 pb92 |\
184 ap113)
185 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
186 ucidef_add_switch "switch0" \
187 "0@eth0" "1:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "2:wan"
188 ;;
189
190 el-m150)
191 ucidef_set_interfaces_lan_wan "eth1" "eth0"
192 ucidef_add_switch "switch0" \
193 "0:lan" "1:lan" "3@eth1" # XXX: confirm!
194 ;;
195
196 tl-wdr4300|\
197 tl-wr1041n-v2)
198 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
199 ucidef_add_switch "switch0" \
200 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
201 ;;
202
203 tl-wr1043nd)
204 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
205 ucidef_add_switch "switch0" \
206 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
207 ;;
208
209 tl-wr2543n)
210 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
211 ucidef_add_switch "switch0" \
212 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
213 ;;
214
215 tl-wr841n-v1|\
216 tl-wr941nd)
217 ucidef_set_interface_raw "eth" "eth0"
218 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
219 ;;
220
221 dir-615-i1 |\
222 r6100 |\
223 smart-300 |\
224 tl-mr3420-v2 |\
225 tl-wr841n-v8 |\
226 tl-wr842n-v2 |\
227 tl-wr941nd-v5 |\
228 tl-wr941nd-v6 |\
229 tl-wdr6500-v2 |\
230 wnr2000-v3 |\
231 wnr2000-v4 |\
232 wnr2200 |\
233 wnr612-v2 |\
234 wnr1000-v2)
235 ucidef_set_interfaces_lan_wan "eth1" "eth0"
236 ucidef_add_switch "switch0" \
237 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4@eth1" # XXX: confirm!
238 ;;
239
240 uap-pro)
241 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
242 ucidef_add_switch "switch0" \
243 "0@eth0" "1:lan" "2:wan"
244 ;;
245
246 nanostation-m-xw)
247 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
248 ucidef_add_switch "switch0" \
249 "0@eth0" "5:lan" "1:wan"
250 ;;
251
252 wrt160nl)
253 ucidef_set_interfaces_lan_wan "eth0" "eth1"
254 ucidef_add_switch "switch0" \
255 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4@eth0"
256 ;;
257
258 wzr-hp-g300nh)
259 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
260 ucidef_add_switch "switch0" \
261 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
262 ;;
263
264 dgl-5500-a1 |\
265 dir-825-c1)
266 local mac
267 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
268 ucidef_add_switch "switch0" \
269 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
270 mac=$(mtd_get_mac_ascii nvram "wan_mac")
271 [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
272 ;;
273
274 mynet-n750)
275 local mac
276 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
277 ucidef_add_switch "switch0" \
278 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
279 mac=$(mtd_get_mac_ascii devdata "wanmac")
280 [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
281 ;;
282
283 onion-omega)
284 ucidef_set_interface_lan "wlan0"
285 ;;
286
287 dhp-1565-a1 |\
288 dir-835-a1 |\
289 wndr3700v4 | \
290 wndr4300)
291 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
292 ucidef_add_switch "switch0" \
293 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
294 mac_lan=$(mtd_get_mac_binary caldata 0)
295 [ -n "$mac_lan" ] && ucidef_set_interface_macaddr "lan" "$mac_lan"
296 mac_wan=$(mtd_get_mac_binary caldata 6)
297 [ -n "$mac_wan" ] && ucidef_set_interface_macaddr "wan" "$mac_wan"
298 ;;
299
300 esr900)
301 local mac
302 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
303 ucidef_add_switch "switch0" \
304 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
305 mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
306 [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
307 ;;
308
309 dlan-hotspot |\
310 dlan-pro-500-wp)
311 ucidef_set_interface_lan "eth0 eth1"
312 ;;
313
314 dlan-pro-1200-ac)
315 ucidef_set_interface_lan "eth0"
316 ucidef_add_switch "switch0"
317 ucidef_add_switch_attr "switch0" "reset" "false"
318 ucidef_add_switch_ports "switch0" \
319 "0@eth0" "2:lan" "3:lan" "4:lan"
320 ;;
321
322 all0305 |\
323 antminer-s1 |\
324 antminer-s3 |\
325 aw-nr580 |\
326 bullet-m |\
327 cap4200ag |\
328 eap300v2 |\
329 eap7660d |\
330 el-mini |\
331 loco-m-xw |\
332 mr1750 |\
333 mr600 |\
334 mr600v2 |\
335 mr900 |\
336 mr900v2 |\
337 rb-411 |\
338 rb-911g-2hpnd |\
339 rb-911g-5hpacd |\
340 rb-911g-5hpnd |\
341 rb-912uag-2hpnd |\
342 rb-912uag-5hpnd |\
343 rb-sxt2n |\
344 rb-sxt5n |\
345 rocket-m-xw |\
346 tl-mr10u |\
347 tl-mr11u |\
348 tl-mr12u |\
349 tl-mr13u |\
350 tl-mr3020 |\
351 tl-mr3040 |\
352 tl-mr3040-v2 |\
353 tl-wa701nd-v2 |\
354 tl-wa7210n-v2 |\
355 tl-wa750re |\
356 tl-wa850re |\
357 tl-wa830re-v2 |\
358 tl-wa801nd-v2 |\
359 tl-wa901nd |\
360 tl-wa901nd-v2 |\
361 tl-wa901nd-v3 |\
362 tl-wr703n |\
363 tube2h |\
364 wndap360 |\
365 mynet-rext |\
366 wp543)
367 ucidef_set_interface_lan "eth0"
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_set_interfaces_lan_wan "eth0.1" "eth0.2"
399 ucidef_add_switch "switch0" \
400 "0@eth0" "3:lan" "2:wan"
401 ;;
402
403 wpj531)
404 ucidef_set_interfaces_lan_wan "eth0" "eth1"
405 ;;
406
407 wpj558)
408 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
409 ucidef_add_switch "switch0" \
410 "5:lan" "1:wan" "6@eth0"
411 ;;
412
413 ap121 |\
414 ap121-mini |\
415 ap96 |\
416 airrouter |\
417 dir-600-a1 |\
418 dir-615-c1 |\
419 dir-615-e1 |\
420 dir-615-e4 |\
421 hiwifi-hc6361 |\
422 ja76pf |\
423 mc-mac1200r|\
424 minibox-v1 |\
425 mynet-n600 |\
426 oolite |\
427 qihoo-c301 |\
428 rb-750 |\
429 rb-751 |\
430 tew-632brp |\
431 tew-712br |\
432 tew-732br |\
433 tl-mr3220 |\
434 tl-mr3220-v2 |\
435 tl-mr3420 |\
436 tl-wdr3320-v2 |\
437 tl-wdr3500 |\
438 tl-wr741nd |\
439 tl-wr741nd-v4 |\
440 tl-wr841n-v7 |\
441 tl-wr841n-v9 |\
442 whr-g301n |\
443 whr-hp-g300n |\
444 whr-hp-gn |\
445 wzr-hp-ag300h)
446 ucidef_set_interfaces_lan_wan "eth0" "eth1"
447 ucidef_add_switch "switch0" \
448 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
449 ;;
450
451 wzr-hp-g450h)
452 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
453 ucidef_add_switch "switch0" \
454 "0@eth0" "2:lan:1 3:lan:2 4:lan:3 5:lan:4" "1:wan"
455 ;;
456
457 ew-dorin)
458 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
459 ucidef_add_switch "switch0" \
460 "0@eth0" "1:lan" "2:lan" "3:wan"
461 ;;
462
463 ew-dorin-router)
464 ucidef_set_interfaces_lan_wan "eth0" "eth1"
465 ucidef_add_switch "switch0" "0@eth0" "2:lan" "3:lan"
466 ;;
467
468 wndr3700)
469 ucidef_set_interfaces_lan_wan "eth0" "eth1"
470 ucidef_add_switch "switch0" \
471 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
472
473 # Blinkrate: 0=43ms; 1=84ms; 2=120ms; 3=170ms; 4=340ms; 5=670ms
474 ucidef_add_switch_attr "switch0" "blinkrate" 2
475
476 # Port 1 controls the GREEN configuration of LEDs for
477 # the switch and the section does not correspond to a real
478 # switch port.
479 #
480 # 0=LED off; 1=Collision/FDX; 2=Link/activity; 3=1000 Mb/s;
481 # 4=100 Mb/s; 5=10 Mb/s; 6=1000 Mb/s+activity; 7=100 Mb/s+activity;
482 # 8=10 Mb/s+activity; 9=10/100 Mb/s+activity; 10: Fiber;
483 # 11: Fault; 12: Link/activity(tx); 13: Link/activity(rx);
484 # 14: Link (master); 15: separate register
485 ucidef_add_switch_port_attr "switch0" 1 led 6
486
487 # Port 2 controls the ORANGE configuration of LEDs for
488 # the switch and the section does not correspond to a real
489 # switch port.
490 #
491 # See the key above for switch port 1 for the meaning of the
492 # 'led' setting below.
493 ucidef_add_switch_port_attr "switch0" 2 led 9
494
495 # Port 5 controls the configuration of the WAN LED and the
496 # section does not correspond to a real switch port.
497 #
498 # To toggle the use of green or orange LEDs for the WAN port,
499 # see the LED setting for wndr3700:green:wan in /etc/config/system.
500 #
501 # See the key above for switch port 1 for the meaning of the
502 # 'led' setting below.
503 ucidef_add_switch_port_attr "switch0" 5 led 2
504 ;;
505
506 *)
507 ucidef_set_interfaces_lan_wan "eth0" "eth1"
508 ;;
509 esac
510
511 board_config_flush
512
513 exit 0