diff mbox series

[7/8] wifi: mt76: mt7996: implement driver specific get_txpower function

Message ID 20250311103646.43346-7-nbd@nbd.name (mailing list archive)
State Accepted
Delegated to: Felix Fietkau
Headers show
Series [1/8] wifi: mt76: mt7996: revise TXS size | expand

Checks

Context Check Description
wifibot/fixes_present success Fixes tag not required for -next series
wifibot/series_format warning Series does not have a cover letter; Target tree name not specified in the subject
wifibot/tree_selection success Guessed tree name to be wireless-next
wifibot/ynl success Generated files up to date; no warnings/errors; no diff in generated;
wifibot/build_clang fail Errors and warnings before: 0 this patch: 12
wifibot/build_clang_rust success No Rust files in patch. Skipping build
wifibot/build_tools success No tools touched, skip
wifibot/check_selftest success No net selftest shell script
wifibot/deprecated_api success None detected
wifibot/header_inline success No static functions without inline keyword in header files
wifibot/source_inline success Was 0 now: 0
wifibot/verify_fixes success No Fixes tag
wifibot/build_allmodconfig_warn fail Errors and warnings before: 0 this patch: 12
wifibot/checkpatch success total: 0 errors, 0 warnings, 0 checks, 39 lines checked
wifibot/kdoc success Errors and warnings before: 0 this patch: 0
wifibot/build_32bit fail Errors and warnings before: 0 this patch: 12
wifibot/verify_signedoff success Signed-off-by tag matches author and committer

Commit Message

Felix Fietkau March 11, 2025, 10:36 a.m. UTC
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(-)

Comments

Lorenzo Bianconi March 11, 2025, 1:55 p.m. UTC | #1
On Mar 11, Felix Fietkau wrote:
> 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)

I guess the signature here should be:

static int
mt7996_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 
		   unsigned int link_id, int *dbm)
{
}

Regards,
Lorenzo

> +{
> +	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
> 
>
Felix Fietkau March 11, 2025, 2:01 p.m. UTC | #2
On 11.03.25 14:55, Lorenzo Bianconi wrote:
> On Mar 11, Felix Fietkau wrote:
>> 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)
> 
> I guess the signature here should be:
> 
> static int
> mt7996_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
> 		   unsigned int link_id, int *dbm)
> {
> }

Will fix, thanks.

- Felix
diff mbox series

Patch

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,