blob: 54719173ad22618378f99b04b67f578203d75979 [file] [log] [blame]
developer9237f442024-06-14 17:13:04 +08001From e993c3e5aecb0d86609ebda85608bf84547b7ca7 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
developer9237f442024-06-14 17:13:04 +08004Subject: [PATCH 112/116] wifi: 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.
developer66e89bc2024-04-23 14:50:01 +080011---
12 mt7996/main.c | 28 +++++++++++++++++++++++++++-
13 1 file changed, 27 insertions(+), 1 deletion(-)
14
15diff --git a/mt7996/main.c b/mt7996/main.c
developer9237f442024-06-14 17:13:04 +080016index d1f2c25..dcb0b07 100644
developer66e89bc2024-04-23 14:50:01 +080017--- a/mt7996/main.c
18+++ b/mt7996/main.c
19@@ -975,6 +975,32 @@ out:
20 mutex_unlock(&dev->mt76.mutex);
21 }
22
23+int mt7996_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
24+ int *dbm)
25+{
26+ struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
27+ struct mt7996_bss_conf *mconf;
28+ struct mt7996_dev *dev = mt7996_hw_dev(hw);
29+ struct mt76_phy *mphy;
30+ int delta;
31+
32+ mutex_lock(&dev->mt76.mutex);
33+ mconf = mconf_dereference_protected(mvif, mvif->master_link_id);
34+ if (!mconf || !mconf->phy) {
35+ *dbm = 0;
36+ goto out;
37+ }
38+
39+ mphy = mconf->phy->mt76;
40+
41+ delta = mt76_tx_power_nss_delta(hweight16(mphy->chainmask));
42+
43+ *dbm = DIV_ROUND_UP(mphy->txpower_cur + delta, 2);
44+out:
45+ mutex_unlock(&dev->mt76.mutex);
46+ return 0;
47+}
48+
49 static void
50 mt7996_channel_switch_beacon(struct ieee80211_hw *hw,
51 struct ieee80211_vif *vif,
52@@ -2635,7 +2661,7 @@ const struct ieee80211_ops mt7996_ops = {
53 .hw_scan = mt7996_hw_scan,
54 .cancel_hw_scan = mt7996_cancel_hw_scan,
55 .release_buffered_frames = mt76_release_buffered_frames,
56- .get_txpower = mt76_get_txpower,
57+ .get_txpower = mt7996_get_txpower,
58 .channel_switch_beacon = mt7996_channel_switch_beacon,
59 .get_stats = mt7996_get_stats,
60 .get_et_sset_count = mt7996_get_et_sset_count,
61--
developer9237f442024-06-14 17:13:04 +0800622.18.0
developer66e89bc2024-04-23 14:50:01 +080063