From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Subject: [PATCH 7/8] wifi: mt76: mt7996: implement driver specific get_txpower function
Date: Tue, 11 Mar 2025 11:36:44 +0100 [thread overview]
Message-ID: <20250311103646.43346-7-nbd@nbd.name> (raw)
In-Reply-To: <20250311103646.43346-1-nbd@nbd.name>
Fixes reporting tx power for vifs that don't have a channel context
assigned. Report the tx power of a phy that is covered by the vif's
radio mask.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../net/wireless/mediatek/mt76/mt7996/main.c | 27 ++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
index 886b6ef3462b..89fc3f102555 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
@@ -602,6 +602,31 @@ static void mt7996_configure_filter(struct ieee80211_hw *hw,
mutex_unlock(&dev->mt76.mutex);
}
+static int
+mt7996_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif, int *dbm)
+{
+ struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
+ struct mt7996_phy *phy = mt7996_vif_link_phy(&mvif->deflink);
+ struct mt7996_dev *dev = mt7996_hw_dev(hw);
+ struct wireless_dev *wdev;
+ int n_chains, delta, i;
+
+ if (!phy) {
+ wdev = ieee80211_vif_to_wdev(vif);
+ for (i = 0; i < hw->wiphy->n_radio; i++)
+ if (wdev->radio_mask & BIT(i))
+ phy = dev->radio_phy[i];
+
+ if (!phy)
+ return -EINVAL;
+ }
+
+ n_chains = hweight16(phy->mt76->chainmask);
+ delta = mt76_tx_power_nss_delta(n_chains);
+ *dbm = DIV_ROUND_UP(phy->mt76->txpower_cur + delta, 2);
+
+ return 0;
+}
static u8
mt7996_get_rates_table(struct mt7996_phy *phy, struct ieee80211_bss_conf *conf,
bool beacon, bool mcast)
@@ -1651,7 +1676,7 @@ const struct ieee80211_ops mt7996_ops = {
.remain_on_channel = mt76_remain_on_channel,
.cancel_remain_on_channel = mt76_cancel_remain_on_channel,
.release_buffered_frames = mt76_release_buffered_frames,
- .get_txpower = mt76_get_txpower,
+ .get_txpower = mt7996_get_txpower,
.channel_switch_beacon = mt7996_channel_switch_beacon,
.get_stats = mt7996_get_stats,
.get_et_sset_count = mt7996_get_et_sset_count,
--
2.47.1
next prev parent reply other threads:[~2025-03-11 10:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-11 10:36 [PATCH 1/8] wifi: mt76: mt7996: revise TXS size Felix Fietkau
2025-03-11 10:36 ` [PATCH 2/8] wifi: mt76: mt7996: fix SER reset trigger on WED reset Felix Fietkau
2025-03-11 10:36 ` [PATCH 3/8] wifi: mt76: mt7996: remove unnecessary key->cipher check for BIP frames Felix Fietkau
2025-03-11 10:36 ` [PATCH 4/8] wifi: mt76: scan: set vif offchannel link for scanning/roc Felix Fietkau
2025-03-11 10:36 ` [PATCH 5/8] wifi: mt76: mt7996: use the correct vif " Felix Fietkau
2025-03-12 2:08 ` Ping-Ke Shih
2025-03-12 9:06 ` Felix Fietkau
2025-03-11 10:36 ` [PATCH 6/8] mt76: only mark tx-status-failed frames as ACKed on mt76x0/2 Felix Fietkau
2025-03-11 10:47 ` Felix Fietkau
2025-03-11 10:36 ` Felix Fietkau [this message]
2025-03-11 13:55 ` [PATCH 7/8] wifi: mt76: mt7996: implement driver specific get_txpower function Lorenzo Bianconi
2025-03-11 14:01 ` Felix Fietkau
2025-03-11 10:36 ` [PATCH 8/8] wifi: mt76: scan: fix setting tx_info fields Felix Fietkau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250311103646.43346-7-nbd@nbd.name \
--to=nbd@nbd.name \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox