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