Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2138824rdb; Mon, 20 Nov 2023 03:12:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6V442bIGxo9gVqtZRhpWo+LHuMDc60TTji184f2g3aiFBBSuGM/9tRJFp8IKdwVdNj4ph X-Received: by 2002:a05:6a00:80b:b0:6c3:3bf9:217e with SMTP id m11-20020a056a00080b00b006c33bf9217emr6229778pfk.19.1700478756490; Mon, 20 Nov 2023 03:12:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700478756; cv=none; d=google.com; s=arc-20160816; b=RQas82QqBI1lXSfrPsqAHYQIMbL+eMPSSLKfmITag0UdT9b/5jO8XnRQDHsl/K4krD kKR2/8Jvz/VtzNrRdlUEpsGtbfAPryauBCsaTnQrXtTHdG5pRpHAqlKq5Zdhd3fbIDzl cCdnj3k/jCx6Ge/EqfB3o0zDT69xJ+hIXTwZ6PKl+ukWe/UHzjQJnqPvXLb5Enbzs9sZ H6IYUlorjLKKK/4U+qj46pyI/jVh/QzFrrOpfW3/auX8JT/LTQuuKPsSexyLQux/HhJm UUlZCwW25xVkUB8KBnZpgGeRo2lJI2BabRjUrDd32sQg2WvQEuuH+SbsPoccc1ncu45S 3S8A== 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=+p0WpiZm2A8NelwUk+rR7V+ehCKom9sKbqRbQbLPWBY=; fh=xmX3nUiCDRywM7GN/jnkxEI0WXifvWaaBmhMyTMYa4c=; b=K50ARdzpkjT+rHO3QxwrIDKTAKQ76DWIMS7rN/la/s/Rs3kl7v/oORgExMV1aI84L6 nMkDHRgpktm4IHanoX2q5bOxH7QSz3RT6Xuvqs/qM6yjMFUsRioVhRU4jHGwJ7Wn2EU5 lvBV0UWIWg+aHlV6zSkFScXH2YsrGn7EJzbkpHRBbP1AEDyx/VODVaYL6Izs3NTD4u29 STaE8jjIrT9suC3BtuESKaI6pH+zf1tEdKjeBocSh3rMr7wUG8xotlrzW6xihZxd0Zsq t+bt552gFMJIha0aDT+5ty1pGv/9lY5ZRTnN2WXzq/a+UPe011qKBbcJ96aal7YP/Lzh +jFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=SgdEb5Xr; 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 o14-20020a635a0e000000b005c242315f27si1875034pgb.713.2023.11.20.03.12.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 03:12:36 -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=SgdEb5Xr; 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 3F9ED8027678; Mon, 20 Nov 2023 03:12:35 -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 S232721AbjKTLMf (ORCPT + 54 others); Mon, 20 Nov 2023 06:12:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232632AbjKTLMe (ORCPT ); Mon, 20 Nov 2023 06:12:34 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A7359D for ; Mon, 20 Nov 2023 03:12:23 -0800 (PST) X-UUID: a9a9d22c879511ee8051498923ad61e6-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=+p0WpiZm2A8NelwUk+rR7V+ehCKom9sKbqRbQbLPWBY=; b=SgdEb5XrNsQmNUZZCKD3RYItoyj2XcesjZfjqqEMwPDyLFOvygP6B9GOgv+RVezuuv3ZkCmTy+70xWvuSz2NXTCpsEUrmYsPbCdJdonF4f7NPXSVa5DabdyHt1rbMldmRYbUOv02SyTedwf9KuaikEh0ZeZS2dwX4zqPimjy5kQ=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.33,REQID:b8ef21b3-b50c-4a38-8ae4-2b9bc79ea794,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:d08cbcfc-4a48-46e2-b946-12f04f20af8c,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: a9a9d22c879511ee8051498923ad61e6-20231120 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1469364347; Mon, 20 Nov 2023 19:12:16 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) 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; Mon, 20 Nov 2023 19:12:14 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 20 Nov 2023 19:12:14 +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 19:12:10 +0800 Message-ID: <20231120111212.4478-2-mingyen.hsieh@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20231120111212.4478-1-mingyen.hsieh@mediatek.com> References: <20231120111212.4478-1-mingyen.hsieh@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, RDNS_NONE,SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR, UNPARSEABLE_RELAY autolearn=no 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]); Mon, 20 Nov 2023 03:12:35 -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 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..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; + 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