V2 ar71xx : Add Support for the Bitmain Antrouter R1
[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/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 antrouter-r1 |\
321 aw-nr580 |\
322 bullet-m |\
323 c-55 |\
324 cap4200ag |\
325 eap300v2 |\
326 eap7660d |\
327 el-mini |\
328 loco-m-xw |\
329 mr1750 |\
330 mr18 |\
331 mr600 |\
332 mr600v2 |\
333 mr900 |\
334 mr900v2 |\
335 rb-411 |\
336 rb-911g-2hpnd |\
337 rb-911g-5hpacd |\
338 rb-911g-5hpnd |\
339 rb-912uag-2hpnd |\
340 rb-912uag-5hpnd |\
341 rb-sxt2n |\
342 rb-sxt5n |\
343 rocket-m-xw |\
344 tl-mr10u |\
345 tl-mr11u |\
346 tl-mr12u |\
347 tl-mr13u |\
348 tl-mr3020 |\
349 tl-mr3040 |\
350 tl-mr3040-v2 |\
351 tl-wa701nd-v2 |\
352 tl-wa7210n-v2 |\
353 tl-wa750re |\
354 tl-wa850re |\
355 tl-wa830re-v2 |\
356 tl-wa801nd-v2 |\
357 tl-wa901nd |\
358 tl-wa901nd-v2 |\
359 tl-wa901nd-v3 |\
360 tl-wr703n |\
361 tube2h |\
362 wndap360 |\
363 mynet-rext |\
364 wp543)
365 ucidef_set_interface_lan "eth0"
366 ;;
367
368 cap324)
369 ucidef_set_interface_lan "eth0" "dhcp"
370 ;;
371
372 arduino-yun | \
373 dir-505-a1)
374 ucidef_set_interface_lan "eth1"
375 ;;
376
377 alfa-ap96 |\
378 alfa-nx |\
379 ap83 |\
380 gl-ar150 |\
381 gl-domino |\
382 gl-inet |\
383 jwap003 |\
384 pb42 |\
385 pb44 |\
386 routerstation|\
387 tl-wr710n |\
388 tl-wr720n-v3|\
389 wpe72)
390 ucidef_set_interfaces_lan_wan "eth1" "eth0"
391 ;;
392
393 gl-ar300)
394 ucidef_set_interfaces_lan_wan "eth1" "eth0"
395 ucidef_add_switch "switch0" \
396 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
397 ;;
398
399 wpj344)
400 ucidef_add_switch "switch0" \
401 "0@eth0" "3:lan" "2:wan"
402 ;;
403
404 wpj531)
405 ucidef_set_interfaces_lan_wan "eth0" "eth1"
406 ;;
407
408 wpj558)
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_add_switch "switch0" \
453 "0@eth0" "2:lan:1 3:lan:2 4:lan:3 5:lan:4" "1:wan"
454 ;;
455
456 ew-dorin)
457 ucidef_add_switch "switch0" \
458 "0@eth0" "1:lan" "2:lan" "3:wan"
459 ;;
460
461 ew-dorin-router)
462 ucidef_set_interfaces_lan_wan "eth0" "eth1"
463 ucidef_add_switch "switch0" "0@eth0" "2:lan" "3:lan"
464 ;;
465
466 wndr3700)
467 ucidef_set_interfaces_lan_wan "eth0" "eth1"
468 ucidef_add_switch "switch0" \
469 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
470
471 # Blinkrate: 0=43ms; 1=84ms; 2=120ms; 3=170ms; 4=340ms; 5=670ms
472 ucidef_add_switch_attr "switch0" "blinkrate" 2
473
474 # Port 1 controls the GREEN configuration of LEDs for
475 # the switch and the section does not correspond to a real
476 # switch port.
477 #
478 # 0=LED off; 1=Collision/FDX; 2=Link/activity; 3=1000 Mb/s;
479 # 4=100 Mb/s; 5=10 Mb/s; 6=1000 Mb/s+activity; 7=100 Mb/s+activity;
480 # 8=10 Mb/s+activity; 9=10/100 Mb/s+activity; 10: Fiber;
481 # 11: Fault; 12: Link/activity(tx); 13: Link/activity(rx);
482 # 14: Link (master); 15: separate register
483 ucidef_add_switch_port_attr "switch0" 1 led 6
484
485 # Port 2 controls the ORANGE configuration of LEDs for
486 # the switch and the section does not correspond to a real
487 # switch port.
488 #
489 # See the key above for switch port 1 for the meaning of the
490 # 'led' setting below.
491 ucidef_add_switch_port_attr "switch0" 2 led 9
492
493 # Port 5 controls the configuration of the WAN LED and the
494 # section does not correspond to a real switch port.
495 #
496 # To toggle the use of green or orange LEDs for the WAN port,
497 # see the LED setting for wndr3700:green:wan in /etc/config/system.
498 #
499 # See the key above for switch port 1 for the meaning of the
500 # 'led' setting below.
501 ucidef_add_switch_port_attr "switch0" 5 led 2
502 ;;
503
504 *)
505 ucidef_set_interfaces_lan_wan "eth0" "eth1"
506 ;;
507 esac
508
509 board_config_flush
510
511 exit 0