developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1 | From cae948de0db9841b932562c2283331155ff182f0 Mon Sep 17 00:00:00 2001 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2 | From: Allen Ye <allen.ye@mediatek.com> |
| 3 | Date: Mon, 8 Apr 2024 16:56:09 +0800 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 117/199] mtk: mt76: mt7996: Fix get_txpower wrong result in |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 5 | single wiphy and legacy mode |
| 6 | |
| 7 | Fix get_txpower wrong result in single wiphy and legacy mode. |
| 8 | ieee80211_hw is get from wiphy0, so we need to get correct phy from vif. |
| 9 | |
| 10 | Temporarily use link 0 bss due to mac80211 didn't pass link id here. |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 11 | |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 12 | --- |
| 13 | mt7996/main.c | 28 +++++++++++++++++++++++++++- |
| 14 | 1 file changed, 27 insertions(+), 1 deletion(-) |
| 15 | |
| 16 | diff --git a/mt7996/main.c b/mt7996/main.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 17 | index 155318b3..7e56f4b0 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 18 | --- a/mt7996/main.c |
| 19 | +++ b/mt7996/main.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 20 | @@ -982,6 +982,32 @@ out: |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 21 | 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, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 53 | @@ -2669,7 +2695,7 @@ const struct ieee80211_ops mt7996_ops = { |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 54 | .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 | -- |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 63 | 2.18.0 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 64 | |