ramips: add support for RT-N14U (mt7620n based) board
[openwrt/openwrt.git] / target / linux / ramips / base-files / etc / uci-defaults / 02_network
1 #!/bin/sh
2
3 . /lib/functions.sh
4 . /lib/ramips.sh
5 . /lib/functions/uci-defaults.sh
6
7 ramips_setup_rt3x5x_vlans()
8 {
9 if [ ! -x /sbin/swconfig ]; then
10 # legacy default
11 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
12 return
13 fi
14 local wanports=""
15 local lanports=""
16 for port in 5 4 3 2 1 0; do
17 if [ `swconfig dev rt305x port $port get disable` = "1" ]; then
18 continue
19 fi
20 if [ `swconfig dev rt305x port $port get lan` = "0" ]; then
21 wanports="$port $wanports"
22 else
23 lanports="$port $lanports"
24 fi
25 done
26 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
27 ucidef_add_switch "rt305x" "1" "1"
28 ucidef_add_switch_vlan "rt305x" "1" "$lanports 6t"
29 ucidef_add_switch_vlan "rt305x" "2" "$wanports 6t"
30 }
31
32 ramips_setup_interfaces()
33 {
34 local board="$1"
35
36 ucidef_set_interface_loopback
37
38 case $board in
39 3g300m | \
40 w150m | \
41 all0256n | \
42 all5002 | \
43 all5003 | \
44 awm002-evb | \
45 broadway | \
46 dcs-930| \
47 wnce2001)
48 ucidef_add_switch "switch0" "1" "0"
49 ucidef_set_interface_lan "eth0"
50 ;;
51
52 3g-6200nl | \
53 wl-330n | \
54 wmr300)
55 ucidef_set_interface_lan "eth0.1"
56 ;;
57
58 3g-6200n | \
59 b2c | \
60 nw718 | \
61 psr-680w | \
62 sl-r7205 | \
63 w502u | \
64 wr6202)
65 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
66 ;;
67
68 asl26555)
69 ucidef_set_interface_lan "eth0.1"
70 ucidef_add_switch "switch0" "1" "1"
71 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
72 ;;
73
74 dir-610-a1 | \
75 dir-300-b7 | \
76 dir-320-b1 | \
77 dir-615-h1 | \
78 mzk-w300nh2)
79 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
80 ucidef_add_switch "switch0" "1" "1"
81 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
82 ucidef_add_switch_vlan "switch0" "2" "4 6t"
83 ;;
84
85 argus-atp52b | \
86 dir-645 | \
87 f5d8235-v1 | \
88 f5d8235-v2 | \
89 hg255d | \
90 rt-n14u | \
91 ur-326n4g)
92 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
93 ucidef_add_switch "switch0" "1" "1"
94 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
95 ucidef_add_switch_vlan "switch0" "2" "0 6t"
96 ;;
97
98 ur-336un)
99 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
100 ;;
101
102 br6524n | \
103 v11st-fe)
104 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
105 ucidef_add_switch "switch0" "1" "1"
106 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
107 ucidef_add_switch_vlan "switch0" "2" "0 5t"
108 ;;
109
110 rt-n15 | \
111 wl-351)
112 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
113 ucidef_add_switch "switch0" "1" "1"
114 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
115 ucidef_add_switch_vlan "switch0" "2" "4 5t"
116 ;;
117
118 rt-n56u)
119 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
120 ucidef_add_switch "switch0" "1" "1"
121 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t"
122 ucidef_add_switch_vlan "switch0" "2" "4 8t"
123 ;;
124
125 tew-691gr|\
126 tew-692gr)
127 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
128 ucidef_add_switch "switch0" "1" "1"
129 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
130 ucidef_add_switch_vlan "switch0" "2" "0t 5"
131 ;;
132
133 wcr-150gn)
134 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
135 ucidef_add_switch "switch0" "1" "1"
136 ucidef_add_switch_vlan "switch0" "1" "0 6t"
137 ucidef_add_switch_vlan "switch0" "2" "6t"
138 ;;
139
140 d105 | \
141 omni-emb-hpm|\
142 wli-tx4-ag300n)
143 ucidef_set_interface_lan "eth0"
144 ;;
145
146 *)
147 RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
148 if [ -n "${RT3X5X}" ]; then
149 ramips_setup_rt3x5x_vlans
150 else
151 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
152 fi
153 ;;
154 esac
155 }
156
157 ramips_setup_macs()
158 {
159 local board="$1"
160 local lan_mac=""
161 local wan_mac=""
162
163 case $board in
164 *)
165 wan_mac=$(macaddr_add "$lan_mac" 1)
166 ;;
167
168 w306r-v20)
169 wan_mac=$(macaddr_add "$lan_mac" 5)
170 ;;
171
172 tew-691gr)
173 wan_mac=$(macaddr_add "$lan_mac" 3)
174 ;;
175
176 tew-692gr)
177 wan_mac=$(macaddr_add "$lan_mac" 4)
178 ;;
179
180 m3 |\
181 m4 |\
182 x5 |\
183 x8)
184 lan_mac=$(macaddr_add "$lan_mac" -1)
185 ;;
186
187 dir-620-a1)
188 lan_mac=$(macaddr_setbit_la "$lan_mac")
189 wan_mac=$(macaddr_add "$lan_mac" 1)
190 ;;
191
192 dir-645)
193 lan_mac=$(mtd_get_mac_ascii nvram lanmac)
194 wan_mac=$(mtd_get_mac_ascii nvram wanmac)
195 ;;
196
197 nbg-419n | \
198 wcr-150gn)
199 wan_mac=$(mtd_get_mac_binary factory 40)
200 ;;
201
202 rt-n56u)
203 wan_mac=$(mtd_get_mac_binary factory 32772)
204 ;;
205
206 all0239-3g | \
207 carambola | \
208 freestation5 | \
209 w502u | \
210 wnce2001)
211 wan_mac=$(mtd_get_mac_binary factory 46)
212 ;;
213
214 wl341v3)
215 lan_mac=$(mtd_get_mac_binary board-nvram 65440)
216 wan_mac=$(macaddr_add "$lan_mac" 1)
217 ;;
218
219 esac
220
221 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
222 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
223 }
224
225 [ -e /etc/config/network ] && exit 0
226
227 touch /etc/config/network
228
229 board=$(ramips_board_name)
230
231 ramips_setup_interfaces $board
232 ramips_setup_macs $board
233
234 uci commit network
235
236 exit 0