Linux-mediatek Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: <sean.wang@mediatek.com>
To: <lorenzo.bianconi@redhat.com>
Cc: <nbd@nbd.name>, <sean.wang@mediatek.com>,
	<Soul.Huang@mediatek.com>, <YN.Chen@mediatek.com>,
	<Leon.Yen@mediatek.com>, <Deren.Wu@mediatek.com>,
	<km.lin@mediatek.com>, <robin.chiu@mediatek.com>,
	<ch.yeh@mediatek.com>, <posh.sun@mediatek.com>,
	<Eric.Liang@mediatek.com>, <Stella.Chang@mediatek.com>,
	<jemele@google.com>, <yenlinlai@google.com>,
	<linux-wireless@vger.kernel.org>,
	<linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH v2] mt76: connac: add support maximum regulatory Tx power
Date: Thu, 5 Aug 2021 15:50:02 +0800	[thread overview]
Message-ID: <1628149802-26387-1-git-send-email-sean.wang@mediatek.com> (raw)
In-Reply-To: <YQuI/Zf8vYjKx9LR@lore-desk--annotate>

From: Sean Wang <sean.wang@mediatek.com>

>> From: YN Chen <YN.Chen@mediatek.com>
>>
>> Consider .max_reg_power in struct ieee80211_channel to limit the
>> maximum power the wireless device allowed to transmit on the
>> corresponding channel according to the regulatory domain.
>>
>> Co-developed-by: Sean Wang <sean.wang@mediatek.com>
>> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
>> Signed-off-by: YN Chen <YN.Chen@mediatek.com>
>> ---
>> v2: consider the power limit that can be allowed on mt7663
>> ---
>>  .../wireless/mediatek/mt76/mt76_connac_mcu.c  | 43
>> ++++++++++++++++++-
>>  1 file changed, 41 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
>> b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
>> index d71393b1c5e6..80987af03efe 100644
>> --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
>> +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
>> @@ -1773,6 +1773,43 @@ static s8 mt76_connac_get_sar_power(struct mt76_phy *phy,
>>	return target_power;
>>  }
>>
>> +static s8 mt76_connac_get_ch_power(struct mt76_phy *phy,
>> +				   struct ieee80211_channel *chan,
>> +				   s8 target_power)
>> +{
>> +	struct mt76_dev *dev = phy->dev;
>> +	struct ieee80211_supported_band *sband;
>> +	int i;
>> +
>> +	switch (chan->band) {
>> +	case NL80211_BAND_2GHZ:
>> +		sband = &phy->sband_2g.sband;
>> +		break;
>> +	case NL80211_BAND_5GHZ:
>> +		sband = &phy->sband_5g.sband;
>> +		break;
>> +	default:
>> +		return target_power;
>> +	}
>> +
>> +	for (i = 0; i < sband->n_channels; i++) {
>> +		struct ieee80211_channel *ch = &sband->channels[i];
>> +
>> +		if (ch->hw_value == chan->hw_value) {
>> +			if (!(ch->flags & IEEE80211_CHAN_DISABLED)) {
>> +				int power = 2 * ch->max_reg_power;
>> +
>> +				if (is_mt7663(dev) && (power > 63 || power < -64))
>> +					power = 63;
>
>I guess now you are missing the value for mt7921. What I mean is something similar to mt76_connac_mcu_build_sku()
>
>int max_power = is_mt7921(dev) ? 127 : 63;

the power limit that can be allowed on mt7921 would be -128 to 127 and target_power is s8 type

so I think the boundary check for mt7921 case is unnecessary

>Regards,
>Lorenzo
>
>> +				target_power = min_t(s8, power, target_power);
>> +			}
>> +			break;
>> +		}
>> +	}
>> +
>> +	return target_power;
>> +}
>> +
>>  static int
>>  mt76_connac_mcu_rate_txpower_band(struct mt76_phy *phy,
>>				  enum nl80211_band band)
>> @@ -1840,10 +1877,12 @@ mt76_connac_mcu_rate_txpower_band(struct mt76_phy *phy,
>>				.hw_value = ch_list[idx],
>>				.band = band,
>>			};
>> -			s8 sar_power;
>> +			s8 reg_power, sar_power;
>>
>> +			reg_power = mt76_connac_get_ch_power(phy, &chan,
>> +							     tx_power);
>>			sar_power = mt76_connac_get_sar_power(phy, &chan,
>> -							      tx_power);
>> +							      reg_power);
>>
>>			mt76_get_rate_power_limits(phy, &chan, &limits,
>>						   sar_power);
>> --
>> 2.25.1
>>
>
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

       reply	other threads:[~2021-08-05  7:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <YQuI/Zf8vYjKx9LR@lore-desk--annotate>
2021-08-05  7:50 ` sean.wang [this message]
2021-08-04 22:23 [PATCH v2] mt76: connac: add support maximum regulatory Tx power sean.wang
2021-08-05  6:45 ` Lorenzo Bianconi

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=1628149802-26387-1-git-send-email-sean.wang@mediatek.com \
    --to=sean.wang@mediatek.com \
    --cc=Deren.Wu@mediatek.com \
    --cc=Eric.Liang@mediatek.com \
    --cc=Leon.Yen@mediatek.com \
    --cc=Soul.Huang@mediatek.com \
    --cc=Stella.Chang@mediatek.com \
    --cc=YN.Chen@mediatek.com \
    --cc=ch.yeh@mediatek.com \
    --cc=jemele@google.com \
    --cc=km.lin@mediatek.com \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=nbd@nbd.name \
    --cc=posh.sun@mediatek.com \
    --cc=robin.chiu@mediatek.com \
    --cc=yenlinlai@google.com \
    /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