[][mac80211][wifi6][mt76][Fix unusual Tx/Rx airtime duration values]

[Description]
Fix unusual Tx/Rx airtime duration values when running
"iw dev <devname> station dump".

[Release-log]
N/A


Change-Id: Idf66d36f7dcf1a2a43b291a562e70956dff6d957
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8694736
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/0014-wifi-mt76-mt7915-fix-unusual-Tx-Rx-airtime-duration-.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/0014-wifi-mt76-mt7915-fix-unusual-Tx-Rx-airtime-duration-.patch
new file mode 100644
index 0000000..1438b46
--- /dev/null
+++ b/autobuild_mac80211_release/package/kernel/mt76/patches/0014-wifi-mt76-mt7915-fix-unusual-Tx-Rx-airtime-duration-.patch
@@ -0,0 +1,38 @@
+From b2acf1eea1036709b57e96ced4152fb20f8ec677 Mon Sep 17 00:00:00 2001
+From: Henry Yen <henry.yen@mediatek.com>
+Date: Thu, 22 Feb 2024 11:24:46 +0800
+Subject: [PATCH] wifi: mt76: mt7915: fix unusual Tx/Rx airtime duration values
+
+Fix unusual Tx/Rx airtime duration values when running
+"iw dev <devname> station dump".
+
+Signed-off-by: Henry.Yen <henry.yen@mediatek.com>
+---
+ mt7915/mac.c | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/mt7915/mac.c b/mt7915/mac.c
+index 7b3963f..fe078f4 100644
+--- a/mt7915/mac.c
++++ b/mt7915/mac.c
+@@ -141,8 +141,15 @@ static void mt7915_mac_sta_poll(struct mt7915_dev *dev)
+ 			msta->airtime_ac[i] = mt76_rr(dev, addr);
+ 			msta->airtime_ac[i + 4] = mt76_rr(dev, addr + 4);
+ 
+-			tx_time[i] = msta->airtime_ac[i] - tx_last;
+-			rx_time[i] = msta->airtime_ac[i + 4] - rx_last;
++			if (msta->airtime_ac[i] <= tx_last)
++				tx_time[i] = 0;
++			else
++				tx_time[i] = msta->airtime_ac[i] - tx_last;
++
++			if (msta->airtime_ac[i + 4] <= rx_last)
++				rx_time[i] = 0;
++			else
++				rx_time[i] = msta->airtime_ac[i + 4] - rx_last;
+ 
+ 			if ((tx_last | rx_last) & BIT(30))
+ 				clear = true;
+-- 
+2.18.0
+