Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp826020rdf; Tue, 21 Nov 2023 19:08:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IESRLJgjDwzms+nPBnUZop7+wOMTqKc5y19riBfLTT1PgEbKJMp/MBlwnBCrVnkS1pYnMzY X-Received: by 2002:a9d:7398:0:b0:6d6:4708:b1c with SMTP id j24-20020a9d7398000000b006d647080b1cmr1270105otk.2.1700622481803; Tue, 21 Nov 2023 19:08:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700622481; cv=none; d=google.com; s=arc-20160816; b=tAIRiPL6GVt/wB4cBQYGUjV7MUjFI3yzaWmnjXW6GF3VWtIJPThyCqcKga7whPtv7N LCyfypCQph464UtK9hgSmTHTKT6tyPQ/Sfn+M9FsXSRMRnYN4N5B0SqbQA+tTo/r0hXF JnoAGpPhZKQI+55abhd6xVFTV2x2ITtOqPs+MQP/5YrcSVXaquv+xYC52+j4FDORLwc+ vUqjvySqNOfaoERDXJSwG0LWZTr/EtpZuTcDLqq5VtYOAD3u+XCRjF/wXKdloCroV1xi kIULPVXgv4rdLDvsOC5D5eNqQ1zZfDr514srYy9hXhOidCru+Aw18Sv2q4iENGrHsQ9J eJ2Q== 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=jSFFjTdw0ItTbmm8+XW8dK5TPxES/Z2vXBWRweW0Bno=; fh=xmX3nUiCDRywM7GN/jnkxEI0WXifvWaaBmhMyTMYa4c=; b=LTVZKl+/Ae6ZOfXH5v4vnWljb8cUedbvBBAzaEBQFFTcBOmsFFhLB4epXFInXI1kJ4 sh8Xtz7Wez0w3RPPEdqzy9toaUHzsgl0SSeR8J69UlpLCm2ElPDAm94BIYsgwj21xDEI SxYvIsicuCFd6q7Uo8po7aFwIX0zZOU8Um7QlnFJS3GEtTBo2K36c4c2cfaL0K8DcQJg PxDq4Qy0zvkGrHuP9gBv2mwvZGkFuaiSuLiJghXrEJJad82ZwfNh+0x3eVGbjQ3nVH9a P4e/FsuzeN+N309CXFNZfbcnNIk0UxhK1dE4yfwipTzQXUkPZsjzTAXtiRqSpVOyyGSd aLHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=QG+4fdkc; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id e31-20020a63545f000000b005b91192c625si11813777pgm.589.2023.11.21.19.08.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 19:08:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=QG+4fdkc; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 5EE4480E06B3; Tue, 21 Nov 2023 19:07:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343566AbjKVDHW (ORCPT + 54 others); Tue, 21 Nov 2023 22:07:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235054AbjKVDHT (ORCPT ); Tue, 21 Nov 2023 22:07:19 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AE271720 for ; Tue, 21 Nov 2023 19:07:01 -0800 (PST) X-UUID: 3133ca3288e411eea33bb35ae8d461a2-20231122 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=jSFFjTdw0ItTbmm8+XW8dK5TPxES/Z2vXBWRweW0Bno=; b=QG+4fdkcBIIn0wMgvmpuwB1QlnOBCqEjclsJnExgtzD5sF2XJp5z/2Vrb+eZyRE/iqEgSNuAgEZYBeM511uM4I0wOI7gItTT8KFTTfA5mnBlBgjEB1zvyYsxUsoNeqbvLTK8ZXgw0DUGNpa1msHQbr6L8poNz/JJubEvpilQ1rk=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.33,REQID:80f020a1-9c63-4183-a9e5-ac4f7033f7f6,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:692aed72-1bd3-4f48-b671-ada88705968c,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: 3133ca3288e411eea33bb35ae8d461a2-20231122 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1565193917; Wed, 22 Nov 2023 11:06:55 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 22 Nov 2023 11:06:54 +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; Wed, 22 Nov 2023 11:06:54 +0800 From: Mingyen Hsieh To: , CC: , , , , , , , , , , , , , , Ming Yen Hsieh Subject: [PATCH v4 1/3] wifi: mt76: mt7921: fix country count limitation for CLC Date: Wed, 22 Nov 2023 11:06:44 +0800 Message-ID: <20231122030646.31784-2-mingyen.hsieh@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20231122030646.31784-1-mingyen.hsieh@mediatek.com> References: <20231122030646.31784-1-mingyen.hsieh@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Tue, 21 Nov 2023 19:07:25 -0800 (PST) From: Ming Yen Hsieh Due to the increase in the number of power tables for 6Ghz 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 --- v2: - Convert type of buf_len from "__le16" to "u16". --- 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..36ac004e1ec9 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; + u16 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