blob: d147e2f40da00ed5fb16308fdc5eac446bd64032 [file] [log] [blame]
developerd0c89452024-10-11 16:53:27 +08001From 67c0e729c31b13fc348746b398857c353e43dab1 Mon Sep 17 00:00:00 2001
developer66e89bc2024-04-23 14:50:01 +08002From: Allen Ye <allen.ye@mediatek.com>
3Date: Mon, 8 Apr 2024 16:56:09 +0800
developerd0c89452024-10-11 16:53:27 +08004Subject: [PATCH 105/223] mtk: mt76: mt7996: Fix get_txpower wrong result in
developer66e89bc2024-04-23 14:50:01 +08005 single wiphy and legacy mode
6
7Fix get_txpower wrong result in single wiphy and legacy mode.
8ieee80211_hw is get from wiphy0, so we need to get correct phy from vif.
9
10Temporarily use link 0 bss due to mac80211 didn't pass link id here.
developer05f3b2b2024-08-19 19:17:34 +080011
developerd0c89452024-10-11 16:53:27 +080012Change-Id: I306897ded276b0e5aee191339f18f0f25ca322f2
developer66e89bc2024-04-23 14:50:01 +080013---
14 mt7996/main.c | 28 +++++++++++++++++++++++++++-
15 1 file changed, 27 insertions(+), 1 deletion(-)
16
17diff --git a/mt7996/main.c b/mt7996/main.c
developerd0c89452024-10-11 16:53:27 +080018index 67948343..b7096901 100644
developer66e89bc2024-04-23 14:50:01 +080019--- a/mt7996/main.c
20+++ b/mt7996/main.c
developer05f3b2b2024-08-19 19:17:34 +080021@@ -982,6 +982,32 @@ out:
developer66e89bc2024-04-23 14:50:01 +080022 mutex_unlock(&dev->mt76.mutex);
23 }
24
25+int mt7996_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
26+ int *dbm)
27+{
28+ struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
29+ struct mt7996_bss_conf *mconf;
30+ struct mt7996_dev *dev = mt7996_hw_dev(hw);
31+ struct mt76_phy *mphy;
32+ int delta;
33+
34+ mutex_lock(&dev->mt76.mutex);
35+ mconf = mconf_dereference_protected(mvif, mvif->master_link_id);
36+ if (!mconf || !mconf->phy) {
37+ *dbm = 0;
38+ goto out;
39+ }
40+
41+ mphy = mconf->phy->mt76;
42+
43+ delta = mt76_tx_power_nss_delta(hweight16(mphy->chainmask));
44+
45+ *dbm = DIV_ROUND_UP(mphy->txpower_cur + delta, 2);
46+out:
47+ mutex_unlock(&dev->mt76.mutex);
48+ return 0;
49+}
50+
51 static void
52 mt7996_channel_switch_beacon(struct ieee80211_hw *hw,
53 struct ieee80211_vif *vif,
developerd0c89452024-10-11 16:53:27 +080054@@ -2673,7 +2699,7 @@ const struct ieee80211_ops mt7996_ops = {
developer66e89bc2024-04-23 14:50:01 +080055 .hw_scan = mt7996_hw_scan,
56 .cancel_hw_scan = mt7996_cancel_hw_scan,
57 .release_buffered_frames = mt76_release_buffered_frames,
58- .get_txpower = mt76_get_txpower,
59+ .get_txpower = mt7996_get_txpower,
60 .channel_switch_beacon = mt7996_channel_switch_beacon,
61 .get_stats = mt7996_get_stats,
62 .get_et_sset_count = mt7996_get_et_sset_count,
63--
developerd0c89452024-10-11 16:53:27 +0800642.45.2
developer66e89bc2024-04-23 14:50:01 +080065