From patchwork Tue May 7 04:56:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshitha Prem X-Patchwork-Id: 13656236 X-Patchwork-Delegate: kvalo@adurom.com Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 16AAD6A8A7 for ; Tue, 7 May 2024 04:57:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057849; cv=none; b=pDYooRn3tN5RCxotblJrP6+SOTqnYmjny1OBZFW50LOK4WVfsX9XwZKvP5uLJTVYf/M8jvd9s5mv7uO/cB3waXBXoGqTwyOR9huGPxt59Epm4Uh/0gu41o+IYD1TgZnNWObdCoqg9r+9BnLc9nNIFBsww31RTjIKAIPFQoM/KpY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057849; c=relaxed/simple; bh=8s3S88fZ9BQCpUYpQRhsN0rlf3OfwoesgMMcmJfRErE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=labN+dwWcuoua/1mahgcZB6IeWtuM3n8F4dsuJZOXSBuNmOaeivGxXpAeAmKPuYxVNk20+XQ7G57lW9vH1Sflx7Hx5CERCUUo80CIHqI3VNgqhrJbsQ52F3q7VFZ6wCsjh7ijMBz2H8JHotEIKvUFqHwy5J3pXMMncz2OtLrf7A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=pQ2pRNHX; arc=none smtp.client-ip=205.220.180.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=qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="pQ2pRNHX" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4473nWAd011483; Tue, 7 May 2024 04:57:22 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; s=qcppdkim1; bh=ubEDxTg wQG3NWeLVroPU8GBZ/i2g4vrRhCf4aVvc7Ao=; b=pQ2pRNHXuB3TvSE78Jxx4Wj epXrRzNwRTYj48gIDUsZSmjJZCNyBqTdi1bb3/P/tJ+IcqZysdi5ZbN+pGgW8M9D DZSccEfktOicStmoPdzOW2Wk2D9IJ0ryNW8T95L/Ilir0Up7EcHervPqMdjlcLBo 87IHDLc0raHe8cg+tXjpRgPSJbWXYNYFad5zuLnGh0zWkC59Dqole6PGkqX95Olh l8o6zYq+2b7R4kSGlGDSOXZQqdQC6oCDO5xBi3t7uqCGauF4+0IxwJ6PzrvUR9rU r+4r2TjfZad30hkjnUFQX4FQh6GFQmiiSLTZHF7Gaani0oet2zD1AMamuhGGpuw= = Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xxxj1hr73-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:21 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 4474vItA003579; Tue, 7 May 2024 04:57:18 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 3xwe3kn4yf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:18 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4474vIrB003572; Tue, 7 May 2024 04:57:18 GMT Received: from hu-devc-blr-u22-a.qualcomm.com (hu-hprem-blr.qualcomm.com [10.190.108.75]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 4474vINP003570 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:18 +0000 Received: by hu-devc-blr-u22-a.qualcomm.com (Postfix, from userid 4146166) id 03B7A4114D; Tue, 7 May 2024 10:27:17 +0530 (+0530) From: Harshitha Prem To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Karthikeyan Periyasamy , Harshitha Prem Subject: [PATCH v4 1/8] wifi: ath12k: Refactor core start api Date: Tue, 7 May 2024 10:26:55 +0530 Message-Id: <20240507045702.2858954-2-quic_hprem@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240507045702.2858954-1-quic_hprem@quicinc.com> References: <20240507045702.2858954-1-quic_hprem@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: kgRuoExF52RBIDiPx-J1YU8eqg_Idx13 X-Proofpoint-ORIG-GUID: kgRuoExF52RBIDiPx-J1YU8eqg_Idx13 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-07_02,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 malwarescore=0 clxscore=1015 adultscore=0 mlxlogscore=999 impostorscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2405070033 From: Karthikeyan Periyasamy Hardware device group abstraction would be introduced, in future, where radios across different devices can be grouped together to support multi-link operation and register as a device group to mac80211. Currently, ath12k_mac_allocate() and ath12k_mac_register() APIs are part of ath12k_core_start() and ath12k_core_pdev_create() respectively and are based on per device (ath12k_base). These APIs can be decoupled and moved out to ath12k_core_qmi_firmware_ready() itself. This refactor would be helpful for device group abstraction when mac80211 allocate and register will be changed from per device (ath12k_base) to per device group (ath12k_hw_group). Add changes to move allocate and register APIs from existing one and modify corresponding deinit sequence. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1 Signed-off-by: Karthikeyan Periyasamy Signed-off-by: Harshitha Prem Acked-by: Jeff Johnson --- drivers/net/wireless/ath/ath12k/core.c | 59 ++++++++++++-------------- drivers/net/wireless/ath/ath12k/pci.c | 1 + 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c index 9482d5db71e7..b7fcdc39f990 100644 --- a/drivers/net/wireless/ath/ath12k/core.c +++ b/drivers/net/wireless/ath/ath12k/core.c @@ -568,9 +568,10 @@ static void ath12k_core_stop(struct ath12k_base *ab) ath12k_acpi_stop(ab); + ath12k_dp_rx_pdev_reo_cleanup(ab); ath12k_hif_stop(ab); ath12k_wmi_detach(ab); - ath12k_dp_rx_pdev_reo_cleanup(ab); + ath12k_dp_free(ab); /* De-Init of components as needed */ } @@ -672,7 +673,7 @@ static int ath12k_core_soc_create(struct ath12k_base *ab) static void ath12k_core_soc_destroy(struct ath12k_base *ab) { - ath12k_dp_free(ab); + ath12k_hif_power_down(ab, false); ath12k_reg_free(ab); ath12k_debugfs_soc_destroy(ab); ath12k_qmi_deinit_service(ab); @@ -682,30 +683,17 @@ static int ath12k_core_pdev_create(struct ath12k_base *ab) { int ret; - ret = ath12k_mac_register(ab); - if (ret) { - ath12k_err(ab, "failed register the radio with mac80211: %d\n", ret); - return ret; - } - ret = ath12k_dp_pdev_alloc(ab); if (ret) { ath12k_err(ab, "failed to attach DP pdev: %d\n", ret); - goto err_mac_unregister; + return ret; } return 0; - -err_mac_unregister: - ath12k_mac_unregister(ab); - - return ret; } static void ath12k_core_pdev_destroy(struct ath12k_base *ab) { - ath12k_mac_unregister(ab); - ath12k_hif_irq_disable(ab); ath12k_dp_pdev_free(ab); } @@ -763,19 +751,12 @@ static int ath12k_core_start(struct ath12k_base *ab, goto err_hif_stop; } - ret = ath12k_mac_allocate(ab); - if (ret) { - ath12k_err(ab, "failed to create new hw device with mac80211 :%d\n", - ret); - goto err_hif_stop; - } - ath12k_dp_cc_config(ab); ret = ath12k_dp_rx_pdev_reo_setup(ab); if (ret) { ath12k_err(ab, "failed to initialize reo destination rings: %d\n", ret); - goto err_mac_destroy; + goto err_hif_stop; } ath12k_dp_hal_rx_desc_init(ab); @@ -818,8 +799,6 @@ static int ath12k_core_start(struct ath12k_base *ab, err_reo_cleanup: ath12k_dp_rx_pdev_reo_cleanup(ab); -err_mac_destroy: - ath12k_mac_destroy(ab); err_hif_stop: ath12k_hif_stop(ab); err_wmi_detach: @@ -873,11 +852,25 @@ int ath12k_core_qmi_firmware_ready(struct ath12k_base *ab) goto err_dp_free; } + ret = ath12k_mac_allocate(ab); + if (ret) { + ath12k_err(ab, "failed to create new hw device with mac80211 :%d\n", + ret); + goto err_core_stop; + } + + ret = ath12k_mac_register(ab); + if (ret) { + ath12k_err(ab, "failed register the radio with mac80211: %d\n", ret); + goto err_mac_destroy; + } + ret = ath12k_core_pdev_create(ab); if (ret) { ath12k_err(ab, "failed to create pdev core: %d\n", ret); - goto err_core_stop; + goto err_mac_unregister; } + ath12k_hif_irq_enable(ab); ret = ath12k_core_rfkill_config(ab); @@ -891,10 +884,14 @@ int ath12k_core_qmi_firmware_ready(struct ath12k_base *ab) return 0; err_core_pdev_destroy: + ath12k_hif_irq_disable(ab); ath12k_core_pdev_destroy(ab); +err_mac_unregister: + ath12k_mac_unregister(ab); +err_mac_destroy: + ath12k_mac_destroy(ab); err_core_stop: ath12k_core_stop(ab); - ath12k_mac_destroy(ab); err_dp_free: ath12k_dp_free(ab); mutex_unlock(&ab->core_lock); @@ -1208,15 +1205,15 @@ void ath12k_core_deinit(struct ath12k_base *ab) { mutex_lock(&ab->core_lock); + ath12k_hif_irq_disable(ab); ath12k_core_pdev_destroy(ab); + ath12k_mac_unregister(ab); + ath12k_mac_destroy(ab); ath12k_core_stop(ab); mutex_unlock(&ab->core_lock); - ath12k_hif_power_down(ab, false); - ath12k_mac_destroy(ab); ath12k_core_soc_destroy(ab); - ath12k_fw_unmap(ab); } void ath12k_core_free(struct ath12k_base *ab) diff --git a/drivers/net/wireless/ath/ath12k/pci.c b/drivers/net/wireless/ath/ath12k/pci.c index 16af046c33d9..95259b8cf251 100644 --- a/drivers/net/wireless/ath/ath12k/pci.c +++ b/drivers/net/wireless/ath/ath12k/pci.c @@ -1512,6 +1512,7 @@ static void ath12k_pci_remove(struct pci_dev *pdev) cancel_work_sync(&ab->reset_work); ath12k_core_deinit(ab); + ath12k_fw_unmap(ab); qmi_fail: ath12k_mhi_unregister(ab_pci); From patchwork Tue May 7 04:56:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshitha Prem X-Patchwork-Id: 13656238 X-Patchwork-Delegate: kvalo@adurom.com Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 6A53F6D1B0 for ; Tue, 7 May 2024 04:57:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057858; cv=none; b=ihbUp4xpym1wiKmIILmlSVfUj7/2gzFzB9EUHMlBacQMjyANOSGg4SzatWYNbp9h9MuQjjT5kR91a0tD4UZysnGuoLHlQ0pNE3f7oG02WyUigSj/XY++ukXW7LDcUgaHwmOW7Gm5xYCchMCzodnnnBAM5SVyGEFdPKq61RdeMcM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057858; c=relaxed/simple; bh=BvE7CluTvzFl1YEKzOMXpzrxuU7CqQ27a0ZuQbI8hP0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cvxOH8aVPQoJFKg5fp/IUrP/2Vx51NuSZ0sFh5detRHaZ3D6oJ3LJsxPn504OBaxLCYFweBBka2cOw2oITBXfM9uzv4flyp5WT1ZauRBLpWB9k9cPY+xQccgAjxKuuWCz+wXTFuvsYb4XOSj0gWVmaA4kb3LtNwS+q8XDOcKtSE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=mjUV+3QG; arc=none smtp.client-ip=205.220.180.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=qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="mjUV+3QG" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4473Iku5020657; Tue, 7 May 2024 04:57:33 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; s=qcppdkim1; bh=506CAO+ iBgTlQnbH2aXPvFgvMayo/gSiLO3W3JeVs+I=; b=mjUV+3QGjMSk7c5XCGicecQ iI5mtnEnT75CUMDxNxXVr9HWrpCDL9mvuwMzXwt/mNpmXODnHhYBXs6CRZafgSaf +wq4u1r/mJTMEAeg8llleuIYRzzDY5Cw8u4BwrKhNYfTDhkERcuwhOChv8/ttWdX UJ+YGOwmbE+um5+ua5H8+ngzB3uKzrpK+6cSutsAKFVFDtgyAHgJSP6BxJqqaIVM FUzQUiKQBkqxPHAsgxJXOICJwSKn0dtFhgICdInPvj2ZU8GXhyX1tKxCCTxWRTeK 5CnyQd2HgPsibYiyiVuY1Mw1jnTA4PDseZTJUFuFUMGE2NCxQsnvx7jM1qZeHWg= = Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xyc9b04nh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:32 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 4474vM9F003603; Tue, 7 May 2024 04:57:22 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 3xwe3kn4yv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:22 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4474vMBU003597; Tue, 7 May 2024 04:57:22 GMT Received: from hu-devc-blr-u22-a.qualcomm.com (hu-hprem-blr.qualcomm.com [10.190.108.75]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 4474vLQd003594 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:22 +0000 Received: by hu-devc-blr-u22-a.qualcomm.com (Postfix, from userid 4146166) id 075AF4114D; Tue, 7 May 2024 10:27:21 +0530 (+0530) From: Harshitha Prem To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Karthikeyan Periyasamy , Harshitha Prem Subject: [PATCH v4 2/8] wifi: ath12k: Add helpers to get or set ath12k_hw Date: Tue, 7 May 2024 10:26:56 +0530 Message-Id: <20240507045702.2858954-3-quic_hprem@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240507045702.2858954-1-quic_hprem@quicinc.com> References: <20240507045702.2858954-1-quic_hprem@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: eW1ZoGKIDx9jTOlBkJBmuwkQEO_sHhU5 X-Proofpoint-ORIG-GUID: eW1ZoGKIDx9jTOlBkJBmuwkQEO_sHhU5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-07_02,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 bulkscore=0 phishscore=0 clxscore=1015 suspectscore=0 mlxlogscore=679 malwarescore=0 mlxscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2405070033 From: Karthikeyan Periyasamy Currently, one or more ath12k_hw is part of a device (ath12k_base) but in future, it would be part of device group abstraction (ath12k_hw_group), i.e., when multiple radios (ar) across different devices can be combined together in a device group (ath12k_hw_group). In order to facilitate the above transition, introduce helpers such as ath12k_ab_to_ah() and ath12k_ab_set_ah() to get and set values of ath12k_hw respectively. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1 Signed-off-by: Karthikeyan Periyasamy Signed-off-by: Harshitha Prem Acked-by: Jeff Johnson --- drivers/net/wireless/ath/ath12k/core.c | 6 +++--- drivers/net/wireless/ath/ath12k/core.h | 11 +++++++++++ drivers/net/wireless/ath/ath12k/mac.c | 23 +++++++++++++---------- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c index b7fcdc39f990..217a1081fa94 100644 --- a/drivers/net/wireless/ath/ath12k/core.c +++ b/drivers/net/wireless/ath/ath12k/core.c @@ -950,7 +950,7 @@ static void ath12k_rfkill_work(struct work_struct *work) spin_unlock_bh(&ab->base_lock); for (i = 0; i < ab->num_hw; i++) { - ah = ab->ah[i]; + ah = ath12k_ab_to_ah(ab, i); if (!ah) continue; @@ -1002,7 +1002,7 @@ static void ath12k_core_pre_reconfigure_recovery(struct ath12k_base *ab) set_bit(ATH12K_FLAG_CRASH_FLUSH, &ab->dev_flags); for (i = 0; i < ab->num_hw; i++) { - ah = ab->ah[i]; + ah = ath12k_ab_to_ah(ab, i); if (!ah || ah->state == ATH12K_HW_STATE_OFF) continue; @@ -1041,7 +1041,7 @@ static void ath12k_core_post_reconfigure_recovery(struct ath12k_base *ab) int i, j; for (i = 0; i < ab->num_hw; i++) { - ah = ab->ah[i]; + ah = ath12k_ab_to_ah(ab, i); if (!ah || ah->state == ATH12K_HW_STATE_OFF) continue; diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h index 3cfc65b36579..c88262276cd9 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -1058,4 +1058,15 @@ static inline struct ieee80211_hw *ath12k_ar_to_hw(struct ath12k *ar) #define for_each_ar(ah, ar, index) \ for ((index) = 0; ((index) < (ah)->num_radio && \ ((ar) = &(ah)->radio[(index)])); (index)++) + +static inline struct ath12k_hw *ath12k_ab_to_ah(struct ath12k_base *ab, int idx) +{ + return ab->ah[idx]; +} + +static inline void ath12k_ab_set_ah(struct ath12k_base *ab, int idx, + struct ath12k_hw *ah) +{ + ab->ah[idx] = ah; +} #endif /* _CORE_H_ */ diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index 4f07ac8c0287..ff26cbc63b0a 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -8886,7 +8886,7 @@ int ath12k_mac_register(struct ath12k_base *ab) ab->free_vdev_map = (1LL << (ab->num_radios * TARGET_NUM_VDEVS)) - 1; for (i = 0; i < ab->num_hw; i++) { - ah = ab->ah[i]; + ah = ath12k_ab_to_ah(ab, i); ret = ath12k_mac_hw_register(ah); if (ret) @@ -8897,7 +8897,7 @@ int ath12k_mac_register(struct ath12k_base *ab) err: for (i = i - 1; i >= 0; i--) { - ah = ab->ah[i]; + ah = ath12k_ab_to_ah(ab, i); if (!ah) continue; @@ -8913,7 +8913,7 @@ void ath12k_mac_unregister(struct ath12k_base *ab) int i; for (i = ab->num_hw - 1; i >= 0; i--) { - ah = ab->ah[i]; + ah = ath12k_ab_to_ah(ab, i); if (!ah) continue; @@ -8971,6 +8971,7 @@ static struct ath12k_hw *ath12k_mac_hw_allocate(struct ath12k_base *ab, void ath12k_mac_destroy(struct ath12k_base *ab) { struct ath12k_pdev *pdev; + struct ath12k_hw *ah; int i; for (i = 0; i < ab->num_radios; i++) { @@ -8982,11 +8983,12 @@ void ath12k_mac_destroy(struct ath12k_base *ab) } for (i = 0; i < ab->num_hw; i++) { - if (!ab->ah[i]) + ah = ath12k_ab_to_ah(ab, i); + if (!ah) continue; - ath12k_mac_hw_destroy(ab->ah[i]); - ab->ah[i] = NULL; + ath12k_mac_hw_destroy(ah); + ath12k_ab_set_ah(ab, i, NULL); } } @@ -9017,7 +9019,7 @@ int ath12k_mac_allocate(struct ath12k_base *ab) goto err; } - ab->ah[i] = ah; + ath12k_ab_set_ah(ab, i, ah); } ath12k_dp_pdev_pre_alloc(ab); @@ -9026,11 +9028,12 @@ int ath12k_mac_allocate(struct ath12k_base *ab) err: for (i = i - 1; i >= 0; i--) { - if (!ab->ah[i]) + ah = ath12k_ab_to_ah(ab, i); + if (!ah) continue; - ath12k_mac_hw_destroy(ab->ah[i]); - ab->ah[i] = NULL; + ath12k_mac_hw_destroy(ah); + ath12k_ab_set_ah(ab, i, NULL); } return ret; From patchwork Tue May 7 04:56:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshitha Prem X-Patchwork-Id: 13656237 X-Patchwork-Delegate: kvalo@adurom.com Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 D59056CDB1 for ; Tue, 7 May 2024 04:57:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057857; cv=none; b=WMr3Koi+OQZ0tIbGrNDJPX5QTpwds6QCAzWsu1fztc7DH1jZ4BbZ1aWUVkWOrgEU3bkhRVabOrd14rgT5T1GvzJ4oRa923lN5M/oQCWM0LHyevmgftx/XL6V0hx3V+JGKlmrKPSXHkun8Q+JlHjvA5RTXzJ1Jo7sgIOrXtjepuI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057857; c=relaxed/simple; bh=fZ2okmahIYtvxUdGAqWO04/TrlfhOsKclQydgNlQuDA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=L4vEe6uOdxfBWNpzwP7JIp6qEGM7bMweNfkbNFyK2OTtHtrpvHit6MiV8XaUe7SOHbaJMfeEZ9voN77ServoP0aHUjmlRaSacKtMG52bfGRh9U88uaYu+wAq4ePaFA3/Ldpat+E9mcjPyQbTp4x9JpEhDdtHg4zTXW9mLwwmlPI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=jdnu0Vpl; arc=none smtp.client-ip=205.220.180.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=qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="jdnu0Vpl" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4473KeuL019034; Tue, 7 May 2024 04:57:32 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; s=qcppdkim1; bh=3isgEBf fzYEQsvvgH5j932Ob5avBkeu1B6MNSFtYUbU=; b=jdnu0VplnF3dtvFil5d3gkP riqkb0aQZ3ScZDeXdLUEhAHgL1x0osQeHZBhwKjQ+TdrxTwi4XRPEW10LvkqUucN f+xpu+9qK57BrPrTaWSXFzo7WrlVRMBSAZSLj7XFJ8B/o1bVOiEgrhp5teip/Fau 0deh8fuELhZ6IGant7YJEaZ++ncBe2MtBJ2xdjyq8HNoJni1wkZYst9o5J3qOSTR zl9KfPMV8VuLm614/avqY9fqmCP27fII2pUJbMURv5E2zWZP6Y7OpjzdMoZveY3i CgUqNvO0/Pr3wWc5TO/dOGKnCVfDlEl83BnTRrhJiXLGYMOFBDnO3yvLSKCd5Lw= = Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xxxj1hr7b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:32 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 4474vSbK003660; Tue, 7 May 2024 04:57:28 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 3xwe3kn50q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:28 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4474vSNm003652; Tue, 7 May 2024 04:57:28 GMT Received: from hu-devc-blr-u22-a.qualcomm.com (hu-hprem-blr.qualcomm.com [10.190.108.75]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 4474vSkA003646 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:28 +0000 Received: by hu-devc-blr-u22-a.qualcomm.com (Postfix, from userid 4146166) id 499994114D; Tue, 7 May 2024 10:27:27 +0530 (+0530) From: Harshitha Prem To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Karthikeyan Periyasamy , Harshitha Prem Subject: [PATCH v4 3/8] wifi: ath12k: Add ath12k_get_num_hw api Date: Tue, 7 May 2024 10:26:57 +0530 Message-Id: <20240507045702.2858954-4-quic_hprem@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240507045702.2858954-1-quic_hprem@quicinc.com> References: <20240507045702.2858954-1-quic_hprem@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: Dupxga4V3ugzwO-C4CK8WfjJbLKQmKm3 X-Proofpoint-ORIG-GUID: Dupxga4V3ugzwO-C4CK8WfjJbLKQmKm3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-07_02,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 malwarescore=0 clxscore=1015 adultscore=0 mlxlogscore=796 impostorscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2405070033 From: Karthikeyan Periyasamy Currently, one or more ath12k_hw is part of device (ath12k_base) but in future, ath12k_hw would be part of device group (ath12k_hw_group). Hence, num_hw under device would be moved to device group. To facilitate above transition, add helper ath12k_get_num_hw() api to get the number of radios per device. In future, this helper would be able to get the number of radios in a device group. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1 Signed-off-by: Karthikeyan Periyasamy Signed-off-by: Harshitha Prem Acked-by: Jeff Johnson --- drivers/net/wireless/ath/ath12k/core.c | 6 +++--- drivers/net/wireless/ath/ath12k/core.h | 5 +++++ drivers/net/wireless/ath/ath12k/mac.c | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c index 217a1081fa94..23b0edec1789 100644 --- a/drivers/net/wireless/ath/ath12k/core.c +++ b/drivers/net/wireless/ath/ath12k/core.c @@ -949,7 +949,7 @@ static void ath12k_rfkill_work(struct work_struct *work) rfkill_radio_on = ab->rfkill_radio_on; spin_unlock_bh(&ab->base_lock); - for (i = 0; i < ab->num_hw; i++) { + for (i = 0; i < ath12k_get_num_hw(ab); i++) { ah = ath12k_ab_to_ah(ab, i); if (!ah) continue; @@ -1001,7 +1001,7 @@ static void ath12k_core_pre_reconfigure_recovery(struct ath12k_base *ab) if (ab->is_reset) set_bit(ATH12K_FLAG_CRASH_FLUSH, &ab->dev_flags); - for (i = 0; i < ab->num_hw; i++) { + for (i = 0; i < ath12k_get_num_hw(ab); i++) { ah = ath12k_ab_to_ah(ab, i); if (!ah || ah->state == ATH12K_HW_STATE_OFF) continue; @@ -1040,7 +1040,7 @@ static void ath12k_core_post_reconfigure_recovery(struct ath12k_base *ab) struct ath12k *ar; int i, j; - for (i = 0; i < ab->num_hw; i++) { + for (i = 0; i < ath12k_get_num_hw(ab); i++) { ah = ath12k_ab_to_ah(ab, i); if (!ah || ah->state == ATH12K_HW_STATE_OFF) continue; diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h index c88262276cd9..49ff408d6db1 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -1069,4 +1069,9 @@ static inline void ath12k_ab_set_ah(struct ath12k_base *ab, int idx, { ab->ah[idx] = ah; } + +static inline int ath12k_get_num_hw(struct ath12k_base *ab) +{ + return ab->num_hw; +} #endif /* _CORE_H_ */ diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index ff26cbc63b0a..2e0bd7cfc7bf 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -8885,7 +8885,7 @@ int ath12k_mac_register(struct ath12k_base *ab) ab->cc_freq_hz = 320000; ab->free_vdev_map = (1LL << (ab->num_radios * TARGET_NUM_VDEVS)) - 1; - for (i = 0; i < ab->num_hw; i++) { + for (i = 0; i < ath12k_get_num_hw(ab); i++) { ah = ath12k_ab_to_ah(ab, i); ret = ath12k_mac_hw_register(ah); @@ -8912,7 +8912,7 @@ void ath12k_mac_unregister(struct ath12k_base *ab) struct ath12k_hw *ah; int i; - for (i = ab->num_hw - 1; i >= 0; i--) { + for (i = ath12k_get_num_hw(ab) - 1; i >= 0; i--) { ah = ath12k_ab_to_ah(ab, i); if (!ah) continue; @@ -8982,7 +8982,7 @@ void ath12k_mac_destroy(struct ath12k_base *ab) pdev->ar = NULL; } - for (i = 0; i < ab->num_hw; i++) { + for (i = 0; i < ath12k_get_num_hw(ab); i++) { ah = ath12k_ab_to_ah(ab, i); if (!ah) continue; @@ -9005,7 +9005,7 @@ int ath12k_mac_allocate(struct ath12k_base *ab) ab->num_hw = ab->num_radios; radio_per_hw = 1; - for (i = 0; i < ab->num_hw; i++) { + for (i = 0; i < ath12k_get_num_hw(ab); i++) { for (j = 0; j < radio_per_hw; j++) { pdev_map[j].ab = ab; pdev_map[j].pdev_idx = (i * radio_per_hw) + j; From patchwork Tue May 7 04:56:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshitha Prem X-Patchwork-Id: 13656240 X-Patchwork-Delegate: kvalo@adurom.com Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 B24147319F for ; Tue, 7 May 2024 04:57:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057861; cv=none; b=p6r0XM8npKT3madu5G7TjiYxGa+nx1uV2mhRzEFRQro7TrQlvL3PjhEUUi63gST7AJn3hTdR0yVJOl4T98V5rKdHF8f9AUfIpt2BCZArUA7UcXiWpQcGsX5fyDj5in0Q1nN1F9HW0az8xv5sCDickijqwueR3GR9nCz57gP/lTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057861; c=relaxed/simple; bh=Wt3npiWDE+gKd+wNvz2QXwy05Oub8/JP6IEzSUWkqAQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uTthhGKjFP5Lz9T7n0p8bdc3yesPowkMDbkQqqSGNWi5KoqtGuNGZGz11tG4r3WcaKgkf8XwCh+CgEwpUfew9wQ3Pvao2yxSyHj6IkJh5VorZePr8EmZGprEBBQ+UoIxVhEwWRKV10IgRfv2DTXb45OgZndM2TytyDg4y6k2W6I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=GxRCHoMS; arc=none smtp.client-ip=205.220.180.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=qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="GxRCHoMS" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4473NL7B012224; Tue, 7 May 2024 04:57:35 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; s=qcppdkim1; bh=IoIiHlt AK92Yj6c06oX+3YkBas+7zL9fmP20FIBSM9g=; b=GxRCHoMSvWQU7EK1qhS6OWW x+fzG87jMZ9tt4vQxsNtsyfbhvp8D8S56fjTIUOT48ycpR9ib9Fkn5TtQx9RPuN+ JYP9QHJoWKeHovcrKJlLEjqWkVRfH48LFa8vkLv0pLiOvAnL8pf8KFagPhPbJB7j YbgBGZwJRxKUWBjyczCv8FkF1Vew87LuUH+oXpyom96iISTL7nRs/DBwLL+EJ7Ta u0gmXCD4le85gxEB5Y0skSTimsHHovVtO/ii0aZ8NE5qd4l1mEWtJ88j6Px2ucGQ 8pE0nKXPQYqk0xZVXqQjUKZ7q1a24VlhyUYeFwzft2NO2/uiJlgdSpIPTirIHbw= = Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xy1vw9a47-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:35 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 4474vWqA004107; Tue, 7 May 2024 04:57:32 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 3xwe3kn516-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:32 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4474vSNo003652; Tue, 7 May 2024 04:57:31 GMT Received: from hu-devc-blr-u22-a.qualcomm.com (hu-hprem-blr.qualcomm.com [10.190.108.75]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 4474vVXG004102 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:31 +0000 Received: by hu-devc-blr-u22-a.qualcomm.com (Postfix, from userid 4146166) id A78A74114D; Tue, 7 May 2024 10:27:30 +0530 (+0530) From: Harshitha Prem To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Karthikeyan Periyasamy , Harshitha Prem Subject: [PATCH v4 4/8] wifi: ath12k: Introduce QMI firmware ready flag Date: Tue, 7 May 2024 10:26:58 +0530 Message-Id: <20240507045702.2858954-5-quic_hprem@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240507045702.2858954-1-quic_hprem@quicinc.com> References: <20240507045702.2858954-1-quic_hprem@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: Ral9lY2UNAGbo7D8ir7Bjs0U4l6M-z8a X-Proofpoint-GUID: Ral9lY2UNAGbo7D8ir7Bjs0U4l6M-z8a X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-07_02,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 malwarescore=0 adultscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=817 impostorscore=0 mlxscore=0 spamscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2405070033 From: Karthikeyan Periyasamy When hardware device group abstraction is introduced, QMI firmware ready event of different devices in a group can be received simultaneously. To indicate firmware ready event is completed for a particular device in a group set a flag (ATH12K_FLAG_QMI_FW_READY_COMPLETE). This would be helpful when hardware recovery is introduced for hardware device group abstraction. Add changes to set/unset ATH12K_FLAG_QMI_FW_READY_COMPLETE flag for a device. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1 Signed-off-by: Karthikeyan Periyasamy Signed-off-by: Harshitha Prem Acked-by: Jeff Johnson --- drivers/net/wireless/ath/ath12k/core.h | 1 + drivers/net/wireless/ath/ath12k/qmi.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h index 49ff408d6db1..4736d1afa0c7 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -210,6 +210,7 @@ enum ath12k_dev_flags { ATH12K_FLAG_HTC_SUSPEND_COMPLETE, ATH12K_FLAG_CE_IRQ_ENABLED, ATH12K_FLAG_EXT_IRQ_ENABLED, + ATH12K_FLAG_QMI_FW_READY_COMPLETE, }; enum ath12k_monitor_flags { diff --git a/drivers/net/wireless/ath/ath12k/qmi.c b/drivers/net/wireless/ath/ath12k/qmi.c index 3bb730326a02..19a03cf8c391 100644 --- a/drivers/net/wireless/ath/ath12k/qmi.c +++ b/drivers/net/wireless/ath/ath12k/qmi.c @@ -3023,6 +3023,8 @@ void ath12k_qmi_firmware_stop(struct ath12k_base *ab) { int ret; + clear_bit(ATH12K_FLAG_QMI_FW_READY_COMPLETE, &ab->dev_flags); + ret = ath12k_qmi_wlanfw_mode_send(ab, ATH12K_FIRMWARE_MODE_OFF); if (ret < 0) { ath12k_warn(ab, "qmi failed to send wlan mode off\n"); @@ -3320,7 +3322,7 @@ static void ath12k_qmi_driver_event_work(struct work_struct *work) break; case ATH12K_QMI_EVENT_FW_READY: clear_bit(ATH12K_FLAG_QMI_FAIL, &ab->dev_flags); - if (test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags)) { + if (test_bit(ATH12K_FLAG_QMI_FW_READY_COMPLETE, &ab->dev_flags)) { if (ab->is_reset) ath12k_hal_dump_srng_stats(ab); queue_work(ab->workqueue, &ab->restart_work); @@ -3330,8 +3332,12 @@ static void ath12k_qmi_driver_event_work(struct work_struct *work) clear_bit(ATH12K_FLAG_CRASH_FLUSH, &ab->dev_flags); clear_bit(ATH12K_FLAG_RECOVERY, &ab->dev_flags); - ath12k_core_qmi_firmware_ready(ab); - set_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags); + ret = ath12k_core_qmi_firmware_ready(ab); + if (!ret) { + set_bit(ATH12K_FLAG_QMI_FW_READY_COMPLETE, + &ab->dev_flags); + set_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags); + } break; default: From patchwork Tue May 7 04:56:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshitha Prem X-Patchwork-Id: 13656241 X-Patchwork-Delegate: kvalo@adurom.com Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 E4ED17CF33 for ; Tue, 7 May 2024 04:57:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057868; cv=none; b=FexPp1jQoHzMJFlsmc5/kkGKljOXHmSXlZlGgO2EylWr74ErPpfHAEODbbv0C9zR08Saikc1QwjWsh7Tr33yVoCy2538ojxigYLUJw18ON81XDuSFCrRehtZ7LvHz0KvhvIpXx6tKQJZ5LTDrVtSz7abnZb/Cu1plSCMd0SGAso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057868; c=relaxed/simple; bh=Z7MCuUVg/N9CtaFTTOFZVGy9sO3a2ZI+XYywsXx/H0Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QWQWN/1SjyVADgiylMO2LMj8wkKLZpVvpnBlJeOSV3hhMW/uI0E4Za6woI6PB5xD2IOp2nyX9lHS+LuapN6WUcGb8UjDIjhzK7stgTL+AFkROzxfoY4PKygSl16dQjRPw1VCnE3Pqe3tak3CC1tZefB359uv8D7G5ho5YEo/ldQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=jn1oqI9I; arc=none smtp.client-ip=205.220.180.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=qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="jn1oqI9I" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4474TwUp017216; Tue, 7 May 2024 04:57:43 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; s=qcppdkim1; bh=4v6AGBl zBUsb2583+c8yEcosQ2QkwG19GKVzZSugUzc=; b=jn1oqI9IJyQFBWqL0hK0FCb p+mUj1BT2Hj2kUvweIxJj1CXKROmneysXlp9NgVBEdEumFo7DdoRkCLiyZo/ZcZa TE4zpQiOycnWtyhEHcmzsJU00mYAX0wRUdlLuLM1dFcyxeH8G1dVIt4tMk8D533q NWf/HtSlTa0eABHxG2kURMyilmJZMuuWmRHOZo2WV9dejzT/wmQpQZcjCdhDVNu0 d7EFcOYsOprKmtujPP2P3S0Jj6ea5mL9AHiWAtb3heZ9IyiXGapAX1UevhFbx7SY 5UJx3nTgwVmud8viasHwEILpZPD5wQyAONEevqEaQBb9UJb6NbpU0Fk8zJOX91Q= = Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xy1vw9a4p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:43 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 4474veip004180; Tue, 7 May 2024 04:57:40 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 3xwe3kn526-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:39 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4474vduW004168; Tue, 7 May 2024 04:57:39 GMT Received: from hu-devc-blr-u22-a.qualcomm.com (hu-hprem-blr.qualcomm.com [10.190.108.75]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 4474vdsx004167 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:39 +0000 Received: by hu-devc-blr-u22-a.qualcomm.com (Postfix, from userid 4146166) id F336D4114D; Tue, 7 May 2024 10:27:38 +0530 (+0530) From: Harshitha Prem To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Karthikeyan Periyasamy , Harshitha Prem Subject: [PATCH v4 5/8] wifi: ath12k: move ATH12K_FLAG_REGISTERED flag set to mac_register api Date: Tue, 7 May 2024 10:26:59 +0530 Message-Id: <20240507045702.2858954-6-quic_hprem@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240507045702.2858954-1-quic_hprem@quicinc.com> References: <20240507045702.2858954-1-quic_hprem@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: t_vU-6IfPumf0e6pWGmMbjRZSrUmSrqR X-Proofpoint-GUID: t_vU-6IfPumf0e6pWGmMbjRZSrUmSrqR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-07_02,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 malwarescore=0 adultscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=999 impostorscore=0 mlxscore=0 spamscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2405070033 From: Karthikeyan Periyasamy When hardware device group abstraction is introduced, in future, a group abstraction is registered to mac80211 rather than a particular device. Hence, setting ATH12K_FLAG_REGISTERED in QMI firmware ready event might not be ideal. Add changes to move set/unset of ATH12K_FLAG_REGISTERED flag inside ath12k_mac_register() and ath12k_mac_unregister() respectively. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1 Signed-off-by: Karthikeyan Periyasamy Signed-off-by: Harshitha Prem Acked-by: Jeff Johnson --- drivers/net/wireless/ath/ath12k/mac.c | 2 ++ drivers/net/wireless/ath/ath12k/qmi.c | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index 2e0bd7cfc7bf..ada4569fbff4 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -8893,6 +8893,7 @@ int ath12k_mac_register(struct ath12k_base *ab) goto err; } + set_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags); return 0; err: @@ -8912,6 +8913,7 @@ void ath12k_mac_unregister(struct ath12k_base *ab) struct ath12k_hw *ah; int i; + clear_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags); for (i = ath12k_get_num_hw(ab) - 1; i >= 0; i--) { ah = ath12k_ab_to_ah(ab, i); if (!ah) diff --git a/drivers/net/wireless/ath/ath12k/qmi.c b/drivers/net/wireless/ath/ath12k/qmi.c index 19a03cf8c391..b3a8459ab4e5 100644 --- a/drivers/net/wireless/ath/ath12k/qmi.c +++ b/drivers/net/wireless/ath/ath12k/qmi.c @@ -3333,11 +3333,9 @@ static void ath12k_qmi_driver_event_work(struct work_struct *work) &ab->dev_flags); clear_bit(ATH12K_FLAG_RECOVERY, &ab->dev_flags); ret = ath12k_core_qmi_firmware_ready(ab); - if (!ret) { + if (!ret) set_bit(ATH12K_FLAG_QMI_FW_READY_COMPLETE, &ab->dev_flags); - set_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags); - } break; default: From patchwork Tue May 7 04:57:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshitha Prem X-Patchwork-Id: 13656242 X-Patchwork-Delegate: kvalo@adurom.com Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 59DAB6BFBA for ; Tue, 7 May 2024 04:57:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057872; cv=none; b=rnUAQKUaagBv/ouiVbvmpm05XRCHUP9LkkP7GkrXQhkIf6JbVBRWVc6VztxvFcx7B+TrACLK09wJhGCOLVxsOWaDs2TalSphHhK1w8EBQSt2GmJLtA6Jf3coxfuTYuDQmQqEf9PNU8FLl46heBbS9vPBgKIHBzEsoXGiFSxZTYk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057872; c=relaxed/simple; bh=J3kPPbtMaKAv7z46yTO+fv7yAmmbUSe24wmyJymmgvs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GQhMzBkzUOe1dV5c7coGkWihaxFS9l4CNWFovmU5ItDJ/d3WJguq3nLBVB4Gh4hddocf0WrDTh9ZmgE7vHbJYMTIpa9PblBbOEUfcRgRSXDd5KlGCUg8nR0+Q3g4ctLPaBWEFb1d7qMT2fsrfZg5NjBLL8xzLCHCi5ahRsLHbSE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=ZLtPTt9j; arc=none smtp.client-ip=205.220.180.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=qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="ZLtPTt9j" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4473Orwd011072; Tue, 7 May 2024 04:57:45 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; s=qcppdkim1; bh=E0gNuG0 HmtY8JNQxz8auAcGTIIjBEC4/EtbXxnVBynM=; b=ZLtPTt9jUj2HeC0i1bH+5e2 d9O3rvZz84gjwvPv3O9VFoyRGURZ4pF/UOhi2kstYnhXb4ghlD+SedGY3zkumQwK SrJzSNvHDIAONXllvt9aGqBKz8KdlUGBoRbwwqQp/FHirAgtEhj8eIISD8qZyr31 TOvZxGEgi+I3pySvGtLly3RQVYhk6i1CBWQJv9+ajMj5++HmXzx53Qx36YyW37XG oCOpb+54kcFmrCw3RS8tHjb6BKl3ZQjRU5IXN2mWPqvBxfRIH8djzuNQiWIw27Sc Ri87bs1bQw3eX6Z/sCwVbVnHdQP8jMSTIEv6N3wuYdo9P6tygoZz1cvn4+KkGUQ= = Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xyc03g5p5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:44 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 4474veiq004180; Tue, 7 May 2024 04:57:41 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 3xwe3kn52c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:41 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4474vfkt004191; Tue, 7 May 2024 04:57:41 GMT Received: from hu-devc-blr-u22-a.qualcomm.com (hu-hprem-blr.qualcomm.com [10.190.108.75]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 4474vfOB004190 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:41 +0000 Received: by hu-devc-blr-u22-a.qualcomm.com (Postfix, from userid 4146166) id 1AE7D4114D; Tue, 7 May 2024 10:27:40 +0530 (+0530) From: Harshitha Prem To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Karthikeyan Periyasamy , Harshitha Prem Subject: [PATCH v4 6/8] wifi: ath12k: Introduce device group abstraction Date: Tue, 7 May 2024 10:27:00 +0530 Message-Id: <20240507045702.2858954-7-quic_hprem@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240507045702.2858954-1-quic_hprem@quicinc.com> References: <20240507045702.2858954-1-quic_hprem@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: y5uKiOHazovgi7DPVlfZQ0HUaf5-s1AF X-Proofpoint-GUID: y5uKiOHazovgi7DPVlfZQ0HUaf5-s1AF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-07_02,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 suspectscore=0 priorityscore=1501 mlxlogscore=999 adultscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2405070033 From: Karthikeyan Periyasamy Currently, single device is probed and once firmware is ready, the device is registered to mac80211. For multi-link operation, different bands of different devices or same device would be part of a single wiphy and for this, hardware device group abstraction would be helpful. Hardware device group abstraction - when there are multiple devices (with single radio or dual radio) that are connected by any means of interface for communicating between them, then these devices can be combined together as a single group using a group id to form a group abstraction and register to mac80211. The grouping information of multiple devices would be based on device tree during device probe. If no such information is available then a single device will be part of group abstraction and registered to mac80211 else multiple devices advertised in device tree are combined and then registered to mac80211. For device group abstraction, a base structure named ath12k_hw_group (ag) and the following helpers are introduced: ath12k_core_hw_group_alloc() : allocate ath12k_hw_group (ag) based on group id and number of devices that are going to be part of this group. ath12k_core_hw_group_free() : free ag during deinit. ath12k_core_assign_hw_group() : assign/map the details of group to ath12k_base (ab). ath12k_core_unassign_hw_group() : unassign/unmap the details of ag in ath12k_base (ab). ath12k_core_hw_group_create() : create the devices which are part of group (ag). ath12k_core_hw_group_destroy() : cleanup the devices in ag These helpers are used during device probe and mapping the group to the devices involved. Please find the illustration of how multiple devices might be combined together in future based on group id. Grouping of multiple devices (in future) +------------------------------------------------------------------------+ | +-------------------------------------+ +-------------------+ | | | +-----------+ | | +-----------+ | | +-----------+ | | | | | ar (2GHz) | | | | ar (5GHz) | | | | ar (6GHz) | | | | | +-----------+ | | +-----------+ | | +-----------+ | | | | ath12k_base (ab) | | ath12k_base (ab) | | | | (Dual band device) | | | | | +-------------------------------------+ +-------------------+ | | ath12k_hw_group (ag) based on group id | +------------------------------------------------------------------------+ In the above representation, two devices are combined into single group based on group id. Add base code changes where single device would be part of a group with an invalid group id forming an group abstraction. Multi device grouping will be introduced in future. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1 Signed-off-by: Karthikeyan Periyasamy Co-developed-by: Harshitha Prem Signed-off-by: Harshitha Prem Acked-by: Jeff Johnson --- drivers/net/wireless/ath/ath12k/core.c | 218 ++++++++++++++++++++++++- drivers/net/wireless/ath/ath12k/core.h | 19 +++ drivers/net/wireless/ath/ath12k/pci.c | 1 + 3 files changed, 229 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c index 23b0edec1789..c1cda7d37c1a 100644 --- a/drivers/net/wireless/ath/ath12k/core.c +++ b/drivers/net/wireless/ath/ath12k/core.c @@ -21,6 +21,9 @@ unsigned int ath12k_debug_mask; module_param_named(debug_mask, ath12k_debug_mask, uint, 0644); MODULE_PARM_DESC(debug_mask, "Debugging mask"); +static DEFINE_MUTEX(ath12k_hw_lock); +static struct list_head ath12k_hw_groups = LIST_HEAD_INIT(ath12k_hw_groups); + static int ath12k_core_rfkill_config(struct ath12k_base *ab) { struct ath12k *ar; @@ -1188,20 +1191,111 @@ int ath12k_core_pre_init(struct ath12k_base *ab) return 0; } -int ath12k_core_init(struct ath12k_base *ab) +static inline +bool ath12k_core_hw_group_create_ready(struct ath12k_hw_group *ag) { - int ret; + lockdep_assert_held(&ag->mutex_lock); - ret = ath12k_core_soc_create(ab); - if (ret) { - ath12k_err(ab, "failed to create soc core: %d\n", ret); - return ret; + return (ag->num_probed == ag->num_devices); +} + +static struct ath12k_hw_group * +ath12k_core_hw_group_alloc(u8 id, u8 max_devices) +{ + struct ath12k_hw_group *ag; + + lockdep_assert_held(&ath12k_hw_lock); + + ag = kzalloc(sizeof(*ag), GFP_KERNEL); + if (!ag) + return NULL; + + ag->id = id; + ag->num_devices = max_devices; + list_add(&ag->list, &ath12k_hw_groups); + mutex_init(&ag->mutex_lock); + + return ag; +} + +static void ath12k_core_hw_group_free(struct ath12k_hw_group *ag) +{ + mutex_lock(&ath12k_hw_lock); + + list_del(&ag->list); + kfree(ag); + + mutex_unlock(&ath12k_hw_lock); +} + +static struct ath12k_hw_group *ath12k_core_assign_hw_group(struct ath12k_base *ab) +{ + struct ath12k_hw_group *ag; + u32 group_id = ATH12K_INVALID_GROUP_ID; + + lockdep_assert_held(&ath12k_hw_lock); + + /* The grouping of multiple devices will be done based on device tree file. + * TODO: device tree file parsing to know about the devices involved in group. + * + * The platforms that do not have any valid group information would have each + * device to be part of its own invalid group. + * + * Currently, we are not parsing any device tree information and hence, grouping + * of multiple devices is not involved. Thus, single device is added to device + * group. + */ + ag = ath12k_core_hw_group_alloc(group_id, 1); + if (!ag) { + ath12k_warn(ab, "unable to create new hw group\n"); + return NULL; } + ath12k_dbg(ab, ATH12K_DBG_BOOT, "Single device is added to hardware group\n"); - return 0; + ab->device_id = ag->num_probed++; + ag->ab[ab->device_id] = ab; + ab->ag = ag; + + return ag; } -void ath12k_core_deinit(struct ath12k_base *ab) +void ath12k_core_unassign_hw_group(struct ath12k_base *ab) +{ + struct ath12k_hw_group *ag = ab->ag; + u8 device_id = ab->device_id; + int num_probed; + + if (!ag) + return; + + mutex_lock(&ag->mutex_lock); + + if (WARN_ON(device_id >= ag->num_devices)) { + mutex_unlock(&ag->mutex_lock); + return; + } + + if (WARN_ON(ag->ab[device_id] != ab)) { + mutex_unlock(&ag->mutex_lock); + return; + } + + ag->ab[device_id] = NULL; + ab->ag = NULL; + ab->device_id = ATH12K_INVALID_DEVICE_ID; + + if (ag->num_probed) + ag->num_probed--; + + num_probed = ag->num_probed; + + mutex_unlock(&ag->mutex_lock); + + if (!num_probed) + ath12k_core_hw_group_free(ag); +} + +static void ath12k_core_device_cleanup(struct ath12k_base *ab) { mutex_lock(&ab->core_lock); @@ -1212,8 +1306,114 @@ void ath12k_core_deinit(struct ath12k_base *ab) ath12k_core_stop(ab); mutex_unlock(&ab->core_lock); +} + +static void ath12k_core_hw_group_destroy(struct ath12k_hw_group *ag) +{ + struct ath12k_base *ab; + int i; - ath12k_core_soc_destroy(ab); + if (WARN_ON(!ag)) + return; + + for (i = 0; i < ag->num_devices; i++) { + ab = ag->ab[i]; + if (!ab) + continue; + + if (test_and_clear_bit(ATH12K_FLAG_HW_GROUP_ATTACHED, &ab->dev_flags)) + ath12k_core_soc_destroy(ab); + } +} + +static void ath12k_core_hw_group_cleanup(struct ath12k_hw_group *ag) +{ + struct ath12k_base *ab; + int i; + + if (!ag) + return; + + mutex_lock(&ag->mutex_lock); + for (i = 0; i < ag->num_devices; i++) { + ab = ag->ab[i]; + if (!ab) + continue; + + if (test_bit(ATH12K_FLAG_QMI_FW_READY_COMPLETE, &ab->dev_flags)) + ath12k_core_device_cleanup(ab); + } + mutex_unlock(&ag->mutex_lock); +} + +static int ath12k_core_hw_group_create(struct ath12k_hw_group *ag) +{ + int i, ret; + struct ath12k_base *ab; + + lockdep_assert_held(&ag->mutex_lock); + + for (i = 0; i < ag->num_devices; i++) { + ab = ag->ab[i]; + if (!ab) + continue; + + mutex_lock(&ab->core_lock); + ret = ath12k_core_soc_create(ab); + if (ret) { + mutex_unlock(&ab->core_lock); + ath12k_err(ab, "failed to create soc core: %d\n", ret); + return ret; + } + set_bit(ATH12K_FLAG_HW_GROUP_ATTACHED, &ab->dev_flags); + mutex_unlock(&ab->core_lock); + } + + return 0; +} + +int ath12k_core_init(struct ath12k_base *ab) +{ + struct ath12k_hw_group *ag; + int ret; + + mutex_lock(&ath12k_hw_lock); + ag = ath12k_core_assign_hw_group(ab); + if (!ag) { + mutex_unlock(&ath12k_hw_lock); + ath12k_warn(ab, "unable to get hw group\n"); + return -ENODEV; + } + mutex_unlock(&ath12k_hw_lock); + + mutex_lock(&ag->mutex_lock); + + ath12k_dbg(ab, ATH12K_DBG_BOOT, "num devices in group %d, num probed %d\n", + ag->num_devices, ag->num_probed); + + if (ath12k_core_hw_group_create_ready(ag)) { + ret = ath12k_core_hw_group_create(ag); + if (ret) { + mutex_unlock(&ag->mutex_lock); + ath12k_warn(ab, "unable to create hw group\n"); + goto err_hw_group; + } + } + mutex_unlock(&ag->mutex_lock); + + return 0; + +err_hw_group: + ath12k_core_hw_group_destroy(ab->ag); + ath12k_core_unassign_hw_group(ab); + return ret; +} + +void ath12k_core_deinit(struct ath12k_base *ab) +{ + ath12k_core_hw_group_cleanup(ab->ag); + ath12k_core_hw_group_destroy(ab->ag); + ath12k_core_unassign_hw_group(ab); } void ath12k_core_free(struct ath12k_base *ab) diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h index 4736d1afa0c7..c6238335c7c0 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -59,6 +59,10 @@ #define ATH12K_RECONFIGURE_TIMEOUT_HZ (10 * HZ) #define ATH12K_RECOVER_START_TIMEOUT_HZ (20 * HZ) +#define ATH12K_MAX_SOCS 3 +#define ATH12K_INVALID_GROUP_ID 0xFF +#define ATH12K_INVALID_DEVICE_ID 0xFF + enum ath12k_bdf_search { ATH12K_BDF_SEARCH_DEFAULT, ATH12K_BDF_SEARCH_BUS_AND_BOARD, @@ -211,6 +215,7 @@ enum ath12k_dev_flags { ATH12K_FLAG_CE_IRQ_ENABLED, ATH12K_FLAG_EXT_IRQ_ENABLED, ATH12K_FLAG_QMI_FW_READY_COMPLETE, + ATH12K_FLAG_HW_GROUP_ATTACHED, }; enum ath12k_monitor_flags { @@ -732,6 +737,17 @@ struct ath12k_soc_dp_stats { struct ath12k_soc_dp_tx_err_stats tx_err; }; +/* Holds info on the group of devices that are registered as a single wiphy */ +struct ath12k_hw_group { + struct list_head list; + u8 id; + u8 num_devices; + u8 num_probed; + struct ath12k_base *ab[ATH12K_MAX_SOCS]; + /* To synchronize group create, assign, start, stop */ + struct mutex mutex_lock; +}; + /** * enum ath12k_link_capable_flags - link capable flags * @@ -932,6 +948,8 @@ struct ath12k_base { #endif /* CONFIG_ACPI */ + struct ath12k_hw_group *ag; + /* must be last */ u8 drv_priv[] __aligned(sizeof(void *)); }; @@ -962,6 +980,7 @@ int ath12k_core_resume_early(struct ath12k_base *ab); int ath12k_core_resume(struct ath12k_base *ab); int ath12k_core_suspend(struct ath12k_base *ab); int ath12k_core_suspend_late(struct ath12k_base *ab); +void ath12k_core_unassign_hw_group(struct ath12k_base *ab); const struct firmware *ath12k_core_firmware_request(struct ath12k_base *ab, const char *filename); diff --git a/drivers/net/wireless/ath/ath12k/pci.c b/drivers/net/wireless/ath/ath12k/pci.c index 95259b8cf251..a4605549ba13 100644 --- a/drivers/net/wireless/ath/ath12k/pci.c +++ b/drivers/net/wireless/ath/ath12k/pci.c @@ -1505,6 +1505,7 @@ static void ath12k_pci_remove(struct pci_dev *pdev) if (test_bit(ATH12K_FLAG_QMI_FAIL, &ab->dev_flags)) { ath12k_pci_power_down(ab, false); ath12k_qmi_deinit_service(ab); + ath12k_core_unassign_hw_group(ab); goto qmi_fail; } From patchwork Tue May 7 04:57:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshitha Prem X-Patchwork-Id: 13656243 X-Patchwork-Delegate: kvalo@adurom.com Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 D76346A8CF for ; Tue, 7 May 2024 04:57:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057877; cv=none; b=fjyaBDiz2bH3lEAp8uF7VTW7lOYvWUh8bpiYGmuHZ1nEsVIKAjqp/rDNC9exYukgI+Ro9fTl5egoVZ8WSOuOYV2dZDtJ1ii8bIEWN6yS4ZIIBmTGKNYzzkLDm0gc4AZt54fiVWEoTInjydYic5r0n/LEiIGswiv8F53VPqUn+RM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057877; c=relaxed/simple; bh=XGiEqs0sO64oa653qbneEpUdwmSRuS2QMaDT6uUKZNM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gaeAPSkAF8x5Uz64JnOZv/wkENM9qDCwG0VWVs+NbRJKrzmgyiDBHMQzTUXHCDclvM3LS4lL0ZcKaLQqeEvXLAo8Ho+xhNL4Z265L9wjfAbm1kDFLqF2y1cZPuzC3E0kXZuUClk3MzxHbXIfFDPPftT5ZG5x66mMvPh8uIxRAwk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=UZqExhJl; arc=none smtp.client-ip=205.220.180.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=qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="UZqExhJl" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4471QMLZ024267; Tue, 7 May 2024 04:57:49 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; s=qcppdkim1; bh=xznOile in3JcPGlXp/TXF2KzLIpQjnzIRngUPSw4pEY=; b=UZqExhJlTGUXIDV39MF02CV ND3iYwqUja7oHEKiDyAghc4yQ4fOw4onVUT99NtCs4AHefHUhuYLzDTsGSKDTX1Z fdajCtAnIE2Lj2L6ojWJTgP4VZBCLUPQozs3AyRQMRdfn8xYSoEL/rkblvl/ZpbE MVJyb9WCnH52bRo2X4MkLoS+Syw+eNDsLdAmpF3K6+iWLR4zkk13RAoBgiZJw2Oz aKmqzRiR8oWH3oXwhc/3Sw5vFgnaWEeoyl5XuLQ0WDZDxeCvrROTsS4H3V5iDCkQ gNW5ciucFbXyJO4RH6wXGqJeEXHMb+lQGot3ZsCZslENVjYVdPpjTKB/RpjJZIg= = Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xy1vw9a4x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:48 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 4474vItC003579; Tue, 7 May 2024 04:57:45 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 3xwe3kn52u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:45 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4474vj5T004235; Tue, 7 May 2024 04:57:45 GMT Received: from hu-devc-blr-u22-a.qualcomm.com (hu-hprem-blr.qualcomm.com [10.190.108.75]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 4474vjOQ004223 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:45 +0000 Received: by hu-devc-blr-u22-a.qualcomm.com (Postfix, from userid 4146166) id 712DA4114D; Tue, 7 May 2024 10:27:44 +0530 (+0530) From: Harshitha Prem To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Karthikeyan Periyasamy , Harshitha Prem Subject: [PATCH v4 7/8] wifi: ath12k: refactor core start based on hardware group Date: Tue, 7 May 2024 10:27:01 +0530 Message-Id: <20240507045702.2858954-8-quic_hprem@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240507045702.2858954-1-quic_hprem@quicinc.com> References: <20240507045702.2858954-1-quic_hprem@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: tDTExdLJtgymxft8OYVLAJK6ool8eg1n X-Proofpoint-GUID: tDTExdLJtgymxft8OYVLAJK6ool8eg1n X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-07_02,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 malwarescore=0 adultscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=934 impostorscore=0 mlxscore=0 spamscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2405070033 From: Karthikeyan Periyasamy Currently, mac allocate/register and core_pdev_create are initiated immediately when QMI firmware ready event is received for a particular device. With hardware device group abstraction, QMI firmware ready event can be received simultaneously for different devices in the group and so, it should not be registered immediately rather it has to be deferred until all devices in the group has received QMI firmware ready. To handle this, refactor the code of core start to move the following apis inside a wrapper ath12k_core_hw_group_start() * ath12k_mac_allocate() * ath12k_core_pdev_create() * ath12k_core_rfkill_config() * ath12k_mac_register() * ath12k_hif_irq_enable() similarly, move the corresponding destroy/unregister/disable apis inside wrapper ath12k_core_hw_group_stop() Add the device flags to indicate pdev created and IRQ enabled which would be helpful for device clean up during failure cases. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1 Signed-off-by: Karthikeyan Periyasamy Co-developed-by: Harshitha Prem Signed-off-by: Harshitha Prem Acked-by: Jeff Johnson --- drivers/net/wireless/ath/ath12k/core.c | 216 +++++++++++++++++++------ drivers/net/wireless/ath/ath12k/core.h | 32 ++++ 2 files changed, 197 insertions(+), 51 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c index c1cda7d37c1a..1165baf31211 100644 --- a/drivers/net/wireless/ath/ath12k/core.c +++ b/drivers/net/wireless/ath/ath12k/core.c @@ -566,6 +566,9 @@ u32 ath12k_core_get_max_num_tids(struct ath12k_base *ab) static void ath12k_core_stop(struct ath12k_base *ab) { + clear_bit(ATH12K_FLAG_CORE_STARTED, &ab->dev_flags); + ath12k_dec_num_core_started(ab); + if (!test_bit(ATH12K_FLAG_CRASH_FLUSH, &ab->dev_flags)) ath12k_qmi_firmware_stop(ab); @@ -692,11 +695,15 @@ static int ath12k_core_pdev_create(struct ath12k_base *ab) return ret; } + set_bit(ATH12K_FLAG_PDEV_CREATED, &ab->dev_flags); + return 0; } static void ath12k_core_pdev_destroy(struct ath12k_base *ab) { + clear_bit(ATH12K_FLAG_PDEV_CREATED, &ab->dev_flags); + ath12k_dp_pdev_free(ab); } @@ -705,6 +712,8 @@ static int ath12k_core_start(struct ath12k_base *ab, { int ret; + lockdep_assert_held(&ab->core_lock); + ret = ath12k_wmi_attach(ab); if (ret) { ath12k_err(ab, "failed to attach wmi: %d\n", ret); @@ -798,6 +807,11 @@ static int ath12k_core_start(struct ath12k_base *ab, /* ACPI is optional so continue in case of an error */ ath12k_dbg(ab, ATH12K_DBG_BOOT, "acpi failed: %d\n", ret); + /* Indicate the core start in the appropriate group */ + ath12k_inc_num_core_started(ab); + + set_bit(ATH12K_FLAG_CORE_STARTED, &ab->dev_flags); + return 0; err_reo_cleanup: @@ -809,6 +823,109 @@ static int ath12k_core_start(struct ath12k_base *ab, return ret; } +static void ath12k_core_device_cleanup(struct ath12k_base *ab) +{ + mutex_lock(&ab->core_lock); + + if (test_and_clear_bit(ATH12K_FLAG_CORE_HIF_IRQ_ENABLED, &ab->dev_flags)) + ath12k_hif_irq_disable(ab); + + if (test_bit(ATH12K_FLAG_PDEV_CREATED, &ab->dev_flags)) + ath12k_core_pdev_destroy(ab); + + if (test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags)) { + ath12k_mac_unregister(ab); + ath12k_mac_destroy(ab); + } + + mutex_unlock(&ab->core_lock); +} + +static void ath12k_core_hw_group_stop(struct ath12k_hw_group *ag) +{ + struct ath12k_base *ab; + int i; + + lockdep_assert_held(&ag->mutex_lock); + + for (i = ag->num_devices - 1; i >= 0; i--) { + ab = ag->ab[i]; + if (!ab) + continue; + ath12k_core_device_cleanup(ab); + } +} + +static int ath12k_core_hw_group_start(struct ath12k_hw_group *ag) +{ + struct ath12k_base *ab; + int ret, i; + bool is_registered; + + lockdep_assert_held(&ag->mutex_lock); + + for (i = 0; i < ag->num_devices; i++) { + ab = ag->ab[i]; + if (!ab) + continue; + + mutex_lock(&ab->core_lock); + + /* Check if already registered or not, since same flow + * execute for HW restart case. + */ + is_registered = test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags); + + if (is_registered) + goto core_pdev_create; + + ret = ath12k_mac_allocate(ab); + if (ret) { + ath12k_err(ab, "failed to create new hw device with mac80211 :%d\n", + ret); + mutex_unlock(&ab->core_lock); + return ret; + } + + ret = ath12k_mac_register(ab); + if (ret) { + ath12k_err(ab, "failed to register radio with mac80211: %d\n", + ret); + mutex_unlock(&ab->core_lock); + goto err; + } + +core_pdev_create: + ret = ath12k_core_pdev_create(ab); + if (ret) { + ath12k_err(ab, "failed to create pdev core %d\n", ret); + mutex_unlock(&ab->core_lock); + goto err; + } + + ret = ath12k_core_rfkill_config(ab); + if (ret && ret != -EOPNOTSUPP) { + mutex_unlock(&ab->core_lock); + goto err; + } + + ath12k_hif_irq_enable(ab); + + set_bit(ATH12K_FLAG_CORE_HIF_IRQ_ENABLED, &ab->dev_flags); + + mutex_unlock(&ab->core_lock); + } + + set_bit(ATH12K_GROUP_FLAG_REGISTERED, &ag->flags); + + return 0; + +err: + ath12k_core_hw_group_stop(ag); + + return ret; +} + static int ath12k_core_start_firmware(struct ath12k_base *ab, enum ath12k_firmware_mode mode) { @@ -826,9 +943,18 @@ static int ath12k_core_start_firmware(struct ath12k_base *ab, return ret; } +static inline +bool ath12k_core_hw_group_start_ready(struct ath12k_hw_group *ag) +{ + lockdep_assert_held(&ag->mutex_lock); + + return (ag->num_started == ag->num_devices); +} + int ath12k_core_qmi_firmware_ready(struct ath12k_base *ab) { - int ret; + struct ath12k_hw_group *ag; + int ret, i; ret = ath12k_core_start_firmware(ab, ATH12K_FIRMWARE_MODE_NORMAL); if (ret) { @@ -848,59 +974,50 @@ int ath12k_core_qmi_firmware_ready(struct ath12k_base *ab) goto err_firmware_stop; } + ag = ath12k_ab_to_ag(ab); + + mutex_lock(&ag->mutex_lock); mutex_lock(&ab->core_lock); ret = ath12k_core_start(ab, ATH12K_FIRMWARE_MODE_NORMAL); if (ret) { ath12k_err(ab, "failed to start core: %d\n", ret); goto err_dp_free; } + mutex_unlock(&ab->core_lock); - ret = ath12k_mac_allocate(ab); - if (ret) { - ath12k_err(ab, "failed to create new hw device with mac80211 :%d\n", - ret); - goto err_core_stop; - } - - ret = ath12k_mac_register(ab); - if (ret) { - ath12k_err(ab, "failed register the radio with mac80211: %d\n", ret); - goto err_mac_destroy; + if (ath12k_core_hw_group_start_ready(ag)) { + ret = ath12k_core_hw_group_start(ag); + if (ret) { + ath12k_warn(ab, "unable to start hw group\n"); + goto err_core_stop; + } + ath12k_dbg(ab, ATH12K_DBG_BOOT, "group %d started\n", ag->id); } + mutex_unlock(&ag->mutex_lock); - ret = ath12k_core_pdev_create(ab); - if (ret) { - ath12k_err(ab, "failed to create pdev core: %d\n", ret); - goto err_mac_unregister; - } + return 0; - ath12k_hif_irq_enable(ab); +err_core_stop: + for (i = ag->num_devices - 1; i >= 0; i--) { + ab = ag->ab[i]; + if (!ab) + continue; - ret = ath12k_core_rfkill_config(ab); - if (ret && ret != -EOPNOTSUPP) { - ath12k_err(ab, "failed to config rfkill: %d\n", ret); - goto err_core_pdev_destroy; + mutex_lock(&ab->core_lock); + if (test_bit(ATH12K_FLAG_CORE_STARTED, &ab->dev_flags)) + ath12k_core_stop(ab); + mutex_unlock(&ab->core_lock); } + goto exit; - mutex_unlock(&ab->core_lock); - - return 0; - -err_core_pdev_destroy: - ath12k_hif_irq_disable(ab); - ath12k_core_pdev_destroy(ab); -err_mac_unregister: - ath12k_mac_unregister(ab); -err_mac_destroy: - ath12k_mac_destroy(ab); -err_core_stop: - ath12k_core_stop(ab); err_dp_free: ath12k_dp_free(ab); mutex_unlock(&ab->core_lock); err_firmware_stop: ath12k_qmi_firmware_stop(ab); +exit: + mutex_unlock(&ag->mutex_lock); return ret; } @@ -1152,6 +1269,10 @@ static void ath12k_core_reset(struct work_struct *work) ath12k_dbg(ab, ATH12K_DBG_BOOT, "reset starting\n"); + mutex_lock(&ab->ag->mutex_lock); + ath12k_dec_num_core_started(ab); + mutex_unlock(&ab->ag->mutex_lock); + ab->is_reset = true; atomic_set(&ab->recovery_start_count, 0); reinit_completion(&ab->recovery_start); @@ -1261,7 +1382,7 @@ static struct ath12k_hw_group *ath12k_core_assign_hw_group(struct ath12k_base *a void ath12k_core_unassign_hw_group(struct ath12k_base *ab) { - struct ath12k_hw_group *ag = ab->ag; + struct ath12k_hw_group *ag = ath12k_ab_to_ag(ab); u8 device_id = ab->device_id; int num_probed; @@ -1295,19 +1416,6 @@ void ath12k_core_unassign_hw_group(struct ath12k_base *ab) ath12k_core_hw_group_free(ag); } -static void ath12k_core_device_cleanup(struct ath12k_base *ab) -{ - mutex_lock(&ab->core_lock); - - ath12k_hif_irq_disable(ab); - ath12k_core_pdev_destroy(ab); - ath12k_mac_unregister(ab); - ath12k_mac_destroy(ab); - ath12k_core_stop(ab); - - mutex_unlock(&ab->core_lock); -} - static void ath12k_core_hw_group_destroy(struct ath12k_hw_group *ag) { struct ath12k_base *ab; @@ -1335,14 +1443,20 @@ static void ath12k_core_hw_group_cleanup(struct ath12k_hw_group *ag) return; mutex_lock(&ag->mutex_lock); + if (test_and_clear_bit(ATH12K_GROUP_FLAG_REGISTERED, &ag->flags)) + ath12k_core_hw_group_stop(ag); + for (i = 0; i < ag->num_devices; i++) { ab = ag->ab[i]; if (!ab) continue; - if (test_bit(ATH12K_FLAG_QMI_FW_READY_COMPLETE, &ab->dev_flags)) - ath12k_core_device_cleanup(ab); + mutex_lock(&ab->core_lock); + if (test_bit(ATH12K_FLAG_CORE_STARTED, &ab->dev_flags)) + ath12k_core_stop(ab); + mutex_unlock(&ab->core_lock); } + mutex_unlock(&ag->mutex_lock); } diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h index c6238335c7c0..2c3c585797cf 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -202,6 +202,10 @@ enum ath12k_scan_state { ATH12K_SCAN_ABORTING, }; +enum ath12k_hw_group_flags { + ATH12K_GROUP_FLAG_REGISTERED, +}; + enum ath12k_dev_flags { ATH12K_CAC_RUNNING, ATH12K_FLAG_CRASH_FLUSH, @@ -216,6 +220,9 @@ enum ath12k_dev_flags { ATH12K_FLAG_EXT_IRQ_ENABLED, ATH12K_FLAG_QMI_FW_READY_COMPLETE, ATH12K_FLAG_HW_GROUP_ATTACHED, + ATH12K_FLAG_PDEV_CREATED, + ATH12K_FLAG_CORE_STARTED, + ATH12K_FLAG_CORE_HIF_IRQ_ENABLED, }; enum ath12k_monitor_flags { @@ -743,6 +750,8 @@ struct ath12k_hw_group { u8 id; u8 num_devices; u8 num_probed; + u8 num_started; + unsigned long flags; struct ath12k_base *ab[ATH12K_MAX_SOCS]; /* To synchronize group create, assign, start, stop */ struct mutex mutex_lock; @@ -1094,4 +1103,27 @@ static inline int ath12k_get_num_hw(struct ath12k_base *ab) { return ab->num_hw; } + +static inline +struct ath12k_hw_group *ath12k_ab_to_ag(struct ath12k_base *ab) +{ + return ab->ag; +} + +static inline +void ath12k_inc_num_core_started(struct ath12k_base *ab) +{ + lockdep_assert_held(&ab->ag->mutex_lock); + + ab->ag->num_started++; +} + +static inline +void ath12k_dec_num_core_started(struct ath12k_base *ab) +{ + lockdep_assert_held(&ab->ag->mutex_lock); + + ab->ag->num_started--; +} + #endif /* _CORE_H_ */ From patchwork Tue May 7 04:57:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshitha Prem X-Patchwork-Id: 13656244 X-Patchwork-Delegate: kvalo@adurom.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 3DB766A8D8 for ; Tue, 7 May 2024 04:58:01 +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=1715057884; cv=none; b=CJgV/s4a5WmoyblFJBir6qqI/oYcb6jlTtnS7anrjHL2lRyMUgCSfKyrPeEjtDqAwWEPAMoPsiy00Agz3CpJRVs3MqwHpnCmvdS4LVY2JQQffKMlu54XsAOnhhyjNElwhhzNkzk7wAs8+bB4YEUqUby/QepCCi8SkYuiHKXmrYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057884; c=relaxed/simple; bh=5CYTNY4DCzsAj4LWHHhAXOAcFXrtRfQz7cYgsVx/PvU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sf/pKrDpxZlxA5tlNIdZnoUkQpLtDy5HtW3lBQYMX6yL29dWpqzgY5pcccNbN+CXze8aafF5EKT8OvcGaLgndumOfuNqCGJrQ/7H1XduqqKYHuHHzeyIfiPt7D+Enk4jDSiBjLNcS9VW/QDOlJgBpk665TBaHtst+wONHHZS49E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=LxLdt7Yk; 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=qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="LxLdt7Yk" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4473KTwb003856; Tue, 7 May 2024 04:57:54 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; s=qcppdkim1; bh=K6Vxp5U i3pvzEDEA6ulu82JW3Ka3FJdUn8bBsg035+M=; b=LxLdt7Yk/gFPdkjgz6t9bBX TbnuMJ/SJZjm7iu2pJ+2h5PEmwXuw09m5Vkt7RrpDx8ZndQh40wEJdNCuKBd2LEg G+aGqTMS1jSOhXkUNLnq62N8J/C1zCGwiy4zCJMzX7veten+k525No8Vi93eeDjJ H+LTEHmgi/bgR5Vc8n+hs9xUFMCaq8j1ftzpCjL9D9cNoX40nYrViLwxRb3R9XcP 2Csu/r0uzeT9qYWeTey62g4yxyCG1mutj5Lez6TvZ4b5nOUbbsd9pyQHkr0loyke L1VAzE3RLJ3FKhTueqZx0mtDDazd1XVM6Dd/SZ2AmFZtQ0jfakwZ9H2X69l5Gzg= = Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xxvv722hh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:53 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 4474vItD003579; Tue, 7 May 2024 04:57:50 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 3xwe3kn53f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:50 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4474vo4Z004282; Tue, 7 May 2024 04:57:50 GMT Received: from hu-devc-blr-u22-a.qualcomm.com (hu-hprem-blr.qualcomm.com [10.190.108.75]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 4474vovS004281 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:50 +0000 Received: by hu-devc-blr-u22-a.qualcomm.com (Postfix, from userid 4146166) id E96314114D; Tue, 7 May 2024 10:27:48 +0530 (+0530) From: Harshitha Prem To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Karthikeyan Periyasamy , Harshitha Prem Subject: [PATCH v4 8/8] wifi: ath12k: move ath12k_hw from per soc to group Date: Tue, 7 May 2024 10:27:02 +0530 Message-Id: <20240507045702.2858954-9-quic_hprem@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240507045702.2858954-1-quic_hprem@quicinc.com> References: <20240507045702.2858954-1-quic_hprem@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: sxghYzz88sgpmuP7AGE4HJ0IArEnmgz5 X-Proofpoint-ORIG-GUID: sxghYzz88sgpmuP7AGE4HJ0IArEnmgz5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-07_02,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 clxscore=1015 suspectscore=0 spamscore=0 mlxscore=0 priorityscore=1501 mlxlogscore=999 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2405070033 From: Karthikeyan Periyasamy Currently, hardware abstractions (ah) of different radio bands are tightly coupled to a single device (ab). But, with hardware device group abstraction (ag), multiple radios across different devices in a group can possibly form different combinations of hardware abstractions (ah) within the group. Hence, the mapping between ah to ab can be removed and instead it can be mapped with ag. Please find below illustration of how mapping between ath12k_hw (ah), ath12k_base (ab) and ath12k_hw_group (ag) is changed. current mapping of hardware abstraction (ah) with device (ab) +------------------------------------------------+ | +-------------------------------------+ | | | +---------------+ +---------------+ | | | | |ath12k_hw (ah) | |ath12k_hw (ah) | | | | | +---------------+ +---------------+ | | | | | | | | +-----------+ | +-----------+ | | | | | ar (2GHz) | | | ar (5GHz) | | | | | +-----------+ | +-----------+ | | | | Dual band device-1 (ab) | | | +-------------------------------------+ | | ath12k_hw_group (ag) based on group id | +------------------------------------------------+ After, with hardware device group abstraction (moving ah array out of ab to ag) +----------------------------------------------+ | +---------------+ +---------------+ | | |ath12k_hw (ah) | |ath12k_hw (ah) | | | +---------------+ +---------------+ | | +-------------------------------------+ | | | +-----------+ +-----------+ | | | | | ar (2GHz) | | ar (5GHz) | | | | | +-----------+ +-----------+ | | | | Dual band device-1 (ab) | | | +-------------------------------------+ | | ath12k_hw_group (ag) based on group id | +----------------------------------------------+ This decoupling of ath12k_hw (ah) from ath12k_base (ab) and mapping it to ath12k_hw_group (ag) will help in forming different combinations of multi-link devices. Say for example, device 1 has two radios (2 GHz and 5 GHz band) and device 2 has one radio (6 GHz). In existing code - device 1 will have two hardware abstractions hw1 (2 GHz) and hw2 (5 GHz) will be registered separately to mac80211 as phy0 and phy1 respectively. Similarly, device 2 will register its hw (6 GHz) as phy2 to mac80211. In future, with multi-link abstraction combination 1 - Different group id for device1 and device 2 Device 1 will create a single hardware abstraction hw1 (2 GHz and 5 GHz) and will be registered to mac80211 as phy0. similarly, device 2 will register its hardware (6 GHz) to mac80211 as phy1. combination 2 - Same group id for device1 and device 2 Both device details are combined together as a group, say group1, with single hardware abstraction of radios 2 GHz, 5 GHz and 6 GHz band details and will be registered to mac80211 as phy0. Hence, Add changes to decouple ath12k_hw (ah) from ath12k_base (ab) and map it to ath12k_hw_group (ag). Refactor the following APIs to help simplify the registration based on ath12k_hw_group (ag) rather than ath12k_base (ab) * ath12k_mac_allocate() * ath12k_mac_destroy() * ath12k_mac_register() * ath12k_mac_unregister() Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1 Signed-off-by: Karthikeyan Periyasamy Signed-off-by: Harshitha Prem Acked-by: Jeff Johnson --- drivers/net/wireless/ath/ath12k/core.c | 52 +++++++---------- drivers/net/wireless/ath/ath12k/core.h | 25 ++++---- drivers/net/wireless/ath/ath12k/mac.c | 81 ++++++++++++++++++-------- drivers/net/wireless/ath/ath12k/mac.h | 9 +-- 4 files changed, 98 insertions(+), 69 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c index 1165baf31211..88b14343d91f 100644 --- a/drivers/net/wireless/ath/ath12k/core.c +++ b/drivers/net/wireless/ath/ath12k/core.c @@ -833,11 +833,6 @@ static void ath12k_core_device_cleanup(struct ath12k_base *ab) if (test_bit(ATH12K_FLAG_PDEV_CREATED, &ab->dev_flags)) ath12k_core_pdev_destroy(ab); - if (test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags)) { - ath12k_mac_unregister(ab); - ath12k_mac_destroy(ab); - } - mutex_unlock(&ab->core_lock); } @@ -854,6 +849,8 @@ static void ath12k_core_hw_group_stop(struct ath12k_hw_group *ag) continue; ath12k_core_device_cleanup(ab); } + ath12k_mac_unregister(ag); + ath12k_mac_destroy(ag); } static int ath12k_core_hw_group_start(struct ath12k_hw_group *ag) @@ -864,6 +861,23 @@ static int ath12k_core_hw_group_start(struct ath12k_hw_group *ag) lockdep_assert_held(&ag->mutex_lock); + /* Check if already registered or not, since same flow + * execute for HW restart case. + */ + is_registered = test_bit(ATH12K_GROUP_FLAG_REGISTERED, &ag->flags); + + if (is_registered) + goto core_pdev_create; + + ret = ath12k_mac_allocate(ag); + if (WARN_ON(ret)) + return ret; + + ret = ath12k_mac_register(ag); + if (WARN_ON(ret)) + goto err_mac_alloc; + +core_pdev_create: for (i = 0; i < ag->num_devices; i++) { ab = ag->ab[i]; if (!ab) @@ -871,31 +885,6 @@ static int ath12k_core_hw_group_start(struct ath12k_hw_group *ag) mutex_lock(&ab->core_lock); - /* Check if already registered or not, since same flow - * execute for HW restart case. - */ - is_registered = test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags); - - if (is_registered) - goto core_pdev_create; - - ret = ath12k_mac_allocate(ab); - if (ret) { - ath12k_err(ab, "failed to create new hw device with mac80211 :%d\n", - ret); - mutex_unlock(&ab->core_lock); - return ret; - } - - ret = ath12k_mac_register(ab); - if (ret) { - ath12k_err(ab, "failed to register radio with mac80211: %d\n", - ret); - mutex_unlock(&ab->core_lock); - goto err; - } - -core_pdev_create: ret = ath12k_core_pdev_create(ab); if (ret) { ath12k_err(ab, "failed to create pdev core %d\n", ret); @@ -922,7 +911,10 @@ static int ath12k_core_hw_group_start(struct ath12k_hw_group *ag) err: ath12k_core_hw_group_stop(ag); + return ret; +err_mac_alloc: + ath12k_mac_destroy(ag); return ret; } diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h index 2c3c585797cf..58cd5428502b 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -60,6 +60,7 @@ #define ATH12K_RECOVER_START_TIMEOUT_HZ (20 * HZ) #define ATH12K_MAX_SOCS 3 +#define ATH12K_GROUP_MAX_RADIO (ATH12K_MAX_SOCS * MAX_RADIOS) #define ATH12K_INVALID_GROUP_ID 0xFF #define ATH12K_INVALID_DEVICE_ID 0xFF @@ -755,6 +756,15 @@ struct ath12k_hw_group { struct ath12k_base *ab[ATH12K_MAX_SOCS]; /* To synchronize group create, assign, start, stop */ struct mutex mutex_lock; + + /* Holds information of wiphy (hw) registration. + * + * In Multi/Single Link Operation case, all pdevs are registered as + * a single wiphy. In other (legacy/Non-MLO) cases, each pdev is + * registered as separate wiphys. + */ + struct ath12k_hw *ah[MAX_RADIOS]; + u8 num_hw; }; /** @@ -826,15 +836,6 @@ struct ath12k_base { struct ath12k_pdev __rcu *pdevs_active[MAX_RADIOS]; - /* Holds information of wiphy (hw) registration. - * - * In Multi/Single Link Operation case, all pdevs are registered as - * a single wiphy. In other (legacy/Non-MLO) cases, each pdev is - * registered as separate wiphys. - */ - struct ath12k_hw *ah[MAX_RADIOS]; - u8 num_hw; - struct ath12k_wmi_hal_reg_capabilities_ext_arg hal_reg_cap[MAX_RADIOS]; unsigned long long free_vdev_map; unsigned long long free_vdev_stats_id_map; @@ -1090,18 +1091,18 @@ static inline struct ieee80211_hw *ath12k_ar_to_hw(struct ath12k *ar) static inline struct ath12k_hw *ath12k_ab_to_ah(struct ath12k_base *ab, int idx) { - return ab->ah[idx]; + return ab->ag->ah[idx]; } static inline void ath12k_ab_set_ah(struct ath12k_base *ab, int idx, struct ath12k_hw *ah) { - ab->ah[idx] = ah; + ab->ag->ah[idx] = ah; } static inline int ath12k_get_num_hw(struct ath12k_base *ab) { - return ab->num_hw; + return ab->ag->num_hw; } static inline diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index ada4569fbff4..256095042948 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -8872,19 +8872,13 @@ static void ath12k_mac_setup(struct ath12k *ar) clear_bit(ATH12K_FLAG_MONITOR_ENABLED, &ar->monitor_flags); } -int ath12k_mac_register(struct ath12k_base *ab) +int ath12k_mac_register(struct ath12k_hw_group *ag) { + struct ath12k_base *ab = ag->ab[0]; struct ath12k_hw *ah; int i; int ret; - if (test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags)) - return 0; - - /* Initialize channel counters frequency value in hertz */ - ab->cc_freq_hz = 320000; - ab->free_vdev_map = (1LL << (ab->num_radios * TARGET_NUM_VDEVS)) - 1; - for (i = 0; i < ath12k_get_num_hw(ab); i++) { ah = ath12k_ab_to_ah(ab, i); @@ -8908,8 +8902,9 @@ int ath12k_mac_register(struct ath12k_base *ab) return ret; } -void ath12k_mac_unregister(struct ath12k_base *ab) +void ath12k_mac_unregister(struct ath12k_hw_group *ag) { + struct ath12k_base *ab = ag->ab[0]; struct ath12k_hw *ah; int i; @@ -8970,18 +8965,24 @@ static struct ath12k_hw *ath12k_mac_hw_allocate(struct ath12k_base *ab, return ah; } -void ath12k_mac_destroy(struct ath12k_base *ab) +void ath12k_mac_destroy(struct ath12k_hw_group *ag) { struct ath12k_pdev *pdev; - struct ath12k_hw *ah; + struct ath12k_base *ab = ag->ab[0]; int i; + struct ath12k_hw *ah; - for (i = 0; i < ab->num_radios; i++) { - pdev = &ab->pdevs[i]; - if (!pdev->ar) + for (i = 0; i < ag->num_devices; i++) { + ab = ag->ab[i]; + if (!ab) continue; - pdev->ar = NULL; + for (i = 0; i < ab->num_radios; i++) { + pdev = &ab->pdevs[i]; + if (!pdev->ar) + continue; + pdev->ar = NULL; + } } for (i = 0; i < ath12k_get_num_hw(ab); i++) { @@ -8994,20 +8995,46 @@ void ath12k_mac_destroy(struct ath12k_base *ab) } } -int ath12k_mac_allocate(struct ath12k_base *ab) +static void ath12k_set_device_defaults(struct ath12k_base *ab) +{ + /* Initialize channel counters frequency value in hertz */ + ab->cc_freq_hz = 320000; + ab->free_vdev_map = (1LL << (ab->num_radios * TARGET_NUM_VDEVS)) - 1; + ath12k_dp_pdev_pre_alloc(ab); +} + +int ath12k_mac_allocate(struct ath12k_hw_group *ag) { struct ath12k_hw *ah; + struct ath12k_base *ab; struct ath12k_pdev_map pdev_map[MAX_RADIOS]; int ret, i, j; u8 radio_per_hw; + int mac_id, device_id; + int total_radio, num_hw; - if (test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags)) - return 0; + total_radio = 0; + for (i = 0; i < ag->num_devices; i++) + total_radio += ag->ab[i]->num_radios; - ab->num_hw = ab->num_radios; + /* All pdev get combined and register as single wiphy based on + * hardware group which participate in multi-link operation else + * each pdev get register separately. + * + * Currently, registering as single pdevs. + */ radio_per_hw = 1; + num_hw = total_radio / radio_per_hw; + + if (WARN_ON(num_hw >= ATH12K_GROUP_MAX_RADIO)) + return -ENOSPC; + + ag->num_hw = 0; + device_id = 0; + mac_id = 0; + for (i = 0; i < num_hw; i++) { + ab = ag->ab[device_id]; - for (i = 0; i < ath12k_get_num_hw(ab); i++) { for (j = 0; j < radio_per_hw; j++) { pdev_map[j].ab = ab; pdev_map[j].pdev_idx = (i * radio_per_hw) + j; @@ -9021,11 +9048,19 @@ int ath12k_mac_allocate(struct ath12k_base *ab) goto err; } - ath12k_ab_set_ah(ab, i, ah); + mac_id++; + /* If mac_id falls beyond the current device MACs then + * move to next device + */ + if (mac_id >= ab->num_radios) { + device_id++; + mac_id = 0; + ath12k_set_device_defaults(ab); + } + ag->ah[i] = ah; + ag->num_hw++; } - ath12k_dp_pdev_pre_alloc(ab); - return 0; err: diff --git a/drivers/net/wireless/ath/ath12k/mac.h b/drivers/net/wireless/ath/ath12k/mac.h index 69fd282b9dd3..f0ea0b5f50e4 100644 --- a/drivers/net/wireless/ath/ath12k/mac.h +++ b/drivers/net/wireless/ath/ath12k/mac.h @@ -13,6 +13,7 @@ struct ath12k; struct ath12k_base; struct ath12k_hw; +struct ath12k_hw_group; struct ath12k_pdev_map; struct ath12k_generic_iter { @@ -50,10 +51,10 @@ enum ath12k_supported_bw { extern const struct htt_rx_ring_tlv_filter ath12k_mac_mon_status_filter_default; -void ath12k_mac_destroy(struct ath12k_base *ab); -void ath12k_mac_unregister(struct ath12k_base *ab); -int ath12k_mac_register(struct ath12k_base *ab); -int ath12k_mac_allocate(struct ath12k_base *ab); +void ath12k_mac_destroy(struct ath12k_hw_group *ag); +void ath12k_mac_unregister(struct ath12k_hw_group *ag); +int ath12k_mac_register(struct ath12k_hw_group *ag); +int ath12k_mac_allocate(struct ath12k_hw_group *ag); int ath12k_mac_hw_ratecode_to_legacy_rate(u8 hw_rc, u8 preamble, u8 *rateidx, u16 *rate); u8 ath12k_mac_bitrate_to_idx(const struct ieee80211_supported_band *sband,