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