aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ramips/base-files
diff options
context:
space:
mode:
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>2019-12-16 18:07:03 +0100
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>2019-12-17 15:09:48 +0100
commitf45a16dead15169f06a999f71061e66df1fc478c (patch)
tree4fabc0bcafe66c3d6a9fc497d111ee029ed54c6f /target/linux/ramips/base-files
parent38bdfcdb87e9b3a1232e9820bd6534da4c28282b (diff)
downloadupstream-f45a16dead15169f06a999f71061e66df1fc478c.tar.gz
upstream-f45a16dead15169f06a999f71061e66df1fc478c.tar.bz2
upstream-f45a16dead15169f06a999f71061e66df1fc478c.zip
ramips: allow to set switchdev by board in ramips_set_preinit_iface
This adds the option to determine switchdev by board when setting preinit iface for failsafe. The patch reorganizes the code to use functions for setting correct switchdev based on SOC and board, which is supposed to improve readability and maintainability. In this patch, the ramips_switchdev_from_board function is added without specifying an actual device using it. This is meant to make the life of device supporters waiting for merge easier, as there is less to rebase and keep track of. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Diffstat (limited to 'target/linux/ramips/base-files')
-rw-r--r--target/linux/ramips/base-files/lib/preinit/07_set_preinit_iface_ramips67
1 files changed, 47 insertions, 20 deletions
diff --git a/target/linux/ramips/base-files/lib/preinit/07_set_preinit_iface_ramips b/target/linux/ramips/base-files/lib/preinit/07_set_preinit_iface_ramips
index 003a4dda7b..68c1285eb4 100644
--- a/target/linux/ramips/base-files/lib/preinit/07_set_preinit_iface_ramips
+++ b/target/linux/ramips/base-files/lib/preinit/07_set_preinit_iface_ramips
@@ -3,27 +3,54 @@
# Copyright (C) 2013 OpenWrt.org
#
+. /lib/functions.sh
+
+ramips_switchdev_from_soc() {
+ # The ethernet switch driver enables VLAN by default, but
+ # failsafe uses eth0, making the device unreachable:
+ # https://dev.openwrt.org/ticket/18768
+
+ local switchdev
+ local RT3X5X=$(grep -E "(RT3.5|RT5350|MT7628|MT7688|MT7620|MT7621)" /proc/cpuinfo)
+
+ [ -n "$RT3X5X" ] || return 1
+
+ case "$RT3X5X" in
+ *MT7620*)
+ switchdev=mt7620
+ ;;
+ *MT7621*)
+ switchdev=mt7530
+ ;;
+ *)
+ switchdev=rt305x
+ ;;
+ esac
+
+ echo "$switchdev"
+}
+
+ramips_switchdev_from_board() {
+ # For these devices, external ethernet switch should be used
+ # instead of the SoC internal switch.
+
+ local switchdev
+ local board=$(board_name)
+
+ case "$board" in
+ esac
+
+ echo "$switchdev"
+}
+
ramips_set_preinit_iface() {
- RT3X5X=$(grep -E "(RT3.5|RT5350|MT7628|MT7688|MT7620|MT7621)" /proc/cpuinfo)
-
- if [ -n "${RT3X5X}" ]; then
- # The ethernet switch driver enables VLAN by default, but
- # failsafe uses eth0, making the device unreachable:
- # https://dev.openwrt.org/ticket/18768
- case "${RT3X5X}" in
- *MT7620*)
- ralink_switchdev=mt7620
- ;;
- *MT7621*)
- ralink_switchdev=mt7530
- ;;
- *)
- ralink_switchdev=rt305x
- ;;
- esac
- swconfig dev $ralink_switchdev set reset 1
- swconfig dev $ralink_switchdev set enable_vlan 0
- swconfig dev $ralink_switchdev set apply 1
+ local switchdev=$(ramips_switchdev_from_board)
+ [ -n "$switchdev" ] || switchdev=$(ramips_switchdev_from_soc)
+
+ if [ -n "$switchdev" ]; then
+ swconfig dev $switchdev set reset 1
+ swconfig dev $switchdev set enable_vlan 0
+ swconfig dev $switchdev set apply 1
fi
ifname=eth0