Skip to content

Commit

Permalink
add ASUS RT-AC58U in IPQ40xx
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsnowwolf committed Apr 8, 2018
1 parent d1f8dda commit a8cd67f
Show file tree
Hide file tree
Showing 18 changed files with 1,012 additions and 61 deletions.
1 change: 1 addition & 0 deletions config/Config-images.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ menu "Target Images"
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ramips
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_apm821xx
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_mpc85xx
default TARGET_INITRAMFS_COMPRESSION_LZMA if TARGET_ipq40xx
default TARGET_INITRAMFS_COMPRESSION_NONE
depends on TARGET_ROOTFS_INITRAMFS
help
Expand Down
14 changes: 12 additions & 2 deletions target/linux/ipq40xx/base-files/etc/board.d/01_leds
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,22 @@ asus,rt-ac58u)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:blue:wlan2G" "phy0tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "${boardname}:blue:wlan5G" "phy1tpt"
ucidef_set_led_usbport "usb" "USB" "${boardname}:blue:usb" "usb1-port1" "usb2-port1" "usb3-port1" "usb4-port1"
ucidef_set_led_netdev "wan" "WAN" "${boardname}:blue:wan" "eth1"
ucidef_set_led_switch "wan" "WAN" "${boardname}:blue:wan" "switch0" "0x20"
ucidef_set_led_switch "lan" "LAN" "${boardname}:blue:lan" "switch0" "0x1e"
;;
asus,rt-acrh17)
ucidef_set_led_default "status" "STATUS" "${boardname}:blue:status" "1"
ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:blue:wlan2g" "phy1tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "${boardname}:blue:wlan5g" "phy0tpt"
ucidef_set_led_switch "wan" "WAN(blue)" "${boardname}:blue:wan" "switch0" "0x20"
ucidef_set_led_switch "lan1" "LAN1" "${boardname}:blue:lan1" "switch0" "0x02"
ucidef_set_led_switch "lan2" "LAN2" "${boardname}:blue:lan2" "switch0" "0x04"
ucidef_set_led_switch "lan3" "LAN3" "${boardname}:blue:lan3" "switch0" "0x08"
ucidef_set_led_switch "lan4" "LAN4" "${boardname}:blue:lan4" "switch0" "0x10"
;;
avm,fritzbox-4040)
ucidef_set_led_wlan "wlan" "WLAN" "fritz4040:green:wlan" "phy0tpt" "phy1tpt"
ucidef_set_led_netdev "wan" "WAN" "fritz4040:green:wan" "eth1"
ucidef_set_led_switch "wan" "WAN" "fritz4040:green:wan" "switch0" "0x20"
ucidef_set_led_switch "lan" "LAN" "fritz4040:green:lan" "switch0" "0x1e"
;;
glinet,gl-b1300)
Expand Down
25 changes: 15 additions & 10 deletions target/linux/ipq40xx/base-files/etc/board.d/02_network
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,32 @@ asus,rt-ac58u)
CI_UBIPART=UBI_DEV
wan_mac_addr=$(mtd_get_mac_binary_ubi Factory 20486)
lan_mac_addr=$(mtd_get_mac_binary_ubi Factory 4102)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
"0t@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
ucidef_set_interface_macaddr "lan" "$lan_mac_addr"
ucidef_set_interface_macaddr "wan" "$wan_mac_addr"
;;
avm,fritzbox-4040)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
asus,rt-acrh17)
CI_UBIPART=UBI_DEV
lan_mac_addr=$(mtd_get_mac_binary_ubi Factory 4102)
wan_mac_addr=$(mtd_get_mac_binary_ubi Factory 36870)
ucidef_add_switch "switch0" \
"0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
"0t@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
ucidef_set_interface_macaddr "lan" "$lan_mac_addr"
ucidef_set_interface_macaddr "wan" "$wan_mac_addr"
;;
compex,wpj428)
ucidef_set_interface_lan "eth0 eth1"
avm,fritzbox-4040)
ucidef_add_switch "switch0" \
"0t@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
;;
glinet,gl-b1300)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
ucidef_add_switch "switch0" \
"0u@eth0" "3:lan" "4:lan"
"0t@eth0" "3:lan" "4:lan" "5:wan"
;;
compex,wpj428|\
openmesh,a42)
ucidef_set_interfaces_lan_wan "eth1" "eth0"
ucidef_add_switch "switch0" \
"0t@eth0" "4:lan" "5:wan"
;;

meraki,mr33)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ case "$FIRMWARE" in
;;
"ath10k/pre-cal-ahb-a000000.wifi.bin")
case "$board" in
asus,rt-acrh17|\
asus,rt-ac58u)
CI_UBIPART=UBI_DEV
ath10kcal_ubi_extract "Factory" 4096 12064
Expand Down Expand Up @@ -158,6 +159,14 @@ case "$FIRMWARE" in
;;
esac
;;
"ath10k/pre-cal-pci-0000:01:00.0.bin")
case "$board" in
asus,rt-acrh17)
CI_UBIPART=UBI_DEV
ath10kcal_ubi_extract "Factory" 36864 12064
;;
esac
;;
*)
exit 1
;;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

[ -f /lib/adjust_network.sh ] && {
. /lib/adjust_network.sh

adjust_eth_queue
}
18 changes: 18 additions & 0 deletions target/linux/ipq40xx/base-files/etc/init.d/adjust_network
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011 OpenWrt.org

START=11
STOP=98

adjust_smp_affinity() {
test -f /lib/adjust_network.sh && {
. /lib/adjust_network.sh

adjust_edma_smp_affinity
adjust_radio_smp_affinity
}
}

boot() {
adjust_smp_affinity
}
86 changes: 86 additions & 0 deletions target/linux/ipq40xx/base-files/lib/adjust_network.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/bin/sh
# this scripts is used for adjust cpu's choice of interrupts.
#

################################################
# Adjust smp_affinity of edma
# Globals:
# None
# Arguments:
# None
# Returns:
# None
# Remark:
# execute only once on start-up.
################################################
adjust_edma_smp_affinity() {
grep -q edma_eth_ /proc/interrupts || return 0
local nr=`cat /proc/cpuinfo | grep processor | wc -l`
local cpu=0
local tx_irq_num

for tx_num in `seq 0 1 15` ; do
cpu=`printf "%x" $((1<<((tx_num/4+3)%nr)))`
tx_irq_num=`grep -m1 edma_eth_tx$tx_num /proc/interrupts | cut -d ':' -f 1 | tail -n1 | tr -d ' '`
[ -n "$tx_irq_num" ] && echo $cpu > /proc/irq/$tx_irq_num/smp_affinity
done

for rx_num in `seq 0 1 7` ; do
cpu=`printf "%x" $((1<<((rx_num/2)%nr)))`
rx_irq_num=`grep -m1 edma_eth_rx$rx_num /proc/interrupts | cut -d ':' -f 1 | tail -n1 | tr -d ' '`
[ -n "$rx_irq_num" ] && echo $cpu > /proc/irq/$rx_irq_num/smp_affinity
done
}

################################################
# Adjust smp_affinity of ath10k for 2G and 5G
# Globals:
# None
# Arguments:
# None
# Returns:
# None
# Remark:
# execute only once on start-up.
################################################
adjust_radio_smp_affinity() {
local irqs="`grep -E 'ath10k' /proc/interrupts | cut -d ':' -f 1 | tr -d ' '`"
local nr=`cat /proc/cpuinfo | grep processor | wc -l`
local idx=2

for irq in $irqs; do
cpu=`printf "%x" $((1<<((idx)%nr)))`
echo $cpu > /proc/irq/$irq/smp_affinity
idx=$((idx+1))
done
}

################################################
# Adjust queue of eth
# Globals:
# None
# Arguments:
# None
# Returns:
# None
# Remark:
# Each network reboot needs to be executed.
################################################
adjust_eth_queue() {
local nr=`cat /proc/cpuinfo | grep processor | wc -l`
local cpu=`printf "%x" $(((1<<nr)-1))`

for epath in /sys/class/net/eth[0-9]*; do
test -e $epath || break
echo $epath | grep -q "\." && continue
eth=`basename $epath`
for exps in /sys/class/net/$eth/queues/rx-[0-9]*/rps_cpus; do
test -e $exps || break
echo $cpu > $exps
echo 256 > `dirname $exps`/rps_flow_cnt
done
which ethtool >/dev/null 2>&1 && ethtool -K $eth gro off
done

echo 1024 > /proc/sys/net/core/rps_sock_flow_entries
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

preinit_set_mac_address() {
case $(board_name) in
asus,rt-acrh17|\
asus,rt-ac58u)
CI_UBIPART=UBI_DEV
mac=$(mtd_get_mac_binary_ubi Factory 4102)
ifconfig eth0 hw ether $mac 2>/dev/null
;;
meraki,mr33)
mac_lan=$(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 102)
[ -n "$mac_lan" ] && ip link set dev eth0 address "$mac_lan"
Expand Down
Loading

0 comments on commit a8cd67f

Please sign in to comment.