blob: 082b6a739ef45318e0a9fc9f70d4d2545996fd24 [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From cae948de0db9841b932562c2283331155ff182f0 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
developer05f3b2b2024-08-19 19:17:34 +08004Subject: [PATCH 117/199] 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
developer66e89bc2024-04-23 14:50:01 +080012---
13 mt7996/main.c | 28 +++++++++++++++++++++++++++-
14 1 file changed, 27 insertions(+), 1 deletion(-)
15
16diff --git a/mt7996/main.c b/mt7996/main.c
developer05f3b2b2024-08-19 19:17:34 +080017index 155318b3..7e56f4b0 100644
developer66e89bc2024-04-23 14:50:01 +080018--- a/mt7996/main.c
19+++ b/mt7996/main.c
developer05f3b2b2024-08-19 19:17:34 +080020@@ -982,6 +982,32 @@ out:
developer66e89bc2024-04-23 14:50:01 +080021 mutex_unlock(&dev->mt76.mutex);
22 }
23
24+int mt7996_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
25+ int *dbm)
26+{
27+ struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
28+ struct mt7996_bss_conf *mconf;
29+ struct mt7996_dev *dev = mt7996_hw_dev(hw);
30+ struct mt76_phy *mphy;
31+ int delta;
32+
33+ mutex_lock(&dev->mt76.mutex);
34+ mconf = mconf_dereference_protected(mvif, mvif->master_link_id);
35+ if (!mconf || !mconf->phy) {
36+ *dbm = 0;
37+ goto out;
38+ }
39+
40+ mphy = mconf->phy->mt76;
41+
42+ delta = mt76_tx_power_nss_delta(hweight16(mphy->chainmask));
43+
44+ *dbm = DIV_ROUND_UP(mphy->txpower_cur + delta, 2);
45+out:
46+ mutex_unlock(&dev->mt76.mutex);
47+ return 0;
48+}
49+
50 static void
51 mt7996_channel_switch_beacon(struct ieee80211_hw *hw,
52 struct ieee80211_vif *vif,
developer05f3b2b2024-08-19 19:17:34 +080053@@ -2669,7 +2695,7 @@ const struct ieee80211_ops mt7996_ops = {
developer66e89bc2024-04-23 14:50:01 +080054 .hw_scan = mt7996_hw_scan,
55 .cancel_hw_scan = mt7996_cancel_hw_scan,
56 .release_buffered_frames = mt76_release_buffered_frames,
57- .get_txpower = mt76_get_txpower,
58+ .get_txpower = mt7996_get_txpower,
59 .channel_switch_beacon = mt7996_channel_switch_beacon,
60 .get_stats = mt7996_get_stats,
61 .get_et_sset_count = mt7996_get_et_sset_count,
62--
developer9237f442024-06-14 17:13:04 +0800632.18.0
developer66e89bc2024-04-23 14:50:01 +080064