Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1970661rdb; Sun, 19 Nov 2023 19:29:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxwU6VfcE/Fxblt5UwOOG9dyBap4esdifCpLN6KCwkBCa59hC4ftLwgJa+MnQzQl4A1Ard X-Received: by 2002:a17:902:f54c:b0:1cf:63bb:82a6 with SMTP id h12-20020a170902f54c00b001cf63bb82a6mr487161plf.65.1700450946090; Sun, 19 Nov 2023 19:29:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700450946; cv=none; d=google.com; s=arc-20160816; b=IIkN6HyZ1c0K85CTOgG9YdN9qZpbkNjHd1MEKEfmRJZyr7u8K14CnKqKV765grIRWh 5z/HzyrC1Eq/DkthYzrClQGX5kuB0bakL/2XpDmjGJkGyvm0nuAG1e+E/91NOCfO3mIM KiLIcOISrwrauYSHDMIhVbzUESeICuMlL5JjVew3hmd8yB85nZu7LboW99CC/WQMHJ6Z 6KTmfMc4Q5wn80nMvIbVkpymLh4WOSvm7lKtd5CUBiH33Be7BSl/VRnLRauIfUeMLoDE VAgOUAatab9zoNAkBqx40DFhzmom6wSS5YHjG6IWJpv9a05fvA6oYY+AI98N4gBEddx+ blyg== 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:dkim-signature; bh=jER1tgbz+SMDkjfPgmApSeYcdW/s60lAdREALHngU9M=; fh=xmX3nUiCDRywM7GN/jnkxEI0WXifvWaaBmhMyTMYa4c=; b=c39/cg265q4L5+1VAp7SA7K++uGHEdwsc6EEUNsJh25pZJPgI1gUvt/9jC9roQ7B+L GK9jaTXxvCImm2OUjYKJbcODvBmSOPJeNsSDrti0etEszAznfXbHmqmRTzqVwCPJpM8s qwP1j8LTOPdgix1Nj1efiMOSVDgTjJFXedQztk8uE6mcjU34LDtcfNPGq1R2/cOS4M/t bJq8BptVl3+r12HohU/VvZ0j0vqcBgsdJYTfoXdQ/+H7i3LTt4v+cH3yygkt4fpzhiq2 8jE80zYlSOmuT9KCKhHFLVG0GLyRoRLj4zhnl5AaK3+A6zys1qgP7uz7JX/WgXWSoNFn Krhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=dff21sZ6; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id q15-20020a17090311cf00b001b9d180fd9asi7523428plh.121.2023.11.19.19.29.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 19:29:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=dff21sZ6; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 6A4B4809AFF9; Sun, 19 Nov 2023 19:29:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230339AbjKTD2v (ORCPT + 54 others); Sun, 19 Nov 2023 22:28:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231755AbjKTD2s (ORCPT ); Sun, 19 Nov 2023 22:28:48 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE1B0137 for ; Sun, 19 Nov 2023 19:28:37 -0800 (PST) X-UUID: dfc59684875411ee8051498923ad61e6-20231120 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=jER1tgbz+SMDkjfPgmApSeYcdW/s60lAdREALHngU9M=; b=dff21sZ616WaPH2YuFgB1OfyWkaydE9fXW/DIItEO+IYv2kOuX/8mE5sLNKTNr8na2wZVPWZMLTbaD2nXRqVJtJe8bLSACwybfbq+00crjVOLPBIlqTSWi54ljUY/dvKmd+9ElVKp/SMdFSIGjZHLsyp3phIwvefu+LurmE80zw=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.33,REQID:03bbef9e-96ac-4f6d-849e-1bf80af219d4,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:364b77b,CLOUDID:7cea3e60-c89d-4129-91cb-8ebfae4653fc,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO, DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: dfc59684875411ee8051498923ad61e6-20231120 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2089172538; Mon, 20 Nov 2023 11:28:29 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by MTKMBS14N1.mediatek.inc (172.21.101.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 20 Nov 2023 11:28:27 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 20 Nov 2023 11:28:27 +0800 From: Mingyen Hsieh To: , CC: , , , , , , , , , , , , , , Ming Yen Hsieh Subject: [PATCH 1/3] wifi: mt76: mt7921: fix country count limitation for CLC Date: Mon, 20 Nov 2023 11:27:48 +0800 Message-ID: <20231120032750.19747-2-mingyen.hsieh@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20231120032750.19747-1-mingyen.hsieh@mediatek.com> References: <20231120032750.19747-1-mingyen.hsieh@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--1.822100-8.000000 X-TMASE-MatchedRID: zfURmU8ZpfHhF8fPoBwQ4Eg5Iem1vm3HEjUQ5RU6WJKctWHPLT5Fff/v iojdMcFdjBmhBLd6Ukq+020ZTJzUqvfA/LmKnHFmGXsV1o1VQtyCxYB2hPS4vVxOQqP2lG9go8W MkQWv6iXBcIE78YqRWvcUt5lc1lLgjMejjvPkBr4hwYrKBQ5f5zdjHajg8a1O5jBU76rMQuY8tQ XqqbIdXqsebsuKB0iZ8vv67x8uj6SfMJo2joeOMxgZS5SUVbjxsaV9h+i6SUF5lSmbrC6fdtr/T o2FgNrjDLMIOOVTHz2nbLeYgH6K31Zca9RSYo/b X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--1.822100-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 1D0A646E31734DB031C4349BA779DB6F2DF17D1FB339457E9E365530C7BBCDD32000:8 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sun, 19 Nov 2023 19:29:03 -0800 (PST) From: Ming Yen Hsieh Due to the increase in the number of power tables on CLC, the variable nr_country is no longer sufficient to represent the total quantity. Therefore, we have switched to calculating the length of clc buf to obtain the correct power table. Additionally, the version number has been incremented to 1. Fixes: 23bdc5d8cadf ("wifi: mt76: mt7921: introduce Country Location Control support") Signed-off-by: Ming Yen Hsieh --- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c index 753a4fc45c70..e4edea1ab3dd 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c @@ -1264,6 +1264,7 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2, u8 mtcl_conf; u8 rsvd[62]; } __packed req = { + .ver = 1, .idx = idx, .env = env_cap, .env_6g = dev->phy.power_type, @@ -1271,7 +1272,8 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2, .mtcl_conf = mt792x_acpi_get_mtcl_conf(&dev->phy, alpha2), }; int ret, valid_cnt = 0; - u8 i, *pos; + __le16 buf_len = 0; + u8 *pos; if (!clc) return 0; @@ -1281,12 +1283,15 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2, if (mt76_find_power_limits_node(&dev->mt76)) req.cap |= CLC_CAP_DTS_EN; + buf_len = le16_to_cpu(clc->len) - sizeof(*clc); pos = clc->data; - for (i = 0; i < clc->nr_country; i++) { + while (buf_len > 16) { struct mt7921_clc_rule *rule = (struct mt7921_clc_rule *)pos; u16 len = le16_to_cpu(rule->len); + u16 offset = len + sizeof(*rule); - pos += len + sizeof(*rule); + pos += offset; + buf_len -= offset; if (rule->alpha2[0] != alpha2[0] || rule->alpha2[1] != alpha2[1]) continue; -- 2.18.0