From patchwork Tue Sep 20 10:05:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasanthakumar Thiagarajan X-Patchwork-Id: 12981805 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 276FCC54EE9 for ; Tue, 20 Sep 2022 10:06:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230478AbiITKGl (ORCPT ); Tue, 20 Sep 2022 06:06:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231209AbiITKGN (ORCPT ); Tue, 20 Sep 2022 06:06:13 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DA1561703 for ; Tue, 20 Sep 2022 03:05:49 -0700 (PDT) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28K7xkEH003441; Tue, 20 Sep 2022 10:05:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=+ZUNOp+ii3f76ZX7ecrwsYhNG5DBFifaGnTQBCkEx9Q=; b=fYiYYIm6GooOZUqatd4qFFDlbbQSrueGsVv1HqtM73rMhTVVxrNgMMFZqfR6Szy6dR8v hIznuHpVcKKVpJw1MojW8H7VjsNARMIBgUhoeMTOGa1P4/KZ0HFTiSt9t/+BCjWiCCPm QD1ryrFN/LXxXGB2uNn4koO3Om8ZRbZMPQdoYgv8R5UF/9/p9HbCE7GQWcgm38axRY2M stWhrrVbB77Dku/7rUxsbjUMdtipgNZvERrFhYuu+nG0z7Jsz+WVrM4GE8dyghKTygKh Yr7+GNbWFsmlqwNcB7B18/ASz8JCLX84HOyDTSqwDV5ACinYBsK9eDXyesbCuARFw5V0 Xw== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3jpw78ana0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 10:05:42 +0000 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 28KA5gKH012328 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 10:05:42 GMT Received: from CDCCSTEX0180100-LIN.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.986.29; Tue, 20 Sep 2022 03:05:40 -0700 From: Vasanthakumar Thiagarajan To: CC: Subject: [RFC 1/4] wifi: cfg80211: Add provision to advertise multiple radio in one wiphy Date: Tue, 20 Sep 2022 15:35:15 +0530 Message-ID: <20220920100518.19705-2-quic_vthiagar@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220920100518.19705-1-quic_vthiagar@quicinc.com> References: <20220920100518.19705-1-quic_vthiagar@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] 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: B_SvgrCHHgeegoqhbKCn6QbQQkX6yLJh X-Proofpoint-GUID: B_SvgrCHHgeegoqhbKCn6QbQQkX6yLJh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_02,2022-09-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 mlxscore=0 adultscore=0 suspectscore=0 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209200061 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The prerequisite for MLO support in cfg80211/mac80211 is that all the links participating in MLO must be from 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. This commit adds 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. Signed-off-by: Vasanthakumar Thiagarajan --- include/net/cfg80211.h | 24 +++++++++ net/wireless/core.c | 109 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index e09ff87146c1..4662231ad068 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -5088,6 +5088,18 @@ struct wiphy_iftype_akm_suites { int n_akm_suites; }; +/** + * struct ieee80211_supported_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 { + int n_chans; + struct ieee80211_channel chans[]; +}; + /** * struct wiphy - wireless hardware description * @mtx: mutex for the data (structures) of this device @@ -5297,6 +5309,15 @@ struct wiphy_iftype_akm_suites { * NL80211_MAX_NR_AKM_SUITES in order to avoid compatibility issues with * legacy userspace and maximum allowed value is * CFG80211_MAX_NUM_AKM_SUITES. + * + * @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. + * */ struct wiphy { struct mutex mtx; @@ -5445,6 +5466,9 @@ struct wiphy { u8 ema_max_profile_periodicity; u16 max_num_akm_suites; + struct ieee80211_chans_per_hw **hw_chans; + int num_hw; + char priv[] __aligned(NETDEV_ALIGN); }; diff --git a/net/wireless/core.c b/net/wireless/core.c index 5b0c4d5b80cf..4163602a1b9a 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -653,6 +653,110 @@ 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[i].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; + bool found; + int i, j; + + for (i = 0; i < chans->n_chans; i++) { + 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 = 0; j < wiphy->num_hw; j++) { + const struct ieee80211_chans_per_hw *hw_chans1; + const struct ieee80211_chans_per_hw *hw_chans2; + + if (i == j) + continue; + + 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)) { + WARN_ON(1); + return -EINVAL; + } + } + + return 0; +} + int wiphy_register(struct wiphy *wiphy) { struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); @@ -908,6 +1012,11 @@ int wiphy_register(struct wiphy *wiphy) return -EINVAL; } + if (cfg80211_validate_per_hw_chans(&rdev->wiphy)) { + WARN_ON(1); + return -EINVAL; + } + for (i = 0; i < rdev->wiphy.n_vendor_commands; i++) { /* * Validate we have a policy (can be explicitly set to From patchwork Tue Sep 20 10:05:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasanthakumar Thiagarajan X-Patchwork-Id: 12981807 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DA01C6FA8B for ; Tue, 20 Sep 2022 10:11:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229777AbiITKLF (ORCPT ); Tue, 20 Sep 2022 06:11:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230434AbiITKKw (ORCPT ); Tue, 20 Sep 2022 06:10:52 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1C2B6AA05 for ; Tue, 20 Sep 2022 03:10:47 -0700 (PDT) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28KA0N1v027518; Tue, 20 Sep 2022 10:10:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=h3HVczrMpOtauqQmDDmamAnVsfheGtIga8wRQ42gEXo=; b=cdXvoHyIX2hIZs4s4g5oFxtr2mll/g/eyOFZWLpLpSQoqa7Qk/dzMy7xQVxh9yWkCsck 1PgVrkrJKGylkC4unsC0reQBXYqXsGpwGAnrFIP4K9OKVd8n5wCL6ll5asd3ZdmgTr8H PhDi6YuKTQblMcmlKZmPQ8wpvrP6eQ0DOgyYrxzX3FXv/JyKiSKj0gWrGAOYivY71Saz 8L6tJ1UJ3fHZxBQh+yLaStAx0dQt+2leMvekyoPIOHc9Yax0yfCCxqNhdmcsAOeOIW5r e7n9Q2itDvxyr3hlS4KuNlcI13Uw+g8mvP/+79UZEoaeZQ7R/FJrGOgnnUZFAQuAxX3Q SQ== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3jpx50ad0t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 10:10:45 +0000 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 28KA5ivT022220 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 10:05:44 GMT Received: from CDCCSTEX0180100-LIN.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.986.29; Tue, 20 Sep 2022 03:05:42 -0700 From: Vasanthakumar Thiagarajan To: CC: Subject: [RFC 2/4] wifi: nl80211: send underlying multi-hardware channel capabilities to user space Date: Tue, 20 Sep 2022 15:35:16 +0530 Message-ID: <20220920100518.19705-3-quic_vthiagar@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220920100518.19705-1-quic_vthiagar@quicinc.com> References: <20220920100518.19705-1-quic_vthiagar@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] 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: wRZnu9Y5gOcbBJdyzdQLEHZQc2oSbUUb X-Proofpoint-GUID: wRZnu9Y5gOcbBJdyzdQLEHZQc2oSbUUb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_02,2022-09-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 adultscore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 priorityscore=1501 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209200062 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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. Signed-off-by: Vasanthakumar Thiagarajan --- 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 c32e7616a366..070b31277402 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -2749,6 +2749,12 @@ enum nl80211_commands { * When used with %NL80211_CMD_FRAME_TX_STATUS, indicates the ack RX * timestamp. When used with %NL80211_CMD_FRAME RX notification, indicates * the incoming frame RX timestamp. + * + * @NL80211_ATTR_MULTI_HW_MACS: nested attribute to send the hardware mac + * 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 @@ -3277,6 +3283,8 @@ enum nl80211_attrs { NL80211_ATTR_TX_HW_TIMESTAMP, NL80211_ATTR_RX_HW_TIMESTAMP, + NL80211_ATTR_MULTI_HW_MACS, + /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, @@ -7720,4 +7728,24 @@ enum nl80211_ap_settings_flags { NL80211_AP_SETTINGS_SA_QUERY_OFFLOAD_SUPPORT = 1 << 1, }; +/** + * nl80211_multi_hw_mac_attrs - multi-hw mac attributes + * + * @NL80211_MULTI_HW_MAC_ATTR_INVALID: invalid + * @NL80211_MULTI_HW_MAC_ATTR_IDX: (u8) array index in wiphy @hw_chans to refer an + * underlying hw mac for which the supported channel list is advertised. + * @NL80211_MULTI_HW_MAC_ATTR_FREQS: array of supported center frequencies + * @__NL80211_MULTI_HW_MAC_ATTR_LAST: internal use + * @NL80211_MULTI_HW_MAC_ATTR_MAX: maximum multi-hw mac attribute + */ +enum nl80211_multi_hw_mac_attrs { + __NL80211_MULTI_HW_MAC_ATTR_INVALID, + + NL80211_MULTI_HW_MAC_ATTR_IDX, + NL80211_MULTI_HW_MAC_ATTR_FREQS, + + /* keep last */ + __NL80211_MULTI_HW_MAC_ATTR_LAST, + NL80211_MULTI_HW_MAC_ATTR_MAX = __NL80211_MULTI_HW_MAC_ATTR_LAST - 1 +}; #endif /* __LINUX_NL80211_H */ diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 8ff8b1c040f0..b7d466010e81 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -2355,6 +2355,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_MACS); + 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_MAC_ATTR_IDX, i)) + return -ENOBUFS; + + freqs = nla_nest_start(msg, + NL80211_MULTI_HW_MAC_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; @@ -2959,6 +3000,12 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, if (rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_MLO) nla_put_flag(msg, NL80211_ATTR_MLO_SUPPORT); + 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 Tue Sep 20 10:05:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasanthakumar Thiagarajan X-Patchwork-Id: 12981809 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4476ECAAD8 for ; Tue, 20 Sep 2022 10:11:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229792AbiITKLG (ORCPT ); Tue, 20 Sep 2022 06:11:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230458AbiITKKx (ORCPT ); Tue, 20 Sep 2022 06:10:53 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75F8D5F7F9 for ; Tue, 20 Sep 2022 03:10:50 -0700 (PDT) Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28K7xg6X011091; Tue, 20 Sep 2022 10:10:46 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; s=qcppdkim1; bh=9K+EwUuXa0toeSRdMguuObo92UDwfBJhDLFubGNUME0=; b=LbHGY9AHG4YO2UgIw0UChPFlszeUNRHB/aLCQV1aCc/ZVSAQaeHLECFyy0Ex4mUbc20j cAPqk+Rnnp2DXeX1zunIm/Jwz/U2TxyfSTaijkTcGoGuqgA+6m8yqZ/QJ1hwHpbITaX3 uhHVg6+lD6t6AETJZ+hmJ5lMhqiZT3tBlTmJfmiWFsVoAmTECXW+XaGNxJhMCwJJed97 Mhxjgnx/E30Fmxqr28YFGu/Cbc25GDAkVzHWdVGd4BiPON+18t/0jWSF4ZOP1d+slbny Ksr68yhQYBiYmJczx3TjDwboJDzj2KuBDF4m/RM2nCezKEXYI4UFI1iW2m/TF2RcUWZT Fg== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3jq04y247n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 10:10:46 +0000 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 28KA5jIO022243 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 10:05:45 GMT Received: from CDCCSTEX0180100-LIN.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.986.29; Tue, 20 Sep 2022 03:05:44 -0700 From: Vasanthakumar Thiagarajan To: CC: Subject: [RFC 3/4] wifi: cfg80211/mac80211: extend iface comb advertisement for multi-hardware dev Date: Tue, 20 Sep 2022 15:35:17 +0530 Message-ID: <20220920100518.19705-4-quic_vthiagar@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220920100518.19705-1-quic_vthiagar@quicinc.com> References: <20220920100518.19705-1-quic_vthiagar@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] 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: EE4GJFrP2H5G2SWidTXkcxK5MKQKm_9p X-Proofpoint-GUID: EE4GJFrP2H5G2SWidTXkcxK5MKQKm_9p X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_02,2022-09-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 clxscore=1015 mlxscore=0 malwarescore=0 bulkscore=0 phishscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209200062 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org When 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. Iface combination for each underlying hardware is described with an identifier, the same index which is used in wiphy->hw_chans[] to learn the channel capabilities of the respective hardware. It should be noted that the supporting drivers also need to signal the iface comb capabilities that are common for all the hardware through the existing interface to maintain the backward compatibility with the user space. Provision to advertise per physical hardware specific iface comb capabilities and the sanity checks on the advertised capabilities are implemented in this commit. 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), }, }, }; Signed-off-by: Vasanthakumar Thiagarajan --- include/net/cfg80211.h | 106 ++++++++++++++++++++++++ net/mac80211/main.c | 54 +++++++++++++ net/wireless/core.c | 178 +++++++++++++++++++++++++++++------------ net/wireless/util.c | 18 +++++ 4 files changed, 307 insertions(+), 49 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 4662231ad068..175c2ad4a3e8 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -4726,6 +4726,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. + * + * @hw_chans_idx: index of hardware specific channel list as per wiphy @hw_chans + * @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 + */ +struct ieee80211_iface_per_hw { + u8 hw_chans_idx; + const struct ieee80211_iface_limit *limits; + u32 num_different_channels; + u16 max_interfaces; + u8 n_limits; +}; + /** * struct ieee80211_iface_combination - possible interface combination * @@ -4784,6 +4810,62 @@ struct ieee80211_iface_limit { * .num_different_channels = 2, * }; * + * + * 4. Hardware specific interface combination with driver supporting two hw + * (MAC), one underlying MAC 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 limits4[] = { + * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), }, + * { .max = 1, .types = BIT(NL80211_IFTYPE_AP), }, + * }; + * struct ieee80211_iface_limit limits5_2ghz[] = { + * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), }, + * { .max = 1, .types = BIT(NL80211_IFTYPE_AP), }, + * }; + * struct ieee80211_iface_limit limits5_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 = limits5_2ghz, + * .num_different_channels = 1, + * .max_interfaces = 2, + * .n_limits = ARRAY_SIZE(limits5_2ghz), + * }, + * { + * .hw_chans_idx = 1, + * .limits = limits5_5ghz, + * .num_different_channels = 1, + * .max_interfaces = 3, + * .n_limits = ARRAY_SIZE(limits5_5ghz), + * }, + * }; + * struct ieee80211_iface_combination combination4 = { + * .limits = limits4, + * .n_limits = ARRAY_SIZE(limits4), + * .max_interfaces = 2, + * .num_different_channels = 1, + * .iface_hw_list = hw_combinations, + * .n_hw_list = ARRAY_SIZE(hw_combinations), + * }; + * */ struct ieee80211_iface_combination { /** @@ -4841,6 +4923,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 { @@ -8791,6 +8887,16 @@ bool cfg80211_iftype_allowed(struct wiphy *wiphy, enum nl80211_iftype iftype, void cfg80211_assoc_comeback(struct net_device *netdev, const u8 *ap_addr, u32 timeout); +/** + * cfg80211_hw_chans_includes_dfs - check if per-hardware channel includes DFS + * @chans: hardware channel list + * + * Check if the given per-hardware list includes channels in DFS range. + * Please note the channel is checked against the entire range of DFS + * freq in 5 GHz irrespective of regulatory configurations. + */ +bool cfg80211_hw_chans_includes_dfs(const struct ieee80211_chans_per_hw *chans); + /* Logging, debugging and troubleshooting/diagnostic helpers. */ /* wiphy_printk helpers, similar to dev_printk */ diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 46f3eddc2388..2e008fa976e9 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -933,6 +933,45 @@ 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 h, l; + u32 hw_idx_bm = 0; + + if (!local->use_chanctx) + return -EINVAL; + + for (h = 0; h < c->n_hw_list; h++) { + const struct ieee80211_iface_per_hw *hl; + const struct ieee80211_chans_per_hw *chans; + + hl = &c->iface_hw_list[h]; + + if (hl->hw_chans_idx >= local->hw.wiphy->num_hw) + return -EINVAL; + + chans = local->hw.wiphy->hw_chans[hl->hw_chans_idx]; + if (c->radar_detect_widths && + cfg80211_hw_chans_includes_dfs(chans) && + hl->num_different_channels > 1) + return -EINVAL; + + for (l = 0; l < hl->n_limits; l++) + if ((hl->limits[l].types & BIT(NL80211_IFTYPE_ADHOC)) && + hl->limits[l].max > 1) + return -EINVAL; + + if (hw_idx_bm & BIT(h)) + return -EINVAL; + + hw_idx_bm |= BIT(h); + } + + return 0; +} + int ieee80211_register_hw(struct ieee80211_hw *hw) { struct ieee80211_local *local = hw_to_local(hw); @@ -1035,6 +1074,21 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) } } + for (i = 0; i < local->hw.wiphy->n_iface_combinations; i++) { + const struct ieee80211_iface_combination *comb; + + comb = &local->hw.wiphy->iface_combinations[i]; + + if (comb->n_hw_list && !local->hw.wiphy->num_hw) + return -EINVAL; + + if (!comb->n_hw_list) + continue; + + if (ieee80211_check_per_hw_iface_comb(local, comb)) + return -EINVAL; + } + /* Only HW csum features are currently compatible with mac80211 */ if (WARN_ON(hw->netdev_features & ~MAC80211_SUPPORTED_FEATURES)) return -EINVAL; diff --git a/net/wireless/core.c b/net/wireless/core.c index 4163602a1b9a..50fd7f131736 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -563,10 +563,126 @@ 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 l; + + for (l = 0; l < n_limits; l++) { + u16 types = limits[l].types; + + /* + * Don't advertise an unsupported type + * in a combination. + */ + if (WARN_ON((wiphy->interface_modes & types) != types)) + 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[l].max > 1)) + return -EINVAL; + + /* Only a single NAN can be allowed */ + if (WARN_ON(types & BIT(NL80211_IFTYPE_NAN) && + limits[l].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[l].max; + } + + return 0; +} + +static int +wiphy_verify_comb_per_hw(struct wiphy *wiphy, + const struct ieee80211_iface_combination *comb) +{ + int h; + u32 hw_idx_bitmap = 0; + int ret; + + for (h = 0; h < comb->n_hw_list; h++) { + 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[h]; + + 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; - int i, j; + int i; + int ret; for (i = 0; i < wiphy->n_iface_combinations; i++) { u32 cnt = 0; @@ -593,54 +709,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; @@ -648,6 +721,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; diff --git a/net/wireless/util.c b/net/wireless/util.c index 0b28d00ba8f5..dee9bf309345 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -2504,3 +2504,21 @@ cfg80211_get_iftype_ext_capa(struct wiphy *wiphy, enum nl80211_iftype type) return NULL; } EXPORT_SYMBOL(cfg80211_get_iftype_ext_capa); + +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; +} +EXPORT_SYMBOL(cfg80211_hw_chans_includes_dfs); From patchwork Tue Sep 20 10:05:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasanthakumar Thiagarajan X-Patchwork-Id: 12981806 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23CE8ECAAD8 for ; Tue, 20 Sep 2022 10:07:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229929AbiITKHT (ORCPT ); Tue, 20 Sep 2022 06:07:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230506AbiITKHE (ORCPT ); Tue, 20 Sep 2022 06:07:04 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAF4061738 for ; Tue, 20 Sep 2022 03:07:02 -0700 (PDT) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28K7xcFc023504; Tue, 20 Sep 2022 10:05:48 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; s=qcppdkim1; bh=zoGG73whL65cB+dCMtnJXPjzU/eTvaiJulFQDEVaFg4=; b=ZyCT/aH+qGs8VCUW3o9Y7muVsNJ8wA5oHIBYzdWbirKMamxq9M1kkxPtNJt+u7R1Br1k OqDazcSZTH136QoYqppZr/BE8QhU9RdOJp1KCt7leEZBY0FA1r8IErMfubdHjHj+lBqG RxS6tLRAR1w5Nkj/A8/vQpDCsnkx7uodyr8rPDYCDuh4WuREAensoclC5yxZdgkPG7qB m2XFOw0yptBqmkVLR7pKE1uSwqSI+d6IwqszXYXRwI93c+PznfBCXAgJlillBAzd1COY VatbCASZIkTkiAATBXuT8LKH+NIhAaWQH/qXQ5Q7wr/53oUmRhTOxp9Q0PZm4YyqXK/S 3A== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3jpxaejbgv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 10:05:47 +0000 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 28KA5lSt004547 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 10:05:47 GMT Received: from CDCCSTEX0180100-LIN.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.986.29; Tue, 20 Sep 2022 03:05:45 -0700 From: Vasanthakumar Thiagarajan To: CC: Subject: [RFC 4/4] wifi: nl80211: send iface combination to user space in multi-hardware wiphy Date: Tue, 20 Sep 2022 15:35:18 +0530 Message-ID: <20220920100518.19705-5-quic_vthiagar@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220920100518.19705-1-quic_vthiagar@quicinc.com> References: <20220920100518.19705-1-quic_vthiagar@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] 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: 023v3_eOp-ZNsMR85izsJ5WRlI-hMI_m X-Proofpoint-ORIG-GUID: 023v3_eOp-ZNsMR85izsJ5WRlI-hMI_m X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_02,2022-09-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 mlxlogscore=759 adultscore=0 clxscore=1015 malwarescore=0 phishscore=0 impostorscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209200061 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org A new nested nl attribute is added to the same existing NL command to advertise the iface combination capability for each underlying hardware when driver groups more than one physical hardware under one wiphy to enable MLO among them. Signed-off-by: Vasanthakumar Thiagarajan --- include/uapi/linux/nl80211.h | 50 ++++++++++++++++++++++++- net/wireless/nl80211.c | 71 ++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index 070b31277402..678da076b122 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -5779,6 +5779,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 * @@ -5795,7 +5799,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. * @@ -5814,12 +5830,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 b7d466010e81..1f3b79e10697 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -1595,6 +1595,74 @@ static int nl80211_put_iftypes(struct sk_buff *msg, u32 attr, u16 ifmodes) 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; + int l; + + 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; + + for (l = 0; l < c->iface_hw_list->n_limits; l++) { + struct nlattr *limit; + + limit = nla_nest_start(msg, l + 1); + if (!limit) + return -ENOBUFS; + + if (nla_put_u16(msg, NL80211_IFACE_LIMIT_MAX, + c->iface_hw_list[i].limits[l].max)) + return -ENOBUFS; + + if (nla_put_u16(msg, NL80211_IFACE_LIMIT_TYPES, + c->iface_hw_list[i].limits[l].types)) + return -ENOBUFS; + + nla_nest_end(msg, limit); + } + 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) @@ -1658,6 +1726,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); }