From patchwork Thu Mar 28 07:29:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karthikeyan Periyasamy X-Patchwork-Id: 13608065 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F8904E1D1 for ; Thu, 28 Mar 2024 07:30:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711611018; cv=none; b=aOi9bsOP28PWb/YI+qHGxL0Te5+Q7N4tWQ16utRUnRJ+mFQjpAkWCbB93/Eut0F1jpazmUZel0RdWKDX7GPWDbkDQA6laWYfJEYrmbiBLc//XACwKlZiC0F0Gwww05ONIOz3XA43pVQHQdf4DDHNlG8NuIjN++hXGCVuEjXCbZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711611018; c=relaxed/simple; bh=yuFCxM2KrYFnO9kHj8KW9Y6PTLlOFvICfyJNhddE6aE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rXJ/omxJUTMCXAnSLIdohIw6O+dhkQBpwQIP/977tW23gq708+51ZlPIKJkIMnJxqqFCgQpOEapN4wCAZaO3QHFgD3l9O7E+CPtXmZDQCnuj2uJmjdAz+BHTDq7bQQTgIKpey0ZSzA//cu3yaKRX8CBUIyJLaPGPXOQCzsEpqDw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=UxQcZTOq; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="UxQcZTOq" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42S52okD008246; Thu, 28 Mar 2024 07:30:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=sf7XQrn8OOpzfAnWC78Bzf3fNIIO26Kb7m5W2QlOTsU=; b=Ux QcZTOqM9vggr+9yIjmOzn7nn9aFVaA16PysK8iuDfpAxwHN5PMG4yAdj6iIIUzf4 rnPeP+X+DKmFz9yJ5EXTRAg+20CPOoR8WjCcNsDFwX54E6W6pzCyChakLBDqE80m zBbKRMSiIC9ITs6rck1UeMdLhG0rM4bCsdflpN5aWXYbdWNegcSxVIQSq2Eb8GaC jWAvobYTU5XzaE+ohmsgsHt+7wnjBsOo3oyNNC5ocy5OV8bo4rVgCOD0PXNvo4HZ /tSNwImoZ1hmgQ+UMT44f0RfktwKrcOb8S+vzgv005eRs6t/IeegG39ABtHufOYL Q1bHjsO7xH7lLadReICw== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x4u1wjb2v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:30:08 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42S7TjQj012638 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:29:45 GMT Received: from hu-periyasa-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 28 Mar 2024 00:29:43 -0700 From: Karthikeyan Periyasamy To: , CC: , Vasanthakumar Thiagarajan , Karthikeyan Periyasamy Subject: [PATCH 01/13] wifi: cfg80211: Add provision to advertise multiple radio in one wiphy Date: Thu, 28 Mar 2024 12:59:04 +0530 Message-ID: <20240328072916.1164195-2-quic_periyasa@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328072916.1164195-1-quic_periyasa@quicinc.com> References: <20240328072916.1164195-1-quic_periyasa@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: iC8DXTC_-GQr-yHgugZ9RYewSFrPLKWm X-Proofpoint-ORIG-GUID: iC8DXTC_-GQr-yHgugZ9RYewSFrPLKWm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_06,2024-03-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 impostorscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403210001 definitions=main-2403280048 From: Vasanthakumar Thiagarajan As originally discussed in the RFC [1], the prerequisite for MLO support in cfg80211/mac80211 is that all the links participating in MLO must belong to the same wiphy/ieee80211_hw. To meet this expectation, some drivers may need to group multiple discrete hardware, each acting as a link in MLO, under one wiphy. Though most of the hardware abstractions must be handled within the driver itself, it may be required to have some sort of mapping while describing interface combination capabilities for each of the underlying hardware. Add an advertisement provision for drivers supporting such MLO mode of operation. Capability advertisement such as the number of supported channels for each physical hardware has been identified to support some of the common use cases. [1]: https://lore.kernel.org/linux-wireless/20220920100518.19705-2-quic_vthiagar@quicinc.com/ Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00188-QCAHKSWPL_SILICONZ-1 Signed-off-by: Vasanthakumar Thiagarajan Co-developed-by: Karthikeyan Periyasamy Signed-off-by: Karthikeyan Periyasamy --- include/net/cfg80211.h | 24 ++++++++++ net/wireless/core.c | 100 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 2e2be4fd2bb6..dde129e61b60 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -5394,6 +5394,18 @@ struct wiphy_iftype_akm_suites { #define CFG80211_HW_TIMESTAMP_ALL_PEERS 0xffff +/** + * struct ieee80211_chans_per_hw - supported channels as per the + * underlying physical hardware configuration + * + * @n_chans: number of channels in @chans + * @chans: list of channels supported by the constituent hardware + */ +struct ieee80211_chans_per_hw { + u32 n_chans; + struct ieee80211_channel chans[]; +}; + /** * struct wiphy - wireless hardware description * @mtx: mutex for the data (structures) of this device @@ -5610,6 +5622,15 @@ struct wiphy_iftype_akm_suites { * A value of %CFG80211_HW_TIMESTAMP_ALL_PEERS indicates the driver * supports enabling HW timestamping for all peers (i.e. no need to * specify a mac address). + * + * @hw_chans: list of the channels supported by every constituent underlying + * hardware. Drivers abstracting multiple discrete hardware (radio) under + * one wiphy can advertise the list of channels supported by each physical + * hardware in this list. Underlying hardware specific channel list can be + * used while describing interface combination for each of them. + * @num_hw: number of underlying hardware for which the channels list are + * advertised in @hw_chans, 0 if multi hardware is not support. Expect >2 + * if multi hardware is support. */ struct wiphy { struct mutex mtx; @@ -5760,6 +5781,9 @@ struct wiphy { u16 hw_timestamp_max_peers; + struct ieee80211_chans_per_hw **hw_chans; + u8 num_hw; + char priv[] __aligned(NETDEV_ALIGN); }; diff --git a/net/wireless/core.c b/net/wireless/core.c index 3fb1b637352a..119937d0f2e0 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -690,6 +690,103 @@ static int wiphy_verify_combinations(struct wiphy *wiphy) return 0; } +static int cfg80211_check_hw_chans(const struct ieee80211_chans_per_hw *chans1, + const struct ieee80211_chans_per_hw *chans2) +{ + int i, j; + + if (!chans1 || !chans2) + return -EINVAL; + + if (!chans1->n_chans || !chans2->n_chans) + return -EINVAL; + + /* for now same channel is not allowed in more than one + * physical hardware. + */ + for (i = 0; i < chans1->n_chans; i++) + for (j = 0; j < chans2->n_chans; j++) + if (chans1->chans[i].center_freq == + chans2->chans[j].center_freq) + return -EINVAL; + return 0; +} + +static bool +cfg80211_hw_chans_in_supported_list(struct wiphy *wiphy, + const struct ieee80211_chans_per_hw *chans) +{ + enum nl80211_band band; + struct ieee80211_supported_band *sband; + int i, j; + + for (i = 0; i < chans->n_chans; i++) { + bool found = false; + + for (band = 0; band < NUM_NL80211_BANDS; band++) { + sband = wiphy->bands[band]; + if (!sband) + continue; + for (j = 0; j < sband->n_channels; j++) { + if (chans->chans[i].center_freq == + sband->channels[j].center_freq) { + found = true; + break; + } + } + + if (found) + break; + } + + if (!found) + return false; + } + + return true; +} + +static int cfg80211_validate_per_hw_chans(struct wiphy *wiphy) +{ + int i, j; + int ret; + + if (!wiphy->num_hw) + return 0; + + if (!wiphy->hw_chans) + return -EINVAL; + + /* advertisement of supported channels in wiphy->bands should be + * sufficient when physical hardware is one. + */ + if (wiphy->num_hw < 2) + return -EINVAL; + + for (i = 0; i < wiphy->num_hw; i++) { + for (j = i + 1; j < wiphy->num_hw; j++) { + const struct ieee80211_chans_per_hw *hw_chans1; + const struct ieee80211_chans_per_hw *hw_chans2; + + hw_chans1 = wiphy->hw_chans[i]; + hw_chans2 = wiphy->hw_chans[j]; + ret = cfg80211_check_hw_chans(hw_chans1, hw_chans2); + if (ret) + return ret; + } + } + + for (i = 0; i < wiphy->num_hw; i++) { + const struct ieee80211_chans_per_hw *hw_chans; + + hw_chans = wiphy->hw_chans[i]; + if (!cfg80211_hw_chans_in_supported_list(wiphy, hw_chans)) + return -EINVAL; + } + + return 0; +} + int wiphy_register(struct wiphy *wiphy) { struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); @@ -927,6 +1024,9 @@ int wiphy_register(struct wiphy *wiphy) return -EINVAL; } + if (WARN_ON(cfg80211_validate_per_hw_chans(&rdev->wiphy))) + return -EINVAL; + for (i = 0; i < rdev->wiphy.n_vendor_commands; i++) { /* * Validate we have a policy (can be explicitly set to From patchwork Thu Mar 28 07:29:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karthikeyan Periyasamy X-Patchwork-Id: 13608058 X-Patchwork-Delegate: johannes@sipsolutions.net 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 2BBD22561F for ; Thu, 28 Mar 2024 07:29:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711610996; cv=none; b=dyY8woVRq7O3XaJvocrBF0cC9RNDJxKFK1gWAdUiIiIMgp7ue77lqy7tkEoJYDRAnJ/uD0A6kPg6dWXX6VFshbLRu8nfBC1qUidEmr08m8oRS4umqB0aHfPzRVUBhROvABgRwIq9Yw3oOLZLdfHsaMhajMqzQnkOlllmGdmy9qY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711610996; c=relaxed/simple; bh=kkhe/Ekhfg39O5N45xmWkwhiq40y3S8mBwzZQZFDlOo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZFQGR5stlz36fIqXq5OgkTqvvHpCdJqzbSU2GcoES1cD2qonDvJC/fN3I5xV0loHzp4p9TDplHI4Y4S2lGixdd+haV64FVXVOD5NSxJy2Y39dwMeTza3ysLDknSh6WKiKF6XY9E5D2ntNJCeYlgnIho+zfNj7s9g9ftl9U5DDr4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=WdnrgXYR; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="WdnrgXYR" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42S2kSln015207; Thu, 28 Mar 2024 07:29:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=UaH4fMBk+JQl0hAOLd24qlZKav6+aNCUI7YTLNvxBs4=; b=Wd nrgXYRlZbhgYkBBm4F4zAgG8L84DTW2kd8vCRgObryGFJgDh2+dIbLiHGHuk/fpD tzv42bWZJuLz7dz3ZxXxe0FMeQIz3w+IbbtRz/qJbaAtMu4FihjBlPlia+fAjWnm F5p/c/nY4VR5br16qxJ/flYpE+xEBFKQFLPolfWXPH5XJXcASo2PKbVPHgG4USlJ 0g/Y/+lhztDI6/5fcq3c/Lmab9dqKERKlhIpypzhse5yw4LDo+pgItS1Gquey4xO YKRVn9T0E9V2loS71fhcS5NFZCg5ekuzAdXuAlEMwHg40e+9eG2t1oa+e5icXo0r ho4/Zizfk4ID4He70XOw== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x4u1wjb7a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:29:48 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42S7TmYp000618 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:29:48 GMT Received: from hu-periyasa-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 28 Mar 2024 00:29:45 -0700 From: Karthikeyan Periyasamy To: , CC: , Vasanthakumar Thiagarajan , Karthikeyan Periyasamy Subject: [PATCH 02/13] wifi: nl80211: send underlying multi-hardware channel capabilities to user space Date: Thu, 28 Mar 2024 12:59:05 +0530 Message-ID: <20240328072916.1164195-3-quic_periyasa@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328072916.1164195-1-quic_periyasa@quicinc.com> References: <20240328072916.1164195-1-quic_periyasa@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: fMrZDl1MtlaHgYHUBoxzlprMN36AtsIb X-Proofpoint-ORIG-GUID: fMrZDl1MtlaHgYHUBoxzlprMN36AtsIb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_06,2024-03-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 malwarescore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403210001 definitions=main-2403280048 From: Vasanthakumar Thiagarajan As originally discussed in the RFC [1], when driver supports multiple physical hardware under one wiphy, wiphy->num_hw != 0, send per-hardware supported frequency list to user space. List of frequency are reported inside an index which identifies the hardware as in wiphy->hw_chans[]. This hardware index will be used in follow up patches to identify the interface combination capability for each of the underlying physical hardware abstracted under one wiphy. [1]: https://lore.kernel.org/linux-wireless/20220920100518.19705-3-quic_vthiagar@quicinc.com/ Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00188-QCAHKSWPL_SILICONZ-1 Signed-off-by: Vasanthakumar Thiagarajan Co-developed-by: Karthikeyan Periyasamy Signed-off-by: Karthikeyan Periyasamy --- include/uapi/linux/nl80211.h | 28 +++++++++++++++++++++ net/wireless/nl80211.c | 47 ++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index f917bc6c9b6f..c53c9f941663 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -2856,6 +2856,11 @@ enum nl80211_commands { * %NL80211_CMD_ASSOCIATE indicating the SPP A-MSDUs * are used on this connection * + * @NL80211_ATTR_MULTI_HW: nested attribute to send the hardware specific + * channel capabilities to user space. Drivers registering multiple + * physical hardware under a wiphy can use this attribute, + * see &enum nl80211_multi_hw_mac_attrs. + * * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use @@ -3401,6 +3406,8 @@ enum nl80211_attrs { NL80211_ATTR_ASSOC_SPP_AMSDU, + NL80211_ATTR_MULTI_HW, + /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, @@ -7999,4 +8006,25 @@ enum nl80211_ap_settings_flags { NL80211_AP_SETTINGS_SA_QUERY_OFFLOAD_SUPPORT = 1 << 1, }; +/** + * nl80211_multi_hw_attrs - multi-hw attributes + * + * @NL80211_MULTI_HW_ATTR_INVALID: invalid + * @NL80211_MULTI_HW_ATTR_IDX: (u8) multi-HW index to refer the underlying HW + * for which the supported channel list is advertised. Internally refer + * the index of the wiphy's @hw_chans array. + * @NL80211_MULTI_HW_ATTR_FREQS: array of supported center frequencies + * @__NL80211_MULTI_HW_ATTR_LAST: internal use + * @NL80211_MULTI_HW_ATTR_MAX: maximum multi-hw mac attribute + */ +enum nl80211_multi_hw_attrs { + __NL80211_MULTI_HW_ATTR_INVALID, + + NL80211_MULTI_HW_ATTR_IDX, + NL80211_MULTI_HW_ATTR_FREQS, + + /* keep last */ + __NL80211_MULTI_HW_ATTR_LAST, + NL80211_MULTI_HW_ATTR_MAX = __NL80211_MULTI_HW_ATTR_LAST - 1 +}; #endif /* __LINUX_NL80211_H */ diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index b4edba6b0b7b..2a5e395e2e0b 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -2392,6 +2392,47 @@ static int nl80211_put_mbssid_support(struct wiphy *wiphy, struct sk_buff *msg) return -ENOBUFS; } +static int nl80211_put_multi_hw_support(struct wiphy *wiphy, + struct sk_buff *msg) +{ + struct nlattr *hw_macs, *hw_mac; + struct nlattr *freqs; + int i, c; + + if (!wiphy->num_hw) + return 0; + + hw_macs = nla_nest_start(msg, NL80211_ATTR_MULTI_HW); + if (!hw_macs) + return -ENOBUFS; + + for (i = 0; i < wiphy->num_hw; i++) { + hw_mac = nla_nest_start(msg, i + 1); + if (!hw_mac) + return -ENOBUFS; + + if (nla_put_u8(msg, NL80211_MULTI_HW_ATTR_IDX, i)) + return -ENOBUFS; + + freqs = nla_nest_start(msg, + NL80211_MULTI_HW_ATTR_FREQS); + if (!freqs) + return -ENOBUFS; + + for (c = 0; c < wiphy->hw_chans[i]->n_chans; c++) + if (nla_put_u32(msg, c + 1, + wiphy->hw_chans[i]->chans[c].center_freq)) + return -ENOBUFS; + + nla_nest_end(msg, freqs); + + nla_nest_end(msg, hw_mac); + } + + nla_nest_end(msg, hw_macs); + return 0; +} + struct nl80211_dump_wiphy_state { s64 filter_wiphy; long start; @@ -3001,6 +3042,12 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, rdev->wiphy.hw_timestamp_max_peers)) goto nla_put_failure; + state->split_start++; + break; + case 17: + if (nl80211_put_multi_hw_support(&rdev->wiphy, msg)) + goto nla_put_failure; + /* done */ state->split_start = 0; break; From patchwork Thu Mar 28 07:29:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karthikeyan Periyasamy X-Patchwork-Id: 13608061 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A1A5524AD for ; Thu, 28 Mar 2024 07:30:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711611006; cv=none; b=k0M9fHUnPq300xUiP5Ml/g3bLlmAjYFQGWCZKmb2YA2Ul3xcbNCQe/x+hpruhppi96zp7ukrQzkPy5usKsP2srkVHoC43i0MUZbSGaUy3pp95eSbdQq6qYi84Wif3BlSYjSoJeo0xsgy3OAXuxgDILGOKLJ003lq2OePYy5RpQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711611006; c=relaxed/simple; bh=wgLANPldKFWvjWWSx8MEt+dxjQf79YYovr/AVlx5E54=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mSSyG78C/yFTzEiG8Z7EkGBQh6kNSqrwrWryieLzj15Soi/XUShf08v4T5P/cn33lgjr1vpyadqmVqr3NE9AIUwEqvYfhZbClzeWp5uFN1XYYuMNwPdj2Cpgcg06f6/XTnSHpZReqwv1l6nXpLa04BRJIKxc5CpA5mdUUjpqzdk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=DGTa5dxm; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="DGTa5dxm" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42S5Rmas031006; Thu, 28 Mar 2024 07:29:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=DxCSHKc0iSM7IkMD1RtvUkbD5Fho5ZLQQsfV5vV2cjU=; b=DG Ta5dxmNXDfXPP29jxEbMxIFLXN7bV9xNd7FMXVrNXhNZsTZVSbsbhfiyPrjExCoE tXXIL9BWhIpbwhJ5/SQxJlnrfxxUt8e2UWktikC48Jw27Lkxjbey3MtrYx/DONfW XK6zTuMbB49Q2cogJqyVBiIbwkH/89G5ZhWOnGOd+XniIc608D87dxt0XuLAMk7b hRf/ujD4EcJPw2gMJhcOcyUPBmAAMzf5uhIWJHBz8GY82zYZRwwKZ6D+aVBQzwkx xJOu12L893Pd24RcdySNwpTxVEbfSHu28WpE6tJG3bG07t7repa5JGZGXFXlNWea dRL6F2Pqo2lzSMgRQCEQ== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x4u20jcxk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:29:56 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42S7To87003640 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:29:50 GMT Received: from hu-periyasa-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 28 Mar 2024 00:29:48 -0700 From: Karthikeyan Periyasamy To: , CC: , Vasanthakumar Thiagarajan , Karthikeyan Periyasamy Subject: [PATCH 03/13] wifi: cfg80211: Refactor the interface combination limit check Date: Thu, 28 Mar 2024 12:59:06 +0530 Message-ID: <20240328072916.1164195-4-quic_periyasa@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328072916.1164195-1-quic_periyasa@quicinc.com> References: <20240328072916.1164195-1-quic_periyasa@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: Xn_imFvkmRJfKzvmRH7H_p4a_ZcTO1xl X-Proofpoint-GUID: Xn_imFvkmRJfKzvmRH7H_p4a_ZcTO1xl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_06,2024-03-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 priorityscore=1501 phishscore=0 malwarescore=0 mlxscore=0 mlxlogscore=970 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403210001 definitions=main-2403280048 From: Vasanthakumar Thiagarajan Move the interface combination limit check validation into a helper function. This will make the iface combination limit validation functionality more scalable for supporting multiple physical hardware interface combination. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00188-QCAHKSWPL_SILICONZ-1 Signed-off-by: Vasanthakumar Thiagarajan Co-developed-by: Karthikeyan Periyasamy Signed-off-by: Karthikeyan Periyasamy --- net/wireless/core.c | 114 +++++++++++++++++++++++++------------------- 1 file changed, 65 insertions(+), 49 deletions(-) diff --git a/net/wireless/core.c b/net/wireless/core.c index 119937d0f2e0..2b810855a805 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -600,10 +600,69 @@ struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv, } EXPORT_SYMBOL(wiphy_new_nm); +static int +wiphy_verify_comb_limit(struct wiphy *wiphy, + const struct ieee80211_iface_limit *limits, + u8 n_limits, u32 bcn_int_min_gcd, u32 *iface_cnt, + u16 *all_iftypes) +{ + int i; + + for (i = 0; i < n_limits; i++) { + u16 types = limits[i].types; + + /* Don't advertise an unsupported type + * in a combination. + */ + if (WARN_ON((wiphy->interface_modes & types) != types)) + return -EINVAL; + + if (WARN_ON(!limits[i].max)) + return -EINVAL; + + /* interface types shouldn't overlap */ + if (WARN_ON(types & *all_iftypes)) + return -EINVAL; + + *all_iftypes |= types; + + /* Shouldn't list software iftypes in combinations! */ + if (WARN_ON(wiphy->software_iftypes & types)) + return -EINVAL; + + /* Only a single P2P_DEVICE can be allowed */ + if (WARN_ON(types & BIT(NL80211_IFTYPE_P2P_DEVICE) && + limits[i].max > 1)) + return -EINVAL; + + /* Only a single NAN can be allowed */ + if (WARN_ON(types & BIT(NL80211_IFTYPE_NAN) && + limits[i].max > 1)) + return -EINVAL; + + /* This isn't well-defined right now. If you have an + * IBSS interface, then its beacon interval may change + * by joining other networks, and nothing prevents it + * from doing that. + * So technically we probably shouldn't even allow AP + * and IBSS in the same interface, but it seems that + * some drivers support that, possibly only with fixed + * beacon intervals for IBSS. + */ + if (WARN_ON(types & BIT(NL80211_IFTYPE_ADHOC) && + bcn_int_min_gcd)) + return -EINVAL; + + *iface_cnt += limits[i].max; + } + + return 0; +} + static int wiphy_verify_combinations(struct wiphy *wiphy) { const struct ieee80211_iface_combination *c; - int i, j; + int i, ret; for (i = 0; i < wiphy->n_iface_combinations; i++) { u32 cnt = 0; @@ -630,54 +689,11 @@ static int wiphy_verify_combinations(struct wiphy *wiphy) if (WARN_ON(!c->n_limits)) return -EINVAL; - for (j = 0; j < c->n_limits; j++) { - u16 types = c->limits[j].types; - - /* interface types shouldn't overlap */ - if (WARN_ON(types & all_iftypes)) - return -EINVAL; - all_iftypes |= types; - - if (WARN_ON(!c->limits[j].max)) - return -EINVAL; - - /* Shouldn't list software iftypes in combinations! */ - if (WARN_ON(wiphy->software_iftypes & types)) - return -EINVAL; - - /* Only a single P2P_DEVICE can be allowed */ - if (WARN_ON(types & BIT(NL80211_IFTYPE_P2P_DEVICE) && - c->limits[j].max > 1)) - return -EINVAL; - - /* Only a single NAN can be allowed */ - if (WARN_ON(types & BIT(NL80211_IFTYPE_NAN) && - c->limits[j].max > 1)) - return -EINVAL; - - /* - * This isn't well-defined right now. If you have an - * IBSS interface, then its beacon interval may change - * by joining other networks, and nothing prevents it - * from doing that. - * So technically we probably shouldn't even allow AP - * and IBSS in the same interface, but it seems that - * some drivers support that, possibly only with fixed - * beacon intervals for IBSS. - */ - if (WARN_ON(types & BIT(NL80211_IFTYPE_ADHOC) && - c->beacon_int_min_gcd)) { - return -EINVAL; - } - - cnt += c->limits[j].max; - /* - * Don't advertise an unsupported type - * in a combination. - */ - if (WARN_ON((wiphy->interface_modes & types) != types)) - return -EINVAL; - } + ret = wiphy_verify_comb_limit(wiphy, c->limits, c->n_limits, + c->beacon_int_min_gcd, + &cnt, &all_iftypes); + if (ret) + return ret; if (WARN_ON(all_iftypes & BIT(NL80211_IFTYPE_WDS))) return -EINVAL; From patchwork Thu Mar 28 07:29:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Karthikeyan Periyasamy X-Patchwork-Id: 13608068 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59E4452F96 for ; Thu, 28 Mar 2024 07:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711611021; cv=none; b=ePBKAnKIpZeqsSSEVrfZ1YSmK+tckQSgPO5f6x65coVXg45lousY4/fh75pXe+oaSxCxStp5sRqHD/BTyo5OkVtkiJy6Xlht4KxhmAlo33kEC9pB6nqzMgfBZl3a78Rd1V9pt8Ezy4jUIjtGIMOLfBRs9UOCpWuukDLmGzNRrIY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711611021; c=relaxed/simple; bh=qdM8CKRYFSCyshP+cMf59eT93klHlq7hXGwWaAUtRoE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MaUQ3jWYjysLsLZfQ+RIqNV6pHfqFituZ9VlPtgcvoza7OzO0JDd3nrixxvZYlcbjHLY6qfSK19QhJxyn72iXwzHJzWeI5QazMBD5zpGdowkFgVA+9Ed6ANrxp92FwTyRZbeFA1mfk54iZ6nP/49DnE4NaQCSwiaJhqGlxzJ32A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=lDJoto8E; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="lDJoto8E" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42S4fvOO028796; Thu, 28 Mar 2024 07:30:08 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-type:content-transfer-encoding; s= qcppdkim1; bh=mY1WVvWUa3DboJH7ADBJXhfPU1+y1DUVM8FJmgvcp5c=; b=lD Joto8EKp/iWLahwxY9QwfJo8AM0RDDdnABZm59tpMh2wQ88Vjjuj48iGyxvMcmwL P0Ps0QpbKcrZ8RIP8i7E+eOwNokDZtzOuOnZpFqYvbJg9RINAizRk2CVqOHPlUcu LvahHjGN/yuoano/iFitIhWhwQjCpidRyPq1AffOsS6stjRcyhIbBjk9wleAR/ON NR2YogFt/oM7wjBztupakgz3Y2OAOrvTgdhmTbrioM63qtYFtmAQlUvlHyqCw3Wl t0njH5hobSUQTKR9zwIt4lXnd/SYJo8RLzdDEhtBVRwpiaMzs2t0kzOBZt2AbF2I T4sbqbfZUurgkAjHFhTQ== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x4u1wjb37-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:30:08 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42S7Tq5C003687 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:29:52 GMT Received: from hu-periyasa-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 28 Mar 2024 00:29:50 -0700 From: Karthikeyan Periyasamy To: , CC: , Vasanthakumar Thiagarajan , Karthikeyan Periyasamy Subject: [PATCH 04/13] wifi: cfg80211/mac80211: extend iface comb advertisement for multi-hardware dev Date: Thu, 28 Mar 2024 12:59:07 +0530 Message-ID: <20240328072916.1164195-5-quic_periyasa@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328072916.1164195-1-quic_periyasa@quicinc.com> References: <20240328072916.1164195-1-quic_periyasa@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 0fbya7M05UqIpQYjoHfhDZLh47dPUnuS X-Proofpoint-ORIG-GUID: 0fbya7M05UqIpQYjoHfhDZLh47dPUnuS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_06,2024-03-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 impostorscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403210001 definitions=main-2403280048 From: Vasanthakumar Thiagarajan As originally discussed in the RFC [1], when a driver combines multiple discrete hardware under one wiphy, it is required for the driver to be able to advertise iface combination capabilities per underlying physical hardware. Each underlying hardware's iface combination is described with an identifier, which corresponds to the same index used in wiphy->hw_chans[] to learn the channel capabilities of the respective hardware. It’s important to note that supporting drivers also signal the iface combination capabilities that are common for all the hardware through the existing interface, maintaining backward compatibility with user space. This commit implements provisions to advertise per-physical hardware specific iface combination capabilities and includes sanity checks on the advertised capabilities. The sanity check includes channel validation against the entire range of DFS frequencies, irrespective of regulatory configurations. Example: Say driver abstracts two discrete hardware under one wiphy, wiphy->hw_chans[0] supporting 2 GHz and wiphy->hw_chans[1] supporting 5 GHz. Each hardware can operate on only one channel at any given time but under the wiphy there can be concurrent interfaces on both the radios. 2 GHz hardware supports #STA <= 1, #AP <= 3 total 4 and 5 GHz hardware supports #STA <= 1, #AP <= 4 total 5 struct ieee80211_iface_limit limits_common[] = { { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), }, { .max = 3, .types = BIT(NL80211_IFTYPE_AP), }, }; limits_common[] defines the minimum (common) capability out of all the underlying hardware specific capabilities. This is reported in the existing advertisement mechanism. Common max_interfaces across 2 GHz and 5 GHz is 4, common num_different_channels is 1. struct ieee80211_iface_limit limits_2ghz[] = { { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), }, { .max = 3, .types = BIT(NL80211_IFTYPE_AP), }, }; struct ieee80211_iface_limit limits_5ghz[] = { { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), }, { .max = 4, .types = BIT(NL80211_IFTYPE_AP), }, }; struct ieee80211_iface_combination combination = { .limits = limits_common, .max_interfaces = 4, .num_different_channels = 1, ... .freq_range = { { .hw_chan_idx = 0, .limits = limits_2ghz, .max_interfaces = 4, .num_different_channels = 1, .n_limits = ARRAY_SIZE(limits_2ghz), }, { .hw_chan_idx = 1, .limits = limits_5ghz, .max_interfaces = 5, .num_different_channels = 1, .n_limits = ARRAY_SIZE(limits_5ghz), }, }, }; [1]: https://lore.kernel.org/linux-wireless/20220920100518.19705-4-quic_vthiagar@quicinc.com/ Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00188-QCAHKSWPL_SILICONZ-1 Signed-off-by: Vasanthakumar Thiagarajan Co-developed-by: Karthikeyan Periyasamy Signed-off-by: Karthikeyan Periyasamy --- include/net/cfg80211.h | 96 ++++++++++++++++++++++++++++++++++++++++++ net/mac80211/main.c | 46 ++++++++++++++++++++ net/wireless/core.c | 92 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 234 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index dde129e61b60..491d074fe430 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -5030,6 +5030,32 @@ struct ieee80211_iface_limit { u16 types; }; +/** + * struct ieee80211_iface_per_hw - hardware specific interface combination + * + * Drivers registering multiple radios under a single wiphy can advertise + * radio specific interface combinations through this structure. Please note + * that to maintain the compatibility with the user space which is not aware + * of this extension of per-hardware interface combination signaling, + * the driver should still advertise it's interface combination (mostly + * common minimum capability) using the existing interface combination signaling + * method. + * + * @limits: limits for the given interface type + * @num_different_channels: number of different channels which can be active + * concurrently in this hardware + * @max_interfaces: maximum number of total interfaces allowed in this group + * @n_limits: number of limitations + * @hw_chans_idx: index of hardware specific channel list as per wiphy @hw_chans + */ +struct ieee80211_iface_per_hw { + const struct ieee80211_iface_limit *limits; + u32 num_different_channels; + u16 max_interfaces; + u8 n_limits; + u8 hw_chans_idx; +}; + /** * struct ieee80211_iface_combination - possible interface combination * @@ -5088,6 +5114,62 @@ struct ieee80211_iface_limit { * .num_different_channels = 2, * }; * + * + * 4. Hardware specific interface combination with driver supporting two + * physical HW, first underlying HW supporting 2 GHz band and the other + * supporting 5 GHz band. + * + * Allow #STA <= 1, #AP <= 1, channels = 1, total 2 in 2 GHz radio and + * + * Allow #STA <= 1, #AP <= 2, channels = 1, total 3 in 5 GHz radio + * + * Drivers advertising per-hardware interface combination should also + * advertise a sub-set of capabilities using existing interface mainly for + * maintaining compatibility with the user space which is not aware of the + * new per-hardware advertisement. + * + * Sub-set interface combination advertised in the existing infrastructure: + * Allow #STA <= 1, #AP <= 1, channels = 1, total 2 + * + * .. code-block:: c + * + * struct ieee80211_iface_limit limits_overall[] = { + * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), }, + * { .max = 1, .types = BIT(NL80211_IFTYPE_AP), }, + * }; + * struct ieee80211_iface_limit limits_2ghz[] = { + * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), }, + * { .max = 1, .types = BIT(NL80211_IFTYPE_AP), }, + * }; + * struct ieee80211_iface_limit limits_5ghz[] = { + * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), }, + * { .max = 2, .types = BIT(NL80211_IFTYPE_AP), }, + * }; + * struct ieee80211_iface_per_hw hw_combinations[] = { + * { + * .hw_chans_idx = 0, + * .limits = limits_2ghz, + * .num_different_channels = 1, + * .max_interfaces = 2, + * .n_limits = ARRAY_SIZE(limits_2ghz), + * }, + * { + * .hw_chans_idx = 1, + * .limits = limits_5ghz, + * .num_different_channels = 1, + * .max_interfaces = 3, + * .n_limits = ARRAY_SIZE(limits_5ghz), + * }, + * }; + * struct ieee80211_iface_combination combination4 = { + * .limits = limits_overall, + * .n_limits = ARRAY_SIZE(limits_overall), + * .max_interfaces = 2, + * .num_different_channels = 1, + * .iface_hw_list = hw_combinations, + * .n_hw_list = ARRAY_SIZE(hw_combinations), + * }; + * */ struct ieee80211_iface_combination { /** @@ -5145,6 +5227,20 @@ struct ieee80211_iface_combination { * combination must be greater or equal to this value. */ u32 beacon_int_min_gcd; + + /** + * @iface_hw_list: + * This wiphy has multiple underlying radios, describe interface + * combination for each of them, valid only when the driver advertises + * multi-radio presence in wiphy @hw_chans. + */ + const struct ieee80211_iface_per_hw *iface_hw_list; + + /** + * @n_hw_list: + * number of hardware in @iface_hw_List + */ + u32 n_hw_list; }; struct ieee80211_txrx_stypes { diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 4eaea0a9975b..24765ab5121b 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -1083,6 +1083,46 @@ static int ieee80211_init_cipher_suites(struct ieee80211_local *local) return 0; } +static int +ieee80211_check_per_hw_iface_comb(struct ieee80211_local *local, + const struct ieee80211_iface_combination *c) +{ + int hw_idx, lmt_idx; + u32 hw_idx_bm = 0; + + if (!local->hw.wiphy->num_hw) + return -EINVAL; + + if (local->emulate_chanctx) + return -EINVAL; + + for (hw_idx = 0; hw_idx < c->n_hw_list; hw_idx++) { + const struct ieee80211_iface_per_hw *hl; + + hl = &c->iface_hw_list[hw_idx]; + + if (hl->hw_chans_idx >= local->hw.wiphy->num_hw) + return -EINVAL; + + /* mac80211 doesn't support more than one IBSS interface right now */ + for (lmt_idx = 0; lmt_idx < hl->n_limits; lmt_idx++) { + const struct ieee80211_iface_limit *limits; + + limits = &hl->limits[lmt_idx]; + if ((limits->types & BIT(NL80211_IFTYPE_ADHOC)) && + limits->max > 1) + return -EINVAL; + } + + if (hw_idx_bm & BIT(hw_idx)) + return -EINVAL; + + hw_idx_bm |= BIT(hw_idx); + } + + return 0; +} + int ieee80211_register_hw(struct ieee80211_hw *hw) { struct ieee80211_local *local = hw_to_local(hw); @@ -1323,6 +1363,12 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) if ((c->limits[j].types & BIT(NL80211_IFTYPE_ADHOC)) && c->limits[j].max > 1) return -EINVAL; + + if (!c->n_hw_list) + continue; + + if (ieee80211_check_per_hw_iface_comb(local, c)) + return -EINVAL; } local->int_scan_req = kzalloc(sizeof(*local->int_scan_req) + diff --git a/net/wireless/core.c b/net/wireless/core.c index 2b810855a805..88de2839ed6b 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -600,6 +600,34 @@ struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv, } EXPORT_SYMBOL(wiphy_new_nm); +/** + * cfg80211_hw_chans_includes_dfs - check if per-hardware channel includes DFS + * @chans: hardware channel list + * + * Check if the given per-hardware list include channels in DFS range. + * Please note the channel is checked against the entire range of DFS + * freq in 5 GHz irrespective of regulatory configurations. + * + * This helper helps for the sanity checks on the channel advertisement from + * driver during the hw registration. + */ +static bool +cfg80211_hw_chans_includes_dfs(const struct ieee80211_chans_per_hw *chans) +{ + int i; + + for (i = 0; i < chans->n_chans; i++) { + if (chans->chans[i].band == NL80211_BAND_5GHZ && + ((chans->chans[i].center_freq >= 5250 && + chans->chans[i].center_freq <= 5340) || + (chans->chans[i].center_freq >= 5480 && + chans->chans[i].center_freq <= 5720))) + return true; + } + + return false; +} + static int wiphy_verify_comb_limit(struct wiphy *wiphy, const struct ieee80211_iface_limit *limits, @@ -659,6 +687,63 @@ wiphy_verify_comb_limit(struct wiphy *wiphy, return 0; } +static int +wiphy_verify_comb_per_hw(struct wiphy *wiphy, + const struct ieee80211_iface_combination *comb) +{ + int i; + u32 hw_idx_bitmap = 0; + int ret; + + for (i = 0; i < comb->n_hw_list; i++) { + const struct ieee80211_iface_per_hw *hl; + const struct ieee80211_chans_per_hw *chans; + u32 iface_cnt = 0; + u16 all_iftypes = 0; + + hl = &comb->iface_hw_list[i]; + + if (hl->hw_chans_idx >= wiphy->num_hw) + return -EINVAL; + + if (hw_idx_bitmap & BIT(hl->hw_chans_idx)) + return -EINVAL; + + hw_idx_bitmap |= BIT(hl->hw_chans_idx); + chans = wiphy->hw_chans[hl->hw_chans_idx]; + + if (WARN_ON(hl->max_interfaces < 2 && + (!comb->radar_detect_widths || + !(cfg80211_hw_chans_includes_dfs(chans))))) + return -EINVAL; + + if (WARN_ON(!hl->num_different_channels)) + return -EINVAL; + + if (WARN_ON(comb->radar_detect_widths && + cfg80211_hw_chans_includes_dfs(chans) && + hl->num_different_channels > 1)) + return -EINVAL; + + if (WARN_ON(!hl->n_limits)) + return -EINVAL; + + ret = wiphy_verify_comb_limit(wiphy, hl->limits, hl->n_limits, + comb->beacon_int_min_gcd, + &iface_cnt, &all_iftypes); + if (ret) + return ret; + + if (WARN_ON(all_iftypes & BIT(NL80211_IFTYPE_WDS))) + return -EINVAL; + + if (WARN_ON(iface_cnt < comb->max_interfaces)) + return -EINVAL; + } + + return 0; +} + static int wiphy_verify_combinations(struct wiphy *wiphy) { const struct ieee80211_iface_combination *c; @@ -701,6 +786,13 @@ static int wiphy_verify_combinations(struct wiphy *wiphy) /* You can't even choose that many! */ if (WARN_ON(cnt < c->max_interfaces)) return -EINVAL; + + /* Do similar validations on the freq range specific interface + * combinations when advertised. + */ + if (WARN_ON(c->n_hw_list && + wiphy_verify_comb_per_hw(wiphy, c))) + return -EINVAL; } return 0; From patchwork Thu Mar 28 07:29:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karthikeyan Periyasamy X-Patchwork-Id: 13608059 X-Patchwork-Delegate: johannes@sipsolutions.net 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 69EC92561F for ; Thu, 28 Mar 2024 07:30: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=1711611002; cv=none; b=iWAOF1DTB1TTzV1uJpI0GYZkXmzzWQ+LpGev4uKMKsC14hDJDdaNdvHZzhQESpOo4Uugcp/HNJNiVQ2I5AcZExtqNuc5pO3NY0mqp2qJ1R8TzsX+/GD6F1E/F8SNODrjSWjYyEkTNbn4lo/me7m82BM5z0jd3ktciCFeC97M1bA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711611002; c=relaxed/simple; bh=JL2/Tm7BaG2V9sgAIKz8NpEvmKNda25iJuwGdwGHJBQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZUg6sOS8xlZPFbJcc/vwUUPOrzJVvenNluhDMucqSue11J42gdyYkOhr4e8r3irVXmY/Kddl+Ya3l00eGk2hLfva8hmsh4deUg92YRjRauWGwp2Jup3UgkVUB0pavNaVUgu2oOtsrxX3kUZQC1Cs/rZZE1RK7xBfrGtt3+cDbQA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=f+BRoVmp; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="f+BRoVmp" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42S6qjxR027529; Thu, 28 Mar 2024 07:29:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=UZbA36QIpM4yifccyxCOLoRUvteQcmHywRf1LnmTIx0=; b=f+ BRoVmpTgd+A5R35LdjWt0/rKHg+pbDrvJ9phtePA6cNtGNxgYWfONudMAU706Irz POAy9jfYVyo1KWyBAAiXfhose7+54yuMCaiMj6yqauS1d69FnDXFkrzVFUO5rIZX NibCo8xuhIRJnfEr1HdIT74DsNcx98yf2i14lIKaKESdZJ7ir7os+lQkozTb8TOp g3/Hzi8zG2GssFD6mA6tIb2Igf9kMHlmePL0cajqW1hCPStcltJSoK9i1F8yJFI/ 9GHgbM4ruV/l86GhUB68ZpQVFxfbMfmEWUP9LKYYKXQm3uDKlBkmDQuzGHaJmNni TvetS9XNp+Hpuwo2doKQ== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x53nxg4w0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:29:55 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42S7Ttrr003744 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:29:55 GMT Received: from hu-periyasa-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 28 Mar 2024 00:29:53 -0700 From: Karthikeyan Periyasamy To: , CC: , Vasanthakumar Thiagarajan , Karthikeyan Periyasamy Subject: [PATCH 05/13] wifi: nl80211: Refactor the interface combination limit check Date: Thu, 28 Mar 2024 12:59:08 +0530 Message-ID: <20240328072916.1164195-6-quic_periyasa@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328072916.1164195-1-quic_periyasa@quicinc.com> References: <20240328072916.1164195-1-quic_periyasa@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: KYxEzmzAXEVj4iWXi9RkaQgAtKeYEvuC X-Proofpoint-ORIG-GUID: KYxEzmzAXEVj4iWXi9RkaQgAtKeYEvuC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_06,2024-03-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 bulkscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 malwarescore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403210001 definitions=main-2403280048 From: Vasanthakumar Thiagarajan Move the nl80211 interface combination limit advertisement into a helper function. This will make the iface combination limit advertisement functionality more scalable for supporting multiple physical hardware interface combination. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00188-QCAHKSWPL_SILICONZ-1 Signed-off-by: Vasanthakumar Thiagarajan Co-developed-by: Karthikeyan Periyasamy Signed-off-by: Karthikeyan Periyasamy --- net/wireless/nl80211.c | 49 +++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 2a5e395e2e0b..37524a61f417 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -1622,12 +1622,43 @@ static int nl80211_put_iftypes(struct sk_buff *msg, u32 attr, u16 ifmodes) return -ENOBUFS; } +static int +nl80211_put_iface_limits(struct sk_buff *msg, + const struct ieee80211_iface_limit *limits, + u8 n_limits) +{ + int i; + + for (i = 0; i < n_limits; i++) { + struct nlattr *nl_limit; + + nl_limit = nla_nest_start_noflag(msg, i + 1); + if (!nl_limit) + goto nla_put_failure; + + if (nla_put_u32(msg, NL80211_IFACE_LIMIT_MAX, + limits[i].max)) + goto nla_put_failure; + + if (nl80211_put_iftypes(msg, NL80211_IFACE_LIMIT_TYPES, + limits[i].types)) + goto nla_put_failure; + + nla_nest_end(msg, nl_limit); + } + + return 0; + +nla_put_failure: + return -ENOBUFS; +} + static int nl80211_put_iface_combinations(struct wiphy *wiphy, struct sk_buff *msg, bool large) { struct nlattr *nl_combis; - int i, j; + int i; nl_combis = nla_nest_start_noflag(msg, NL80211_ATTR_INTERFACE_COMBINATIONS); @@ -1649,20 +1680,8 @@ static int nl80211_put_iface_combinations(struct wiphy *wiphy, if (!nl_limits) goto nla_put_failure; - for (j = 0; j < c->n_limits; j++) { - struct nlattr *nl_limit; - - nl_limit = nla_nest_start_noflag(msg, j + 1); - if (!nl_limit) - goto nla_put_failure; - if (nla_put_u32(msg, NL80211_IFACE_LIMIT_MAX, - c->limits[j].max)) - goto nla_put_failure; - if (nl80211_put_iftypes(msg, NL80211_IFACE_LIMIT_TYPES, - c->limits[j].types)) - goto nla_put_failure; - nla_nest_end(msg, nl_limit); - } + if (nl80211_put_iface_limits(msg, c->limits, c->n_limits)) + goto nla_put_failure; nla_nest_end(msg, nl_limits); From patchwork Thu Mar 28 07:29:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karthikeyan Periyasamy X-Patchwork-Id: 13608060 X-Patchwork-Delegate: johannes@sipsolutions.net 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 40A0C2561F for ; Thu, 28 Mar 2024 07:30:04 +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=1711611005; cv=none; b=M/X7M/e8khoMDTgMQ81iBTQ3oyW4r60hhJvd/rbm2/gAeXcIaeLPzzY1HGg08hmicrqDum7N7fQd8AX5nBNZFXD4iYEp4qC/WB5q/GuiqDflOphOMVEOSauN+Pp8M+EPnXv7N2nhIG4WYKTnkjqLyvEfsIa/GF1nFwW2sybQK2Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711611005; c=relaxed/simple; bh=98V+gNE2ku1GYZJ+TfuXi6ZGJRzuUymnDi5gHlAKa9Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RAvRtvvFaaZs1k4OxTD9W5+XNM10YCZ8GSPDCwx9OmsIii4IKJWiXYEEtNxfY2QST+sKlmyyQ+oCdGY4F4G6bxxyD1onWxIrNC7w3hP1T55yy6nOf14/1O6FQMpHk3YN1UD4BsBgi5wQz9tnqrPcQfhfRwA1T28w0B+u0vWniXg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=mBe9qt4t; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="mBe9qt4t" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42S6iX8A017470; Thu, 28 Mar 2024 07:29:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=RWPAWZS5q6QijauSiOmT/R9lEekKzDrnSghigim3D8w=; b=mB e9qt4tlHfgeDeESll4ymYKG/8m404H0hmHYMrcXvXSw3DRMQZNc7GJWNpY/nZaz4 rtopVJ9KAlSAtlO7Nuter/UbvJej+JLOWYfL8+0Me0UZlLAeFaNmW6Gzskfj/mRg pje1B7dm3TZ9WVu4yrLdoB4UOReMaca6o3TyCmzE50fj34rqfJgCMejz4kFFoalb WLntqe48UsF5vhVukpgeXIOFfN9WOTkTJksVv7YM4zt/C1T0/MYLLqS1pAB+Qx6E 8OxftLBHyZRwXS2d4s9iYrF7hwG60M6Z/LorWCnf3rkm5bUvLlRjPyFDCq5Z8iIG Fa1NT+GkNDFhc4fuDX9Q== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x4u1wjb83-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:29:58 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42S7TvKK001172 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:29:57 GMT Received: from hu-periyasa-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 28 Mar 2024 00:29:55 -0700 From: Karthikeyan Periyasamy To: , CC: , Vasanthakumar Thiagarajan , Karthikeyan Periyasamy Subject: [PATCH 06/13] wifi: nl80211: send iface combination to user space in multi-hardware wiphy Date: Thu, 28 Mar 2024 12:59:09 +0530 Message-ID: <20240328072916.1164195-7-quic_periyasa@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328072916.1164195-1-quic_periyasa@quicinc.com> References: <20240328072916.1164195-1-quic_periyasa@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: bGI7j-f7Ma6VzT_rySZUtLpTIQR0sOGS X-Proofpoint-ORIG-GUID: bGI7j-f7Ma6VzT_rySZUtLpTIQR0sOGS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_06,2024-03-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxscore=0 suspectscore=0 adultscore=0 mlxlogscore=864 spamscore=0 impostorscore=0 malwarescore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403210001 definitions=main-2403280048 From: Vasanthakumar Thiagarajan As originally discussed in the RFC [1], add a new nested attribute to the existing NL80211_CMD_NEW_WIPHY command. This attribute should advertise the iface combination capability for each underlying physical hardware device. This is necessary when the driver groups more than one physical hardware under single wiphy. [1]: https://lore.kernel.org/linux-wireless/20220920100518.19705-5-quic_vthiagar@quicinc.com/ Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00188-QCAHKSWPL_SILICONZ-1 Signed-off-by: Vasanthakumar Thiagarajan Co-developed-by: Karthikeyan Periyasamy Signed-off-by: Karthikeyan Periyasamy --- include/uapi/linux/nl80211.h | 50 ++++++++++++++++++++++++++++++- net/wireless/nl80211.c | 58 ++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index c53c9f941663..aa0988be1f2a 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -6004,6 +6004,10 @@ enum nl80211_iface_limit_attrs { * @NL80211_IFACE_COMB_BI_MIN_GCD: u32 attribute specifying the minimum GCD of * different beacon intervals supported by all the interface combinations * in this group (if not present, all beacon intervals be identical). + * @NL80211_IFACE_COMB_PER_HW_COMB: nested attribute specifying the interface + * combination for each underlying hardware when multiple hardware are + * registered under one wiphy, + * see &enum nl80211_if_comb_per_hw_comb_attrs. * @NUM_NL80211_IFACE_COMB: number of attributes * @MAX_NL80211_IFACE_COMB: highest attribute number * @@ -6020,7 +6024,19 @@ enum nl80211_iface_limit_attrs { * numbers = [ #{STA} <= 1, #{P2P-client,P2P-GO} <= 3 ], max = 4 * => allows a STA plus three P2P interfaces * - * The list of these four possibilities could completely be contained + * When describing per-hardware combinations in multi-hardware in + * one wiphy model, the first possibility can further include the finer + * capabilities like below + * hw_chan_idx = 0, numbers = [ #{STA} <= 1, #{AP} <= 1 ], + * channels = 1, max = 2 + * => allows a STA plus an AP interface on the underlying hardware mac + * advertised at index 0 in wiphy @hw_chans array. + * hw_chan_idx = 1, numbers = [ #{STA} <= 1, #{AP} <= 2 ], + * channels = 1, max = 3 + * => allows a STA plus two AP interfaces on the underlying hardware mac + * advertised at index 1 in wiphy @hw_chans array. + * + * The list of these five possibilities could completely be contained * within the %NL80211_ATTR_INTERFACE_COMBINATIONS attribute to indicate * that any of these groups must match. * @@ -6039,12 +6055,44 @@ enum nl80211_if_combination_attrs { NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS, NL80211_IFACE_COMB_RADAR_DETECT_REGIONS, NL80211_IFACE_COMB_BI_MIN_GCD, + NL80211_IFACE_COMB_PER_HW_COMB, /* keep last */ NUM_NL80211_IFACE_COMB, MAX_NL80211_IFACE_COMB = NUM_NL80211_IFACE_COMB - 1 }; +/** + * enum nl80211_if_comb_per_hw_comb_attrs - per-hardware iface combination + * attributes with multi-hw radios in one wiphy model + * + * @NL80211_IFACE_COMB_PER_HW_COMB_UNSPEC: (reserved) + * @NL80211_IFACE_COMB_PER_HW_COMB_HW_IDX: u8 attribute specifying the index + * to the wiphy @hw_chans list for which the iface combination is being + * described. + * @NL80211_IFACE_COMB_PER_HW_COMB_LIMITS: nested attribute containing the + * limits for the given interface types, see + * &enum nl80211_iface_limit_attrs. + * @NL80211_IFACE_COMB_PER_HW_COMB_MAXIMUM: u32 attribute giving the maximum + * number of interfaces that can be created in this group. This number + * does not apply to the interfaces purely managed in software. + * @NL80211_IFACE_COMB_PER_HW_COMB_NUM_CHANNELS: u32 attribute specifying the + * number of different channels that can be used in this group. + * @NUM_NL80211_IFACE_COMB_PER_HW_COMB: number of attributes + * @MAX_NL80211_IFACE_COMB_PER_HW_COMB: highest attribute number + */ +enum nl80211_if_comb_per_hw_comb_attrs { + NL80211_IFACE_COMB_PER_HW_COMB_UNSPEC, + NL80211_IFACE_COMB_PER_HW_COMB_HW_IDX, + NL80211_IFACE_COMB_PER_HW_COMB_LIMITS, + NL80211_IFACE_COMB_PER_HW_COMB_MAXIMUM, + NL80211_IFACE_COMB_PER_HW_COMB_NUM_CHANNELS, + + /* keep last */ + NUM_NL80211_IFACE_COMB_PER_HW_COMB, + MAX_NL80211_IFACE_COMB_PER_HW_COMB = + NUM_NL80211_IFACE_COMB_PER_HW_COMB - 1 +}; /** * enum nl80211_plink_state - state of a mesh peer link finite state machine diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 37524a61f417..87436924834f 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -1653,6 +1653,61 @@ nl80211_put_iface_limits(struct sk_buff *msg, return -ENOBUFS; } +static int +nl80211_put_per_hw_iface_combinations(struct wiphy *wiphy, struct sk_buff *msg, + const struct ieee80211_iface_combination *c) +{ + struct nlattr *hw_combis; + int i; + + if (!wiphy->num_hw) + return 0; + + hw_combis = nla_nest_start(msg, NL80211_IFACE_COMB_PER_HW_COMB); + if (!hw_combis) + return -ENOBUFS; + + for (i = 0; i < c->n_hw_list; i++) { + struct nlattr *hw_combi, *limits; + + hw_combi = nla_nest_start(msg, i + 1); + if (!hw_combi) + return -ENOBUFS; + + if (nla_put_u8(msg, NL80211_IFACE_COMB_PER_HW_COMB_HW_IDX, + c->iface_hw_list[i].hw_chans_idx)) + return -ENOBUFS; + + limits = nla_nest_start(msg, + NL80211_IFACE_COMB_PER_HW_COMB_LIMITS); + if (!limits) + return -ENOBUFS; + + if (nl80211_put_iface_limits(msg, + c->iface_hw_list[i].limits, + c->iface_hw_list[i].n_limits)) + return -ENOBUFS; + + nla_nest_end(msg, limits); + + if (nla_put_u32(msg, + NL80211_IFACE_COMB_PER_HW_COMB_NUM_CHANNELS, + c->iface_hw_list[i].num_different_channels)) + return -ENOBUFS; + + if (nla_put_u16(msg, + NL80211_IFACE_COMB_PER_HW_COMB_MAXIMUM, + c->iface_hw_list[i].max_interfaces)) + return -ENOBUFS; + + nla_nest_end(msg, hw_combi); + } + + nla_nest_end(msg, hw_combis); + + return 0; +} + static int nl80211_put_iface_combinations(struct wiphy *wiphy, struct sk_buff *msg, bool large) @@ -1704,6 +1759,9 @@ static int nl80211_put_iface_combinations(struct wiphy *wiphy, c->beacon_int_min_gcd)) goto nla_put_failure; + if (large && nl80211_put_per_hw_iface_combinations(wiphy, msg, c)) + goto nla_put_failure; + nla_nest_end(msg, nl_combi); } From patchwork Thu Mar 28 07:29:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karthikeyan Periyasamy X-Patchwork-Id: 13608062 X-Patchwork-Delegate: johannes@sipsolutions.net 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 E9DDF535C8 for ; Thu, 28 Mar 2024 07:30:06 +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=1711611008; cv=none; b=sM+++S8W5R8FGuKTFSu5BCUXVnKZPT4jJrOpDp9al1HkWGWiTM85XeAAx1FQeoDbcUEUnp8cI3YAOi29tz3olmQ/NMdQDM5vuARdS+a5bxGNaqLvYpg5hYhYpgEWZq7ZSJOdUUjOn+HVhF+9dS1doDHwArG0qnMSuxRiIVQrWoM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711611008; c=relaxed/simple; bh=yJBunkAK0QHItVcWofovBlnil12JFPgiOotyzjn288Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=no9cjj2BboBYK3XFD0HOPrk5g56ipDUmsSANKWxXTO7ZvkuRcLsYnYZ/Ijt8jx9rxGIirjqugFhUEM9xK7ONLdtgFZP9wrbp7+oUSe/OZYTAESdfG0HwSf3ucj5EZECXYTMT/yVv1jhqr/jrxx+1Vnh4rpaQNy6iTivLxEa1NPI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=afwzXtg4; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="afwzXtg4" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42S6qjdr027622; Thu, 28 Mar 2024 07:30:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=mAA7rlFgKmMrThlT0BEckk99yJ8QCub2J11vEDLCuZ8=; b=af wzXtg4gPNeQqliKrh/oN5NY5CYZlz/0gML45xWN2MdP/3GMNTNTuJc8eBgJ39KgO MbMWrfglYDzn4YroVX5WrEcHZGuWqwh0N5roI9zhiQ+5LxPYzimBP125WFdiBPH3 Ig4lpqdGFKCC1rPqJzvecNCndW9etmTffhiCvNf73ECdp7pRp9fxAdtam/No5r3g 9nUehTsgkaYGlGexsLqwK3C9GnmdtNAYwkLvuxm2Q50FOGLBeKOjl3JmvsvNcBUT +WWmBeHq4uW0q5dNGlN4nRFEoxNPM/7p4XdIbzDh+oLcqnkYDb42k9+FYHMHDT7M BwnV3cn4N4RkQ8YnJERQ== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x53nxg4wg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:30:00 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42S7U01T001180 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:30:00 GMT Received: from hu-periyasa-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 28 Mar 2024 00:29:57 -0700 From: Karthikeyan Periyasamy To: , CC: , Vasanthakumar Thiagarajan , Karthikeyan Periyasamy Subject: [PATCH 07/13] wifi: cfg80211/mac80211: Refactor iface comb iterate callback for multi-hardware dev Date: Thu, 28 Mar 2024 12:59:10 +0530 Message-ID: <20240328072916.1164195-8-quic_periyasa@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328072916.1164195-1-quic_periyasa@quicinc.com> References: <20240328072916.1164195-1-quic_periyasa@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 8S-Xuw1nM8TK4Aai6Z_1qdbLzqAKqstW X-Proofpoint-ORIG-GUID: 8S-Xuw1nM8TK4Aai6Z_1qdbLzqAKqstW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_06,2024-03-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=916 impostorscore=0 spamscore=0 bulkscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 malwarescore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403210001 definitions=main-2403280048 From: Vasanthakumar Thiagarajan Currently, interface combination iterate callback gets notified for each matching combination. To support multi-physical hardware interface combination advertisements, the callback subscriber should additionally receive the hardware index information to indicate which physical hardware is chosen in the matching combination. Refactor the iterate callback by introducing an argument for passing the hardware index. This hardware index is valid for the multi-hardware advertisements and invalid (-1) for the single hardware combination advertisement. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00188-QCAHKSWPL_SILICONZ-1 Signed-off-by: Vasanthakumar Thiagarajan Co-developed-by: Karthikeyan Periyasamy Signed-off-by: Karthikeyan Periyasamy --- include/net/cfg80211.h | 2 +- net/mac80211/util.c | 2 +- net/wireless/util.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 491d074fe430..246a8c07becf 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -9233,7 +9233,7 @@ int cfg80211_check_combinations(struct wiphy *wiphy, int cfg80211_iter_combinations(struct wiphy *wiphy, struct iface_combination_params *params, void (*iter)(const struct ieee80211_iface_combination *c, - void *data), + int hw_chan_idx, void *data), void *data); /* diff --git a/net/mac80211/util.c b/net/mac80211/util.c index cda398d8f60d..b1f3b1eb053d 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -4014,7 +4014,7 @@ int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata, static void ieee80211_iter_max_chans(const struct ieee80211_iface_combination *c, - void *data) + int hw_chan_idx, void *data) { u32 *max_num_different_channels = data; diff --git a/net/wireless/util.c b/net/wireless/util.c index 2bde8a354631..b60a6a6da744 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -2363,13 +2363,13 @@ int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev, int cfg80211_iter_combinations(struct wiphy *wiphy, struct iface_combination_params *params, void (*iter)(const struct ieee80211_iface_combination *c, - void *data), + int hw_chan_idx, void *data), void *data) { const struct ieee80211_regdomain *regdom; enum nl80211_dfs_regions region = 0; int i, j, iftype; - int num_interfaces = 0; + int num_interfaces = 0, hw_chan_idx = -1; u32 used_iftypes = 0; u32 beacon_int_gcd; bool beacon_int_different; @@ -2460,7 +2460,7 @@ int cfg80211_iter_combinations(struct wiphy *wiphy, * supported the requested numbers, so we're good. */ - (*iter)(c, data); + (*iter)(c, hw_chan_idx, data); cont: kfree(limits); } @@ -2471,7 +2471,7 @@ EXPORT_SYMBOL(cfg80211_iter_combinations); static void cfg80211_iter_sum_ifcombs(const struct ieee80211_iface_combination *c, - void *data) + int hw_chan_idx, void *data) { int *num = data; (*num)++; From patchwork Thu Mar 28 07:29:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karthikeyan Periyasamy X-Patchwork-Id: 13608063 X-Patchwork-Delegate: johannes@sipsolutions.net 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 42F1451C54 for ; Thu, 28 Mar 2024 07:30:10 +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=1711611011; cv=none; b=oAgyqrqGkK8GKsbfnwjFQWjFWSjXZNO3Kd9YsfkF87NE3k6KwTQV3DkWEpiXHZ9/376rcE2+yTVkUBDdu7mM/UFwJVcSi/m25twDCdjxc/cA9jXVYInAKmkYPcLLGE4lynIsO+DtydoNxYKW3strhko8HTgSPM7OZiwM+Gi8omA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711611011; c=relaxed/simple; bh=oRWDMjZoeZroMUZE4S1jnm/ekwhc6o8X0x42JdybI28=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W1wDSlrAL3JtLT23Nr5jvGA+RQT4HCUicqAdYhAgO6LchCA7+Xf/0wxWm/HZVMZWqQcB4mSyXHftleZMIgr/kY6djGE0nYG2kri95+fd7SC6B+lxCF3f18ZSIAaW/lPSHkYkOE0vbS/zHLYStiYyIz7Op3c0E7Zsg7HjTWE33P0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=nE+iEZna; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="nE+iEZna" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42S3RDub008039; Thu, 28 Mar 2024 07:30:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=vzFMCWN64d8JTCXizncnmHel3u9nVpLxYSuQ9oJegME=; b=nE +iEZnaeZmHzEBQF0HOs7kUTd1EDP0F0DruxoXQN16qyJMC+2zQpt2gpQcIUNLk94 O/lljfgGWPbjVqwwHJgkOGzDZNrzYbEKRX9u1DYfy3S7kZ9hEmOVrVWqUJ52kR1/ OWGC16n63mVFvOXeEJ7PlSbW9Y9NHl4x87JoiTE4HH6AZvMADeyyXXyqD08gfr+6 Xj4AzeivZ20gJy0926bUdICFHt6UuRdOn4eQ1KPROVSQOWD3XlUFtavFdVznhr+y nVAUOj+qaE8zfCs1CEDYlWfWiW3cuXqFX9T7+ZLgz1B6omWRVCkw3JLKjUFj92r0 eMciHcf8MANcuPYwawjA== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x4u1wt9de-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:30:03 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42S7U2sd004429 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:30:02 GMT Received: from hu-periyasa-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 28 Mar 2024 00:30:00 -0700 From: Karthikeyan Periyasamy To: , CC: , Vasanthakumar Thiagarajan , Karthikeyan Periyasamy Subject: [PATCH 08/13] wifi: cfg80211: Refactor the iface combination iteration helper function Date: Thu, 28 Mar 2024 12:59:11 +0530 Message-ID: <20240328072916.1164195-9-quic_periyasa@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328072916.1164195-1-quic_periyasa@quicinc.com> References: <20240328072916.1164195-1-quic_periyasa@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 1ARFm6oLhtyOzb6ZR50mqk4Y5zNld8ki X-Proofpoint-GUID: 1ARFm6oLhtyOzb6ZR50mqk4Y5zNld8ki X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_06,2024-03-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 malwarescore=0 impostorscore=0 mlxscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403210001 definitions=main-2403280048 From: Vasanthakumar Thiagarajan Currently, the iteration helper function retrieves iface types information from the iface combination parameter and performs iface combination limit validation. To accommodate per physical hardware iface combinations, the aforementioned validation and information retrieval need to be executed for each physical hardware instance. Consequently, relocate the validation and retrieval operations to a new helper function and scale it to support per physical hardware iface combinations. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00188-QCAHKSWPL_SILICONZ-1 Signed-off-by: Vasanthakumar Thiagarajan Co-developed-by: Karthikeyan Periyasamy Signed-off-by: Karthikeyan Periyasamy --- net/wireless/util.c | 135 ++++++++++++++++++++++++++++++++------------ 1 file changed, 98 insertions(+), 37 deletions(-) diff --git a/net/wireless/util.c b/net/wireless/util.c index b60a6a6da744..39358b69dd36 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -2360,6 +2360,84 @@ int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev, return 0; } +static int +cfg80211_validate_iface_limits(struct wiphy *wiphy, + const int iftype_num[NUM_NL80211_IFTYPES], + struct ieee80211_iface_limit *limits, + u8 n_limits, + u32 *all_iftypes) +{ + enum nl80211_iftype iftype; + int i; + + for (iftype = 0; iftype < NUM_NL80211_IFTYPES; iftype++) { + if (cfg80211_iftype_allowed(wiphy, iftype, 0, 1)) + continue; + + for (i = 0; i < n_limits; i++) { + *all_iftypes |= limits[i].types; + + if (!(limits[i].types & BIT(iftype))) + continue; + + if (limits[i].max < iftype_num[iftype]) + return -EINVAL; + + limits[i].max -= iftype_num[iftype]; + } + } + + return 0; +} + +static int +cfg80211_validate_iface_comb_limits(struct wiphy *wiphy, + struct iface_combination_params *params, + const struct ieee80211_iface_combination *c, + u16 num_interfaces, u32 *all_iftypes) +{ + struct ieee80211_iface_limit *limits; + int ret = 0; + + if (num_interfaces > c->max_interfaces) + return -EINVAL; + + if (params->num_different_channels > c->num_different_channels) + return -EINVAL; + + limits = kmemdup(c->limits, sizeof(limits[0]) * c->n_limits, + GFP_KERNEL); + if (!limits) + return -ENOMEM; + + ret = cfg80211_validate_iface_limits(wiphy, + params->iftype_num, + limits, + c->n_limits, + all_iftypes); + + kfree(limits); + + return ret; +} + +static u16 cfg80211_get_iftype_info(struct wiphy *wiphy, + const int iftype_num[NUM_NL80211_IFTYPES], + u32 *used_iftypes) +{ + enum nl80211_iftype iftype; + u16 num_interfaces = 0; + + for (iftype = 0; iftype < NUM_NL80211_IFTYPES; iftype++) { + num_interfaces += iftype_num[iftype]; + if (iftype_num[iftype] > 0 && + !cfg80211_iftype_allowed(wiphy, iftype, 0, 1)) + *used_iftypes |= BIT(iftype); + } + + return num_interfaces; +} + int cfg80211_iter_combinations(struct wiphy *wiphy, struct iface_combination_params *params, void (*iter)(const struct ieee80211_iface_combination *c, @@ -2368,11 +2446,13 @@ int cfg80211_iter_combinations(struct wiphy *wiphy, { const struct ieee80211_regdomain *regdom; enum nl80211_dfs_regions region = 0; - int i, j, iftype; - int num_interfaces = 0, hw_chan_idx = -1; + int i; + int hw_chan_idx = -1; u32 used_iftypes = 0; u32 beacon_int_gcd; + u16 num_interfaces = 0; bool beacon_int_different; + int ret = 0; /* * This is a bit strange, since the iteration used to rely only on @@ -2395,50 +2475,33 @@ int cfg80211_iter_combinations(struct wiphy *wiphy, rcu_read_unlock(); } - for (iftype = 0; iftype < NUM_NL80211_IFTYPES; iftype++) { - num_interfaces += params->iftype_num[iftype]; - if (params->iftype_num[iftype] > 0 && - !cfg80211_iftype_allowed(wiphy, iftype, 0, 1)) - used_iftypes |= BIT(iftype); - } + num_interfaces = cfg80211_get_iftype_info(wiphy, + params->iftype_num, + &used_iftypes); for (i = 0; i < wiphy->n_iface_combinations; i++) { const struct ieee80211_iface_combination *c; - struct ieee80211_iface_limit *limits; u32 all_iftypes = 0; c = &wiphy->iface_combinations[i]; - if (num_interfaces > c->max_interfaces) - continue; - if (params->num_different_channels > c->num_different_channels) + ret = cfg80211_validate_iface_comb_limits(wiphy, params, + c, num_interfaces, + &all_iftypes); + if (ret == -ENOMEM) { + break; + } else if (ret) { + ret = 0; continue; - - limits = kmemdup(c->limits, sizeof(limits[0]) * c->n_limits, - GFP_KERNEL); - if (!limits) - return -ENOMEM; - - for (iftype = 0; iftype < NUM_NL80211_IFTYPES; iftype++) { - if (cfg80211_iftype_allowed(wiphy, iftype, 0, 1)) - continue; - for (j = 0; j < c->n_limits; j++) { - all_iftypes |= limits[j].types; - if (!(limits[j].types & BIT(iftype))) - continue; - if (limits[j].max < params->iftype_num[iftype]) - goto cont; - limits[j].max -= params->iftype_num[iftype]; - } } if (params->radar_detect != (c->radar_detect_widths & params->radar_detect)) - goto cont; + continue; if (params->radar_detect && c->radar_detect_regions && !(c->radar_detect_regions & BIT(region))) - goto cont; + continue; /* Finally check that all iftypes that we're currently * using are actually part of this combination. If they @@ -2446,14 +2509,14 @@ int cfg80211_iter_combinations(struct wiphy *wiphy, * to continue to the next. */ if ((all_iftypes & used_iftypes) != used_iftypes) - goto cont; + continue; if (beacon_int_gcd) { if (c->beacon_int_min_gcd && beacon_int_gcd < c->beacon_int_min_gcd) - goto cont; + continue; if (!c->beacon_int_min_gcd && beacon_int_different) - goto cont; + continue; } /* This combination covered all interface types and @@ -2461,11 +2524,9 @@ int cfg80211_iter_combinations(struct wiphy *wiphy, */ (*iter)(c, hw_chan_idx, data); - cont: - kfree(limits); } - return 0; + return ret; } EXPORT_SYMBOL(cfg80211_iter_combinations); From patchwork Thu Mar 28 07:29:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karthikeyan Periyasamy X-Patchwork-Id: 13608064 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD2844E1D1 for ; Thu, 28 Mar 2024 07:30:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711611015; cv=none; b=YqhHlgqtJC713EGKCc5paGLg/Xkd58sYoT5f36atgvTilabaGkq1e3Y1FWIQTd3bxw0m6Kv07kWVWSZEJgwEGvYANqy91Sw25A/dseij1GFpM/nj/sy1gNI38VegpcPUJ3iw5BlyHobdlOMuQiFJlGgvNg26V4JKhTe9vKbe/9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711611015; c=relaxed/simple; bh=igWnA3U2uZ8Ccum/OpTiN2mscy1MhlLRZaC2kesF4E4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MQtBTz7JVx0jJHu81fUl8qlcLjnqEEmutcQg0Z2pcc+oMM26h4EjLP4LCDeu7LO0d5MtXGCSam+KL/IYQ2y3KylTEMN6N1FmnMqtVp3/wk/aulLgBa2etSmoVfxjQfzZH4jjq3vAI5ju0VvhHWSkkqDbmB92l3CibxS8mNMWQRc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=CiKosPce; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="CiKosPce" Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42S4LGv4014521; Thu, 28 Mar 2024 07:30:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=D2SDNHlklnUQzCd4heMupV2hHWsQZ7S0hZa9dPOh1Co=; b=Ci KosPcehrwPb65eOOYWAtbWKW+fD2wBsEbsA37SKX+EZoMq+aBfzNBsi7Vn7Cfuyj KBlDh78GmyEz2y4vF56lHLsiMR3JfOR096IuTDQV20Y3h5aMVzC/sub4eKax1tB2 ge/0gm50KdmvzEiBmcn9B3tHxWxAIKvDtpukGDVvgRB0SiIv2BOazG9bKFrxgI3t 5x6wIVWCiEIFzKNoJFr0Lks8Lb1D6Z/MKCyCNRL2GFGK7CR/bNmYg+Mg1+LWQ7p1 oQ0FKRo+zMmIeIY4V5P6XtQFPhIDaP2Cni713elSFEyjvSC35HYni8b/D1sAHVV5 VadTPQccUWwo5we52Cow== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x4u20aayf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:30:05 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42S7U4Eo000436 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:30:04 GMT Received: from hu-periyasa-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 28 Mar 2024 00:30:02 -0700 From: Karthikeyan Periyasamy To: , CC: , Vasanthakumar Thiagarajan , Karthikeyan Periyasamy Subject: [PATCH 09/13] wifi: cfg80211: Add multi-hardware iface combination support Date: Thu, 28 Mar 2024 12:59:12 +0530 Message-ID: <20240328072916.1164195-10-quic_periyasa@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328072916.1164195-1-quic_periyasa@quicinc.com> References: <20240328072916.1164195-1-quic_periyasa@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 22xMlyFJMf5OSTxMtDzwxi1DgiQJW-ud X-Proofpoint-GUID: 22xMlyFJMf5OSTxMtDzwxi1DgiQJW-ud X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_06,2024-03-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 impostorscore=0 mlxscore=0 adultscore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403210001 definitions=main-2403280048 From: Vasanthakumar Thiagarajan Currently, the interface combination parameter supports a single physical hardware configuration. To support multiple physical hardware interface combination, add per hardware configuration parameters (like num_different_channels, iftype_num[NUM_NL80211_IFTYPES]) and channel definition for which the interface combination will be checked. Modify the iface combination iterate helper function to retrieve the per hardware parameters and validate the iface combination limits. For the per hardware parameters, retrieve the respective hardware index from the channel definition and pass them to the iterator callback. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00188-QCAHKSWPL_SILICONZ-1 Signed-off-by: Vasanthakumar Thiagarajan Co-developed-by: Karthikeyan Periyasamy Signed-off-by: Karthikeyan Periyasamy --- include/net/cfg80211.h | 53 +++++++++++ net/wireless/util.c | 196 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 241 insertions(+), 8 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 246a8c07becf..8668b877fc3a 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1585,6 +1585,23 @@ struct cfg80211_color_change_settings { u8 color; }; +/** + * struct iface_comb_per_hw_params - HW specific interface combinations input + * + * Used to pass per-hw interface combination parameters + * + * @num_different_channels: the number of different channels we want to use + * with in the per-hw supported channels. + * @iftype_num: array with the number of interfaces of each interface + * type. The index is the interface type as specified in &enum + * nl80211_iftype. + */ + +struct iface_comb_per_hw_params { + int num_different_channels; + int iftype_num[NUM_NL80211_IFTYPES]; +}; + /** * struct iface_combination_params - input parameters for interface combinations * @@ -1601,12 +1618,27 @@ struct cfg80211_color_change_settings { * @new_beacon_int: set this to the beacon interval of a new interface * that's not operating yet, if such is to be checked as part of * the verification + * @chandef: Channel definition for which the interface combination is to be + * checked, when checking during interface preparation on a new channel, + * for example. This will be used when the driver advertises underlying + * hw specific interface combination in a multi physical hardware device. + * This will be NULL when the interface combination check is not due to + * channel or the interface combination does not include per-hw + * advertisement. + * @n_per_hw: number of Per-HW interface combinations. + * @per_hw: @n_per_hw of hw specific interface combinations. Per-hw channel + * list index as advertised in wiphy @hw_chans is used as index + * in @per_hw to maintain the interface combination of the corresponding + * hw. */ struct iface_combination_params { int num_different_channels; u8 radar_detect; int iftype_num[NUM_NL80211_IFTYPES]; u32 new_beacon_int; + const struct cfg80211_chan_def *chandef; + u8 n_per_hw; + const struct iface_comb_per_hw_params *per_hw; }; /** @@ -9236,6 +9268,27 @@ int cfg80211_iter_combinations(struct wiphy *wiphy, int hw_chan_idx, void *data), void *data); +/** + * cfg80211_per_hw_iface_comb_advertised - if per-hw iface combination supported + * + * @wiphy: the wiphy + * + * This function is used to check underlying per-hw interface combination is + * advertised by the driver. + */ +bool cfg80211_per_hw_iface_comb_advertised(struct wiphy *wiphy); + +/** + * cfg80211_get_hw_idx_by_chan - get the hw index by the channel + * + * @wiphy: the wiphy + * @chan: channel for which the supported hw index is required + * + * returns -1 in case the channel is not supported by any of the constituent hw + */ +int cfg80211_get_hw_idx_by_chan(struct wiphy *wiphy, + const struct ieee80211_channel *chan); + /* * cfg80211_stop_iface - trigger interface disconnection * diff --git a/net/wireless/util.c b/net/wireless/util.c index 39358b69dd36..635fd2637b73 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -2390,6 +2390,78 @@ cfg80211_validate_iface_limits(struct wiphy *wiphy, return 0; } +static const struct ieee80211_iface_per_hw * +cfg80211_get_hw_iface_comb_by_idx(struct wiphy *wiphy, + const struct ieee80211_iface_combination *c, + int idx) +{ + int i; + + for (i = 0; i < c->n_hw_list; i++) + if (c->iface_hw_list[i].hw_chans_idx == idx) + break; + + if (i == c->n_hw_list) + return NULL; + + return &c->iface_hw_list[i]; +} + +static int +cfg80211_validate_iface_comb_per_hw_limits(struct wiphy *wiphy, + struct iface_combination_params *params, + const struct ieee80211_iface_combination *c, + u16 *num_ifaces, u32 *all_iftypes) +{ + struct ieee80211_iface_limit *limits; + const struct iface_comb_per_hw_params *per_hw; + const struct ieee80211_iface_per_hw *per_hw_comb; + int i, ret = 0; + + for (i = 0; i < params->n_per_hw; i++) { + per_hw = ¶ms->per_hw[i]; + + per_hw_comb = cfg80211_get_hw_iface_comb_by_idx(wiphy, c, i); + if (!per_hw_comb) { + ret = -EINVAL; + goto out; + } + + if (num_ifaces[i] > per_hw_comb->max_interfaces) { + ret = -EINVAL; + goto out; + } + + if (per_hw->num_different_channels > + per_hw_comb->num_different_channels) { + ret = -EINVAL; + goto out; + } + + limits = kmemdup(per_hw_comb->limits, + sizeof(limits[0]) * per_hw_comb->n_limits, + GFP_KERNEL); + if (!limits) { + ret = -ENOMEM; + goto out; + } + + ret = cfg80211_validate_iface_limits(wiphy, + per_hw->iftype_num, + limits, + per_hw_comb->n_limits, + all_iftypes); + + kfree(limits); + + if (ret) + goto out; + } + +out: + return ret; +} + static int cfg80211_validate_iface_comb_limits(struct wiphy *wiphy, struct iface_combination_params *params, @@ -2421,6 +2493,23 @@ cfg80211_validate_iface_comb_limits(struct wiphy *wiphy, return ret; } +bool cfg80211_per_hw_iface_comb_advertised(struct wiphy *wiphy) +{ + int i; + + for (i = 0; i < wiphy->n_iface_combinations; i++) + if (wiphy->iface_combinations[i].n_hw_list) + return true; + + return false; +} +EXPORT_SYMBOL(cfg80211_per_hw_iface_comb_advertised); + +static void cfg80211_put_iface_comb_iftypes(u16 *num_ifaces) +{ + kfree(num_ifaces); +} + static u16 cfg80211_get_iftype_info(struct wiphy *wiphy, const int iftype_num[NUM_NL80211_IFTYPES], u32 *used_iftypes) @@ -2438,6 +2527,69 @@ static u16 cfg80211_get_iftype_info(struct wiphy *wiphy, return num_interfaces; } +static u16* +cfg80211_get_iface_comb_iftypes(struct wiphy *wiphy, + struct iface_combination_params *params, + u32 *used_iftypes) +{ + const struct iface_comb_per_hw_params *per_hw; + u16 *num_ifaces; + int i; + u8 num_hw; + + num_hw = params->n_per_hw ? params->n_per_hw : 1; + + num_ifaces = kcalloc(num_hw, sizeof(*num_ifaces), GFP_KERNEL); + if (!num_ifaces) + return NULL; + + if (!params->n_per_hw) { + num_ifaces[0] = cfg80211_get_iftype_info(wiphy, + params->iftype_num, + used_iftypes); + } else { + /* account per_hw interfaces, if advertised */ + for (i = 0; i < params->n_per_hw; i++) { + per_hw = ¶ms->per_hw[i]; + num_ifaces[i] = cfg80211_get_iftype_info(wiphy, + per_hw->iftype_num, + used_iftypes); + } + } + + return num_ifaces; +} + +static bool +cfg80211_chan_supported_by_sub_hw(const struct ieee80211_chans_per_hw *hw_chans, + const struct ieee80211_channel *chan) +{ + int i; + + for (i = 0; i < hw_chans->n_chans; i++) + if (chan->center_freq == hw_chans->chans[i].center_freq) + return true; + + return false; +} + +int +cfg80211_get_hw_idx_by_chan(struct wiphy *wiphy, + const struct ieee80211_channel *chan) +{ + int i; + + if (!chan) + return -1; + + for (i = 0; i < wiphy->num_hw; i++) + if (cfg80211_chan_supported_by_sub_hw(wiphy->hw_chans[i], chan)) + return i; + + return -1; +} +EXPORT_SYMBOL(cfg80211_get_hw_idx_by_chan); + int cfg80211_iter_combinations(struct wiphy *wiphy, struct iface_combination_params *params, void (*iter)(const struct ieee80211_iface_combination *c, @@ -2450,8 +2602,8 @@ int cfg80211_iter_combinations(struct wiphy *wiphy, int hw_chan_idx = -1; u32 used_iftypes = 0; u32 beacon_int_gcd; - u16 num_interfaces = 0; - bool beacon_int_different; + u16 *num_ifaces = NULL; + bool beacon_int_different, is_per_hw; int ret = 0; /* @@ -2475,9 +2627,26 @@ int cfg80211_iter_combinations(struct wiphy *wiphy, rcu_read_unlock(); } - num_interfaces = cfg80211_get_iftype_info(wiphy, - params->iftype_num, - &used_iftypes); + is_per_hw = cfg80211_per_hw_iface_comb_advertised(wiphy); + /* check per HW validation */ + if (params->n_per_hw) { + if (!is_per_hw) + return -EINVAL; + + if (params->n_per_hw > wiphy->num_hw) + return -EINVAL; + } + + if (is_per_hw && params->chandef && + cfg80211_chandef_valid(params->chandef)) + hw_chan_idx = cfg80211_get_hw_idx_by_chan(wiphy, + params->chandef->chan); + + num_ifaces = cfg80211_get_iface_comb_iftypes(wiphy, + params, + &used_iftypes); + if (!num_ifaces) + return -ENOMEM; for (i = 0; i < wiphy->n_iface_combinations; i++) { const struct ieee80211_iface_combination *c; @@ -2485,9 +2654,18 @@ int cfg80211_iter_combinations(struct wiphy *wiphy, c = &wiphy->iface_combinations[i]; - ret = cfg80211_validate_iface_comb_limits(wiphy, params, - c, num_interfaces, - &all_iftypes); + if (params->n_per_hw) + ret = cfg80211_validate_iface_comb_per_hw_limits(wiphy, + params, + c, + num_ifaces, + &all_iftypes); + else + ret = cfg80211_validate_iface_comb_limits(wiphy, + params, + c, + num_ifaces[0], + &all_iftypes); if (ret == -ENOMEM) { break; } else if (ret) { @@ -2526,6 +2704,8 @@ int cfg80211_iter_combinations(struct wiphy *wiphy, (*iter)(c, hw_chan_idx, data); } + cfg80211_put_iface_comb_iftypes(num_ifaces); + return ret; } EXPORT_SYMBOL(cfg80211_iter_combinations); From patchwork Thu Mar 28 07:29:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karthikeyan Periyasamy X-Patchwork-Id: 13608066 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 468FF2561F for ; Thu, 28 Mar 2024 07:30:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711611019; cv=none; b=LyQSHpMn5PBvgMMB3OS+9SErDa1+iagE2nYIHR2LPlCftaLqP3lfwH9GJ6dY2kLeDU7Sfpxk0ywwLMXrFRsplCyH9UtBvr1WGRIIOcwi0OoConmIUfyul20CQ/hTxByyhJxH13va4mAwgiKCQktW2M4A5gLU8GIcg5hNT5Ac9UU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711611019; c=relaxed/simple; bh=f6MNTOWwzwf6ydIW6HtiwQ76qAdLfrunihPWPOaZACo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qgOkcawmooGQexyu2/RDwr+pIXtIWCecVabMOWOZ0IJZyP7t4IpCcHdLJwRFoc5F8QSbsgl3oOQ6RzEbJKI7HYxPp4ljQGtGfLnIzM16bHvx577K0V525jUC8GaV5gA/yrBiYNsWB7mrBUQDxjOM5hlA0yRxFlVyiHmdzhQ2mRQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=ek0iPnvm; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="ek0iPnvm" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42S5S5OV016571; Thu, 28 Mar 2024 07:30:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=7xp+XbKb73LQNxCMLPSORGHvndiMuoHtAUrCCwDw+eU=; b=ek 0iPnvm8spNXXxE6Dfu5ymEiwHdNw8wmSDxOrCF/z96nBKX4OHkkJplkiJYuSc+/t 6d3/NjagXEmLNi36e674LL9Ifo6gF65psqNV8wsBHdrKCMseKH6UyUgFsYkdV+Kt H0LvQWA0orkKvvErS3HBo0JYSJ1br2Rb44dioyLQNNAZFQgw37vxYzrJGxPkBEHU ykzvPRBxqAkTKK98PjL5DHVooB6jLw3QoJaCCs1URgSoWzqdi4OUjtPjdW6stPPE Z7wtGvQDoA1s8VYu/CpF+65yJMEsNrLezvJLmP8InoPuJkIee6pvN1FTFJz555IQ w0Crvj3UBNQ0ziDynK8A== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x4u1wtbn4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:30:11 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42S7U75r000502 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:30:07 GMT Received: from hu-periyasa-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 28 Mar 2024 00:30:05 -0700 From: Karthikeyan Periyasamy To: , CC: , Vasanthakumar Thiagarajan , Karthikeyan Periyasamy Subject: [PATCH 10/13] wifi: mac80211: expose channel context helper function Date: Thu, 28 Mar 2024 12:59:13 +0530 Message-ID: <20240328072916.1164195-11-quic_periyasa@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328072916.1164195-1-quic_periyasa@quicinc.com> References: <20240328072916.1164195-1-quic_periyasa@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: xMKdNmPFr_uNVzBGA_dI9aiknVAtmJmp X-Proofpoint-ORIG-GUID: xMKdNmPFr_uNVzBGA_dI9aiknVAtmJmp X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_06,2024-03-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxlogscore=994 priorityscore=1501 lowpriorityscore=0 adultscore=0 malwarescore=0 mlxscore=0 spamscore=0 bulkscore=0 impostorscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403210001 definitions=main-2403280048 From: Vasanthakumar Thiagarajan Currently, link specific channel context helper function scope is static. For multi hardware iface combination support, mac80211 need this helper function, so expose it internally. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00188-QCAHKSWPL_SILICONZ-1 Signed-off-by: Vasanthakumar Thiagarajan Co-developed-by: Karthikeyan Periyasamy Signed-off-by: Karthikeyan Periyasamy --- net/mac80211/chan.c | 2 +- net/mac80211/ieee80211_i.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index 5a7fb0e4f89d..08a362892d9a 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -67,7 +67,7 @@ static bool ieee80211_can_create_new_chanctx(struct ieee80211_local *local) return ieee80211_num_chanctx(local) < ieee80211_max_num_channels(local); } -static struct ieee80211_chanctx * +struct ieee80211_chanctx * ieee80211_link_get_chanctx(struct ieee80211_link_data *link) { struct ieee80211_local *local __maybe_unused = link->sdata->local; diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index def611e4e55f..202bbffec746 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -2577,6 +2577,8 @@ void ieee80211_link_copy_chanctx_to_vlans(struct ieee80211_link_data *link, bool clear); int ieee80211_chanctx_refcount(struct ieee80211_local *local, struct ieee80211_chanctx *ctx); +struct ieee80211_chanctx * +ieee80211_link_get_chanctx(struct ieee80211_link_data *link); void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local, struct ieee80211_chanctx *chanctx); From patchwork Thu Mar 28 07:29:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karthikeyan Periyasamy X-Patchwork-Id: 13608069 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50BE653E17 for ; Thu, 28 Mar 2024 07:30:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711611023; cv=none; b=g7J3lqAFgv97Vi2bJSuU4fiGAu/2OWiR0PfCLl75tuK/ZCOpjtUT/9bUJPqxiWgFuBG9rmPc+rdLktOE50wNiWuegOUllNrjZYFE15ayR27RxFG+SQmbuOb1M0jt1BCoDUubhGlehc4LJ+ORvSX+4NEb7q5t+Y8UHv62o5EyRT8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711611023; c=relaxed/simple; bh=JJp+Vyh1lNEfhffR8l0pgkCmcaq7Be+70PvUeYzEPks=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Fm3QFpVUXGYye4dMEXqdPYv1h9u6qfBoqTqYVLEjnZUUXNpOIW5rtCLihOX7G/+ttJLsN2J80cJK5xUKIpghDgF1KG9jy1TQKIUMu7RkwsduEGsn9zw8a8RuLjBAVujx6Y8p7KnNG+uLVL3BNljmX8sEZ2pUBVKGJbqJP0ZkeUo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=FoGOd3G/; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="FoGOd3G/" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42S4u682015094; Thu, 28 Mar 2024 07:30:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=rSxKIjo/maAlGl1SnvISTzkFB8wGULpB3LJphUKy/YM=; b=Fo GOd3G/GiepGDt4jClVKOGHxoYnX81O42Y9L4bqRZXY27j8XU/fWC1BwJK4amp4G2 0Wi9cw0h9KJobyAPFx5c2skLxTJSb75dmtRjqxq5aLJeY5xOjYcc2UWgXt1RpWmO ktmsCFNBpehTcGawEEKtUvr/H9fQOURtgt0cbvcSom3oHDU13DnPu1mgAWcWktG4 79CdDyyuJ73w4Kt5ahs3iP+jYmdooWUtz/wKgkooUWrNvcKIo+1hlSFNOXv5SfPe dbQ1IgTYEz50N2i2KqLE5OfWxuoe3xh4UGpm6qQe11oNCOou2BnhYuF1H+B+c+ks 3CPC95yxYoSbt9+9noPA== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x4u1yjaut-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:30:10 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42S7U9FV004892 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:30:09 GMT Received: from hu-periyasa-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 28 Mar 2024 00:30:07 -0700 From: Karthikeyan Periyasamy To: , CC: , Vasanthakumar Thiagarajan , Karthikeyan Periyasamy Subject: [PATCH 11/13] wifi: mac80211: Add multi-hardware support in the iface comb helper Date: Thu, 28 Mar 2024 12:59:14 +0530 Message-ID: <20240328072916.1164195-12-quic_periyasa@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328072916.1164195-1-quic_periyasa@quicinc.com> References: <20240328072916.1164195-1-quic_periyasa@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: Fjr9dXMqvujiTldB_0ADICPRt4y1rkEX X-Proofpoint-ORIG-GUID: Fjr9dXMqvujiTldB_0ADICPRt4y1rkEX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_06,2024-03-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 impostorscore=0 suspectscore=0 mlxscore=0 clxscore=1015 mlxlogscore=999 malwarescore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403210001 definitions=main-2403280048 From: Vasanthakumar Thiagarajan Currently, iface combination param supports single physical hardware. To support multi physical hardware, add hardware specific checks on the channel context creation and populate hardware specific parameters from the channel definition for which the interface combination need to check. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00188-QCAHKSWPL_SILICONZ-1 Signed-off-by: Vasanthakumar Thiagarajan Co-developed-by: Karthikeyan Periyasamy Signed-off-by: Karthikeyan Periyasamy --- net/mac80211/chan.c | 33 +++++-- net/mac80211/ieee80211_i.h | 3 +- net/mac80211/util.c | 194 ++++++++++++++++++++++++++++++++++--- 3 files changed, 207 insertions(+), 23 deletions(-) diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index 08a362892d9a..0558eafa45aa 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -47,24 +47,43 @@ int ieee80211_chanctx_refcount(struct ieee80211_local *local, ieee80211_chanctx_num_reserved(local, ctx); } -static int ieee80211_num_chanctx(struct ieee80211_local *local) +static int ieee80211_num_chanctx(struct ieee80211_local *local, + const struct cfg80211_chan_def *chandef) { struct ieee80211_chanctx *ctx; - int num = 0; + int num = 0, hw_idx = -1, ctx_idx; lockdep_assert_wiphy(local->hw.wiphy); - list_for_each_entry(ctx, &local->chanctx_list, list) - num++; + if (chandef && cfg80211_chandef_valid(chandef)) + hw_idx = cfg80211_get_hw_idx_by_chan(local->hw.wiphy, + chandef->chan); + + if (hw_idx < 0) { + list_for_each_entry(ctx, &local->chanctx_list, list) + num++; + } else { + list_for_each_entry(ctx, &local->chanctx_list, list) { + ctx_idx = cfg80211_get_hw_idx_by_chan(local->hw.wiphy, + ctx->conf.def.chan); + if (ctx_idx != hw_idx) + continue; + + num++; + } + } return num; } -static bool ieee80211_can_create_new_chanctx(struct ieee80211_local *local) +static +bool ieee80211_can_create_new_chanctx(struct ieee80211_local *local, + const struct cfg80211_chan_def *chandef) { lockdep_assert_wiphy(local->hw.wiphy); - return ieee80211_num_chanctx(local) < ieee80211_max_num_channels(local); + return ieee80211_num_chanctx(local, chandef) < + ieee80211_max_num_channels(local, chandef); } struct ieee80211_chanctx * @@ -1029,7 +1048,7 @@ int ieee80211_link_reserve_chanctx(struct ieee80211_link_data *link, new_ctx = ieee80211_find_reservation_chanctx(local, chanreq, mode); if (!new_ctx) { - if (ieee80211_can_create_new_chanctx(local)) { + if (ieee80211_can_create_new_chanctx(local, &chanreq->oper)) { new_ctx = ieee80211_new_chanctx(local, chanreq, mode); if (IS_ERR(new_ctx)) return PTR_ERR(new_ctx); diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 202bbffec746..42f4211c622b 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -2600,7 +2600,8 @@ int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata, const struct cfg80211_chan_def *chandef, enum ieee80211_chanctx_mode chanmode, u8 radar_detect); -int ieee80211_max_num_channels(struct ieee80211_local *local); +int ieee80211_max_num_channels(struct ieee80211_local *local, + const struct cfg80211_chan_def *chandef); void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local, struct ieee80211_chanctx *ctx); diff --git a/net/mac80211/util.c b/net/mac80211/util.c index b1f3b1eb053d..f8ffc8ad0cd8 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -3926,6 +3926,44 @@ static u8 ieee80211_chanctx_radar_detect(struct ieee80211_local *local, return radar_detect; } +static void +ieee80211_get_per_hw_sdata_active_iface(struct ieee80211_sub_if_data *sdata, + struct iface_comb_per_hw_params *per_hw, + int iftype_num[NUM_NL80211_IFTYPES], + int *total) +{ + struct ieee80211_local *local = sdata->local; + unsigned int link_id; + int hw_idx; + + for (link_id = 0; link_id < ARRAY_SIZE(sdata->link); link_id++) { + struct ieee80211_link_data *link; + struct ieee80211_chanctx *ctx; + + link = sdata_dereference(sdata->link[link_id], sdata); + if (!link) + continue; + + ctx = ieee80211_link_get_chanctx(link); + if (ctx && + ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED) + ctx = ctx->replace_ctx; + + hw_idx = -1; + if (ctx && cfg80211_chandef_valid(&ctx->conf.def)) + hw_idx = cfg80211_get_hw_idx_by_chan(local->hw.wiphy, + ctx->conf.def.chan); + + if (hw_idx >= 0) + per_hw[hw_idx].iftype_num[sdata->wdev.iftype]++; + else + iftype_num[sdata->wdev.iftype]++; + + if (total) + (*total)++; + } +} + int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata, const struct cfg80211_chan_def *chandef, enum ieee80211_chanctx_mode chanmode, @@ -3936,9 +3974,12 @@ int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata, enum nl80211_iftype iftype = sdata->wdev.iftype; struct ieee80211_chanctx *ctx; int total = 1; + struct iface_comb_per_hw_params *per_hw __free(kfree) = NULL; struct iface_combination_params params = { .radar_detect = radar_detect, }; + bool is_per_hw; + int hchan_idx = -1; lockdep_assert_wiphy(local->hw.wiphy); @@ -3969,26 +4010,68 @@ int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata, return 0; } - if (chandef) - params.num_different_channels = 1; + is_per_hw = cfg80211_per_hw_iface_comb_advertised(local->hw.wiphy); + if (is_per_hw) { + per_hw = kcalloc(local->hw.wiphy->num_hw, sizeof(*per_hw), + GFP_KERNEL); + if (!per_hw) + return -ENOMEM; + + if (chandef && cfg80211_chandef_valid(chandef)) { + hchan_idx = cfg80211_get_hw_idx_by_chan(local->hw.wiphy, + chandef->chan); + if (hchan_idx < 0) + goto skip; - if (iftype != NL80211_IFTYPE_UNSPECIFIED) - params.iftype_num[iftype] = 1; + per_hw[hchan_idx].num_different_channels = 1; + if (iftype != NL80211_IFTYPE_UNSPECIFIED) + per_hw[hchan_idx].iftype_num[iftype] = 1; + } + } else { + if (chandef) + params.num_different_channels = 1; + + if (iftype != NL80211_IFTYPE_UNSPECIFIED) + params.iftype_num[iftype] = 1; + } + +skip: list_for_each_entry(ctx, &local->chanctx_list, list) { if (ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED) continue; + + if (is_per_hw) { + if (WARN_ON(!cfg80211_chandef_valid(&ctx->conf.def))) + continue; + + hchan_idx = cfg80211_get_hw_idx_by_chan(local->hw.wiphy, + ctx->conf.def.chan); + if (WARN_ON(hchan_idx < 0)) + continue; + } + params.radar_detect |= ieee80211_chanctx_radar_detect(local, ctx); + if (ctx->mode == IEEE80211_CHANCTX_EXCLUSIVE) { - params.num_different_channels++; + if (is_per_hw) + per_hw[hchan_idx].num_different_channels++; + else + params.num_different_channels++; + continue; } + if (chandef && chanmode == IEEE80211_CHANCTX_SHARED && cfg80211_chandef_compatible(chandef, &ctx->conf.def)) continue; - params.num_different_channels++; + + if (is_per_hw) + per_hw[hchan_idx].num_different_channels++; + else + params.num_different_channels++; } list_for_each_entry_rcu(sdata_iter, &local->interfaces, list) { @@ -4002,13 +4085,25 @@ int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata, wdev_iter->iftype, 0, 1)) continue; - params.iftype_num[wdev_iter->iftype]++; - total++; + if (is_per_hw) { + ieee80211_get_per_hw_sdata_active_iface(sdata_iter, + per_hw, + params.iftype_num, + &total); + } else { + params.iftype_num[wdev_iter->iftype]++; + total++; + } } if (total == 1 && !params.radar_detect) return 0; + if (is_per_hw) { + params.n_per_hw = local->hw.wiphy->num_hw; + params.per_hw = per_hw; + } + return cfg80211_check_combinations(local->hw.wiphy, ¶ms); } @@ -4022,31 +4117,100 @@ ieee80211_iter_max_chans(const struct ieee80211_iface_combination *c, c->num_different_channels); } -int ieee80211_max_num_channels(struct ieee80211_local *local) +static void +ieee80211_iter_per_hw_max_chans(const struct ieee80211_iface_combination *c, + int hw_chan_idx, void *data) +{ + u32 *max_num_diff_chans = data; + u32 max_supp_diff_chans = 0; + int i; + + for (i = 0; i < c->n_hw_list; i++) { + const struct ieee80211_iface_per_hw *h; + + h = &c->iface_hw_list[i]; + if (hw_chan_idx != -1) { + if (h->hw_chans_idx == hw_chan_idx) { + max_supp_diff_chans = h->num_different_channels; + break; + } + continue; + } + max_supp_diff_chans += h->num_different_channels; + } + + *max_num_diff_chans = max(*max_num_diff_chans, max_supp_diff_chans); +} + +int ieee80211_max_num_channels(struct ieee80211_local *local, + const struct cfg80211_chan_def *chandef) { struct ieee80211_sub_if_data *sdata; struct ieee80211_chanctx *ctx; + struct iface_comb_per_hw_params *per_hw __free(kfree) = NULL; + struct iface_combination_params params = {0}; + void (*iter)(const struct ieee80211_iface_combination *c, + int hw_chan_idx, void *data) = ieee80211_iter_max_chans; u32 max_num_different_channels = 1; + bool is_per_hw; int err; - struct iface_combination_params params = {0}; lockdep_assert_wiphy(local->hw.wiphy); + is_per_hw = cfg80211_per_hw_iface_comb_advertised(local->hw.wiphy); + if (is_per_hw) { + per_hw = kcalloc(local->hw.wiphy->num_hw, + sizeof(*params.per_hw), + GFP_KERNEL); + if (!per_hw) + return -ENOMEM; + + params.chandef = chandef; + iter = ieee80211_iter_per_hw_max_chans; + } + list_for_each_entry(ctx, &local->chanctx_list, list) { - if (ctx->replace_state == IEEE80211_CHANCTX_WILL_BE_REPLACED) + if (ctx->replace_state == + IEEE80211_CHANCTX_WILL_BE_REPLACED) continue; - params.num_different_channels++; + if (is_per_hw) { + int hw_idx; + + if (WARN_ON(!cfg80211_chandef_valid(&ctx->conf.def))) + continue; + + hw_idx = cfg80211_get_hw_idx_by_chan(local->hw.wiphy, + ctx->conf.def.chan); + if (WARN_ON(hw_idx < 0)) + continue; + + per_hw[hw_idx].num_different_channels++; + } else { + params.num_different_channels++; + } params.radar_detect |= ieee80211_chanctx_radar_detect(local, ctx); } - list_for_each_entry_rcu(sdata, &local->interfaces, list) - params.iftype_num[sdata->wdev.iftype]++; + list_for_each_entry_rcu(sdata, &local->interfaces, list) { + if (is_per_hw && ieee80211_sdata_running(sdata)) + ieee80211_get_per_hw_sdata_active_iface(sdata, + per_hw, + params.iftype_num, + NULL); + else + params.iftype_num[sdata->wdev.iftype]++; + } + + if (is_per_hw) { + params.n_per_hw = local->hw.wiphy->num_hw; + params.per_hw = per_hw; + } err = cfg80211_iter_combinations(local->hw.wiphy, ¶ms, - ieee80211_iter_max_chans, + iter, &max_num_different_channels); if (err < 0) return err; From patchwork Thu Mar 28 07:29:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karthikeyan Periyasamy X-Patchwork-Id: 13608067 X-Patchwork-Delegate: kvalo@adurom.com Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79EAC537F5 for ; Thu, 28 Mar 2024 07:30:19 +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=1711611020; cv=none; b=N11mvlpS47KTmafqo9XoMZScJ+ONEMp/9i1u8BwOkxv4pgyE+gFiTrjW+pMEhdcpaa6/Y7gpS8CHd/bCE2G9yQIZ0InT/pedsvlXjP/0fG4jwa7IhFhiiV2mcBAM+jfwwsh77fhiLTtTrCc/usrY+nfbz//EzgJSa+ULCaH6BWc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711611020; c=relaxed/simple; bh=qgtUJ9Qb0c1d4ANEhpl0hr1bMgVvNbPcH7OGu6E6700=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=M9nrzUKS/R3bQnjTGmCfujfM+lPaclFJmsYVef3jluekjcOvm3T1FX27ijKulz3REhKqk0LLrCDkeJAFm7XpFVjZSNESZkFHbaWjRhcMYFuOCY/m4NYWNymdptT6DTf6p87gXsUAqUh77bOX9nncKsKEhB5n4/prsAUpAfuv5y4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=hYwhuoWB; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="hYwhuoWB" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42S3ns57031494; Thu, 28 Mar 2024 07:30: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:content-type; s= qcppdkim1; bh=BVEFDZ2WTP4C+ARaLT2dCt71jFI5J76TrRdBOehoe4E=; b=hY whuoWBRmec3k2s1yqvZ48r9rhbXCTDCSPZ+uu0ZDNkqd/zV3MBTWasCbOsU3RJhk pIl1BCwzvV00oORyEDp+XDTXhhtk3fFxo+8lFnmOgMt+zVL1PDRUguu7+i7Mv1oQ IPupEuj/iFXElRD585u1Ly+rXqWRGaP46lbEiZLqUnspf6B408MEvNENzPF+d8pQ jDFVUkxSNLD+jz7e5RtwMkHKUZpb1f9xKd5zlRAmFU4QSiCDUQ3P+hkAYDmpoy79 b8QR9d+6M45E2T1jQ88uXypSFG4cqx1XksHatURrEm2kkJH8zOyI2v3NbAMoYgKk +ZNEvPcAb7N6ZHM69s8g== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x4u20acu0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:30:12 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42S7UBMr013403 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:30:11 GMT Received: from hu-periyasa-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 28 Mar 2024 00:30:09 -0700 From: Karthikeyan Periyasamy To: , CC: , Karthikeyan Periyasamy Subject: [PATCH 12/13] wifi: ath12k: Introduce iface combination cleanup helper Date: Thu, 28 Mar 2024 12:59:15 +0530 Message-ID: <20240328072916.1164195-13-quic_periyasa@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328072916.1164195-1-quic_periyasa@quicinc.com> References: <20240328072916.1164195-1-quic_periyasa@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: X6mhx8re7R4-DFU8pAIHiuENpe-xYaZ5 X-Proofpoint-GUID: X6mhx8re7R4-DFU8pAIHiuENpe-xYaZ5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_06,2024-03-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 suspectscore=0 mlxlogscore=961 spamscore=0 priorityscore=1501 phishscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403210001 definitions=main-2403280048 Introduce a cleanup helper function to avoid redundant code for iface combination cleanup. Remove the cleanup code from ath12k_mac_hw_unregister() and ath12k_mac_hw_register() and replace it with new cleanup helper function. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00188-QCAHKSWPL_SILICONZ-1 Signed-off-by: Karthikeyan Periyasamy --- drivers/net/wireless/ath/ath12k/mac.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index 52a5fb8b03e9..44c8bf6eb6ae 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -7781,6 +7781,14 @@ static bool ath12k_mac_is_iface_mode_enable(struct ath12k_hw *ah, return is_enable; } +static void ath12k_mac_cleanup_iface_combinations(struct ath12k_hw *ah) +{ + struct wiphy *wiphy = ah->hw->wiphy; + + kfree(wiphy->iface_combinations[0].limits); + kfree(wiphy->iface_combinations); +} + static int ath12k_mac_setup_iface_combinations(struct ath12k_hw *ah) { struct wiphy *wiphy = ah->hw->wiphy; @@ -7905,7 +7913,6 @@ static void ath12k_mac_cleanup_unregister(struct ath12k *ar) static void ath12k_mac_hw_unregister(struct ath12k_hw *ah) { struct ieee80211_hw *hw = ah->hw; - struct wiphy *wiphy = hw->wiphy; struct ath12k *ar = ath12k_ah_to_ar(ah); cancel_work_sync(&ar->regd_update_work); @@ -7914,8 +7921,7 @@ static void ath12k_mac_hw_unregister(struct ath12k_hw *ah) ath12k_mac_cleanup_unregister(ar); - kfree(wiphy->iface_combinations[0].limits); - kfree(wiphy->iface_combinations); + ath12k_mac_cleanup_iface_combinations(ah); SET_IEEE80211_DEV(hw, NULL); } @@ -8087,7 +8093,7 @@ static int ath12k_mac_hw_register(struct ath12k_hw *ah) ret = ieee80211_register_hw(hw); if (ret) { ath12k_err(ab, "ieee80211 registration failed: %d\n", ret); - goto err_free_if_combs; + goto err_cleanup_if_combs; } if (!ab->hw_params->supports_monitor) @@ -8110,9 +8116,8 @@ static int ath12k_mac_hw_register(struct ath12k_hw *ah) err_unregister_hw: ieee80211_unregister_hw(hw); -err_free_if_combs: - kfree(wiphy->iface_combinations[0].limits); - kfree(wiphy->iface_combinations); +err_cleanup_if_combs: + ath12k_mac_cleanup_iface_combinations(ah); err_cleanup_unregister: ath12k_mac_cleanup_unregister(ar); From patchwork Thu Mar 28 07:29:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karthikeyan Periyasamy X-Patchwork-Id: 13608070 X-Patchwork-Delegate: kvalo@adurom.com Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B305D5427E for ; Thu, 28 Mar 2024 07:30: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=1711611023; cv=none; b=N7Z2+FOLc541JNqfQfEjVaQA9h6saoE428pPFGm5/xtTds5qPtg/CbXfYiiJ6O/S046TM8NhbuvamFl186LMqJK1N+hbsk/yNCBUG04QuQKvXCUnwc2Zd3hHQ64mW0qJ2gMUDphzNL48Of22fIACvoE5sS7ayspQ5eBXe41vAVg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711611023; c=relaxed/simple; bh=pZrxSuKWz5Z3mCUoHB7BqLhhk76yUNAi2dwuOA8WZfY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ozsmtt9Gepw5O4BrBbfM9VyHgmgmq/C8nqoRTIDs+q57M7eBgUuHfXOuMuk3oa1C7qLALP2PAJKPDuHgjjsbtDzplDjNwkA+GHAzPAYGW14BiLexZHv2rGPx8/mp7PZAnVYC8uQ+pH0MH18WjhR4WGMQ7GHlHVmejZpNtbv1jAw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=E1ovLLg5; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="E1ovLLg5" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42S7EZd1019132; Thu, 28 Mar 2024 07:30:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=+RIBdnw0vwx2Tq+khsrWtyptD39yTzsKamSP4/IYk0Q=; b=E1 ovLLg5dxRV4YAePyLTus+Fv4EtHtn2FXHhCpd89IKhw3OLwIe45vqJodM8iyyjYu T9jW+3oqS6g30ZwDqZ32YJS6uEYqtrei5lrgMOUB0QSATuwsXfE+4s11APdA/Tp/ Bzo7mL+Oo+F43GbV4RkfChac/tWs7ew8UNd3XWeSumGpV38uEH/yaxDuyA+sXq1T DZCNA2RAOUs49N+CYALqMlEmCu6Nioyy//irh6irMDw3si4pYm6zjUloMIhUNxsD KixoIzvTynr+hb/za0rzldSWWv+dJmQubY2g/Nb9Sg0DlF3letQ9ZIZ1auX2DlEX upfDOb8ce/bC6rc18kQw== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3x4u1wt9f1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:30:14 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42S7UEJG000713 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Mar 2024 07:30:14 GMT Received: from hu-periyasa-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 28 Mar 2024 00:30:11 -0700 From: Karthikeyan Periyasamy To: , CC: , Harshitha Prem , Karthikeyan Periyasamy Subject: [PATCH 13/13] wifi: ath12k: Advertise multi hardware iface combination Date: Thu, 28 Mar 2024 12:59:16 +0530 Message-ID: <20240328072916.1164195-14-quic_periyasa@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240328072916.1164195-1-quic_periyasa@quicinc.com> References: <20240328072916.1164195-1-quic_periyasa@quicinc.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: ZwcF98HMWFacUr1UTBOD1GHNB5JqPeF6 X-Proofpoint-GUID: ZwcF98HMWFacUr1UTBOD1GHNB5JqPeF6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_06,2024-03-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 malwarescore=0 impostorscore=0 mlxscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=746 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403210001 definitions=main-2403280048 From: Harshitha Prem The prerequisite for MLO support in cfg80211/mac80211 requires that all the links participating in MLO belong to the same wiphy/ieee80211_hw. The driver needs to group multiple discrete hardware each acting as a link in MLO, under one wiphy. Consequently, the driver advertises multi hardware interface combination capabilities with a list of supported frequencies. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.1.1-00188-QCAHKSWPL_SILICONZ-1 Signed-off-by: Harshitha Prem Co-developed-by: Karthikeyan Periyasamy Signed-off-by: Karthikeyan Periyasamy --- drivers/net/wireless/ath/ath12k/mac.c | 128 +++++++++++++++++++++++++- 1 file changed, 127 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index 44c8bf6eb6ae..3d0cae8d883a 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -7781,10 +7781,126 @@ static bool ath12k_mac_is_iface_mode_enable(struct ath12k_hw *ah, return is_enable; } +static +struct ieee80211_chans_per_hw *ath12k_setup_per_hw_chan(struct ath12k *ar) +{ + struct ieee80211_chans_per_hw *chans; + struct ieee80211_supported_band *band; + + if (ar->pdev->cap.supported_bands & WMI_HOST_WLAN_2G_CAP) + band = &ar->mac.sbands[NL80211_BAND_2GHZ]; + else if (ar->pdev->cap.supported_bands & WMI_HOST_WLAN_5G_CAP && + !ar->supports_6ghz) + band = &ar->mac.sbands[NL80211_BAND_5GHZ]; + else if (ar->pdev->cap.supported_bands & WMI_HOST_WLAN_5G_CAP && + ar->supports_6ghz) + band = &ar->mac.sbands[NL80211_BAND_6GHZ]; + + chans = kzalloc(struct_size(chans, chans, band->n_channels), + GFP_KERNEL); + if (!chans) + return NULL; + + memcpy(chans->chans, band->channels, + sizeof(*band->channels) * band->n_channels); + chans->n_chans = band->n_channels; + + return chans; +} + +static void ath12k_mac_cleanup_hw_channels(struct ath12k_hw *ah) +{ + struct wiphy *wiphy = ah->hw->wiphy; + int i; + + for (i = 0; i < ah->num_radio; i++) + kfree(wiphy->hw_chans[i]); + + kfree(wiphy->hw_chans); +} + +static int +ath12k_mac_setup_hw_channels(struct ath12k_hw *ah) +{ + struct wiphy *wiphy = ah->hw->wiphy; + int i, ret; + + wiphy->hw_chans = kcalloc(ah->num_radio, sizeof(*wiphy->hw_chans), + GFP_KERNEL); + if (!wiphy->hw_chans) + return -ENOMEM; + + for (i = 0; i < ah->num_radio; i++) { + wiphy->hw_chans[i] = ath12k_setup_per_hw_chan(&ah->radio[i]); + if (!wiphy->hw_chans[i]) { + ret = -ENOMEM; + goto cleanup_hw_chan; + } + } + + wiphy->num_hw = ah->num_radio; + + return 0; + +cleanup_hw_chan: + for (i = i - 1; i >= 0; i--) + kfree(wiphy->hw_chans[i]); + + kfree(wiphy->hw_chans); + + return ret; +} + +static void +ath12k_mac_cleanup_per_hw_iface_comb(struct ath12k_hw *ah) +{ + struct wiphy *wiphy = ah->hw->wiphy; + + ath12k_mac_cleanup_hw_channels(ah); + + kfree(wiphy->iface_combinations[0].iface_hw_list); +} + +static int +ath12k_mac_setup_per_hw_iface_comb(struct ath12k_hw *ah, + struct ieee80211_iface_combination *comb) +{ + struct ieee80211_iface_per_hw *iface_hw; + struct ieee80211_hw *hw = ah->hw; + int i, ret; + + ret = ath12k_mac_setup_hw_channels(ah); + if (ret) + return ret; + + iface_hw = kcalloc(ah->num_radio, sizeof(*iface_hw), GFP_KERNEL); + if (!iface_hw) { + ath12k_mac_cleanup_hw_channels(ah); + return -ENOMEM; + } + + for (i = 0; i < ah->num_radio; i++) { + iface_hw[i].hw_chans_idx = i; + iface_hw[i].num_different_channels = + comb->num_different_channels; + iface_hw[i].max_interfaces = comb->max_interfaces; + iface_hw[i].limits = comb->limits; + iface_hw[i].n_limits = comb->n_limits; + } + + comb->iface_hw_list = iface_hw; + comb->n_hw_list = hw->wiphy->num_hw; + + return 0; +} + static void ath12k_mac_cleanup_iface_combinations(struct ath12k_hw *ah) { struct wiphy *wiphy = ah->hw->wiphy; + if (ah->num_radio > 1) + ath12k_mac_cleanup_per_hw_iface_comb(ah); + kfree(wiphy->iface_combinations[0].limits); kfree(wiphy->iface_combinations); } @@ -7794,7 +7910,7 @@ static int ath12k_mac_setup_iface_combinations(struct ath12k_hw *ah) struct wiphy *wiphy = ah->hw->wiphy; struct ieee80211_iface_combination *combinations; struct ieee80211_iface_limit *limits; - int n_limits, max_interfaces; + int n_limits, max_interfaces, ret; bool ap, mesh, p2p; ap = ath12k_mac_is_iface_mode_enable(ah, NL80211_IFTYPE_AP); @@ -7857,6 +7973,16 @@ static int ath12k_mac_setup_iface_combinations(struct ath12k_hw *ah) BIT(NL80211_CHAN_WIDTH_40) | BIT(NL80211_CHAN_WIDTH_80); + if (ah->num_radio > 1) { + ret = ath12k_mac_setup_per_hw_iface_comb(ah, combinations); + if (ret) { + kfree(limits); + kfree(combinations); + + return ret; + } + } + wiphy->iface_combinations = combinations; wiphy->n_iface_combinations = 1;