ramips: Add support for the D-Link DCS-930 B1
[openwrt/staging/dedeckeh.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 microwrt | \
49 w150m | \
50 zte-q7 | \
51 all0256n | \
52 all5002 | \
53 all5003 | \
54 broadway | \
55 dcs-930| \
56 dcs-930l-b1| \
57 ht-tm02| \
58 ncs601w | \
59 wnce2001)
60 ucidef_add_switch "switch0" "1" "0"
61 ucidef_set_interface_lan "eth0"
62 ;;
63
64 3g-6200nl | \
65 mlw221 | \
66 mr-102n)
67 ucidef_set_interface_lan "eth0.2"
68 ;;
69 mlwg2)
70 ucidef_set_interface_lan "eth0.1"
71 ;;
72
73 m2m)
74 ucidef_add_switch "switch0" "4"
75 ucidef_set_interface_lan "eth0"
76 ;;
77
78 wizard8800 | \
79 wl-330n | \
80 wmr300)
81 ucidef_set_interface_lan "eth0.1"
82 ;;
83
84 b2c | \
85 nw718 | \
86 psr-680w | \
87 sl-r7205 | \
88 w502u | \
89 wr6202)
90 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
91 ;;
92
93 awapn2403)
94 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
95 ucidef_add_switch "switch0" "1" "1"
96 ucidef_add_switch_vlan "switch0" "1" "0 6t"
97 ucidef_add_switch_vlan "switch0" "2" "1 6t"
98 ;;
99
100 br-6475nd)
101 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
102 ucidef_add_switch "switch0" "1" "1"
103 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 9t"
104 ucidef_add_switch_vlan "switch0" "2" "0 9t"
105 ;;
106
107 asl26555)
108 ucidef_set_interface_lan "eth0.1"
109 ucidef_add_switch "switch0" "1" "1"
110 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
111 ;;
112
113 cf-wr800n)
114 ucidef_set_interface_lan "eth0.1"
115 ucidef_add_switch "switch0" "1" "1"
116 ucidef_add_switch_vlan "switch0" "1" "4 6t"
117 ;;
118
119 cy-swr1100)
120 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
121 ucidef_add_switch "switch0" "1" "1"
122 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 9t"
123 ucidef_add_switch_vlan "switch0" "2" "4 9t"
124 ;;
125
126 3g-6200n | \
127 ai-br100 | \
128 dir-610-a1 | \
129 dir-300-b7 | \
130 dir-320-b1 | \
131 dir-615-h1 | \
132 firewrt | \
133 pbr-m1 | \
134 hlk-rm04 | \
135 mt7621 | \
136 mt7628 | \
137 mzk-w300nh2 | \
138 mzk-750dhp | \
139 whr-300hp2 | \
140 whr-600d | \
141 wsr-600 | \
142 wsr-1166 | \
143 wt1520 | \
144 xiaomi-miwifi-mini |\
145 y1)
146 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
147 ucidef_add_switch "switch0" "1" "1"
148 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
149 ucidef_add_switch_vlan "switch0" "2" "4 6t"
150 ;;
151
152 whr-1166d)
153 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
154 ucidef_add_switch "switch0" "1" "1"
155 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
156 ucidef_add_switch_vlan "switch0" "2" "5 6t"
157 ;;
158
159 awm002-evb | \
160 awm003-evb | \
161 argus-atp52b | \
162 dir-645 | \
163 dir-860l-b1 | \
164 f5d8235-v1 | \
165 f5d8235-v2 | \
166 hg255d | \
167 rt-n14u | \
168 wrtnode | \
169 wt3020 | \
170 ur-326n4g | \
171 zbt-wa05)
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 6t"
175 ucidef_add_switch_vlan "switch0" "2" "0 6t"
176 ;;
177
178 ur-336un)
179 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
180 ;;
181
182 br6524n | \
183 v11st-fe)
184 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
185 ucidef_add_switch "switch0" "1" "1"
186 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
187 ucidef_add_switch_vlan "switch0" "2" "0 5t"
188 ;;
189
190 ar670w | \
191 ar725w | \
192 rt-n15 | \
193 wl-351)
194 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
195 ucidef_add_switch "switch0" "1" "1"
196 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
197 ucidef_add_switch_vlan "switch0" "2" "4 5t"
198 ;;
199
200 rt-n56u)
201 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
202 ucidef_add_switch "switch0" "1" "1"
203 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t"
204 ucidef_add_switch_vlan "switch0" "2" "4 8t"
205 ;;
206
207 tew-691gr|\
208 tew-692gr)
209 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
210 ucidef_add_switch "switch0" "1" "1"
211 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
212 ucidef_add_switch_vlan "switch0" "2" "0t 5"
213 ;;
214
215 vocore)
216 ucidef_set_interface_lan "eth0.1"
217 ucidef_add_switch "switch0" "1" "1"
218 ucidef_add_switch_vlan "switch0" "1" "0 4 6t"
219 ;;
220
221 wcr-150gn)
222 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
223 ucidef_add_switch "switch0" "1" "1"
224 ucidef_add_switch_vlan "switch0" "1" "0 6t"
225 ucidef_add_switch_vlan "switch0" "2" "6t"
226 ;;
227
228 wr8305rt)
229 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
230 ucidef_add_switch "switch0" "1" "1"
231 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4 6t"
232 ucidef_add_switch_vlan "switch0" "2" "4 6t"
233 ;;
234
235 y1s)
236 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
237 ucidef_add_switch "switch0" "1" "1"
238 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5 6t"
239 ucidef_add_switch_vlan "switch0" "2" "0 6t"
240 ;;
241 d105 | \
242 na930 | \
243 omni-emb-hpm|\
244 wli-tx4-ag300n)
245 ucidef_set_interface_lan "eth0"
246 ;;
247
248 e1700 | \
249 mt7620a_mt7530)
250 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
251 ucidef_add_switch "switch1" "1" "1"
252 ucidef_add_switch_vlan "switch1" "1" "0 1 2 3 6t"
253 ucidef_add_switch_vlan "switch1" "2" "4 6t"
254 ;;
255
256 wzr-agl300nh)
257 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
258 ucidef_add_switch "switch0" "1" "1"
259 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
260 ucidef_add_switch_vlan "switch0" "2" "0 5t"
261 ;;
262 *)
263 RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
264 if [ -n "${RT3X5X}" ]; then
265 ramips_setup_rt3x5x_vlans
266 else
267 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
268 fi
269 ;;
270 esac
271 }
272
273 ramips_setup_macs()
274 {
275 local board="$1"
276 local lan_mac=""
277 local wan_mac=""
278
279 case $board in
280 br-6475nd)
281 lan_mac=$(cat /sys/class/net/eth0/address)
282 wan_mac=$(mtd_get_mac_binary devdata 7)
283 ;;
284
285 w306r-v20)
286 lan_mac=$(cat /sys/class/net/eth0/address)
287 wan_mac=$(macaddr_add "$lan_mac" 5)
288 ;;
289
290 tew-691gr)
291 lan_mac=$(cat /sys/class/net/eth0/address)
292 wan_mac=$(macaddr_add "$lan_mac" 3)
293 ;;
294
295 tew-692gr)
296 lan_mac=$(cat /sys/class/net/eth0/address)
297 wan_mac=$(macaddr_add "$lan_mac" 4)
298 ;;
299
300 m3 |\
301 m4 |\
302 x5 |\
303 x8)
304 lan_mac=$(cat /sys/class/net/eth0/address)
305 lan_mac=$(macaddr_add "$lan_mac" -2)
306 ;;
307
308 a5-v11 |\
309 bc2 |\
310 broadway |\
311 d105 |\
312 dir-620-a1 |\
313 esr-9753 |\
314 freestation5 |\
315 hlk-rm04 | \
316 mpr-a1 | \
317 mpr-a2 | \
318 dir-300-b7 | \
319 dir-320-b1 | \
320 psr-680w |\
321 sl-r7205 |\
322 y1 |\
323 y1s)
324 lan_mac=$(cat /sys/class/net/eth0/address)
325 lan_mac=$(macaddr_setbit_la "$lan_mac")
326 wan_mac=$(macaddr_add "$lan_mac" 1)
327 ;;
328
329 ht-tm02)
330 lan_mac=$(cat /sys/class/net/eth0/address)
331 ;;
332
333 cy-swr1100 | \
334 dir-645)
335 lan_mac=$(mtd_get_mac_ascii nvram lanmac)
336 wan_mac=$(mtd_get_mac_ascii nvram wanmac)
337 ;;
338
339 e1700)
340 wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
341 ;;
342
343 wcr-150gn)
344 wan_mac=$(mtd_get_mac_binary factory 40)
345 ;;
346
347 rt-n56u)
348 lan_mac=$(cat /sys/class/net/eth0/address)
349 lan_mac=$(macaddr_setbit_la "$lan_mac")
350 wan_mac=$(mtd_get_mac_binary factory 32772)
351 ;;
352
353 all0239-3g | \
354 carambola | \
355 freestation5 | \
356 w502u | \
357 wnce2001)
358 wan_mac=$(mtd_get_mac_binary factory 46)
359 ;;
360
361 wsr-600|whr-300hp2|whr-600d|whr-1166d)
362 wan_mac=$(mtd_get_mac_binary factory 4)
363 lan_mac=$wan_mac
364 ;;
365 wsr-1166)
366 local index="$(find_mtd_index "board_data")"
367 wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
368 lan_mac=$wan_mac
369 ;;
370 *)
371 lan_mac=$(cat /sys/class/net/eth0/address)
372 wan_mac=$(macaddr_add "$lan_mac" 1)
373 ;;
374
375 esac
376
377 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
378 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
379 }
380
381 board_config_update
382 board=$(ramips_board_name)
383 ramips_setup_interfaces $board
384 ramips_setup_macs $board
385 board_config_flush
386
387 exit 0