Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp301420lqh; Mon, 6 May 2024 22:05:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV1al99T32arrWQa9bHTHBZfas9qDJ7XR7kGvJg/GDq+u6jSjZDxbJYIycC2yGXA7lyLNV74vM6rwsil2lVNrTb23bu00P31a1GqazaPw== X-Google-Smtp-Source: AGHT+IELA1HmeoqLPnG+WlvhI/pS2lHEi9omhj+3y87E3QvBACJEV+4e8okzCyLJPkMIDGZ00hav X-Received: by 2002:a17:902:e952:b0:1e7:89af:f267 with SMTP id b18-20020a170902e95200b001e789aff267mr14748721pll.37.1715058349996; Mon, 06 May 2024 22:05:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715058349; cv=pass; d=google.com; s=arc-20160816; b=TXAY0MLRZcx10zEwi19/AWij9vRAH5G/wmXJeqAePzayjzQdeuOyPYN1FSLQN4/CYl E4cg9qNKBvadtzAJoicGXxlaIhtHnXbKTTJrk+47Emp0nSjG+VVxNdV74jKnC+vnde7n 6uAJAlYGuK0Wb6McYLPMrYlSkKjZWyRZVlAAEgyHOp7jsPAMvbzlO940393LAcn9mJXF 0oSMdv1y7FTRXnhbg6kcuryRSDDTI0qlvzpzEM/Z4FB/iSMOunLmNln5HtguNejYJPwL bU/E1XuRL3paRjKcBErzEAqnJESPwMJpO8kcBmpcLQQnVEZYxWpllnA7g8aUCuHlaQb+ x02Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=K6Vxp5Ui3pvzEDEA6ulu82JW3Ka3FJdUn8bBsg035+M=; fh=wnySVr9+WO9j7lO1L6CVbSw/CjEiK6R10EUaKUiDPbE=; b=r37dv5tpQBcB8hIXne4wOmnE5AJXW7J0V6YKlZ25Iy97JAR7WFAaw7saJVzPBvOj49 s1yhH7XjULkHIKyD7WIexw0q6U6VreWjDu8M4CyRQFhu2CDZ+kJD48LFCVdJGOk4SotV h8i+aSFlnBeyv8L4cW/K0lWKr/kaxFirCaRe7x32Lfheqx6ZPpDBDaJludnW63BIaK/G IOKY1worJ3N8dB9HyjPaGC2MhcjA7REKO9UBYNTsjNEnMpbxYP8IAU2KUCVIUDSGUeNC yifxYwsDHpgKkzlfVQ+BxxGwX2ns5TwXh5dlviSt7gO/VScjs2JJ67atpRm594NRAWpM FeDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=LxLdt7Yk; arc=pass (i=1 spf=pass spfdomain=qualcomm.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-wireless+bounces-7269-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-wireless+bounces-7269-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id a15-20020a170902eccf00b001eb71628291si9981297plh.117.2024.05.06.22.05.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 22:05:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-7269-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=LxLdt7Yk; arc=pass (i=1 spf=pass spfdomain=qualcomm.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-wireless+bounces-7269-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-wireless+bounces-7269-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 6A52CB25A35 for ; Tue, 7 May 2024 05:00:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 151646A8CF; Tue, 7 May 2024 04:58:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="LxLdt7Yk" X-Original-To: linux-wireless@vger.kernel.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3DB766A8D8 for ; Tue, 7 May 2024 04:58:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057884; cv=none; b=CJgV/s4a5WmoyblFJBir6qqI/oYcb6jlTtnS7anrjHL2lRyMUgCSfKyrPeEjtDqAwWEPAMoPsiy00Agz3CpJRVs3MqwHpnCmvdS4LVY2JQQffKMlu54XsAOnhhyjNElwhhzNkzk7wAs8+bB4YEUqUby/QepCCi8SkYuiHKXmrYs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715057884; c=relaxed/simple; bh=5CYTNY4DCzsAj4LWHHhAXOAcFXrtRfQz7cYgsVx/PvU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sf/pKrDpxZlxA5tlNIdZnoUkQpLtDy5HtW3lBQYMX6yL29dWpqzgY5pcccNbN+CXze8aafF5EKT8OvcGaLgndumOfuNqCGJrQ/7H1XduqqKYHuHHzeyIfiPt7D+Enk4jDSiBjLNcS9VW/QDOlJgBpk665TBaHtst+wONHHZS49E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=LxLdt7Yk; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qualcomm.com Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4473KTwb003856; Tue, 7 May 2024 04:57:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=qcppdkim1; bh=K6Vxp5U i3pvzEDEA6ulu82JW3Ka3FJdUn8bBsg035+M=; b=LxLdt7Yk/gFPdkjgz6t9bBX TbnuMJ/SJZjm7iu2pJ+2h5PEmwXuw09m5Vkt7RrpDx8ZndQh40wEJdNCuKBd2LEg G+aGqTMS1jSOhXkUNLnq62N8J/C1zCGwiy4zCJMzX7veten+k525No8Vi93eeDjJ H+LTEHmgi/bgR5Vc8n+hs9xUFMCaq8j1ftzpCjL9D9cNoX40nYrViLwxRb3R9XcP 2Csu/r0uzeT9qYWeTey62g4yxyCG1mutj5Lez6TvZ4b5nOUbbsd9pyQHkr0loyke L1VAzE3RLJ3FKhTueqZx0mtDDazd1XVM6Dd/SZ2AmFZtQ0jfakwZ9H2X69l5Gzg= = Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xxvv722hh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:53 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 4474vItD003579; Tue, 7 May 2024 04:57:50 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 3xwe3kn53f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:50 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4474vo4Z004282; Tue, 7 May 2024 04:57:50 GMT Received: from hu-devc-blr-u22-a.qualcomm.com (hu-hprem-blr.qualcomm.com [10.190.108.75]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 4474vovS004281 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 May 2024 04:57:50 +0000 Received: by hu-devc-blr-u22-a.qualcomm.com (Postfix, from userid 4146166) id E96314114D; Tue, 7 May 2024 10:27:48 +0530 (+0530) From: Harshitha Prem To: ath12k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Karthikeyan Periyasamy , Harshitha Prem Subject: [PATCH v4 8/8] wifi: ath12k: move ath12k_hw from per soc to group Date: Tue, 7 May 2024 10:27:02 +0530 Message-Id: <20240507045702.2858954-9-quic_hprem@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240507045702.2858954-1-quic_hprem@quicinc.com> References: <20240507045702.2858954-1-quic_hprem@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: sxghYzz88sgpmuP7AGE4HJ0IArEnmgz5 X-Proofpoint-ORIG-GUID: sxghYzz88sgpmuP7AGE4HJ0IArEnmgz5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-07_02,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 clxscore=1015 suspectscore=0 spamscore=0 mlxscore=0 priorityscore=1501 mlxlogscore=999 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2405070033 From: Karthikeyan Periyasamy Currently, hardware abstractions (ah) of different radio bands are tightly coupled to a single device (ab). But, with hardware device group abstraction (ag), multiple radios across different devices in a group can possibly form different combinations of hardware abstractions (ah) within the group. Hence, the mapping between ah to ab can be removed and instead it can be mapped with ag. Please find below illustration of how mapping between ath12k_hw (ah), ath12k_base (ab) and ath12k_hw_group (ag) is changed. current mapping of hardware abstraction (ah) with device (ab) +------------------------------------------------+ | +-------------------------------------+ | | | +---------------+ +---------------+ | | | | |ath12k_hw (ah) | |ath12k_hw (ah) | | | | | +---------------+ +---------------+ | | | | | | | | +-----------+ | +-----------+ | | | | | ar (2GHz) | | | ar (5GHz) | | | | | +-----------+ | +-----------+ | | | | Dual band device-1 (ab) | | | +-------------------------------------+ | | ath12k_hw_group (ag) based on group id | +------------------------------------------------+ After, with hardware device group abstraction (moving ah array out of ab to ag) +----------------------------------------------+ | +---------------+ +---------------+ | | |ath12k_hw (ah) | |ath12k_hw (ah) | | | +---------------+ +---------------+ | | +-------------------------------------+ | | | +-----------+ +-----------+ | | | | | ar (2GHz) | | ar (5GHz) | | | | | +-----------+ +-----------+ | | | | Dual band device-1 (ab) | | | +-------------------------------------+ | | ath12k_hw_group (ag) based on group id | +----------------------------------------------+ This decoupling of ath12k_hw (ah) from ath12k_base (ab) and mapping it to ath12k_hw_group (ag) will help in forming different combinations of multi-link devices. Say for example, device 1 has two radios (2 GHz and 5 GHz band) and device 2 has one radio (6 GHz). In existing code - device 1 will have two hardware abstractions hw1 (2 GHz) and hw2 (5 GHz) will be registered separately to mac80211 as phy0 and phy1 respectively. Similarly, device 2 will register its hw (6 GHz) as phy2 to mac80211. In future, with multi-link abstraction combination 1 - Different group id for device1 and device 2 Device 1 will create a single hardware abstraction hw1 (2 GHz and 5 GHz) and will be registered to mac80211 as phy0. similarly, device 2 will register its hardware (6 GHz) to mac80211 as phy1. combination 2 - Same group id for device1 and device 2 Both device details are combined together as a group, say group1, with single hardware abstraction of radios 2 GHz, 5 GHz and 6 GHz band details and will be registered to mac80211 as phy0. Hence, Add changes to decouple ath12k_hw (ah) from ath12k_base (ab) and map it to ath12k_hw_group (ag). Refactor the following APIs to help simplify the registration based on ath12k_hw_group (ag) rather than ath12k_base (ab) * ath12k_mac_allocate() * ath12k_mac_destroy() * ath12k_mac_register() * ath12k_mac_unregister() Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1 Signed-off-by: Karthikeyan Periyasamy Signed-off-by: Harshitha Prem --- drivers/net/wireless/ath/ath12k/core.c | 52 +++++++---------- drivers/net/wireless/ath/ath12k/core.h | 25 ++++---- drivers/net/wireless/ath/ath12k/mac.c | 81 ++++++++++++++++++-------- drivers/net/wireless/ath/ath12k/mac.h | 9 +-- 4 files changed, 98 insertions(+), 69 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c index 1165baf31211..88b14343d91f 100644 --- a/drivers/net/wireless/ath/ath12k/core.c +++ b/drivers/net/wireless/ath/ath12k/core.c @@ -833,11 +833,6 @@ static void ath12k_core_device_cleanup(struct ath12k_base *ab) if (test_bit(ATH12K_FLAG_PDEV_CREATED, &ab->dev_flags)) ath12k_core_pdev_destroy(ab); - if (test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags)) { - ath12k_mac_unregister(ab); - ath12k_mac_destroy(ab); - } - mutex_unlock(&ab->core_lock); } @@ -854,6 +849,8 @@ static void ath12k_core_hw_group_stop(struct ath12k_hw_group *ag) continue; ath12k_core_device_cleanup(ab); } + ath12k_mac_unregister(ag); + ath12k_mac_destroy(ag); } static int ath12k_core_hw_group_start(struct ath12k_hw_group *ag) @@ -864,6 +861,23 @@ static int ath12k_core_hw_group_start(struct ath12k_hw_group *ag) lockdep_assert_held(&ag->mutex_lock); + /* Check if already registered or not, since same flow + * execute for HW restart case. + */ + is_registered = test_bit(ATH12K_GROUP_FLAG_REGISTERED, &ag->flags); + + if (is_registered) + goto core_pdev_create; + + ret = ath12k_mac_allocate(ag); + if (WARN_ON(ret)) + return ret; + + ret = ath12k_mac_register(ag); + if (WARN_ON(ret)) + goto err_mac_alloc; + +core_pdev_create: for (i = 0; i < ag->num_devices; i++) { ab = ag->ab[i]; if (!ab) @@ -871,31 +885,6 @@ static int ath12k_core_hw_group_start(struct ath12k_hw_group *ag) mutex_lock(&ab->core_lock); - /* Check if already registered or not, since same flow - * execute for HW restart case. - */ - is_registered = test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags); - - if (is_registered) - goto core_pdev_create; - - ret = ath12k_mac_allocate(ab); - if (ret) { - ath12k_err(ab, "failed to create new hw device with mac80211 :%d\n", - ret); - mutex_unlock(&ab->core_lock); - return ret; - } - - ret = ath12k_mac_register(ab); - if (ret) { - ath12k_err(ab, "failed to register radio with mac80211: %d\n", - ret); - mutex_unlock(&ab->core_lock); - goto err; - } - -core_pdev_create: ret = ath12k_core_pdev_create(ab); if (ret) { ath12k_err(ab, "failed to create pdev core %d\n", ret); @@ -922,7 +911,10 @@ static int ath12k_core_hw_group_start(struct ath12k_hw_group *ag) err: ath12k_core_hw_group_stop(ag); + return ret; +err_mac_alloc: + ath12k_mac_destroy(ag); return ret; } diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h index 2c3c585797cf..58cd5428502b 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -60,6 +60,7 @@ #define ATH12K_RECOVER_START_TIMEOUT_HZ (20 * HZ) #define ATH12K_MAX_SOCS 3 +#define ATH12K_GROUP_MAX_RADIO (ATH12K_MAX_SOCS * MAX_RADIOS) #define ATH12K_INVALID_GROUP_ID 0xFF #define ATH12K_INVALID_DEVICE_ID 0xFF @@ -755,6 +756,15 @@ struct ath12k_hw_group { struct ath12k_base *ab[ATH12K_MAX_SOCS]; /* To synchronize group create, assign, start, stop */ struct mutex mutex_lock; + + /* Holds information of wiphy (hw) registration. + * + * In Multi/Single Link Operation case, all pdevs are registered as + * a single wiphy. In other (legacy/Non-MLO) cases, each pdev is + * registered as separate wiphys. + */ + struct ath12k_hw *ah[MAX_RADIOS]; + u8 num_hw; }; /** @@ -826,15 +836,6 @@ struct ath12k_base { struct ath12k_pdev __rcu *pdevs_active[MAX_RADIOS]; - /* Holds information of wiphy (hw) registration. - * - * In Multi/Single Link Operation case, all pdevs are registered as - * a single wiphy. In other (legacy/Non-MLO) cases, each pdev is - * registered as separate wiphys. - */ - struct ath12k_hw *ah[MAX_RADIOS]; - u8 num_hw; - struct ath12k_wmi_hal_reg_capabilities_ext_arg hal_reg_cap[MAX_RADIOS]; unsigned long long free_vdev_map; unsigned long long free_vdev_stats_id_map; @@ -1090,18 +1091,18 @@ static inline struct ieee80211_hw *ath12k_ar_to_hw(struct ath12k *ar) static inline struct ath12k_hw *ath12k_ab_to_ah(struct ath12k_base *ab, int idx) { - return ab->ah[idx]; + return ab->ag->ah[idx]; } static inline void ath12k_ab_set_ah(struct ath12k_base *ab, int idx, struct ath12k_hw *ah) { - ab->ah[idx] = ah; + ab->ag->ah[idx] = ah; } static inline int ath12k_get_num_hw(struct ath12k_base *ab) { - return ab->num_hw; + return ab->ag->num_hw; } static inline diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index ada4569fbff4..256095042948 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -8872,19 +8872,13 @@ static void ath12k_mac_setup(struct ath12k *ar) clear_bit(ATH12K_FLAG_MONITOR_ENABLED, &ar->monitor_flags); } -int ath12k_mac_register(struct ath12k_base *ab) +int ath12k_mac_register(struct ath12k_hw_group *ag) { + struct ath12k_base *ab = ag->ab[0]; struct ath12k_hw *ah; int i; int ret; - if (test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags)) - return 0; - - /* Initialize channel counters frequency value in hertz */ - ab->cc_freq_hz = 320000; - ab->free_vdev_map = (1LL << (ab->num_radios * TARGET_NUM_VDEVS)) - 1; - for (i = 0; i < ath12k_get_num_hw(ab); i++) { ah = ath12k_ab_to_ah(ab, i); @@ -8908,8 +8902,9 @@ int ath12k_mac_register(struct ath12k_base *ab) return ret; } -void ath12k_mac_unregister(struct ath12k_base *ab) +void ath12k_mac_unregister(struct ath12k_hw_group *ag) { + struct ath12k_base *ab = ag->ab[0]; struct ath12k_hw *ah; int i; @@ -8970,18 +8965,24 @@ static struct ath12k_hw *ath12k_mac_hw_allocate(struct ath12k_base *ab, return ah; } -void ath12k_mac_destroy(struct ath12k_base *ab) +void ath12k_mac_destroy(struct ath12k_hw_group *ag) { struct ath12k_pdev *pdev; - struct ath12k_hw *ah; + struct ath12k_base *ab = ag->ab[0]; int i; + struct ath12k_hw *ah; - for (i = 0; i < ab->num_radios; i++) { - pdev = &ab->pdevs[i]; - if (!pdev->ar) + for (i = 0; i < ag->num_devices; i++) { + ab = ag->ab[i]; + if (!ab) continue; - pdev->ar = NULL; + for (i = 0; i < ab->num_radios; i++) { + pdev = &ab->pdevs[i]; + if (!pdev->ar) + continue; + pdev->ar = NULL; + } } for (i = 0; i < ath12k_get_num_hw(ab); i++) { @@ -8994,20 +8995,46 @@ void ath12k_mac_destroy(struct ath12k_base *ab) } } -int ath12k_mac_allocate(struct ath12k_base *ab) +static void ath12k_set_device_defaults(struct ath12k_base *ab) +{ + /* Initialize channel counters frequency value in hertz */ + ab->cc_freq_hz = 320000; + ab->free_vdev_map = (1LL << (ab->num_radios * TARGET_NUM_VDEVS)) - 1; + ath12k_dp_pdev_pre_alloc(ab); +} + +int ath12k_mac_allocate(struct ath12k_hw_group *ag) { struct ath12k_hw *ah; + struct ath12k_base *ab; struct ath12k_pdev_map pdev_map[MAX_RADIOS]; int ret, i, j; u8 radio_per_hw; + int mac_id, device_id; + int total_radio, num_hw; - if (test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags)) - return 0; + total_radio = 0; + for (i = 0; i < ag->num_devices; i++) + total_radio += ag->ab[i]->num_radios; - ab->num_hw = ab->num_radios; + /* All pdev get combined and register as single wiphy based on + * hardware group which participate in multi-link operation else + * each pdev get register separately. + * + * Currently, registering as single pdevs. + */ radio_per_hw = 1; + num_hw = total_radio / radio_per_hw; + + if (WARN_ON(num_hw >= ATH12K_GROUP_MAX_RADIO)) + return -ENOSPC; + + ag->num_hw = 0; + device_id = 0; + mac_id = 0; + for (i = 0; i < num_hw; i++) { + ab = ag->ab[device_id]; - for (i = 0; i < ath12k_get_num_hw(ab); i++) { for (j = 0; j < radio_per_hw; j++) { pdev_map[j].ab = ab; pdev_map[j].pdev_idx = (i * radio_per_hw) + j; @@ -9021,11 +9048,19 @@ int ath12k_mac_allocate(struct ath12k_base *ab) goto err; } - ath12k_ab_set_ah(ab, i, ah); + mac_id++; + /* If mac_id falls beyond the current device MACs then + * move to next device + */ + if (mac_id >= ab->num_radios) { + device_id++; + mac_id = 0; + ath12k_set_device_defaults(ab); + } + ag->ah[i] = ah; + ag->num_hw++; } - ath12k_dp_pdev_pre_alloc(ab); - return 0; err: diff --git a/drivers/net/wireless/ath/ath12k/mac.h b/drivers/net/wireless/ath/ath12k/mac.h index 69fd282b9dd3..f0ea0b5f50e4 100644 --- a/drivers/net/wireless/ath/ath12k/mac.h +++ b/drivers/net/wireless/ath/ath12k/mac.h @@ -13,6 +13,7 @@ struct ath12k; struct ath12k_base; struct ath12k_hw; +struct ath12k_hw_group; struct ath12k_pdev_map; struct ath12k_generic_iter { @@ -50,10 +51,10 @@ enum ath12k_supported_bw { extern const struct htt_rx_ring_tlv_filter ath12k_mac_mon_status_filter_default; -void ath12k_mac_destroy(struct ath12k_base *ab); -void ath12k_mac_unregister(struct ath12k_base *ab); -int ath12k_mac_register(struct ath12k_base *ab); -int ath12k_mac_allocate(struct ath12k_base *ab); +void ath12k_mac_destroy(struct ath12k_hw_group *ag); +void ath12k_mac_unregister(struct ath12k_hw_group *ag); +int ath12k_mac_register(struct ath12k_hw_group *ag); +int ath12k_mac_allocate(struct ath12k_hw_group *ag); int ath12k_mac_hw_ratecode_to_legacy_rate(u8 hw_rc, u8 preamble, u8 *rateidx, u16 *rate); u8 ath12k_mac_bitrate_to_idx(const struct ieee80211_supported_band *sband, -- 2.34.1