Skip to contentSkip to conversation

cfg80211/mac80211 patches from our internal tree 2023-09-28

PATCH In review [email protected] 4 participants 24 messages Sep 28, 2023 – Sep 29, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover cfg80211/mac80211 patches from our internal tree 2023-09-28

From: Gregory Greenman <[email protected]>

Hi,

A bunch of patches from our internal tree with mac80211 and cfg80211 changes. It's the usual developement, cleanups and bugfixes.

Thanks,
Gregory

Benjamin Berg (2):
wifi: mac80211: cleanup auth_data only if association continues
wifi: mac80211: mesh: fix some kdoc warnings

Emmanuel Grumbach (1):
wifi: mac80211: fix a expired vs. cancel race in roc

Ilan Peer (5):
wifi: mac80211: Rename and update IEEE80211_VIF_DISABLE_SMPS_OVERRIDE
wifi: cfg80211: Include operating class 137 in 6GHz band
wifi: cfg80211: Handle specific BSSID in 6GHz scanning
wifi: mac80211: Fix setting vif links
wifi: cfg80211: Fix typo in documentation

Johannes Berg (4):
wifi: mac80211: drop robust action frames before assoc
wifi: mac80211: don't recreate driver link debugfs in reconfig
wifi: cfg80211: wext: convert return value to kernel-doc
wifi: mac80211: flush STA queues on unauthorization

Miri Korenblit (6):
wifi: mac80211: add a driver callback to add vif debugfs
wifi: mac80211: handle debugfs when switching to/from MLO
wifi: mac80211: Check if we had first beacon with relevant links
wifi: mac80211: add link id to mgd_prepare_tx()
wifi: mac80211: make mgd_protect_tdls_discover MLO-aware
wifi: mac80211: purge TX queues in flush_queues flow

 .../wireless/intel/iwlwifi/mvm/mld-mac80211.c |  6 +-
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h  |  3 +-
 drivers/net/wireless/intel/iwlwifi/mvm/tdls.c |  5 +-
 include/net/cfg80211.h                        |  2 +-
 include/net/mac80211.h                        | 18 ++++--
 net/mac80211/cfg.c                            |  6 ++
 net/mac80211/debugfs_netdev.c                 | 28 +++++++--
 net/mac80211/debugfs_netdev.h                 | 15 ++++-
 net/mac80211/driver-ops.c                     | 23 +++++--
 net/mac80211/driver-ops.h                     | 32 +++++++++-
 net/mac80211/ieee80211_i.h                    |  1 +
 net/mac80211/iface.c                          |  2 +-
 net/mac80211/link.c                           |  7 ++-
 net/mac80211/mesh.c                           |  8 ++-
 net/mac80211/mesh_hwmp.c                      |  2 +
 net/mac80211/mesh_pathtbl.c                   | 20 ++++---
 net/mac80211/mesh_plink.c                     |  6 +-
 net/mac80211/mesh_ps.c                        |  6 +-
 net/mac80211/mesh_sync.c                      |  4 +-
 net/mac80211/mlme.c                           | 41 ++++++++++---
 net/mac80211/offchannel.c                     | 17 ++++++
 net/mac80211/rx.c                             |  9 +++
 net/mac80211/sta_info.c                       | 60 ++++++++++++-------
 net/mac80211/tdls.c                           |  2 +-
 net/mac80211/util.c                           | 13 ++++
 net/wireless/scan.c                           | 37 ++++++++++++
 net/wireless/util.c                           |  1 +
 net/wireless/wext-compat.c                    |  4 +-
 28 files changed, 304 insertions(+), 74 deletions(-)
Signature · 1 line
2.38.1
#1 lore raw

PATCH 1/18 wifi: mac80211: cleanup auth_data only if association continues

From: Benjamin Berg <[email protected]>

If the association command fails then the authentication is still valid and it makes sense to keep it alive. Otherwise, we would currently get into an inconsistent state because mac80211 on the one hand is disconnected but on the other hand the state is not entirely cleared and a new authentication could not continue.

---
 net/mac80211/mlme.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
net/mac80211/mlme.c +13 -4
index dc9a94bd3b11..e92598dcf3ed 100644
@@ -7715,7 +7715,10 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
 		match = ether_addr_equal(ifmgd->auth_data->ap_addr,
 					 assoc_data->ap_addr) &&
 			ifmgd->auth_data->link_id == req->link_id;
-		ieee80211_destroy_auth_data(sdata, match);
+
+		/* Cleanup is delayed if auth_data matches */
+		if (!match)
+			ieee80211_destroy_auth_data(sdata, false);
 	}
 
 	/* prepare assoc data */
@@ -7938,11 +7941,17 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
 
 	run_again(sdata, assoc_data->timeout);
 
+	/* We are associating, clean up auth_data */
+	if (ifmgd->auth_data)
+		ieee80211_destroy_auth_data(sdata, true);
+
 	return 0;
  err_clear:
-	eth_zero_addr(sdata->deflink.u.mgd.bssid);
-	ieee80211_link_info_change_notify(sdata, &sdata->deflink,
-					  BSS_CHANGED_BSSID);
+	if (!ifmgd->auth_data) {
+		eth_zero_addr(sdata->deflink.u.mgd.bssid);
+		ieee80211_link_info_change_notify(sdata, &sdata->deflink,
+						  BSS_CHANGED_BSSID);
+	}
 	ifmgd->assoc_data = NULL;
  err_free:
 	kfree(assoc_data);
Signature · 1 line
2.38.1
#2 lore raw

PATCH 2/18 wifi: mac80211: drop robust action frames before assoc

In reply to [email protected]

From: Johannes Berg <[email protected]>

To be able to more easily understand the code, drop robust action frames before being associated, even if there's no MFP in the end, as they are Class 3 Frames and shouldn't be transmitted in the first place.

---
 net/mac80211/rx.c | 9 +++++++++
 1 file changed, 9 insertions(+)
net/mac80211/rx.c +9 -0
index fb2d4a7436be..aec851c722f1 100644
@@ -2473,6 +2473,15 @@ static int ieee80211_drop_unencrypted_mgmt(struct ieee80211_rx_data *rx)
 			return RX_DROP_U_UNPROT_UNICAST_PUB_ACTION;
 	}
 
+	/*
+	 * Drop robust action frames before assoc regardless of MFP state,
+	 * after assoc we also have decided on MFP or not.
+	 */
+	if (ieee80211_is_action(fc) &&
+	    ieee80211_is_robust_mgmt_frame(rx->skb) &&
+	    (!rx->sta || !test_sta_flag(rx->sta, WLAN_STA_ASSOC)))
+		return -EACCES;
+
 	return 0;
 }
 
Signature · 1 line
2.38.1
#3 lore raw

PATCH 3/18 wifi: mac80211: don't recreate driver link debugfs in reconfig

In reply to [email protected]

From: Johannes Berg <[email protected]>

We can delete any that we want to remove, but we can't recreate the links as they already exist.

Fixes 170cd6a66d9a ("wifi: mac80211: add netdev per-link debugfs data and driver hook")
---
 net/mac80211/driver-ops.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
net/mac80211/driver-ops.c +6 -3
index 169dbbca54b6..9112715a749a 100644
@@ -526,10 +526,13 @@ int drv_change_vif_links(struct ieee80211_local *local,
 	if (ret)
 		return ret;
 
-	for_each_set_bit(link_id, &links_to_add, IEEE80211_MLD_MAX_NUM_LINKS) {
-		link = rcu_access_pointer(sdata->link[link_id]);
+	if (!local->in_reconfig) {
+		for_each_set_bit(link_id, &links_to_add,
+				 IEEE80211_MLD_MAX_NUM_LINKS) {
+			link = rcu_access_pointer(sdata->link[link_id]);
 
-		ieee80211_link_debugfs_drv_add(link);
+			ieee80211_link_debugfs_drv_add(link);
+		}
 	}
 
 	return 0;
Signature · 1 line
2.38.1
#4 lore raw

PATCH 4/18 wifi: mac80211: add a driver callback to add vif debugfs

In reply to [email protected]

From: Miri Korenblit <[email protected]>

Add a callback which the driver can use to add the vif debugfs. We used to have this back until commit d260ff12e776 ("mac80211:
remove vif debugfs driver callbacks") where we thought that it will be easier to just add them during interface add/remove.

However, now with multi-link, we want to have proper debugfs for drivers for multi-link where some files might be in the netdev for non-MLO connections, and in the links for MLO ones, so we need to do some reconstruction when switching the mode.

Moving to this new call enables that and MLO drivers will have to use it for proper debugfs operation.

---
 include/net/mac80211.h    |  6 ++++++
 net/mac80211/driver-ops.c | 11 ++++++++---
 net/mac80211/driver-ops.h | 23 +++++++++++++++++++++++
 3 files changed, 37 insertions(+), 3 deletions(-)
include/net/mac80211.h +6 -0
index 72375eceb786..a9b73e357462 100644
@@ -3869,6 +3869,10 @@ struct ieee80211_prep_tx_info {
  *	the station. See @sta_pre_rcu_remove if needed.
  *	This callback can sleep.
  *
+ * @vif_add_debugfs: Drivers can use this callback to add a debugfs vif
+ *	directory with its files. This callback should be within a
+ *	CONFIG_MAC80211_DEBUGFS conditional. This callback can sleep.
+ *
  * @link_add_debugfs: Drivers can use this callback to add debugfs files
  *	when a link is added to a mac80211 vif. This callback should be within
  *	a CONFIG_MAC80211_DEBUGFS conditional. This callback can sleep.
@@ -4368,6 +4372,8 @@ struct ieee80211_ops {
 	int (*sta_remove)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 			  struct ieee80211_sta *sta);
 #ifdef CONFIG_MAC80211_DEBUGFS
+	void (*vif_add_debugfs)(struct ieee80211_hw *hw,
+				struct ieee80211_vif *vif);
 	void (*link_add_debugfs)(struct ieee80211_hw *hw,
 				 struct ieee80211_vif *vif,
 				 struct ieee80211_bss_conf *link_conf,
net/mac80211/driver-ops.c +8 -3
index 9112715a749a..08861ec61be9 100644
@@ -72,10 +72,15 @@ int drv_add_interface(struct ieee80211_local *local,
 	ret = local->ops->add_interface(&local->hw, &sdata->vif);
 	trace_drv_return_int(local, ret);
 
-	if (ret == 0)
-		sdata->flags |= IEEE80211_SDATA_IN_DRIVER;
+	if (ret)
+		return ret;
 
-	return ret;
+	sdata->flags |= IEEE80211_SDATA_IN_DRIVER;
+
+	if (!local->in_reconfig)
+		drv_vif_add_debugfs(local, sdata);
+
+	return 0;
 }
 
 int drv_change_interface(struct ieee80211_local *local,
net/mac80211/driver-ops.h +23 -0
index 77048b9065e6..e07e65da15ee 100644
@@ -489,6 +489,23 @@ static inline void drv_sta_remove(struct ieee80211_local *local,
 }
 
 #ifdef CONFIG_MAC80211_DEBUGFS
+static inline void drv_vif_add_debugfs(struct ieee80211_local *local,
+				       struct ieee80211_sub_if_data *sdata)
+{
+	might_sleep();
+
+	if (sdata->vif.type == NL80211_IFTYPE_MONITOR ||
+	    WARN_ON(!sdata->vif.debugfs_dir))
+		return;
+
+	sdata = get_bss_sdata(sdata);
+	if (!check_sdata_in_driver(sdata))
+		return;
+
+	if (local->ops->vif_add_debugfs)
+		local->ops->vif_add_debugfs(&local->hw, &sdata->vif);
+}
+
 static inline void drv_link_add_debugfs(struct ieee80211_local *local,
 					struct ieee80211_sub_if_data *sdata,
 					struct ieee80211_bss_conf *link_conf,
@@ -539,6 +556,12 @@ static inline void drv_link_sta_add_debugfs(struct ieee80211_local *local,
 		local->ops->link_sta_add_debugfs(&local->hw, &sdata->vif,
 						 link_sta, dir);
 }
+#else
+static inline void drv_vif_add_debugfs(struct ieee80211_local *local,
+				       struct ieee80211_sub_if_data *sdata)
+{
+	might_sleep();
+}
 #endif
 
 static inline void drv_sta_pre_rcu_remove(struct ieee80211_local *local,
Signature · 1 line
2.38.1
#5 lore raw

PATCH 5/18 wifi: mac80211: handle debugfs when switching to/from MLO

In reply to [email protected]

From: Miri Korenblit <[email protected]>

In MLO, we have a per-link debugfs directory which contains the per-link files. In case of non-MLO we would like to put the per-link files in the netdev directory to keep it how it was before MLO.

- Upon interface creation the netdev will be created with the per-link files in it.
- Upon switching to MLO: delete the entire netdev directory and then recreate it without the per-link files. Then the per-link directories with the per-link files in it will be created in ieee80211_link_init()
- Upon switching to non-MLO: delete the entire netdev directory (including the per-link directories) and recreate it with the per-link files in it.

Note that this also aligns to always call the vif link debugfs method for the deflink as promised in the documentation, which wasn't done before.

---
 net/mac80211/debugfs_netdev.c | 23 ++++++++++++++++++-----
 net/mac80211/debugfs_netdev.h | 15 ++++++++++++---
 net/mac80211/driver-ops.c     |  5 ++++-
 net/mac80211/iface.c          |  2 +-
 net/mac80211/link.c           |  5 +++++
 5 files changed, 40 insertions(+), 10 deletions(-)
net/mac80211/debugfs_netdev.c +18 -5
index 14a40348959a..b383dad18841 100644
@@ -934,18 +934,20 @@ static void add_link_files(struct ieee80211_link_data *link,
 	}
 }
 
-void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata)
+void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata,
+				  bool mld_vif)
 {
 	char buf[10+IFNAMSIZ];
 
 	sprintf(buf, "netdev:%s", sdata->name);
 	sdata->vif.debugfs_dir = debugfs_create_dir(buf,
 		sdata->local->hw.wiphy->debugfsdir);
+	/* deflink also has this */
+	sdata->deflink.debugfs_dir = sdata->vif.debugfs_dir;
 	sdata->debugfs.subdir_stations = debugfs_create_dir("stations",
 							sdata->vif.debugfs_dir);
 	add_files(sdata);
-
-	if (!(sdata->local->hw.wiphy->flags & WIPHY_FLAG_SUPPORTS_MLO))
+	if (!mld_vif)
 		add_link_files(&sdata->deflink, sdata->vif.debugfs_dir);
 }
 
@@ -973,11 +975,21 @@ void ieee80211_debugfs_rename_netdev(struct ieee80211_sub_if_data *sdata)
 	debugfs_rename(dir->d_parent, dir, dir->d_parent, buf);
 }
 
+void ieee80211_debugfs_recreate_netdev(struct ieee80211_sub_if_data *sdata,
+				       bool mld_vif)
+{
+	ieee80211_debugfs_remove_netdev(sdata);
+	ieee80211_debugfs_add_netdev(sdata, mld_vif);
+	drv_vif_add_debugfs(sdata->local, sdata);
+	if (!mld_vif)
+		ieee80211_link_debugfs_drv_add(&sdata->deflink);
+}
+
 void ieee80211_link_debugfs_add(struct ieee80211_link_data *link)
 {
 	char link_dir_name[10];
 
-	if (WARN_ON(!link->sdata->vif.debugfs_dir))
+	if (WARN_ON(!link->sdata->vif.debugfs_dir || link->debugfs_dir))
 		return;
 
 	/* For now, this should not be called for non-MLO capable drivers */
@@ -1014,7 +1026,8 @@ void ieee80211_link_debugfs_remove(struct ieee80211_link_data *link)
 
 void ieee80211_link_debugfs_drv_add(struct ieee80211_link_data *link)
 {
-	if (WARN_ON(!link->debugfs_dir))
+	if (link->sdata->vif.type == NL80211_IFTYPE_MONITOR ||
+	    WARN_ON(!link->debugfs_dir))
 		return;
 
 	drv_link_add_debugfs(link->sdata->local, link->sdata,
net/mac80211/debugfs_netdev.h +12 -3
index 99e688dcabd6..b226b1aae88a 100644
@@ -1,4 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Portions:
+ * Copyright (C) 2023 Intel Corporation
+ */
 /* routines exported for debugfs handling */
 
 #ifndef __IEEE80211_DEBUGFS_NETDEV_H
@@ -7,9 +11,12 @@
 #include "ieee80211_i.h"
 
 #ifdef CONFIG_MAC80211_DEBUGFS
-void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata);
+void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata,
+				  bool mld_vif);
 void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata);
 void ieee80211_debugfs_rename_netdev(struct ieee80211_sub_if_data *sdata);
+void ieee80211_debugfs_recreate_netdev(struct ieee80211_sub_if_data *sdata,
+				       bool mld_vif);
 
 void ieee80211_link_debugfs_add(struct ieee80211_link_data *link);
 void ieee80211_link_debugfs_remove(struct ieee80211_link_data *link);
@@ -18,7 +25,7 @@ void ieee80211_link_debugfs_drv_add(struct ieee80211_link_data *link);
 void ieee80211_link_debugfs_drv_remove(struct ieee80211_link_data *link);
 #else
 static inline void ieee80211_debugfs_add_netdev(
-	struct ieee80211_sub_if_data *sdata)
+	struct ieee80211_sub_if_data *sdata, bool mld_vif)
 {}
 static inline void ieee80211_debugfs_remove_netdev(
 	struct ieee80211_sub_if_data *sdata)
@@ -26,7 +33,9 @@ static inline void ieee80211_debugfs_remove_netdev(
 static inline void ieee80211_debugfs_rename_netdev(
 	struct ieee80211_sub_if_data *sdata)
 {}
-
+static inline void ieee80211_debugfs_recreate_netdev(
+	struct ieee80211_sub_if_data *sdata, bool mld_vif)
+{}
 static inline void ieee80211_link_debugfs_add(struct ieee80211_link_data *link)
 {}
 static inline void ieee80211_link_debugfs_remove(struct ieee80211_link_data *link)
net/mac80211/driver-ops.c +4 -1
index 08861ec61be9..7938ec87ef25 100644
@@ -77,8 +77,11 @@ int drv_add_interface(struct ieee80211_local *local,
 
 	sdata->flags |= IEEE80211_SDATA_IN_DRIVER;
 
-	if (!local->in_reconfig)
+	if (!local->in_reconfig) {
 		drv_vif_add_debugfs(local, sdata);
+		/* initially vif is not MLD */
+		ieee80211_link_debugfs_drv_add(&sdata->deflink);
+	}
 
 	return 0;
 }
net/mac80211/iface.c +1 -1
index 510f8aead4f9..124cc53f6b34 100644
@@ -1775,7 +1775,7 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
 	/* need to do this after the switch so vif.type is correct */
 	ieee80211_link_setup(&sdata->deflink);
 
-	ieee80211_debugfs_add_netdev(sdata);
+	ieee80211_debugfs_add_netdev(sdata, false);
 }
 
 static int ieee80211_runtime_change_iftype(struct ieee80211_sub_if_data *sdata,
net/mac80211/link.c +5 -0
index 2a78374f6f04..76c61a132569 100644
@@ -235,6 +235,9 @@ static int ieee80211_vif_update_links(struct ieee80211_sub_if_data *sdata,
 		RCU_INIT_POINTER(sdata->vif.link_conf[link_id], NULL);
 	}
 
+	if (!old_links)
+		ieee80211_debugfs_recreate_netdev(sdata, true);
+
 	/* link them into data structures */
 	for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS) {
 		WARN_ON(!use_deflink &&
@@ -261,6 +264,8 @@ static int ieee80211_vif_update_links(struct ieee80211_sub_if_data *sdata,
 					   old_links & old_active,
 					   new_links & sdata->vif.active_links,
 					   old);
+		if (!new_links)
+			ieee80211_debugfs_recreate_netdev(sdata, false);
 	}
 
 	if (ret) {
Signature · 1 line
2.38.1
#6 lore raw

PATCH 6/18 wifi: mac80211: Rename and update IEEE80211_VIF_DISABLE_SMPS_OVERRIDE

In reply to [email protected]

From: Ilan Peer <[email protected]>

EMLSR operation and SMPS operation cannot coexist. Thus, when EMLSR is enabled, all SMPS signaling towards the AP should be stopped (it is expected that the AP will consider SMPS to be off).

Rename IEEE80211_VIF_DISABLE_SMPS_OVERRIDE to IEEE80211_VIF_EML_ACTIVE and use the flag as an indication from the driver that EMLSR is enabled. When EMLSR is enabled SMPS flows towards the AP MLD should be stopped.

---
 drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c | 6 +++---
 include/net/mac80211.h                                | 6 +++---
 net/mac80211/cfg.c                                    | 6 ++++++
 net/mac80211/debugfs_netdev.c                         | 5 ++++-
 4 files changed, 16 insertions(+), 7 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c +3 -3
index 5449deb3c2d6..726a3276f715 100644
@@ -240,8 +240,8 @@ static int iwl_mvm_esr_mode_active(struct iwl_mvm *mvm,
 
 	mvmvif->esr_active = true;
 
-	/* Disable SMPS overrideing by user */
-	vif->driver_flags |= IEEE80211_VIF_DISABLE_SMPS_OVERRIDE;
+	/* Indicate to mac80211 that EML is enabled */
+	vif->driver_flags |= IEEE80211_VIF_EML_ACTIVE;
 
 	iwl_mvm_update_smps_on_active_links(mvm, vif, IWL_MVM_SMPS_REQ_FW,
 					    IEEE80211_SMPS_OFF);
@@ -399,7 +399,7 @@ static int iwl_mvm_esr_mode_inactive(struct iwl_mvm *mvm,
 
 	mvmvif->esr_active = false;
 
-	vif->driver_flags &= ~IEEE80211_VIF_DISABLE_SMPS_OVERRIDE;
+	vif->driver_flags &= ~IEEE80211_VIF_EML_ACTIVE;
 
 	iwl_mvm_update_smps_on_active_links(mvm, vif, IWL_MVM_SMPS_REQ_FW,
 					    IEEE80211_SMPS_AUTOMATIC);
include/net/mac80211.h +3 -3
index a9b73e357462..7dae9aac089c 100644
@@ -1767,15 +1767,15 @@ struct ieee80211_channel_switch {
  * @IEEE80211_VIF_GET_NOA_UPDATE: request to handle NOA attributes
  *	and send P2P_PS notification to the driver if NOA changed, even
  *	this is not pure P2P vif.
- * @IEEE80211_VIF_DISABLE_SMPS_OVERRIDE: disable user configuration of
- *	SMPS mode via debugfs.
+ * @IEEE80211_VIF_EML_ACTIVE: The driver indicates that EML operation is
+ *      enabled for the interface.
  */
 enum ieee80211_vif_flags {
 	IEEE80211_VIF_BEACON_FILTER		= BIT(0),
 	IEEE80211_VIF_SUPPORTS_CQM_RSSI		= BIT(1),
 	IEEE80211_VIF_SUPPORTS_UAPSD		= BIT(2),
 	IEEE80211_VIF_GET_NOA_UPDATE		= BIT(3),
-	IEEE80211_VIF_DISABLE_SMPS_OVERRIDE	= BIT(4),
+	IEEE80211_VIF_EML_ACTIVE	        = BIT(4),
 };
 
 
net/mac80211/cfg.c +6 -0
index 8f1d128b5eeb..3c167db6ce4e 100644
@@ -3152,6 +3152,12 @@ int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,
 	old_req = link->u.mgd.req_smps;
 	link->u.mgd.req_smps = smps_mode;
 
+	/* The driver indicated that EML is enabled for the interface, which
+	 * implies that SMPS flows towards the AP should be stopped.
+	 */
+	if (sdata->vif.driver_flags & IEEE80211_VIF_EML_ACTIVE)
+		return 0;
+
 	if (old_req == smps_mode &&
 	    smps_mode != IEEE80211_SMPS_AUTOMATIC)
 		return 0;
net/mac80211/debugfs_netdev.c +4 -1
index b383dad18841..ec91e131b29e 100644
@@ -323,7 +323,10 @@ static int ieee80211_set_smps(struct ieee80211_link_data *link,
 	struct ieee80211_sub_if_data *sdata = link->sdata;
 	struct ieee80211_local *local = sdata->local;
 
-	if (sdata->vif.driver_flags & IEEE80211_VIF_DISABLE_SMPS_OVERRIDE)
+	/* The driver indicated that EML is enabled for the interface, thus do
+	 * not allow to override the SMPS state.
+	 */
+	if (sdata->vif.driver_flags & IEEE80211_VIF_EML_ACTIVE)
 		return -EOPNOTSUPP;
 
 	if (!(local->hw.wiphy->features & NL80211_FEATURE_STATIC_SMPS) &&
Signature · 1 line
2.38.1
#7 lore raw

PATCH 7/18 wifi: cfg80211: Include operating class 137 in 6GHz band

In reply to [email protected]

From: Ilan Peer <[email protected]>

Draft P802.11be_D3.1 added operating class to describe 320 MHz operation in the 6GHz band. Include this new operating class in ieee80211_operating_class_to_band().

---
 net/wireless/util.c | 1 +
 1 file changed, 1 insertion(+)
net/wireless/util.c +1 -0
index 213c9405e645..0893b7f57832 100644
@@ -1999,6 +1999,7 @@ bool ieee80211_operating_class_to_band(u8 operating_class,
 		*band = NL80211_BAND_5GHZ;
 		return true;
 	case 131 ... 135:
+	case 137:
 		*band = NL80211_BAND_6GHZ;
 		return true;
 	case 81:
Signature · 1 line
2.38.1
#8 lore raw

PATCH 8/18 wifi: mac80211: mesh: fix some kdoc warnings

In reply to [email protected]

From: Benjamin Berg <[email protected]>

These were mostly missing or incorrectly tagged return values.

---
 net/mac80211/mesh.c         |  8 ++++++--
 net/mac80211/mesh_hwmp.c    |  2 ++
 net/mac80211/mesh_pathtbl.c | 20 +++++++++++++-------
 net/mac80211/mesh_plink.c   |  6 +++++-
 net/mac80211/mesh_ps.c      |  6 +++++-
 net/mac80211/mesh_sync.c    |  4 +++-
 6 files changed, 34 insertions(+), 12 deletions(-)
net/mac80211/mesh.c +6 -2
index 0d0fbae51b61..9b1fd43df6ef 100644
@@ -56,6 +56,8 @@ static void ieee80211_mesh_housekeeping_timer(struct timer_list *t)
  *
  * This function checks if the mesh configuration of a mesh point matches the
  * local mesh configuration, i.e. if both nodes belong to the same mesh network.
+ *
+ * Returns: %true if both nodes belong to the same mesh
  */
 bool mesh_matches_local(struct ieee80211_sub_if_data *sdata,
 			struct ieee802_11_elems *ie)
@@ -119,6 +121,8 @@ bool mesh_matches_local(struct ieee80211_sub_if_data *sdata,
  * mesh_peer_accepts_plinks - check if an mp is willing to establish peer links
  *
  * @ie: information elements of a management frame from the mesh peer
+ *
+ * Returns: %true if the mesh peer is willing to establish peer links
  */
 bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie)
 {
@@ -858,7 +862,7 @@ bool ieee80211_mesh_xmit_fast(struct ieee80211_sub_if_data *sdata,
  * @meshsa:	source address in the mesh.  Same as TA, as frame is
  *              locally originated.
  *
- * Return the length of the 802.11 (does not include a mesh control header)
+ * Returns: the length of the 802.11 frame header (excludes mesh control header)
  */
 int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
 				  const u8 *meshda, const u8 *meshsa)
@@ -891,7 +895,7 @@ int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
  * @addr6:	2nd address in the ae header, which corresponds to addr6 of the
  *              mesh frame
  *
- * Return the header length.
+ * Returns: the header length
  */
 unsigned int ieee80211_new_mesh_header(struct ieee80211_sub_if_data *sdata,
 				       struct ieee80211s_hdr *meshhdr,
net/mac80211/mesh_hwmp.c +2 -0
index 51369072984e..775d52561c54 100644
@@ -230,6 +230,8 @@ static void prepare_frame_for_deferred_tx(struct ieee80211_sub_if_data *sdata,
  * Note: This function may be called with driver locks taken that the driver
  * also acquires in the TX path.  To avoid a deadlock we don't transmit the
  * frame directly but add it to the pending queue instead.
+ *
+ * Returns: 0 on success
  */
 int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata,
 		       u8 ttl, const u8 *target, u32 target_sn,
net/mac80211/mesh_pathtbl.c +13 -7
index 3e52aaa57b1f..8a3f44ce3e04 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2008, 2009 open80211s Ltd.
+ * Copyright (C) 2023 Intel Corporation
  * Author:     Luis Carlos Cobo <[email protected]>
  */
 
@@ -173,6 +174,11 @@ static void prepare_for_gate(struct sk_buff *skb, char *dst_addr,
 /**
  * mesh_path_move_to_queue - Move or copy frames from one mpath queue to another
  *
+ * @gate_mpath: An active mpath the frames will be sent to (i.e. the gate)
+ * @from_mpath: The failed mpath
+ * @copy: When true, copy all the frames to the new mpath queue.  When false,
+ * move them.
+ *
  * This function is used to transfer or copy frames from an unresolved mpath to
  * a gate mpath.  The function also adds the Address Extension field and
  * updates the next hop.
@@ -181,11 +187,6 @@ static void prepare_for_gate(struct sk_buff *skb, char *dst_addr,
  * destination addresses are updated.
  *
  * The gate mpath must be an active mpath with a valid mpath->next_hop.
- *
- * @gate_mpath: An active mpath the frames will be sent to (i.e. the gate)
- * @from_mpath: The failed mpath
- * @copy: When true, copy all the frames to the new mpath queue.  When false,
- * move them.
  */
 static void mesh_path_move_to_queue(struct mesh_path *gate_mpath,
 				    struct mesh_path *from_mpath,
@@ -330,6 +331,8 @@ mpp_path_lookup_by_idx(struct ieee80211_sub_if_data *sdata, int idx)
 /**
  * mesh_path_add_gate - add the given mpath to a mesh gate to our path table
  * @mpath: gate path to add to table
+ *
+ * Returns: 0 on success, -EEXIST
  */
 int mesh_path_add_gate(struct mesh_path *mpath)
 {
@@ -388,6 +391,8 @@ static void mesh_gate_del(struct mesh_table *tbl, struct mesh_path *mpath)
 /**
  * mesh_gate_num - number of gates known to this interface
  * @sdata: subif data
+ *
+ * Returns: The number of gates
  */
 int mesh_gate_num(struct ieee80211_sub_if_data *sdata)
 {
@@ -861,10 +866,9 @@ static void table_flush_by_iface(struct mesh_table *tbl)
 /**
  * mesh_path_flush_by_iface - Deletes all mesh paths associated with a given iface
  *
- * This function deletes both mesh paths as well as mesh portal paths.
- *
  * @sdata: interface data to match
  *
+ * This function deletes both mesh paths as well as mesh portal paths.
  */
 void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata)
 {
@@ -944,6 +948,8 @@ void mesh_path_tx_pending(struct mesh_path *mpath)
  * queue to that gate's queue.  If there are more than one gates, the frames
  * are copied from each gate to the next.  After frames are copied, the
  * mpath queues are emptied onto the transmission queue.
+ *
+ * Returns: 0 on success, -EHOSTUNREACH
  */
 int mesh_path_send_to_gates(struct mesh_path *mpath)
 {
net/mac80211/mesh_plink.c +5 -1
index a1e526419e9d..dbabeefe4515 100644
@@ -153,6 +153,8 @@ static u64 mesh_set_short_slot_time(struct ieee80211_sub_if_data *sdata)
  * selected if any non-HT peers are present in our MBSS.  20MHz-protection mode
  * is selected if all peers in our 20/40MHz MBSS support HT and at least one
  * HT20 peer is present. Otherwise no-protection mode is selected.
+ *
+ * Returns: BSS_CHANGED_HT or 0 for no change
  */
 static u64 mesh_set_ht_prot_mode(struct ieee80211_sub_if_data *sdata)
 {
@@ -362,7 +364,7 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
  * Mesh paths with this peer as next hop should be flushed
  * by the caller outside of plink_lock.
  *
- * Returns beacon changed flag if the beacon content changed.
+ * Returns: beacon changed flag if the beacon content changed.
  *
  * Locking: the caller must hold sta->mesh->plink_lock
  */
@@ -390,6 +392,8 @@ static u64 __mesh_plink_deactivate(struct sta_info *sta)
  * @sta: mesh peer link to deactivate
  *
  * All mesh paths with this peer as next hop will be flushed
+ *
+ * Returns: beacon changed flag if the beacon content changed.
  */
 u64 mesh_plink_deactivate(struct sta_info *sta)
 {
net/mac80211/mesh_ps.c +5 -1
index 35eacca43e49..20e022a03933 100644
@@ -15,6 +15,8 @@
 /**
  * mps_qos_null_get - create pre-addressed QoS Null frame for mesh powersave
  * @sta: the station to get the frame for
+ *
+ * Returns: A newly allocated SKB
  */
 static struct sk_buff *mps_qos_null_get(struct sta_info *sta)
 {
@@ -77,6 +79,8 @@ static void mps_qos_null_tx(struct sta_info *sta)
  *
  * sets the non-peer power mode and triggers the driver PS (re-)configuration
  * Return BSS_CHANGED_BEACON if a beacon update is necessary.
+ *
+ * Returns: BSS_CHANGED_BEACON if a beacon update is in order.
  */
 u64 ieee80211_mps_local_status_update(struct ieee80211_sub_if_data *sdata)
 {
@@ -147,7 +151,7 @@ u64 ieee80211_mps_local_status_update(struct ieee80211_sub_if_data *sdata)
  *
  * @sta: mesh STA
  * @pm: the power mode to set
- * Return BSS_CHANGED_BEACON if a beacon update is in order.
+ * Returns: BSS_CHANGED_BEACON if a beacon update is in order.
  */
 u64 ieee80211_mps_set_sta_local_pm(struct sta_info *sta,
 				   enum nl80211_mesh_power_mode pm)
net/mac80211/mesh_sync.c +3 -1
index 9e342cc2504c..8cf3f395f52f 100644
@@ -3,7 +3,7 @@
  * Copyright 2011-2012, Pavel Zubarev <[email protected]>
  * Copyright 2011-2012, Marco Porsch <[email protected]>
  * Copyright 2011-2012, cozybit Inc.
- * Copyright (C) 2021 Intel Corporation
+ * Copyright (C) 2021,2023 Intel Corporation
  */
 
 #include "ieee80211_i.h"
@@ -37,6 +37,8 @@ struct sync_method {
  * mesh_peer_tbtt_adjusting - check if an mp is currently adjusting its TBTT
  *
  * @cfg: mesh config element from the mesh peer (or %NULL)
+ *
+ * Returns: If the mesh peer is currently adjusting its TBTT
  */
 static bool mesh_peer_tbtt_adjusting(const struct ieee80211_meshconf_ie *cfg)
 {
Signature · 1 line
2.38.1
#9 lore raw

Re: [PATCH 08/18] wifi: mac80211: mesh: fix some kdoc warnings

Quoted 20 lines · On 9/28/2023 7:35 AM, [email protected] wrote:

From: Benjamin Berg <[email protected]>

These were mostly missing or incorrectly tagged return values.

---
  net/mac80211/mesh.c         |  8 ++++++--
  net/mac80211/mesh_hwmp.c    |  2 ++
  net/mac80211/mesh_pathtbl.c | 20 +++++++++++++-------
  net/mac80211/mesh_plink.c   |  6 +++++-
  net/mac80211/mesh_ps.c      |  6 +++++-
  net/mac80211/mesh_sync.c    |  4 +++-
  6 files changed, 34 insertions(+), 12 deletions(-)
net/mac80211/mesh.c +0 -0
index 0d0fbae51b61..9b1fd43df6ef 100644

net/mac80211/mesh.c static void ieee80211_mesh_housekeeping_timer(struct timer_list *t) · line 60

Quoted 5 lines
net/mac80211/mesh.c +2 -0
@@ -56,6 +56,8 @@ static void ieee80211_mesh_housekeeping_timer(struct timer_list *t)
   *
   * This function checks if the mesh configuration of a mesh point matches the
   * local mesh configuration, i.e. if both nodes belong to the same mesh network.
+ *
+ * Returns: %true if both nodes belong to the same mesh

I thought kdoc used Return: not Returns:

<https://static.lwn.net/kerneldoc/doc-guide/kernel-doc.html#function-documentation>

maintainer
#10 lore raw

Re: [PATCH 08/18] wifi: mac80211: mesh: fix some kdoc warnings

Hi,

Quoted 11 lines

net/mac80211/mesh.c static void ieee80211_mesh_housekeeping_timer(struct timer_list *t) · line 60

Quoted 7 lines

+++ b/net/mac80211/mesh.c

net/mac80211/mesh.c +2 -0
@@ -56,6 +56,8 @@ static void ieee80211_mesh_housekeeping_timer(struct timer_list *t)
   *
   * This function checks if the mesh configuration of a mesh point matches the
   * local mesh configuration, i.e. if both nodes belong to the same mesh network.
+ *
+ * Returns: %true if both nodes belong to the same mesh

I thought kdoc used Return: not Returns:

<https://static.lwn.net/kerneldoc/doc-guide/kernel-doc.html#function-documentation>

Huh, indeed.

I'm sure this actually fixed it though because we did start running kernel-doc on this code internally (via W=1), the issue at hand was that we used to compile without mesh (not supported by iwlwifi) and now added it for hwsim testing.

So ... I looked, and indeed _both_ are accepted:

scripts/kernel-doc:

        } elsif ($newsection =~ m/^returns?$/i) {
            $newsection = $section_return;
        } elsif ($newsection =~ m/^\@return$/) {
            # special: @return is a section, not a param description
            $newsection = $section_return;

which I guess means

/**
* foo - ...
*
* Returns: bar
*/

and

/**
* foo - ...
*
* Return: bar
*/

and

/**
* foo - ...
*
* @return
* bar
*/

are all accepted.

Though "Return:" is more common, perhaps due to the docs:

$ git grep ' \* Returns:' -- | wc -l
3066
$ git grep ' \* Return:' -- | wc -l
9189

Personally, I find "Returns: %true if both nodes ..." to be nicer to read, since it's more like a sentence?

But then again it depends on whether you're reading it as a description or an instruction, I guess. "Returns: something" is a description, and "Return: something" is an instruction (for the function). Hmm.

I'm inclined to say I like the descriptive text better, but since it shows up in the generated documentation with "Return" anyway, maybe it's better to have it in the same way in the code?

Though of course it's (slightly) easier to just apply it as is :)

What do you (and others!) think? Does it matter?

johannes

#11 lore raw

Re: [PATCH 08/18] wifi: mac80211: mesh: fix some kdoc warnings

Quoted 14 lines · Johannes Berg

Hi,

Quoted 11 lines

net/mac80211/mesh.c static void ieee80211_mesh_housekeeping_timer(struct timer_list *t) · line 60

Quoted 7 lines

+++ b/net/mac80211/mesh.c

net/mac80211/mesh.c +2 -0
@@ -56,6 +56,8 @@ static void ieee80211_mesh_housekeeping_timer(struct timer_list *t)
    *
    * This function checks if the mesh configuration of a mesh point matches the
    * local mesh configuration, i.e. if both nodes belong to the same mesh network.
+ *
+ * Returns: %true if both nodes belong to the same mesh

I thought kdoc used Return: not Returns:

<https://static.lwn.net/kerneldoc/doc-guide/kernel-doc.html#function-documentation>

Quoted 8 lines

Huh, indeed.

I'm sure this actually fixed it though because we did start running kernel-doc on this code internally (via W=1), the issue at hand was that we used to compile without mesh (not supported by iwlwifi) and now added it for hwsim testing.

So ... I looked, and indeed _both_ are accepted:

Hah, I suspect I used "Returns:" here because the file already used it in other places. But, I am also used to "Returns:" from gtk-doc, so it might also have felt natural to me because of that.

My hunch is, that it really doesn't matter and it can be left as-is for now. But it is also obviously true that it may be surprising and the extra consistency would help. So, a follow up patch to make everything consistent seems reasonable to me.

Benjamin

Quoted 56 lines

scripts/kernel-doc:

        } elsif ($newsection =~ m/^returns?$/i) { $newsection = $section_return;
        } elsif ($newsection =~ m/^\@return$/) {
            # special: @return is a section, not a param description $newsection = $section_return;

which I guess means

 /**
  * foo - ...
  *
  * Returns: bar
  */

and

 /**
  * foo - ...
  *
  * Return: bar
  */

and

 /**
  * foo - ...
  *
  * @return
  * bar
  */

are all accepted.

Though "Return:" is more common, perhaps due to the docs:

$ git grep ' \* Returns:' -- | wc -l
3066
$ git grep ' \* Return:' -- | wc -l
9189

Personally, I find "Returns: %true if both nodes ..." to be nicer to read, since it's more like a sentence?

But then again it depends on whether you're reading it as a description or an instruction, I guess. "Returns: something" is a description, and "Return: something" is an instruction (for the function). Hmm.

I'm inclined to say I like the descriptive text better, but since it shows up in the generated documentation with "Return" anyway, maybe it's better to have it in the same way in the code?

Quoted 5 lines

Though of course it's (slightly) easier to just apply it as is :)

What do you (and others!) think? Does it matter?

johannes

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

#12 lore raw

PATCH 9/18 wifi: cfg80211: Handle specific BSSID in 6GHz scanning

In reply to [email protected]

From: Ilan Peer <[email protected]>

When the scan parameters for a 6GHz scan specify a unicast BSSID address, and the corresponding AP is found in the scan list, add a corresponding entry in the collocated AP list, so this AP would be directly probed even if it was not advertised as a collocated AP.

This is needed for handling a scan request that is intended for a ML probe flow, where user space can requests a scan to retrieve information for other links in the AP MLD.

---
 net/wireless/scan.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
net/wireless/scan.c +37 -0
index 8d114faf4842..6c2acd3fa36a 100644
@@ -830,10 +830,47 @@ static int cfg80211_scan_6ghz(struct cfg80211_registered_device *rdev)
 		list_for_each_entry(intbss, &rdev->bss_list, list) {
 			struct cfg80211_bss *res = &intbss->pub;
 			const struct cfg80211_bss_ies *ies;
+			const struct element *ssid_elem;
+			struct cfg80211_colocated_ap *entry;
+			u32 s_ssid_tmp;
+			int ret;
 
 			ies = rcu_access_pointer(res->ies);
 			count += cfg80211_parse_colocated_ap(ies,
 							     &coloc_ap_list);
+
+			/* In case the scan request specified a specific BSSID
+			 * and the BSS is found and operating on 6GHz band then
+			 * add this AP to the collocated APs list.
+			 * This is relevant for ML probe requests when the lower
+			 * band APs have not been discovered.
+			 */
+			if (is_broadcast_ether_addr(rdev_req->bssid) ||
+			    !ether_addr_equal(rdev_req->bssid, res->bssid) ||
+			    res->channel->band != NL80211_BAND_6GHZ)
+				continue;
+
+			ret = cfg80211_calc_short_ssid(ies, &ssid_elem,
+						       &s_ssid_tmp);
+			if (ret)
+				continue;
+
+			entry = kzalloc(sizeof(*entry) + IEEE80211_MAX_SSID_LEN,
+					GFP_ATOMIC);
+
+			if (!entry)
+				continue;
+
+			memcpy(entry->bssid, res->bssid, ETH_ALEN);
+			entry->short_ssid = s_ssid_tmp;
+			memcpy(entry->ssid, ssid_elem->data,
+			       ssid_elem->datalen);
+			entry->ssid_len = ssid_elem->datalen;
+			entry->short_ssid_valid = true;
+			entry->center_freq = res->channel->center_freq;
+
+			list_add_tail(&entry->list, &coloc_ap_list);
+			count++;
 		}
 		spin_unlock_bh(&rdev->bss_lock);
 	}
Signature · 1 line
2.38.1
#13 lore raw

PATCH 10/18 wifi: mac80211: Fix setting vif links

In reply to [email protected]

From: Ilan Peer <[email protected]>

When setting the interface links, ignore the change iff both the valid links and the dormant links did not change. This is needed to support cases where the valid links didn't change but the dormant links did.

Fixes 6d543b34dbcf ("wifi: mac80211: Support disabled links during association")
---
 net/mac80211/link.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/link.c +1 -1
index 76c61a132569..bf7bd880d062 100644
@@ -195,7 +195,7 @@ static int ieee80211_vif_update_links(struct ieee80211_sub_if_data *sdata,
 
 	memset(to_free, 0, sizeof(links));
 
-	if (old_links == new_links)
+	if (old_links == new_links && dormant_links == sdata->vif.dormant_links)
 		return 0;
 
 	/* if there were no old links, need to clear the pointers to deflink */
Signature · 1 line
2.38.1
#14 lore raw

PATCH 11/18 wifi: cfg80211: Fix typo in documentation

In reply to [email protected]

From: Ilan Peer <[email protected]>

Fix a small typo in a comment.

---
 include/net/cfg80211.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/cfg80211.h +1 -1
index 34c50f7273d1..f4cba7e601e2 100644
@@ -2661,7 +2661,7 @@ static inline void get_random_mask_addr(u8 *buf, const u8 *addr, const u8 *mask)
  *	or no match (RSSI only)
  * @rssi_thold: don't report scan results below this threshold (in s32 dBm)
  * @per_band_rssi_thold: Minimum rssi threshold for each band to be applied
- *	for filtering out scan results received. Drivers advertize this support
+ *	for filtering out scan results received. Drivers advertise this support
  *	of band specific rssi based filtering through the feature capability
  *	%NL80211_EXT_FEATURE_SCHED_SCAN_BAND_SPECIFIC_RSSI_THOLD. These band
  *	specific rssi thresholds take precedence over rssi_thold, if specified.
Signature · 1 line
2.38.1
#15 lore raw

PATCH 12/18 wifi: mac80211: Check if we had first beacon with relevant links

In reply to [email protected]

From: Miri Korenblit <[email protected]>

If there is a disassoc before the fisrt beacon we need to protect a session for the deauth frame. Currently we are checking if we had a beacon in the default link, which is wrong in a MLO connection and link id != 0.
Fix this by checking all the active links, if non had a beacon then protect a session.
If at least one link had a beacon there is no need for session protection.

---
 net/mac80211/mlme.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
net/mac80211/mlme.c +14 -3
index e92598dcf3ed..e3db27ec6793 100644
@@ -2935,9 +2935,20 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
 		 * deauthentication frame by calling mgd_prepare_tx, if the
 		 * driver requested so.
 		 */
-		if (ieee80211_hw_check(&local->hw, DEAUTH_NEED_MGD_TX_PREP) &&
-		    !sdata->deflink.u.mgd.have_beacon) {
-			drv_mgd_prepare_tx(sdata->local, sdata, &info);
+		if (ieee80211_hw_check(&local->hw, DEAUTH_NEED_MGD_TX_PREP)) {
+			for (link_id = 0; link_id < ARRAY_SIZE(sdata->link);
+			     link_id++) {
+				struct ieee80211_link_data *link;
+
+				link = sdata_dereference(sdata->link[link_id],
+							 sdata);
+				if (!link)
+					continue;
+				if (link->u.mgd.have_beacon)
+					break;
+			}
+			if (link_id == IEEE80211_MLD_MAX_NUM_LINKS)
+				drv_mgd_prepare_tx(sdata->local, sdata, &info);
 		}
 
 		ieee80211_send_deauth_disassoc(sdata, sdata->vif.cfg.ap_addr,
Signature · 1 line
2.38.1
#16 lore raw

Re: [PATCH 12/18] wifi: mac80211: Check if we had first beacon with relevant links

Quoted 7 lines · On 9/28/2023 7:35 AM, [email protected] wrote:

From: Miri Korenblit <[email protected]>

If there is a disassoc before the fisrt beacon we need to protect a session for the deauth frame. Currently we are checking if we had a beacon in the default link, which is wrong in a MLO connection and link id != 0.
Fix this by checking all the active links, if non had a beacon then

s/ non / none /

#17 lore raw

PATCH 13/18 wifi: mac80211: add link id to mgd_prepare_tx()

In reply to [email protected]

From: Miri Korenblit <[email protected]>

As we are moving to MLO and links terms, also the airtime protection will be done for a link rather than for a vif. Thus, some drivers will need to know for which link to protect airtime. Add link id as a parameter to the mgd_prepare_tx() callback.

---
 include/net/mac80211.h    | 3 +++
 net/mac80211/driver-ops.h | 1 +
 net/mac80211/mlme.c       | 9 ++++++++-
 3 files changed, 12 insertions(+), 1 deletion(-)
include/net/mac80211.h +3 -0
index 7dae9aac089c..db3e3bd62a61 100644
@@ -3641,11 +3641,14 @@ enum ieee80211_reconfig_type {
  * @success: whether the frame exchange was successful, only
  *	used with the mgd_complete_tx() method, and then only
  *	valid for auth and (re)assoc.
+ * @link_id: the link id on which the frame will be TX'ed.
+ *	Only used with the mgd_prepare_tx() method.
  */
 struct ieee80211_prep_tx_info {
 	u16 duration;
 	u16 subtype;
 	u8 success:1;
+	int link_id;
 };
 
 /**
net/mac80211/driver-ops.h +1 -0
index e07e65da15ee..3c8eb6afd6fd 100644
@@ -928,6 +928,7 @@ static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
 		return;
 	WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
 
+	info->link_id = info->link_id < 0 ? 0 : info->link_id;
 	trace_drv_mgd_prepare_tx(local, sdata, info->duration,
 				 info->subtype, info->success);
 	if (local->ops->mgd_prepare_tx)
net/mac80211/mlme.c +8 -1
index e3db27ec6793..d19940864774 100644
@@ -1583,6 +1583,7 @@ static int ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
 
 	ifmgd->assoc_req_ies_len = pos - ie_start;
 
+	info.link_id = assoc_data->assoc_link_id;
 	drv_mgd_prepare_tx(local, sdata, &info);
 
 	IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
@@ -2947,8 +2948,10 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
 				if (link->u.mgd.have_beacon)
 					break;
 			}
-			if (link_id == IEEE80211_MLD_MAX_NUM_LINKS)
+			if (link_id == IEEE80211_MLD_MAX_NUM_LINKS) {
+				info.link_id = ffs(sdata->vif.active_links) - 1;
 				drv_mgd_prepare_tx(sdata->local, sdata, &info);
+			}
 		}
 
 		ieee80211_send_deauth_disassoc(sdata, sdata->vif.cfg.ap_addr,
@@ -3576,6 +3579,7 @@ static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata,
 	u32 tx_flags = 0;
 	struct ieee80211_prep_tx_info info = {
 		.subtype = IEEE80211_STYPE_AUTH,
+		.link_id = auth_data->link_id,
 	};
 
 	pos = mgmt->u.auth.variable;
@@ -6566,6 +6570,7 @@ static int ieee80211_auth(struct ieee80211_sub_if_data *sdata)
 	if (auth_data->algorithm == WLAN_AUTH_SAE)
 		info.duration = jiffies_to_msecs(IEEE80211_AUTH_TIMEOUT_SAE);
 
+	info.link_id = auth_data->link_id;
 	drv_mgd_prepare_tx(local, sdata, &info);
 
 	sdata_info(sdata, "send auth to %pM (try %d/%d)\n",
@@ -7986,6 +7991,7 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
 			   req->bssid, req->reason_code,
 			   ieee80211_get_reason_code_string(req->reason_code));
 
+		info.link_id = ifmgd->auth_data->link_id;
 		drv_mgd_prepare_tx(sdata->local, sdata, &info);
 		ieee80211_send_deauth_disassoc(sdata, req->bssid, req->bssid,
 					       IEEE80211_STYPE_DEAUTH,
@@ -8006,6 +8012,7 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
 			   req->bssid, req->reason_code,
 			   ieee80211_get_reason_code_string(req->reason_code));
 
+		info.link_id = ifmgd->assoc_data->assoc_link_id;
 		drv_mgd_prepare_tx(sdata->local, sdata, &info);
 		ieee80211_send_deauth_disassoc(sdata, req->bssid, req->bssid,
 					       IEEE80211_STYPE_DEAUTH,
Signature · 1 line
2.38.1
#18 lore raw

PATCH 14/18 wifi: mac80211: make mgd_protect_tdls_discover MLO-aware

In reply to [email protected]

From: Miri Korenblit <[email protected]>

Since userspace can choose now what link to establish the TDLS on, we should know on what channel to do session protection. Add a link id parameter to this callback.

---
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h  | 3 ++-
 drivers/net/wireless/intel/iwlwifi/mvm/tdls.c | 5 +++--
 include/net/mac80211.h                        | 3 ++-
 net/mac80211/driver-ops.h                     | 8 ++++++--
 net/mac80211/tdls.c                           | 2 +-
 5 files changed, 14 insertions(+), 7 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +2 -1
index 66d9de0f1511..74cb2f863472 100644
@@ -2345,7 +2345,8 @@ void iwl_mvm_teardown_tdls_peers(struct iwl_mvm *mvm);
 void iwl_mvm_recalc_tdls_state(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 			       bool sta_added);
 void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw,
-					   struct ieee80211_vif *vif);
+					   struct ieee80211_vif *vif,
+					   unsigned int link_id);
 int iwl_mvm_tdls_channel_switch(struct ieee80211_hw *hw,
 				struct ieee80211_vif *vif,
 				struct ieee80211_sta *sta, u8 oper_class,
drivers/net/wireless/intel/iwlwifi/mvm/tdls.c +3 -2
index dae6f2a1aad9..fac992af3ddb 100644
@@ -2,7 +2,7 @@
 /*
  * Copyright (C) 2014 Intel Mobile Communications GmbH
  * Copyright (C) 2017 Intel Deutschland GmbH
- * Copyright (C) 2018-2020, 2022 Intel Corporation
+ * Copyright (C) 2018-2020, 2022-2023 Intel Corporation
  */
 #include <linux/etherdevice.h>
 #include "mvm.h"
@@ -144,7 +144,8 @@ void iwl_mvm_recalc_tdls_state(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 }
 
 void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw,
-					   struct ieee80211_vif *vif)
+					   struct ieee80211_vif *vif,
+					   unsigned int link_id)
 {
 	struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
 	u32 duration = 2 * vif->bss_conf.dtim_period * vif->bss_conf.beacon_int;
include/net/mac80211.h +2 -1
index db3e3bd62a61..c839a04ad9db 100644
@@ -4525,7 +4525,8 @@ struct ieee80211_ops {
 				   struct ieee80211_prep_tx_info *info);
 
 	void	(*mgd_protect_tdls_discover)(struct ieee80211_hw *hw,
-					     struct ieee80211_vif *vif);
+					     struct ieee80211_vif *vif,
+					     unsigned int link_id);
 
 	int (*add_chanctx)(struct ieee80211_hw *hw,
 			   struct ieee80211_chanctx_conf *ctx);
net/mac80211/driver-ops.h +6 -2
index 3c8eb6afd6fd..568633b38c47 100644
@@ -956,7 +956,8 @@ static inline void drv_mgd_complete_tx(struct ieee80211_local *local,
 
 static inline void
 drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
-			      struct ieee80211_sub_if_data *sdata)
+			      struct ieee80211_sub_if_data *sdata,
+			      int link_id)
 {
 	might_sleep();
 	lockdep_assert_wiphy(local->hw.wiphy);
@@ -965,9 +966,12 @@ drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
 		return;
 	WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
 
+	link_id = link_id > 0 ? link_id : 0;
+
 	trace_drv_mgd_protect_tdls_discover(local, sdata);
 	if (local->ops->mgd_protect_tdls_discover)
-		local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif);
+		local->ops->mgd_protect_tdls_discover(&local->hw, &sdata->vif,
+						      link_id);
 	trace_drv_return_void(local);
 }
 
net/mac80211/tdls.c +1 -1
index f3fd66d30b84..05a7dff69fe9 100644
@@ -1318,7 +1318,7 @@ int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
 		 * response frame. It is transmitted directly and not buffered
 		 * by the AP.
 		 */
-		drv_mgd_protect_tdls_discover(sdata->local, sdata);
+		drv_mgd_protect_tdls_discover(sdata->local, sdata, link_id);
 		fallthrough;
 	case WLAN_TDLS_SETUP_CONFIRM:
 	case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
Signature · 1 line
2.38.1
#19 lore raw

PATCH 15/18 wifi: mac80211: fix a expired vs. cancel race in roc

In reply to [email protected]

From: Emmanuel Grumbach <[email protected]>

When the remain on channel is removed at the time it should have expired, we have a race: the driver could be handling the flow of the expiration while mac80211 is cancelling that very same remain on channel request.

This wouldn't be problem in itself, but since mac80211 can send the next request to the driver in the cancellation flow, we can get to the following situation:

CPU0 CPU1
expiration of roc in driver ieee80211_remain_on_channel_expired()
Cancellation of the roc
schedules a worker (hw_roc_done)
Add next roc
hw_roc_done_wk runs and ends
the second roc prematurely.

Since, by design, there is only one single request sent to the driver at a time, we can safely assume that after the cancel() request returns from the driver, we should not handle any worker that handles the expiration of the request.

Cancel the hw_roc_done worker after the cancellation to make sure we start the next one with a clean slate.

---
 net/mac80211/offchannel.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
net/mac80211/offchannel.c +17 -0
index 071582dbe6a5..6c4080202573 100644
@@ -717,6 +717,23 @@ static int ieee80211_cancel_roc(struct ieee80211_local *local,
 			return ret;
 		}
 
+		/*
+		 * We could be racing against the notification from the driver:
+		 *  + driver is handling the notification on CPU0
+		 *  + user space is cancelling the remain on channel and
+		 *    schedules the hw_roc_done worker.
+		 *
+		 *  Now hw_roc_done might start to run after the next roc will
+		 *  start and mac80211 will think that this second roc has
+		 *  ended prematurely.
+		 *  Cancel the work to make sure that all the pending workers
+		 *  have completed execution.
+		 *  Note that this assumes that by the time the driver returns
+		 *  from drv_cancel_remain_on_channel, it has completed all
+		 *  the processing of related notifications.
+		 */
+		wiphy_work_cancel(local->hw.wiphy, &local->hw_roc_done);
+
 		/* TODO:
 		 * if multiple items were combined here then we really shouldn't
 		 * cancel them all - we should wait for as much time as needed
Signature · 1 line
2.38.1
#20 lore raw

PATCH 16/18 wifi: cfg80211: wext: convert return value to kernel-doc

In reply to [email protected]

From: Johannes Berg <[email protected]>

Since I'm getting a warning here right now, fix the kernel-doc to be "Returns:" rather than just writing that out in the doc paragraph.

---
 net/wireless/wext-compat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/wireless/wext-compat.c +2 -2
index d23ce088bffa..2371069f3c43 100644
@@ -7,7 +7,7 @@
  * we directly assign the wireless handlers of wireless interfaces.
  *
  * Copyright 2008-2009	Johannes Berg <[email protected]>
- * Copyright (C) 2019-2022 Intel Corporation
+ * Copyright (C) 2019-2023 Intel Corporation
  */
 
 #include <linux/export.h>
@@ -227,7 +227,7 @@ EXPORT_WEXT_HANDLER(cfg80211_wext_giwrange);
  * cfg80211_wext_freq - get wext frequency for non-"auto"
  * @freq: the wext freq encoding
  *
- * Returns a frequency, or a negative error code, or 0 for auto.
+ * Returns: a frequency, or a negative error code, or 0 for auto.
  */
 int cfg80211_wext_freq(struct iw_freq *freq)
 {
Signature · 1 line
2.38.1
#21 lore raw

Re: [PATCH 16/18] wifi: cfg80211: wext: convert return value to kernel-doc

Quoted 26 lines · On 9/28/2023 7:35 AM, [email protected] wrote:

From: Johannes Berg <[email protected]>

Since I'm getting a warning here right now, fix the kernel-doc to be "Returns:" rather than just writing that out in the doc paragraph.

---
  net/wireless/wext-compat.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
net/wireless/wext-compat.c +1 -1
index d23ce088bffa..2371069f3c43 100644
@@ -7,7 +7,7 @@
   * we directly assign the wireless handlers of wireless interfaces.
   *
   * Copyright 2008-2009	Johannes Berg <[email protected]>
- * Copyright (C) 2019-2022 Intel Corporation
+ * Copyright (C) 2019-2023 Intel Corporation
   */
 
  #include <linux/export.h>

net/wireless/wext-compat.c EXPORT_WEXT_HANDLER(cfg80211_wext_giwrange); · line 230

Quoted 5 lines
net/wireless/wext-compat.c +1 -1
@@ -227,7 +227,7 @@ EXPORT_WEXT_HANDLER(cfg80211_wext_giwrange);
   * cfg80211_wext_freq - get wext frequency for non-"auto"
   * @freq: the wext freq encoding
   *
- * Returns a frequency, or a negative error code, or 0 for auto.
+ * Returns: a frequency, or a negative error code, or 0 for auto.

again, shouldn't this be Return:

Quoted 3 lines
net/wireless/wext-compat.c +0 -0
   */
  int cfg80211_wext_freq(struct iw_freq *freq)
  {
#22 lore raw

PATCH 17/18 wifi: mac80211: purge TX queues in flush_queues flow

In reply to [email protected]

From: Miri Korenblit <[email protected]>

When this flow is invoked with the "drop" parameter as true, we only drop the frames from the hw queues, but not from the sw queues.
So when we call wake_queues() after hw queue purging, all the frames from the sw queues will be TX'ed,
when what we actually want to do is to purge all queues in order to not TX anything...
This can cause, for example, TXing data frames to the peer after the deauth frame was sent.
Fix this by purging the sw queues in addition to the hw queues if the drop parameter is true.

---
 net/mac80211/ieee80211_i.h |  1 +
 net/mac80211/sta_info.c    | 28 ++++++++++++++++++----------
 net/mac80211/util.c        | 13 +++++++++++++
 3 files changed, 32 insertions(+), 10 deletions(-)
net/mac80211/ieee80211_i.h +1 -0
index eb459a6a76f5..4f9afa2fe0e9 100644
@@ -2390,6 +2390,7 @@ void ieee80211_txq_init(struct ieee80211_sub_if_data *sdata,
 			struct txq_info *txq, int tid);
 void ieee80211_txq_purge(struct ieee80211_local *local,
 			 struct txq_info *txqi);
+void ieee80211_purge_sta_txqs(struct sta_info *sta);
 void ieee80211_txq_remove_vlan(struct ieee80211_local *local,
 			       struct ieee80211_sub_if_data *sdata);
 void ieee80211_fill_txq_stats(struct cfg80211_txq_stats *txqstats,
net/mac80211/sta_info.c +18 -10
index ba36fc29e532..450700173422 100644
@@ -113,6 +113,23 @@ static int link_sta_info_hash_del(struct ieee80211_local *local,
 			       &link_sta->link_hash_node, link_sta_rht_params);
 }
 
+void ieee80211_purge_sta_txqs(struct sta_info *sta)
+{
+	struct ieee80211_local *local = sta->sdata->local;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
+		struct txq_info *txqi;
+
+		if (!sta->sta.txq[i])
+			continue;
+
+		txqi = to_txq_info(sta->sta.txq[i]);
+
+		ieee80211_txq_purge(local, txqi);
+	}
+}
+
 static void __cleanup_single_sta(struct sta_info *sta)
 {
 	int ac, i;
@@ -139,16 +156,7 @@ static void __cleanup_single_sta(struct sta_info *sta)
 		atomic_dec(&ps->num_sta_ps);
 	}
 
-	for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
-		struct txq_info *txqi;
-
-		if (!sta->sta.txq[i])
-			continue;
-
-		txqi = to_txq_info(sta->sta.txq[i]);
-
-		ieee80211_txq_purge(local, txqi);
-	}
+	ieee80211_purge_sta_txqs(sta);
 
 	for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
 		local->total_ps_buffered -= skb_queue_len(&sta->ps_tx_buf[ac]);
net/mac80211/util.c +13 -0
index 98a3bffc6991..b6be18710441 100644
@@ -693,6 +693,19 @@ void __ieee80211_flush_queues(struct ieee80211_local *local,
 					IEEE80211_QUEUE_STOP_REASON_FLUSH,
 					false);
 
+	if (drop) {
+		struct sta_info *sta;
+
+		/* Purge the queues, so the frames on them won't be
+		 * sent during __ieee80211_wake_queue()
+		 */
+		list_for_each_entry(sta, &local->sta_list, list) {
+			if (sdata != sta->sdata)
+				continue;
+			ieee80211_purge_sta_txqs(sta);
+		}
+	}
+
 	drv_flush(local, sdata, queues, drop);
 
 	ieee80211_wake_queues_by_reason(&local->hw, queues,
Signature · 1 line
2.38.1
#23 lore raw

PATCH 18/18 wifi: mac80211: flush STA queues on unauthorization

In reply to [email protected]

From: Johannes Berg <[email protected]>

When the station is marked as no longer authorized, we shouldn't transmit to it any longer, but in particular we shouldn't be able to transmit to it after removing keys, which might lead to frames being sent out unencrypted depending on the exact hardware offload mechanism. Thus, instead of flushing only on station destruction, which covers only some cases, always flush on unauthorization.

---
 net/mac80211/sta_info.c | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)
net/mac80211/sta_info.c +20 -12
index 450700173422..0ba613dd1cc4 100644
@@ -1275,6 +1275,8 @@ static int _sta_info_move_state(struct sta_info *sta,
 				enum ieee80211_sta_state new_state,
 				bool recalc)
 {
+	struct ieee80211_local *local = sta->local;
+
 	might_sleep();
 
 	if (sta->sta_state == new_state)
@@ -1350,6 +1352,24 @@ static int _sta_info_move_state(struct sta_info *sta,
 		} else if (sta->sta_state == IEEE80211_STA_AUTHORIZED) {
 			ieee80211_vif_dec_num_mcast(sta->sdata);
 			clear_bit(WLAN_STA_AUTHORIZED, &sta->_flags);
+
+			/*
+			 * If we have encryption offload, flush (station) queues
+			 * (after ensuring concurrent TX completed) so we won't
+			 * transmit anything later unencrypted if/when keys are
+			 * also removed, which might otherwise happen depending
+			 * on how the hardware offload works.
+			 */
+			if (local->ops->set_key) {
+				synchronize_net();
+				if (local->ops->flush_sta)
+					drv_flush_sta(local, sta->sdata, sta);
+				else
+					ieee80211_flush_queues(local,
+							       sta->sdata,
+							       false);
+			}
+
 			ieee80211_clear_fast_xmit(sta);
 			ieee80211_clear_fast_rx(sta);
 		}
@@ -1415,18 +1435,6 @@ static void __sta_info_destroy_part2(struct sta_info *sta, bool recalc)
 		WARN_ON_ONCE(ret);
 	}
 
-	/* Flush queues before removing keys, as that might remove them
-	 * from hardware, and then depending on the offload method, any
-	 * frames sitting on hardware queues might be sent out without
-	 * any encryption at all.
-	 */
-	if (local->ops->set_key) {
-		if (local->ops->flush_sta)
-			drv_flush_sta(local, sta->sdata, sta);
-		else
-			ieee80211_flush_queues(local, sta->sdata, false);
-	}
-
 	/* now keys can no longer be reached */
 	ieee80211_free_sta_keys(local, sta);
 
Signature · 1 line
2.38.1