ramips: add support for Tenda 3G150B
[openwrt/svn-archive/archive.git] / target / linux / ramips / base-files / etc / board.d / 02_network
1 #!/bin/sh
2
3 . /lib/functions.sh
4 . /lib/ramips.sh
5 . /lib/functions/uci-defaults-new.sh
6 . /lib/functions/system.sh
7
8 ramips_setup_rt3x5x_vlans()
9 {
10 if [ ! -x /sbin/swconfig ]; then
11 # legacy default
12 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
13 return
14 fi
15 local wanports=""
16 local lanports=""
17 for port in 5 4 3 2 1 0; do
18 if [ `swconfig dev rt305x port $port get disable` = "1" ]; then
19 continue
20 fi
21 if [ `swconfig dev rt305x port $port get lan` = "0" ]; then
22 wanports="$port $wanports"
23 else
24 lanports="$port $lanports"
25 fi
26 done
27 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
28 ucidef_add_switch "rt305x" "1" "1"
29 ucidef_add_switch_vlan "rt305x" "1" "$lanports 6t"
30 ucidef_add_switch_vlan "rt305x" "2" "$wanports 6t"
31 }
32
33 ramips_setup_interfaces()
34 {
35 local board="$1"
36
37 ucidef_set_interface_loopback
38
39 case $board in
40 a5-v11)
41 ucidef_set_interface_lan "eth0.1"
42 ucidef_add_switch "switch0" "1" "1"
43 ucidef_add_switch_vlan "switch0" "1" "0 6t"
44 ;;
45
46 3g150b | \
47 3g300m | \
48 w150m | \
49 all0256n | \
50 all5002 | \
51 all5003 | \
52 broadway | \
53 dcs-930| \
54 ht-tm02| \
55 ncs601w | \
56 wnce2001)
57 ucidef_add_switch "switch0" "1" "0"
58 ucidef_set_interface_lan "eth0"
59 ;;
60
61 3g-6200nl | \
62 mlw221)
63 ucidef_set_interface_lan "eth0.2"
64 ;;
65 mlwg2)
66 ucidef_set_interface_lan "eth0.1"
67 ;;
68
69 m2m)
70 ucidef_add_switch "switch0" "4"
71 ucidef_set_interface_lan "eth0"
72 ;;
73
74 wizard8800 | \
75 wl-330n | \
76 wmr300)
77 ucidef_set_interface_lan "eth0.1"
78 ;;
79
80 b2c | \
81 nw718 | \
82 psr-680w | \
83 sl-r7205 | \
84 w502u | \
85 wr6202)
86 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
87 ;;
88
89 awapn2403)
90 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
91 ucidef_add_switch "switch0" "1" "1"
92 ucidef_add_switch_vlan "switch0" "1" "0 6t"
93 ucidef_add_switch_vlan "switch0" "2" "1 6t"
94 ;;
95
96 br-6475nd)
97 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
98 ucidef_add_switch "switch0" "1" "1"
99 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 9t"
100 ucidef_add_switch_vlan "switch0" "2" "0 9t"
101 ;;
102
103 asl26555)
104 ucidef_set_interface_lan "eth0.1"
105 ucidef_add_switch "switch0" "1" "1"
106 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
107 ;;
108
109 cy-swr1100)
110 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
111 ucidef_add_switch "switch0" "1" "1"
112 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 9t"
113 ucidef_add_switch_vlan "switch0" "2" "4 9t"
114 ;;
115
116 3g-6200n | \
117 ai-br100 | \
118 dir-610-a1 | \
119 dir-300-b7 | \
120 dir-320-b1 | \
121 dir-615-h1 | \
122 firewrt | \
123 hlk-rm04 | \
124 mt7621 | \
125 mt7628 | \
126 mzk-w300nh2 | \
127 mzk-750dhp | \
128 whr-300hp2 | \
129 whr-600d | \
130 wsr-600 | \
131 wsr-1166 | \
132 wt1520 | \
133 y1)
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 1 2 3 6t"
137 ucidef_add_switch_vlan "switch0" "2" "4 6t"
138 ;;
139
140 whr-1166d)
141 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
142 ucidef_add_switch "switch0" "1" "1"
143 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
144 ucidef_add_switch_vlan "switch0" "2" "5 6t"
145 ;;
146
147 awm002-evb | \
148 awm003-evb | \
149 argus-atp52b | \
150 dir-645 | \
151 dir-860l-b1 | \
152 f5d8235-v1 | \
153 f5d8235-v2 | \
154 hg255d | \
155 rt-n14u | \
156 wrtnode | \
157 wt3020 | \
158 ur-326n4g | \
159 zbt-wa05)
160 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
161 ucidef_add_switch "switch0" "1" "1"
162 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
163 ucidef_add_switch_vlan "switch0" "2" "0 6t"
164 ;;
165
166 ur-336un)
167 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
168 ;;
169
170 br6524n | \
171 v11st-fe)
172 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
173 ucidef_add_switch "switch0" "1" "1"
174 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
175 ucidef_add_switch_vlan "switch0" "2" "0 5t"
176 ;;
177
178 ar670w | \
179 ar725w | \
180 rt-n15 | \
181 wl-351)
182 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
183 ucidef_add_switch "switch0" "1" "1"
184 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
185 ucidef_add_switch_vlan "switch0" "2" "4 5t"
186 ;;
187
188 rt-n56u)
189 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
190 ucidef_add_switch "switch0" "1" "1"
191 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t"
192 ucidef_add_switch_vlan "switch0" "2" "4 8t"
193 ;;
194
195 tew-691gr|\
196 tew-692gr)
197 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
198 ucidef_add_switch "switch0" "1" "1"
199 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
200 ucidef_add_switch_vlan "switch0" "2" "0t 5"
201 ;;
202
203 vocore)
204 ucidef_set_interface_lan "eth0.1"
205 ucidef_add_switch "switch0" "1" "1"
206 ucidef_add_switch_vlan "switch0" "1" "0 4 6t"
207 ;;
208
209 wcr-150gn)
210 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
211 ucidef_add_switch "switch0" "1" "1"
212 ucidef_add_switch_vlan "switch0" "1" "0 6t"
213 ucidef_add_switch_vlan "switch0" "2" "6t"
214 ;;
215
216 wr8305rt)
217 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
218 ucidef_add_switch "switch0" "1" "1"
219 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4 6t"
220 ucidef_add_switch_vlan "switch0" "2" "4 6t"
221 ;;
222
223 y1s)
224 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
225 ucidef_add_switch "switch0" "1" "1"
226 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5 6t"
227 ucidef_add_switch_vlan "switch0" "2" "0 6t"
228 ;;
229 d105 | \
230 na930 | \
231 omni-emb-hpm|\
232 wli-tx4-ag300n)
233 ucidef_set_interface_lan "eth0"
234 ;;
235
236 e1700 | \
237 mt7620a_mt7530)
238 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
239 ucidef_add_switch "switch1" "1" "1"
240 ucidef_add_switch_vlan "switch1" "1" "0 1 2 3 6t"
241 ucidef_add_switch_vlan "switch1" "2" "4 6t"
242 ;;
243
244 *)
245 RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
246 if [ -n "${RT3X5X}" ]; then
247 ramips_setup_rt3x5x_vlans
248 else
249 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
250 fi
251 ;;
252 esac
253 }
254
255 ramips_setup_macs()
256 {
257 local board="$1"
258 local lan_mac=""
259 local wan_mac=""
260
261 case $board in
262 br-6475nd)
263 lan_mac=$(cat /sys/class/net/eth0/address)
264 wan_mac=$(mtd_get_mac_binary devdata 7)
265 ;;
266
267 w306r-v20)
268 lan_mac=$(cat /sys/class/net/eth0/address)
269 wan_mac=$(macaddr_add "$lan_mac" 5)
270 ;;
271
272 tew-691gr)
273 lan_mac=$(cat /sys/class/net/eth0/address)
274 wan_mac=$(macaddr_add "$lan_mac" 3)
275 ;;
276
277 tew-692gr)
278 lan_mac=$(cat /sys/class/net/eth0/address)
279 wan_mac=$(macaddr_add "$lan_mac" 4)
280 ;;
281
282 m3 |\
283 m4 |\
284 x5 |\
285 x8)
286 lan_mac=$(cat /sys/class/net/eth0/address)
287 lan_mac=$(macaddr_add "$lan_mac" -2)
288 ;;
289
290 a5-v11 |\
291 bc2 |\
292 broadway |\
293 d105 |\
294 dir-620-a1 |\
295 esr-9753 |\
296 freestation5 |\
297 hlk-rm04 | \
298 mpr-a1 | \
299 mpr-a2 | \
300 dir-300-b7 | \
301 dir-320-b1 | \
302 psr-680w |\
303 sl-r7205 |\
304 y1 |\
305 y1s)
306 lan_mac=$(cat /sys/class/net/eth0/address)
307 lan_mac=$(macaddr_setbit_la "$lan_mac")
308 wan_mac=$(macaddr_add "$lan_mac" 1)
309 ;;
310
311 ht-tm02)
312 lan_mac=$(cat /sys/class/net/eth0/address)
313 ;;
314
315 cy-swr1100 | \
316 dir-645)
317 lan_mac=$(mtd_get_mac_ascii nvram lanmac)
318 wan_mac=$(mtd_get_mac_ascii nvram wanmac)
319 ;;
320
321 e1700)
322 wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
323 ;;
324
325 wcr-150gn)
326 wan_mac=$(mtd_get_mac_binary factory 40)
327 ;;
328
329 rt-n56u)
330 lan_mac=$(cat /sys/class/net/eth0/address)
331 lan_mac=$(macaddr_setbit_la "$lan_mac")
332 wan_mac=$(mtd_get_mac_binary factory 32772)
333 ;;
334
335 all0239-3g | \
336 carambola | \
337 freestation5 | \
338 w502u | \
339 wnce2001)
340 wan_mac=$(mtd_get_mac_binary factory 46)
341 ;;
342
343 *)
344 lan_mac=$(cat /sys/class/net/eth0/address)
345 wan_mac=$(macaddr_add "$lan_mac" 1)
346 ;;
347
348 esac
349
350 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
351 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
352 }
353
354 board_config_update
355 board=$(ramips_board_name)
356 ramips_setup_interfaces $board
357 ramips_setup_macs $board
358 board_config_flush
359
360 exit 0