From 19724e28c81e3ff642f09c49f612cd147c54a697 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Tue, 22 Oct 2019 12:37:13 +0200 Subject: 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 --- .../mt76x8/base-files/etc/board.d/02_network | 191 +++++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100755 target/linux/ramips/mt76x8/base-files/etc/board.d/02_network (limited to 'target/linux/ramips/mt76x8/base-files/etc/board.d/02_network') diff --git a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network new file mode 100755 index 0000000000..3bb5d31423 --- /dev/null +++ b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network @@ -0,0 +1,191 @@ +#!/bin/sh + +. /lib/functions.sh +. /lib/functions/uci-defaults.sh +. /lib/functions/system.sh + +ramips_setup_interfaces() +{ + local board="$1" + + case $board in + alfa-network,awusfree1|\ + d-team,pbr-d1|\ + tama,w06|\ + tplink,tl-mr3020-v3|\ + tplink,tl-wr802n-v4) + ucidef_set_interface_lan "eth0" + ;; + buffalo,wcr-1166ds) + ucidef_add_switch "switch0" \ + "3:lan" "4:wan" "6@eth0" + ;; + cudy,wr1000) + ucidef_add_switch "switch0" \ + "2:lan:2" "3:lan:1" "4:wan" "6@eth0" + ;; + duzun,dm06) + ucidef_add_switch "switch0" \ + "1:lan" "0:wan" "6@eth0" + ;; + glinet,gl-mt300n-v2) + ucidef_add_switch "switch0" \ + "1:lan" "0:wan" "6@eth0" + ;; + glinet,vixmini) + ucidef_add_switch "switch0" \ + "0:lan" "6@eth0" + ;; + hilink,hlk-7628n|\ + hiwifi,hc5861b|\ + skylab,skw92a|\ + tplink,archer-c20-v4|\ + tplink,archer-c50-v3|\ + tplink,archer-c50-v4|\ + tplink,tl-mr3420-v5|\ + tplink,tl-wr840n-v4|\ + tplink,tl-wr840n-v5|\ + tplink,tl-wr841n-v13|\ + tplink,tl-wr841n-v14|\ + tplink,tl-wr842n-v5|\ + unielec,u7628-01-16m|\ + wrtnode,wrtnode2p|\ + wrtnode,wrtnode2r|\ + zyxel,keenetic-extra-ii) + ucidef_add_switch "switch0" \ + "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0" + ;; + hiwifi,hc5661a|\ + hiwifi,hc5761a|\ + mediatek,mt7628an-eval-board|\ + mercury,mac1200r-v2|\ + totolink,lr1200|\ + wavlink,wl-wn570ha1|\ + wavlink,wl-wn575a3|\ + xiaomi,miwifi-nano) + ucidef_add_switch "switch0" \ + "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0" + ;; + iptime,a3) + ucidef_add_switch "switch0" \ + "2:lan:2" "3:lan:1" "0:wan" "6@eth0" + ;; + iptime,a604m) + ucidef_add_switch "switch0" \ + "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0" + ;; + mediatek,linkit-smart-7688|\ + onion,omega2p|\ + onion,omega2|\ + tplink,tl-wa801nd-v5|\ + widora,neo-16m|\ + widora,neo-32m) + ucidef_add_switch "switch0" + ucidef_add_switch_attr "switch0" "enable" "false" + ucidef_set_interface_lan "eth0" + ;; + netgear,r6120) + ucidef_add_switch "switch0" \ + "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0" + ;; + rakwireless,rak633) + ucidef_add_switch "switch0" \ + "0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0" + ;; + tplink,tl-wr902ac-v3) + ucidef_add_switch "switch0" \ + "4:lan" "6@eth0" + ;; + vocore,vocore2|\ + vocore,vocore2-lite) + ucidef_add_switch "switch0" \ + "0:lan" "2:lan" "6t@eth0" + ;; + wiznet,wizfi630s) + ucidef_add_switch "switch0" \ + "0:wan" "3:lan" "4:lan" "6@eth0" + ;; + xiaomi,mir4a-100m) + ucidef_add_switch "switch0" \ + "4:lan:1" "2:lan:2" "0:wan" "6@eth0" + ;; + zbtlink,zbt-we1226) + ucidef_add_switch "switch0" \ + "0:lan:2" "1:lan:1" "4:wan" "6@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,wcr-1166ds) + local index="$(find_mtd_index "board_data")" + wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)" + lan_mac=$wan_mac + ;; + cudy,wr1000) + wan_mac=$(mtd_get_mac_binary factory 0x2e) + label_mac=$(cat /sys/class/ieee80211/phy0/macaddress) + ;; + glinet,gl-mt300n-v2) + # This empty case has to be kept for devices without any MAC address adjustments + ;; + hilink,hlk-7628n) + lan_mac=$(macaddr_setbit_la "$(cat /sys/class/net/eth0/address)") + wan_mac=$(macaddr_add "$lan_mac" 1) + ;; + hiwifi,hc5661a|\ + hiwifi,hc5761a|\ + hiwifi,hc5861b) + 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) + ;; + iptime,a3|\ + iptime,a604m) + wan_mac=$(mtd_get_mac_binary u-boot 0x1fc40) + ;; + mediatek,linkit-smart-7688|\ + onion,omega2|\ + onion,omega2p) + wan_mac=$(mtd_get_mac_binary factory 0x4) + lan_mac=$(mtd_get_mac_binary factory 0x2e) + ;; + mercury,mac1200r-v2) + wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory_info 0xd)" 1) + ;; + skylab,skw92a|\ + totolink,lr1200) + wan_mac=$(mtd_get_mac_binary factory 0x2e) + ;; + vocore,vocore2|\ + vocore,vocore2-lite) + label_mac=$(cat /sys/class/ieee80211/phy0/macaddress) + ;; + *) + 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 -- cgit v1.2.3