[][MAC80211][WiFi6/7][app][Add single wiphy support for atenl & iwpriv wrapper]
[Description]
Add single wiphy support for atenl & iwpirv wrapper
To support single wiphy, main phy idx is used for debugfs in atenl &
iwpriv wrapper.
[Release-log]
N/A
Change-Id: Ic146442a8838cd812be9e92ce3e4f5e5f32c91fe
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/9176525
diff --git a/feed/app/atenl/files/ated.sh b/feed/app/atenl/files/ated.sh
index e989e44..9037054 100755
--- a/feed/app/atenl/files/ated.sh
+++ b/feed/app/atenl/files/ated.sh
@@ -9,8 +9,10 @@
interface=""
phy_idx=0
ated_file="/tmp/interface"
+iwpriv_file="/tmp/iwpriv_wrapper"
SOC_start_idx="0"
-is_eagle="0"
+SOC_end_idx="0"
+is_connac3="0"
function do_cmd() {
case ${work_mode} in
@@ -31,8 +33,8 @@
local config=$1
local tmp_file=$3
- # check it is SOC(mt7986)/Eagle or PCIE card (mt7915/7916), and write its config
- if [ ${config} != "STARTIDX" ] && [ ${config} != "IS_EAGLE" ]; then
+ # check it is SOC(mt7986)/Eagle/Kite or PCIE card (mt7915/7916), and write its config
+ if [ ${config} != "STARTIDX" ] && [ ${config} != "ENDIDX" ] && [ ${config} != "IS_CONNAC3" ]; then
if [ $phy_idx -lt $SOC_start_idx ]; then
config="${config}_PCIE"
elif [ $phy_idx -ge $SOC_start_idx ]; then
@@ -60,8 +62,8 @@
return
fi
- # check it is SOC(mt7986)/Eagle or PCIE card (mt7915/7916), and write its config
- if [ ${config} != "STARTIDX" ] && [ ${config} != "IS_EAGLE" ]; then
+ # check it is SOC(mt7986)/Eagle/Kite or PCIE card (mt7915/7916), and write its config
+ if [ ${config} != "STARTIDX" ] && [ ${config} != "ENDIDX" ] && [ ${config} != "IS_CONNAC3" ]; then
if [ $phy_idx -lt $SOC_start_idx ]; then
config="${config}_PCIE"
elif [ $phy_idx -ge $SOC_start_idx ]; then
@@ -76,37 +78,69 @@
fi
}
-function convert_interface {
+function parse_sku {
SOC_start_idx=$(get_config "STARTIDX" ${ated_file})
- is_eagle=$(get_config "IS_EAGLE" ${ated_file})
+ SOC_end_idx=$(get_config "ENDIDX" ${ated_file})
+ is_connac3=$(get_config "IS_CONNAC3" ${ated_file})
local eeprom_file=/sys/kernel/debug/ieee80211/phy0/mt76/eeprom
- if [ -z "${SOC_start_idx}" ] || [ -z "${is_eagle}" ]; then
+ if [ -z "${SOC_start_idx}" ] || [ -z "${SOC_end_idx}" ] || [ -z "${is_connac3}" ]; then
if [ ! -z "$(head -c 2 ${eeprom_file} | hexdump | grep "7916")" ]; then
SOC_start_idx="2"
- is_eagle="0"
+ SOC_end_idx="3"
+ is_connac3="0"
elif [ ! -z "$(head -c 2 ${eeprom_file} | hexdump | grep "7915")" ]; then
SOC_start_idx="1"
- is_eagle="0"
+ SOC_end_idx="2"
+ is_connac3="0"
+ elif [ ! -z "$(head -c 2 ${eeprom_file} | hexdump | grep "7981")" ]; then
+ SOC_start_idx="0"
+ SOC_end_idx="1"
+ is_connac3="0"
elif [ ! -z "$(head -c 2 ${eeprom_file} | hexdump | grep "7986")" ]; then
SOC_start_idx="0"
- is_eagle="0"
+ SOC_end_idx="1"
+ is_connac3="0"
elif [ ! -z "$(head -c 2 ${eeprom_file} | hexdump | grep "7990")" ]; then
SOC_start_idx="0"
+ SOC_end_idx="2"
+ is_connac3="1"
+ elif [ ! -z "$(head -c 2 ${eeprom_file} | hexdump | grep "7992")" ]; then
+ SOC_start_idx="0"
- is_eagle="1"
+ SOC_end_idx="1"
+ is_connac3="1"
else
echo "Interface Conversion Failed!"
echo "Please use iwpriv <phy0/phy1/..> set <...> or configure the sku of your board manually by the following commands"
- echo "For AX6000/Eagle: echo STARTIDX=0 >> ${ated_file}"
- echo "For AX7800: echo STARTIDX=2 >> ${ated_file}"
- echo "For AX8400: echo STARTIDX=1 >> ${ated_file}"
+ echo "For AX3000/AX6000:"
+ echo " echo STARTIDX=0 >> ${ated_file}"
+ echo " echo ENDIDX=1 >> ${ated_file}"
+ echo " echo IS_CONNAC3=0 >> ${ated_file}"
+ echo "For AX7800:"
+ echo " echo STARTIDX=2 >> ${ated_file}"
+ echo " echo ENDIDX=3 >> ${ated_file}"
+ echo " echo IS_CONNAC3=0 >> ${ated_file}"
+ echo "For AX8400:"
+ echo " echo STARTIDX=1 >> ${ated_file}"
+ echo " echo ENDIDX=2 >> ${ated_file}"
+ echo " echo IS_CONNAC3=0 >> ${ated_file}"
+ echo "For Eagle:"
+ echo " echo STARTIDX=0 >> ${ated_file}"
+ echo " echo ENDIDX=2 >> ${ated_file}"
+ echo " echo IS_CONNAC3=1 >> ${ated_file}"
+ echo "For Kite:"
+ echo " echo STARTIDX=0 >> ${ated_file}"
+ echo " echo ENDIDX=1 >> ${ated_file}"
+ echo " echo IS_CONNAC3=1 >> ${ated_file}"
exit 0
fi
record_config "STARTIDX" ${SOC_start_idx} ${ated_file}
- record_config "IS_EAGLE" ${is_eagle} ${ated_file}
+ record_config "ENDIDX" ${SOC_end_idx} ${ated_file}
+ record_config "IS_CONNAC3" ${is_connac3} ${ated_file}
fi
-
+}
- if [ ${is_eagle} == "0" ]; then
+function convert_interface {
+ if [ ${is_connac3} == "0" ]; then
if [[ $1 == "raix"* ]]; then
phy_idx=1
elif [[ $1 == "rai"* ]]; then
@@ -118,7 +152,7 @@
fi
# convert phy index according to band idx
- local band_idx=$(get_config "ATECTRLBANDIDX" ${ated_file})
+ local band_idx=$(get_config "ATECTRLBANDIDX" ${iwpriv_file})
if [ "${band_idx}" = "0" ]; then
if [[ $1 == "raix"* ]]; then
phy_idx=0
@@ -135,7 +169,7 @@
fi
fi
else
- # Eagle has different mapping method
+ # Connac 3 chips has different mapping method
# phy0: ra0
# phy1: rai0
# phy2: rax0
@@ -162,6 +196,7 @@
add_quote="0"
else
if [[ ${i} == "ra"* ]]; then
+ parse_sku
convert_interface $i
cmd="${cmd} ${interface}"
else
diff --git a/feed/app/atenl/files/iwpriv.sh b/feed/app/atenl/files/iwpriv.sh
index c2b2b88..0dde191 100755
--- a/feed/app/atenl/files/iwpriv.sh
+++ b/feed/app/atenl/files/iwpriv.sh
@@ -12,6 +12,7 @@
iwpriv_file="/tmp/iwpriv_wrapper"
interface_file="/tmp/interface"
phy_idx=$(echo ${interface} | tr -dc '0-9')
+main_phy_idx=0
function do_cmd() {
case ${work_mode} in
@@ -42,7 +43,7 @@
local config=$1
local tmp_file=$3
- # check it is SOC(mt7986)/Eagle or PCIE card (mt7915/7916), and write its config
+ # check it is SOC(mt7986)/Eagle/Kite or PCIE card (mt7915/7916), and write its config
if [ ${tmp_file} != ${interface_file} ]; then
if [ $phy_idx -lt $SOC_start_idx ]; then
config="${config}_PCIE"
@@ -71,7 +72,7 @@
return
fi
- # check it is SOC(mt7986)/Eagle or PCIE card (mt7915/7916), and write its config
+ # check it is SOC(mt7986)/Eagle/Kite or PCIE card (mt7915/7916), and write its config
if [ ${tmp_file} != ${interface_file} ]; then
if [ $phy_idx -lt $SOC_start_idx ]; then
config="${config}_PCIE"
@@ -178,7 +179,7 @@
fi
fi
else
- # Eagle has different mapping method
+ # Connac 3 chips has different mapping method
# phy0: ra0
# phy1: rai0
# phy2: rax0
@@ -1167,14 +1168,13 @@
function register_handler {
- local phy_idx=$1
- local offset=$2
- local val=$3
- local cmd=$4
+ local offset=$1
+ local val=$2
+ local cmd=$3
local w_cmd="write"
- regidx=/sys/kernel/debug/ieee80211/phy${phy_idx}/mt76/regidx
- regval=/sys/kernel/debug/ieee80211/phy${phy_idx}/mt76/regval
+ regidx=/sys/kernel/debug/ieee80211/phy${main_phy_idx}/mt76/regidx
+ regval=/sys/kernel/debug/ieee80211/phy${main_phy_idx}/mt76/regval
echo ${offset} > ${regidx}
if [[ "${cmd}" == "${w_cmd}" ]]; then
@@ -1199,6 +1199,11 @@
full_cmd=$4
fi
+# get main phy idx
+if [ "${phy_idx}" -ge "${SOC_start_idx}" ]; then
+ main_phy_idx=${SOC_start_idx}
+fi
+
tmp_work_mode=$(get_config "WORKMODE" ${iwpriv_file})
if [ ! -z ${tmp_work_mode} ]; then
@@ -1344,8 +1349,8 @@
elif [ "${cmd_type}" = "show" ]; then
if [ "${cmd}" = "wtbl" ]; then
- wlan_idx=/sys/kernel/debug/ieee80211/phy${phy_idx}/mt76/wlan_idx
- wtbl_info=/sys/kernel/debug/ieee80211/phy${phy_idx}/mt76/wtbl_info
+ wlan_idx=/sys/kernel/debug/ieee80211/phy${main_phy_idx}/mt76/wlan_idx
+ wtbl_info=/sys/kernel/debug/ieee80211/phy${main_phy_idx}/mt76/wtbl_info
do_cmd "echo ${param} > ${wlan_idx}"
do_cmd "cat ${wtbl_info}"
@@ -1410,20 +1415,20 @@
# reg write
if [[ ${full_cmd} == *"="* ]]; then
- register_handler ${phy_idx} ${offset} ${val} "write"
+ register_handler ${offset} ${val} "write"
else
start_addr=$(echo ${full_cmd} | sed s/-/' '/g | cut -d " " -f 1)
end_addr=$(echo ${full_cmd} | sed s/-/' '/g | cut -d " " -f 2)
loop=$((0x${end_addr}-0x${start_addr}))
if [[ ${loop} == "0" ]]; then
- register_handler ${phy_idx} ${offset} ${val}
+ register_handler ${offset} ${val}
else
i=0
while [ $i -le $loop ]; do
addr=$((0x${start_addr}+$i))
offset=$(printf "0x%x" ${addr})
- register_handler ${phy_idx} ${offset} ${val}
+ register_handler ${offset} ${val}
i=$(($i + 4))
done
fi
diff --git a/feed/app/atenl/src/atenl.h b/feed/app/atenl/src/atenl.h
index a5f9fbb..a6695c9 100644
--- a/feed/app/atenl/src/atenl.h
+++ b/feed/app/atenl/src/atenl.h
@@ -85,6 +85,7 @@
u16 adie_id;
u8 sub_chip_id;
u8 cur_band;
+ u8 main_phy_idx;
u8 mac_addr[ETH_ALEN];
char *bridge_name;
diff --git a/feed/app/atenl/src/eeprom.c b/feed/app/atenl/src/eeprom.c
index d112dc7..b3a652a 100644
--- a/feed/app/atenl/src/eeprom.c
+++ b/feed/app/atenl/src/eeprom.c
@@ -27,7 +27,7 @@
snprintf(fname, sizeof(fname),
"/sys/kernel/debug/ieee80211/phy%d/mt76/eeprom",
- get_band_val(an, 0, phy_idx));
+ an->main_phy_idx);
fd_ori = open(fname, O_RDONLY);
if (fd_ori < 0)
return -1;
@@ -344,17 +344,14 @@
bool flash_mode;
int eeprom_fd;
char buf[30];
- u8 main_phy_idx = phy_idx;
set_band_val(an, 0, phy_idx, phy_idx);
atenl_nl_check_mtd(an);
flash_mode = an->mtd_part != NULL;
// Get the first main phy index for this chip
- if (flash_mode)
- main_phy_idx -= an->band_idx;
-
- snprintf(buf, sizeof(buf), "/tmp/atenl-eeprom-phy%u", main_phy_idx);
+ an->main_phy_idx = phy_idx - an->band_idx;
+ snprintf(buf, sizeof(buf), "/tmp/atenl-eeprom-phy%u", an->main_phy_idx);
eeprom_file = strdup(buf);
eeprom_fd = atenl_eeprom_init_file(an, flash_mode);
@@ -461,7 +458,7 @@
snprintf(fname, sizeof(fname),
"/sys/kernel/debug/ieee80211/phy%d/mt76/eeprom",
- get_band_val(an, 0, phy_idx));
+ an->main_phy_idx);
fd_ori = open(fname, O_RDONLY);
if (fd_ori < 0)
return -1;
diff --git a/feed/app/atenl/src/nl.c b/feed/app/atenl/src/nl.c
index 6850fc8..baf2944 100644
--- a/feed/app/atenl/src/nl.c
+++ b/feed/app/atenl/src/nl.c
@@ -1199,12 +1199,13 @@
return NL_SKIP;
nla_parse_nested(tb, MT76_TM_ATTR_MAX, attr, testdata_policy);
+ an->band_idx = nla_get_u32(tb[MT76_TM_ATTR_BAND_IDX]);
+
if (!tb[MT76_TM_ATTR_MTD_PART] || !tb[MT76_TM_ATTR_MTD_OFFSET])
return NL_SKIP;
an->mtd_part = strdup(nla_get_string(tb[MT76_TM_ATTR_MTD_PART]));
an->mtd_offset = nla_get_u32(tb[MT76_TM_ATTR_MTD_OFFSET]);
- an->band_idx = nla_get_u32(tb[MT76_TM_ATTR_BAND_IDX]);
return NL_SKIP;
}
diff --git a/feed/app/atenl/src/util.c b/feed/app/atenl/src/util.c
index b224040..109e7db 100644
--- a/feed/app/atenl/src/util.c
+++ b/feed/app/atenl/src/util.c
@@ -11,7 +11,7 @@
/* write offset into regidx */
ret = snprintf(dir, sizeof(dir),
"/sys/kernel/debug/ieee80211/phy%d/mt76/regidx",
- get_band_val(an, 0, phy_idx));
+ an->main_phy_idx);
if (snprintf_error(sizeof(dir), ret))
return ret;
@@ -30,7 +30,7 @@
/* read value from regval */
ret = snprintf(dir, sizeof(dir),
"/sys/kernel/debug/ieee80211/phy%d/mt76/regval",
- get_band_val(an, 0, phy_idx));
+ an->main_phy_idx);
if (snprintf_error(sizeof(dir), ret))
return ret;
@@ -63,7 +63,7 @@
/* write offset into regidx */
ret = snprintf(dir, sizeof(dir),
"/sys/kernel/debug/ieee80211/phy%d/mt76/regidx",
- get_band_val(an, 0, phy_idx));
+ an->main_phy_idx);
if (snprintf_error(sizeof(dir), ret))
return ret;
@@ -82,7 +82,7 @@
/* write value into regval */
ret = snprintf(dir, sizeof(dir),
"/sys/kernel/debug/ieee80211/phy%d/mt76/regval",
- get_band_val(an, 0, phy_idx));
+ an->main_phy_idx);
if (snprintf_error(sizeof(dir), ret))
return ret;
@@ -118,7 +118,7 @@
/* write regidx */
ret = snprintf(dir, sizeof(dir),
"/sys/kernel/debug/ieee80211/phy%d/mt76/regidx",
- get_band_val(an, 0, phy_idx));
+ an->main_phy_idx);
if (snprintf_error(sizeof(dir), ret))
return ret;
@@ -137,7 +137,7 @@
/* read from rf_regval */
ret = snprintf(dir, sizeof(dir),
"/sys/kernel/debug/ieee80211/phy%d/mt76/rf_regval",
- get_band_val(an, 0, phy_idx));
+ an->main_phy_idx);
if (snprintf_error(sizeof(dir), ret))
return ret;
@@ -175,7 +175,7 @@
/* write regidx */
ret = snprintf(dir, sizeof(dir),
"/sys/kernel/debug/ieee80211/phy%d/mt76/regidx",
- get_band_val(an, 0, phy_idx));
+ an->main_phy_idx);
if (snprintf_error(sizeof(dir), ret))
return ret;
@@ -194,7 +194,7 @@
/* write value into rf_val */
ret = snprintf(dir, sizeof(dir),
"/sys/kernel/debug/ieee80211/phy%d/mt76/rf_regval",
- get_band_val(an, 0, phy_idx));
+ an->main_phy_idx);
if (snprintf_error(sizeof(dir), ret))
return ret;