aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ramips/mt7621/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/mt7621/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/mt7621/base-files/etc/board.d/02_network')
-rwxr-xr-xtarget/linux/ramips/mt7621/base-files/etc/board.d/02_network238
1 files changed, 238 insertions, 0 deletions
diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
new file mode 100755
index 0000000000..11cf27e092
--- /dev/null
+++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
@@ -0,0 +1,238 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. /lib/functions/uci-defaults.sh
+. /lib/functions/system.sh
+
+ramips_setup_interfaces()
+{
+ local board="$1"
+
+ case $board in
+ adslr,g7|\
+ afoundry,ew1200|\
+ d-team,pbr-m1|\
+ firefly,firewrt|\
+ hiwifi,hc5962|\
+ mediatek,ap-mt7621a-v60|\
+ mediatek,mt7621-eval-board|\
+ mqmaker,witi|\
+ mtc,wr1201|\
+ netis,wf-2881|\
+ phicomm,k2p|\
+ planex,vr500|\
+ samknows,whitebox-v8|\
+ storylink,sap-g3200u3|\
+ telco-electronics,x1|\
+ totolink,a7000r|\
+ unielec,u7621-06-16m|\
+ unielec,u7621-06-64m|\
+ xiaoyu,xy-c5|\
+ xzwifi,creativebox-v1|\
+ youku,yk-l2|\
+ zbtlink,zbt-we1326|\
+ zbtlink,zbt-we3526|\
+ zbtlink,zbt-wg2626|\
+ zbtlink,zbt-wg3526-16m|\
+ zbtlink,zbt-wg3526-32m)
+ ucidef_add_switch "switch0" \
+ "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
+ ;;
+ asiarf,ap7621-001)
+ ucidef_add_switch "switch0" "0:lan" "4:wan" "6@eth0"
+ ;;
+ asiarf,ap7621-nv1)
+ ucidef_add_switch "switch0" "0:wan" "2:lan" "3:lan" "6@eth0"
+ ;;
+ asus,rt-ac57u|\
+ mikrotik,rb750gr3|\
+ mikrotik,rbm33g|\
+ ubiquiti,edgerouterx|\
+ ubiquiti,edgerouterx-sfp|\
+ youhua,wr1200js)
+ ucidef_add_switch "switch0" \
+ "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
+ ;;
+ asus,rt-ac65p|\
+ asus,rt-ac85p|\
+ dlink,dir-860l-b1|\
+ elecom,wrc-1167ghbk2-s|\
+ elecom,wrc-1900gst|\
+ elecom,wrc-2533gst|\
+ iodata,wn-ax1167gr|\
+ iodata,wn-gx300gr|\
+ iodata,wnpr2600g)
+ ucidef_add_switch "switch0" \
+ "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
+ ;;
+ buffalo,wsr-1166dhp|\
+ buffalo,wsr-600dhp)
+ ucidef_add_switch "switch0" \
+ "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "4:wan:5" "6@eth0"
+ ;;
+ d-team,newifi-d2|\
+ wevo,11acnas|\
+ wevo,w2914ns-v2)
+ ucidef_add_switch "switch0" \
+ "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan:5" "6@eth0"
+ ;;
+ edimax,rg21s)
+ ucidef_add_switch "switch0" \
+ "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
+ ;;
+ gehua,ghl-r-001)
+ ucidef_add_switch "switch0" \
+ "0:lan" "1:lan" "2:lan" "4:wan" "6@eth0"
+ ;;
+ gnubee,gb-pc1|\
+ gnubee,gb-pc2)
+ ucidef_add_switch "switch0" \
+ "0:lan" "4:lan" "6@eth0"
+ ;;
+ lenovo,newifi-d1)
+ ucidef_add_switch "switch0" \
+ "1:lan:2" "2:lan:1" "4:wan" "6@eth0"
+ ;;
+ linksys,re6500)
+ ucidef_add_switch "switch0" \
+ "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "6@eth0"
+ ;;
+ mikrotik,rbm11g|\
+ thunder,timecloud)
+ ucidef_add_switch "switch0"
+ ucidef_add_switch_attr "switch0" "enable" "false"
+ ucidef_set_interface_lan "eth0"
+ ;;
+ netgear,ex6150|\
+ tplink,re350-v1|\
+ tplink,re650-v1)
+ ucidef_add_switch "switch0" \
+ "0:lan" "6@eth0"
+ ;;
+ netgear,r6220|\
+ netgear,r6260|\
+ netgear,r6350|\
+ netgear,r6850|\
+ netgear,wndr3700-v5)
+ ucidef_add_switch "switch0" \
+ "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
+ ;;
+ xiaomi,mir3g)
+ ucidef_add_switch "switch0" \
+ "2:lan:2" "3:lan:1" "1:wan" "6t@eth0"
+ ;;
+ xiaomi,mir3g-v2)
+ ucidef_add_switch "switch0" \
+ "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
+ ;;
+ xiaomi,mir3p)
+ ucidef_add_switch "switch0" \
+ "1:lan:3" "2:lan:2" "3: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
+ asus,rt-ac57u|\
+ d-team,newifi-d2|\
+ d-team,pbr-m1|\
+ elecom,wrc-1167ghbk2-s|\
+ elecom,wrc-1900gst|\
+ elecom,wrc-2533gst|\
+ lenovo,newifi-d1|\
+ phicomm,k2p|\
+ planex,vr500|\
+ samknows,whitebox-v8|\
+ youhua,wr1200js|\
+ youku,yk-l2|\
+ zbtlink,zbt-we3526)
+ wan_mac=$(mtd_get_mac_binary factory 0xe006)
+ ;;
+ asus,rt-ac65p|\
+ asus,rt-ac85p)
+ wan_mac=$(mtd_get_mac_ascii u-boot-env et1macaddr)
+ label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
+ ;;
+ buffalo,wsr-1166dhp)
+ local index="$(find_mtd_index "board_data")"
+ wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
+ lan_mac=$wan_mac
+ ;;
+ buffalo,wsr-600dhp)
+ # This empty case has to be kept for devices without any MAC address adjustments
+ ;;
+ dlink,dir-860l-b1)
+ lan_mac=$(mtd_get_mac_ascii factory lanmac)
+ wan_mac=$(mtd_get_mac_ascii factory wanmac)
+ label_mac=$(cat /sys/class/ieee80211/phy1/macaddress)
+ ;;
+ edimax,rg21s)
+ lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
+ wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
+ ;;
+ hiwifi,hc5962)
+ 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-ax1167gr|\
+ iodata,wn-gx300gr)
+ wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1)
+ ;;
+ iodata,wnpr2600g)
+ wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
+ label_mac=$wan_mac
+ ;;
+ netgear,r6260|\
+ netgear,r6350|\
+ netgear,r6850)
+ wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 2)
+ ;;
+ xiaomi,mir3g)
+ lan_mac=$(mtd_get_mac_binary factory 0xe006)
+ ;;
+ xiaomi,mir3g-v2)
+ wan_mac=$(mtd_get_mac_binary factory 0xe006)
+ label_mac=$wan_mac
+ ;;
+ xiaomi,mir3p)
+ lan_mac=$(mtd_get_mac_binary factory 0xe006)
+ label_mac=$lan_mac
+ ;;
+ zbtlink,zbt-we1326)
+ wan_mac=$(mtd_get_mac_binary factory 0xe006)
+ label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
+ ;;
+ zbtlink,zbt-wg3526-16m|\
+ zbtlink,zbt-wg3526-32m)
+ wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
+ 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