122c1a103d907a20bdb8136942941ca75cb3c350
[openwrt/openwrt.git] / target / linux / ipq40xx / base-files / etc / board.d / 02_network
1 #!/bin/sh
2 #
3 # Copyright (c) 2015 The Linux Foundation. All rights reserved.
4 # Copyright (c) 2011-2015 OpenWrt.org
5 #
6
7 . /lib/functions/uci-defaults.sh
8 . /lib/functions/system.sh
9
10 ipq40xx_setup_interfaces()
11 {
12 local board="$1"
13
14 case "$board" in
15 8dev,jalapeno|\
16 alfa-network,ap120c-ac|\
17 engenius,ens620ext)
18 ucidef_set_interfaces_lan_wan "eth0" "eth1"
19 ;;
20 asus,map-ac2200|\
21 cilab,meshpoint-one|\
22 openmesh,a42|\
23 openmesh,a62)
24 ucidef_set_interfaces_lan_wan "eth1" "eth0"
25 ;;
26 asus,rt-ac58u|\
27 zyxel,nbg6617)
28 ucidef_set_interfaces_lan_wan "eth0" "eth1"
29 ucidef_add_switch "switch0" \
30 "0u@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
31 ;;
32 avm,fritzbox-4040|\
33 linksys,ea6350v3|\
34 linksys,ea8300)
35 ucidef_set_interfaces_lan_wan "eth0" "eth1"
36 ucidef_add_switch "switch0" \
37 "0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
38 ;;
39 avm,fritzbox-7530)
40 ucidef_add_switch "switch0" \
41 "0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
42 ;;
43 avm,fritzrepeater-1200|\
44 engenius,eap1300|\
45 meraki,mr33|\
46 netgear,ex6100v2|\
47 netgear,ex6150v2|\
48 zyxel,wre6606)
49 ucidef_set_interface_lan "eth0"
50 ;;
51 avm,fritzrepeater-3000|\
52 compex,wpj419|\
53 compex,wpj428)
54 ucidef_set_interface_lan "eth0 eth1"
55 ;;
56 glinet,gl-b1300)
57 ucidef_set_interfaces_lan_wan "eth0" "eth1"
58 ucidef_add_switch "switch0" \
59 "0u@eth0" "3:lan" "4:lan"
60 ;;
61 qxwlan,e2600ac-c1 |\
62 qxwlan,e2600ac-c2)
63 ucidef_set_interfaces_lan_wan "eth0" "eth1"
64 ucidef_add_switch "switch0" \
65 "0u@eth0" "3:lan" "4:lan" "0u@eth1" "5:wan"
66 ;;
67 unielec,u4019-32m)
68 ucidef_set_interfaces_lan_wan "eth0" "eth1"
69 ucidef_add_switch "switch0" \
70 "0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "0u@eth1" "5:wan"
71 ;;
72 *)
73 echo "Unsupported hardware. Network interfaces not initialized"
74 ;;
75 esac
76 }
77
78 ipq40xx_setup_macs()
79 {
80 local board="$1"
81
82 case "$board" in
83 asus,rt-ac58u)
84 CI_UBIPART=UBI_DEV
85 wan_mac=$(mtd_get_mac_binary_ubi Factory 0x5006)
86 lan_mac=$(mtd_get_mac_binary_ubi Factory 0x1006)
87 ;;
88 cilab,meshpoint-one)
89 label_mac=$(mtd_get_mac_binary "ART" 0x1006)
90 ;;
91 engenius,ens620ext)
92 wan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
93 lan_mac=$(macaddr_add "$wan_mac" 1)
94 ;;
95 linksys,ea6350v3)
96 wan_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
97 lan_mac=$(macaddr_add "$wan_mac" 1)
98 ;;
99 esac
100
101 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
102 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
103 [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
104 }
105
106 board_config_update
107 board=$(board_name)
108 ipq40xx_setup_interfaces $board
109 ipq40xx_setup_macs $board
110 board_config_flush
111
112 exit 0