[][MAC80211][app][atenl: update iwpriv wrapper]
[Description]
Add following:
- add ra0/band_idx to phy0/phy1 conversion
- print rx_stat to dmesg to fit iTest autoscript
- add conversion for mac addr setting
- fix set channel conversion
- fix some conversion problems
[Release-log]
N/A
Change-Id: I79ea76d817fe880bc1df2c4db568b363472b9722
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/5702581
diff --git a/feed/atenl/files/iwpriv.sh b/feed/atenl/files/iwpriv.sh
index 075be04..c6b3c11 100755
--- a/feed/atenl/files/iwpriv.sh
+++ b/feed/atenl/files/iwpriv.sh
@@ -1,16 +1,13 @@
#!/bin/ash
-interface=$1
-cmd_type=$2
+interface=$1 # phy0/phy1/ra0
+cmd_type=$2 # set/show/e2p/mac
full_cmd=$3
work_mode="RUN" # RUN/PRINT/DEBUG
-tmp_file="$HOME/.tmp_ate_config"
+tmp_file="/tmp/iwpriv_wrapper"
phy_idx=$(echo ${interface} | tr -dc '0-9')
-cmd=$(echo ${full_cmd} | sed s/=/' '/g | cut -d " " -f 1)
-param=$(echo ${full_cmd} | sed s/=/' '/g | cut -d " " -f 2)
-
function do_cmd() {
case ${work_mode} in
"RUN")
@@ -26,6 +23,10 @@
esac
}
+function write_dmesg() {
+ echo "$1" > /dev/kmsg
+}
+
function record_config() {
if [ -f ${tmp_file} ]; then
if grep -q $1 ${tmp_file}; then
@@ -39,7 +40,16 @@
}
function get_config() {
- echo "$(cat ${tmp_file} | grep $1 | sed s/=/' '/g | cut -d " " -f 2)"
+ if [ ! -f ${tmp_file} ]; then
+ echo ""
+ return
+ fi
+
+ if grep -q $1 ${tmp_file}; then
+ echo "$(cat ${tmp_file} | grep $1 | sed s/=/' '/g | cut -d " " -f 2)"
+ else
+ echo ""
+ fi
}
function simple_convert() {
@@ -170,8 +180,9 @@
local band=$(echo $1 | sed s/:/' '/g | cut -d " " -f 2)
local ch=$(echo $1 | sed s/:/' '/g | cut -d " " -f 1)
local bw=$(get_config "ATETXBW" | cut -d ":" -f 1)
+ local bw_str="HT20"
- if [ "${band}" = "0" ]; then
+ if [ -z "${band}" ] || [ "${band}" = "0" ]; then
case ${bw} in
"1")
if [ "${ch}" -ge "1" ] && [ "${ch}" -le "7" ]; then
@@ -180,27 +191,98 @@
local bw_str="HT40-"
fi
;;
- "0")
- local bw_str="HT20"
- ;;
esac
elif [ "${band}" = "1" ]; then
case ${bw} in
"5")
- local bw_str="160MHz"
+ bw_str="160MHz"
+ if [ ${ch} -lt "68" ]; then
+ ch="36"
+ elif [ ${ch} -lt "100" ]; then
+ ch="68"
+ elif [ ${ch} -lt "132" ]; then
+ ch="100"
+ elif [ ${ch} -lt "181" ]; then
+ ch="149"
+ fi
;;
"2")
- local bw_str="80MHz"
+ bw_str="80MHz"
+ if [ ${ch} -lt "52" ]; then
+ ch="36"
+ elif [ ${ch} -lt "68" ]; then
+ ch="52"
+ elif [ ${ch} -lt "84" ]; then
+ ch="68"
+ elif [ ${ch} -lt "100" ]; then
+ ch="84"
+ elif [ ${ch} -lt "116" ]; then
+ ch="100"
+ elif [ ${ch} -lt "132" ]; then
+ ch="116"
+ elif [ ${ch} -lt "149" ]; then
+ ch="132"
+ elif [ ${ch} -lt "165" ]; then
+ ch="149"
+ elif [ ${ch} -lt "181" ]; then
+ ch="165"
+ fi
;;
"1")
- if [ "${ch}" == "36" ] || [ "${ch}" == "44" ] || [ "${ch}" == "52" ] || [ "${ch}" == "60" ] || \
- [ "${ch}" == "100" ] || [ "${ch}" == "108" ] || [ "${ch}" == "116" ] || [ "${ch}" == "124" ] || \
- [ "${ch}" == "132" ] || [ "${ch}" == "132" ] || [ "${ch}" == "140" ] || [ "${ch}" == "149" ] || \
- [ "${ch}" == "157" ]
- then
- local bw_str="HT40+"
- else
- local bw_str="HT40-"
+ if [ ${ch} -lt "44" ]; then
+ ch=$([ "${ch}" -lt "40" ] && echo "36" || echo "40")
+ bw_str=$([ "${ch}" -le "38" ] && echo "HT40+" || echo "HT40-")
+ elif [ ${ch} -lt "52" ]; then
+ ch=$([ "${ch}" -lt "48" ] && echo "44" || echo "48")
+ bw_str=$([ "${ch}" -le "46" ] && echo "HT40+" || echo "HT40-")
+ elif [ ${ch} -lt "60" ]; then
+ ch=$([ "${ch}" -lt "56" ] && echo "52" || echo "56")
+ bw_str=$([ "${ch}" -le "54" ] && echo "HT40+" || echo "HT40-")
+ elif [ ${ch} -lt "68" ]; then
+ ch=$([ "${ch}" -lt "64" ] && echo "60" || echo "64")
+ bw_str=$([ "${ch}" -le "62" ] && echo "HT40+" || echo "HT40-")
+ elif [ ${ch} -lt "76" ]; then
+ ch=$([ "${ch}" -lt "72" ] && echo "68" || echo "72")
+ bw_str=$([ "${ch}" -le "70" ] && echo "HT40+" || echo "HT40-")
+ elif [ ${ch} -lt "84" ]; then
+ ch=$([ "${ch}" -lt "80" ] && echo "76" || echo "80")
+ bw_str=$([ "${ch}" -le "78" ] && echo "HT40+" || echo "HT40-")
+ elif [ ${ch} -lt "92" ]; then
+ ch=$([ "${ch}" -lt "88" ] && echo "84" || echo "88")
+ bw_str=$([ "${ch}" -le "86" ] && echo "HT40+" || echo "HT40-")
+ elif [ ${ch} -lt "100" ]; then
+ ch=$([ "${ch}" -lt "96" ] && echo "92" || echo "96")
+ bw_str=$([ "${ch}" -le "94" ] && echo "HT40+" || echo "HT40-")
+ elif [ ${ch} -lt "108" ]; then
+ ch=$([ "${ch}" -lt "104" ] && echo "100" || echo "104")
+ bw_str=$([ "${ch}" -le "102" ] && echo "HT40+" || echo "HT40-")
+ elif [ ${ch} -lt "116" ]; then
+ ch=$([ "${ch}" -lt "112" ] && echo "108" || echo "112")
+ bw_str=$([ "${ch}" -le "110" ] && echo "HT40+" || echo "HT40-")
+ elif [ ${ch} -lt "124" ]; then
+ ch=$([ "${ch}" -lt "120" ] && echo "116" || echo "120")
+ bw_str=$([ "${ch}" -le "118" ] && echo "HT40+" || echo "HT40-")
+ elif [ ${ch} -lt "132" ]; then
+ ch=$([ "${ch}" -lt "128" ] && echo "124" || echo "128")
+ bw_str=$([ "${ch}" -le "126" ] && echo "HT40+" || echo "HT40-")
+ elif [ ${ch} -lt "140" ]; then
+ ch=$([ "${ch}" -lt "136" ] && echo "132" || echo "136")
+ bw_str=$([ "${ch}" -le "134" ] && echo "HT40+" || echo "HT40-")
+ elif [ ${ch} -lt "149" ]; then
+ ch=$([ "${ch}" -lt "144" ] && echo "140" || echo "144")
+ bw_str=$([ "${ch}" -le "142" ] && echo "HT40+" || echo "HT40-")
+ elif [ ${ch} -lt "157" ]; then
+ ch=$([ "${ch}" -lt "153" ] && echo "149" || echo "153")
+ bw_str=$([ "${ch}" -le "151" ] && echo "HT40+" || echo "HT40-")
+ elif [ ${ch} -lt "165" ]; then
+ ch=$([ "${ch}" -lt "161" ] && echo "157" || echo "161")
+ bw_str=$([ "${ch}" -le "159" ] && echo "HT40+" || echo "HT40-")
+ elif [ ${ch} -lt "173" ]; then
+ ch=$([ "${ch}" -lt "169" ] && echo "165" || echo "169")
+ bw_str=$([ "${ch}" -le "167" ] && echo "HT40+" || echo "HT40-")
+ elif [ ${ch} -lt "181" ]; then
+ ch=$([ "${ch}" -lt "177" ] && echo "173" || echo "177")
+ bw_str=$([ "${ch}" -le "175" ] && echo "HT40+" || echo "HT40-")
fi
;;
"0")
@@ -214,6 +296,68 @@
do_cmd "iw dev mon${phy_idx} set channel ${ch} ${bw_str}"
}
+function convert_rxstat {
+ local res=$(do_cmd "mt76-test ${interface} dump stats")
+ local mdrdy=$(echo "${res}" | grep "rx_packets" | cut -d "=" -f 2)
+ local fcs_error=$(echo "${res}" | grep "rx_fcs_error" | cut -d "=" -f 2)
+ local rcpi=$(echo "${res}" | grep "last_rcpi" | cut -d "=" -f 2 | sed 's/,/ /g')
+ local ib_rssi=$(echo "${res}" | grep "last_ib_rssi" | cut -d "=" -f 2 | sed 's/,/ /g')
+ local wb_rssi=$(echo "${res}" | grep "last_wb_rssi" | cut -d "=" -f 2 | sed 's/,/ /g')
+ local rx_ok=$(expr ${mdrdy} - ${fcs_error})
+
+ write_dmesg "rcpi: ${rcpi}"
+ write_dmesg "fagc rssi ib: ${ib_rssi}"
+ write_dmesg "fagc rssi wb: ${wb_rssi}"
+ write_dmesg "all_mac_rx_mdrdy_cnt: ${mdrdy}"
+ write_dmesg "all_mac_rx_fcs_err_cnt: ${fcs_error}"
+ write_dmesg "all_mac_rx_ok_cnt: ${rx_ok}"
+}
+
+function change_band_idx {
+ local old_idx=$(get_config "ATECTRLBANDIDX")
+ local new_idx=$1
+
+ if [ -z "${old_idx}" ] && [ "${new_idx}" == "0" ]; then
+ return
+ fi
+
+ if [ "${old_idx}" != "${new_idx}" ]; then
+ if [ -z "${old_idx}" ]; then
+ old_idx=0
+ fi
+
+ interface="phy${old_idx}"
+ phy_idx=${old_idx}
+ do_ate_work "ATESTOP"
+
+ interface="phy${new_idx}"
+ phy_idx=${new_idx}
+ do_ate_work "ATESTART"
+
+ record_config "ATECTRLBANDIDX" ${new_idx}
+ fi
+}
+
+function set_mac_addr {
+ record_config ${cmd} ${param}
+
+ local addr1=$(get_config "ATEDA")
+ local addr2=$(get_config "ATESA")
+ local addr3=$(get_config "ATEBSSID")
+
+ if [ -z "${addr1}" ]; then
+ addr1="00:11:22:33:44:55"
+ fi
+ if [ -z "${addr2}" ]; then
+ addr2="00:11:22:33:44:55"
+ fi
+ if [ -z "${addr3}" ]; then
+ addr3="00:11:22:33:44:55"
+ fi
+
+ do_cmd "mt76-test phy${phy_idx} set mac_addrs=${addr1},${addr2},${addr3}"
+}
+
function do_ate_work() {
local ate_cmd=$1
@@ -238,8 +382,9 @@
do_cmd "mt76-test ${interface} set state=off"
do_cmd "iw dev mon${phy_idx} del"
do_cmd "iw phy ${interface} interface add wlan${phy_idx} type managed"
- do_cmd "ifconfig wlan${phy_idx} up"
fi
+
+ rm ${tmp_file} > /dev/null 2>&1
;;
"TXFRAME")
do_cmd "mt76-test ${interface} set state=tx_frames"
@@ -267,6 +412,22 @@
esac
}
+# main start here
+
+if [[ ${interface} == "ra"* ]]; then
+ tmp=$(get_config "ATECTRLBANDIDX")
+ if [ ! -z "${tmp}" ]; then
+ interface="phy${tmp}"
+ phy_idx=${tmp}
+ else
+ interface="phy0"
+ phy_idx=0
+ fi
+fi
+
+cmd=$(echo ${full_cmd} | sed s/=/' '/g | cut -d " " -f 1)
+param=$(echo ${full_cmd} | sed s/=/' '/g | cut -d " " -f 2)
+
if [ "${cmd_type}" = "set" ]; then
skip=0
use_ated=0
@@ -307,10 +468,18 @@
convert_channel ${param}
skip=1
;;
+ "ATERXSTAT")
+ convert_rxstat
+ skip=1
+ ;;
"ATECTRLBANDIDX")
- echo "Unused command, please use phy0/phy1 to switch"
+ change_band_idx ${param}
skip=1
;;
+ "ATEDA"|"ATESA"|"ATEBSSID")
+ set_mac_addr ${cmd} ${param}
+ skip=1
+ ;;
"bufferMode")
if [ "${param}" = "2" ]; then
do_cmd "ated -i ${interface} -c \"eeprom update\""
@@ -328,9 +497,11 @@
if [ "${skip}" != "1" ]; then
do_cmd "mt76-test ${interface} set ${cmd_new}=${param_new}"
fi
+
elif [ "${cmd_type}" = "show" ]; then
do_cmd "mt76-test ${interface} dump"
do_cmd "mt76-test ${interface} dump stats"
+
elif [ "${cmd_type}" = "e2p" ]; then
offset=$(printf "0x%s" ${cmd})
val=$(printf "0x%s" ${param})
@@ -361,6 +532,7 @@
param=$(printf "0x%s" ${param})
printf "[0x%04x]:0x%02x%02x\n" ${param} ${v2} ${v1}
fi
+
elif [ "${cmd_type}" = "mac" ]; then
regidx=/sys/kernel/debug/ieee80211/phy${phy_idx}/mt76/regidx
regval=/sys/kernel/debug/ieee80211/phy${phy_idx}/mt76/regval
@@ -375,6 +547,7 @@
res=$(cat ${regval} | cut -d 'x' -f 2)
printf "%s mac:[%s]:%s\n" ${interface} ${offset} ${res}
fi
+
else
echo "Unknown command"
fi