ipq806x: reorganize 02_network board.d script
[openwrt/staging/neocturne.git] / target / linux / ipq806x / base-files / etc / board.d / 02_network
1 #
2 # Copyright (c) 2015 The Linux Foundation. All rights reserved.
3 # Copyright (c) 2011-2015 OpenWrt.org
4 #
5
6 . /lib/functions/uci-defaults.sh
7 . /lib/functions/system.sh
8
9 ipq806x_setup_interfaces()
10 {
11 local board="$1"
12
13 case "$board" in
14 arris,tr4400-v2)
15 ucidef_set_interfaces_lan_wan "eth1" "eth2"
16 ucidef_add_switch "switch0" \
17 "1:lan" "2:lan" "3:lan" "4:lan" "6u@eth1" "0u@eth0"
18 ;;
19 askey,rt4230w-rev6 |\
20 asrock,g10 |\
21 nec,wg2600hp)
22 ucidef_add_switch "switch0" \
23 "2:lan" "3:lan" "4:lan" "5:lan" "6@eth1" "1:wan" "0@eth0"
24 ;;
25 buffalo,wxr-2533dhp |\
26 compex,wpq864 |\
27 netgear,d7800 |\
28 netgear,r7500 |\
29 netgear,r7500v2 |\
30 qcom,ipq8064-ap148)
31 ucidef_add_switch "switch0" \
32 "1:lan" "2:lan" "3:lan" "4:lan" "6@eth1" "5:wan" "0@eth0"
33 ;;
34 edgecore,ecw5410)
35 ucidef_set_interfaces_lan_wan "eth1" "eth0"
36 ;;
37 linksys,ea7500-v1)
38 ucidef_add_switch "switch0" \
39 "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "6@eth1" "1:wan" "0@eth0"
40 ;;
41 linksys,ea8500)
42 ucidef_add_switch "switch0" \
43 "1:lan" "2:lan" "3:lan" "4:lan" "6@eth1" "5:wan" "0@eth0"
44 ;;
45 meraki,mr42)
46 ucidef_set_interface_lan "eth0"
47 ;;
48 meraki,mr52)
49 ucidef_set_interfaces_lan_wan "eth0" "eth1"
50 ;;
51 nec,wg2600hp3)
52 ucidef_add_switch "switch0" \
53 "2:lan" "3:lan" "4:lan" "5:lan" "0@eth1" "1:wan" "6@eth0"
54 ;;
55 netgear,r7800 |\
56 netgear,xr450 |\
57 netgear,xr500 |\
58 tplink,c2600 |\
59 tplink,vr2600v)
60 ucidef_add_switch "switch0" \
61 "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "6@eth1" "5:wan" "0@eth0"
62 ;;
63 qcom,ipq8064-ap161)
64 ucidef_set_interface_lan "eth1 eth2"
65 ucidef_add_switch "switch0" \
66 "0:lan" "1:lan" "2:lan" "3u@eth1" "6:wan" "4u@eth0"
67 ;;
68 qcom,ipq8064-db149)
69 ucidef_set_interface_lan "eth1 eth2 eth3"
70 ucidef_add_switch "switch0" \
71 "1:lan" "2:lan" "3:lan" "4:lan" "6u@eth1" "5:wan" "0u@eth0"
72 ;;
73 tplink,ad7200)
74 ucidef_add_switch "switch0" \
75 "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "6@eth1" "1:wan" "0@eth0"
76 ;;
77 asus,onhub |\
78 tplink,onhub)
79 ucidef_set_interfaces_lan_wan "eth1" "eth0"
80 ucidef_add_switch "switch0" \
81 "1:lan" "6@eth1" "2:wan" "0@eth0"
82 ;;
83 nokia,ac400i |\
84 ubnt,unifi-ac-hd)
85 ucidef_set_interface_lan "eth0 eth1"
86 ;;
87 zyxel,nbg6817)
88 ucidef_add_switch "switch0" \
89 "1:lan" "2:lan" "3:lan" "4:lan" "6@eth1" "5:wan" "0@eth0"
90 ;;
91 *)
92 echo "Unsupported hardware. Network interfaces not intialized"
93 ;;
94 esac
95 }
96
97 ipq806x_setup_mac_address()
98 {
99 local board="$1"
100
101 case "$board" in
102 linksys,ea7500-v1)
103 hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
104 ucidef_set_interface_macaddr "lan" "$hw_mac_addr"
105 ucidef_set_interface_macaddr "wan" "$hw_mac_addr"
106 ;;
107 linksys,ea8500)
108 hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr)
109 ucidef_set_interface_macaddr "lan" "$hw_mac_addr"
110 ucidef_set_interface_macaddr "wan" "$hw_mac_addr"
111 ;;
112 zyxel,nbg6817)
113 hw_mac_addr=$(mtd_get_mac_ascii 0:appsblenv ethaddr)
114 ucidef_set_interface_macaddr "lan" "$(macaddr_add $hw_mac_addr 2)"
115 ucidef_set_interface_macaddr "wan" "$(macaddr_add $hw_mac_addr 3)"
116 ;;
117 esac
118 }
119
120 board_config_update
121
122 board=$(board_name)
123
124 ipq806x_setup_mac_address $board
125 ipq806x_setup_interfaces $board
126
127 board_config_flush
128
129 exit 0