Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp381694pxt; Thu, 5 Aug 2021 01:57:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaX/Ux8ci1Sfz1uyiKUhTDAv4prECMDtErERiw224w/6Dt3KMVh3ZAIkC9u7TTirHrZbVz X-Received: by 2002:a17:906:64a:: with SMTP id t10mr3715739ejb.5.1628153830209; Thu, 05 Aug 2021 01:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628153830; cv=none; d=google.com; s=arc-20160816; b=ahImM/tVv5kx36INp6IWMjLY53uFkliTizy8UBrJddhQAvCp9sJiJD16RYMw2xZyK9 H8CIBFqpo+p6puBSW3h3A5MI0y2t4sf6idCnTsqmSGfYUizY4HoHoFfjOyLSk34qcJkl j8uFM22LKDd7fFwrJwemYH0Pvl+6j4gU9pDLxbf7zKuk/dQpoMDfaswnkrDIXcuUzyCH IHsQmOVJZhPAa4n6rfnWnZO1IkdFVplwbLOHG9r0Y+db1/V3A4ayWtgp8TDgXWn+JYxP rnioy5mvAlVTaD85ww99qAzqYCjg8zdwgT9vQxbhHaOMlylYqXecipGGcx2Ge9l6XwKo D5NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=K8bGpUGe1HyuW92CwY0uDn+1Do8SQ9QJ3xnWNSylqb0=; b=V2S1Lk95Kc9YQVDsTdWDvbBMsRwLsUZXjZo4IHaE/mwHlneApbP8JKs0pkzQVbg8lf XyFRy83x8TSMl/fAZN95ITNCAov8uaYfYjd9juoumierOghe/3Ou7oLUPtSOQQgUtNJa GpvsGFRHEFOGv2CGhBPTuluE8GtfDjzK1lMv4fxgsKq/pFTH2xi/E9riXBN1+buLBWd4 n3cfjFnhaPqZW6SXSXrPbN/BkB/g/sGb+TjOC+K71WtTUok3sTTdojh3FawSNI7Hb6e1 +y+IryZInXVclxby3+2sGv95FmoKivqlolMyHXgejEh7HHKNGj7zlxNHPWPIhRUZ4JHS BM5A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f15si5070353eds.511.2021.08.05.01.56.43; Thu, 05 Aug 2021 01:57:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236191AbhHEHup (ORCPT + 99 others); Thu, 5 Aug 2021 03:50:45 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:52974 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229674AbhHEHuo (ORCPT ); Thu, 5 Aug 2021 03:50:44 -0400 X-UUID: 09012ca01f6e4b8d93495502ba24a715-20210805 X-UUID: 09012ca01f6e4b8d93495502ba24a715-20210805 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1570785462; Thu, 05 Aug 2021 15:50:26 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 5 Aug 2021 15:50:03 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 5 Aug 2021 15:50:03 +0800 From: To: CC: , , , , , , , , , , , , , , , Subject: Re: [PATCH v2] mt76: connac: add support maximum regulatory Tx power Date: Thu, 5 Aug 2021 15:50:02 +0800 Message-ID: <1628149802-26387-1-git-send-email-sean.wang@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Sean Wang >> From: YN Chen >> >> 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 >> Signed-off-by: Sean Wang >> Signed-off-by: YN Chen >> --- >> 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 >> >