From patchwork Thu Jan 2 14:19:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miri Korenblit X-Patchwork-Id: 13924495 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 2E57C1A23BE for ; Thu, 2 Jan 2025 14:20:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827626; cv=none; b=oa0pPHmKpi0V6QFa5haCfcGYzsedkJihCtXdkZPugKj5gHoPdyCQwFNd498CLsX/CvGvdrZEH5uQYr2LhbUMJWDoqLXiT1ul0W8phRKx82jO4FhuHqE3gJCqw1tvTHqTu1X+YBYg444QA1sS480A0DBbacHwGgKSCQP/VIb2JJI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827626; c=relaxed/simple; bh=2+0Nq3nGeAQG20gDLc3yjxYcjfORvE827GE5HMEzluM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GOpBHoFU92XiZjwDAWOmL4vyrl7GTkNXzfj9reKY8iPwL9eZqlq9++OT6sK5iGOJNtkg3Kwh84cbvtlF+70wEOX4qgYHU7HgpcPT7EPHjy82VulqNbtoa/sfcnrwzvnQ5VM2O6BdYkQDu/c9vm22dn3tnRvPgTzptU0cFWmjYV8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=SzXqDjnG; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SzXqDjnG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735827625; x=1767363625; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2+0Nq3nGeAQG20gDLc3yjxYcjfORvE827GE5HMEzluM=; b=SzXqDjnGjvNIPUDwycUyDLa8Efu5ndDuRO7eqMNDSiqYzUPfI2Fsyk8G BbuVFKz1kq6JDGlzvxHYV8htGl1THrIm0v1d4IFCVvuxUUnVLr979h6ZF FMIziwgb/H0pMITnIHHaG8YZL2TnSNDLIpwvrLWNmW/Nph4jED8YoAobe 6v89IXgP24dCNM8BPcgheO3LrRbR/OUTMIdhQm41A3Dgb4bocOt0cmhGG xaOtiZtUNsQ45aeUmCYyRcvm1lucgsjMMAjq/fa7iA9ippmFI7XKgv+6G OvbEaYruBocfJjEQmlYWVpq+5X1V3skC7yu7PRFgNxZS9YDIofjWM6iCL Q==; X-CSE-ConnectionGUID: QiwIOeb1Q8uOQEHle2pxiw== X-CSE-MsgGUID: G5r1gZCUQ1m4eAEJngGxuw== X-IronPort-AV: E=McAfee;i="6700,10204,11302"; a="46735090" X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="46735090" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:24 -0800 X-CSE-ConnectionGUID: ko9bbqZOQz2pN1iSngPAjw== X-CSE-MsgGUID: +waI7OSyTYm8R001Y+IXyA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="132357355" Received: from weis0040.iil.intel.com ([10.12.217.108]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:23 -0800 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Ilan Peer Subject: [PATCH 01/17] wifi: ieee80211: Add some missing MLO related definitions Date: Thu, 2 Jan 2025 16:19:53 +0200 Message-Id: <20250102161730.4970ca10ebfd.Ibe7f6108cd0e04b8c739a8e35a4f485f664a17e6@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> References: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited From: Ilan Peer As a preparation to support ML reconfiguration request and response, add additional ML reconfiguration definitions required to support the flow. See Section 9.4.2.321.4 in Draft P802.11be_D6.0. Signed-off-by: Ilan Peer Signed-off-by: Miri Korenblit --- include/linux/ieee80211.h | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index 745c3b125d97..ee6bebfd041d 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -3885,6 +3885,16 @@ enum ieee80211_protected_eht_actioncode { WLAN_PROTECTED_EHT_ACTION_TTLM_REQ = 0, WLAN_PROTECTED_EHT_ACTION_TTLM_RES = 1, WLAN_PROTECTED_EHT_ACTION_TTLM_TEARDOWN = 2, + WLAN_PROTECTED_EHT_ACTION_EPCS_ENABLE_REQ = 3, + WLAN_PROTECTED_EHT_ACTION_EPCS_ENABLE_RESP = 4, + WLAN_PROTECTED_EHT_ACTION_EPCS_ENABLE_TEARDOWN = 5, + WLAN_PROTECTED_EHT_ACTION_EML_OP_MODE_NOTIF = 6, + WLAN_PROTECTED_EHT_ACTION_LINK_RECOMMEND = 7, + WLAN_PROTECTED_EHT_ACTION_ML_OP_UPDATE_REQ = 8, + WLAN_PROTECTED_EHT_ACTION_ML_OP_UPDATE_RESP = 9, + WLAN_PROTECTED_EHT_ACTION_LINK_RECONFIG_NOTIF = 10, + WLAN_PROTECTED_EHT_ACTION_LINK_RECONFIG_REQ = 11, + WLAN_PROTECTED_EHT_ACTION_LINK_RECONFIG_RESP = 12, }; /* Security key length */ @@ -5021,6 +5031,8 @@ struct ieee80211_multi_link_elem { #define IEEE80211_MLD_CAP_OP_TID_TO_LINK_MAP_NEG_SUPP_DIFF 3 #define IEEE80211_MLD_CAP_OP_FREQ_SEP_TYPE_IND 0x0f80 #define IEEE80211_MLD_CAP_OP_AAR_SUPPORT 0x1000 +#define IEEE80211_MLD_CAP_OP_LINK_RECONF_SUPPORT 0x2000 +#define IEEE80211_MLD_CAP_OP_ALIGNED_TWT_SUPPORT 0x4000 struct ieee80211_mle_basic_common_info { u8 len; @@ -5036,6 +5048,9 @@ struct ieee80211_mle_preq_common_info { } __packed; #define IEEE80211_MLC_RECONF_PRES_MLD_MAC_ADDR 0x0010 +#define IEEE80211_MLC_RECONF_PRES_EML_CAPA 0x0020 +#define IEEE80211_MLC_RECONF_PRES_MLD_CAPA_OP 0x0040 +#define IEEE80211_MLC_RECONF_PRES_EXT_MLD_CAPA_OP 0x0080 /* no fixed fields in RECONF */ @@ -5354,6 +5369,12 @@ static inline bool ieee80211_mle_size_ok(const u8 *data, size_t len) case IEEE80211_ML_CONTROL_TYPE_RECONF: if (control & IEEE80211_MLC_RECONF_PRES_MLD_MAC_ADDR) common += ETH_ALEN; + if (control & IEEE80211_MLC_RECONF_PRES_EML_CAPA) + common += 2; + if (control & IEEE80211_MLC_RECONF_PRES_MLD_CAPA_OP) + common += 2; + if (control & IEEE80211_MLC_RECONF_PRES_EXT_MLD_CAPA_OP) + common += 2; break; case IEEE80211_ML_CONTROL_TYPE_TDLS: common += sizeof(struct ieee80211_mle_tdls_common_info); @@ -5504,8 +5525,13 @@ ieee80211_mle_basic_sta_prof_bss_param_ch_cnt(const struct ieee80211_mle_per_sta #define IEEE80211_MLE_STA_RECONF_CONTROL_COMPLETE_PROFILE 0x0010 #define IEEE80211_MLE_STA_RECONF_CONTROL_STA_MAC_ADDR_PRESENT 0x0020 #define IEEE80211_MLE_STA_RECONF_CONTROL_AP_REM_TIMER_PRESENT 0x0040 -#define IEEE80211_MLE_STA_RECONF_CONTROL_OPERATION_UPDATE_TYPE 0x0780 -#define IEEE80211_MLE_STA_RECONF_CONTROL_OPERATION_PARAMS_PRESENT 0x0800 +#define IEEE80211_MLE_STA_RECONF_CONTROL_OPERATION_TYPE 0x0780 +#define IEEE80211_MLE_STA_RECONF_CONTROL_OPERATION_TYPE_AP_REM 0 +#define IEEE80211_MLE_STA_RECONF_CONTROL_OPERATION_TYPE_OP_PARAM_UPDATE 1 +#define IEEE80211_MLE_STA_RECONF_CONTROL_OPERATION_TYPE_ADD_LINK 2 +#define IEEE80211_MLE_STA_RECONF_CONTROL_OPERATION_TYPE_DEL_LINK 3 +#define IEEE80211_MLE_STA_RECONF_CONTROL_OPERATION_TYPE_NSTR_STATUS 4 +#define IEEE80211_MLE_STA_RECONF_CONTROL_OPERATION_PARAMS_PRESENT 0x0800 /** * ieee80211_mle_reconf_sta_prof_size_ok - validate reconfiguration multi-link From patchwork Thu Jan 2 14:19:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miri Korenblit X-Patchwork-Id: 13924496 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 615701AF0BA for ; Thu, 2 Jan 2025 14:20:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827628; cv=none; b=R2J11x55mO5G6g1gDEDbdeMJ9++EToWyXNKxh8DgpMprugAEze2yUrh4dgn5ZwtAlMf0//KCJNkuArwbpUrUSS7r9J/AxeDcESO7uQB48NJinvloQZoKTYnsqdABENkgPLamLrpPyaJfaAw1Qefd4ieyylfuvzSNw82td2a+CIE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827628; c=relaxed/simple; bh=EhV1aIA7Tc7/MY2d6btyxBm4yk6IQ06bcRH2APesIIc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=J01NPwmyt3a8YbiD8DMxBw5I6cnlRfxItMOFua1OmX4FViunm272oqoybgWtvxLefM9GwPy7Jmn3CEz7+bNjqvAOwnMPXKm174CYL/xwG79rAi378qT5kgEM7FkwgiyWj/L722LCm/089YY3SJEddQrO0EQ1scH4pLADETpu6sg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=g8Z9p/KU; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="g8Z9p/KU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735827626; x=1767363626; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EhV1aIA7Tc7/MY2d6btyxBm4yk6IQ06bcRH2APesIIc=; b=g8Z9p/KUUAak7HbpKS+esFwRwK+kBmpk8QElL2TgFEpThLH7v+gRzkhM Ntm/eH8dqJBL4ITLsQpX5rsTKdrfjR8SjyfSlWiJv6Wa2Itou3Ne9yCbj +vEywF6hpfSMrTTfeLMMPnQ35Ad5cE2+/8YbZrbSj9CLhGLScSetKe9sv 0B60x/I9XHdCOxBZa21vhe68QcS9ru7f+9tY1m9fkBRwsoaHDo7mB1P4C fZ5jA/0upms3lOmwACo/pA1NItqayfPDXC3nJDkBU2b50p9BTZQoiKC/4 01lXtTgWtelqgxf95tq9lPOtYwXcD47ixhsUSG1XVj1M23USiz4XCQoQf Q==; X-CSE-ConnectionGUID: tVgtjhnrSO+rmxfAMvEI0w== X-CSE-MsgGUID: sLeBJEjeTGiR2z2QXjosAw== X-IronPort-AV: E=McAfee;i="6700,10204,11302"; a="46735095" X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="46735095" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:26 -0800 X-CSE-ConnectionGUID: HUesHvJ6QDit+yN6InoW/Q== X-CSE-MsgGUID: gNWnZhv7ShC1/kCaHCR11A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="132357361" Received: from weis0040.iil.intel.com ([10.12.217.108]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:24 -0800 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Ilan Peer , Johannes Berg Subject: [PATCH 02/17] wifi: nl80211: Split the links handling of an association request Date: Thu, 2 Jan 2025 16:19:54 +0200 Message-Id: <20250102161730.1e9c1873796a.I27a51c8c1d455f0a6d5b59f93f2c9ac49282febb@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> References: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited From: Ilan Peer And move it to a separate function so it could later be reused for dynamic addition of links. Signed-off-by: Ilan Peer Reviewed-by: Johannes Berg Signed-off-by: Miri Korenblit --- net/wireless/nl80211.c | 151 +++++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 75 deletions(-) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 39c114265db8..9a9e61421c47 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -11113,12 +11113,83 @@ static struct cfg80211_bss *nl80211_assoc_bss(struct cfg80211_registered_device return bss; } +static int nl80211_process_links(struct cfg80211_registered_device *rdev, + struct cfg80211_assoc_link *links, + const u8 *ssid, int ssid_len, + struct genl_info *info) +{ + unsigned int attrsize = NUM_NL80211_ATTR * sizeof(struct nlattr *); + struct nlattr **attrs __free(kfree) = kzalloc(attrsize, GFP_KERNEL); + struct nlattr *link; + unsigned int link_id; + int rem, err; + + if (!attrs) + return -ENOMEM; + + nla_for_each_nested(link, info->attrs[NL80211_ATTR_MLO_LINKS], rem) { + memset(attrs, 0, attrsize); + + nla_parse_nested(attrs, NL80211_ATTR_MAX, link, NULL, NULL); + + if (!attrs[NL80211_ATTR_MLO_LINK_ID]) { + NL_SET_BAD_ATTR(info->extack, link); + return -EINVAL; + } + + link_id = nla_get_u8(attrs[NL80211_ATTR_MLO_LINK_ID]); + /* cannot use the same link ID again */ + if (links[link_id].bss) { + NL_SET_BAD_ATTR(info->extack, link); + return -EINVAL; + } + links[link_id].bss = + nl80211_assoc_bss(rdev, ssid, ssid_len, attrs, + link_id, link_id); + if (IS_ERR(links[link_id].bss)) { + err = PTR_ERR(links[link_id].bss); + links[link_id].bss = NULL; + NL_SET_ERR_MSG_ATTR(info->extack, link, + "Error fetching BSS for link"); + return err; + } + + if (attrs[NL80211_ATTR_IE]) { + links[link_id].elems = nla_data(attrs[NL80211_ATTR_IE]); + links[link_id].elems_len = + nla_len(attrs[NL80211_ATTR_IE]); + + if (cfg80211_find_elem(WLAN_EID_FRAGMENT, + links[link_id].elems, + links[link_id].elems_len)) { + NL_SET_ERR_MSG_ATTR(info->extack, + attrs[NL80211_ATTR_IE], + "cannot deal with fragmentation"); + return -EINVAL; + } + + if (cfg80211_find_ext_elem(WLAN_EID_EXT_NON_INHERITANCE, + links[link_id].elems, + links[link_id].elems_len)) { + NL_SET_ERR_MSG_ATTR(info->extack, + attrs[NL80211_ATTR_IE], + "cannot deal with non-inheritance"); + return -EINVAL; + } + } + + links[link_id].disabled = + nla_get_flag(attrs[NL80211_ATTR_MLO_LINK_DISABLED]); + } + + return 0; +} + static int nl80211_associate(struct sk_buff *skb, struct genl_info *info) { struct cfg80211_registered_device *rdev = info->user_ptr[0]; struct net_device *dev = info->user_ptr[1]; struct cfg80211_assoc_request req = {}; - struct nlattr **attrs = NULL; const u8 *ap_addr, *ssid; unsigned int link_id; int err, ssid_len; @@ -11257,10 +11328,6 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info) req.link_id = nl80211_link_id_or_invalid(info->attrs); if (info->attrs[NL80211_ATTR_MLO_LINKS]) { - unsigned int attrsize = NUM_NL80211_ATTR * sizeof(*attrs); - struct nlattr *link; - int rem = 0; - if (req.link_id < 0) return -EINVAL; @@ -11275,72 +11342,10 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info) req.ap_mld_addr = nla_data(info->attrs[NL80211_ATTR_MLD_ADDR]); ap_addr = req.ap_mld_addr; - attrs = kzalloc(attrsize, GFP_KERNEL); - if (!attrs) - return -ENOMEM; - - nla_for_each_nested(link, - info->attrs[NL80211_ATTR_MLO_LINKS], - rem) { - memset(attrs, 0, attrsize); - - nla_parse_nested(attrs, NL80211_ATTR_MAX, - link, NULL, NULL); - - if (!attrs[NL80211_ATTR_MLO_LINK_ID]) { - err = -EINVAL; - NL_SET_BAD_ATTR(info->extack, link); - goto free; - } - - link_id = nla_get_u8(attrs[NL80211_ATTR_MLO_LINK_ID]); - /* cannot use the same link ID again */ - if (req.links[link_id].bss) { - err = -EINVAL; - NL_SET_BAD_ATTR(info->extack, link); - goto free; - } - req.links[link_id].bss = - nl80211_assoc_bss(rdev, ssid, ssid_len, attrs, - req.link_id, link_id); - if (IS_ERR(req.links[link_id].bss)) { - err = PTR_ERR(req.links[link_id].bss); - req.links[link_id].bss = NULL; - NL_SET_ERR_MSG_ATTR(info->extack, - link, "Error fetching BSS for link"); - goto free; - } - - if (attrs[NL80211_ATTR_IE]) { - req.links[link_id].elems = - nla_data(attrs[NL80211_ATTR_IE]); - req.links[link_id].elems_len = - nla_len(attrs[NL80211_ATTR_IE]); - - if (cfg80211_find_elem(WLAN_EID_FRAGMENT, - req.links[link_id].elems, - req.links[link_id].elems_len)) { - NL_SET_ERR_MSG_ATTR(info->extack, - attrs[NL80211_ATTR_IE], - "cannot deal with fragmentation"); - err = -EINVAL; - goto free; - } - - if (cfg80211_find_ext_elem(WLAN_EID_EXT_NON_INHERITANCE, - req.links[link_id].elems, - req.links[link_id].elems_len)) { - NL_SET_ERR_MSG_ATTR(info->extack, - attrs[NL80211_ATTR_IE], - "cannot deal with non-inheritance"); - err = -EINVAL; - goto free; - } - } - - req.links[link_id].disabled = - nla_get_flag(attrs[NL80211_ATTR_MLO_LINK_DISABLED]); - } + err = nl80211_process_links(rdev, req.links, ssid, ssid_len, + info); + if (err) + goto free; if (!req.links[req.link_id].bss) { err = -EINVAL; @@ -11360,9 +11365,6 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info) err = -EINVAL; goto free; } - - kfree(attrs); - attrs = NULL; } else { if (req.link_id >= 0) return -EINVAL; @@ -11422,7 +11424,6 @@ static int nl80211_associate(struct sk_buff *skb, struct genl_info *info) for (link_id = 0; link_id < ARRAY_SIZE(req.links); link_id++) cfg80211_put_bss(&rdev->wiphy, req.links[link_id].bss); cfg80211_put_bss(&rdev->wiphy, req.bss); - kfree(attrs); return err; } From patchwork Thu Jan 2 14:19:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miri Korenblit X-Patchwork-Id: 13924497 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 EF5C11B413C for ; Thu, 2 Jan 2025 14:20:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827629; cv=none; b=dCkKdeOXcUIy10XPFuVai8eDEKhX710ddJn9rSvPSIGiy1ZZVxxhX/lTgcZY4QEvowyOVQFSRS/V/d9W1KJPU6JHxq+UMshRfyHyUcvU7V61OYAwKNDsLKoqXl4O/gyo7Qz/J7Q2NpkbZ/8cF4mErCJoriiv/syU3YBiENdl30w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827629; c=relaxed/simple; bh=CrLh/jyYsi7aC8AolFESjybslFWGt6k+GdAxKTLK/e0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mapdwQhDLoBxzlqnTK/ds/KR6B9vYYaboOB4FGi+51Kc8HSUDWm4fDZAV586ZUgfTup5QfkK3bnugakOvl2K1AxsF1cgzeXVJnmcbFJ1iHZrGtZevRtr/qfZg8ZfnTzMzN2pY8/hnhSg7wP8AK4eCZNZ8lOM4eP8fOoGLZBopF0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=SGnlfKE+; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SGnlfKE+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735827628; x=1767363628; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CrLh/jyYsi7aC8AolFESjybslFWGt6k+GdAxKTLK/e0=; b=SGnlfKE+Kf5GcmDmOtQSC4SRFCl0EDl8BjKyfwzrCH93inSR1WF0ueAr HmubRKFZxSu0sw/oBnZUWhu+7Wh1EhurYuMalY11SRNHv182ooyg2AzJv 2qAitPtt1GyquEe1fasC+zk9/TIqrC4ATE0dFDpHYapxGqVN/CTeD4fV6 j1tK8H7z6R/X1GvheZENI7kFcZZUBjQgOHkOjEO3+lFLdaXPXuMdId/fd Ic5vANlP6Ac3A3u5Lte0LfzoXWFP8fSXw/9KN5lwd/KUdUVYWiJfqRsJf JTXhEWTlKa+9KGVNJw52CXIvY7GssqDSmPmiy9ZEx0s6HaOzEYKoMeIdj g==; X-CSE-ConnectionGUID: qqUjBsgMQxuutyU8WDmRfw== X-CSE-MsgGUID: Q+BYqruaRV6rjX+hcnA5Xg== X-IronPort-AV: E=McAfee;i="6700,10204,11302"; a="46735100" X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="46735100" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:28 -0800 X-CSE-ConnectionGUID: LPjYiVMjTqWEMVaqBTjSQg== X-CSE-MsgGUID: ntR8Qcu4SK23O+UnWb3bag== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="132357374" Received: from weis0040.iil.intel.com ([10.12.217.108]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:26 -0800 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Ilan Peer Subject: [PATCH 03/17] wifi: cfg80211: Add support for dynamic addition/removal of links Date: Thu, 2 Jan 2025 16:19:55 +0200 Message-Id: <20250102161730.cef23352f2a2.I79c849974c494cb1cbf9e1b22a5d2d37395ff5ac@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> References: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited From: Ilan Peer Add support for requesting dynamic addition/removal of links to the current MLO association. Signed-off-by: Ilan Peer Signed-off-by: Miri Korenblit --- include/net/cfg80211.h | 45 +++++++++++++++++++ include/uapi/linux/nl80211.h | 10 +++++ net/wireless/core.h | 4 ++ net/wireless/mlme.c | 77 +++++++++++++++++++++++++++++++++ net/wireless/nl80211.c | 84 ++++++++++++++++++++++++++++++++++++ net/wireless/nl80211.h | 3 ++ net/wireless/rdev-ops.h | 19 ++++++++ net/wireless/trace.h | 44 +++++++++++++++++++ 8 files changed, 286 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 8a38d66be2c9..d4b4cabac029 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -4596,6 +4596,15 @@ struct mgmt_frame_regs { * @set_ttlm: set the TID to link mapping. * @get_radio_mask: get bitmask of radios in use. * (invoked with the wiphy mutex held) + * @assoc_ml_reconf: Request a non-AP MLO connection to perform ML + * reconfiguration, i.e., add and/or remove links to/from the + * association using ML reconfiguration action frames. Successfully added + * links will be added to the set of valid links. Successfully removed + * links will be removed from the set of valid links. The driver must + * indicate removed links by calling cfg80211_links_removed() and added + * links by calling cfg80211_mlo_reconf_add_done(). When calling + * cfg80211_mlo_reconf_add_done() the bss pointer must be given for each + * link for which MLO reconfiguration 'add' operation was requested. */ struct cfg80211_ops { int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow); @@ -4959,6 +4968,9 @@ struct cfg80211_ops { int (*set_ttlm)(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_ttlm_params *params); u32 (*get_radio_mask)(struct wiphy *wiphy, struct net_device *dev); + int (*assoc_ml_reconf)(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_assoc_link *add_links, + u16 rem_links); }; /* @@ -9716,6 +9728,39 @@ static inline int cfg80211_color_change_notify(struct net_device *dev, */ void cfg80211_links_removed(struct net_device *dev, u16 link_mask); +/** + * struct cfg80211_mlo_reconf_done_data - MLO reconfiguration data + * @buf: MLO Reconfiguration Response frame (header + body) + * @len: length of the frame data + * @added_links: BIT mask of links successfully added to the association + * @links: per-link information indexed by link ID + * @links.bss: the BSS that MLO reconfiguration was requested for, ownership of + * the pointer moves to cfg80211 in the call to + * cfg80211_mlo_reconf_add_done(). + * + * The BSS pointer must be set for each link for which 'add' operation was + * requested in the assoc_ml_reconf callback. + */ +struct cfg80211_mlo_reconf_done_data { + const u8 *buf; + size_t len; + u16 added_links; + struct { + struct cfg80211_bss *bss; + } links[IEEE80211_MLD_MAX_NUM_LINKS]; +}; + +/** + * cfg80211_mlo_reconf_add_done - Notify about MLO reconfiguration result + * @dev: network device. + * @data: MLO reconfiguration done data, &struct cfg80211_mlo_reconf_done_data + * + * Inform cfg80211 and the userspace that processing of ML reconfiguration + * request to add links to the association is done. + */ +void cfg80211_mlo_reconf_add_done(struct net_device *dev, + struct cfg80211_mlo_reconf_done_data *data); + /** * cfg80211_schedule_channels_check - schedule regulatory check if needed * @wdev: the wireless device to check diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index ee1cf19803ea..f900d7cc42bc 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -1329,6 +1329,9 @@ * %NL80211_ATTR_MLO_TTLM_ULINK attributes are used to specify the * TID to Link mapping for downlink/uplink traffic. * + * @NL80211_CMD_ASSOC_MLO_RECONF: For a non-AP MLD station, request to + * add/remove links to/from the association. + * * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */ @@ -1586,6 +1589,8 @@ enum nl80211_commands { NL80211_CMD_SET_TID_TO_LINK_MAPPING, + NL80211_CMD_ASSOC_MLO_RECONF, + /* add new commands above here */ /* used to define NL80211_CMD_MAX below */ @@ -2877,6 +2882,9 @@ enum nl80211_commands { * This can be used to provide a list of selectors that are implemented * by the supplicant. If not given, support for SAE_H2E is assumed. * + * @NL80211_ATTR_MLO_RECONF_REM_LINKS: (u16) A bitmask of the links requested + * to be removed from the MLO association. + * * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use @@ -3429,6 +3437,8 @@ enum nl80211_attrs { NL80211_ATTR_SUPPORTED_SELECTORS, + NL80211_ATTR_MLO_RECONF_REM_LINKS, + /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, diff --git a/net/wireless/core.h b/net/wireless/core.h index 4c45f994a8c0..826299f3d781 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h @@ -567,6 +567,10 @@ int cfg80211_remove_virtual_intf(struct cfg80211_registered_device *rdev, struct wireless_dev *wdev); void cfg80211_wdev_release_link_bsses(struct wireless_dev *wdev, u16 link_mask); +int cfg80211_assoc_ml_reconf(struct cfg80211_registered_device *rdev, + struct net_device *dev, + struct cfg80211_assoc_link *links, + u16 rem_links); /** * struct cfg80211_colocated_ap - colocated AP information * diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c index 5c09bf4cdc2e..e10f2b3b4b7f 100644 --- a/net/wireless/mlme.c +++ b/net/wireless/mlme.c @@ -1294,3 +1294,80 @@ void cfg80211_stop_background_radar_detection(struct wireless_dev *wdev) &rdev->background_radar_chandef, NL80211_RADAR_CAC_ABORTED); } + +int cfg80211_assoc_ml_reconf(struct cfg80211_registered_device *rdev, + struct net_device *dev, + struct cfg80211_assoc_link *links, + u16 rem_links) +{ + struct wireless_dev *wdev = dev->ieee80211_ptr; + int err; + + lockdep_assert_wiphy(wdev->wiphy); + + err = rdev_assoc_ml_reconf(rdev, dev, links, rem_links); + if (!err) { + int link_id; + + for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; + link_id++) { + if (!links[link_id].bss) + continue; + + cfg80211_ref_bss(&rdev->wiphy, links[link_id].bss); + cfg80211_hold_bss(bss_from_pub(links[link_id].bss)); + } + } + + return err; +} + +void cfg80211_mlo_reconf_add_done(struct net_device *dev, + struct cfg80211_mlo_reconf_done_data *data) +{ + struct wireless_dev *wdev = dev->ieee80211_ptr; + struct wiphy *wiphy = wdev->wiphy; + int link_id; + + lockdep_assert_wiphy(wiphy); + + trace_cfg80211_mlo_reconf_add_done(dev, data->added_links, + data->buf, data->len); + + if (WARN_ON(!wdev->valid_links)) + return; + + if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION && + wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)) + return; + + /* validate that a BSS is given for each added link */ + for (link_id = 0; link_id < ARRAY_SIZE(data->links); link_id++) { + struct cfg80211_bss *bss = data->links[link_id].bss; + + if (!(data->added_links & BIT(link_id))) + continue; + + if (WARN_ON(!bss)) + return; + } + + for (link_id = 0; link_id < ARRAY_SIZE(data->links); link_id++) { + struct cfg80211_bss *bss = data->links[link_id].bss; + + if (!bss) + continue; + + if (data->added_links & BIT(link_id)) { + wdev->links[link_id].client.current_bss = + bss_from_pub(bss); + } else { + cfg80211_unhold_bss(bss_from_pub(bss)); + cfg80211_put_bss(wiphy, bss); + } + } + + wdev->valid_links |= data->added_links; + nl80211_mlo_reconf_add_done(dev, data); +} +EXPORT_SYMBOL(cfg80211_mlo_reconf_add_done); diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 9a9e61421c47..ea7eda9feabb 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -848,6 +848,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { [NL80211_ATTR_SUPPORTED_SELECTORS] = NLA_POLICY_VALIDATE_FN(NLA_BINARY, validate_supported_selectors, NL80211_MAX_SUPP_SELECTORS), + [NL80211_ATTR_MLO_RECONF_REM_LINKS] = { .type = NLA_U16 }, }; /* policy for the key attributes */ @@ -16475,6 +16476,66 @@ nl80211_set_ttlm(struct sk_buff *skb, struct genl_info *info) return rdev_set_ttlm(rdev, dev, ¶ms); } +static int nl80211_assoc_ml_reconf(struct sk_buff *skb, struct genl_info *info) +{ + struct cfg80211_registered_device *rdev = info->user_ptr[0]; + struct net_device *dev = info->user_ptr[1]; + struct wireless_dev *wdev = dev->ieee80211_ptr; + struct cfg80211_assoc_link links[IEEE80211_MLD_MAX_NUM_LINKS] = {}; + unsigned int link_id; + u16 add_links, rem_links; + int err; + + if (!wdev->valid_links) + return -EINVAL; + + if (dev->ieee80211_ptr->conn_owner_nlportid && + dev->ieee80211_ptr->conn_owner_nlportid != info->snd_portid) + return -EPERM; + + if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION && + dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT) + return -EOPNOTSUPP; + + add_links = 0; + if (info->attrs[NL80211_ATTR_MLO_LINKS]) { + err = nl80211_process_links(rdev, links, NULL, 0, info); + if (err) + return err; + + for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; + link_id++) { + if (!links[link_id].bss) + continue; + add_links |= BIT(link_id); + } + } + + if (info->attrs[NL80211_ATTR_MLO_RECONF_REM_LINKS]) + rem_links = + nla_get_u16(info->attrs[NL80211_ATTR_MLO_RECONF_REM_LINKS]); + else + rem_links = 0; + + /* Validate that existing links are not added, removed links are valid + * and don't allow adding and removing the same links + */ + if ((add_links & rem_links) || !(add_links | rem_links) || + (wdev->valid_links & add_links) || + ((wdev->valid_links & rem_links) != rem_links)) { + err = -EINVAL; + goto out; + } + + err = cfg80211_assoc_ml_reconf(rdev, dev, links, rem_links); + +out: + for (link_id = 0; link_id < ARRAY_SIZE(links); link_id++) + cfg80211_put_bss(&rdev->wiphy, links[link_id].bss); + + return err; +} + #define NL80211_FLAG_NEED_WIPHY 0x01 #define NL80211_FLAG_NEED_NETDEV 0x02 #define NL80211_FLAG_NEED_RTNL 0x04 @@ -17667,6 +17728,12 @@ static const struct genl_small_ops nl80211_small_ops[] = { .flags = GENL_UNS_ADMIN_PERM, .internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP), }, + { + .cmd = NL80211_CMD_ASSOC_MLO_RECONF, + .doit = nl80211_assoc_ml_reconf, + .flags = GENL_UNS_ADMIN_PERM, + .internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP), + }, }; static struct genl_family nl80211_fam __ro_after_init = { @@ -18563,6 +18630,23 @@ void cfg80211_links_removed(struct net_device *dev, u16 link_mask) } EXPORT_SYMBOL(cfg80211_links_removed); +void nl80211_mlo_reconf_add_done(struct net_device *dev, + struct cfg80211_mlo_reconf_done_data *data) +{ + struct wireless_dev *wdev = dev->ieee80211_ptr; + struct wiphy *wiphy = wdev->wiphy; + struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); + struct nl80211_mlme_event event = { + .cmd = NL80211_CMD_ASSOC_MLO_RECONF, + .buf = data->buf, + .buf_len = data->len, + .uapsd_queues = -1, + }; + + nl80211_send_mlme_event(rdev, dev, &event, GFP_KERNEL); +} +EXPORT_SYMBOL(nl80211_mlo_reconf_add_done); + void nl80211_send_ibss_bssid(struct cfg80211_registered_device *rdev, struct net_device *netdev, const u8 *bssid, gfp_t gfp) diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h index ffaab9a92e5b..5e25782af1e0 100644 --- a/net/wireless/nl80211.h +++ b/net/wireless/nl80211.h @@ -124,4 +124,7 @@ void cfg80211_free_coalesce(struct cfg80211_coalesce *coalesce); /* peer measurement */ int nl80211_pmsr_start(struct sk_buff *skb, struct genl_info *info); +void nl80211_mlo_reconf_add_done(struct net_device *dev, + struct cfg80211_mlo_reconf_done_data *data); + #endif /* __NET_WIRELESS_NL80211_H */ diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h index 8f2aa7e76c0a..2393a25577ad 100644 --- a/net/wireless/rdev-ops.h +++ b/net/wireless/rdev-ops.h @@ -1547,4 +1547,23 @@ rdev_get_radio_mask(struct cfg80211_registered_device *rdev, return rdev->ops->get_radio_mask(wiphy, dev); } + +static inline int +rdev_assoc_ml_reconf(struct cfg80211_registered_device *rdev, + struct net_device *dev, + struct cfg80211_assoc_link *add_links, + u16 rem_links) +{ + struct wiphy *wiphy = &rdev->wiphy; + int ret = -EOPNOTSUPP; + + trace_rdev_assoc_ml_reconf(wiphy, dev, add_links, rem_links); + if (rdev->ops->assoc_ml_reconf) + ret = rdev->ops->assoc_ml_reconf(wiphy, dev, add_links, + rem_links); + trace_rdev_return_int(wiphy, ret); + + return ret; +} + #endif /* __CFG80211_RDEV_OPS */ diff --git a/net/wireless/trace.h b/net/wireless/trace.h index 41a9f52e1f97..d57e676cb5af 100644 --- a/net/wireless/trace.h +++ b/net/wireless/trace.h @@ -4104,6 +4104,50 @@ TRACE_EVENT(cfg80211_links_removed, __entry->link_mask) ); +TRACE_EVENT(cfg80211_mlo_reconf_add_done, + TP_PROTO(struct net_device *netdev, u16 link_mask, + const u8 *buf, size_t len), + TP_ARGS(netdev, link_mask, buf, len), + TP_STRUCT__entry( + NETDEV_ENTRY + __field(u16, link_mask) + __dynamic_array(u8, buf, len) + ), + TP_fast_assign( + NETDEV_ASSIGN; + __entry->link_mask = link_mask; + memcpy(__get_dynamic_array(buf), buf, len); + ), + TP_printk(NETDEV_PR_FMT ", link_mask:0x%x", + NETDEV_PR_ARG, __entry->link_mask) +); + +TRACE_EVENT(rdev_assoc_ml_reconf, + TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, + struct cfg80211_assoc_link *add_links, + u16 rem_links), + TP_ARGS(wiphy, netdev, add_links, rem_links), + TP_STRUCT__entry( + WIPHY_ENTRY + NETDEV_ENTRY + __field(u16, add_links) + __field(u16, rem_links) + ), + TP_fast_assign( + WIPHY_ASSIGN; + NETDEV_ASSIGN; + u32 i; + + __entry->add_links = 0; + __entry->rem_links = rem_links; + for (i = 0; add_links && i < IEEE80211_MLD_MAX_NUM_LINKS; i++) + if (add_links[i].bss) + __entry->add_links |= BIT(i); + ), + TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", add_links=0x%x, rem_links=0x%x", + WIPHY_PR_ARG, NETDEV_PR_ARG, + __entry->add_links, __entry->rem_links) +); #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */ #undef TRACE_INCLUDE_PATH From patchwork Thu Jan 2 14:19:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miri Korenblit X-Patchwork-Id: 13924498 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 881811B3724 for ; Thu, 2 Jan 2025 14:20:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827631; cv=none; b=m5m9ZGRN9PZ2V07HwfUczq9qxGQlTCH3V5WNq0iCWlKo6Vb9hK/Nemk9H6ncCgglh81W2wuNHZf98RTKaufwn9d6aMyS+TTxUC36KxdVxZ21q4JjNJ477PNadePB8FjlEOCsSwhE5AGEgGMCUr/ijYWEYOnclxaiASYs6U4WDmU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827631; c=relaxed/simple; bh=KrepId+URL+McHwvoO3F0S5zSWcZ63fMVY5SnCf6h4w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FFnPO+AW6mD2TXTUcmenRLy8pJaGVZs+Z1kbrOYr9PjuK1ulZp4XBgoeYaTAxjQjUy35JYC2NFb7q/5e+pxMOoAbigEROpd2gs8wi/jjK1YHIzxVGRrfU8/9oOxUsE6s3+zDZ1UMBYsIUb4hYFbM2bUpQ6n+kjcu9TCPZDSZxOk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Q+GzATO9; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Q+GzATO9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735827629; x=1767363629; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KrepId+URL+McHwvoO3F0S5zSWcZ63fMVY5SnCf6h4w=; b=Q+GzATO9CMH+NsShWdXHRGHYNLChhdeg2NbVXSqKXK/9JCebLmL/wKoZ XU/eCz9khxC8Ysq7E//YNF6uRv8r7J4BCDlZZaq4BxcB2gosF0oHRbB3M 1CjOnxcwhwXlLoDDRftEdzurPpbf3eCzSgGp4itbBjvPmhdILNZ4Lz20N xXzWTtoruzUPQmMfF/qGaFTZsbZffFCpt1sEq5CBfWi+ZyI9Xp+zCPey1 PqP/mCzQVz6aYmwICN7kmxSc43NStCxGBcCuak01h3nLOdV544qUzuWEh I1nXWuPEd69rzJz6LjhrmOKlbrntXa/TcCZoUvmhSQL+ppKh8RepxQ5Sn Q==; X-CSE-ConnectionGUID: NL4gudYoTsiYPynnw9Zkbw== X-CSE-MsgGUID: THe1Ow/WT1K8iY4Spk/20Q== X-IronPort-AV: E=McAfee;i="6700,10204,11302"; a="46735103" X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="46735103" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:29 -0800 X-CSE-ConnectionGUID: FOYP2xY2TdaoZmuECGkDpA== X-CSE-MsgGUID: 7GzsFYi/RsihTy0eJnrfdw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="132357382" Received: from weis0040.iil.intel.com ([10.12.217.108]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:27 -0800 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Ilan Peer , Johannes Berg Subject: [PATCH 04/17] wifi: mac80211: Refactor adding association elements Date: Thu, 2 Jan 2025 16:19:56 +0200 Message-Id: <20250102161730.191f58f2bba7.I6baa6e2989a39937234ff91d7db5ff1359a6bb30@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> References: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited From: Ilan Peer Instead of always using 'sdata->u.mgd.assoc_data' have the association data be passed as an argument. This will later allow to use the same functionality for adding links to the current association. Signed-off-by: Ilan Peer Reviewed-by: Johannes Berg Signed-off-by: Miri Korenblit --- net/mac80211/mlme.c | 73 +++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index ad4a474585e0..50bbe4532ac1 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -1636,23 +1636,25 @@ static size_t ieee80211_add_before_he_elems(struct sk_buff *skb, #define PRESENT_ELEMS_MAX 8 #define PRESENT_ELEM_EXT_OFFS 0x100 -static void ieee80211_assoc_add_ml_elem(struct ieee80211_sub_if_data *sdata, - struct sk_buff *skb, u16 capab, - const struct element *ext_capa, - const u16 *present_elems); - -static size_t ieee80211_assoc_link_elems(struct ieee80211_sub_if_data *sdata, - struct sk_buff *skb, u16 *capab, - const struct element *ext_capa, - const u8 *extra_elems, - size_t extra_elems_len, - unsigned int link_id, - struct ieee80211_link_data *link, - u16 *present_elems) +static void +ieee80211_assoc_add_ml_elem(struct ieee80211_sub_if_data *sdata, + struct sk_buff *skb, u16 capab, + const struct element *ext_capa, + const u16 *present_elems, + struct ieee80211_mgd_assoc_data *assoc_data); + +static size_t +ieee80211_add_link_elems(struct ieee80211_sub_if_data *sdata, + struct sk_buff *skb, u16 *capab, + const struct element *ext_capa, + const u8 *extra_elems, + size_t extra_elems_len, + unsigned int link_id, + struct ieee80211_link_data *link, + u16 *present_elems, + struct ieee80211_mgd_assoc_data *assoc_data) { enum nl80211_iftype iftype = ieee80211_vif_type_p2p(&sdata->vif); - struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; - struct ieee80211_mgd_assoc_data *assoc_data = ifmgd->assoc_data; struct cfg80211_bss *cbss = assoc_data->link[link_id].bss; struct ieee80211_channel *chan = cbss->channel; const struct ieee80211_sband_iftype_data *iftd; @@ -1801,7 +1803,7 @@ static size_t ieee80211_assoc_link_elems(struct ieee80211_sub_if_data *sdata, if (link_id == assoc_data->assoc_link_id) ieee80211_assoc_add_ml_elem(sdata, skb, orig_capab, ext_capa, - present_elems); + present_elems, assoc_data); /* crash if somebody gets it wrong */ present_elems = NULL; @@ -1880,14 +1882,14 @@ static void ieee80211_add_non_inheritance_elem(struct sk_buff *skb, *len = skb->len - skb_len - 2; } -static void ieee80211_assoc_add_ml_elem(struct ieee80211_sub_if_data *sdata, - struct sk_buff *skb, u16 capab, - const struct element *ext_capa, - const u16 *outer_present_elems) +static void +ieee80211_assoc_add_ml_elem(struct ieee80211_sub_if_data *sdata, + struct sk_buff *skb, u16 capab, + const struct element *ext_capa, + const u16 *outer_present_elems, + struct ieee80211_mgd_assoc_data *assoc_data) { struct ieee80211_local *local = sdata->local; - struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; - struct ieee80211_mgd_assoc_data *assoc_data = ifmgd->assoc_data; struct ieee80211_multi_link_elem *ml_elem; struct ieee80211_mle_basic_common_info *common; const struct wiphy_iftype_ext_capab *ift_ext_capa; @@ -1960,16 +1962,17 @@ static void ieee80211_assoc_add_ml_elem(struct ieee80211_sub_if_data *sdata, * (if applicable) are skipped. So we only have * the capability field (remember the position and fill * later), followed by the elements added below by - * calling ieee80211_assoc_link_elems(). + * calling ieee80211_add_link_elems(). */ capab_pos = skb_put(skb, 2); - extra_used = ieee80211_assoc_link_elems(sdata, skb, &capab, - ext_capa, - extra_elems, - extra_elems_len, - link_id, NULL, - link_present_elems); + extra_used = ieee80211_add_link_elems(sdata, skb, &capab, + ext_capa, + extra_elems, + extra_elems_len, + link_id, NULL, + link_present_elems, + assoc_data); if (extra_elems) skb_put_data(skb, extra_elems + extra_used, extra_elems_len - extra_used); @@ -2156,12 +2159,12 @@ static int ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) /* add the elements for the assoc (main) link */ link_capab = capab; - offset = ieee80211_assoc_link_elems(sdata, skb, &link_capab, - ext_capa, - assoc_data->ie, - assoc_data->ie_len, - assoc_data->assoc_link_id, link, - present_elems); + offset = ieee80211_add_link_elems(sdata, skb, &link_capab, + ext_capa, + assoc_data->ie, + assoc_data->ie_len, + assoc_data->assoc_link_id, link, + present_elems, assoc_data); put_unaligned_le16(link_capab, capab_pos); /* if present, add any custom non-vendor IEs */ From patchwork Thu Jan 2 14:19:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miri Korenblit X-Patchwork-Id: 13924499 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 2D17F1B4233 for ; Thu, 2 Jan 2025 14:20:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827632; cv=none; b=I2pMbAsau6FQMDzK8xBcEE/ArLmF73LhONyDgtp8Ojgqquwy+F6iff/ag3CEB7YVrYQkhvu1iexY80t/dDi26ZoZNd0nyf7JBK0u9HKZUUzmCqO7+MEsFO6QrPcx9eYJ+nAcsKj5lS/ToH0NNsrR4HBkFk4b62RC/zvDXJv1UrM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827632; c=relaxed/simple; bh=+zNhoZ9QtSqC+/2DxO6GtoDNitjMjDHgzqgTWGKXVEY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tgbAzcjVz7bg3SEcxegO9N7TCoHRORgbQnYHyjG6X2L/E1asNO2Tb9r3fsbxC1lxwHU3R96nYUp11UEIb52ik/rPlVNTgiemlITZUxombdEkKKrwizSVn+ZRv69hNpGtb2P1bnYfaHe4PiUTmyLfiLpF1w7S2eE5ALQbP+lXhEo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=C2BBgqmC; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="C2BBgqmC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735827631; x=1767363631; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+zNhoZ9QtSqC+/2DxO6GtoDNitjMjDHgzqgTWGKXVEY=; b=C2BBgqmCEylizH0OGWFGpK2Xl9xoleyY+eXi6+qzEPqY+K02jazsze1D ECUUPlZOCZDQgiqa2dDFx+PqGgNsxyM07zmPsaC+NtoDopSj2FZ7xdvl/ SsZkavpwEPUHppAqXT2VrsLuEHll5vk6NG8/BLVoJapV8xu+GXSCdnbVD fdICHDf7AM1fRHenniq5vhiDLDrGfIVaTanR3l6Z3xTPtY4ynHOhB0Ybu vJlFCKOcJ1XxNexrUa8yUDua3aTfQh3SL87h9+gAV0BVENWAOcwjUhUE9 Vmb/A2HbcDHpWCql9XyM8xei4Dx/6XEUM9eDQri4Is1yxhQlegA4VbRUC A==; X-CSE-ConnectionGUID: jghjRh2aRe+o2JB4/Ke5vQ== X-CSE-MsgGUID: hlgRh0e9RS6iSUhFhuaeGQ== X-IronPort-AV: E=McAfee;i="6700,10204,11302"; a="46735106" X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="46735106" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:31 -0800 X-CSE-ConnectionGUID: ST+lrMtESKWxJzr61s4JRA== X-CSE-MsgGUID: bITWBi1jTpOtcASN1TyFeA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="132357390" Received: from weis0040.iil.intel.com ([10.12.217.108]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:29 -0800 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Ilan Peer , Johannes Berg Subject: [PATCH 05/17] wifi: mac80211: Pull link space calculation to a function Date: Thu, 2 Jan 2025 16:19:57 +0200 Message-Id: <20250102161730.ac16adfa39d4.I9e28c2fcd5ca252341c817fc03ea8df7b807fcbf@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> References: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited From: Ilan Peer Pull the calculation of the size needed for a link in an association request frame to a function, so it could also be used during the construction of other frames as well, e.g., ML link configuration request frame. Signed-off-by: Ilan Peer Reviewed-by: Johannes Berg Signed-off-by: Miri Korenblit --- net/mac80211/mlme.c | 84 ++++++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 31 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 50bbe4532ac1..390d4d994c6a 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -1989,6 +1989,55 @@ ieee80211_assoc_add_ml_elem(struct ieee80211_sub_if_data *sdata, ieee80211_fragment_element(skb, ml_elem_len, WLAN_EID_FRAGMENT); } +static int +ieee80211_link_common_elems_size(struct ieee80211_sub_if_data *sdata, + enum nl80211_iftype iftype, + struct cfg80211_bss *cbss, + size_t elems_len) +{ + struct ieee80211_local *local = sdata->local; + const struct ieee80211_sband_iftype_data *iftd; + struct ieee80211_supported_band *sband; + size_t size = 0; + + if (!cbss) + return size; + + sband = local->hw.wiphy->bands[cbss->channel->band]; + + /* add STA profile elements length */ + size += elems_len; + + /* and supported rates length */ + size += 4 + sband->n_bitrates; + + /* supported channels */ + size += 2 + 2 * sband->n_channels; + + iftd = ieee80211_get_sband_iftype_data(sband, iftype); + if (iftd) + size += iftd->vendor_elems.len; + + /* power capability */ + size += 4; + + /* HT, VHT, HE, EHT */ + size += 2 + sizeof(struct ieee80211_ht_cap); + size += 2 + sizeof(struct ieee80211_vht_cap); + size += 2 + 1 + sizeof(struct ieee80211_he_cap_elem) + + sizeof(struct ieee80211_he_mcs_nss_supp) + + IEEE80211_HE_PPE_THRES_MAX_LEN; + + if (sband->band == NL80211_BAND_6GHZ) + size += 2 + 1 + sizeof(struct ieee80211_he_6ghz_capa); + + size += 2 + 1 + sizeof(struct ieee80211_eht_cap_elem) + + sizeof(struct ieee80211_eht_mcs_nss_supp) + + IEEE80211_EHT_PPE_THRES_MAX_LEN; + + return size; +} + static int ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) { struct ieee80211_local *local = sdata->local; @@ -2027,42 +2076,15 @@ static int ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) { struct cfg80211_bss *cbss = assoc_data->link[link_id].bss; - const struct ieee80211_sband_iftype_data *iftd; - struct ieee80211_supported_band *sband; + size_t elems_len = assoc_data->link[link_id].elems_len; if (!cbss) continue; - sband = local->hw.wiphy->bands[cbss->channel->band]; - n_links++; - /* add STA profile elements length */ - size += assoc_data->link[link_id].elems_len; - /* and supported rates length */ - size += 4 + sband->n_bitrates; - /* supported channels */ - size += 2 + 2 * sband->n_channels; - - iftd = ieee80211_get_sband_iftype_data(sband, iftype); - if (iftd) - size += iftd->vendor_elems.len; - - /* power capability */ - size += 4; - - /* HT, VHT, HE, EHT */ - size += 2 + sizeof(struct ieee80211_ht_cap); - size += 2 + sizeof(struct ieee80211_vht_cap); - size += 2 + 1 + sizeof(struct ieee80211_he_cap_elem) + - sizeof(struct ieee80211_he_mcs_nss_supp) + - IEEE80211_HE_PPE_THRES_MAX_LEN; - - if (sband->band == NL80211_BAND_6GHZ) - size += 2 + 1 + sizeof(struct ieee80211_he_6ghz_capa); - - size += 2 + 1 + sizeof(struct ieee80211_eht_cap_elem) + - sizeof(struct ieee80211_eht_mcs_nss_supp) + - IEEE80211_EHT_PPE_THRES_MAX_LEN; + + size += ieee80211_link_common_elems_size(sdata, iftype, cbss, + elems_len); /* non-inheritance element */ size += 2 + 2 + PRESENT_ELEMS_MAX; From patchwork Thu Jan 2 14:19:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miri Korenblit X-Patchwork-Id: 13924500 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 E13E41B4236 for ; Thu, 2 Jan 2025 14:20:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827635; cv=none; b=JrFvJR2BuC+fSma1yVYlOO1ABOyfzjBGBUTZkkRLhlnDQvDVBdObPQf8PWuneBgNfAvpGxAG6yEmdkd85kAcuXBJXszzpvHONewhyADhLwsAfDnFgcPU2x/3WQUiGyC5jxrn4I4QVKA+0xGEkfxog3LOaGUsW64Wm4L8ZmumbqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827635; c=relaxed/simple; bh=Oqse3GoMMSRQQA1XJg8n9BVRyEpDfj5KCuZxqKgNGRE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=d+xgDWqoiQHSkO/7gdfBoweaJGCsqfvf3JLq6ti9XqDWNZB6e/NZ5qDrcLrN0WGG9IYgfqPJFQu0DTxcBN7nQgtl1S+eMlkUf0thEYzt9oPHILq7eEiz+A29QC/57LQz1xa1l3UIP1kgZOd/RnUUrljhQkXTA/BAM0kDl0Rvhf0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ErN6R98h; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ErN6R98h" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735827633; x=1767363633; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Oqse3GoMMSRQQA1XJg8n9BVRyEpDfj5KCuZxqKgNGRE=; b=ErN6R98h2o/39WnBIJO3lMqzG5CCNDz6SUfi7YeEU245b5FoeD3eWdFJ 6M80BxPhyA2Wrvu4B02CJI4gwJTIp/hVBLwibA5w+SefbG6g5laGHyju4 ybnddXDKzbCdRM/Pv4yWilREhMU8kyaCd1qFCXu/6J6iG5i2BtCTH1VAs ips97QDelFa/8cEFQiDhkoxgDpZxnLthVHa4tD1ihUKYPyHd/hBFdTjp2 l6ZRLiy23MFhQro0DLUKiJNXqNCtlrPQNcNTviMhvBv42hBCWutoQVDXh VkPPl48MiwNRSH5euPSGThNZmwzOyZ4H+Wk48H8GZwkTvOB6jipkZX/af w==; X-CSE-ConnectionGUID: ixT7iTluROaQBy+AYIbMPA== X-CSE-MsgGUID: 5ERtw/bqTGKUEAJYou7jbA== X-IronPort-AV: E=McAfee;i="6700,10204,11302"; a="46735110" X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="46735110" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:32 -0800 X-CSE-ConnectionGUID: CjeGp7EuS4SQ1KSW1ln+lA== X-CSE-MsgGUID: MgjhRT3eTKysHGB0YjG4eg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="132357397" Received: from weis0040.iil.intel.com ([10.12.217.108]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:31 -0800 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Ilan Peer Subject: [PATCH 06/17] wifi: mac80211: Support dynamic link addition and removal Date: Thu, 2 Jan 2025 16:19:58 +0200 Message-Id: <20250102161730.ec0492a8dd21.I2869686642bbc0f86c40f284ebf7e6f644b551ab@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> References: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited From: Ilan Peer Add support for adding and removing station links: - Adding links is done asynchronously, i.e., first an ML reconfiguration action frame is sent to the AP requesting to add links, and only when the AP replies, links which were added successfully by the AP are added locally. - Removing links is done synchronously, i.e., the links are removed before sending the ML reconfiguration action frame to the AP (to avoid using this links after the AP MLD removed them but before the station got the ML reconfiguration response). In case the AP replies with a status indicating that a link removal was not successful, disconnect (as this should not happen an is an indication that something might be wrong on the AP MLD). Signed-off-by: Ilan Peer Signed-off-by: Miri Korenblit --- include/linux/ieee80211.h | 11 + net/mac80211/cfg.c | 13 + net/mac80211/ieee80211_i.h | 15 + net/mac80211/iface.c | 4 + net/mac80211/mlme.c | 757 ++++++++++++++++++++++++++++++++++++- net/mac80211/rx.c | 12 + 6 files changed, 811 insertions(+), 1 deletion(-) diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index ee6bebfd041d..b5c5b5c39d9a 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -1532,6 +1532,17 @@ struct ieee80211_mgmt { struct { u8 action_code; } __packed ttlm_tear_down; + struct { + u8 action_code; + u8 dialog_token; + u8 variable[]; + } __packed ml_reconf_req; + struct { + u8 action_code; + u8 dialog_token; + u8 count; + u8 variable[]; + } __packed ml_reconf_resp; } u; } __packed action; DECLARE_FLEX_ARRAY(u8, body); /* Generic frame body */ diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index b8495d5f2297..1a912cb8ae8d 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -5180,6 +5180,18 @@ ieee80211_set_ttlm(struct wiphy *wiphy, struct net_device *dev, return ieee80211_req_neg_ttlm(sdata, params); } +static int +ieee80211_assoc_ml_reconf(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_assoc_link *add_links, + u16 rem_links) +{ + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); + + lockdep_assert_wiphy(sdata->local->hw.wiphy); + + return ieee80211_mgd_assoc_ml_reconf(sdata, add_links, rem_links); +} + const struct cfg80211_ops mac80211_config_ops = { .add_virtual_intf = ieee80211_add_iface, .del_virtual_intf = ieee80211_del_iface, @@ -5294,4 +5306,5 @@ const struct cfg80211_ops mac80211_config_ops = { .set_hw_timestamp = ieee80211_set_hw_timestamp, .set_ttlm = ieee80211_set_ttlm, .get_radio_mask = ieee80211_get_radio_mask, + .assoc_ml_reconf = ieee80211_assoc_ml_reconf, }; diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 7b8a0da8eaff..64df7d739ebf 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -606,6 +606,15 @@ struct ieee80211_if_managed { /* dialog token enumerator for neg TTLM request */ u8 dialog_token_alloc; struct wiphy_delayed_work neg_ttlm_timeout_work; + + /* Locally initiated multi-link reconfiguration */ + struct { + struct ieee80211_mgd_assoc_data *add_links_data; + struct wiphy_delayed_work wk; + u16 removed_links; + u16 added_links; + u8 dialog_token; + } reconf; }; struct ieee80211_if_ibss { @@ -2770,6 +2779,12 @@ void ieee80211_check_wbrf_support(struct ieee80211_local *local); void ieee80211_add_wbrf(struct ieee80211_local *local, struct cfg80211_chan_def *chandef); void ieee80211_remove_wbrf(struct ieee80211_local *local, struct cfg80211_chan_def *chandef); +int ieee80211_mgd_assoc_ml_reconf(struct ieee80211_sub_if_data *sdata, + struct cfg80211_assoc_link *add_links, + u16 rem_links); + +void ieee80211_process_ml_reconf_resp(struct ieee80211_sub_if_data *sdata, + struct ieee80211_mgmt *mgmt, size_t len); #if IS_ENABLED(CONFIG_MAC80211_KUNIT_TEST) #define EXPORT_SYMBOL_IF_MAC80211_KUNIT(sym) EXPORT_SYMBOL_IF_KUNIT(sym) #define VISIBLE_IF_MAC80211_KUNIT diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 2e170dbde732..0ea7e77860b7 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -1560,6 +1560,10 @@ static void ieee80211_iface_process_skb(struct ieee80211_local *local, ieee80211_process_neg_ttlm_res(sdata, mgmt, skb->len); break; + case WLAN_PROTECTED_EHT_ACTION_LINK_RECONFIG_RESP: + ieee80211_process_ml_reconf_resp(sdata, mgmt, + skb->len); + break; default: break; } diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 390d4d994c6a..b08b59961bf3 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -3842,6 +3842,38 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, netif_carrier_on(sdata->dev); } +static void ieee80211_ml_reconf_reset(struct ieee80211_sub_if_data *sdata) +{ + struct ieee80211_mgd_assoc_data *add_links_data = + sdata->u.mgd.reconf.add_links_data; + + if (!ieee80211_vif_is_mld(&sdata->vif) || + !(sdata->u.mgd.reconf.added_links | + sdata->u.mgd.reconf.removed_links)) + return; + + wiphy_delayed_work_cancel(sdata->local->hw.wiphy, + &sdata->u.mgd.reconf.wk); + sdata->u.mgd.reconf.added_links = 0; + sdata->u.mgd.reconf.removed_links = 0; + sdata->u.mgd.reconf.dialog_token = 0; + + if (add_links_data) { + struct cfg80211_mlo_reconf_done_data done_data = {}; + u8 link_id; + + for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; + link_id++) + done_data.links[link_id].bss = + add_links_data->link[link_id].bss; + + cfg80211_mlo_reconf_add_done(sdata->dev, &done_data); + + kfree(sdata->u.mgd.reconf.add_links_data); + sdata->u.mgd.reconf.add_links_data = NULL; + } +} + static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, u16 stype, u16 reason, bool tx, u8 *frame_buf) @@ -4034,6 +4066,12 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, ieee80211_vif_set_links(sdata, 0, 0); ifmgd->mcast_seq_last = IEEE80211_SN_MODULO; + + /* if disconnection happens in the middle of the ML reconfiguration + * flow, cfg80211 must called to release the BSS references obtained + * when the flow started. + */ + ieee80211_ml_reconf_reset(sdata); } static void ieee80211_reset_ap_probe(struct ieee80211_sub_if_data *sdata) @@ -4909,7 +4947,8 @@ static bool ieee80211_assoc_config_link(struct ieee80211_link_data *link, u64 *changed) { struct ieee80211_sub_if_data *sdata = link->sdata; - struct ieee80211_mgd_assoc_data *assoc_data = sdata->u.mgd.assoc_data; + struct ieee80211_mgd_assoc_data *assoc_data = + sdata->u.mgd.assoc_data ?: sdata->u.mgd.reconf.add_links_data; struct ieee80211_bss_conf *bss_conf = link->conf; struct ieee80211_local *local = sdata->local; unsigned int link_id = link->link_id; @@ -8338,6 +8377,25 @@ static void ieee80211_request_smps_mgd_work(struct wiphy *wiphy, link->u.mgd.driver_smps_mode); } +static void ieee80211_ml_sta_reconf_timeout(struct wiphy *wiphy, + struct wiphy_work *work) +{ + struct ieee80211_sub_if_data *sdata = + container_of(work, struct ieee80211_sub_if_data, + u.mgd.reconf.wk.work); + + if (!sdata->u.mgd.reconf.added_links && + !sdata->u.mgd.reconf.removed_links) + return; + + sdata_info(sdata, + "mlo: reconf: timeout: added=0x%x, removed=0x%x\n", + sdata->u.mgd.reconf.added_links, + sdata->u.mgd.reconf.removed_links); + + __ieee80211_disconnect(sdata); +} + /* interface setup */ void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata) { @@ -8352,6 +8410,8 @@ void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata) ieee80211_tdls_peer_del_work); wiphy_delayed_work_init(&ifmgd->ml_reconf_work, ieee80211_ml_reconf_work); + wiphy_delayed_work_init(&ifmgd->reconf.wk, + ieee80211_ml_sta_reconf_timeout); timer_setup(&ifmgd->timer, ieee80211_sta_timer, 0); timer_setup(&ifmgd->bcn_mon_timer, ieee80211_sta_bcn_mon_timer, 0); timer_setup(&ifmgd->conn_mon_timer, ieee80211_sta_conn_mon_timer, 0); @@ -8412,6 +8472,9 @@ void ieee80211_mgd_setup_link(struct ieee80211_link_data *link) if (sdata->u.mgd.assoc_data) ether_addr_copy(link->conf->addr, sdata->u.mgd.assoc_data->link[link_id].addr); + else if (sdata->u.mgd.reconf.add_links_data) + ether_addr_copy(link->conf->addr, + sdata->u.mgd.reconf.add_links_data->link[link_id].addr); else if (!is_valid_ether_addr(link->conf->addr)) eth_random_addr(link->conf->addr); } @@ -9665,3 +9728,695 @@ void ieee80211_disable_rssi_reports(struct ieee80211_vif *vif) _ieee80211_enable_rssi_reports(sdata, 0, 0); } EXPORT_SYMBOL(ieee80211_disable_rssi_reports); + +static void ieee80211_ml_reconf_selectors(unsigned long *userspace_selectors) +{ + *userspace_selectors = 0; + + /* these selectors are mandatory for ML reconfiguration */ + set_bit(BSS_MEMBERSHIP_SELECTOR_SAE_H2E, userspace_selectors); + set_bit(BSS_MEMBERSHIP_SELECTOR_HE_PHY, userspace_selectors); + set_bit(BSS_MEMBERSHIP_SELECTOR_EHT_PHY, userspace_selectors); +} + +void ieee80211_process_ml_reconf_resp(struct ieee80211_sub_if_data *sdata, + struct ieee80211_mgmt *mgmt, size_t len) +{ + struct ieee80211_local *local = sdata->local; + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; + struct ieee80211_mgd_assoc_data *add_links_data = + ifmgd->reconf.add_links_data; + struct sta_info *sta; + struct cfg80211_mlo_reconf_done_data done_data = {}; + u16 sta_changed_links = sdata->u.mgd.reconf.added_links | + sdata->u.mgd.reconf.removed_links; + u16 link_mask, valid_links; + unsigned int link_id; + unsigned long userspace_selectors; + size_t orig_len = len; + u8 i, group_key_data_len; + u8 *pos; + + if (!ieee80211_vif_is_mld(&sdata->vif) || + len < offsetofend(typeof(*mgmt), u.action.u.ml_reconf_resp) || + mgmt->u.action.u.ml_reconf_resp.dialog_token != + sdata->u.mgd.reconf.dialog_token || + !sta_changed_links) + return; + + pos = mgmt->u.action.u.ml_reconf_resp.variable; + len -= offsetofend(typeof(*mgmt), u.action.u.ml_reconf_resp); + + /* each status duple is 3 octets */ + if (len < mgmt->u.action.u.ml_reconf_resp.count * 3) { + sdata_info(sdata, + "mlo: reconf: unexpected len=%zu, count=%u\n", + len, mgmt->u.action.u.ml_reconf_resp.count); + goto disconnect; + } + + link_mask = sta_changed_links; + for (i = 0; i < mgmt->u.action.u.ml_reconf_resp.count; i++) { + u16 status = get_unaligned_le16(pos + 1); + + link_id = *pos; + + if (!(link_mask & BIT(link_id))) { + sdata_info(sdata, + "mlo: reconf: unexpected link: %u, changed=0x%x\n", + link_id, sta_changed_links); + goto disconnect; + } + + /* clear the corresponding link, to detect the case that + * the same link was included more than one time + */ + link_mask &= ~BIT(link_id); + + /* Handle failure to remove links here. Failure to remove added + * links will be done later in the flow. + */ + if (status != WLAN_STATUS_SUCCESS) { + sdata_info(sdata, + "mlo: reconf: failed on link=%u, status=%u\n", + link_id, status); + + /* The AP MLD failed to remove a link that was already + * removed locally. As this is not expected behavior, + * disconnect + */ + if (sdata->u.mgd.reconf.removed_links & BIT(link_id)) + goto disconnect; + + /* The AP MLD failed to add a link. Remove it from the + * added links. + */ + sdata->u.mgd.reconf.added_links &= ~BIT(link_id); + } + + pos += 3; + len -= 3; + } + + if (link_mask) { + sdata_info(sdata, + "mlo: reconf: no response for links=0x%x\n", + link_mask); + goto disconnect; + } + + if (!sdata->u.mgd.reconf.added_links) + goto out; + + if (len < 1 || len < 1 + *pos) { + sdata_info(sdata, + "mlo: reconf: invalid group key data length"); + goto disconnect; + } + + /* The Group Key Data field must be present when links are added. This + * field should be processed by userland. + */ + group_key_data_len = *pos++; + + pos += group_key_data_len; + len -= group_key_data_len + 1; + + /* Process the information for the added links */ + sta = sta_info_get(sdata, sdata->vif.cfg.ap_addr); + if (WARN_ON(!sta)) + goto disconnect; + + valid_links = sdata->vif.valid_links; + for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) { + if (!add_links_data->link[link_id].bss || + !(sdata->u.mgd.reconf.added_links & BIT(link_id))) + + continue; + + valid_links |= BIT(link_id); + if (ieee80211_sta_allocate_link(sta, link_id)) + goto disconnect; + } + + ieee80211_vif_set_links(sdata, valid_links, sdata->vif.dormant_links); + ieee80211_ml_reconf_selectors(&userspace_selectors); + link_mask = 0; + for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) { + struct cfg80211_bss *cbss = add_links_data->link[link_id].bss; + struct ieee80211_link_data *link; + struct link_sta_info *link_sta; + u64 changed = 0; + + if (!cbss) + continue; + + link = sdata_dereference(sdata->link[link_id], sdata); + if (WARN_ON(!link)) + goto disconnect; + + link_info(link, + "mlo: reconf: local address %pM, AP link address %pM\n", + add_links_data->link[link_id].addr, + add_links_data->link[link_id].bss->bssid); + + link_sta = rcu_dereference_protected(sta->link[link_id], + lockdep_is_held(&local->hw.wiphy->mtx)); + if (WARN_ON(!link_sta)) + goto disconnect; + + if (!link->u.mgd.have_beacon) { + const struct cfg80211_bss_ies *ies; + + rcu_read_lock(); + ies = rcu_dereference(cbss->beacon_ies); + if (ies) + link->u.mgd.have_beacon = true; + else + ies = rcu_dereference(cbss->ies); + ieee80211_get_dtim(ies, + &link->conf->sync_dtim_count, + &link->u.mgd.dtim_period); + link->conf->beacon_int = cbss->beacon_interval; + rcu_read_unlock(); + } + + link->conf->dtim_period = link->u.mgd.dtim_period ?: 1; + + link->u.mgd.conn = add_links_data->link[link_id].conn; + if (ieee80211_prep_channel(sdata, link, link_id, cbss, + true, &link->u.mgd.conn, + &userspace_selectors)) { + link_info(link, "mlo: reconf: prep_channel failed\n"); + goto disconnect; + } + + if (ieee80211_mgd_setup_link_sta(link, sta, link_sta, + add_links_data->link[link_id].bss)) + goto disconnect; + + if (!ieee80211_assoc_config_link(link, link_sta, + add_links_data->link[link_id].bss, + mgmt, pos, len, + &changed)) + goto disconnect; + + /* The AP MLD indicated success for this link, but the station + * profile status indicated otherwise. Since there is an + * inconsistency in the ML reconfiguration response, disconnect + */ + if (add_links_data->link[link_id].status != WLAN_STATUS_SUCCESS) + goto disconnect; + + ieee80211_sta_init_nss(link_sta); + if (ieee80211_sta_activate_link(sta, link_id)) + goto disconnect; + + changed |= ieee80211_link_set_associated(link, cbss); + ieee80211_link_info_change_notify(sdata, link, changed); + + ieee80211_recalc_smps(sdata, link); + link_mask |= BIT(link_id); + } + + sdata_info(sdata, + "mlo: reconf: current valid_links=0x%x, added=0x%x\n", + valid_links, link_mask); + + /* links might have changed due to rejected ones, set them again */ + ieee80211_vif_set_links(sdata, valid_links, sdata->vif.dormant_links); + ieee80211_vif_cfg_change_notify(sdata, BSS_CHANGED_MLD_VALID_LINKS); + + ieee80211_recalc_ps(local); + ieee80211_recalc_ps_vif(sdata); + + done_data.buf = (const u8 *)mgmt; + done_data.len = orig_len; + done_data.added_links = link_mask; + + for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) + done_data.links[link_id].bss = add_links_data->link[link_id].bss; + + cfg80211_mlo_reconf_add_done(sdata->dev, &done_data); + kfree(sdata->u.mgd.reconf.add_links_data); + sdata->u.mgd.reconf.add_links_data = NULL; +out: + ieee80211_ml_reconf_reset(sdata); + return; + +disconnect: + __ieee80211_disconnect(sdata); +} + +static struct sk_buff * +ieee80211_build_ml_reconf_req(struct ieee80211_sub_if_data *sdata, + struct ieee80211_mgd_assoc_data *add_links_data, + u16 removed_links) +{ + struct ieee80211_local *local = sdata->local; + struct ieee80211_mgmt *mgmt; + struct ieee80211_multi_link_elem *ml_elem; + struct ieee80211_mle_basic_common_info *common; + enum nl80211_iftype iftype = ieee80211_vif_type_p2p(&sdata->vif); + struct sk_buff *skb; + size_t size; + unsigned int link_id; + __le16 eml_capa = 0, mld_capa_ops = 0; + struct ieee80211_tx_info *info; + u8 common_size, var_common_size; + u8 *ml_elem_len; + u16 capab = 0; + + size = local->hw.extra_tx_headroom + sizeof(*mgmt); + + /* Consider the maximal length of the reconfiguration ML element */ + size += sizeof(struct ieee80211_multi_link_elem); + + /* The Basic ML element and the Reconfiguration ML element have the same + * fixed common information fields in the context of ML reconfiguration + * action frame. The AP MLD MAC address must always be present + */ + common_size = sizeof(*common); + + /* when adding links, the MLD capabilities must be present */ + var_common_size = 0; + if (add_links_data) { + const struct wiphy_iftype_ext_capab *ift_ext_capa = + cfg80211_get_iftype_ext_capa(local->hw.wiphy, + ieee80211_vif_type_p2p(&sdata->vif)); + + if (ift_ext_capa) { + eml_capa = cpu_to_le16(ift_ext_capa->eml_capabilities); + mld_capa_ops = + cpu_to_le16(ift_ext_capa->mld_capa_and_ops); + } + + /* MLD capabilities and operation */ + var_common_size += 2; + + /* EML capabilities */ + if (eml_capa & cpu_to_le16((IEEE80211_EML_CAP_EMLSR_SUPP | + IEEE80211_EML_CAP_EMLMR_SUPPORT))) + var_common_size += 2; + } + + /* Add the common information length */ + size += common_size + var_common_size; + + for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) { + struct cfg80211_bss *cbss; + size_t elems_len; + + if (removed_links & BIT(link_id)) { + size += sizeof(struct ieee80211_mle_per_sta_profile) + + ETH_ALEN; + continue; + } + + if (!add_links_data || !add_links_data->link[link_id].bss) + continue; + + elems_len = add_links_data->link[link_id].elems_len; + cbss = add_links_data->link[link_id].bss; + + /* should be the same across all BSSes */ + if (cbss->capability & WLAN_CAPABILITY_PRIVACY) + capab |= WLAN_CAPABILITY_PRIVACY; + + size += 2 + sizeof(struct ieee80211_mle_per_sta_profile) + + ETH_ALEN; + + /* SSID element + WMM */ + size += 2 + sdata->vif.cfg.ssid_len + 9; + size += ieee80211_link_common_elems_size(sdata, iftype, cbss, + elems_len); + } + + skb = alloc_skb(size, GFP_KERNEL); + if (!skb) + return NULL; + + skb_reserve(skb, local->hw.extra_tx_headroom); + mgmt = skb_put_zero(skb, offsetofend(struct ieee80211_mgmt, + u.action.u.ml_reconf_req)); + + /* Add the MAC header */ + mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | + IEEE80211_STYPE_ACTION); + memcpy(mgmt->da, sdata->vif.cfg.ap_addr, ETH_ALEN); + memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); + memcpy(mgmt->bssid, sdata->vif.cfg.ap_addr, ETH_ALEN); + + /* Add the action frame fixed fields */ + mgmt->u.action.category = WLAN_CATEGORY_PROTECTED_EHT; + mgmt->u.action.u.ml_reconf_req.action_code = + WLAN_PROTECTED_EHT_ACTION_LINK_RECONFIG_REQ; + + /* allocate a dialog token and store it */ + sdata->u.mgd.reconf.dialog_token = ++sdata->u.mgd.dialog_token_alloc; + mgmt->u.action.u.ml_reconf_req.dialog_token = + sdata->u.mgd.reconf.dialog_token; + + /* Add the ML reconfiguration element and the common information */ + skb_put_u8(skb, WLAN_EID_EXTENSION); + ml_elem_len = skb_put(skb, 1); + skb_put_u8(skb, WLAN_EID_EXT_EHT_MULTI_LINK); + ml_elem = skb_put(skb, sizeof(*ml_elem)); + ml_elem->control = + cpu_to_le16(IEEE80211_ML_CONTROL_TYPE_RECONF | + IEEE80211_MLC_RECONF_PRES_MLD_MAC_ADDR); + common = skb_put(skb, common_size); + common->len = common_size + var_common_size; + memcpy(common->mld_mac_addr, sdata->vif.addr, ETH_ALEN); + + if (add_links_data) { + if (eml_capa & + cpu_to_le16((IEEE80211_EML_CAP_EMLSR_SUPP | + IEEE80211_EML_CAP_EMLMR_SUPPORT))) { + ml_elem->control |= + cpu_to_le16(IEEE80211_MLC_RECONF_PRES_EML_CAPA); + skb_put_data(skb, &eml_capa, sizeof(eml_capa)); + } + + ml_elem->control |= + cpu_to_le16(IEEE80211_MLC_RECONF_PRES_MLD_CAPA_OP); + + skb_put_data(skb, &mld_capa_ops, sizeof(mld_capa_ops)); + } + + if (sdata->u.mgd.flags & IEEE80211_STA_ENABLE_RRM) + capab |= WLAN_CAPABILITY_RADIO_MEASURE; + + /* Add the per station profile */ + for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) { + u8 *subelem_len = NULL; + u16 ctrl; + const u8 *addr; + + /* Skip links that are not changing */ + if (!(removed_links & BIT(link_id)) && + (!add_links_data || !add_links_data->link[link_id].bss)) + continue; + + ctrl = link_id | + IEEE80211_MLE_STA_RECONF_CONTROL_STA_MAC_ADDR_PRESENT; + + if (removed_links & BIT(link_id)) { + struct ieee80211_bss_conf *conf = + sdata_dereference(sdata->vif.link_conf[link_id], + sdata); + if (!conf) + continue; + + addr = conf->addr; + ctrl |= u16_encode_bits(IEEE80211_MLE_STA_RECONF_CONTROL_OPERATION_TYPE_DEL_LINK, + IEEE80211_MLE_STA_RECONF_CONTROL_OPERATION_TYPE); + } else { + addr = add_links_data->link[link_id].addr; + ctrl |= IEEE80211_MLE_STA_RECONF_CONTROL_COMPLETE_PROFILE | + u16_encode_bits(IEEE80211_MLE_STA_RECONF_CONTROL_OPERATION_TYPE_ADD_LINK, + IEEE80211_MLE_STA_RECONF_CONTROL_OPERATION_TYPE); + } + + skb_put_u8(skb, IEEE80211_MLE_SUBELEM_PER_STA_PROFILE); + subelem_len = skb_put(skb, 1); + + put_unaligned_le16(ctrl, skb_put(skb, sizeof(ctrl))); + skb_put_u8(skb, 1 + ETH_ALEN); + skb_put_data(skb, addr, ETH_ALEN); + + if (!(removed_links & BIT(link_id))) { + u16 link_present_elems[PRESENT_ELEMS_MAX] = {}; + size_t extra_used; + void *capab_pos; + u8 qos_info; + + capab_pos = skb_put(skb, 2); + + skb_put_u8(skb, WLAN_EID_SSID); + skb_put_u8(skb, sdata->vif.cfg.ssid_len); + skb_put_data(skb, sdata->vif.cfg.ssid, + sdata->vif.cfg.ssid_len); + + extra_used = + ieee80211_add_link_elems(sdata, skb, &capab, NULL, + add_links_data->link[link_id].elems, + add_links_data->link[link_id].elems_len, + link_id, NULL, + link_present_elems, + add_links_data); + + if (add_links_data->link[link_id].elems) + skb_put_data(skb, + add_links_data->link[link_id].elems + + extra_used, + add_links_data->link[link_id].elems_len - + extra_used); + if (sdata->u.mgd.flags & IEEE80211_STA_UAPSD_ENABLED) { + qos_info = sdata->u.mgd.uapsd_queues; + qos_info |= (sdata->u.mgd.uapsd_max_sp_len << + IEEE80211_WMM_IE_STA_QOSINFO_SP_SHIFT); + } else { + qos_info = 0; + } + + ieee80211_add_wmm_info_ie(skb_put(skb, 9), qos_info); + put_unaligned_le16(capab, capab_pos); + } + + ieee80211_fragment_element(skb, subelem_len, + IEEE80211_MLE_SUBELEM_FRAGMENT); + } + + ieee80211_fragment_element(skb, ml_elem_len, WLAN_EID_FRAGMENT); + + info = IEEE80211_SKB_CB(skb); + info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; + + return skb; +} + +int ieee80211_mgd_assoc_ml_reconf(struct ieee80211_sub_if_data *sdata, + struct cfg80211_assoc_link *add_links, + u16 rem_links) +{ + struct ieee80211_local *local = sdata->local; + struct ieee80211_mgd_assoc_data *data = NULL; + struct sta_info *sta; + struct sk_buff *skb; + u16 added_links, new_valid_links; + int link_id, err; + + if (!ieee80211_vif_is_mld(&sdata->vif) || + !(sdata->vif.cfg.mld_capa_op & + IEEE80211_MLD_CAP_OP_LINK_RECONF_SUPPORT)) + return -EINVAL; + + /* No support for concurrent ML reconfiguration operation */ + if (sdata->u.mgd.reconf.added_links || + sdata->u.mgd.reconf.removed_links) + return -EBUSY; + + added_links = 0; + for (link_id = 0; add_links && link_id < IEEE80211_MLD_MAX_NUM_LINKS; + link_id++) { + if (!add_links[link_id].bss) + continue; + + added_links |= BIT(link_id); + } + + sta = sta_info_get(sdata, sdata->vif.cfg.ap_addr); + if (WARN_ON(!sta)) + return -ENOLINK; + + if (rem_links & BIT(sta->sta.deflink.link_id)) + return -EINVAL; + + /* Adding links to the set of valid link is done only after a successful + * ML reconfiguration frame exchange. Here prepare the data for the ML + * reconfiguration frame construction and allocate the required + * resources + */ + if (added_links) { + bool uapsd_supported; + unsigned long userspace_selectors; + + data = kzalloc(sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + uapsd_supported = true; + ieee80211_ml_reconf_selectors(&userspace_selectors); + for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; + link_id++) { + struct ieee80211_supported_band *sband; + struct cfg80211_bss *link_cbss = add_links[link_id].bss; + struct ieee80211_bss *bss; + + if (!link_cbss) + continue; + + bss = (void *)link_cbss->priv; + + if (!bss->wmm_used) { + err = -EINVAL; + goto err_free; + } + + if (link_cbss->channel->band == NL80211_BAND_S1GHZ) { + err = -EINVAL; + goto err_free; + } + + eth_random_addr(data->link[link_id].addr); + data->link[link_id].conn = + ieee80211_conn_settings_unlimited; + sband = + local->hw.wiphy->bands[link_cbss->channel->band]; + + ieee80211_determine_our_sta_mode(sdata, sband, + NULL, true, link_id, + &data->link[link_id].conn); + + data->link[link_id].bss = link_cbss; + data->link[link_id].disabled = + add_links[link_id].disabled; + data->link[link_id].elems = + (u8 *)add_links[link_id].elems; + data->link[link_id].elems_len = + add_links[link_id].elems_len; + + if (!bss->uapsd_supported) + uapsd_supported = false; + + if (data->link[link_id].conn.mode < + IEEE80211_CONN_MODE_EHT) { + err = -EINVAL; + goto err_free; + } + + err = ieee80211_mgd_get_ap_ht_vht_capa(sdata, data, + link_id); + if (err) { + err = -EINVAL; + goto err_free; + } + } + + /* Require U-APSD support to be similar to the current valid + * links + */ + if (uapsd_supported != + !!(sdata->u.mgd.flags & IEEE80211_STA_UAPSD_ENABLED)) { + err = -EINVAL; + goto err_free; + } + + for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; + link_id++) { + if (!data->link[link_id].bss) + continue; + + /* only used to verify the mode, nothing is allocated */ + err = ieee80211_prep_channel(sdata, NULL, link_id, + data->link[link_id].bss, + true, + &data->link[link_id].conn, + &userspace_selectors); + if (err) + goto err_free; + } + } + + /* link removal is done before the ML reconfiguration frame exchange so + * that these links will not be used between their removal by the AP MLD + * and before the station got the ML reconfiguration response. Based on + * Section 35.3.6.4 in Draft P802.11be_D7.0 the AP MLD should accept the + * link removal request. + */ + if (rem_links) { + u16 new_active_links = sdata->vif.active_links & ~rem_links; + + new_valid_links = sdata->vif.valid_links & ~rem_links; + + /* Should not be left with no valid links to perform the + * ML reconfiguration + */ + if (!new_valid_links || + !(new_valid_links & ~sdata->vif.dormant_links)) { + sdata_info(sdata, "mlo: reconf: no valid links\n"); + err = -EINVAL; + goto err_free; + } + + if (new_active_links != sdata->vif.active_links) { + if (!new_active_links) + new_active_links = + BIT(__ffs(new_valid_links & + ~sdata->vif.dormant_links)); + + err = ieee80211_set_active_links(&sdata->vif, + new_active_links); + if (err) { + sdata_info(sdata, + "mlo: reconf: failed set active links\n"); + goto err_free; + } + } + } + + /* Build the SKB before the link removal as the construction of the + * station info for removed links requires the local address. + * Invalidate the removed links, so that the transmission of the ML + * reconfiguration request frame would not be done using them, as the AP + * is expected to send the ML reconfiguration response frame on the link + * on which the request was received. + */ + skb = ieee80211_build_ml_reconf_req(sdata, data, rem_links); + if (!skb) + return -ENOMEM; + + if (rem_links) { + u16 new_dormant_links = sdata->vif.dormant_links & ~rem_links; + + err = ieee80211_vif_set_links(sdata, new_valid_links, + new_dormant_links); + if (err) { + sdata_info(sdata, + "mlo: reconf: failed set valid links\n"); + kfree_skb(skb); + goto err_free; + } + + for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; + link_id++) { + if (!(rem_links & BIT(link_id))) + continue; + + ieee80211_sta_remove_link(sta, link_id); + } + + /* notify the driver and upper layers */ + ieee80211_vif_cfg_change_notify(sdata, + BSS_CHANGED_MLD_VALID_LINKS); + cfg80211_links_removed(sdata->dev, rem_links); + } + + sdata_info(sdata, "mlo: reconf: adding=0x%x, removed=0x%x\n", + added_links, rem_links); + + ieee80211_tx_skb(sdata, skb); + + sdata->u.mgd.reconf.added_links = added_links; + sdata->u.mgd.reconf.add_links_data = data; + sdata->u.mgd.reconf.removed_links = rem_links; + wiphy_delayed_work_queue(sdata->local->hw.wiphy, + &sdata->u.mgd.reconf.wk, + IEEE80211_ASSOC_TIMEOUT_SHORT); + return 0; + + err_free: + kfree(data); + return err; +} diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 3c0cc3cf5ec8..82caf64a5b35 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -3818,6 +3818,18 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) u.action.u.ttlm_res)) goto invalid; goto queue; + case WLAN_PROTECTED_EHT_ACTION_LINK_RECONFIG_RESP: + if (sdata->vif.type != NL80211_IFTYPE_STATION) + break; + + /* The reconfiguration response action frame must + * least one 'Status Duple' entry (3 octets) + */ + if (len < + offsetofend(typeof(*mgmt), + u.action.u.ml_reconf_resp) + 3) + goto invalid; + goto queue; default: break; } From patchwork Thu Jan 2 14:19:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miri Korenblit X-Patchwork-Id: 13924501 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 69B9F1B2188 for ; Thu, 2 Jan 2025 14:20:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827636; cv=none; b=eSBFUNCQwnlKaQ+8DwEftzlNc+4cfsK/0xmzhYCzyW4UZOqR6AtF+Qj01Nx0l/MNt4vR5mo3SEVOMUHVKjKxk1LTWZCKi5cWV7dGaMZId5+uBwWCfndLSrgFVq6yZHViY2rmvkBSS0k/7Bgu1QiBr5XWrwgYSCGqjSkxV+k1y7M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827636; c=relaxed/simple; bh=tkkSXh2Nh9GZyk0MIj87JqN7OpJgyj/pUNbdqdhuZTc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XrxlZhFNx9TBdFUCGOPtkzgcG0HbdAfs1peDxCkALaAYWcT4HkWQwQzq9R84enLc+dASepUqC63gNMhYGAEu0C1Q/OI0rqWzNuexxA6F88z71wJVFPGg+rBMdZ8+d2M1b5FPlg9y6BC9LrP7fkJdlTeN6xqEYbQD2kOmLH0xozA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Fo+dvk+G; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Fo+dvk+G" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735827634; x=1767363634; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tkkSXh2Nh9GZyk0MIj87JqN7OpJgyj/pUNbdqdhuZTc=; b=Fo+dvk+GM/LcWqloZ/CfWByknkpYzt925XsdV7+K1mUEYycMUOgYUxjx kPbSNFjPdYfp2Tyf5EXXAjT/JiFdo1gBLhpuDtQ2nkrEuUxibGxMFoOh4 5UvVBOeZFgYs1qb0YBYzEhuzj9V7Ab+asSXnSkB1LdUofn7EtZ9UbRnTu 4q2a8e73EpNb0A56DAtc40YJkGDCiHaTKk6jHF+VUvDCbUXfNdFCy+u3v Ppb6FYRP0mFPZcQl7pyf2hSdT02Qglc6ytdDrT51TsfWGPL3Njy+hkk1I YQ1SiQZMOvBW7lHzy6SiLAcl4rlny7YarxLrkoyULez/hn39Zppt6EdHQ A==; X-CSE-ConnectionGUID: CL4CKHWxRty2Y/FH7BmZpw== X-CSE-MsgGUID: zloitSc/Ra2y0nWnhBpP9Q== X-IronPort-AV: E=McAfee;i="6700,10204,11302"; a="46735112" X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="46735112" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:34 -0800 X-CSE-ConnectionGUID: /0RINjqgQ0erM9nKBOCepw== X-CSE-MsgGUID: aeF33shRSla06QIEYgMhiw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="132357402" Received: from weis0040.iil.intel.com ([10.12.217.108]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:32 -0800 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Ilan Peer , Johannes Berg Subject: [PATCH 07/17] wifi: cfg80211: Add support for controlling EPCS Date: Thu, 2 Jan 2025 16:19:59 +0200 Message-Id: <20250102161730.ea54ac94445c.I11d750188bc0871e13e86146a3b5cc048d853e69@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> References: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited From: Ilan Peer Add support for configuring Emergency Preparedness Communication Services (EPCS) for station mode. Signed-off-by: Ilan Peer Reviewed-by: Johannes Berg Signed-off-by: Miri Korenblit --- include/net/cfg80211.h | 10 ++++++ include/uapi/linux/nl80211.h | 9 ++++++ net/wireless/nl80211.c | 60 ++++++++++++++++++++++++++++++++++++ net/wireless/rdev-ops.h | 15 +++++++++ net/wireless/trace.h | 34 ++++++++++++++++++++ 5 files changed, 128 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index d4b4cabac029..363d7dd2255a 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -4594,6 +4594,7 @@ struct mgmt_frame_regs { * * @set_hw_timestamp: Enable/disable HW timestamping of TM/FTM frames. * @set_ttlm: set the TID to link mapping. + * @set_epcs: Enable/Disable EPCS for station mode. * @get_radio_mask: get bitmask of radios in use. * (invoked with the wiphy mutex held) * @assoc_ml_reconf: Request a non-AP MLO connection to perform ML @@ -4971,6 +4972,8 @@ struct cfg80211_ops { int (*assoc_ml_reconf)(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_assoc_link *add_links, u16 rem_links); + int (*set_epcs)(struct wiphy *wiphy, struct net_device *dev, + bool val); }; /* @@ -9771,6 +9774,13 @@ void cfg80211_mlo_reconf_add_done(struct net_device *dev, */ void cfg80211_schedule_channels_check(struct wireless_dev *wdev); +/** + * cfg80211_epcs_changed - Notify about a change in EPCS state + * @netdev: the wireless device whose EPCS state changed + * @enabled: set to true if EPCS was enabled, otherwise set to false. + */ +void cfg80211_epcs_changed(struct net_device *netdev, bool enabled); + #ifdef CONFIG_CFG80211_DEBUGFS /** * wiphy_locked_debugfs_read - do a locked read in debugfs diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index f900d7cc42bc..f6c1b181c886 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -1332,6 +1332,10 @@ * @NL80211_CMD_ASSOC_MLO_RECONF: For a non-AP MLD station, request to * add/remove links to/from the association. * + * @NL80211_CMD_EPCS_CFG: EPCS configuration for a station. Used by userland to + * control EPCS configuration. Used to notify userland on the current state + * of EPCS. + * * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */ @@ -1590,6 +1594,7 @@ enum nl80211_commands { NL80211_CMD_SET_TID_TO_LINK_MAPPING, NL80211_CMD_ASSOC_MLO_RECONF, + NL80211_CMD_EPCS_CFG, /* add new commands above here */ @@ -2885,6 +2890,9 @@ enum nl80211_commands { * @NL80211_ATTR_MLO_RECONF_REM_LINKS: (u16) A bitmask of the links requested * to be removed from the MLO association. * + * @NL80211_ATTR_EPCS: Flag attribute indicating that EPCS is enabled for a + * station interface. + * * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use @@ -3438,6 +3446,7 @@ enum nl80211_attrs { NL80211_ATTR_SUPPORTED_SELECTORS, NL80211_ATTR_MLO_RECONF_REM_LINKS, + NL80211_ATTR_EPCS, /* add attributes here, update the policy in nl80211.c */ diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index ea7eda9feabb..d073f14eb6ae 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -849,6 +849,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { NLA_POLICY_VALIDATE_FN(NLA_BINARY, validate_supported_selectors, NL80211_MAX_SUPP_SELECTORS), [NL80211_ATTR_MLO_RECONF_REM_LINKS] = { .type = NLA_U16 }, + [NL80211_ATTR_EPCS] = { .type = NLA_FLAG }, }; /* policy for the key attributes */ @@ -16536,6 +16537,26 @@ static int nl80211_assoc_ml_reconf(struct sk_buff *skb, struct genl_info *info) return err; } +static int +nl80211_epcs_cfg(struct sk_buff *skb, struct genl_info *info) +{ + struct cfg80211_registered_device *rdev = info->user_ptr[0]; + struct net_device *dev = info->user_ptr[1]; + struct wireless_dev *wdev = dev->ieee80211_ptr; + bool val; + + if (wdev->iftype != NL80211_IFTYPE_STATION && + wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) + return -EOPNOTSUPP; + + if (!wdev->connected) + return -ENOLINK; + + val = nla_get_flag(info->attrs[NL80211_ATTR_EPCS]); + + return rdev_set_epcs(rdev, dev, val); +} + #define NL80211_FLAG_NEED_WIPHY 0x01 #define NL80211_FLAG_NEED_NETDEV 0x02 #define NL80211_FLAG_NEED_RTNL 0x04 @@ -17734,6 +17755,12 @@ static const struct genl_small_ops nl80211_small_ops[] = { .flags = GENL_UNS_ADMIN_PERM, .internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP), }, + { + .cmd = NL80211_CMD_EPCS_CFG, + .doit = nl80211_epcs_cfg, + .flags = GENL_UNS_ADMIN_PERM, + .internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP), + }, }; static struct genl_family nl80211_fam __ro_after_init = { @@ -20479,6 +20506,39 @@ void cfg80211_schedule_channels_check(struct wireless_dev *wdev) } EXPORT_SYMBOL(cfg80211_schedule_channels_check); +void cfg80211_epcs_changed(struct net_device *netdev, bool enabled) +{ + struct wireless_dev *wdev = netdev->ieee80211_ptr; + struct wiphy *wiphy = wdev->wiphy; + struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); + struct sk_buff *msg; + void *hdr; + + trace_cfg80211_epcs_changed(wdev, enabled); + + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); + if (!msg) + return; + + hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_EPCS_CFG); + if (!hdr) { + nlmsg_free(msg); + return; + } + + if (enabled && nla_put_flag(msg, NL80211_ATTR_EPCS)) + goto nla_put_failure; + + genlmsg_end(msg, hdr); + genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, + NL80211_MCGRP_MLME, GFP_KERNEL); + return; + + nla_put_failure: + nlmsg_free(msg); +} +EXPORT_SYMBOL(cfg80211_epcs_changed); + /* initialisation/exit functions */ int __init nl80211_init(void) diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h index 2393a25577ad..759da1623342 100644 --- a/net/wireless/rdev-ops.h +++ b/net/wireless/rdev-ops.h @@ -1566,4 +1566,19 @@ rdev_assoc_ml_reconf(struct cfg80211_registered_device *rdev, return ret; } +static inline int +rdev_set_epcs(struct cfg80211_registered_device *rdev, + struct net_device *dev, bool val) +{ + struct wiphy *wiphy = &rdev->wiphy; + int ret = -EOPNOTSUPP; + + trace_rdev_set_epcs(wiphy, dev, val); + if (rdev->ops->set_epcs) + ret = rdev->ops->set_epcs(wiphy, dev, val); + trace_rdev_return_int(wiphy, ret); + + return ret; +} + #endif /* __CFG80211_RDEV_OPS */ diff --git a/net/wireless/trace.h b/net/wireless/trace.h index d57e676cb5af..9aa8081ca454 100644 --- a/net/wireless/trace.h +++ b/net/wireless/trace.h @@ -3049,6 +3049,24 @@ TRACE_EVENT(rdev_set_ttlm, WIPHY_PR_ARG, NETDEV_PR_ARG) ); +TRACE_EVENT(rdev_set_epcs, + TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, + bool val), + TP_ARGS(wiphy, netdev, val), + TP_STRUCT__entry( + WIPHY_ENTRY + NETDEV_ENTRY + __field(bool, val) + ), + TP_fast_assign( + WIPHY_ASSIGN; + NETDEV_ASSIGN; + __entry->val = val; + ), + TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", config=%u", + WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->val) +); + /************************************************************* * cfg80211 exported functions traces * *************************************************************/ @@ -4148,6 +4166,22 @@ TRACE_EVENT(rdev_assoc_ml_reconf, WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->add_links, __entry->rem_links) ); + +TRACE_EVENT(cfg80211_epcs_changed, + TP_PROTO(struct wireless_dev *wdev, bool enabled), + TP_ARGS(wdev, enabled), + TP_STRUCT__entry( + WDEV_ENTRY + __field(u32, enabled) + ), + TP_fast_assign( + WDEV_ASSIGN; + __entry->enabled = enabled; + ), + TP_printk(WDEV_PR_FMT ", enabled=%u", + WDEV_PR_ARG, __entry->enabled) +); + #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */ #undef TRACE_INCLUDE_PATH From patchwork Thu Jan 2 14:20:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miri Korenblit X-Patchwork-Id: 13924502 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 25DE71B4250 for ; Thu, 2 Jan 2025 14:20:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827638; cv=none; b=jITt/ZKV6eFgi8lVyaQsmmNkOW2mQnUDDQFBnSOzV8xruLyG0wILTzSoXLaUwZ4JmmFEza8PQlNiQqhNt9d0jpi6ThcO/y/lKiryY8yNzrz7MuA5bdSQKnOipS1PRzbp4mrN0E4gyOTPTY+XQ+6S3wZJBKzedWCNmxhh1tU4o/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827638; c=relaxed/simple; bh=LXNUUO/V7qb2Kt6nJWhnekim8+kYkn5bm6O9wnH7XqU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=quxgUW1a8rcxmcb7EZzTZO4kwo0qa4QsGB/W9crKyGXJRmSBK51bhaU7EZE2nS9x+SvhzUEsh84KcWncSAT9sEilPvSTlEjqMelfErj/ofc1qJoMEnGfHqao+u9vUNRCgypWbZRmgDX3Hc99Gj/QRgLRHYaEZM2b+AaGiC4Pm7M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=AROyvqCT; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AROyvqCT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735827636; x=1767363636; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LXNUUO/V7qb2Kt6nJWhnekim8+kYkn5bm6O9wnH7XqU=; b=AROyvqCTm8U2TQW7KB6daAR5L30ZLbeuc9Rae0JfunelVYCo8yu6kHkh 5M+RzKbRZgfquuxK/pc5KGPoRBNePhVpnf9CinlhnTtvJ41BXGEn92IoR /dXqPqB5dl+nu271JdLzz5T3baRCKFIq0hStCme4oBH+D5MDePQ3I3luU L4OnNkSeEROEALdNvyTPRfxhpR7oGaa0LD7xBep+Tig9VYHzjruX3y2ts S6WbZAUD6SQK8v9v755ZLOREOyleSkYyUgfbch2BlQv+10tREAao6fqre cd13KYkpDKibjlQMAc25CnhP7sJdlZb3CCSvUZj3RBs87Mo/N3o3mwOJs A==; X-CSE-ConnectionGUID: VPbcwfquSVy7k4Ut5Yw47w== X-CSE-MsgGUID: aD5t0eDGQSyFverS2YZEzw== X-IronPort-AV: E=McAfee;i="6700,10204,11302"; a="46735114" X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="46735114" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:36 -0800 X-CSE-ConnectionGUID: 9Z4kiwtLS3Ou+qb2QItf9w== X-CSE-MsgGUID: 9ZFwPV2lSrex3VVq9++27Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="132357408" Received: from weis0040.iil.intel.com ([10.12.217.108]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:34 -0800 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Ilan Peer , Johannes Berg Subject: [PATCH 08/17] wifi: mac80211: Fix common size calculation for ML element Date: Thu, 2 Jan 2025 16:20:00 +0200 Message-Id: <20250102161730.5790376754a7.I381208cbb72b1be2a88239509294099e9337e254@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> References: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited From: Ilan Peer When the ML type is EPCS the control bitmap is reserved, the length is always 7 and is captured by the 1st octet after the control. Fixes: 0f48b8b88aa9 ("wifi: ieee80211: add definitions for multi-link element") Signed-off-by: Ilan Peer Reviewed-by: Johannes Berg Signed-off-by: Miri Korenblit --- include/linux/ieee80211.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index b5c5b5c39d9a..16741e542e81 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -5084,28 +5084,24 @@ static inline u8 ieee80211_mle_common_size(const u8 *data) { const struct ieee80211_multi_link_elem *mle = (const void *)data; u16 control = le16_to_cpu(mle->control); - u8 common = 0; switch (u16_get_bits(control, IEEE80211_ML_CONTROL_TYPE)) { case IEEE80211_ML_CONTROL_TYPE_BASIC: case IEEE80211_ML_CONTROL_TYPE_PREQ: case IEEE80211_ML_CONTROL_TYPE_TDLS: case IEEE80211_ML_CONTROL_TYPE_RECONF: + case IEEE80211_ML_CONTROL_TYPE_PRIO_ACCESS: /* * The length is the first octet pointed by mle->variable so no * need to add anything */ break; - case IEEE80211_ML_CONTROL_TYPE_PRIO_ACCESS: - if (control & IEEE80211_MLC_PRIO_ACCESS_PRES_AP_MLD_MAC_ADDR) - common += ETH_ALEN; - return common; default: WARN_ON(1); return 0; } - return sizeof(*mle) + common + mle->variable[0]; + return sizeof(*mle) + mle->variable[0]; } /** @@ -5392,8 +5388,7 @@ static inline bool ieee80211_mle_size_ok(const u8 *data, size_t len) check_common_len = true; break; case IEEE80211_ML_CONTROL_TYPE_PRIO_ACCESS: - if (control & IEEE80211_MLC_PRIO_ACCESS_PRES_AP_MLD_MAC_ADDR) - common += ETH_ALEN; + common = ETH_ALEN + 1; break; default: /* we don't know this type */ From patchwork Thu Jan 2 14:20:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miri Korenblit X-Patchwork-Id: 13924503 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 DBFB31B4245 for ; Thu, 2 Jan 2025 14:20:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827640; cv=none; b=MhktVMAqG14owvXQ8wqIc04l0uo5g0yMUSSKEOYMw/pgoy7+D/tskhQAzgSWQRfXDjbmcoT8hjLNXOZaq2xzexZKfR+YT1MwcqNh+HxcgZeZucHBHRBHGYwA1f49A+gdqyy4IAiiE43lbigVTaOFjwvGxS81NFTMAy/Vc4KYk+4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827640; c=relaxed/simple; bh=FdjyHsSsaQOf6iSENrU6HnAqaXiXVLUCn/0aplTnKe8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kHX7lVZdKWm9gHG11zCgD6mc61J4UdSz7ZOvDH677z8yDkByzNhPd9YYAoojREL/l807PwbEcsF6vr42OoLteHhI9/pCyA2p6x88ynacWK7g6cNqr1nm7Bpt12aX0hYtWR8d3Trzb2jzqI4b15PPkHj7QcLzhBWSLLXjaTV+ci0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=VdRGoqLr; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="VdRGoqLr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735827638; x=1767363638; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FdjyHsSsaQOf6iSENrU6HnAqaXiXVLUCn/0aplTnKe8=; b=VdRGoqLrBvVFqZOdsyto7CwuSvhwFlmn4Z4P/d5RUYESPBphSCWnqeza VP8Yb2nqRNcwG3JzdqplCL9BNJ4FSxkNMERZASxPPdy2uAreZriPP60yv aIIHgIZOHIBxzdneg1rwRM1sJe+4Buae2Te18tqt0mH2yBuxP/ft5rpl2 KrjzIm7EJ55ioFAlMdbBa7mtmucgoiUqputy7nOxdsgaat85aKYJVeYye oHvhVqzDB6RM8J6ggKyWsHUxlGbgls06zq8r6hR67FtIOiMrSquD3Ks3a 8JOLcCnKQ6YNLR7nRCWMJD8zyJ6rQiKAIyKzVezdtwllFw3yKv4aF9t1p g==; X-CSE-ConnectionGUID: f5qhTKf3QUGPLZAL60Nebw== X-CSE-MsgGUID: PKXlnU6GQfqHgFxJHiY41w== X-IronPort-AV: E=McAfee;i="6700,10204,11302"; a="46735116" X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="46735116" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:37 -0800 X-CSE-ConnectionGUID: Wq5VaPE/RfWQGRa7+jtcIg== X-CSE-MsgGUID: p/nCaoF4RvCXViBlWadiFg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="132357413" Received: from weis0040.iil.intel.com ([10.12.217.108]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:35 -0800 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Ilan Peer , Johannes Berg Subject: [PATCH 09/17] wifi: mac80211: Support parsing EPCS ML element Date: Thu, 2 Jan 2025 16:20:01 +0200 Message-Id: <20250102161730.5afdf65cff46.I0ffa30b40fbad47bc5b608b5fd46047a8c44e904@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> References: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited From: Ilan Peer Add support for parsing an ML element of type EPCS priority access, which can optionally be included in EHT protected action frames used to configure EPCS. Signed-off-by: Ilan Peer Reviewed-by: Johannes Berg Signed-off-by: Miri Korenblit --- net/mac80211/ieee80211_i.h | 2 ++ net/mac80211/parse.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 64df7d739ebf..5c5a91ead339 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1762,6 +1762,7 @@ struct ieee802_11_elems { const struct ieee80211_eht_operation *eht_operation; const struct ieee80211_multi_link_elem *ml_basic; const struct ieee80211_multi_link_elem *ml_reconf; + const struct ieee80211_multi_link_elem *ml_epcs; const struct ieee80211_bandwidth_indication *bandwidth_indication; const struct ieee80211_ttlm_elem *ttlm[IEEE80211_TTLM_MAX_CNT]; @@ -1792,6 +1793,7 @@ struct ieee802_11_elems { /* mult-link element can be de-fragmented and thus u8 is not sufficient */ size_t ml_basic_len; size_t ml_reconf_len; + size_t ml_epcs_len; u8 ttlm_num; diff --git a/net/mac80211/parse.c b/net/mac80211/parse.c index 279c5143b335..cd318c1c67be 100644 --- a/net/mac80211/parse.c +++ b/net/mac80211/parse.c @@ -44,6 +44,9 @@ struct ieee80211_elems_parse { /* The reconfiguration Multi-Link element in the original elements */ const struct element *ml_reconf_elem; + /* The EPCS Multi-Link element in the original elements */ + const struct element *ml_epcs_elem; + /* * scratch buffer that can be used for various element parsing related * tasks, e.g., element de-fragmentation etc. @@ -159,6 +162,9 @@ ieee80211_parse_extension_element(u32 *crc, case IEEE80211_ML_CONTROL_TYPE_RECONF: elems_parse->ml_reconf_elem = elem; break; + case IEEE80211_ML_CONTROL_TYPE_PRIO_ACCESS: + elems_parse->ml_epcs_elem = elem; + break; default: break; } @@ -943,6 +949,27 @@ ieee80211_mle_defrag_reconf(struct ieee80211_elems_parse *elems_parse) elems_parse->scratch_pos += ml_len; } +static void +ieee80211_mle_defrag_epcs(struct ieee80211_elems_parse *elems_parse) +{ + struct ieee802_11_elems *elems = &elems_parse->elems; + ssize_t ml_len; + + ml_len = cfg80211_defragment_element(elems_parse->ml_epcs_elem, + elems->ie_start, + elems->total_len, + elems_parse->scratch_pos, + elems_parse->scratch + + elems_parse->scratch_len - + elems_parse->scratch_pos, + WLAN_EID_FRAGMENT); + if (ml_len < 0) + return; + elems->ml_epcs = (void *)elems_parse->scratch_pos; + elems->ml_epcs_len = ml_len; + elems_parse->scratch_pos += ml_len; +} + struct ieee802_11_elems * ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params) { @@ -1001,6 +1028,8 @@ ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params) ieee80211_mle_defrag_reconf(elems_parse); + ieee80211_mle_defrag_epcs(elems_parse); + if (elems->tim && !elems->parse_error) { const struct ieee80211_tim_ie *tim_ie = elems->tim; From patchwork Thu Jan 2 14:20:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miri Korenblit X-Patchwork-Id: 13924504 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 505101B3948 for ; Thu, 2 Jan 2025 14:20:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827641; cv=none; b=fDeCPU4likfj3bmjfBq4ffMtIPtmIZydfSurlQEq7JguZlCuFLtx2vsCKBYP6tSUnrYWFd7RHwzuXwNPkr1R0KqG0ZXsjorU63eGh8wFyS4d32C47MytEIcv/nJ533nG4YB2RVZOEzyf6Rmu1ZQP5nzzajNLeX4EwK8Euz5uBm0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827641; c=relaxed/simple; bh=H3iGrCkmStFfjtjiMU1XNNXU/ht//ydnzW3d9b0r79g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IzMkyQYzfChlk9XdU52wu/NjgiPipIrJHEotV+ynJxNLyzPRpz2Bxm8mz14WSnsJu+5GqrhYEQXq+F+7O0/aB9hH9tYI8QKQ+E1YqmkBUhFlpCbVKfT3pv0nPxXaVILWKWM/1p/zKEiQDoIKSe0OUrC2nEVyJ/t8h9ukycvy1gU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=mI8rpLfq; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mI8rpLfq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735827639; x=1767363639; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=H3iGrCkmStFfjtjiMU1XNNXU/ht//ydnzW3d9b0r79g=; b=mI8rpLfqsQIQXcyXOcb9Z7eZqUjX69ilg0LbZVtjKB6APIoOpxhEweYs lTY8U8V5hfuIesDLMY3aZ8Od/+XPEKASL2MRCerg71VI6lTuaRFqj0+Qy YXa5pE/hUwytV1K/n8KJJaWkvf5MV2BaPG93+Ec86HYKXo2D49eRIn7lU zBPOMnNpHnqBoSFiJOEJ+XA8HFEPJeZfqRWRwnMeUQlb5ie4d1BjfUYtQ hN8F68PQUWMsIlKLLOannCwxv18UKaMrTbZwN1DOzhLil+2U37goPYygE sXko3hz+Dj7NvgN1voe3yuyZzwqc8ebKZWSmHg0aBH99LNalBzcxjCXLe w==; X-CSE-ConnectionGUID: kVY+Vt2aTPa3YiVQr/u73A== X-CSE-MsgGUID: HJ/EvlZAQLetolZPvDV7AQ== X-IronPort-AV: E=McAfee;i="6700,10204,11302"; a="46735118" X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="46735118" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:39 -0800 X-CSE-ConnectionGUID: R07FTATqSue0TnbMFdHVKQ== X-CSE-MsgGUID: NXb4l7c/ReaC8GR4c2Z2XA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="132357416" Received: from weis0040.iil.intel.com ([10.12.217.108]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:37 -0800 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Johannes Berg Subject: [PATCH 10/17] wifi: nl80211: simplify nested if checks Date: Thu, 2 Jan 2025 16:20:02 +0200 Message-Id: <20250102161730.c8bf7338aa64.Ie49dcc1ba44b507d91d5a9d8bd538d7ac2e46c54@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> References: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited From: Johannes Berg In the absence of (an) else clause(s), "if (a) if (b)" is equivalent to "if (a && b)", so simplify the code a bit. Signed-off-by: Johannes Berg Signed-off-by: Miri Korenblit --- net/wireless/nl80211.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index d073f14eb6ae..b3b3c30a787e 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -18536,10 +18536,9 @@ void nl80211_send_port_authorized(struct cfg80211_registered_device *rdev, nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, peer_addr)) goto nla_put_failure; - if ((td_bitmap_len > 0) && td_bitmap) - if (nla_put(msg, NL80211_ATTR_TD_BITMAP, - td_bitmap_len, td_bitmap)) - goto nla_put_failure; + if (td_bitmap_len > 0 && td_bitmap && + nla_put(msg, NL80211_ATTR_TD_BITMAP, td_bitmap_len, td_bitmap)) + goto nla_put_failure; genlmsg_end(msg, hdr); From patchwork Thu Jan 2 14:20:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miri Korenblit X-Patchwork-Id: 13924505 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 899E01B4F14 for ; Thu, 2 Jan 2025 14:20:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827642; cv=none; b=m5dkOs1TG9Eh5FdCYWzui8E4aUvsI3TZRRaqLTMO8EjsMPjq8BLyMQOGhASoEVgByuQi8rUZYcUz/Mz6ZagRBn055qzCoLr5jmF8Y1DuSK9j7fMbuIuXyTwuvJwUOe+HYzRyIYYSEmbi8F47hyoexcXQy1jaLPcOz/N0ZPbLQJw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827642; c=relaxed/simple; bh=L12LwHolbApbTKvjzvTuQ/p2qojRdHgGiIioGYvka44=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tiu9UrfwKj6IQKjXg5QUV6HODgLoj1BNwq2iKsBTKOYXqoVWac4XTube7SCGtOdH3XXkfLv1IvhxwG7rkvkEHJqAPuo1YrxJVpa7tvIpsP0MK0R4FbnIhyrSXvFdMHnymJq2lqg1eJTgAmvV4RUwsV+VmNibi6PG09OJYBEAvYA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=gIB90LPz; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gIB90LPz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735827640; x=1767363640; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=L12LwHolbApbTKvjzvTuQ/p2qojRdHgGiIioGYvka44=; b=gIB90LPzwvN5sMeLzTH48zrGcQzlGl42PBkWCBG9fHGfIPVTFPb31ZOJ ImKfQN4tN9Gf7/chBSqY3XIsTboWSR6z801/WW9wpsqms21I74TJHc6BP nr17xVch5RIrhfUYvVFyv+Qh6FsTj7AXqk7kBlqYpqfiAFSvnBJI3fCyc l93PGJczrgRHENVstULASvtYLoqIiMm2mC1kuXlovuxwVWNssLQ9cuHt5 XCSqm4Aqupy4Rn5cERcXbhoWH74C4h520zhrsBvi3aCxaWoyGdB+94+fS j6+Y4w7EjRZlaPbHEmOPnVZqUIawTrTjnujUWjp5fCOno+OO9waZpVEmk A==; X-CSE-ConnectionGUID: JdPapHPlQXCTJ7vPLnrFiw== X-CSE-MsgGUID: n18ixUolSSqYzbgExhfkdQ== X-IronPort-AV: E=McAfee;i="6700,10204,11302"; a="46735121" X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="46735121" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:40 -0800 X-CSE-ConnectionGUID: nMpqs3Q0QYaypSUoxiFmCg== X-CSE-MsgGUID: 1OKhVjlqQpmn9NCUB23YiQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="132357420" Received: from weis0040.iil.intel.com ([10.12.217.108]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:38 -0800 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Johannes Berg Subject: [PATCH 11/17] wifi: iwlwifi: simplify nested if checks Date: Thu, 2 Jan 2025 16:20:03 +0200 Message-Id: <20250102161730.7ddc9cb1ea50.If18bd94706d6c821e34c38a4704bf85dca6207b2@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> References: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited From: Johannes Berg In the absence of (an) else clause(s), "if (a) if (b)" is equivalent to "if (a && b)", so simplify the code a bit. Signed-off-by: Johannes Berg Signed-off-by: Miri Korenblit --- drivers/net/wireless/intel/iwlwifi/mvm/binding.c | 7 +++---- drivers/net/wireless/intel/iwlwifi/mvm/link.c | 5 ++--- drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c | 6 +++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/binding.c b/drivers/net/wireless/intel/iwlwifi/mvm/binding.c index 458b97930059..58e9a940024d 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/binding.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/binding.c @@ -2,7 +2,7 @@ /* * Copyright (C) 2012-2014, 2020 Intel Corporation * Copyright (C) 2016 Intel Deutschland GmbH - * Copyright (C) 2022 Intel Corporation + * Copyright (C) 2022, 2024 Intel Corporation */ #include #include "fw-api.h" @@ -158,9 +158,8 @@ int iwl_mvm_binding_remove_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif) ret = iwl_mvm_binding_update(mvm, vif, mvmvif->deflink.phy_ctxt, false); - if (!ret) - if (iwl_mvm_sf_update(mvm, vif, true)) - IWL_ERR(mvm, "Failed to update SF state\n"); + if (!ret && iwl_mvm_sf_update(mvm, vif, true)) + IWL_ERR(mvm, "Failed to update SF state\n"); return ret; } diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/link.c b/drivers/net/wireless/intel/iwlwifi/mvm/link.c index 272da41567ef..80c175cc9873 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/link.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/link.c @@ -412,9 +412,8 @@ int iwl_mvm_remove_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif, ret = iwl_mvm_link_cmd_send(mvm, &cmd, FW_CTXT_ACTION_REMOVE); - if (!ret) - if (iwl_mvm_sf_update(mvm, vif, true)) - IWL_ERR(mvm, "Failed to update SF state\n"); + if (!ret && iwl_mvm_sf_update(mvm, vif, true)) + IWL_ERR(mvm, "Failed to update SF state\n"); return ret; } diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c index 8903a5692dfb..a822448ad5ea 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c @@ -139,9 +139,9 @@ void _iwl_trans_pcie_gen2_stop_device(struct iwl_trans *trans) if (trans_pcie->is_down) return; - if (trans->state >= IWL_TRANS_FW_STARTED) - if (trans_pcie->fw_reset_handshake) - iwl_trans_pcie_fw_reset_handshake(trans); + if (trans->state >= IWL_TRANS_FW_STARTED && + trans_pcie->fw_reset_handshake) + iwl_trans_pcie_fw_reset_handshake(trans); trans_pcie->is_down = true; From patchwork Thu Jan 2 14:20:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miri Korenblit X-Patchwork-Id: 13924506 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 3EDEF1B4233 for ; Thu, 2 Jan 2025 14:20:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827644; cv=none; b=uFLIZpOS3zJ5PJr98CivAxvuUnp93czLpjiWLHKubX5fXIcOk7UIgsRHCrevfi1HcxPdDJgi5r1wAxmxRkjpgks+G1jmfcAUDSBYT1dex8/kLytVBZzgSc4OR7p/qd/sj+5SfPXzLIhHwj9z9RQv+GWwUDYlM/WOxU1Jut7SFow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827644; c=relaxed/simple; bh=5/hn7fLDrtMrWx2i3IVHthKejSkJRj+Y0RApiVgFl9U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AVZzBsQTQIq6iGJkcrvjsS88YVD9dXUrW8pfv+YU/lBeg0zbpKrkBkcrn6I7XPGTbG0G2C8Tk3OgqUIp+0UdtJgYoDCXhylRjh6WVf0HRIaGLcNwly8Zj9B513d4Mv+YX9crYCXZjW0qb/Y8fUIceYihdZdTLosF9QdNZxHcIkQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=IUC3GOR9; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IUC3GOR9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735827642; x=1767363642; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5/hn7fLDrtMrWx2i3IVHthKejSkJRj+Y0RApiVgFl9U=; b=IUC3GOR9lK0O3fFyMKOSAwUqjN94c10ZXbg91rJFSTtB4AvxDd8hZFN7 8a0biZBaRDb1BaF6/lb1RNb9thhmISTTnw2UNvdi3AbvytMN2zleyl4MC DhPrZG7/fl0Dd2w+owW2/fzd9HaYx338oVTfyTM6pmes3lt0cJiwxPNUR uTdiDxEOHeL/mH8zKbfwG9JZjJQTDEYXfdVautCWlagSV9+49+V7Zf2+k ODXCmVutCqo9J2ns+3nk1B7QVna2cUonAFfg8XPEYNomCaJls0jGDPEzd lo4Dywjm7k24bLzi2/BmTpaWuUgR/TTfbo8xaVe7U48mY9QwNiaDuha5j A==; X-CSE-ConnectionGUID: Cslflm/5QYemB8jgyOXcqw== X-CSE-MsgGUID: Kt9K0ETFT/up5o9eXIyPxw== X-IronPort-AV: E=McAfee;i="6700,10204,11302"; a="46735123" X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="46735123" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:42 -0800 X-CSE-ConnectionGUID: Cgi8vnnPRKGHzZlbuBY53A== X-CSE-MsgGUID: slPXrLWVRry3QinMyGv/uQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="132357424" Received: from weis0040.iil.intel.com ([10.12.217.108]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:40 -0800 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Benjamin Berg , Johannes Berg Subject: [PATCH 12/17] wifi: mac80211: pass correct link ID on assoc Date: Thu, 2 Jan 2025 16:20:04 +0200 Message-Id: <20250102161730.2b06504ecaef.Ifb94e9375b910de6cdd2e5865d8cb3ab9790b314@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> References: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited From: Benjamin Berg The link ID passed to drv_mgd_complete_tx when handling the association response was not set. Signed-off-by: Benjamin Berg Reviewed-by: Johannes Berg Signed-off-by: Miri Korenblit --- net/mac80211/mlme.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index b08b59961bf3..4d9e3e58f3cb 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -6081,6 +6081,8 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, if (!assoc_data) return; + info.link_id = assoc_data->assoc_link_id; + parse_params.mode = assoc_data->link[assoc_data->assoc_link_id].conn.mode; From patchwork Thu Jan 2 14:20:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miri Korenblit X-Patchwork-Id: 13924507 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 6AC2B1799B for ; Thu, 2 Jan 2025 14:20:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827645; cv=none; b=ap6dtPAkDTz0SQfSs4yNXvMh5ELcfeDBWwhrrKtJwKX3QUK+6gChlR7flHnAML4yXnZIuWI5Ib5j/5rgG+Zs21KJIrNKwH4c2vXMIhuMjMApLL/YUKwUTFrqHRPoo3Ij22g72oFKeeAzHuctLImHwiZpJxzlafwD2XpI/NFNJoE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827645; c=relaxed/simple; bh=X3ZuXp0PSMf9YH+GoKHDmAf0KnIU6Zs97ZI3kEoz4kU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fSMGr5KJDj2XBREXFR66u9lMPjKbE9QlglJuF4dxG3EoTpUjgvb0lpYwbjG5koHijXDl/PwFNbWzQm88cZxeNlM/yBdgLciJBWvpurFkcE9W77MB26SxTe0lHKGjbJ3AFkig9SK6O0TgVe4hGXst2Z5LowO2wCOKR5z6d3oLXXc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=kFEDoUa3; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kFEDoUa3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735827643; x=1767363643; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X3ZuXp0PSMf9YH+GoKHDmAf0KnIU6Zs97ZI3kEoz4kU=; b=kFEDoUa39iOm28HGJQYO2ogcrIcJU0yhJqFL3Y3TCoHZQP3Ff4VF2USs jPuCCCxxq0DUIzSNY0YzaVGChTlPvRx6OFgWR/Ok+hYV6vUp3qLUg39AR X74Vl6Nf61lUfBCNzTpZjvLrWOztrORINlj17woVRf5iQNpWZoRAfVpZi xpQYNuh9TaR+0e7yyCk5U8my6AwsBaJVdtlg/coYbxR0Yyq80rlTNfQGw o4ShjOzRryEa1y6Esl2qKiFZHfWBD/6b2xqfEx1Gan8AiLjvrzuL8Biv0 +5nzB2gqvwAyXe2a48YVUVEQ4i7W+bvIC5N/aFdr8duI87aLOq4RBDZoB Q==; X-CSE-ConnectionGUID: 18UYuOPlRZ2eKZ7hf+c87w== X-CSE-MsgGUID: f6SyHmfGRhWQEX8+qFzk3Q== X-IronPort-AV: E=McAfee;i="6700,10204,11302"; a="46735125" X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="46735125" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:43 -0800 X-CSE-ConnectionGUID: Gm/y4wOyRLaLmusEygD1Wg== X-CSE-MsgGUID: E/MFT5OzRa+b2II3UF+Fhg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="132357428" Received: from weis0040.iil.intel.com ([10.12.217.108]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:41 -0800 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Benjamin Berg Subject: [PATCH 13/17] wifi: mac80211: set key link ID to the deflink one Date: Thu, 2 Jan 2025 16:20:05 +0200 Message-Id: <20250102161730.0c066f084677.I4a5c288465e75119edb6a0df90dddf6f30d14a02@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> References: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited From: Benjamin Berg When in non-MLO mode, the key ID was set to -1 even for keys that are not pairwise. Change the link ID to be the link ID of the deflink in this case so that drivers do not need to special cases for this. Signed-off-by: Benjamin Berg Signed-off-by: Miri Korenblit --- include/net/mac80211.h | 2 +- net/mac80211/cfg.c | 11 ++++++++--- net/mac80211/key.c | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 34382d014c8b..92e18419f061 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -2225,7 +2225,7 @@ enum ieee80211_key_flags { * - Temporal Authenticator Rx MIC Key (64 bits) * @icv_len: The ICV length for this key type * @iv_len: The IV length for this key type - * @link_id: the link ID for MLO, or -1 for non-MLO or pairwise keys + * @link_id: the link ID, 0 for non-MLO, or -1 for pairwise keys */ struct ieee80211_key_conf { atomic64_t tx_pn; diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 1a912cb8ae8d..6199b5f6035c 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -503,6 +503,9 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, if (IS_ERR(link)) return PTR_ERR(link); + if (WARN_ON(pairwise && link_id >= 0)) + return -EINVAL; + if (pairwise && params->mode == NL80211_KEY_SET_TX) return ieee80211_set_tx(sdata, mac_addr, key_idx); @@ -525,10 +528,12 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, if (IS_ERR(key)) return PTR_ERR(key); - key->conf.link_id = link_id; - - if (pairwise) + if (pairwise) { key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE; + key->conf.link_id = -1; + } else { + key->conf.link_id = link->link_id; + } if (params->mode == NL80211_KEY_NO_TX) key->conf.flags |= IEEE80211_KEY_FLAG_NO_AUTO_TX; diff --git a/net/mac80211/key.c b/net/mac80211/key.c index 67ecfea22982..dcf8643a0baa 100644 --- a/net/mac80211/key.c +++ b/net/mac80211/key.c @@ -1409,7 +1409,7 @@ ieee80211_gtk_rekey_add(struct ieee80211_vif *vif, if (sdata->u.mgd.mfp != IEEE80211_MFP_DISABLED) key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT; - key->conf.link_id = link_id; + key->conf.link_id = link_data->link_id; err = ieee80211_key_link(key, link_data, NULL); if (err) From patchwork Thu Jan 2 14:20:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miri Korenblit X-Patchwork-Id: 13924508 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 1E3431B3F30 for ; Thu, 2 Jan 2025 14:20:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827646; cv=none; b=rzVEaWd+z4rVXA/B7dTCq0EPOA1zDdo8CWOEkqmjZPkEFUds50LbpSqww+vDHeIWPtQrFTJLohKbLH7GgVx9orMNHbnFp88k8dDADRIoKiEr90jLDhfVx6cbGMLulfUhjwaXsEkMZA614TZ++Bl+l9Ko8E2Uk9u1NEPGRrVYWls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827646; c=relaxed/simple; bh=DETo942FnqZ28bDGgiCZ/+4Dec3hfUumHdGDEXNW3wA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=I2X94dexJphr7ZJriM8IHhGF3UQsUENdyOhar1ijq8nubrIV/7ylBD3owHZKYmwvkrxHjoUyunPbZCHvIrm63FLkDzAI70uP2AW/SLocr/CAkVjL/Gyqcj1sPxgjpuk8c5DWjqFgDU5msHULpNk95p4wrMCf59Yw7ofNXFhuYLc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=dXPCgtim; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dXPCgtim" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735827645; x=1767363645; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DETo942FnqZ28bDGgiCZ/+4Dec3hfUumHdGDEXNW3wA=; b=dXPCgtimv3Be6Zj+KQkpFS94Lr1Rtt33SBtd/Uk514qhPNe1foohEZBl hg/MZe1yXbT39zDI9BdYjMn6ThWd/S+JHkZRSNGLi3x0Ipg5TLeyaUX4H kax2g5NIVU0xKHnLRpls8mjsp1c14J1duSpiR9OVB13/2rmwDJCNi6RIf fKCHG4eVsnw0BDfBvFTgmFILSh4SIqgVg/jXr9QAKcBYm1fLW9OwHyXUI sceAGbmkv5c8Ss5JZEaT+Y7T0kIjd3O1l3A89mPXLP5ZllikTnZpNkgKJ tL8tFM9NUxNsDe7xD09FwoEsch2qs7IH+ER5JKpJ44WQpdMMk3Sg2Kcj0 w==; X-CSE-ConnectionGUID: nfx3mPysSY+SngaJMWSw9A== X-CSE-MsgGUID: oey7TotWSuC8txn47oq7nA== X-IronPort-AV: E=McAfee;i="6700,10204,11302"; a="46735127" X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="46735127" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:44 -0800 X-CSE-ConnectionGUID: YoKWt3vlRf2x1dV7XykFzg== X-CSE-MsgGUID: f15OI0O2Q1+s2wgGUej+VA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="132357431" Received: from weis0040.iil.intel.com ([10.12.217.108]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:43 -0800 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Johannes Berg Subject: [PATCH 14/17] wifi: mac80211: don't flush non-uploaded STAs Date: Thu, 2 Jan 2025 16:20:06 +0200 Message-Id: <20250102161730.e3d10970a7c7.I491bbcccc46f835ade07df0640a75f6ed92f20a3@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> References: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited From: Johannes Berg If STA state is pre-moved to AUTHORIZED (such as in IBSS scenarios) and insertion fails, the station is freed. In this case, the driver never knew about the station, so trying to flush it is unexpected and may crash. Check if the sta was uploaded to the driver before and fix this. Fixes: d00800a289c9 ("wifi: mac80211: add flush_sta method") Signed-off-by: Johannes Berg Signed-off-by: Miri Korenblit --- net/mac80211/driver-ops.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h index c64531e0a60e..5acecc7bd4a9 100644 --- a/net/mac80211/driver-ops.h +++ b/net/mac80211/driver-ops.h @@ -724,6 +724,9 @@ static inline void drv_flush_sta(struct ieee80211_local *local, if (sdata && !check_sdata_in_driver(sdata)) return; + if (!sta->uploaded) + return; + trace_drv_flush_sta(local, sdata, &sta->sta); if (local->ops->flush_sta) local->ops->flush_sta(&local->hw, &sdata->vif, &sta->sta); From patchwork Thu Jan 2 14:20:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miri Korenblit X-Patchwork-Id: 13924509 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 3A4691B652B for ; Thu, 2 Jan 2025 14:20:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827648; cv=none; b=kpHgWNiWxzujHwYxkwmrJStV4GJhIOLoJ7XbpOKStuuoyG+8Sj+Caw4w2qhSkVf2geORLh9lKbcMpzvFH5zKnjzh6PIXzAhoKjOMb9NTUatuKyJ0Y14U1ZNVjSk5RSviR6kSJS+VcUWabm8QA9ilJNsy9o7PEP6324BK3ZoExCQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827648; c=relaxed/simple; bh=QVnAilAum4oju0gWo6DCHWoGlRxLePj+Z1qBiCdIaKM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tPcu05ecbQa1vE00cftbx++1ZRJf4EPsYDF1cUHlbwa/TVAfdvEOVxQGiNLIhXOsWhLCEuDDqLkJjn8KuoJMlsqEedilwNFlE9ud5ZNtglv9bHf8F/eN2Xhq05SKSAQshF3NAIV8icPRNOeTSZ8W0r++QSgdYX5+Mzs3TRCpiPA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=gzcc9uTS; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gzcc9uTS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735827646; x=1767363646; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QVnAilAum4oju0gWo6DCHWoGlRxLePj+Z1qBiCdIaKM=; b=gzcc9uTS+GOy6vk255Fwz+1Il3tsUKgvCZhHhEcqLu4RXRiepaOmrEE/ uvzzQopFpU0xkG0pP2udYXz3vXwZNORWPs0mQfL2uPP6NkB4/uzBKPbPp FCuLb1uT2AM6MJ4wh7GDWurZaQzSAGrSiC3bjYymXKyestotprWK2cE62 YKS0syhSr8j4b09Lw0vWiA2rlm82P5p4B6DT7qS5a0m7oBIlAeSMxWcun /r8kgTjUkreRrCJ3YK0+3wufNzTr9lsyIDjlS7mvoXj0t6YVfd6/5luDs /o+G2SnG9JvyAkuMm2Bv68CELb1p7pAlprfo3x+03sPk/M8RjhZYlyVgc g==; X-CSE-ConnectionGUID: NW8jxKKdQ2+Q5WPedlfq3A== X-CSE-MsgGUID: hfw8gtzpTjylJOqSIzxmHg== X-IronPort-AV: E=McAfee;i="6700,10204,11302"; a="46735129" X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="46735129" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:46 -0800 X-CSE-ConnectionGUID: kmNzlkM4RhSH9Y14h4YFew== X-CSE-MsgGUID: ZyNsiPDOSh+L5ODpmLmMkA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="132357438" Received: from weis0040.iil.intel.com ([10.12.217.108]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:44 -0800 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Johannes Berg Subject: [PATCH 15/17] wifi: mac80211: ibss: stop transmit when merging IBSS Date: Thu, 2 Jan 2025 16:20:07 +0200 Message-Id: <20250102161730.83b58167e80e.I538751fbe1b4302d20f6ed80afb024bca6a2dbf5@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> References: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited From: Johannes Berg We disable the carrier, but that doesn't immediately take effect, and as such a concurrent transmit can go into the driver while drv_leave_ibss() is happening and confuse it. Synchronize to avoid that. Signed-off-by: Johannes Berg Signed-off-by: Miri Korenblit --- net/mac80211/ibss.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index a1b4178deccf..dfa125219e47 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c @@ -245,6 +245,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, sdata->vif.cfg.ibss_creator = false; sdata->vif.bss_conf.enable_beacon = false; netif_carrier_off(sdata->dev); + synchronize_net(); ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_IBSS | BSS_CHANGED_BEACON_ENABLED); From patchwork Thu Jan 2 14:20:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miri Korenblit X-Patchwork-Id: 13924510 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 9BFC01B6CE9 for ; Thu, 2 Jan 2025 14:20:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827650; cv=none; b=bDvaD+3htVgfj+CSInY3OsdSOEfkEfFynYNLB6U7QoAmpHe2Uw44ciqyo8+/A+b9W7hQ8FVKBEI2LzC0r61AWTt5NjkxdVtZPpvZ096rpvwZXbN4LilHmsPjrrvYhIPbL0tLY/YW2XpJfJhRYshDlZMztRRuOCVVxye4dPY+Kes= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827650; c=relaxed/simple; bh=0WeLh/vPG0isVr1D5FJ+l93dwI/8iSWUSs+KXT6PlOw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cmTsFQEIhJmSVLJNX5oBZJ85wKdoiy+5d09QOraf7btSQy2UkB7sE94i+gDtPx1LI0/HdDdPvH4LI+GNh/InBtsz9/tuH1i1TB51kIf7vknJjRfF8A6tdi4nOCXSwjlaYFKxY6lUmseM/KCVZJd/3nNNTp5jnGVKcOY+FXNkksY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=TDP0gWeo; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TDP0gWeo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735827648; x=1767363648; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0WeLh/vPG0isVr1D5FJ+l93dwI/8iSWUSs+KXT6PlOw=; b=TDP0gWeo+9gP6ZL4geUW4ofFqXJ3/y/TwNcyupzd5REosgQjUR+J/2pQ JAkYrE6SjQ+s+6AwFt56fmX/QgPj73ZBc6gJ0yBGW28lG2JtTOwjJAwMl f58WnM1cLryMQrbNDz9PjFqf56yodKVSHBFvIFEup9mApCJPIS8+NgaY/ Unbjahv5ZEOPUWmFZyLJqwfonoBsWhwVTxf+A2REcBdTMZhwU2alemBp4 LWMZ2BclmD9SIKbsEOm0OKhPuJ4DMyDwSfkJsTnP11w0aMBnAansgVOiR o6y1M3vVij9GQ1415kblgyGQo44gmhtLY5qeEeJeegtilaFiI7ttz35dV g==; X-CSE-ConnectionGUID: MhnPB8T+REeImVWoBPHEsw== X-CSE-MsgGUID: /z4Fdgb3Q9CyDwMXLQ2Cvw== X-IronPort-AV: E=McAfee;i="6700,10204,11302"; a="46735131" X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="46735131" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:47 -0800 X-CSE-ConnectionGUID: HwX1tt1PSeeoZBUcILrLSA== X-CSE-MsgGUID: 9N4+YrLkT3uv+xfMqow52Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="132357448" Received: from weis0040.iil.intel.com ([10.12.217.108]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:46 -0800 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Johannes Berg Subject: [PATCH 16/17] wifi: mac80211: ibss: mark IBSS left before leaving Date: Thu, 2 Jan 2025 16:20:08 +0200 Message-Id: <20250102161730.81a6c12b304c.I8484f768371e128152a84aa164854cca9ec1066b@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> References: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited From: Johannes Berg Mark that we left the IBSS before actually leaving (which requires calling the driver). Otherwise, it's possible to have the driver do some work flushing etc. while leaving, and then get into the work trying to join again while all data is being destroyed. Signed-off-by: Johannes Berg Signed-off-by: Miri Korenblit --- net/mac80211/ibss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index dfa125219e47..05a945df3259 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c @@ -1827,8 +1827,8 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata) { struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; - ieee80211_ibss_disconnect(sdata); ifibss->ssid_len = 0; + ieee80211_ibss_disconnect(sdata); eth_zero_addr(ifibss->bssid); /* remove beacon */ From patchwork Thu Jan 2 14:20:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miri Korenblit X-Patchwork-Id: 13924511 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 0A7221B6CF6 for ; Thu, 2 Jan 2025 14:20:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827651; cv=none; b=DKMny5B5M6usu8oQmEnFKafcYxtEG6KrfHiGaMgI9a5n5Jfbd6VX7GBvHzaLUjIxsjNB8totAunJ26l/U4YidSRQZAH+R2a88Nj6TaMOUiEC5098R4q7mfgV0ETljY2CvNzFin5RRIKApqVAN9nvZbM8slAljvBg9DGnOrpkfX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735827651; c=relaxed/simple; bh=JJPQVWKH+mTq6R4jQgUyomNEBmTpbjK8ktVAeXAAQZE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O6aE9ecvi54Hx+JvHcBAYtIb9GcpAxpqSGjtRyWzIU1SzW/QEmbAfRuB/aELk+e6JWXOHK8Lr0dlo/GX5Ov0kEgeNSK/T3nJ2R+bvSZ3oy9r6SsuSVSP0RigOHVQePqqe3nTnh6gBnKhWJHoG8KcYptMf61USVhCPtzfeOksPK4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=CcSHXums; arc=none smtp.client-ip=192.198.163.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CcSHXums" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735827649; x=1767363649; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JJPQVWKH+mTq6R4jQgUyomNEBmTpbjK8ktVAeXAAQZE=; b=CcSHXumsPUuh5zhbxMme1g2eW6s16afjL7DwmehGFHERfUITcx+V7IXr m8mPCnxfHjFBzvKbzxmyfMjdMDEFdFP7bTZ9O5pg9LPTaCIDVqxRma2ol 9iVrzQqFYnfuuYrMc4HFLA/21Tt8YulLKGFzoKPjQTTDQsQ/W3bwxTafR o+yGDtduZ/qc1Nw0wXTcG1u4fVpT5Ldz/PSgDRVG8K1zvVDypccsE3Fdi YQSxlZsSwTsEqHys2nwiuFt5aAzJ4iqJwxWqTH7VXqsItEMvq2esSMGOD lOYuMXZi68FAypytzDnXEkxEYh25o7zjyoIZk4dk12j2jaUQBZ/3PNDKW g==; X-CSE-ConnectionGUID: tmMVlW0uTOGrcgWhhKm9Vg== X-CSE-MsgGUID: wyNNQi2wQUalROcPcQEIFg== X-IronPort-AV: E=McAfee;i="6700,10204,11302"; a="46735133" X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="46735133" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:49 -0800 X-CSE-ConnectionGUID: e1Ji5hDAQvCDB1t4cdHL8g== X-CSE-MsgGUID: L9Zm+WKvQL+o/6P816zNmw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,285,1728975600"; d="scan'208";a="132357455" Received: from weis0040.iil.intel.com ([10.12.217.108]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jan 2025 06:20:47 -0800 From: Miri Korenblit To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Johannes Berg Subject: [PATCH 17/17] wifi: mac80211: avoid double free in auth/assoc timeout Date: Thu, 2 Jan 2025 16:20:09 +0200 Message-Id: <20250102161730.0c3f7f781096.I2b458fb53291b06717077a815755288a81274756@changeid> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> References: <20250102142009.3057049-1-miriam.rachel.korenblit@intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Israel (74) Limited In case of authentication/association timeout (as detected in ieee80211_iface_work->ieee80211_sta_work), ieee80211_destroy_auth_data is called. At the beginning of it, the pointer to ifmgd::auth_data memory is copied to a local variable. If iface_work is queued again during the execution of the current one, and then the driver is flushing the wiphy_works (for its needs), ieee80211_destroy_auth_data will run again and free auth_data. Then when the execution of the original worker continues, the previously copied pointer will be freed, causing a kernel bug: kernel BUG at mm/slub.c:553! (double free) Same for association timeout (just with ieee80211_destroy_assoc_data and ifmgd::assoc_data) Fix this by NULLifying auth/assoc data right after we copied the pointer to it. That way, even in the scenario above, the code will not handle the same timeout twice. Signed-off-by: Miri Korenblit Reviewed-by: Johannes Berg --- net/mac80211/mlme.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 4d9e3e58f3cb..3ef5f82a9b87 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -4507,6 +4507,8 @@ static void ieee80211_destroy_auth_data(struct ieee80211_sub_if_data *sdata, lockdep_assert_wiphy(sdata->local->hw.wiphy); + sdata->u.mgd.auth_data = NULL; + if (!assoc) { /* * we are not authenticated yet, the only timer that could be @@ -4528,7 +4530,6 @@ static void ieee80211_destroy_auth_data(struct ieee80211_sub_if_data *sdata, cfg80211_put_bss(sdata->local->hw.wiphy, auth_data->bss); kfree(auth_data); - sdata->u.mgd.auth_data = NULL; } enum assoc_status { @@ -4545,6 +4546,8 @@ static void ieee80211_destroy_assoc_data(struct ieee80211_sub_if_data *sdata, lockdep_assert_wiphy(sdata->local->hw.wiphy); + sdata->u.mgd.assoc_data = NULL; + if (status != ASSOC_SUCCESS) { /* * we are not associated yet, the only timer that could be @@ -4583,7 +4586,6 @@ static void ieee80211_destroy_assoc_data(struct ieee80211_sub_if_data *sdata, } kfree(assoc_data); - sdata->u.mgd.assoc_data = NULL; } static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata,