Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp583184rdg; Tue, 10 Oct 2023 22:01:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGgSa3to2AkxhvMlqoEncbAgX/rQmQlkMwI1Htx68P57CKhpHDX157AvsYc6sbYc4b/LiJC X-Received: by 2002:a05:6a20:12d6:b0:153:4ea6:d127 with SMTP id v22-20020a056a2012d600b001534ea6d127mr22068188pzg.18.1697000519178; Tue, 10 Oct 2023 22:01:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697000519; cv=none; d=google.com; s=arc-20160816; b=GeHxbUXhYNbKqqysB9vKM3WWEgE2zQXw7RQEGE+6ynynXQPxbrQUko2raimytnLDZM H1sdO/3/Lk2k2Y96yxiFOt9fyMjizvBIYXVUvXnFuOzafS5wsB/Ti/EijWfyaJpwioCB TdLtpdjXrWS1AJ3tLOvSUhpmd1sa9WyqQ9BLOx/Tq4Rk5uhfAROPTL5Y7sr4ZIebZfoc HhmamhREF4NFOcZSpv2ZW425AQRMZEuhVg69RHzzjuarro7P8vt9ODnkESiSqy1WvyRN ET+hf01FJaiVXWXiayoH9/L7JPsBFbcxOVY1yKl+g4OAe91s+y7Y8gzmkz8NEXp5ypmj PH9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=V7iIEccUkCBDqQ74w+MlPFrvDEe2ZpdJvdenoi9WzPo=; fh=zKk2CcW+fIQJ7rLFmqrmpTg4LxAxIxobdeHGGmSf1HM=; b=EHdUauwT8sUDmwqmAeroFrZFwqJiuzeANnrxccznlapMN9mKInKv3CJ1ZhgLlZmZJe ppH0bXG6D5ARZzFvPUZxJRUA7DHCbPDgbghkKYaHTaT9fLxsdhbL8CqlwKCcdT/MEwLF nAjFdb4ABVvhbKvPBR5iZomzKi7VBocnlYhi8HgtJ5Iw3vKe30lzAzOKdpLdEj1TB5Pg Ufj3H6LJfFMVeGCwDpEG93zxTUh9dX+c10qvwQVXrzGNxwR6aErSW2e0jCt6thNARl9C oBIFEjen1mwSS1VuACw1oa0kPOioZoopYl1EyWH7xXasb/JkI1qhDAt32a53k2xZf6ng 8b2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="lG7gX/xO"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id h15-20020a17090a604f00b002597ed3cc4fsi12960598pjm.189.2023.10.10.22.01.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 22:01:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="lG7gX/xO"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id B6D11802820F; Tue, 10 Oct 2023 22:01:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345161AbjJKFAa (ORCPT + 52 others); Wed, 11 Oct 2023 01:00:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345123AbjJKFA2 (ORCPT ); Wed, 11 Oct 2023 01:00:28 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72B2491 for ; Tue, 10 Oct 2023 22:00:26 -0700 (PDT) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39B50GQ8014841; Wed, 11 Oct 2023 05:00:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=V7iIEccUkCBDqQ74w+MlPFrvDEe2ZpdJvdenoi9WzPo=; b=lG7gX/xOp8GEvD/jzEbBO112QQtf/PmFqsMI/SdxslAow7CsV9EMbwsQa6pPBNrX/8s9 X9YeqWrdlMXPOmxeTKqWIOaX0SQtoY2gYRU1Hsukr2obqmDsBgkLhcX74nVwPSwMugGK w7i+P3zE2+pOG2G9Jw45ScUAsuJ4/GNoli9vf27Yb3JBYnOZTk+3PihrXFUy+KCHmQ3H 9w5E8u9q7pd2uo7VVjB61DQ4NM5sjQqf70qy9LsGwjckWo6qiXhzGVwGzb0oKJkHF0lo GrwAkjen6pjeEhdCRJ9AyvLqDamEKHeOF03PLYvDQTrUw6iH0y0g8F2d8YIaIPxV0stG 2g== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tne0q0p86-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 11 Oct 2023 05:00:24 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 39B50Nr7029781 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 11 Oct 2023 05:00:23 GMT Received: from lingbok-Latitude-E5440.qca.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Tue, 10 Oct 2023 22:00:21 -0700 From: Lingbo Kong To: , CC: , Subject: [PATCH v6 3/4] wifi: ath12k: add adjust configuration of CCA threshold value for WCN7850 Date: Wed, 11 Oct 2023 01:00:03 -0400 Message-ID: <20231011050004.423413-4-quic_lingbok@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231011050004.423413-1-quic_lingbok@quicinc.com> References: <20231011050004.423413-1-quic_lingbok@quicinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: iPj9dlT1VoTTTffPw5xRlHmGM335JYRn X-Proofpoint-ORIG-GUID: iPj9dlT1VoTTTffPw5xRlHmGM335JYRn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-11_01,2023-10-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 spamscore=0 mlxscore=0 clxscore=1015 priorityscore=1501 phishscore=0 adultscore=0 impostorscore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310110044 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Tue, 10 Oct 2023 22:01:54 -0700 (PDT) X-Spam-Level: ** Currently, ath12k does not have the ability to adjust CCA threshold values to meet the regulatory requirements. In order to support this, ath12k gets CCA threshold configuration in ath12k_acpi_dsm_get_data() function, then sets pdev_id and param_type_id and finally sends these data to firmware to implement the adjustment of the CCA threshold value. Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4 Signed-off-by: Lingbo Kong --- v6: 1.no change v5: 1.rebase to the latest tag v4: 1.revise commit log using imperative voice v3: 1.remove unnecessary cpu_to_le32() 2.adjust the order of the macros 3.apply jeff's advice v2: no change drivers/net/wireless/ath/ath12k/acpi.c | 30 +++++++++++++++++++ drivers/net/wireless/ath/ath12k/acpi.h | 8 ++++++ drivers/net/wireless/ath/ath12k/core.h | 1 + drivers/net/wireless/ath/ath12k/wmi.c | 40 ++++++++++++++++++++++++++ drivers/net/wireless/ath/ath12k/wmi.h | 7 +++-- 5 files changed, 84 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/acpi.c b/drivers/net/wireless/ath/ath12k/acpi.c index a4faeae90a0b..ba29d2bbc076 100644 --- a/drivers/net/wireless/ath/ath12k/acpi.c +++ b/drivers/net/wireless/ath/ath12k/acpi.c @@ -72,6 +72,16 @@ static int ath12k_acpi_dsm_get_data(struct ath12k_base *ab, int func) memcpy(&ab->acdata->geo_offset_data, obj->buffer.pointer, obj->buffer.length); break; + case ATH12K_ACPI_DSM_FUNC_INDEX_CCA: + if (obj->buffer.length != ATH12K_ACPI_DSM_CCA_DATA_SIZE) { + ath12k_err(ab, "Invalid CCA data size %d\n", + obj->buffer.length); + ret = -EINVAL; + goto out; + } + memcpy(&ab->acdata->cca_data, obj->buffer.pointer, + obj->buffer.length); + break; } } else { ath12k_err(ab, @@ -274,6 +284,26 @@ int ath12k_get_acpi_all_data(struct ath12k_base *ab) goto err_free_acdata; } + if (ATH12K_ACPI_FUNC_BIT_VALID(ab->acdata, ATH12K_ACPI_FUNC_BIT_CCA)) { + ret = ath12k_acpi_dsm_get_data(ab, + ATH12K_ACPI_DSM_FUNC_INDEX_CCA); + if (ret) { + ath12k_err(ab, "failed to get cca threshold configuration %d\n", ret); + goto err_free_acdata; + } + + if (ab->acdata->cca_data[0] == ATH12K_ACPI_CCA_THR_VERSION && + ab->acdata->cca_data[ATH12K_ACPI_CCA_THR_OFFSET_DATA_OFFSET] == + ATH12K_ACPI_CCA_THR_ENABLE_FLAG) { + ret = ath12k_wmi_pdev_set_cca_thr_table_param(ab, + ab->acdata->cca_data); + if (ret) { + ath12k_err(ab, "set cca threshold failed %d\n", ret); + goto err_free_acdata; + } + } + } + status = acpi_install_notify_handler(ACPI_HANDLE(ab->dev), ACPI_DEVICE_NOTIFY, acpi_dsm_notify, ab); diff --git a/drivers/net/wireless/ath/ath12k/acpi.h b/drivers/net/wireless/ath/ath12k/acpi.h index 2f930f0718da..1f05a68e490b 100644 --- a/drivers/net/wireless/ath/ath12k/acpi.h +++ b/drivers/net/wireless/ath/ath12k/acpi.h @@ -11,11 +11,13 @@ #define ATH12K_ACPI_DSM_FUNC_INDEX_SUPPORT_FUNCS 0 #define ATH12K_ACPI_DSM_FUNC_INDEX_BIOS_SAR 4 #define ATH12K_ACPI_DSM_FUNC_INDEX_GEO_OFFSET 5 +#define ATH12K_ACPI_DSM_FUNC_INDEX_CCA 6 #define ATH12K_ACPI_DSM_FUNC_INDEX_TAS_CFG 8 #define ATH12K_ACPI_DSM_FUNC_INDEX_TAS_DATA 9 #define ATH12K_ACPI_FUNC_BIT_BIOS_SAR BIT(3) #define ATH12K_ACPI_FUNC_BIT_GEO_OFFSET BIT(4) +#define ATH12K_ACPI_FUNC_BIT_CCA BIT(5) #define ATH12K_ACPI_FUNC_BIT_TAS_CFG BIT(7) #define ATH12K_ACPI_FUNC_BIT_TAS_DATA BIT(8) @@ -26,13 +28,17 @@ #define ATH12K_ACPI_TAS_DATA_ENABLE_FLAG 0x1 #define ATH12K_ACPI_POWER_LIMIT_VERSION 0x1 #define ATH12K_ACPI_POWER_LIMIT_ENABLE_FLAG 0x1 +#define ATH12K_ACPI_CCA_THR_VERSION 0x1 +#define ATH12K_ACPI_CCA_THR_ENABLE_FLAG 0x1 #define ATH12K_ACPI_GEO_OFFSET_DATA_OFFSET 1 #define ATH12K_ACPI_DBS_BACKOFF_DATA_OFFSET 2 +#define ATH12K_ACPI_CCA_THR_OFFSET_DATA_OFFSET 5 #define ATH12K_ACPI_BIOS_SAR_DBS_BACKOFF_LEN 10 #define ATH12K_ACPI_POWER_LIMIT_DATA_OFFSET 12 #define ATH12K_ACPI_BIOS_SAR_GEO_OFFSET_LEN 18 #define ATH12K_ACPI_BIOS_SAR_TABLE_LEN 22 +#define ATH12K_ACPI_CCA_THR_OFFSET_LEN 36 #define ATH12K_ACPI_DSM_TAS_DATA_SIZE 69 #define ATH12K_ACPI_DSM_TAS_CFG_SIZE 108 @@ -41,6 +47,8 @@ ATH12K_ACPI_BIOS_SAR_GEO_OFFSET_LEN) #define ATH12K_ACPI_DSM_BIOS_SAR_DATA_SIZE (ATH12K_ACPI_POWER_LIMIT_DATA_OFFSET + \ ATH12K_ACPI_BIOS_SAR_TABLE_LEN) +#define ATH12K_ACPI_DSM_CCA_DATA_SIZE (ATH12K_ACPI_CCA_THR_OFFSET_DATA_OFFSET + \ + ATH12K_ACPI_CCA_THR_OFFSET_LEN) int ath12k_get_acpi_all_data(struct ath12k_base *ab); void acpi_dsm_notify(acpi_handle handle, u32 event, void *data); diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h index e9823e063fb6..4b663577c2b9 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -802,6 +802,7 @@ struct ath12k_base { u8 tas_sar_power_table[ATH12K_ACPI_DSM_TAS_DATA_SIZE]; u8 bios_sar_data[ATH12K_ACPI_DSM_BIOS_SAR_DATA_SIZE]; u8 geo_offset_data[ATH12K_ACPI_DSM_GEO_OFFSET_DATA_SIZE]; + u8 cca_data[ATH12K_ACPI_DSM_CCA_DATA_SIZE]; } *acdata; /* must be last */ diff --git a/drivers/net/wireless/ath/ath12k/wmi.c b/drivers/net/wireless/ath/ath12k/wmi.c index cea382ee6850..b2fbd285ab4d 100644 --- a/drivers/net/wireless/ath/ath12k/wmi.c +++ b/drivers/net/wireless/ath/ath12k/wmi.c @@ -7144,3 +7144,43 @@ int ath12k_wmi_pdev_set_bios_geo_table_param(struct ath12k_base *ab, return ret; } + +int ath12k_wmi_pdev_set_cca_thr_table_param(struct ath12k_base *ab, + u8 *pcca_table) +{ + struct ath12k_wmi_base *wmi_ab = &ab->wmi_ab; + struct wmi_pdev_set_bios_interface_cmd *cmd; + struct wmi_tlv *tlv; + struct sk_buff *skb; + int ret; + u8 *buf_ptr; + u32 len, cca_thr_len_aligned; + u8 *pcca_value = pcca_table + ATH12K_ACPI_CCA_THR_OFFSET_DATA_OFFSET; + + cca_thr_len_aligned = roundup(ATH12K_ACPI_CCA_THR_OFFSET_LEN, sizeof(u32)); + len = sizeof(*cmd) + TLV_HDR_SIZE + cca_thr_len_aligned; + + skb = ath12k_wmi_alloc_skb(wmi_ab, len); + if (!skb) + return -ENOMEM; + + cmd = (struct wmi_pdev_set_bios_interface_cmd *)skb->data; + cmd->tlv_header = ath12k_wmi_tlv_cmd_hdr(WMI_TAG_PDEV_SET_BIOS_INTERFACE_CMD_PARAMS, + sizeof(*cmd)); + cmd->pdev_id = cpu_to_le32(WMI_PDEV_ID_SOC); + cmd->param_type_id = cpu_to_le32(WMI_BIOS_PARAM_CCA_THRESHOLD_TYPE); + cmd->length = ATH12K_ACPI_CCA_THR_OFFSET_LEN; + + buf_ptr = skb->data + sizeof(*cmd); + tlv = (struct wmi_tlv *)buf_ptr; + tlv->header = ath12k_wmi_tlv_hdr(WMI_TAG_ARRAY_BYTE, cca_thr_len_aligned); + buf_ptr += TLV_HDR_SIZE; + memcpy(buf_ptr, pcca_value, ATH12K_ACPI_CCA_THR_OFFSET_LEN); + + ret = ath12k_wmi_cmd_send(&wmi_ab->wmi[0], skb, WMI_PDEV_SET_BIOS_INTERFACE_CMDID); + if (ret) { + ath12k_warn(ab, "failed to send WMI_PDEV_SET_BIOS_INTERFACE_CMDID %d\n", ret); + dev_kfree_skb(skb); + } + return ret; +} diff --git a/drivers/net/wireless/ath/ath12k/wmi.h b/drivers/net/wireless/ath/ath12k/wmi.h index fa10adfdae0f..5a3d7962b8cb 100644 --- a/drivers/net/wireless/ath/ath12k/wmi.h +++ b/drivers/net/wireless/ath/ath12k/wmi.h @@ -4808,8 +4808,9 @@ struct wmi_pdev_set_bios_interface_cmd { } __packed; enum bios_param_type { - WMI_BIOS_PARAM_TAS_CONFIG_TYPE = 1, - WMI_BIOS_PARAM_TAS_DATA_TYPE = 2, + WMI_BIOS_PARAM_CCA_THRESHOLD_TYPE = 0, + WMI_BIOS_PARAM_TAS_CONFIG_TYPE = 1, + WMI_BIOS_PARAM_TAS_DATA_TYPE = 2, WMI_BIOS_PARAM_TYPE_MAX, }; @@ -4980,4 +4981,6 @@ int ath12k_wmi_pdev_set_bios_sar_table_param(struct ath12k_base *ab, u8 *psar_table); int ath12k_wmi_pdev_set_bios_geo_table_param(struct ath12k_base *ab, u8 *pgeo_table); +int ath12k_wmi_pdev_set_cca_thr_table_param(struct ath12k_base *ab, + u8 *pcca_table); #endif -- 2.34.1