6948851ee58255de9f9d0195911c20092b03ad8e
[openwrt/svn-archive/archive.git] / target / linux / ramips / base-files / lib / preinit / 07_set_preinit_iface_ramips
1 #!/bin/sh
2 #
3 # Copyright (C) 2013 OpenWrt.org
4 #
5
6 . /lib/ramips.sh
7
8 ramips_set_preinit_iface() {
9 RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350|MT7628|MT7688)"`
10 MT762X=`cat /proc/cpuinfo | egrep "MT7620"`
11
12 if [ -n "${RT3X5X}" ]; then
13 swconfig dev rt305x set reset 1
14 elif [ -n "${MT762X}" ]; then
15 # The mt7530 switch driver enables VLAN by default, but
16 # failsafe uses eth0, making the device unreachable:
17 # https://dev.openwrt.org/ticket/18768
18 case "${MT762X}" in
19 *MT7620*)
20 mt762x_switchdev=mt7620
21 ;;
22 esac
23 swconfig dev $mt762x_switchdev set reset 1
24 swconfig dev $mt762x_switchdev set enable_vlan 0
25 swconfig dev $mt762x_switchdev set apply 1
26 fi
27
28 if echo $RT3X5X | egrep -q "(RT5350|MT7628|MT7688)"; then
29 # This is a dirty hack to get by while the switch
30 # problem is investigated. When VLAN is disabled, ICMP
31 # pings work as expected, but TCP connections time
32 # out, so telnetting in failsafe is impossible. The
33 # likely reason is TCP checksumming hardware getting
34 # disabled:
35 # https://www.mail-archive.com/openwrt-devel@lists.openwrt.org/msg19870.html
36 swconfig dev rt305x set enable_vlan 1
37 swconfig dev rt305x vlan 1 set ports "0 6"
38 swconfig dev rt305x port 6 set untag 0
39 swconfig dev rt305x set apply 1
40 ip link add link eth0 name eth0.1 type vlan id 1
41 ip link set eth0 up
42 ifname=eth0.1
43 else
44 ifname=eth0
45 fi
46 }
47
48 boot_hook_add preinit_main ramips_set_preinit_iface