Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2362515lqp; Sun, 24 Mar 2024 15:50:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCViDWSXoUqpZYrnKs/VT59qJoX49x6EmvquPOhJxsKyYB5EUEpNWmwgC5g2W6F8AJ3Z6YW/j+/0RdKB2tODxXJWdwmjdKkppFmFuD76RQ== X-Google-Smtp-Source: AGHT+IFtZmsPQveow+7hk8rVylZKxzFvBS9MpHaAku0RocG+HBNwMZGs4K6f6qqnjT7hfEO58sue X-Received: by 2002:a05:6358:3a1a:b0:17c:2168:d4a0 with SMTP id g26-20020a0563583a1a00b0017c2168d4a0mr7041445rwe.19.1711320612003; Sun, 24 Mar 2024 15:50:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711320611; cv=pass; d=google.com; s=arc-20160816; b=EPgYVNtPhBnv3GF0guvQJi5shjm+FVPyfEq5No6zdo4l4y2m9HdX44gBHJ/y91U5NX xugc4Zh9IURDDRfaxmKlE+v4QodRJ+ZPIrrsDMWZc2tQEiC2ZY/XEXou3e6PvaRPCBJ/ sEu5MwNvrxt5OoDRBhIB5AjdZGIfV6Mq2+yXYpsPJhLt2uVHIfhDI+kkZlYY9XH1jh4W BenOUZN4ioLyvLVG8I5//3xoLWp6f0ThQp2YbGQt+Iarkt/Vr7Rd1jRUmr7vZ5gd4Jho TIocBAxiipquGnzsJulCBldXlCXATxwxS/s+jqavahRI+WotC4PRJd7WZ1IH/Yc8LH2B 89/g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=LORVjKvol3nn8X8bLwdMMVGkthmceXyFHV2BPuBBqfM=; fh=w4otygowgVtHAEurQfYC8DSMqrFw6jTDh+c4Ma1Zaro=; b=PLkHESLT10kzWAwpd7/L0HjVDmOIV5X5CEaPddRMicx8TRxhh+zKC8xL4sxwUtyy9F GSB8F7bVYsK5I6K2r2uZhCi0Z5vdZ4p4XujBkYjnIj8IcHSRAxh4vE+qiQgGU6aocoJH YrCo8/LZgxOTGzYoAamDHyXdjCtmrquTcwWZ7JZgtc1OnVsHay63yTXceaHKbGvjpirF C9Plga1AteH/wfA1JdiapKgn+QxQI7PjVj3ZCetlXNX/VSuzwnFj/xtt7PT1VaHDEM43 6QHS6jq4wd7v/yPww3NQp2Rnb+QkCd2IZjGLye+YBUG6Jh3sUxvphoqo3y7n7H/7sHZO 8qew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VinzE83B; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112949-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112949-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k27-20020a634b5b000000b005dc422577a9si6324006pgl.209.2024.03.24.15.50.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 15:50:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112949-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VinzE83B; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112949-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112949-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9D5822814FB for ; Sun, 24 Mar 2024 22:50:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2284437145; Sun, 24 Mar 2024 22:36:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VinzE83B" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05CAB82D9A; Sun, 24 Mar 2024 22:36:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319762; cv=none; b=G0SUOsFZO9uNsOIfPH+Qxu/UHaoKmwNGoKVlj0GPDZufHdDnWSkEmY6FCTgYyD+GXe1BVwdS4FxpCFsGry9hZTqlYYY+ERj58SSOiRGRA+I1MefemOUJv7FvADDrrZ67LgMGWTAYyNyZSITNvk1ZPmVmGajYbM7WBOKE7WFxJzY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319762; c=relaxed/simple; bh=yPEpggvVYgRTK+qo2VSDS2wmWg/PsKskHvQIgsYNqI4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FkKZuDBRoMjz+1Vi8q1neSIz8THwNk/EK9MRQmJ5xqP15Twfyg6OcunUj60s2Z5nEUqLY+LSb3LyZ4ZcsY+uCM0Gx6Wkn2Uct5J69wlpPz/fnNT48tCPAfnkUEpYRKR91PP1snp+CWNM8Hn0ghBCqfc6S1+HDW+zMuzi2W1LMkk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VinzE83B; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6D7EC433C7; Sun, 24 Mar 2024 22:36:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711319761; bh=yPEpggvVYgRTK+qo2VSDS2wmWg/PsKskHvQIgsYNqI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VinzE83Bpg3AaZKT9SAJFbXxVcEZGb06Aq3iVV9EEgqKEuAChRIFDfJd7aDebOJoo Dfxoj7e7FJkFSc+qBUxLoHsUItn21WuhziJroUyJZMtZHgolfPuiRdnuSoyFDFTP1j Oz/uKUwQYDjp2vHUDmC26bNm1L9qIC6X7gq5glDu0Gn+ux6cqV2i+srth+fbaYsL4N a9yzLQbj3AHAsLsOg/zlhosffmGdOoAUMpcqMdTHl3a4cFy+gWhOsdGE4Y4aWIwgus KyuxsLr6m6S8a++ltYQ4HENxV76LgXXBPJBHttJEDpTQJbNcOzLclYEDY7NwEFKCrK nRxVHirrhn37A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Wen Gong , Baochen Qiang , Kalle Valo , Sasha Levin Subject: [PATCH 6.8 062/715] wifi: ath11k: add support to select 6 GHz regulatory type Date: Sun, 24 Mar 2024 18:24:01 -0400 Message-ID: <20240324223455.1342824-63-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Wen Gong [ Upstream commit e3d373ec4f02bf41379d91707e3e3f2a46464cd7 ] There are 3 types of regulatory rules for AP mode and 6 type for station mode. Add wmi_vdev_type and ieee80211_ap_reg_power to select the exact reg rules. Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.23 Signed-off-by: Wen Gong Signed-off-by: Baochen Qiang Signed-off-by: Kalle Valo Link: https://msgid.link/20231218085844.2658-2-quic_bqiang@quicinc.com Stable-dep-of: cf2df0080bd5 ("wifi: ath11k: fix a possible dead lock caused by ab->base_lock") Signed-off-by: Sasha Levin --- drivers/net/wireless/ath/ath11k/reg.c | 70 +++++++++++++++++++++------ drivers/net/wireless/ath/ath11k/reg.h | 6 ++- drivers/net/wireless/ath/ath11k/wmi.c | 3 +- 3 files changed, 62 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/reg.c b/drivers/net/wireless/ath/ath11k/reg.c index b4fd4d2107c71..78b99ab10c634 100644 --- a/drivers/net/wireless/ath/ath11k/reg.c +++ b/drivers/net/wireless/ath/ath11k/reg.c @@ -618,25 +618,68 @@ ath11k_reg_update_weather_radar_band(struct ath11k_base *ab, *rule_idx = i; } +enum wmi_reg_6ghz_ap_type +ath11k_reg_ap_pwr_convert(enum ieee80211_ap_reg_power power_type) +{ + switch (power_type) { + case IEEE80211_REG_LPI_AP: + return WMI_REG_INDOOR_AP; + case IEEE80211_REG_SP_AP: + return WMI_REG_STANDARD_POWER_AP; + case IEEE80211_REG_VLP_AP: + return WMI_REG_VERY_LOW_POWER_AP; + default: + return WMI_REG_MAX_AP_TYPE; + } +} + struct ieee80211_regdomain * ath11k_reg_build_regd(struct ath11k_base *ab, - struct cur_regulatory_info *reg_info, bool intersect) + struct cur_regulatory_info *reg_info, bool intersect, + enum wmi_vdev_type vdev_type, + enum ieee80211_ap_reg_power power_type) { struct ieee80211_regdomain *tmp_regd, *default_regd, *new_regd = NULL; - struct cur_reg_rule *reg_rule; + struct cur_reg_rule *reg_rule, *reg_rule_6ghz; u8 i = 0, j = 0, k = 0; u8 num_rules; u16 max_bw; - u32 flags; + u32 flags, reg_6ghz_number, max_bw_6ghz; char alpha2[3]; num_rules = reg_info->num_5ghz_reg_rules + reg_info->num_2ghz_reg_rules; - /* FIXME: Currently taking reg rules for 6 GHz only from Indoor AP mode list. - * This can be updated after complete 6 GHz regulatory support is added. - */ - if (reg_info->is_ext_reg_event) - num_rules += reg_info->num_6ghz_rules_ap[WMI_REG_INDOOR_AP]; + if (reg_info->is_ext_reg_event) { + if (vdev_type == WMI_VDEV_TYPE_STA) { + enum wmi_reg_6ghz_ap_type ap_type; + + ap_type = ath11k_reg_ap_pwr_convert(power_type); + + if (ap_type == WMI_REG_MAX_AP_TYPE) + ap_type = WMI_REG_INDOOR_AP; + + reg_6ghz_number = reg_info->num_6ghz_rules_client + [ap_type][WMI_REG_DEFAULT_CLIENT]; + + if (reg_6ghz_number == 0) { + ap_type = WMI_REG_INDOOR_AP; + reg_6ghz_number = reg_info->num_6ghz_rules_client + [ap_type][WMI_REG_DEFAULT_CLIENT]; + } + + reg_rule_6ghz = reg_info->reg_rules_6ghz_client_ptr + [ap_type][WMI_REG_DEFAULT_CLIENT]; + max_bw_6ghz = reg_info->max_bw_6ghz_client + [ap_type][WMI_REG_DEFAULT_CLIENT]; + } else { + reg_6ghz_number = reg_info->num_6ghz_rules_ap[WMI_REG_INDOOR_AP]; + reg_rule_6ghz = + reg_info->reg_rules_6ghz_ap_ptr[WMI_REG_INDOOR_AP]; + max_bw_6ghz = reg_info->max_bw_6ghz_ap[WMI_REG_INDOOR_AP]; + } + + num_rules += reg_6ghz_number; + } if (!num_rules) goto ret; @@ -683,13 +726,10 @@ ath11k_reg_build_regd(struct ath11k_base *ab, * per other BW rule flags we pass from here */ flags = NL80211_RRF_AUTO_BW; - } else if (reg_info->is_ext_reg_event && - reg_info->num_6ghz_rules_ap[WMI_REG_INDOOR_AP] && - (k < reg_info->num_6ghz_rules_ap[WMI_REG_INDOOR_AP])) { - reg_rule = reg_info->reg_rules_6ghz_ap_ptr[WMI_REG_INDOOR_AP] + - k++; - max_bw = min_t(u16, reg_rule->max_bw, - reg_info->max_bw_6ghz_ap[WMI_REG_INDOOR_AP]); + } else if (reg_info->is_ext_reg_event && reg_6ghz_number && + k < reg_6ghz_number) { + reg_rule = reg_rule_6ghz + k++; + max_bw = min_t(u16, reg_rule->max_bw, max_bw_6ghz); flags = NL80211_RRF_AUTO_BW; } else { break; diff --git a/drivers/net/wireless/ath/ath11k/reg.h b/drivers/net/wireless/ath/ath11k/reg.h index f28902f85e419..989b27b16bea0 100644 --- a/drivers/net/wireless/ath/ath11k/reg.h +++ b/drivers/net/wireless/ath/ath11k/reg.h @@ -34,7 +34,11 @@ void ath11k_reg_free(struct ath11k_base *ab); void ath11k_regd_update_work(struct work_struct *work); struct ieee80211_regdomain * ath11k_reg_build_regd(struct ath11k_base *ab, - struct cur_regulatory_info *reg_info, bool intersect); + struct cur_regulatory_info *reg_info, bool intersect, + enum wmi_vdev_type vdev_type, + enum ieee80211_ap_reg_power power_type); int ath11k_regd_update(struct ath11k *ar); int ath11k_reg_update_chan_list(struct ath11k *ar, bool wait); +enum wmi_reg_6ghz_ap_type +ath11k_reg_ap_pwr_convert(enum ieee80211_ap_reg_power power_type); #endif diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c index 8a65fa04b48d9..75c79c99faa9f 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -7151,7 +7151,8 @@ static int ath11k_reg_chan_list_event(struct ath11k_base *ab, !ath11k_reg_is_world_alpha((char *)reg_info->alpha2)) intersect = true; - regd = ath11k_reg_build_regd(ab, reg_info, intersect); + regd = ath11k_reg_build_regd(ab, reg_info, intersect, + WMI_VDEV_TYPE_AP, IEEE80211_REG_LPI_AP); if (!regd) { ath11k_warn(ab, "failed to build regd from reg_info\n"); goto fallback; -- 2.43.0