From patchwork Tue Apr 8 04:21:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Soni X-Patchwork-Id: 14042134 X-Patchwork-Delegate: quic_jjohnson@quicinc.com Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 1A652182D0 for ; Tue, 8 Apr 2025 04:21:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744086112; cv=none; b=Vllo2/oyclKLwcJVHOW9JigOgyaMhWDPiLWpYsfzBwiA22r1l4NcocMfG5eai1GZbGO2LNrKa/N23v1sdLPgrWVLBuLoKzJ8JQueMe92ARRb6zb9Xr7YhtQ4jUMiMLiFuxwDTtaiN33HvpCfFBbLkeveNAICk6ptr0UBv4v9+bQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744086112; c=relaxed/simple; bh=5Swih1l+l4f1qCJU+1qyQPn/vUvLFs4T06x/M8T0jwI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=X2DffMd4KcyOwuSkiRMW3u7sdlwhdO8WoBuEW/LHG+hjHbEHBLbHRK0fwau1Q5hMcrEJQEtD8ZAV6Gn9FGiLRsLwKDuMS4gWN8BR73860Z430jxjHf0CUNf+RHy0EtPEbDu/9hDS5wabBeJjTfk0rBu5KSFZqGAXWoEKBFfjqNo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=JHQkBKyW; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="JHQkBKyW" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5382GL4O008070; Tue, 8 Apr 2025 04:21:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= x3htg6sc6yWZqF0xgEqHwaH74+4CkR+f6D01ur5Wd9c=; b=JHQkBKyWJQVR7B18 jd9zCA7fQkjNKePcHtRvJaDZGJS9SAZr6eMmkC3jJh8iPfYgc8HxcSd55cH+SS/r SWgo870nMsIyE7uvHtV/0N6xcHo+Ci54YEDl8bsufMiuehrt+WGwEDzVqmxs9PGd ZYuvlh2QnGx86pUfWuxbRtRbKKLzTa9Wu5nr2WGxlFb4oMn3YSKkUAxHhChsKEdY 3YQhxFt2C4rrjH9rikmrhySfvZ0IQHvMvr68WQdNXr5hJ1nEzbyuPYsV0+UxaZ1S 22bIVH4tZvKSHS4Ai+BQ9YJBIgOxP75dIDH8/kCKhrSrGXiMxO1xweeUrUiI2+wk fH514g== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 45twtaxg1m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Apr 2025 04:21:47 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5384LlPh011779 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 8 Apr 2025 04:21:47 GMT Received: from hu-rajson-blr.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 7 Apr 2025 21:21:45 -0700 From: Rajat Soni To: CC: , Rajat Soni Subject: [PATCH ath-next 1/3] wifi: ath12k: Add helper function ath12k_mac_update_freq_range() Date: Tue, 8 Apr 2025 09:51:26 +0530 Message-ID: <20250408042128.720263-2-quic_rajson@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250408042128.720263-1-quic_rajson@quicinc.com> References: <20250408042128.720263-1-quic_rajson@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: s9uKFjnk-7DBCz4o_URiQ2DPxI7oDfGE X-Authority-Analysis: v=2.4 cv=LLlmQIW9 c=1 sm=1 tr=0 ts=67f4a45b cx=c_pps a=ouPCqIW2jiPt+lZRy3xVPw==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=GEpy-HfZoHoA:10 a=XR8D0OoHHMoA:10 a=COk6AnOGAAAA:8 a=ZBC4GIfCeQsqTZ2mr1YA:9 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: s9uKFjnk-7DBCz4o_URiQ2DPxI7oDfGE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-08_01,2025-04-07_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 clxscore=1015 mlxlogscore=999 malwarescore=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 mlxscore=0 spamscore=0 adultscore=0 suspectscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2502280000 definitions=main-2504080029 In a subsequent change, the frequency range needs to be updated with each regulatory update. Since the current function also modifies the DISABLED flag in the actual channel list, which should always align with hardware-supported start and end frequencies rather than the current operating ones, the existing function cannot be called again. Therefore, the logic for setting the frequency range needs to be refactored. To address this, refactor the frequency setting part into a new helper function, ath12k_mac_update_freq_range(). Since this needs to be done independently of updating the DISABLED flag, call the new helper function ath12k_mac_update_freq_range() after updating the channel list for each band. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ-1 Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3 Signed-off-by: Rajat Soni --- drivers/net/wireless/ath/ath12k/mac.c | 22 +++++++++++++++++++--- drivers/net/wireless/ath/ath12k/mac.h | 2 ++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index 2b6bdc3d2b11..449aca719ad3 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -10811,6 +10811,16 @@ static const struct ieee80211_ops ath12k_ops = { #endif }; +void ath12k_mac_update_freq_range(struct ath12k *ar, + u32 freq_low, u32 freq_high) +{ + if (!(freq_low && freq_high)) + return; + + ar->freq_range.start_freq = MHZ_TO_KHZ(freq_low); + ar->freq_range.end_freq = MHZ_TO_KHZ(freq_high); +} + static void ath12k_mac_update_ch_list(struct ath12k *ar, struct ieee80211_supported_band *band, u32 freq_low, u32 freq_high) @@ -10825,9 +10835,6 @@ static void ath12k_mac_update_ch_list(struct ath12k *ar, band->channels[i].center_freq > freq_high) band->channels[i].flags |= IEEE80211_CHAN_DISABLED; } - - ar->freq_range.start_freq = MHZ_TO_KHZ(freq_low); - ar->freq_range.end_freq = MHZ_TO_KHZ(freq_high); } static u32 ath12k_get_phy_id(struct ath12k *ar, u32 band) @@ -10885,6 +10892,9 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar, ath12k_mac_update_ch_list(ar, band, reg_cap->low_2ghz_chan, reg_cap->high_2ghz_chan); + + ath12k_mac_update_freq_range(ar, reg_cap->low_2ghz_chan, + reg_cap->high_2ghz_chan); } if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP) { @@ -10907,6 +10917,9 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar, ath12k_mac_update_ch_list(ar, band, reg_cap->low_5ghz_chan, reg_cap->high_5ghz_chan); + + ath12k_mac_update_freq_range(ar, reg_cap->low_5ghz_chan, + reg_cap->high_5ghz_chan); ah->use_6ghz_regd = true; } @@ -10936,6 +10949,9 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar, ath12k_mac_update_ch_list(ar, band, reg_cap->low_5ghz_chan, reg_cap->high_5ghz_chan); + + ath12k_mac_update_freq_range(ar, reg_cap->low_5ghz_chan, + reg_cap->high_5ghz_chan); } } diff --git a/drivers/net/wireless/ath/ath12k/mac.h b/drivers/net/wireless/ath/ath12k/mac.h index 6c5f9d587a60..da37332352fe 100644 --- a/drivers/net/wireless/ath/ath12k/mac.h +++ b/drivers/net/wireless/ath/ath12k/mac.h @@ -126,4 +126,6 @@ struct ath12k *ath12k_get_ar_by_vif(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u8 link_id); int ath12k_mac_get_fw_stats(struct ath12k *ar, struct ath12k_fw_stats_req_params *param); +void ath12k_mac_update_freq_range(struct ath12k *ar, + u32 freq_low, u32 freq_high); #endif From patchwork Tue Apr 8 04:21:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Soni X-Patchwork-Id: 14042135 X-Patchwork-Delegate: quic_jjohnson@quicinc.com Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 3C7B2202F92 for ; Tue, 8 Apr 2025 04:21:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744086113; cv=none; b=CpcJmtRZ5uqkeKiLgCzzBLz7/EKv2DI7W40WW5tUggEABP+3VvNCHaLoY1gM3hImZm60ojHhPv7IRXOguHU8NNlDXBwPE070w7ldm967rMnPMmaUKqd2qZTrNT4XK8DKTqF4yGfdY9u1mkLTjfhMXzyHbYglYiAVClMs9mYMHvI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744086113; c=relaxed/simple; bh=FhujJOSa9jvMCqLJCWnkUsgP6TMmArNgB+BxgM1ZuJw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oqGVkRdPTZzbjEgW7TXAaC8Bq92CNjkSZrEIoXD4kMw7bgZVN2MdyLBShamam5BvLWL9IbXg5l0/J+GUZJ6W6YR8Y4tFX88ENkmxgyjG72DqbyAwnDrJDa33yZIhKbt8tZFqcftP2obRtF1yrAHxJq4ldHq0unmIWwDccQio2QA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=h7hi1uJt; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="h7hi1uJt" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5382GMXf020165; Tue, 8 Apr 2025 04:21:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= WbOZXkX8krhqvTh0vVmdGOuSk8+xXSo+njxrlfO20yY=; b=h7hi1uJtWMmIGcLb lL8bOW4LYufLA2Rny2zLaCHgFvhTpWyrCzqY27YsKezSrGBBuwOBxWtS+blt8SQD UjBkDflMLcsDeTLNFVkfzxpPyji8yhsV4xTfwmYcdTpXG4JGVVgKhd9Mpz6NBgs6 l8mOgCu4QOz9kuIpJjkMMXekf7XRdDz5i/qznj3iiSJcicvdxyaaU0vnGYUDUIO9 Q+17KZhgNZtzByqw2CHEGiJ6O+aDBAGWvEnyxUaaSVtdS9CkG1WO0evOIsatsh7Z rU75QzgcL52E2kddyk0yBGE51SYfStdbELY9Fw1cIzo7LHUhoNQlIKA2bCYEcnzx TmGCvw== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 45twd2pf67-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Apr 2025 04:21:49 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA03.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5384LnbS002411 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 8 Apr 2025 04:21:49 GMT Received: from hu-rajson-blr.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 7 Apr 2025 21:21:47 -0700 From: Rajat Soni To: CC: , Aditya Kumar Singh , Rajat Soni Subject: [PATCH ath-next 2/3] wifi: ath12k: Fix frequency range in driver Date: Tue, 8 Apr 2025 09:51:27 +0530 Message-ID: <20250408042128.720263-3-quic_rajson@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250408042128.720263-1-quic_rajson@quicinc.com> References: <20250408042128.720263-1-quic_rajson@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: ll3FnGozyUsezp3tktnakArNieg_BH4K X-Proofpoint-GUID: ll3FnGozyUsezp3tktnakArNieg_BH4K X-Authority-Analysis: v=2.4 cv=NaLm13D4 c=1 sm=1 tr=0 ts=67f4a45d cx=c_pps a=ouPCqIW2jiPt+lZRy3xVPw==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=GEpy-HfZoHoA:10 a=XR8D0OoHHMoA:10 a=EUspDBNiAAAA:8 a=COk6AnOGAAAA:8 a=tbqBjApZr0fsov_IfRYA:9 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-08_01,2025-04-07_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 impostorscore=0 priorityscore=1501 adultscore=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 spamscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2502280000 definitions=main-2504080029 From: Aditya Kumar Singh During the initial WMI exchange, the firmware updates the hardware-supported start and end frequencies in the ath12k_wmi_hal_reg_capabilities_ext_arg structure. These frequencies, being hardware-supported, may not always align with the current regulatory operating frequencies. When operating as multiple grouped hardwares under a single wiphy, the driver advertises these values directly to the upper layer in the per-radio frequency range, which can be misleading. Sample output snippet from iw phyX info command - [..] Supported wiphy radios: * Idx 0: Frequency Range: 2312 MHz - 2732 MHz [..] * Idx 1: Frequency Range: 5150 MHz - 5330 MHz [..] [..] The frequency range displayed above is incorrect because the driver directly advertises the hardware-supported values to the upper layer. The driver is aware of the current operating regulatory rules, and hence it can use this information to determine the final operating start and end frequencies. To resolve this issue, add support to store the start and end frequencies received during the regulatory update event. Then, intersect these with the hardware-supported start and end frequencies, and finally, advertise the intersected values to the upper layer. Sample output snippet from iw phyX info command after the fix - [..] Supported wiphy radios: * Idx 0: Frequency Range: 2402 MHz - 2472 MHz [..] * Idx 1: Frequency Range: 5170 MHz - 5330 MHz [..] [..] Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ-1 Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3 Signed-off-by: Aditya Kumar Singh Co-developed-by: Rajat Soni Signed-off-by: Rajat Soni --- drivers/net/wireless/ath/ath12k/core.h | 9 ++++++ drivers/net/wireless/ath/ath12k/mac.c | 39 ++++++++++++++++++-------- drivers/net/wireless/ath/ath12k/reg.c | 13 +++++++++ 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h index e8d2a0c859f6..8099a5f54e83 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -880,6 +880,11 @@ struct ath12k_soc_dp_stats { struct ath12k_soc_dp_tx_err_stats tx_err; }; +struct ath12k_reg_freq { + u32 start_freq; + u32 end_freq; +}; + struct ath12k_mlo_memory { struct target_mem_chunk chunk[ATH12K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01]; int mlo_mem_size; @@ -1122,6 +1127,10 @@ struct ath12k_base { enum ath12k_firmware_mode fw_mode; struct ath12k_ftm_event_obj ftm_event_obj; + struct ath12k_reg_freq reg_freq_2ghz; + struct ath12k_reg_freq reg_freq_5ghz; + struct ath12k_reg_freq reg_freq_6ghz; + /* must be last */ u8 drv_priv[] __aligned(sizeof(void *)); }; diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index 449aca719ad3..8c971a58fb6f 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -10859,16 +10859,17 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar, { struct ieee80211_supported_band *band; struct ath12k_wmi_hal_reg_capabilities_ext_arg *reg_cap; + struct ath12k_base *ab = ar->ab; + u32 phy_id, freq_low, freq_high; struct ath12k_hw *ah = ar->ah; void *channels; - u32 phy_id; BUILD_BUG_ON((ARRAY_SIZE(ath12k_2ghz_channels) + ARRAY_SIZE(ath12k_5ghz_channels) + ARRAY_SIZE(ath12k_6ghz_channels)) != ATH12K_NUM_CHANS); - reg_cap = &ar->ab->hal_reg_cap[ar->pdev_idx]; + reg_cap = &ab->hal_reg_cap[ar->pdev_idx]; if (supported_bands & WMI_HOST_WLAN_2GHZ_CAP) { channels = kmemdup(ath12k_2ghz_channels, @@ -10885,16 +10886,21 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar, band->bitrates = ath12k_g_rates; bands[NL80211_BAND_2GHZ] = band; - if (ar->ab->hw_params->single_pdev_only) { + if (ab->hw_params->single_pdev_only) { phy_id = ath12k_get_phy_id(ar, WMI_HOST_WLAN_2GHZ_CAP); - reg_cap = &ar->ab->hal_reg_cap[phy_id]; + reg_cap = &ab->hal_reg_cap[phy_id]; } + + freq_low = max(reg_cap->low_2ghz_chan, + ab->reg_freq_2ghz.start_freq); + freq_high = min(reg_cap->high_2ghz_chan, + ab->reg_freq_2ghz.end_freq); + ath12k_mac_update_ch_list(ar, band, reg_cap->low_2ghz_chan, reg_cap->high_2ghz_chan); - ath12k_mac_update_freq_range(ar, reg_cap->low_2ghz_chan, - reg_cap->high_2ghz_chan); + ath12k_mac_update_freq_range(ar, freq_low, freq_high); } if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP) { @@ -10914,12 +10920,17 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar, band->n_bitrates = ath12k_a_rates_size; band->bitrates = ath12k_a_rates; bands[NL80211_BAND_6GHZ] = band; + + freq_low = max(reg_cap->low_5ghz_chan, + ab->reg_freq_6ghz.start_freq); + freq_high = min(reg_cap->high_5ghz_chan, + ab->reg_freq_6ghz.end_freq); + ath12k_mac_update_ch_list(ar, band, reg_cap->low_5ghz_chan, reg_cap->high_5ghz_chan); - ath12k_mac_update_freq_range(ar, reg_cap->low_5ghz_chan, - reg_cap->high_5ghz_chan); + ath12k_mac_update_freq_range(ar, freq_low, freq_high); ah->use_6ghz_regd = true; } @@ -10941,17 +10952,21 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar, band->bitrates = ath12k_a_rates; bands[NL80211_BAND_5GHZ] = band; - if (ar->ab->hw_params->single_pdev_only) { + if (ab->hw_params->single_pdev_only) { phy_id = ath12k_get_phy_id(ar, WMI_HOST_WLAN_5GHZ_CAP); - reg_cap = &ar->ab->hal_reg_cap[phy_id]; + reg_cap = &ab->hal_reg_cap[phy_id]; } + freq_low = max(reg_cap->low_5ghz_chan, + ab->reg_freq_5ghz.start_freq); + freq_high = min(reg_cap->high_5ghz_chan, + ab->reg_freq_5ghz.end_freq); + ath12k_mac_update_ch_list(ar, band, reg_cap->low_5ghz_chan, reg_cap->high_5ghz_chan); - ath12k_mac_update_freq_range(ar, reg_cap->low_5ghz_chan, - reg_cap->high_5ghz_chan); + ath12k_mac_update_freq_range(ar, freq_low, freq_high); } } diff --git a/drivers/net/wireless/ath/ath12k/reg.c b/drivers/net/wireless/ath/ath12k/reg.c index 893650f76fb2..e1007b878f91 100644 --- a/drivers/net/wireless/ath/ath12k/reg.c +++ b/drivers/net/wireless/ath/ath12k/reg.c @@ -651,6 +651,16 @@ ath12k_reg_update_weather_radar_band(struct ath12k_base *ab, *rule_idx = i; } +static void ath12k_reg_update_freq_range(struct ath12k_reg_freq *reg_freq, + struct ath12k_reg_rule *reg_rule) +{ + if (reg_freq->start_freq > reg_rule->start_freq) + reg_freq->start_freq = reg_rule->start_freq; + + if (reg_freq->end_freq < reg_rule->end_freq) + reg_freq->end_freq = reg_rule->end_freq; +} + struct ieee80211_regdomain * ath12k_reg_build_regd(struct ath12k_base *ab, struct ath12k_reg_info *reg_info, bool intersect) @@ -704,6 +714,7 @@ ath12k_reg_build_regd(struct ath12k_base *ab, max_bw = min_t(u16, reg_rule->max_bw, reg_info->max_bw_2g); flags = 0; + ath12k_reg_update_freq_range(&ab->reg_freq_2ghz, reg_rule); } else if (reg_info->num_5g_reg_rules && (j < reg_info->num_5g_reg_rules)) { reg_rule = reg_info->reg_rules_5g_ptr + j++; @@ -717,6 +728,7 @@ ath12k_reg_build_regd(struct ath12k_base *ab, * per other BW rule flags we pass from here */ flags = NL80211_RRF_AUTO_BW; + ath12k_reg_update_freq_range(&ab->reg_freq_5ghz, reg_rule); } else if (reg_info->is_ext_reg_event && reg_info->num_6g_reg_rules_ap[WMI_REG_INDOOR_AP] && (k < reg_info->num_6g_reg_rules_ap[WMI_REG_INDOOR_AP])) { @@ -724,6 +736,7 @@ ath12k_reg_build_regd(struct ath12k_base *ab, max_bw = min_t(u16, reg_rule->max_bw, reg_info->max_bw_6g_ap[WMI_REG_INDOOR_AP]); flags = NL80211_RRF_AUTO_BW; + ath12k_reg_update_freq_range(&ab->reg_freq_6ghz, reg_rule); } else { break; } From patchwork Tue Apr 8 04:21:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Soni X-Patchwork-Id: 14042136 X-Patchwork-Delegate: quic_jjohnson@quicinc.com Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 DB31625F7B8 for ; Tue, 8 Apr 2025 04:21:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744086116; cv=none; b=ly9G0mMxAxqOQRKOVa2bGxLdVswfpv2mQxVKuoTMm2cquXgfpXviK0mRHfi1p8bhI4l3ZvxdePrwQ6mrAD+6N9uPX9DzAQY54j13OprvOZiNWPC1/89f/2n/YiA8fh7Hkxa9WO6PCeZM5ttmv+UDv2aGFK3jTQc69aZREYUAC0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744086116; c=relaxed/simple; bh=LBJbrFaZypEoWDtimmS8Gcjrgn7zcX6FvMtc6Ee30i0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RdenXTJJk2iLJNOaW6x2n+WnZhsS+sWRnDN5xc/yawDZlbhWEgxtYKOjnVHh0gcGinYWlXMN6TolCI5s197uZ2x7jso9zgbUKqh99HBMktO0mnRc4FGVs9eZLUZZYVmeagQ04qHztzBTwdmZXsWdW1bKO482ZqKbPdmP+0Q5VPQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=DXuZaiCA; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="DXuZaiCA" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5382GSqC008168; Tue, 8 Apr 2025 04:21:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= tjH6i69nbjpMNZDiXdgJw7srN0uxGAjI4AZQw1iRHaI=; b=DXuZaiCALkldBAKU Kitwe8bi3RaknaeSMZU0Kdm6h7Wyp8bx2AuRAr6ccYKWWgoxktp525G33bloMCnG RiAxdgptnos4r3hCx+4YbJ7m4xfV6TUCMGDpzOgkR4OcEWZ2f2YeP3sD3TYravsF L3LAifGaxeY3A8Q4lHk82zZkDLkIBXECDafYjp1eU+yBZ7S+rY0rsnPrOZq/rSDF rCZWvk/kzyBgrdwYMCa6Wb1+/BNwD6utYzP8l7KNXKrTj1zaw8KiXHySf6G8lOu+ rjty8dGd0XqO+39owpVvENIjM2A/DrZdyFWnEmoM125ScvW1mBdMzefvANFrzM39 VqvnpQ== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 45twtaxg1t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Apr 2025 04:21:51 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA04.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 5384LpsG015810 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 8 Apr 2025 04:21:51 GMT Received: from hu-rajson-blr.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 7 Apr 2025 21:21:49 -0700 From: Rajat Soni To: CC: , Aditya Kumar Singh , Rajat Soni Subject: [PATCH ath-next 3/3] wifi: ath12k: Update frequency range if reg rules changes Date: Tue, 8 Apr 2025 09:51:28 +0530 Message-ID: <20250408042128.720263-4-quic_rajson@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250408042128.720263-1-quic_rajson@quicinc.com> References: <20250408042128.720263-1-quic_rajson@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: p9Ft41yVaWQyww_mPrUfT4jJsbOIfKlY X-Authority-Analysis: v=2.4 cv=LLlmQIW9 c=1 sm=1 tr=0 ts=67f4a45f cx=c_pps a=ouPCqIW2jiPt+lZRy3xVPw==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=GEpy-HfZoHoA:10 a=XR8D0OoHHMoA:10 a=EUspDBNiAAAA:8 a=COk6AnOGAAAA:8 a=w9nBwx8m75PmKFNLLyMA:9 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: p9Ft41yVaWQyww_mPrUfT4jJsbOIfKlY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-08_01,2025-04-07_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 clxscore=1015 mlxlogscore=999 malwarescore=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 mlxscore=0 spamscore=0 adultscore=0 suspectscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2502280000 definitions=main-2504080029 From: Aditya Kumar Singh During the hardware register, driver updates the frequency range during boot-up. However, if new regulatory rules are applied after boot-up, the frequency range remains based on the older rules. Since different countries have varying regulatory rules, the frequency range can differ. Retaining the frequency range based on outdated rules can be misleading. Update the frequency range according to the new regulatory rules in the function ath12k_regd_update(). Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.4.1-00199-QCAHKSWPL_SILICONZ-1 Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3 Signed-off-by: Aditya Kumar Singh Co-developed-by: Rajat Soni Signed-off-by: Rajat Soni --- drivers/net/wireless/ath/ath12k/reg.c | 54 +++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/drivers/net/wireless/ath/ath12k/reg.c b/drivers/net/wireless/ath/ath12k/reg.c index e1007b878f91..0fed4e0096cb 100644 --- a/drivers/net/wireless/ath/ath12k/reg.c +++ b/drivers/net/wireless/ath/ath12k/reg.c @@ -6,6 +6,7 @@ #include #include "core.h" #include "debug.h" +#include "mac.h" /* World regdom to be used in case default regd from fw is unavailable */ #define ATH12K_2GHZ_CH01_11 REG_RULE(2412 - 10, 2462 + 10, 40, 0, 20, 0) @@ -246,6 +247,8 @@ static void ath12k_copy_regd(struct ieee80211_regdomain *regd_orig, int ath12k_regd_update(struct ath12k *ar, bool init) { + u32 phy_id, freq_low = 0, freq_high = 0, supported_bands, band; + struct ath12k_wmi_hal_reg_capabilities_ext_arg *reg_cap; struct ath12k_hw *ah = ath12k_ar_to_ah(ar); struct ieee80211_hw *hw = ah->hw; struct ieee80211_regdomain *regd, *regd_copy = NULL; @@ -255,6 +258,47 @@ int ath12k_regd_update(struct ath12k *ar, bool init) ab = ar->ab; + supported_bands = ar->pdev->cap.supported_bands; + if (supported_bands & WMI_HOST_WLAN_2GHZ_CAP) { + band = NL80211_BAND_2GHZ; + } else if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP && !ar->supports_6ghz) { + band = NL80211_BAND_5GHZ; + } else if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP && ar->supports_6ghz) { + band = NL80211_BAND_6GHZ; + } else { + /* This condition is not expected. + */ + WARN_ON(1); + ret = -EINVAL; + goto err; + } + + reg_cap = &ab->hal_reg_cap[ar->pdev_idx]; + + if (ab->hw_params->single_pdev_only && !ar->supports_6ghz) { + phy_id = ar->pdev->cap.band[band].phy_id; + reg_cap = &ab->hal_reg_cap[phy_id]; + } + + /* Possible that due to reg change, current limits for supported + * frequency changed. Update that + */ + if (supported_bands & WMI_HOST_WLAN_2GHZ_CAP) { + freq_low = max(reg_cap->low_2ghz_chan, ab->reg_freq_2ghz.start_freq); + freq_high = min(reg_cap->high_2ghz_chan, ab->reg_freq_2ghz.end_freq); + } else if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP && !ar->supports_6ghz) { + freq_low = max(reg_cap->low_5ghz_chan, ab->reg_freq_5ghz.start_freq); + freq_high = min(reg_cap->high_5ghz_chan, ab->reg_freq_5ghz.end_freq); + } else if (supported_bands & WMI_HOST_WLAN_5GHZ_CAP && ar->supports_6ghz) { + freq_low = max(reg_cap->low_5ghz_chan, ab->reg_freq_6ghz.start_freq); + freq_high = min(reg_cap->high_5ghz_chan, ab->reg_freq_6ghz.end_freq); + } + + ath12k_mac_update_freq_range(ar, freq_low, freq_high); + + ath12k_dbg(ab, ATH12K_DBG_REG, "pdev %u reg updated freq limits %u->%u MHz\n", + ar->pdev->pdev_id, freq_low, freq_high); + /* If one of the radios within ah has already updated the regd for * the wiphy, then avoid setting regd again */ @@ -704,6 +748,16 @@ ath12k_reg_build_regd(struct ath12k_base *ab, "\r\nCountry %s, CFG Regdomain %s FW Regdomain %d, num_reg_rules %d\n", alpha2, ath12k_reg_get_regdom_str(tmp_regd->dfs_region), reg_info->dfs_region, num_rules); + + /* Reset start and end frequency for each band + */ + ab->reg_freq_5ghz.start_freq = INT_MAX; + ab->reg_freq_5ghz.end_freq = 0; + ab->reg_freq_2ghz.start_freq = INT_MAX; + ab->reg_freq_2ghz.end_freq = 0; + ab->reg_freq_6ghz.start_freq = INT_MAX; + ab->reg_freq_6ghz.end_freq = 0; + /* Update reg_rules[] below. Firmware is expected to * send these rules in order(2G rules first and then 5G) */