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