ar71xx: Compex WPJ563 support
[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 ar71xx_setup_interfaces()
11 {
12 local board="$1"
13
14 case "$board" in
15 airgatewaypro)
16 ucidef_add_switch "switch0" \
17 "0@eth0" "4:lan" "5:wan"
18 ;;
19 airrouter|\
20 ap121|\
21 ap121-mini|\
22 ap96|\
23 dir-600-a1|\
24 dir-615-c1|\
25 dir-615-e1|\
26 dir-615-e4|\
27 hiwifi-hc6361|\
28 ja76pf|\
29 mc-mac1200r|\
30 minibox-v1|\
31 mynet-n600|\
32 oolite|\
33 qihoo-c301|\
34 r602n|\
35 rb-750|\
36 rb-751|\
37 som9331|\
38 tew-632brp|\
39 tew-712br|\
40 tew-732br|\
41 tl-mr3220|\
42 tl-mr3220-v2|\
43 tl-mr3420|\
44 tl-wdr3320-v2|\
45 tl-wdr3500|\
46 tl-wr741nd|\
47 tl-wr741nd-v4|\
48 tl-wr840n-v2|\
49 tl-wr840n-v3|\
50 tl-wr841n-v11|\
51 tl-wr841n-v9|\
52 tl-wr842n-v3|\
53 whr-g301n|\
54 whr-hp-g300n|\
55 whr-hp-gn|\
56 wzr-hp-ag300h|\
57 zbt-we1526)
58 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
59 ucidef_add_switch "switch0" \
60 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
61 ;;
62 alfa-ap120c|\
63 all0305|\
64 antminer-s1|\
65 antminer-s3|\
66 antrouter-r1|\
67 aw-nr580|\
68 bullet-m|\
69 c-55|\
70 cap4200ag|\
71 cf-e380ac-v1|\
72 cf-e380ac-v2|\
73 eap120|\
74 eap300v2|\
75 eap7660d|\
76 el-mini|\
77 loco-m-xw|\
78 mr12|\
79 mr16|\
80 mr1750|\
81 mr1750v2|\
82 mr18|\
83 mr600|\
84 mr600v2|\
85 mr900|\
86 mr900v2|\
87 mynet-rext|\
88 pqi-air-pen|\
89 rb-411|\
90 rb-411u|\
91 rb-911g-2hpnd|\
92 rb-911g-5hpacd|\
93 rb-911g-5hpnd|\
94 rb-912uag-2hpnd|\
95 rb-912uag-5hpnd|\
96 rb-lhg-5nd|\
97 rb-mapl-2nd|\
98 rb-sxt2n|\
99 rb-sxt5n|\
100 re450|\
101 rocket-m-xw|\
102 sc300m |\
103 tl-mr10u|\
104 tl-mr11u|\
105 tl-mr12u|\
106 tl-mr13u|\
107 tl-mr3020|\
108 tl-mr3040|\
109 tl-mr3040-v2|\
110 tl-wa701nd-v2|\
111 tl-wa7210n-v2|\
112 tl-wa750re|\
113 tl-wa801nd-v2|\
114 tl-wa830re-v2|\
115 tl-wa850re|\
116 tl-wa850re-v2|\
117 tl-wa901nd|\
118 tl-wa901nd-v2|\
119 tl-wa901nd-v3|\
120 tl-wa901nd-v4|\
121 tl-wr703n|\
122 tl-wr802n-v1|\
123 tl-wr802n-v2|\
124 tube2h|\
125 unifiac-lite|\
126 wndap360|\
127 wp543)
128 ucidef_set_interface_lan "eth0"
129 ;;
130 a40|\
131 a60|\
132 alfa-ap96|\
133 alfa-nx|\
134 gl-ar150|\
135 gl-ar300m|\
136 gl-domino|\
137 gl-inet|\
138 gl-mifi|\
139 jwap003|\
140 om2pv4|\
141 om2p-hsv4|\
142 pb42|\
143 pb44|\
144 rb-750-r2|\
145 rb-750up-r2|\
146 rb-951ui-2hnd|\
147 rb-951ui-2nd|\
148 rb-952ui-5ac2nd|\
149 routerstation|\
150 tl-wr710n|\
151 tl-wr720n-v3|\
152 tl-wr810n|\
153 wpe72|\
154 wrtnode2q)
155 ucidef_set_interfaces_lan_wan "eth1" "eth0"
156 ;;
157 all0258n|\
158 all0315n|\
159 dlan-hotspot|\
160 dlan-pro-500-wp|\
161 dr344|\
162 ja76pf2|\
163 rocket-m-ti|\
164 ubnt-unifi-outdoor)
165 ucidef_set_interface_lan "eth0 eth1"
166 ;;
167 wzr-hp-g300nh2)
168 ucidef_add_switch "switch0" \
169 "0@eth0" "1:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "2:wan"
170 ;;
171 ap132|\
172 ap136|\
173 ap152|\
174 rb-750gl|\
175 rb-751g|\
176 rb-951g-2hnd|\
177 rb-962uigs-5hact2hnt|\
178 wlr8100|\
179 wzr-hp-g450h)
180 ucidef_add_switch "switch0" \
181 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
182 ;;
183 ap135-020|\
184 ap136-020|\
185 bhr-4grv2|\
186 tew-823dru|\
187 tl-wr1043nd-v2|\
188 wzr-450hp2)
189 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
190 ucidef_add_switch "switch0" \
191 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
192 ;;
193 ap136-010|\
194 ap147-010|\
195 nbg6616|\
196 nbg6716)
197 ucidef_set_interfaces_lan_wan "eth0.1" "eth1.2"
198 ucidef_add_switch "switch0" \
199 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth1"
200 ;;
201 ap143|\
202 rb-433|\
203 rb-433u)
204 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
205 ucidef_add_switch "switch0" \
206 "1:lan" "2:lan" "5@eth1"
207 ;;
208 archer-c5|\
209 archer-c7|\
210 tl-wdr4900-v2)
211 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
212 ucidef_add_switch "switch0" \
213 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
214 ;;
215 archer-c59-v1|\
216 rb-450g)
217 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
218 ucidef_add_switch "switch0" \
219 "0@eth1" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
220 ;;
221 archer-c60-v1)
222 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
223 ucidef_add_switch "switch0" \
224 "0@eth1" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
225 ;;
226 arduino-yun|\
227 dir-505-a1|\
228 tl-wa801nd-v3)
229 ucidef_set_interface_lan "eth1"
230 ;;
231 bsb)
232 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
233 ucidef_add_switch "switch0" \
234 "0@eth1" "1:lan" "3:lan"
235 ;;
236 c-60)
237 ucidef_add_switch "switch0" \
238 "0@eth0" "3:wan" "4:lan"
239 ;;
240 cap324)
241 ucidef_set_interface_lan "eth0" "dhcp"
242 ;;
243 cpe210|\
244 cpe510|\
245 wbs210|\
246 wbs510)
247 ucidef_add_switch "switch0" \
248 "0@eth0" "5:lan" "4:wan"
249 ;;
250 cr3000)
251 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
252 ucidef_add_switch "switch0" \
253 "0@eth0" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
254 ;;
255 cr5000|\
256 dgl-5500-a1|\
257 dhp-1565-a1|\
258 dir-825-c1|\
259 dir-835-a1|\
260 esr900|\
261 mynet-n750|\
262 sr3200|\
263 wndr3700v4)
264 ucidef_add_switch "switch0" \
265 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
266 ;;
267 dap-2695-a1)
268 ucidef_add_switch "switch0" "0@eth0" "2:lan" "3:wan" "6@eth1"
269 ;;
270 rb-941-2nd)
271 ucidef_add_switch "switch0" \
272 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:wan:1"
273 ;;
274 db120|\
275 rb-2011l|\
276 rb-2011uas|\
277 rb-2011uas-2hnd|\
278 rb-2011uias|\
279 rb-2011uias-2hnd)
280 case "$board" in
281 rb-2011uas*|\
282 rb-2011uias|\
283 rb-2011uias-2hnd)
284 ucidef_add_switch "switch0" \
285 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan" "6:sfp"
286 ;;
287 *)
288 ucidef_add_switch "switch0" \
289 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
290 ;;
291 esac
292
293 ucidef_add_switch "switch1" \
294 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:lan"
295 ;;
296 dir-615-i1|\
297 omy-g1|\
298 r6100|\
299 smart-300|\
300 tl-mr3420-v2|\
301 tl-wdr6500-v2|\
302 tl-wr841n-v8|\
303 tl-wr940n-v4|\
304 tl-wr941nd-v5|\
305 tl-wr941nd-v6|\
306 wnr1000-v2|\
307 wnr2000-v4|\
308 wnr2200|\
309 wnr612-v2|\
310 wpn824n)
311 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
312 ucidef_add_switch "switch0" \
313 "0@eth1" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
314 ;;
315 dir-825-b1|\
316 nbg460n_550n_550nh|\
317 tew-673gru|\
318 wzr-hp-g300nh)
319 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
320 ucidef_add_switch "switch0" \
321 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
322 ;;
323 dlan-pro-1200-ac)
324 ucidef_set_interface_lan "eth0"
325 ucidef_add_switch "switch0" \
326 "0u@eth0" "2:lan" "3:lan" "4:lan"
327 ucidef_add_switch_attr "switch0" "enable" "false"
328 ;;
329 ebr-2310-c1)
330 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
331 ucidef_add_switch "switch0" \
332 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
333 ;;
334 el-m150)
335 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
336 ucidef_add_switch "switch0" \
337 "0:lan" "1:lan" "3@eth1"
338 ;;
339 dir-869-a1|\
340 epg5000|\
341 esr1750|\
342 tl-wr1043nd-v4|\
343 wndr4300)
344 ucidef_add_switch "switch0" \
345 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
346 ;;
347 ew-dorin)
348 ucidef_add_switch "switch0" \
349 "0@eth0" "1:lan" "2:lan" "3:wan"
350 ;;
351 ew-dorin-router)
352 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
353 ucidef_add_switch "switch0" \
354 "0@eth0" "2:lan" "3:lan"
355 ;;
356 dw33d|\
357 f9k1115v2)
358 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
359 ucidef_add_switch "switch0" \
360 "2:lan" "3:lan" "4:lan" "5:lan" "6@eth1" "0@eth0" "1:wan"
361 ;;
362 gl-ar300|\
363 wnr2000-v3)
364 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
365 ucidef_add_switch "switch0" \
366 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
367 ;;
368 jwap230)
369 ucidef_set_interfaces_lan_wan "eth0.1" "eth1.2"
370 ucidef_add_switch "switch0" \
371 "0@eth0" "1:lan" "5:wan" "6@eth1"
372 ;;
373 nanostation-m-xw)
374 ucidef_add_switch "switch0" \
375 "0@eth0" "5:lan" "1:wan"
376 ;;
377 onion-omega)
378 ucidef_set_interface_lan "wlan0"
379 ;;
380 rb-435g)
381 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
382 ucidef_add_switch "switch0" \
383 "0@eth1" "1:lan" "2:lan"
384 ;;
385 rb-450)
386 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
387 ucidef_add_switch "switch0" \
388 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5@eth1"
389 ;;
390 routerstation-pro)
391 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
392 ucidef_add_switch "switch0" \
393 "0@eth1" "2:lan:3" "3:lan:2" "4:lan:1"
394 ;;
395 rb-493g)
396 ucidef_set_interfaces_lan_wan "eth0.1 eth1.1" "eth1.2"
397 ucidef_add_switch "switch0" \
398 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
399 ucidef_add_switch "switch1" \
400 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
401 ;;
402 tellstick-znet-lite)
403 ucidef_set_interface_wan "eth0"
404 ucidef_set_interface_raw "wlan" "wlan0" "dhcp"
405 ;;
406 tl-wdr4300|\
407 tl-wr1041n-v2)
408 ucidef_add_switch "switch0" \
409 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
410 ;;
411 tl-wpa8630)
412 ucidef_add_switch "switch0" \
413 "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1" "5:lan:4"
414 ;;
415 tl-wr1043nd)
416 ucidef_add_switch "switch0" \
417 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
418 ;;
419 tl-wr2543n)
420 ucidef_add_switch "switch0" \
421 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
422 ;;
423 tl-wr841n-v1|\
424 tl-wr941nd)
425 ucidef_set_interface_raw "eth" "eth0"
426 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
427 ;;
428 tl-wr841n-v7)
429 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
430 ucidef_add_switch "switch0" \
431 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
432 ;;
433 tl-wr842n-v2)
434 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
435 ucidef_add_switch "switch0" \
436 "0@eth1" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
437 ;;
438 uap-pro|\
439 wpj342)
440 ucidef_add_switch "switch0" \
441 "0@eth0" "1:lan" "2:wan"
442 ;;
443 unifiac-pro|\
444 xd3200)
445 ucidef_add_switch "switch0" \
446 "0@eth0" "2:lan" "3:wan"
447 ;;
448 wndr3700|\
449 wndr3700v2|\
450 wndr3800|\
451 wndr3800ch)
452 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
453 ucidef_add_switch "switch0" \
454 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5@eth0"
455
456 ucidef_add_switch_attr "switch0" "blinkrate" 2
457 ucidef_add_switch_port_attr "switch0" 1 led 6
458 ucidef_add_switch_port_attr "switch0" 2 led 9
459 ucidef_add_switch_port_attr "switch0" 5 led 2
460 ;;
461 wpj344)
462 ucidef_add_switch "switch0" \
463 "0@eth0" "3:lan" "2:wan"
464 ;;
465 wpj558)
466 ucidef_add_switch "switch0" \
467 "5:lan" "1:wan" "6@eth0"
468 ;;
469 wpj563)
470 ucidef_add_switch "switch0" \
471 "0@eth0" "2:lan" "3:wan"
472 ;;
473 wrt160nl)
474 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
475 ucidef_add_switch "switch0" \
476 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4@eth0"
477 ;;
478 wzr-hp-g450h)
479 ucidef_add_switch "switch0" \
480 "0@eth0" "2:lan:1 3:lan:2 4:lan:3 5:lan:4" "1:wan"
481 ;;
482 z1)
483 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
484 ucidef_add_switch "switch0" \
485 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4" "5:wan"
486 ;;
487 *)
488 ucidef_set_interfaces_lan_wan "eth0" "eth1"
489 ;;
490 esac
491 }
492
493 ar71xx_setup_macs()
494 {
495 local board="$1"
496 local lan_mac=""
497 local wan_mac=""
498
499 case $board in
500 dgl-5500-a1|\
501 dir-825-c1)
502 wan_mac=$(mtd_get_mac_ascii nvram "wan_mac")
503 ;;
504 dhp-1565-a1|\
505 dir-835-a1|\
506 wndr3700v4|\
507 wndr4300)
508 lan_mac=$(mtd_get_mac_binary caldata 0)
509 wan_mac=$(mtd_get_mac_binary caldata 6)
510 ;;
511 tl-wr1043nd-v4)
512 wan_mac=$(mtd_get_mac_binary config 0x1017c)
513 ;;
514 esr900)
515 wan_mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
516 ;;
517 dir-869-a1|\
518 mynet-n750)
519 wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
520 ;;
521 esac
522
523 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
524 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
525 }
526
527 board_config_update
528 board=$(ar71xx_board_name)
529 ar71xx_setup_interfaces $board
530 ar71xx_setup_macs $board
531 board_config_flush
532
533 exit 0