Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp149533pxb; Thu, 14 Jan 2021 02:15:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPt/pr4Ryz733wlEFBiGCch68D+Ibl3GmQqhfvLVaCuOdSruEavisRA/VcXFmIvf5n0ljD X-Received: by 2002:a05:6402:2683:: with SMTP id w3mr5105309edd.378.1610619322213; Thu, 14 Jan 2021 02:15:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610619322; cv=none; d=google.com; s=arc-20160816; b=iLBjubdXHyRhH3OrA16dQXMurGdiFetGJpF0Rj9PWe1FTzZQuALSP5ct7UCnBCHkjC C6vUbMTjoTbMHh5icC/8Z9GHXP36igU+roMbfKEFXHB0dwTke0cA/fLu6AST6iPH9vhm hHTPG5cT7REMo12oRoMbsIIX5aXWWysOuA2LNy3FbtqPzPJQB7V0EOCmA0/BL5QoN1HV pmrsVwTAA4zCpAQuv+7hYo1+QTwBgYqi0YoPakvRcxZJsJhQ1p/cMTmKzFq8kbciWDCd KYHVfID1F5Xf1t+A5kZl9PtqgyvJmTgJJPbcaA7TlEOmgVQui73J+NmuuD1d8IacY6xM zpjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=ZZhQW659v8ok3HEpZQomXzazDe7ltbs/MsSjMslqZdY=; b=dKjLl72uvo8o40QgIuorYlcLtZ2Dw1A6gIK1eOzeY0VL2t/3LzlNgZmSx1v1Sl4ZEm rYuPN9vSIJR7ewwAum4XsmzKUVRorjQG3UTJNrVQ1TlxuqY788P4fXC9cVjsUP3Nyvzc bXQxuh2UU30tmD0tAmbKCqd+2ph6vpl+ShGHR8ChJsr2LhpLyMrY/WY+ttwW+aVUTJ5l 2QuwNC6R88Hsp45HKXTMEoANYPKt4RWHXkN6GJrb7wcyfMIk1RSr1PT7oyzzHzyH+n8E EiA6Ih8ZSOZhWU3YYBPnooMv4b8bpWXq3bVEfeyBf+hru3tYsyBp4xRVTi0BE/SGhJyA WoqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=tSrcpTQS; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si2148283ejd.293.2021.01.14.02.14.54; Thu, 14 Jan 2021 02:15:22 -0800 (PST) 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; dkim=fail header.i=@nbd.name header.s=20160729 header.b=tSrcpTQS; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726806AbhANKJf (ORCPT + 99 others); Thu, 14 Jan 2021 05:09:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726661AbhANKJe (ORCPT ); Thu, 14 Jan 2021 05:09:34 -0500 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43145C061573 for ; Thu, 14 Jan 2021 02:08:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZZhQW659v8ok3HEpZQomXzazDe7ltbs/MsSjMslqZdY=; b=tSrcpTQSFyjZbh206CqHvvZZ/E +BknSfjJSB4QEhvXpCDtaG9T/HdLY1QQML1LQCU2FZh5DW+HSLXjNipOfwKghLYHW95MRq1TFfTap yZzUEDdm9X9nm+oCRK3QX1wx0AkwjpaPzZmx6xufxeJuDOrH0l4BmKxyzVI2Og/Ym8Ys=; Received: from p54ae91f2.dip0.t-ipconnect.de ([84.174.145.242] helo=nf.local) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1kzzYS-0006ED-UY; Thu, 14 Jan 2021 11:08:37 +0100 Subject: Re: [PATCH] mt76: mt7615: set mcu country code in mt7615_mcu_set_channel_domain() To: Lorenzo Bianconi Cc: lorenzo.bianconi@redhat.com, linux-wireless@vger.kernel.org, sean.wang@mediatek.com References: From: Felix Fietkau Message-ID: Date: Thu, 14 Jan 2021 11:08:36 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On 2021-01-08 18:34, Lorenzo Bianconi wrote: > Update mcu country code running mt7615_mcu_set_channel_domain routine in > mt7615_regd_notifier(). > Filter out disabled channels in mt7615_mcu_set_channel_domain(). > > Signed-off-by: Lorenzo Bianconi > --- > drivers/net/wireless/mediatek/mt76/mt76.h | 1 + > .../net/wireless/mediatek/mt76/mt7615/init.c | 10 +++-- > .../net/wireless/mediatek/mt76/mt7615/mcu.c | 43 +++++++++++++------ > .../wireless/mediatek/mt76/mt7615/mt7615.h | 3 ++ > 4 files changed, 40 insertions(+), 17 deletions(-) > > diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h > index 10034c21f812..5c86ade0aa1e 100644 > --- a/drivers/net/wireless/mediatek/mt76/mt76.h > +++ b/drivers/net/wireless/mediatek/mt76/mt76.h > @@ -647,6 +647,7 @@ struct mt76_dev { > > struct mt76_rate_power rate_power; > > + char alpha2[3]; > enum nl80211_dfs_regions region; > > u32 debugfs_reg; > diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/init.c b/drivers/net/wireless/mediatek/mt76/mt7615/init.c > index a73b76e57c7f..635b94de1021 100644 > --- a/drivers/net/wireless/mediatek/mt76/mt7615/init.c > +++ b/drivers/net/wireless/mediatek/mt76/mt7615/init.c > @@ -296,13 +296,15 @@ mt7615_regd_notifier(struct wiphy *wiphy, > struct mt7615_phy *phy = mphy->priv; > struct cfg80211_chan_def *chandef = &mphy->chandef; > > + memcpy(dev->mt76.alpha2, request->alpha2, sizeof(dev->mt76.alpha2)); > dev->mt76.region = request->dfs_region; > > - if (!(chandef->chan->flags & IEEE80211_CHAN_RADAR)) > - return; > - > mt7615_mutex_acquire(dev); > - mt7615_dfs_init_radar_detector(phy); > + > + if (chandef->chan->flags & IEEE80211_CHAN_RADAR) > + mt7615_dfs_init_radar_detector(phy); > + mt7615_mcu_set_channel_domain(phy); > + > mt7615_mutex_release(dev); > } > > diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c > index c49e9041006f..715423c325e1 100644 > --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c > +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c > @@ -2981,6 +2981,7 @@ int mt7615_mcu_set_channel_domain(struct mt7615_phy *phy) > { > struct mt76_phy *mphy = phy->mt76; > struct mt7615_dev *dev = phy->dev; > + u32 country_code = MT76_ALPHA2_TO_CC(dev->mt76.alpha2); > struct mt7615_mcu_channel_domain { > __le32 country_code; /* regulatory_request.alpha2 */ > u8 bw_2g; /* BW_20_40M 0 > @@ -2995,45 +2996,61 @@ int mt7615_mcu_set_channel_domain(struct mt7615_phy *phy) > u8 n_5ch; > __le16 pad2; > } __packed hdr = { > + .country_code = cpu_to_le32(country_code), Instead of converting alpha2 to a cpu-endian u32 and then turning it back into LE, you should be able to simply add u8 country_code[4] and memcpy the request alpha2 to it without any order swapping. - Felix