From patchwork Wed May 22 09:54:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshitha Prem X-Patchwork-Id: 798919 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 ED30A81723 for ; Wed, 22 May 2024 09:55:14 +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=1716371716; cv=none; b=txqicx+WzoNXcm9ikEaUN5ORN1VDCRqppFSFw5eeN6SyMf3YjIgTkgyf6FgRt1ZdlcroPEwtTQo4A2LvsUNbEpLNdtO74TUpnR0mXx5iZJQsy/T5iHdtMp2z5BWnygnHhG7X6NSWduuVuT/zcgItQ8WQuovjLYX09Ig289kX2ks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716371716; c=relaxed/simple; bh=3FB+QHAAAfpdyskcQ8tKj+CyJfEqRu5rF5PrZ8Oro9M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=InmcpbrOTqxSxzuUSBZZvLKDsGCvTSP9aI+8txNZ2G1looh0NqjRQ4Gbr1VCkbPMCD1wbNk3IJOuGLobcB+RogldyeSj5krM1Y56Xeq32Sadm9w2ESNUgVYuhjS4RZVG6Xg5JdUdYyP5N/yUqhR5+PwrwEHLq1v1lRX/nNZ+798= 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=BzJ1qZn2; 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="BzJ1qZn2" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44M8m7ed001698; Wed, 22 May 2024 09:55:12 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=v8T3sAj hzPrqu0X2wF9xd6B4jRKAemg+UKlmHd79xqc=; b=BzJ1qZn2JBkNX+rkV540zVc 3zchndGCZWycySYTGiITZ1nX3JJywYGcmfOP8vQsRciQzLpzQDdkx1n2YS4SAwpw lKcSWPNruQwW1DmDOkLH/e0et7TTzYjCTRH1/FVyWcUiFWVHGjaiZgWiidb3lvr5 RMxaclO3s/32JBSJlQEkH4+WfnqUKAmZ+ixBTBi2TopKeM/8nip/ZbGG+QVny/WD gRd/zl0upCsvvqgt+5zXLB8GBeRbPGRQ8VP7vyf4TFvXkVcZaFUChveIMqXdvyGD /CRNfHxg3GpwOOJu9bsdfFRTHDU4hkDugSfU2pA0Ge+N9pyuQuQ6bIT2IlxmZJQ= = Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3y6pqc8cq8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:12 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 44M9t8Pn024478; Wed, 22 May 2024 09:55:08 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3y6ndkfput-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:08 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 44M9t8hv024472; Wed, 22 May 2024 09:55:08 GMT Received: from hu-devc-blr-u22-a.qualcomm.com (hu-hprem-blr.qualcomm.com [10.190.108.75]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 44M9t8vL024471 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:08 +0000 Received: by hu-devc-blr-u22-a.qualcomm.com (Postfix, from userid 4146166) id 9C958410F2; Wed, 22 May 2024 15:25:07 +0530 (+0530) From: Harshitha Prem To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Karthikeyan Periyasamy , Harshitha Prem , Jeff Johnson Subject: [PATCH v5 1/8] wifi: ath12k: Refactor core start api Date: Wed, 22 May 2024 15:24:32 +0530 Message-Id: <20240522095439.2596989-2-quic_hprem@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522095439.2596989-1-quic_hprem@quicinc.com> References: <20240522095439.2596989-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: hgNy4HiJFGOP43o51qOGBt_E7uZOBHuf X-Proofpoint-GUID: hgNy4HiJFGOP43o51qOGBt_E7uZOBHuf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-22_05,2024-05-21_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 mlxlogscore=999 impostorscore=0 adultscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 clxscore=1015 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405010000 definitions=main-2405220070 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 e7f628e935e4..342d0ab12105 100644 --- a/drivers/net/wireless/ath/ath12k/core.c +++ b/drivers/net/wireless/ath/ath12k/core.c @@ -565,9 +565,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 */ } @@ -669,7 +670,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); @@ -679,30 +680,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); } @@ -760,19 +748,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); @@ -815,8 +796,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: @@ -870,11 +849,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); @@ -888,10 +881,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); @@ -1205,15 +1202,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 ac75e8e3916b..8f37f6efb8a2 100644 --- a/drivers/net/wireless/ath/ath12k/pci.c +++ b/drivers/net/wireless/ath/ath12k/pci.c @@ -1529,6 +1529,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 Wed May 22 09:54:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshitha Prem X-Patchwork-Id: 798389 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 09DD881723 for ; Wed, 22 May 2024 09:55:20 +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=1716371722; cv=none; b=eyEecl7ASX+2KGgGzkhP4nGAWmdpDSOAqEWwDLdeuzmvYD9yJHPfBTJE4/t+/0MAC1LmZ7VNMZsXa3hUqu3ZD7cueHjGYaIGSRW1gm0ODc0C2qpk2wjRkNQtooSXocU5PegMdLKB9NbspCdyVZRGSctsLtZccb1i7fRv9LYNfOs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716371722; c=relaxed/simple; bh=RASh+UJvq6ygxh2XYu62ZlDC7e4F0InRdmIeEDYJOpk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dwBz+XB1sHW73T98TGIsqDCm0FWOuk6PjCSljHA/VDt5cZVTReN2zvVW0twrbK1rmYy7xgzvfnOkt3Fb9SULtMaa8FLWfgi/wsAywzx4Ygxy0bTd9nBCefqFyZhCGkKHKDP36kNO79COsFE7n6cYPbGL294giZPwRi9ikZFZZss= 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=Uh2CIFSJ; 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="Uh2CIFSJ" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44M8NIqw003043; Wed, 22 May 2024 09:55:18 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=Ei03v/C YUBCQYP94hlE/M/Cli/p1dOmmt2/VlXFAs+k=; b=Uh2CIFSJz1Dmza5goceMeRL 9EgbAr6b5rNOx1qGfizA+Xv/iQzNbt308b4NMTt8/aym3oI6/HMV/nUiVQbN3U4R xa1XJprOxzjNuM5VzYDa/fQ/tKcrG/iYxn404KUcfhW7GnkDA6LRQne+gfzF17Qn uYftEH/GVYj/PHmcQx9VmuLvBnlD+IHCEloP7Y8RyeuhqkL5REPCXuKe4YnDMkIk m/6M0WYvbZmwBwB3wajpkpyxruCQ5apJWN/GQ/jcoj0NB777cNqfOI/B9hrsvLw0 X1v9YICTOpVyOay/M+9OWPDAfM4wJe55X6MLv4geM2EhOMzkQS0v7fq2DkM3FMA= = Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3y6psngg4c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:18 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 44M9tEQj024944; Wed, 22 May 2024 09:55:14 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3y6ndkfpv6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:14 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 44M9tEuT024937; Wed, 22 May 2024 09:55:14 GMT Received: from hu-devc-blr-u22-a.qualcomm.com (hu-hprem-blr.qualcomm.com [10.190.108.75]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 44M9tE9A024935 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:14 +0000 Received: by hu-devc-blr-u22-a.qualcomm.com (Postfix, from userid 4146166) id 04944410F2; Wed, 22 May 2024 15:25:13 +0530 (+0530) From: Harshitha Prem To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Karthikeyan Periyasamy , Harshitha Prem , Jeff Johnson Subject: [PATCH v5 2/8] wifi: ath12k: Add helpers to get or set ath12k_hw Date: Wed, 22 May 2024 15:24:33 +0530 Message-Id: <20240522095439.2596989-3-quic_hprem@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522095439.2596989-1-quic_hprem@quicinc.com> References: <20240522095439.2596989-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: efh7iI9VhmDhMCLf0iK8c9dU2qxyv-3K X-Proofpoint-ORIG-GUID: efh7iI9VhmDhMCLf0iK8c9dU2qxyv-3K X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-22_05,2024-05-21_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 phishscore=0 impostorscore=0 adultscore=0 mlxlogscore=745 clxscore=1015 priorityscore=1501 suspectscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405010000 definitions=main-2405220070 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 342d0ab12105..3925bb70d479 100644 --- a/drivers/net/wireless/ath/ath12k/core.c +++ b/drivers/net/wireless/ath/ath12k/core.c @@ -947,7 +947,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; @@ -999,7 +999,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; @@ -1038,7 +1038,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 7d20b09c52e6..3f5c9fa9d04c 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -1051,4 +1051,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 784964ae03ec..f8e8320b8598 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -9158,7 +9158,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) @@ -9169,7 +9169,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; @@ -9185,7 +9185,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; @@ -9243,6 +9243,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++) { @@ -9254,11 +9255,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); } } @@ -9289,7 +9291,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); @@ -9298,11 +9300,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 Wed May 22 09:54:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshitha Prem X-Patchwork-Id: 798918 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 B997A81729 for ; Wed, 22 May 2024 09:55:21 +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=1716371723; cv=none; b=O0UGSfqn2JUDLd/z6exqkaxIuWdEyE/aKzPU5GM5mldOGHeWwCMzpCxs04sqGIvlFURLD5iPmn7o8tB8xCXFn4jyuVgkzE6ChSj43n/7zh7y3XyyA75Fr/++eoyT+Xtm14qOPuTDOFq7l0IOdJe8Mvjgs1vPDsP5nUAxtkf58Vw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716371723; c=relaxed/simple; bh=g4xoRO9xj6dOiD3VqciB/zfkT2esrbTTCOXNPr9Zz2o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tPi8y4+B1RF4z3scVPVv1frXqaNTjr+V2YtuxjSR88v3HA6TnUz8H9rD/SUWkC+Yk5DdXWNDZTdh2IJ5dbYpDkIMxp56W/BOr0HDXlQ127ZipN4zHdUoTQCNDp+04uIWmFw30Updslrpq//bb+irESUe/Nx4NrjyhVYXiSUaC5k= 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=Pi53iQXH; 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="Pi53iQXH" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44M8Vini008286; Wed, 22 May 2024 09:55:20 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=q9ZloH1 bI1zct1SU4341ZzcGwjDZqsBFVqUcnb6amg4=; b=Pi53iQXH6Ym0qwPgCcO7vb7 lh/k1y5TR7nQ1yb7xmcvZW+UOPzsnYsr6L+Tprh7AbsDMLl7lR/75aAn4Wce64b3 heJK7OXcJToP6kiv8+d73S4qMI7vwOYKlzJCRdMSErPZV0eYTxA5oIokUXOCD8iu VsD8mFn6hmgDpOkg/olZrjAFrqGEDjIJGlhj1/t+m7hqkUBuHIk+6cJ4tBZDVBin ymjht4MVYslMkImEMVVPXS5NNbak1b42a0qHcKmEWQqvAtzjNRq3+UhCmoq85w+h p9JIbOT6cIIopCC/3QUIKiZjtaUvdv5W7XihEb445lb75cXU4ySnNKYUa2phkcA= = Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3y6pqardkv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:19 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 44M9tFb4024963; Wed, 22 May 2024 09:55:15 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3y6ndkfpvc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:15 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 44M9tFMc024958; Wed, 22 May 2024 09:55:15 GMT Received: from hu-devc-blr-u22-a.qualcomm.com (hu-hprem-blr.qualcomm.com [10.190.108.75]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 44M9tFYw024957 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:15 +0000 Received: by hu-devc-blr-u22-a.qualcomm.com (Postfix, from userid 4146166) id 3737541148; Wed, 22 May 2024 15:25:14 +0530 (+0530) From: Harshitha Prem To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Karthikeyan Periyasamy , Harshitha Prem , Jeff Johnson Subject: [PATCH v5 3/8] wifi: ath12k: Add ath12k_get_num_hw api Date: Wed, 22 May 2024 15:24:34 +0530 Message-Id: <20240522095439.2596989-4-quic_hprem@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522095439.2596989-1-quic_hprem@quicinc.com> References: <20240522095439.2596989-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: dArmUokaoJKDT8sFoLWzspKxaLAbc2Oq X-Proofpoint-ORIG-GUID: dArmUokaoJKDT8sFoLWzspKxaLAbc2Oq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-22_05,2024-05-21_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 bulkscore=0 mlxscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxlogscore=856 clxscore=1015 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405010000 definitions=main-2405220070 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 3925bb70d479..7ad65ace7123 100644 --- a/drivers/net/wireless/ath/ath12k/core.c +++ b/drivers/net/wireless/ath/ath12k/core.c @@ -946,7 +946,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; @@ -998,7 +998,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; @@ -1037,7 +1037,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 3f5c9fa9d04c..a22f3561deb0 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -1062,4 +1062,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 f8e8320b8598..66587c5ea8fd 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -9157,7 +9157,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); @@ -9184,7 +9184,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; @@ -9254,7 +9254,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; @@ -9277,7 +9277,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 Wed May 22 09:54:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshitha Prem X-Patchwork-Id: 798388 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 6112281726 for ; Wed, 22 May 2024 09:55:22 +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=1716371723; cv=none; b=Rq3xp95X0NXWM7qrdTpcQ90d15wFTeotL2ZaVeUcrldFpV1Nllks7yYDXezVTUMjdieDvmTLaQYjrMZWkqLxVVKrEp8ZyCMy5tHNRCR5TTQUsgjY0JiplaZsyJD+Q8qgIvwEIB94eWmiC5VUREI7wBQ2G0q5JkZH4ojeDReoOiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716371723; c=relaxed/simple; bh=dwkthOA7GWS4R8gzE42HqNlpALzQ09xMHfIGVIahTSA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iZMkytHC+UExIJB65MrCyJQW4ndEOFmeeEmtnp/YAPDU3tRZGVmgHGNp2vj14dUHt6RPD1V/od9CiQ5TLcbqIUhbefMTcfCE3oOZpTdiTEf5zKvEXk+bGnw0VgEj0u11NU5SE/BJr/TMHKVfwGcIL76XzZVRrV77Bp21tEfSlnQ= 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=igpbat+J; 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="igpbat+J" 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 44M5a7ka025366; Wed, 22 May 2024 09:55:20 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=oRG1vZH hL6MemXix6GK9KFZsHBV6u+6OcmvB1zTdbH0=; b=igpbat+Jn2RGCspb2/wOAtX tY4hiFefQ/8vHkde/ye9/f+HhWw8LL7BOH/T6Pl2zn9LnYqq06U/gVkTW0sH1LjO kTYk4IA+MqLPGu6SLCDrn2dhbK310het6zCfSATql7dxTrFGPaLOIGPuVURJqnSN 679/JUnLB8qE/S4RaxpJBxotgJ+WuiKMvIBvT3V9ujJZgBwkWbI0xc2SHe04hT4t /bextLrLngR7jnTfawRfBYCxlmobOMfgAGGNju5fyc0E7M55jD8dS6YZaNgteWtt e1QUC+6qJkXHbwBF9uLHmkPVLeJSdD9qvyndroY2Ctie1Bj6Gt41bTfTyUPgb7A= = Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3y6n45rnac-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:19 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 44M9tFb5024963; Wed, 22 May 2024 09:55:16 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3y6ndkfpvg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:16 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 44M9tGPX024969; Wed, 22 May 2024 09:55:16 GMT Received: from hu-devc-blr-u22-a.qualcomm.com (hu-hprem-blr.qualcomm.com [10.190.108.75]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 44M9tF50024968 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:16 +0000 Received: by hu-devc-blr-u22-a.qualcomm.com (Postfix, from userid 4146166) id 19FAD410F2; Wed, 22 May 2024 15:25:15 +0530 (+0530) From: Harshitha Prem To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Karthikeyan Periyasamy , Harshitha Prem , Jeff Johnson Subject: [PATCH v5 4/8] wifi: ath12k: Introduce QMI firmware ready flag Date: Wed, 22 May 2024 15:24:35 +0530 Message-Id: <20240522095439.2596989-5-quic_hprem@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522095439.2596989-1-quic_hprem@quicinc.com> References: <20240522095439.2596989-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: WOY8iH4XoZuCfLOEPL7hhkI41vkwX2sK X-Proofpoint-ORIG-GUID: WOY8iH4XoZuCfLOEPL7hhkI41vkwX2sK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-22_05,2024-05-21_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=907 phishscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405010000 definitions=main-2405220070 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 a22f3561deb0..bc2a9e1b1885 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -208,6 +208,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, }; struct ath12k_tx_conf { diff --git a/drivers/net/wireless/ath/ath12k/qmi.c b/drivers/net/wireless/ath/ath12k/qmi.c index f273cb93dedb..4bec52afa507 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 Wed May 22 09:54:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshitha Prem X-Patchwork-Id: 798917 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 EA98B81AA7 for ; Wed, 22 May 2024 09:55:22 +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=1716371724; cv=none; b=Oxh3dDX90nScqCXWBEQzZvQFEgJP8T3q3bUYbOS/oWKHt20AYKo0Je46ISG69HpqESk23EhO2H64qD4ny3MhCg0adILXDQ9JacDPwKRX7ediEEEbOJ0cvq+MuVKx/j6KRFoNNUxvXgwYa+Jl1gYjL/Or+B8V+DRcSrSKV0cpx4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716371724; c=relaxed/simple; bh=8GmhSaFVtWVdvt9xku+kc2rQ/N1+mTiOOTAgiP4FV0Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oW4yo+IVQR5BhguquhfELFkFBwHyM1idr9HU7ZfohBIt73Pcp/tBRt5Zw9OE4e7dpd1ki5cDYrMMKcpaaixohVNpTfbZysti3pC5pz0NO7jHZjP+I5FSl07wfY5oWTmVqU7kpdtx9CNrpgUepfJOFsoaIYELUvnG4Fi0eGdlKYk= 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=phtBX3JU; 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="phtBX3JU" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44M80RiO010132; Wed, 22 May 2024 09:55:20 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=TpDzXI1 XCwKcy5biNSn5A6C8x45nBCjfW3MRqwCUuqY=; b=phtBX3JUGEyiW2xFq7m3Ccl dV6FyjliDmDcut106N9tvmhtlrZpeH8k/+qRmQyL8gqDjfITb+DEq5lMN815ZDil Q4OmebdHygPNt6E91AD84XJKDT4Q+xcpeOk4U1qvkYNvr0VVeWfz9QuPr7rkDYbD Yg2ItTBO9ol3hJG4VfHm7V9rH9xEbLyMo9S6J/ayzjKNtV7zMnNaG5SAa3UABH8F L/PlmpQe+hxUyuKVlKSwpdfQNKeo15dZlP9EAfsRM+KHbY6oYimfjWIDUGiQ7wk4 zdYEcCUEPgd0XLaO44c8936Hy7rVSo6Qjhbf200fl62N9kaPS6dhvch89o7gWWw= = Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3y6pqardkw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:20 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 44M9tEIL024943; Wed, 22 May 2024 09:55:17 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3y6ndkfpvn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:17 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 44M9tGdF024985; Wed, 22 May 2024 09:55:16 GMT Received: from hu-devc-blr-u22-a.qualcomm.com (hu-hprem-blr.qualcomm.com [10.190.108.75]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 44M9tGNh024980 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:16 +0000 Received: by hu-devc-blr-u22-a.qualcomm.com (Postfix, from userid 4146166) id E127541148; Wed, 22 May 2024 15:25:15 +0530 (+0530) From: Harshitha Prem To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Karthikeyan Periyasamy , Harshitha Prem , Jeff Johnson Subject: [PATCH v5 5/8] wifi: ath12k: move ATH12K_FLAG_REGISTERED flag set to mac_register api Date: Wed, 22 May 2024 15:24:36 +0530 Message-Id: <20240522095439.2596989-6-quic_hprem@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522095439.2596989-1-quic_hprem@quicinc.com> References: <20240522095439.2596989-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: HS1f4-_QgnXKLAIQ0-7gp-PLWmqDjsBX X-Proofpoint-ORIG-GUID: HS1f4-_QgnXKLAIQ0-7gp-PLWmqDjsBX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-22_05,2024-05-21_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 bulkscore=0 mlxscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405010000 definitions=main-2405220070 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 66587c5ea8fd..4ab9846f154c 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -9165,6 +9165,7 @@ int ath12k_mac_register(struct ath12k_base *ab) goto err; } + set_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags); return 0; err: @@ -9184,6 +9185,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 4bec52afa507..cbe77507c9ec 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 Wed May 22 09:54:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshitha Prem X-Patchwork-Id: 798387 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 E58C581ABF for ; Wed, 22 May 2024 09:55:23 +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=1716371725; cv=none; b=M0nQSSkvUpLhZw1SRy4NK6hxcgrgj4aFYzbZCYOtYqXuoKx7wpiryZTm8fuSJopPbZF9yacd63nbSoLIa32apEqOX3wG9P4podQcu3PDjiO2R7mjQxi/QRg+GwCkhSbjwYXfupW2D85oghddxx8TsYHKwzHSgF+lmCWnNuHVyKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716371725; c=relaxed/simple; bh=95JxtwVCOBjn2YmHCV46mv2EI7/460fiWIgFHSTm0nA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nJmvQ7X0aiTaG+w6DrIpDFCSbFICt+Cw2rRCtBlvwoWWmFhDYYooNgAn5uOWVqpBg/qVaFu6/eeloduxYhAY3rb1L+Ut5EFk8IbwCy11S5JZp1sU9UeYAWAl6qFbZX223RTSVUYoVMErnDXAFxQ9B585g/SzutIxW67OavUP3NA= 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=izIwOvW3; 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="izIwOvW3" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44M50PPI005035; Wed, 22 May 2024 09:55:21 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=XKkYY+f xG0JFx6qzdH8OY27raY2dKZT7t1X6YeLzNuk=; b=izIwOvW3mH22a65hFN2jhKZ 4+u7b2U5UMn4hhwMjx0DSpz56xXZ4c5PFq1FjCHkes4MON30+WwGsHQN70NozFR9 aG0zywBIcok6fxotiJpwODkuuhOACQsmA2S8MGBkt61WFxi4YJdlj4osm7Xns2M2 q0CTzENV/iymKSpUOYjMs3oMXolSBeh+oYGmFdhwgewAeSr+jhvclBKasGmPpAP6 tOwmvnNc3NXb5pTddXjs9+AymWLBlVOBhlIv08Qvl1QTaZmKmFwSqv/7bhR7VyP9 46dnpuOHFry2NNPE3hz2En4ZZxPn1luTnCXJ+4BKI4dmRJmI6WMlY/hqGfwnCiQ= = Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3y6pr2rh0a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:21 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 44M9o6Ac020639; Wed, 22 May 2024 09:55:18 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3y6ndkfpvr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:18 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 44M9tEuV024937; Wed, 22 May 2024 09:55:17 GMT Received: from hu-devc-blr-u22-a.qualcomm.com (hu-hprem-blr.qualcomm.com [10.190.108.75]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 44M9tHpZ024994 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:17 +0000 Received: by hu-devc-blr-u22-a.qualcomm.com (Postfix, from userid 4146166) id A10F9410F2; Wed, 22 May 2024 15:25:16 +0530 (+0530) From: Harshitha Prem To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Karthikeyan Periyasamy , Harshitha Prem , Jeff Johnson Subject: [PATCH v5 6/8] wifi: ath12k: Introduce device group abstraction Date: Wed, 22 May 2024 15:24:37 +0530 Message-Id: <20240522095439.2596989-7-quic_hprem@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522095439.2596989-1-quic_hprem@quicinc.com> References: <20240522095439.2596989-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: CNp099kLOBXqnDXZcL-sv5Ots36A4xDI X-Proofpoint-GUID: CNp099kLOBXqnDXZcL-sv5Ots36A4xDI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-22_05,2024-05-21_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 bulkscore=0 malwarescore=0 spamscore=0 priorityscore=1501 impostorscore=0 clxscore=1015 lowpriorityscore=0 adultscore=0 suspectscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405010000 definitions=main-2405220070 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 7ad65ace7123..ebe31cbb6435 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; @@ -1185,20 +1188,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); @@ -1209,8 +1303,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 bc2a9e1b1885..a6b8c100ebc8 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, @@ -209,6 +213,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, }; struct ath12k_tx_conf { @@ -725,6 +730,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 * @@ -925,6 +941,8 @@ struct ath12k_base { #endif /* CONFIG_ACPI */ + struct ath12k_hw_group *ag; + /* must be last */ u8 drv_priv[] __aligned(sizeof(void *)); }; @@ -955,6 +973,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 8f37f6efb8a2..82d6aedb0963 100644 --- a/drivers/net/wireless/ath/ath12k/pci.c +++ b/drivers/net/wireless/ath/ath12k/pci.c @@ -1522,6 +1522,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 Wed May 22 09:54:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshitha Prem X-Patchwork-Id: 798916 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 4FE62823A3 for ; Wed, 22 May 2024 09:55:25 +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=1716371727; cv=none; b=u1j+Px3jOV+wGdQwray0yLsLLNFPkKJiNw6VN+iiEfVJjG381ruarVep6r+p3BNbl54EY6bKfiEFPB2MXBvBZnA7FMF+e/yPqpFHFypGU8MsxvhOiexMmwLz6kNmWNynApZSFFRQ8xejBqrdHti6GjRATiUnHf8dOM2EA+rXv5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716371727; c=relaxed/simple; bh=iTTc66FWLMqVwJW+q8zVu23doqvPQTimTRjP+4kH/aY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nsLUgz/mKEZij4c2+RarZ20nx8Dt5/XiBfInh2gUflSSoI9hb1n4tGDinWDZGjRWyDyEM8Gx79SB4reHYunPAoeGqWUlcTCsWRo+praasjUs6ngthDOkumUvA1ReRG/XZ5FTEz4A+o+BJGPvEs9ThaFra03PRtX3qlEADKisSp4= 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=ou55Pxxo; 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="ou55Pxxo" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44M3EfkC014675; Wed, 22 May 2024 09:55: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=LiMh8jq tnyd+d3WnOanZklSMOcOdMMCgbrR+cLLXulw=; b=ou55PxxoObS9QAJqXohIuSB rA8NGHbvME2VXwZgxPymZilOoNiSG4ahbRvI2UWW0cuSJV96fKpWonw7NSfTvFwt 0m5eamjnIPwZl6OBtv489+THEm5ATaJdSEZAYef8lxzjSnFNmqqPNunjFk92O2HL /ePWGlzQuVdr0bfH/7o7ARq5EYtkHIi+D1WKUQiYOvQN4YvQC1xedRVF7TG6UcFe KlTyMdPvxi/IQClqD50sxBxMRTS4qxw2s9f+wJJWMpsGnZvZduKQNFEJc8UNhPWq givXd99SM3CYcSBBbGhVntX1zqItUUZKXhubNToH0Dd60otfYVgKslGyke8UpEA= = Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3y6pqc8cqq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:22 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 44M9tIVv025012; Wed, 22 May 2024 09:55:18 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3y6ndkfpvx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:18 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 44M9stct024345; Wed, 22 May 2024 09:55:18 GMT Received: from hu-devc-blr-u22-a.qualcomm.com (hu-hprem-blr.qualcomm.com [10.190.108.75]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 44M9tIB9025007 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:18 +0000 Received: by hu-devc-blr-u22-a.qualcomm.com (Postfix, from userid 4146166) id 655B241148; Wed, 22 May 2024 15:25:17 +0530 (+0530) From: Harshitha Prem To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Karthikeyan Periyasamy , Harshitha Prem , Jeff Johnson Subject: [PATCH v5 7/8] wifi: ath12k: refactor core start based on hardware group Date: Wed, 22 May 2024 15:24:38 +0530 Message-Id: <20240522095439.2596989-8-quic_hprem@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522095439.2596989-1-quic_hprem@quicinc.com> References: <20240522095439.2596989-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: _ZkuUDZU88lQAow9N8Qst8G5zioyLQlD X-Proofpoint-GUID: _ZkuUDZU88lQAow9N8Qst8G5zioyLQlD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-22_05,2024-05-21_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 mlxlogscore=999 impostorscore=0 adultscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 clxscore=1015 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405010000 definitions=main-2405220070 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 ebe31cbb6435..6897d222d972 100644 --- a/drivers/net/wireless/ath/ath12k/core.c +++ b/drivers/net/wireless/ath/ath12k/core.c @@ -563,6 +563,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); @@ -689,11 +692,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); } @@ -702,6 +709,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); @@ -795,6 +804,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: @@ -806,6 +820,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) { @@ -823,9 +940,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) { @@ -845,59 +971,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; } @@ -1149,6 +1266,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); @@ -1258,7 +1379,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; @@ -1292,19 +1413,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; @@ -1332,14 +1440,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 a6b8c100ebc8..d955deb08fd4 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -200,6 +200,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, @@ -214,6 +218,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, }; struct ath12k_tx_conf { @@ -736,6 +743,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; @@ -1087,4 +1096,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 Wed May 22 09:54:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshitha Prem X-Patchwork-Id: 798386 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 64295823AF for ; Wed, 22 May 2024 09:55:26 +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=1716371728; cv=none; b=KEQDlEpKzYdCO7JoZMZMWMT3DKIy8an/ImvoJtNZrnAt62xpxHiej02WMpA0ciQB7TUjtT3jW9Ag+nq83MNyukWwX9AXN81MBE6icwAxVWydiFSKhVUsMpS2kALiLP9uT/tJdsYibtqwe6JLxONBclGojq+x0IHU77nU1KRGRN0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716371728; c=relaxed/simple; bh=/01GR20EgNmhP7p3kDgjHRVm7cHpERFRifZHxs5oB2Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HiQc3fdN99WwxCDMiA2YhVtt4PMID/r0rZ6ymBiL/NFuW6CH6WVHYbdJxcYqY2JM7QoEo0p4iQ5yP0nTsUWx3incezDWdx+DtRllpQtJ1dt7hqZYNBi4N0R6SCDXgtLI7i1Y7Wi9wSHTBpv50zM4r0fPWD18/JsknrjIzkSLTIw= 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=nsK5nNNS; 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="nsK5nNNS" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44M2pK8C009338; Wed, 22 May 2024 09:55:23 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=TZTfhx/ lgOWdOizKSBpHvFu5VXYWS2ecdx6fXpO76hk=; b=nsK5nNNSD+eog7znyS38DDE XBT2W/SJuuPLt7bU40NmN/OzKCl8WojgBRXGngBsw1mRYd6PpSennAPANRLVOjou hMX+wdz6w23q1a2+8j8YOFDdfKuHvViXW7NeM6bp8LN0/n9oCS5KAst60DMtooF7 STXMRcL5A97F3iVBSss3a5iyeYXQeJiscmsSISmBm9h1yhsYU1awi1LT9PVM8YBx IKy8ntKe5+IUyuenPr70Pn8kEbvlJVLxe9G3vWV1INw14ZQWynLOgZEvcyxQdnSN 7Jqe10MUjtp40S5YIYDhQJtUegPcnGJvHgYsBeg1hRSX3f+yvl0W8PCs7o0OGrg= = Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3y6pqardm0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:22 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 44M9stbm024353; Wed, 22 May 2024 09:55:19 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3y6ndkfpw2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:19 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 44M9tJlp025018; Wed, 22 May 2024 09:55:19 GMT Received: from hu-devc-blr-u22-a.qualcomm.com (hu-hprem-blr.qualcomm.com [10.190.108.75]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 44M9tJHf025017 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2024 09:55:19 +0000 Received: by hu-devc-blr-u22-a.qualcomm.com (Postfix, from userid 4146166) id 219E9410F2; Wed, 22 May 2024 15:25:18 +0530 (+0530) From: Harshitha Prem To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Karthikeyan Periyasamy , Harshitha Prem Subject: [PATCH v5 8/8] wifi: ath12k: move ath12k_hw from per soc to group Date: Wed, 22 May 2024 15:24:39 +0530 Message-Id: <20240522095439.2596989-9-quic_hprem@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522095439.2596989-1-quic_hprem@quicinc.com> References: <20240522095439.2596989-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: DIDlRUrrzaA1cok_ikgRyYiYqJsVDCWb X-Proofpoint-ORIG-GUID: DIDlRUrrzaA1cok_ikgRyYiYqJsVDCWb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-22_05,2024-05-21_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 bulkscore=0 mlxscore=0 adultscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405010000 definitions=main-2405220070 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 --- drivers/net/wireless/ath/ath12k/core.c | 52 +++++++-------- drivers/net/wireless/ath/ath12k/core.h | 25 ++++---- drivers/net/wireless/ath/ath12k/dp.c | 19 ++---- drivers/net/wireless/ath/ath12k/dp.h | 2 +- drivers/net/wireless/ath/ath12k/mac.c | 88 ++++++++++++++++++-------- drivers/net/wireless/ath/ath12k/mac.h | 9 +-- 6 files changed, 109 insertions(+), 86 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c index 6897d222d972..d54655f1f068 100644 --- a/drivers/net/wireless/ath/ath12k/core.c +++ b/drivers/net/wireless/ath/ath12k/core.c @@ -830,11 +830,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); } @@ -851,6 +846,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) @@ -861,6 +858,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) @@ -868,31 +882,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); @@ -919,7 +908,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 d955deb08fd4..fcdd945ba7ea 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 @@ -748,6 +749,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[ATH12K_GROUP_MAX_RADIO]; + u8 num_hw; }; /** @@ -819,15 +829,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; @@ -1083,18 +1084,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/dp.c b/drivers/net/wireless/ath/ath12k/dp.c index c04fa3eb57d6..723d53c68e98 100644 --- a/drivers/net/wireless/ath/ath12k/dp.c +++ b/drivers/net/wireless/ath/ath12k/dp.c @@ -980,21 +980,14 @@ void ath12k_dp_pdev_free(struct ath12k_base *ab) ath12k_dp_rx_pdev_free(ab, i); } -void ath12k_dp_pdev_pre_alloc(struct ath12k_base *ab) +void ath12k_dp_pdev_pre_alloc(struct ath12k *ar) { - struct ath12k *ar; - struct ath12k_pdev_dp *dp; - int i; + struct ath12k_pdev_dp *dp = &ar->dp; - for (i = 0; i < ab->num_radios; i++) { - ar = ab->pdevs[i].ar; - dp = &ar->dp; - dp->mac_id = i; - atomic_set(&dp->num_tx_pending, 0); - init_waitqueue_head(&dp->tx_empty_waitq); - - /* TODO: Add any RXDMA setup required per pdev */ - } + dp->mac_id = ar->pdev_idx; + atomic_set(&dp->num_tx_pending, 0); + init_waitqueue_head(&dp->tx_empty_waitq); + /* TODO: Add any RXDMA setup required per pdev */ } bool ath12k_dp_wmask_compaction_rx_tlv_supported(struct ath12k_base *ab) diff --git a/drivers/net/wireless/ath/ath12k/dp.h b/drivers/net/wireless/ath/ath12k/dp.h index 43589c3dd4bc..8d7f79b6698d 100644 --- a/drivers/net/wireless/ath/ath12k/dp.h +++ b/drivers/net/wireless/ath/ath12k/dp.h @@ -1814,7 +1814,7 @@ void ath12k_dp_free(struct ath12k_base *ab); int ath12k_dp_alloc(struct ath12k_base *ab); void ath12k_dp_cc_config(struct ath12k_base *ab); int ath12k_dp_pdev_alloc(struct ath12k_base *ab); -void ath12k_dp_pdev_pre_alloc(struct ath12k_base *ab); +void ath12k_dp_pdev_pre_alloc(struct ath12k *ar); void ath12k_dp_pdev_free(struct ath12k_base *ab); int ath12k_dp_tx_htt_srng_setup(struct ath12k_base *ab, u32 ring_id, int mac_id, enum hal_ring_type ring_type); diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index 4ab9846f154c..0209a4dde353 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -9144,19 +9144,13 @@ static void ath12k_mac_setup(struct ath12k *ar) skb_queue_head_init(&ar->wmi_mgmt_tx_queue); } -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); @@ -9180,8 +9174,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; @@ -9200,12 +9195,13 @@ static void ath12k_mac_hw_destroy(struct ath12k_hw *ah) ieee80211_free_hw(ah->hw); } -static struct ath12k_hw *ath12k_mac_hw_allocate(struct ath12k_base *ab, +static struct ath12k_hw *ath12k_mac_hw_allocate(struct ath12k_hw_group *ag, struct ath12k_pdev_map *pdev_map, u8 num_pdev_map) { struct ieee80211_hw *hw; struct ath12k *ar; + struct ath12k_base *ab; struct ath12k_pdev *pdev; struct ath12k_hw *ah; int i; @@ -9237,23 +9233,30 @@ static struct ath12k_hw *ath12k_mac_hw_allocate(struct ath12k_base *ab, pdev->ar = ar; ath12k_mac_setup(ar); + ath12k_dp_pdev_pre_alloc(ar); } 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++) { @@ -9266,26 +9269,60 @@ void ath12k_mac_destroy(struct ath12k_base *ab) } } -int ath12k_mac_allocate(struct ath12k_base *ab) +static void ath12k_mac_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; +} + +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; - for (i = 0; i < ath12k_get_num_hw(ab); i++) { + 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++) { for (j = 0; j < radio_per_hw; j++) { + ab = ag->ab[device_id]; pdev_map[j].ab = ab; - pdev_map[j].pdev_idx = (i * radio_per_hw) + j; + pdev_map[j].pdev_idx = mac_id; + mac_id++; + + /* If mac_id falls beyond the current device MACs then + * move to next device + */ + if (mac_id >= ab->num_radios) { + mac_id = 0; + device_id++; + ath12k_mac_set_device_defaults(ab); + } } - ah = ath12k_mac_hw_allocate(ab, pdev_map, radio_per_hw); + ah = ath12k_mac_hw_allocate(ag, pdev_map, radio_per_hw); if (!ah) { ath12k_warn(ab, "failed to allocate mac80211 hw device for hw_idx %d\n", i); @@ -9293,11 +9330,10 @@ int ath12k_mac_allocate(struct ath12k_base *ab) goto err; } - ath12k_ab_set_ah(ab, i, ah); + 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,