developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 1 | From 67c0e729c31b13fc348746b398857c353e43dab1 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 | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 105/223] 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 | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 12 | Change-Id: I306897ded276b0e5aee191339f18f0f25ca322f2 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 13 | --- |
| 14 | mt7996/main.c | 28 +++++++++++++++++++++++++++- |
| 15 | 1 file changed, 27 insertions(+), 1 deletion(-) |
| 16 | |
| 17 | diff --git a/mt7996/main.c b/mt7996/main.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 18 | index 67948343..b7096901 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 19 | --- a/mt7996/main.c |
| 20 | +++ b/mt7996/main.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 21 | @@ -982,6 +982,32 @@ out: |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 22 | 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, |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 54 | @@ -2673,7 +2699,7 @@ const struct ieee80211_ops mt7996_ops = { |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 55 | .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 | -- |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 64 | 2.45.2 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 65 | |