[rdkb][common][bsp][Refactor ans sync wifi from openwrt]
[Description]
Refactor ans sync wifi from openwrt
b60c867 [MAC80211][mt76][Fix mt7915 testmode crash in cck modulation]
8d29c3e [MAC80211][mt76][wifi: mt76: mt7915: rework mt7915_thermal_init]
a41f333 [MAC80211][app][Add dynamic interface deletion/addition during ATESTART/STOP]
[Release-log]
Change-Id: Ic74f6f59d0106318863314ecfce2b985c43d2a16
diff --git a/recipes-wifi/atenl/files/iwpriv.sh b/recipes-wifi/atenl/files/iwpriv.sh
index c711126..fd25212 100644
--- a/recipes-wifi/atenl/files/iwpriv.sh
+++ b/recipes-wifi/atenl/files/iwpriv.sh
@@ -5,6 +5,7 @@
full_cmd=$3
interface_ori=${interface}
SOC_start_idx="0"
+SOC_end_idx="0"
is_eagle="0"
work_mode="RUN" # RUN/PRINT/DEBUG
@@ -42,7 +43,7 @@
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
+ if [ ${tmp_file} != ${interface_file} ]; then
if [ $phy_idx -lt $SOC_start_idx ]; then
config="${config}_PCIE"
elif [ $phy_idx -ge $SOC_start_idx ]; then
@@ -71,7 +72,7 @@
fi
# check it is SOC(mt7986)/Eagle or PCIE card (mt7915/7916), and write its config
- if [ ${config} != "STARTIDX" ] && [ ${config} != "IS_EAGLE" ]; then
+ if [ ${tmp_file} != ${interface_file} ]; then
if [ $phy_idx -lt $SOC_start_idx ]; then
config="${config}_PCIE"
elif [ $phy_idx -ge $SOC_start_idx ]; then
@@ -86,36 +87,56 @@
fi
}
-function convert_interface {
+function parse_sku {
SOC_start_idx=$(get_config "STARTIDX" ${interface_file})
+ SOC_end_idx=$(get_config "ENDIDX" ${interface_file})
is_eagle=$(get_config "IS_EAGLE" ${interface_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_eagle}" ]; then
if [ ! -z "$(head -c 2 ${eeprom_file} | hexdump | grep "7916")" ]; then
SOC_start_idx="2"
+ SOC_end_idx="3"
is_eagle="0"
elif [ ! -z "$(head -c 2 ${eeprom_file} | hexdump | grep "7915")" ]; then
SOC_start_idx="1"
+ SOC_end_idx="2"
is_eagle="0"
elif [ ! -z "$(head -c 2 ${eeprom_file} | hexdump | grep "7986")" ]; then
SOC_start_idx="0"
+ SOC_end_idx="1"
is_eagle="0"
elif [ ! -z "$(head -c 2 ${eeprom_file} | hexdump | grep "7990")" ]; then
SOC_start_idx="0"
+ SOC_end_idx="2"
is_eagle="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 >> ${interface_file}"
- echo "For AX7800: echo STARTIDX=2 >> ${interface_file}"
- echo "For AX8400: echo STARTIDX=1 >> ${interface_file}"
+ echo "For AX6000:"
+ echo " echo STARTIDX=0 >> ${interface_file}"
+ echo " echo ENDIDX=1 >> ${interface_file}"
+ echo " echo IS_EAGLE=0 >> ${interface_file}"
+ echo "For AX7800:"
+ echo " echo STARTIDX=2 >> ${interface_file}"
+ echo " echo ENDIDX=3 >> ${interface_file}"
+ echo " echo IS_EAGLE=0 >> ${interface_file}"
+ echo "For AX8400:"
+ echo " echo STARTIDX=1 >> ${interface_file}"
+ echo " echo ENDIDX=2 >> ${interface_file}"
+ echo " echo IS_EAGLE=0 >> ${interface_file}"
+ echo "For Eagle:"
+ echo " echo STARTIDX=1 >> ${interface_file}"
+ echo " echo ENDIDX=2 >> ${interface_file}"
+ echo " echo IS_EAGLE=1 >> ${interface_file}"
exit 0
fi
record_config "STARTIDX" ${SOC_start_idx} ${interface_file}
+ record_config "ENDIDX" ${SOC_end_idx} ${interface_file}
record_config "IS_EAGLE" ${is_eagle} ${interface_file}
fi
-
+}
+function convert_interface {
if [ ${is_eagle} == "0" ]; then
if [[ $1 == "raix"* ]]; then
phy_idx=1
@@ -230,7 +251,7 @@
function convert_tx_mode() {
# Remove leading zeros
- local tx_mode=$(echo $1 | sed 's/^0*//')
+ local tx_mode=$(echo $1 | sed -r 's/0+([0-9]+)/\1/g')
if [ "$tx_mode" = "0" ]; then
echo "cck"
@@ -871,7 +892,43 @@
echo "ATE already starts."
else
do_cmd "iw phy ${interface} interface add mon${phy_idx} type monitor"
- do_cmd "iw dev wlan${phy_idx} del"
+
+ if [ $phy_idx -ge $SOC_start_idx ]; then
+ local end_idx=$SOC_end_idx
+ local start_idx=$SOC_start_idx
+ else
+ local end_idx=$((SOC_start_idx-1))
+ local start_idx="0"
+ fi
+
+ for phy_index in $( seq $start_idx $end_idx )
+ do
+ # "phy#-1" would not be in iw dev, therefore it will grep the line from the phy#${phy_index} to the end
+ local prev_phy_index=$((phy_index-1))
+ local if_num=$(iw dev | awk "/phy#${phy_index}/,/phy#${prev_phy_index}/" | grep -c Interface)
+ local j="1"
+ # avoid del_if_count reset to 0 when start ate on another band in dbdc case
+ local del_if_count=$(get_config "DEL_IF${phy_index}_NUM" ${interface_file})
+ if [ -z "${del_if_count}" ]; then
+ local del_if_count="0"
+ fi
+
+ for if_count in $( seq 1 $if_num )
+ do
+ local del_if=$(iw dev | awk "/phy#${phy_index}/,/phy#${prev_phy_index}/" | grep Interface | sed -n ${j}p | cut -d " " -f 2)
+ if [ ! -z "${del_if}" ] && [[ "$del_if" != *"mon"* ]]; then
+ do_cmd "iw dev ${del_if} del"
+ del_if_count=$((del_if_count+1))
+ # handle the case of multiple interface in a phy
+ record_config "DEL_IF${phy_index}-${del_if_count}" ${del_if} ${interface_file}
+ else
+ # j add 1 to skip mon interface
+ j=$((j+1))
+ fi
+ done
+ record_config "DEL_IF${phy_index}_NUM" ${del_if_count} ${interface_file}
+ done
+
do_cmd "ifconfig mon${phy_idx} up"
do_cmd "iw reg set VV"
fi
@@ -884,7 +941,55 @@
else
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"
+
+ if [ $phy_idx -ge $SOC_start_idx ]; then
+ local end_idx=$SOC_end_idx
+ local start_idx=$SOC_start_idx
+ else
+ local end_idx=$((SOC_start_idx-1))
+ local start_idx="0"
+ fi
+
+ # first check its phy and dbdc band phy has monitor interface or not
+ # if has at lease one mon interface, then skip adding back normal interface
+ local has_mon="0"
+ for phy_index in $( seq $start_idx $end_idx )
+ do
+ # "phy#-1" would not be in iw dev, therefore it will grep the line from the phy#${phy_index} to the end
+ local prev_phy_index=$((phy_index-1))
+ local has_mon_phy=$(iw dev | awk "/phy#${phy_index}/,/phy#${prev_phy_index}/" | grep "Interface mon")
+ # if this phy interface has mon interface
+ if [ ! -z "${has_mon_phy}" ]; then
+ local has_mon="1"
+ fi
+ done
+
+ for phy_index in $( seq $start_idx $end_idx )
+ do
+ # "phy#-1" would not be in iw dev, therefore it will grep the line from the phy#${phy_index} to the end
+ local prev_phy_index=$((phy_index-1))
+ local j="1"
+ local add_if_num=$(get_config "DEL_IF${phy_index}_NUM" ${interface_file})
+ if [ -z "${add_if_num}" ]; then
+ local add_if_num="0"
+ fi
+ # if this phy interface (including its dbdc phy) has no mon interface and can find deleted interface in file, then add it back
+ if [ "${has_mon}" == "0" ] && [ $add_if_num -ge "1" ]; then
+ local if_index=$add_if_num
+ # add interface backwards
+ while [ $if_index -gt "0" ]
+ do
+ local add_if=$(get_config "DEL_IF${phy_index}-${if_index}" ${interface_file})
+ do_cmd "iw phy phy${phy_index} interface add ${add_if} type managed"
+ # remove the deleted interface in interface_file since it is added back
+ sed -i "/DEL_IF${phy_index}-${if_index}=/d" ${interface_file}
+ if_index=$((if_index-1))
+ done
+ # remove the number of deleted interface in interface_file since it is all added back
+ sed -i "/DEL_IF${phy_index}_NUM=/d" ${interface_file}
+ fi
+ done
+
do_cmd "mt76-test ${interface} set aid=0"
fi
@@ -993,7 +1098,7 @@
}
# main start here
-
+parse_sku
if [ -z ${interface} ]; then
dump_usage
exit
diff --git a/recipes-wifi/linux-mt76/files/patches/0007-wifi-mt76-mt7915-rework-mt7915_thermal_init.patch b/recipes-wifi/linux-mt76/files/patches/0007-wifi-mt76-mt7915-rework-mt7915_thermal_init.patch
new file mode 100644
index 0000000..f5c250a
--- /dev/null
+++ b/recipes-wifi/linux-mt76/files/patches/0007-wifi-mt76-mt7915-rework-mt7915_thermal_init.patch
@@ -0,0 +1,41 @@
+From 6e2b8db65902a9ed9d0bb323b915657f14f9c740 Mon Sep 17 00:00:00 2001
+From: Howard Hsu <howard-yh.hsu@mediatek.com>
+Date: Thu, 19 Jan 2023 11:03:44 +0800
+Subject: [PATCH] wifi: mt76: mt7915: rework mt7915_thermal_init()
+
+If the kernel configuration "CONFIG_HWMON" is not set to Y, the
+critial/maximum high temperature will not be initialised to the correct
+setting. Rework mt7915_thermal_init to fix this.
+---
+ mt7915/init.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/mt7915/init.c b/mt7915/init.c
+index b23a2fb8..476c1238 100644
+--- a/mt7915/init.c
++++ b/mt7915/init.c
+@@ -203,6 +203,10 @@ static int mt7915_thermal_init(struct mt7915_phy *phy)
+ phy->cdev = cdev;
+ }
+
++ /* initialize critical/maximum high temperature */
++ phy->throttle_temp[MT7915_CRIT_TEMP_IDX] = MT7915_CRIT_TEMP;
++ phy->throttle_temp[MT7915_MAX_TEMP_IDX] = MT7915_MAX_TEMP;
++
+ if (!IS_REACHABLE(CONFIG_HWMON))
+ return 0;
+
+@@ -211,10 +215,6 @@ static int mt7915_thermal_init(struct mt7915_phy *phy)
+ if (IS_ERR(hwmon))
+ return PTR_ERR(hwmon);
+
+- /* initialize critical/maximum high temperature */
+- phy->throttle_temp[MT7915_CRIT_TEMP_IDX] = MT7915_CRIT_TEMP;
+- phy->throttle_temp[MT7915_MAX_TEMP_IDX] = MT7915_MAX_TEMP;
+-
+ return 0;
+ }
+
+--
+2.18.0
+
diff --git a/recipes-wifi/linux-mt76/files/patches/1112-mt76-testmode-additional-supports.patch b/recipes-wifi/linux-mt76/files/patches/1112-mt76-testmode-additional-supports.patch
index 7ea329f..1d9a4de 100644
--- a/recipes-wifi/linux-mt76/files/patches/1112-mt76-testmode-additional-supports.patch
+++ b/recipes-wifi/linux-mt76/files/patches/1112-mt76-testmode-additional-supports.patch
@@ -1,7 +1,7 @@
-From 152f71de255dfaf82baeecf1d554152bc2ef3db2 Mon Sep 17 00:00:00 2001
+From 852090bdc691d094e9ede04ea1e8b5931e35cdd9 Mon Sep 17 00:00:00 2001
From: Shayne Chen <shayne.chen@mediatek.com>
Date: Thu, 21 Apr 2022 15:43:19 +0800
-Subject: [PATCH 1112/1131] mt76: testmode: additional supports
+Subject: [PATCH] mt76: testmode: additional supports
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
---
@@ -11,7 +11,7 @@
mt76_connac_mcu.c | 4 +
mt76_connac_mcu.h | 2 +
mt7915/init.c | 2 +-
- mt7915/mac.c | 37 +-
+ mt7915/mac.c | 39 +-
mt7915/main.c | 2 +-
mt7915/mcu.c | 10 +-
mt7915/mcu.h | 28 +-
@@ -24,13 +24,13 @@
testmode.h | 75 +++
tools/fields.c | 80 ++++
tx.c | 3 +-
- 19 files changed, 1963 insertions(+), 147 deletions(-)
+ 19 files changed, 1964 insertions(+), 148 deletions(-)
diff --git a/dma.c b/dma.c
-index fc24b35..dc8d888 100644
+index 9d1b928..f977b7f 100644
--- a/dma.c
+++ b/dma.c
-@@ -539,8 +539,7 @@ free:
+@@ -567,8 +567,7 @@ free:
if (mt76_is_testmode_skb(dev, skb, &hw)) {
struct mt76_phy *phy = hw->priv;
@@ -288,7 +288,7 @@
mt7915_init_txpower(dev, &dev->mphy.sband_2g.sband);
mt7915_init_txpower(dev, &dev->mphy.sband_5g.sband);
diff --git a/mt7915/mac.c b/mt7915/mac.c
-index fc7b790..0746e4b 100644
+index fc7b790..6ed6eb7 100644
--- a/mt7915/mac.c
+++ b/mt7915/mac.c
@@ -628,16 +628,38 @@ mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, __le32 *txwi,
@@ -333,6 +333,15 @@
switch (td->tx_rate_mode) {
case MT76_TM_TX_MODE_HT:
+@@ -668,7 +690,7 @@ mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, __le32 *txwi,
+ rate_idx += 4;
+
+ r = &phy->mt76->hw->wiphy->bands[band]->bitrates[rate_idx];
+- val = cck ? r->hw_value_short : r->hw_value;
++ val = r->hw_value;
+
+ mode = val >> 8;
+ rate_idx = val & 0xff;
@@ -727,13 +749,14 @@ mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, __le32 *txwi,
if (mode >= MT_PHY_TYPE_HE_SU)
val |= FIELD_PREP(MT_TXD6_HELTF, td->tx_ltf);
@@ -2925,5 +2934,5 @@
wake_up(&dev->tx_wait);
--
-2.36.1
+2.18.0
diff --git a/recipes-wifi/linux-mt76/files/patches/patches.inc b/recipes-wifi/linux-mt76/files/patches/patches.inc
index 9f9b18e..f0f97c2 100644
--- a/recipes-wifi/linux-mt76/files/patches/patches.inc
+++ b/recipes-wifi/linux-mt76/files/patches/patches.inc
@@ -6,6 +6,7 @@
file://0004-wifi-mt76-mt7915-add-error-message-in-mt7915_thermal.patch \
file://0005-wifi-mt76-mt7915-set-sku-initial-value-to-zero.patch \
file://0006-wifi-mt76-mt7915-add-chip-id-condition-in-mt7915_che.patch \
+ file://0007-wifi-mt76-mt7915-rework-mt7915_thermal_init.patch \
file://1001-mt76-mt7915-add-mtk-internal-debug-tools-for-mt76.patch \
file://1002-mt76-mt7915-csi-implement-csi-support.patch \
file://1003-mt76-mt7915-air-monitor-support.patch \