aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ramips/mt7620/base-files/etc/board.d/02_network
diff options
context:
space:
mode:
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>2019-10-22 12:37:13 +0200
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>2019-11-03 00:26:17 +0100
commit19724e28c81e3ff642f09c49f612cd147c54a697 (patch)
tree278c45d3b1563cee6108e65c3b5856dbab304062 /target/linux/ramips/mt7620/base-files/etc/board.d/02_network
parent0975c35b83a632f9662d1944307f87da9db06154 (diff)
downloadupstream-19724e28c81e3ff642f09c49f612cd147c54a697.tar.gz
upstream-19724e28c81e3ff642f09c49f612cd147c54a697.tar.bz2
upstream-19724e28c81e3ff642f09c49f612cd147c54a697.zip
ramips: split base-files into subtargets
While most of the target's contents are split into subtargets, the base-files are maintained for the target as a whole. However, OpenWrt already implements a mechanism that will use (and even prefer) files in the subtargets' directories. This can be exploited to make several scripts subtarget-specific and thus save some space. In certain cases, keeping files in parent (=target) base-files was more convenient, and thus no splitting was performed for those. Note that this will increase overall code lines, but reduce code per subtarget. base-files ipk size reduction: master (mt7621) 60958 B split (mt7620) 46358 B (- 14.3 kiB) split (mt7621) 48759 B (- 11.9 kiB) split (mt76x8) 44948 B (- 15.6 kiB) split (rt288x) 43508 B (- 17.0 kiB) split (rt305x) 45616 B (- 15.0 kiB) split (rt3883) 44176 B (- 16.4 kiB) Run-tested on: GL.iNet GL-MT300N-V2 (mt76x8) D-Link DWR-116 (mt7620) Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Diffstat (limited to 'target/linux/ramips/mt7620/base-files/etc/board.d/02_network')
-rwxr-xr-xtarget/linux/ramips/mt7620/base-files/etc/board.d/02_network297
1 files changed, 297 insertions, 0 deletions
diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network
new file mode 100755
index 0000000000..db1f4de2a7
--- /dev/null
+++ b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network
@@ -0,0 +1,297 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. /lib/functions/uci-defaults.sh
+. /lib/functions/system.sh
+
+ramips_setup_interfaces()
+{
+ local board="$1"
+
+ case $board in
+ aigale,ai-br100|\
+ alfa-network,ac1200rm|\
+ asus,rt-n12p|\
+ dlink,dir-810l|\
+ dlink,dwr-116-a1|\
+ dlink,dwr-921-c1|\
+ dlink,dwr-922-e2|\
+ ohyeah,oy-0001|\
+ phicomm,psg1208|\
+ phicomm,psg1218a|\
+ planex,db-wrt01|\
+ planex,mzk-750dhp|\
+ sanlinking,d240|\
+ xiaomi,miwifi-mini|\
+ youku,yk1|\
+ zbtlink,zbt-ape522ii|\
+ zbtlink,zbt-we826-16m|\
+ zbtlink,zbt-we826-32m|\
+ zbtlink,zbt-we826-e|\
+ zbtlink,zbt-wr8305rt|\
+ zyxel,keenetic-omni)
+ ucidef_add_switch "switch0" \
+ "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
+ ;;
+ alfa-network,tube-e4g|\
+ buffalo,wmr-300|\
+ dlink,dch-m225|\
+ elecom,wrh-300cr|\
+ kimax,u25awf-h1|\
+ netgear,ex2700|\
+ netgear,ex3700|\
+ netgear,wn3000rp-v3|\
+ planex,cs-qr10|\
+ planex,mzk-ex300np|\
+ planex,mzk-ex750np|\
+ ravpower,wd03|\
+ sercomm,na930)
+ ucidef_set_interface_lan "eth0"
+ ;;
+ asus,rp-n53)
+ ucidef_add_switch "switch0" \
+ "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0"
+ ;;
+ asus,rt-ac51u)
+ ucidef_add_switch "switch0" \
+ "0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0"
+ ;;
+ asus,rt-n14u|\
+ bdcom,wap2100-sk|\
+ glinet,gl-mt300a|\
+ glinet,gl-mt300n|\
+ glinet,gl-mt750|\
+ hiwifi,hc5661|\
+ tplink,archer-c20i|\
+ wrtnode,wrtnode|\
+ zbtlink,zbt-wa05)
+ ucidef_add_switch "switch0" \
+ "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
+ ;;
+ buffalo,whr-300hp2|\
+ buffalo,whr-600d)
+ ucidef_add_switch "switch0" \
+ "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "4:wan:5" "6@eth0"
+ ;;
+ buffalo,whr-1166d)
+ ucidef_add_switch "switch0" \
+ "0:lan" "1:lan" "2:lan" "3:lan" "5:wan" "6@eth0"
+ ;;
+ comfast,cf-wr800n|\
+ hnet,c108)
+ ucidef_add_switch "switch0" \
+ "4:lan" "6@eth0"
+ ;;
+ dlink,dir-510l)
+ ucidef_add_switch "switch0" \
+ "0:lan" "6@eth0"
+ ;;
+ dlink,dwr-118-a1)
+ ucidef_add_switch "switch0" \
+ "1:lan:2" "2:lan:3" "3:lan:1" "4:lan:0" "5:wan" "6@eth0"
+ ;;
+ dlink,dwr-118-a2)
+ ucidef_add_switch "switch0" \
+ "1:lan:2" "2:lan:1" "3:lan:3" "4:lan" "0:wan" "6@eth0"
+ ;;
+ edimax,br-6478ac-v2|\
+ tplink,archer-c2-v1)
+ ucidef_add_switch "switch1" \
+ "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
+ ;;
+ edimax,ew-7476rpc|\
+ edimax,ew-7478ac|\
+ kimax,u35wf|\
+ microduino,microwrt|\
+ yukai,bocco|\
+ zbtlink,zbt-cpe102|\
+ zte,q7)
+ ucidef_add_switch "switch0"
+ ucidef_add_switch_attr "switch0" "enable" "false"
+ ucidef_set_interface_lan "eth0"
+ ;;
+ engenius,esr600)
+ ucidef_add_switch "switch0" \
+ "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "0@eth0"
+ ;;
+ fon,fon2601)
+ ucidef_add_switch "switch0" \
+ "0:lan" "4:wan" "6@eth0"
+ ;;
+ head-weblink,hdrm200)
+ ucidef_add_switch "switch0" \
+ "1:lan" "2:lan" "3:lan" "4:lan" "5:lan" "0:wan" "6@eth0"
+ ;;
+ hiwifi,hc5761)
+ ucidef_add_switch "switch0" \
+ "1:lan" "4:lan" "0:wan" "6@eth0"
+ ;;
+ hiwifi,hc5861)
+ ucidef_add_switch "switch0" \
+ "0:lan" "1:lan" "5:wan" "6@eth0"
+ ;;
+ iodata,wn-ac1167gr|\
+ iodata,wn-ac733gr3)
+ ucidef_add_switch "switch1" \
+ "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
+ ;;
+ kingston,mlw221)
+ ucidef_set_interface_lan "eth0.2"
+ ;;
+ kingston,mlwg2)
+ ucidef_set_interface_lan "eth0.1"
+ ;;
+ lava,lr-25g001)
+ ucidef_add_switch "switch0" \
+ "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "0@eth0"
+ ;;
+ lenovo,newifi-y1)
+ ucidef_add_switch "switch0" \
+ "0:lan:2" "1:lan:1" "4:wan" "6@eth0"
+ ;;
+ lenovo,newifi-y1s)
+ ucidef_add_switch "switch0" \
+ "1:lan:4" "2:lan:3" "4:lan:2" "5:lan:1" "0:wan" "6@eth0"
+ ;;
+ linksys,e1700|\
+ ralink,mt7620a-mt7530-evb)
+ ucidef_add_switch "switch1" \
+ "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
+ ;;
+ nexx,wt3020-4m|\
+ nexx,wt3020-8m)
+ ucidef_add_switch "switch0" \
+ "4:lan" "0:wan" "6@eth0"
+ ;;
+ phicomm,k2g)
+ ucidef_add_switch "switch0" \
+ "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5:wan" "6@eth0"
+ ;;
+ phicomm,psg1218b)
+ ucidef_add_switch "switch0" \
+ "0:lan:3" "1:lan:2" "2:lan:1" "3:wan" "6@eth0"
+ ;;
+ tplink,archer-c20-v1|\
+ tplink,archer-c50-v1)
+ ucidef_add_switch "switch0" \
+ "1:lan:3" "2:lan:4" "3:lan:1" "4:lan:2" "0:wan" "6@eth0"
+ ;;
+ tplink,archer-mr200)
+ ucidef_add_switch "switch0" \
+ "0:lan" "1:lan" "2:lan" "3:lan" "6t@eth0"
+ ucidef_set_interface_wan "usb0"
+ ;;
+ vonets,var11n-300)
+ ucidef_add_switch "switch0" \
+ "0:lan" "4:wan" "6@eth0"
+ ;;
+ zbtlink,zbt-we1026-5g-16m)
+ ucidef_add_switch "switch0" \
+ "0:lan" "6t@eth0"
+ ;;
+ zbtlink,zbt-we2026)
+ ucidef_add_switch "switch0" \
+ "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan:5" "6@eth0"
+ ;;
+ zyxel,keenetic-omni-ii)
+ ucidef_add_switch "switch0" \
+ "0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6@eth0"
+ ;;
+ zyxel,keenetic-viva)
+ ucidef_add_switch "switch1" \
+ "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "7t@eth0"
+ ;;
+ *)
+ ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
+ ;;
+ esac
+}
+
+ramips_setup_macs()
+{
+ local board="$1"
+ local lan_mac=""
+ local wan_mac=""
+ local label_mac=""
+
+ case $board in
+ buffalo,whr-1166d|\
+ buffalo,whr-300hp2|\
+ buffalo,whr-600d|\
+ xiaomi,miwifi-mini)
+ # This empty case has to be kept for devices without any MAC address adjustments
+ ;;
+ dlink,dch-m225)
+ lan_mac=$(mtd_get_mac_ascii factory lanmac)
+ ;;
+ dlink,dir-510l|\
+ dlink,dwr-116-a1|\
+ dlink,dwr-118-a1|\
+ dlink,dwr-118-a2|\
+ dlink,dwr-921-c1|\
+ dlink,dwr-922-e2|\
+ lava,lr-25g001)
+ wan_mac=$(jboot_config_read -m -i $(find_mtd_part "config") -o 0xE000)
+ lan_mac=$(macaddr_add "$wan_mac" 1)
+ label_mac=$wan_mac
+ ;;
+ dovado,tiny-ac)
+ lan_mac=$(mtd_get_mac_ascii u-boot-env LAN_MAC_ADDR)
+ wan_mac=$(mtd_get_mac_ascii u-boot-env WAN_MAC_ADDR)
+ ;;
+ edimax,br-6478ac-v2)
+ wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 2)
+ ;;
+ engenius,esr600)
+ lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
+ wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
+ ;;
+ glinet,gl-mt300a|\
+ glinet,gl-mt300n|\
+ glinet,gl-mt750)
+ wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
+ label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
+ ;;
+ hiwifi,hc5661|\
+ hiwifi,hc5761|\
+ hiwifi,hc5861)
+ lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
+ label_mac=$lan_mac
+ [ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
+ wan_mac=$(macaddr_add "$lan_mac" 1)
+ ;;
+ iodata,wn-ac1167gr|\
+ iodata,wn-ac733gr3)
+ wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
+ ;;
+ lenovo,newifi-y1|\
+ lenovo,newifi-y1s|\
+ ohyeah,oy-0001|\
+ phicomm,k2g)
+ wan_mac=$(mtd_get_mac_binary factory 0x2e)
+ ;;
+ linksys,e1700)
+ wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
+ ;;
+ zyxel,keenetic-omni|\
+ zyxel,keenetic-omni-ii|\
+ zyxel,keenetic-viva)
+ wan_mac=$(mtd_get_mac_binary factory 0x28)
+ ;;
+ *)
+ wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
+ ;;
+ esac
+
+ [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
+ [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
+ [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
+}
+
+board_config_update
+board=$(board_name)
+ramips_setup_interfaces $board
+ramips_setup_macs $board
+board_config_flush
+
+exit 0