Skip to contentSkip to conversation

cfg80211/mac80211 patches from our internal tree 2023-08-27

PATCH Superseded [email protected] 5 participants 20 messages Aug 27, 2023 – Sep 4, 2023

Subsystems (6)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover cfg80211/mac80211 patches from our internal tree 2023-08-27

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: cfg80211: add ieee80211_fragment_element to public API
wifi: mac80211: add more warnings about inserting sta info

Emmanuel Grumbach (1):
wifi: mac80211: add support for mld in ieee80211_chswitch_done

Ilan Peer (2):
wifi: mac80211: Print local link address during authentication
wifi: mac80211: Do not force off-channel for management Tx with MLO

Johannes Berg (10):
wifi: cfg80211: fix off-by-one in element defrag
wifi: cfg80211: add first kunit tests, for element defrag
wifi: mac80211: add an element parsing unit test
wifi: mac80211: remove unnecessary struct forward declaration
wifi: mac80211: fix various kernel-doc issues
wifi: cfg80211: reg: fix various kernel-doc issues
wifi: mac80211_hwsim: clean up kernel-doc
wifi: mac80211: fix # of MSDU in A-MSDU calculation
wifi: mac80211: take MBSSID/EHT data also from probe resp
wifi: mac80211: fix channel switch link data

 .../net/wireless/intel/iwlegacy/4965-mac.c    |   2 +-
 drivers/net/wireless/intel/iwlegacy/common.c  |   2 +-
 .../net/wireless/intel/iwlwifi/dvm/mac80211.c |   6 +-
 .../net/wireless/intel/iwlwifi/mvm/mac-ctxt.c |   2 +-
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c |  10 +-
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h  |   3 +-
 .../wireless/intel/iwlwifi/mvm/time-event.c   |   2 +-
 drivers/net/wireless/ti/wlcore/event.c        |   2 +-
 drivers/net/wireless/ti/wlcore/main.c         |   6 +-
 drivers/net/wireless/virtual/mac80211_hwsim.h |  19 +--
 include/net/cfg80211.h                        |  12 ++
 include/net/mac80211.h                        |   8 +-
 net/mac80211/Kconfig                          |  11 ++
 net/mac80211/Makefile                         |   2 +
 net/mac80211/cfg.c                            |  42 ++---
 net/mac80211/driver-ops.h                     |   6 +-
 net/mac80211/ieee80211_i.h                    |  21 +--
 net/mac80211/mlme.c                           |  73 +++++---
 net/mac80211/offchannel.c                     |   8 +-
 net/mac80211/sta_info.c                       |  10 +-
 net/mac80211/sta_info.h                       |   4 +-
 net/mac80211/tests/Makefile                   |   3 +
 net/mac80211/tests/elems.c                    | 101 +++++++++++
 net/mac80211/tests/module.c                   |  10 ++
 net/mac80211/util.c                           |  30 +---
 net/wireless/Kconfig                          |  11 ++
 net/wireless/Makefile                         |   1 +
 net/wireless/reg.h                            |  16 +-
 net/wireless/scan.c                           |   4 +-
 net/wireless/tests/Makefile                   |   3 +
 net/wireless/tests/fragmentation.c            | 157 ++++++++++++++++++
 net/wireless/tests/module.c                   |  10 ++
 net/wireless/util.c                           |  29 ++++
 33 files changed, 500 insertions(+), 126 deletions(-)
 create mode 100644 net/mac80211/tests/Makefile
 create mode 100644 net/mac80211/tests/elems.c
 create mode 100644 net/mac80211/tests/module.c
 create mode 100644 net/wireless/tests/Makefile
 create mode 100644 net/wireless/tests/fragmentation.c
 create mode 100644 net/wireless/tests/module.c
Signature · 1 line
2.38.1
#1 lore raw

PATCH 1/15 wifi: mac80211: add support for mld in ieee80211_chswitch_done

From: Emmanuel Grumbach <[email protected]>

This allows to finalize the CSA per link.
In case the switch didn't work, tear down the MLD connection. Also pass the ieee80211_bss_conf to post_channel_switch to let the driver know which link completed the switch.

---
 .../net/wireless/intel/iwlegacy/4965-mac.c    |  2 +-
 drivers/net/wireless/intel/iwlegacy/common.c  |  2 +-
 .../net/wireless/intel/iwlwifi/dvm/mac80211.c |  6 ++--
 .../net/wireless/intel/iwlwifi/mvm/mac-ctxt.c |  2 +-
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 10 +++---
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h  |  3 +-
 .../wireless/intel/iwlwifi/mvm/time-event.c   |  2 +-
 drivers/net/wireless/ti/wlcore/event.c        |  2 +-
 drivers/net/wireless/ti/wlcore/main.c         |  6 ++--
 include/net/mac80211.h                        |  8 +++--
 net/mac80211/cfg.c                            | 35 ++++++++++---------
 net/mac80211/driver-ops.h                     |  6 ++--
 net/mac80211/mlme.c                           | 29 ++++++++++-----
 13 files changed, 68 insertions(+), 45 deletions(-)
drivers/net/wireless/intel/iwlegacy/4965-mac.c +1 -1
index 0a4aa3c678c1..69276266ce6f 100644
@@ -6122,7 +6122,7 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 	if (il->ops->set_channel_switch(il, ch_switch)) {
 		clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status);
 		il->switch_channel = 0;
-		ieee80211_chswitch_done(il->vif, false);
+		ieee80211_chswitch_done(il->vif, false, 0);
 	}
 
 out:
drivers/net/wireless/intel/iwlegacy/common.c +1 -1
index 96002121bb8b..054fef680aba 100644
@@ -4090,7 +4090,7 @@ il_chswitch_done(struct il_priv *il, bool is_success)
 		return;
 
 	if (test_and_clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status))
-		ieee80211_chswitch_done(il->vif, is_success);
+		ieee80211_chswitch_done(il->vif, is_success, 0);
 }
 EXPORT_SYMBOL(il_chswitch_done);
 
drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c +3 -3
index b1939ff275b5..5f3d5b15f727 100644
@@ -2,7 +2,7 @@
 /******************************************************************************
  *
  * Copyright(c) 2003 - 2014 Intel Corporation. All rights reserved.
- * Copyright (C) 2018 - 2019, 2022 Intel Corporation
+ * Copyright(C) 2018 - 2019, 2022 - 2023 Intel Corporation
  *
  * Portions of this file are derived from the ipw3945 project, as well
  * as portions of the ieee80211 subsystem header files.
@@ -1001,7 +1001,7 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw,
 	if (priv->lib->set_channel_switch(priv, ch_switch)) {
 		clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status);
 		priv->switch_channel = 0;
-		ieee80211_chswitch_done(ctx->vif, false);
+		ieee80211_chswitch_done(ctx->vif, false, 0);
 	}
 
 out:
@@ -1024,7 +1024,7 @@ void iwl_chswitch_done(struct iwl_priv *priv, bool is_success)
 		return;
 
 	if (ctx->vif)
-		ieee80211_chswitch_done(ctx->vif, is_success);
+		ieee80211_chswitch_done(ctx->vif, is_success, 0);
 }
 
 static void iwlagn_configure_filter(struct ieee80211_hw *hw,
drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c +1 -1
index 7369a45f7f2b..b28d998c65c5 100644
@@ -1839,7 +1839,7 @@ void iwl_mvm_channel_switch_start_notif(struct iwl_mvm *mvm,
 
 		iwl_mvm_csa_client_absent(mvm, vif);
 		cancel_delayed_work(&mvmvif->csa_work);
-		ieee80211_chswitch_done(vif, true);
+		ieee80211_chswitch_done(vif, true, 0);
 		break;
 	default:
 		/* should never happen */
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +6 -4
index 5918c1f2b10c..921f72dcddac 100644
@@ -1370,7 +1370,8 @@ int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 }
 
 int iwl_mvm_post_channel_switch(struct ieee80211_hw *hw,
-				struct ieee80211_vif *vif)
+				struct ieee80211_vif *vif,
+				struct ieee80211_bss_conf *link_conf)
 {
 	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
 	struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
@@ -1452,7 +1453,8 @@ void iwl_mvm_abort_channel_switch(struct ieee80211_hw *hw,
 	mvmvif->csa_failed = true;
 	mutex_unlock(&mvm->mutex);
 
-	iwl_mvm_post_channel_switch(hw, vif);
+	/* If we're here, we can't support MLD */
+	iwl_mvm_post_channel_switch(hw, vif, &vif->bss_conf);
 }
 
 void iwl_mvm_channel_switch_disconnect_wk(struct work_struct *wk)
@@ -1464,7 +1466,7 @@ void iwl_mvm_channel_switch_disconnect_wk(struct work_struct *wk)
 	vif = container_of((void *)mvmvif, struct ieee80211_vif, drv_priv);
 
 	/* Trigger disconnect (should clear the CSA state) */
-	ieee80211_chswitch_done(vif, false);
+	ieee80211_chswitch_done(vif, false, 0);
 }
 
 static u8
@@ -5535,7 +5537,7 @@ void iwl_mvm_channel_switch_rx_beacon(struct ieee80211_hw *hw,
 		if (mvmvif->csa_misbehave) {
 			/* Second time, give up on this AP*/
 			iwl_mvm_abort_channel_switch(hw, vif);
-			ieee80211_chswitch_done(vif, false);
+			ieee80211_chswitch_done(vif, false, 0);
 			mvmvif->csa_misbehave = false;
 			return;
 		}
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +2 -1
index b18c91c5dd5d..dda13f4351c3 100644
@@ -2427,7 +2427,8 @@ static inline u8 iwl_mvm_phy_band_from_nl80211(enum nl80211_band band)
 /* Channel Switch */
 void iwl_mvm_channel_switch_disconnect_wk(struct work_struct *wk);
 int iwl_mvm_post_channel_switch(struct ieee80211_hw *hw,
-				struct ieee80211_vif *vif);
+				struct ieee80211_vif *vif,
+				struct ieee80211_bss_conf *link);
 
 /* Channel Context */
 /**
drivers/net/wireless/intel/iwlwifi/mvm/time-event.c +1 -1
index 5f0e7144a951..e1f6cea649c3 100644
@@ -223,7 +223,7 @@ iwl_mvm_te_handle_notify_csa(struct iwl_mvm *mvm,
 		}
 		iwl_mvm_csa_client_absent(mvm, te_data->vif);
 		cancel_delayed_work(&mvmvif->csa_work);
-		ieee80211_chswitch_done(te_data->vif, true);
+		ieee80211_chswitch_done(te_data->vif, true, 0);
 		break;
 	default:
 		/* should never happen */
drivers/net/wireless/ti/wlcore/event.c +1 -1
index 46ab69eab26a..1e082d039b82 100644
@@ -229,7 +229,7 @@ void wlcore_event_channel_switch(struct wl1271 *wl,
 		vif = wl12xx_wlvif_to_vif(wlvif);
 
 		if (wlvif->bss_type == BSS_TYPE_STA_BSS) {
-			ieee80211_chswitch_done(vif, success);
+			ieee80211_chswitch_done(vif, success, 0);
 			cancel_delayed_work(&wlvif->channel_switch_work);
 		} else {
 			set_bit(WLVIF_FLAG_BEACON_DISABLED, &wlvif->flags);
drivers/net/wireless/ti/wlcore/main.c +3 -3
index bf21611872a3..b7e68d2721c1 100644
@@ -2043,7 +2043,7 @@ static void wlcore_channel_switch_work(struct work_struct *work)
 		goto out;
 
 	vif = wl12xx_wlvif_to_vif(wlvif);
-	ieee80211_chswitch_done(vif, false);
+	ieee80211_chswitch_done(vif, false, 0);
 
 	ret = pm_runtime_resume_and_get(wl->dev);
 	if (ret < 0)
@@ -3030,7 +3030,7 @@ static int wlcore_unset_assoc(struct wl1271 *wl, struct wl12xx_vif *wlvif)
 		struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif);
 
 		wl12xx_cmd_stop_channel_switch(wl, wlvif);
-		ieee80211_chswitch_done(vif, false);
+		ieee80211_chswitch_done(vif, false, 0);
 		cancel_delayed_work(&wlvif->channel_switch_work);
 	}
 
@@ -5451,7 +5451,7 @@ static void wl12xx_op_channel_switch(struct ieee80211_hw *hw,
 
 	if (unlikely(wl->state == WLCORE_STATE_OFF)) {
 		if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags))
-			ieee80211_chswitch_done(vif, false);
+			ieee80211_chswitch_done(vif, false, 0);
 		goto out;
 	} else if (unlikely(wl->state != WLCORE_STATE_ON)) {
 		goto out;
include/net/mac80211.h +6 -2
index 7c707358d15c..67f54825110f 100644
@@ -4544,7 +4544,8 @@ struct ieee80211_ops {
 				  struct ieee80211_channel_switch *ch_switch);
 
 	int (*post_channel_switch)(struct ieee80211_hw *hw,
-				   struct ieee80211_vif *vif);
+				   struct ieee80211_vif *vif,
+				   struct ieee80211_bss_conf *link_conf);
 	void (*abort_channel_switch)(struct ieee80211_hw *hw,
 				     struct ieee80211_vif *vif);
 	void (*channel_switch_rx_beacon)(struct ieee80211_hw *hw,
@@ -6542,11 +6543,14 @@ void ieee80211_radar_detected(struct ieee80211_hw *hw);
  * ieee80211_chswitch_done - Complete channel switch process
  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  * @success: make the channel switch successful or not
+ * @link_id: the link_id on which the switch was done. Ignored if success is
+ *	false.
  *
  * Complete the channel switch post-process: set the new operational channel
  * and wake up the suspended queues.
  */
-void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success);
+void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success,
+			     unsigned int link_id);
 
 /**
  * ieee80211_channel_switch_disconnect - disconnect due to channel switch error
net/mac80211/cfg.c +19 -16
index 45e7a5d9c7d9..ae5017edd09f 100644
@@ -3638,8 +3638,9 @@ static int ieee80211_set_after_csa_beacon(struct ieee80211_sub_if_data *sdata,
 	return 0;
 }
 
-static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
+static int __ieee80211_csa_finalize(struct ieee80211_link_data *link_data)
 {
+	struct ieee80211_sub_if_data *sdata = link_data->sdata;
 	struct ieee80211_local *local = sdata->local;
 	u64 changed = 0;
 	int err;
@@ -3655,20 +3656,20 @@ static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
 	 * completed successfully
 	 */
 
-	if (sdata->deflink.reserved_chanctx) {
+	if (link_data->reserved_chanctx) {
 		/*
 		 * with multi-vif csa driver may call ieee80211_csa_finish()
 		 * many times while waiting for other interfaces to use their
 		 * reservations
 		 */
-		if (sdata->deflink.reserved_ready)
+		if (link_data->reserved_ready)
 			return 0;
 
 		return ieee80211_link_use_reserved_context(&sdata->deflink);
 	}
 
 	if (!cfg80211_chandef_identical(&sdata->vif.bss_conf.chandef,
-					&sdata->deflink.csa_chandef))
+					&link_data->csa_chandef))
 		return -EINVAL;
 
 	sdata->vif.bss_conf.csa_active = false;
@@ -3685,25 +3686,27 @@ static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
 
 	ieee80211_link_info_change_notify(sdata, &sdata->deflink, changed);
 
-	if (sdata->deflink.csa_block_tx) {
+	if (link_data->csa_block_tx) {
 		ieee80211_wake_vif_queues(local, sdata,
 					  IEEE80211_QUEUE_STOP_REASON_CSA);
-		sdata->deflink.csa_block_tx = false;
+		link_data->csa_block_tx = false;
 	}
 
-	err = drv_post_channel_switch(sdata);
+	err = drv_post_channel_switch(link_data);
 	if (err)
 		return err;
 
-	cfg80211_ch_switch_notify(sdata->dev, &sdata->deflink.csa_chandef, 0,
+	cfg80211_ch_switch_notify(sdata->dev, &link_data->csa_chandef, 0,
 				  sdata->vif.bss_conf.eht_puncturing);
 
 	return 0;
 }
 
-static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
+static void ieee80211_csa_finalize(struct ieee80211_link_data *link_data)
 {
-	if (__ieee80211_csa_finalize(sdata)) {
+	struct ieee80211_sub_if_data *sdata = link_data->sdata;
+
+	if (__ieee80211_csa_finalize(link_data)) {
 		sdata_info(sdata, "failed to finalize CSA, disconnecting\n");
 		cfg80211_stop_iface(sdata->local->hw.wiphy, &sdata->wdev,
 				    GFP_KERNEL);
@@ -3712,9 +3715,9 @@ static void ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)
 
 void ieee80211_csa_finalize_work(struct work_struct *work)
 {
-	struct ieee80211_sub_if_data *sdata =
-		container_of(work, struct ieee80211_sub_if_data,
-			     deflink.csa_finalize_work);
+	struct ieee80211_link_data *link =
+		container_of(work, struct ieee80211_link_data, csa_finalize_work);
+	struct ieee80211_sub_if_data *sdata = link->sdata;
 	struct ieee80211_local *local = sdata->local;
 
 	sdata_lock(sdata);
@@ -3722,13 +3725,13 @@ void ieee80211_csa_finalize_work(struct work_struct *work)
 	mutex_lock(&local->chanctx_mtx);
 
 	/* AP might have been stopped while waiting for the lock. */
-	if (!sdata->vif.bss_conf.csa_active)
+	if (!link->conf->csa_active)
 		goto unlock;
 
 	if (!ieee80211_sdata_running(sdata))
 		goto unlock;
 
-	ieee80211_csa_finalize(sdata);
+	ieee80211_csa_finalize(link);
 
 unlock:
 	mutex_unlock(&local->chanctx_mtx);
@@ -3978,7 +3981,7 @@ __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
 		drv_channel_switch_beacon(sdata, &params->chandef);
 	} else {
 		/* if the beacon didn't change, we can finalize immediately */
-		ieee80211_csa_finalize(sdata);
+		ieee80211_csa_finalize(&sdata->deflink);
 	}
 
 out:
net/mac80211/driver-ops.h +4 -2
index c4505593ba7a..a41dd60ae4b4 100644
@@ -1072,8 +1072,9 @@ drv_pre_channel_switch(struct ieee80211_sub_if_data *sdata,
 }
 
 static inline int
-drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
+drv_post_channel_switch(struct ieee80211_link_data *link)
 {
+	struct ieee80211_sub_if_data *sdata = link->sdata;
 	struct ieee80211_local *local = sdata->local;
 	int ret = 0;
 
@@ -1082,7 +1083,8 @@ drv_post_channel_switch(struct ieee80211_sub_if_data *sdata)
 
 	trace_drv_post_channel_switch(local, sdata);
 	if (local->ops->post_channel_switch)
-		ret = local->ops->post_channel_switch(&local->hw, &sdata->vif);
+		ret = local->ops->post_channel_switch(&local->hw, &sdata->vif,
+						      link->conf);
 	trace_drv_return_int(local, ret);
 	return ret;
 }
net/mac80211/mlme.c +20 -9
index f93eb38ae0b8..ca6045f56b4b 100644
@@ -1773,7 +1773,7 @@ static void ieee80211_chswitch_post_beacon(struct ieee80211_link_data *link)
 	 */
 	link->u.mgd.beacon_crc_valid = false;
 
-	ret = drv_post_channel_switch(sdata);
+	ret = drv_post_channel_switch(link);
 	if (ret) {
 		sdata_info(sdata,
 			   "driver post channel switch failed, disconnecting\n");
@@ -1785,25 +1785,36 @@ static void ieee80211_chswitch_post_beacon(struct ieee80211_link_data *link)
 	cfg80211_ch_switch_notify(sdata->dev, &link->reserved_chandef, 0, 0);
 }
 
-void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success)
+void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success,
+			     unsigned int link_id)
 {
+	struct ieee80211_link_data *link;
 	struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
-	struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
-
-	if (WARN_ON(ieee80211_vif_is_mld(&sdata->vif)))
-		success = false;
+	struct ieee80211_link_data_managed *ifmgd;
 
 	trace_api_chswitch_done(sdata, success);
+
+	rcu_read_lock();
+
+	link = rcu_dereference(sdata->link[link_id]);
+	if (WARN_ON(!link)) {
+		rcu_read_unlock();
+		return;
+	}
+
+	ifmgd = &link->u.mgd;
+
 	if (!success) {
 		sdata_info(sdata,
 			   "driver channel switch failed, disconnecting\n");
 		wiphy_work_queue(sdata->local->hw.wiphy,
-				 &ifmgd->csa_connection_drop_work);
+				 &sdata->u.mgd.csa_connection_drop_work);
 	} else {
 		wiphy_delayed_work_queue(sdata->local->hw.wiphy,
-					 &sdata->deflink.u.mgd.chswitch_work,
-					 0);
+					 &ifmgd->chswitch_work, 0);
 	}
+
+	rcu_read_unlock();
 }
 EXPORT_SYMBOL(ieee80211_chswitch_done);
 
Signature · 1 line
2.38.1
#2 lore raw

Re: [PATCH 01/15] wifi: mac80211: add support for mld in ieee80211_chswitch_done

Quoted 23 lines · On 8/27/2023 4:05 AM, [email protected] wrote:

From: Emmanuel Grumbach <[email protected]>

This allows to finalize the CSA per link.
In case the switch didn't work, tear down the MLD connection. Also pass the ieee80211_bss_conf to post_channel_switch to let the driver know which link completed the switch.

---
  .../net/wireless/intel/iwlegacy/4965-mac.c    |  2 +-
  drivers/net/wireless/intel/iwlegacy/common.c  |  2 +-
  .../net/wireless/intel/iwlwifi/dvm/mac80211.c |  6 ++--
  .../net/wireless/intel/iwlwifi/mvm/mac-ctxt.c |  2 +-
  .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 10 +++---
  drivers/net/wireless/intel/iwlwifi/mvm/mvm.h  |  3 +-
  .../wireless/intel/iwlwifi/mvm/time-event.c   |  2 +-
  drivers/net/wireless/ti/wlcore/event.c        |  2 +-
  drivers/net/wireless/ti/wlcore/main.c         |  6 ++--
  include/net/mac80211.h                        |  8 +++--
  net/mac80211/cfg.c                            | 35 ++++++++++---------
  net/mac80211/driver-ops.h                     |  6 ++--
  net/mac80211/mlme.c                           | 29 ++++++++++-----

...

Quoted 15 lines
include/net/mac80211.h +2 -1
index 7c707358d15c..67f54825110f 100644
@@ -4544,7 +4544,8 @@ struct ieee80211_ops {
  				  struct ieee80211_channel_switch *ch_switch);
 
  	int (*post_channel_switch)(struct ieee80211_hw *hw,
-				   struct ieee80211_vif *vif);
+				   struct ieee80211_vif *vif,
+				   struct ieee80211_bss_conf *link_conf);
  	void (*abort_channel_switch)(struct ieee80211_hw *hw,
  				     struct ieee80211_vif *vif);
  	void (*channel_switch_rx_beacon)(struct ieee80211_hw *hw,

include/net/mac80211.h void ieee80211_radar_detected(struct ieee80211_hw *hw); · line 6547

Quoted 5 lines
include/net/mac80211.h +2 -0
@@ -6542,11 +6543,14 @@ void ieee80211_radar_detected(struct ieee80211_hw *hw);
   * ieee80211_chswitch_done - Complete channel switch process
   * @vif: &struct ieee80211_vif pointer from the add_interface callback.
   * @success: make the channel switch successful or not
+ * @link_id: the link_id on which the switch was done. Ignored if success is
+ *	false.

I would not call this being ignored:
+ link = rcu_dereference(sdata->link[link_id]);
+ if (WARN_ON(!link)) {
+ rcu_read_unlock();
+ return;
+ }

Quoted 10 lines
include/net/mac80211.h +2 -1
   *
   * Complete the channel switch post-process: set the new operational channel
   * and wake up the suspended queues.
   */
-void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success);
+void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success,
+			     unsigned int link_id);
 
  /**
   * ieee80211_channel_switch_disconnect - disconnect due to channel switch error

...

Quoted 20 lines
net/mac80211/mlme.c +3 -2
index f93eb38ae0b8..ca6045f56b4b 100644
@@ -1773,7 +1773,7 @@ static void ieee80211_chswitch_post_beacon(struct ieee80211_link_data *link)
  	 */
  	link->u.mgd.beacon_crc_valid = false;
 
-	ret = drv_post_channel_switch(sdata);
+	ret = drv_post_channel_switch(link);
  	if (ret) {
  		sdata_info(sdata,
  			   "driver post channel switch failed, disconnecting\n");
@@ -1785,25 +1785,36 @@ static void ieee80211_chswitch_post_beacon(struct ieee80211_link_data *link)
  	cfg80211_ch_switch_notify(sdata->dev, &link->reserved_chandef, 0, 0);
  }
 
-void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success)
+void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success,
+			     unsigned int link_id)

net/mac80211/mlme.c static void ieee80211_chswitch_post_beacon(struct ieee80211_link_data *link) · line 1795

Quoted 10 lines
net/mac80211/mlme.c +2 -4
  {
+	struct ieee80211_link_data *link;
  	struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
-	struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
-
-	if (WARN_ON(ieee80211_vif_is_mld(&sdata->vif)))
-		success = false;
+	struct ieee80211_link_data_managed *ifmgd;
 
  	trace_api_chswitch_done(sdata, success);

no value in tracing the link_id?

Quoted 28 lines
net/mac80211/mlme.c +15 -3
+
+	rcu_read_lock();
+
+	link = rcu_dereference(sdata->link[link_id]);
+	if (WARN_ON(!link)) {
+		rcu_read_unlock();
+		return;
+	}
+
+	ifmgd = &link->u.mgd;
+
  	if (!success) {
  		sdata_info(sdata,
  			   "driver channel switch failed, disconnecting\n");
  		wiphy_work_queue(sdata->local->hw.wiphy,
-				 &ifmgd->csa_connection_drop_work);
+				 &sdata->u.mgd.csa_connection_drop_work);
  	} else {
  		wiphy_delayed_work_queue(sdata->local->hw.wiphy,
-					 &sdata->deflink.u.mgd.chswitch_work,
-					 0);
+					 &ifmgd->chswitch_work, 0);
  	}
+
+	rcu_read_unlock();
  }
  EXPORT_SYMBOL(ieee80211_chswitch_done);
 
#3 lore raw

Re: [PATCH 01/15] wifi: mac80211: add support for mld in ieee80211_chswitch_done

Quoted 44 lines · Jeff Johnson
Quoted 23 lines · On 8/27/2023 4:05 AM, [email protected] wrote:

From: Emmanuel Grumbach <[email protected]>

This allows to finalize the CSA per link.
In case the switch didn't work, tear down the MLD connection. Also pass the ieee80211_bss_conf to post_channel_switch to let the driver know which link completed the switch.

---
  .../net/wireless/intel/iwlegacy/4965-mac.c    |  2 +- drivers/net/wireless/intel/iwlegacy/common.c  |  2 +-

  .../net/wireless/intel/iwlwifi/dvm/mac80211.c |  6 ++--
  .../net/wireless/intel/iwlwifi/mvm/mac-ctxt.c |  2 +-
  .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 10 +++---

  drivers/net/wireless/intel/iwlwifi/mvm/mvm.h  |  3 +- .../wireless/intel/iwlwifi/mvm/time-event.c   |  2 +- drivers/net/wireless/ti/wlcore/event.c        |  2 +- drivers/net/wireless/ti/wlcore/main.c         |  6 ++-- include/net/mac80211.h                        |  8 +++-- net/mac80211/cfg.c                            | 35 ++++++++++--------- net/mac80211/driver-ops.h                     |  6 ++-- net/mac80211/mlme.c                           | 29 ++++++++++-----

...

Quoted 19 lines
include/net/mac80211.h +0 -0
index 7c707358d15c..67f54825110f 100644
@@ -4544,7 +4544,8 @@ struct ieee80211_ops {
                                   struct ieee80211_channel_switch *ch_switch);


        int (*post_channel_switch)(struct ieee80211_hw *hw,
-                                  struct ieee80211_vif *vif); +                                  struct ieee80211_vif *vif, +                                  struct ieee80211_bss_conf *link_conf); void (*abort_channel_switch)(struct ieee80211_hw *hw, struct ieee80211_vif *vif); void (*channel_switch_rx_beacon)(struct ieee80211_hw *hw,

include/net/mac80211.h +1 -0
@@ -6542,11 +6543,14 @@ void ieee80211_radar_detected(struct ieee80211_hw *hw);
    * ieee80211_chswitch_done - Complete channel switch process
    * @vif: &struct ieee80211_vif pointer from the add_interface callback.
    * @success: make the channel switch successful or not
+ * @link_id: the link_id on which the switch was done. Ignored if success is
Quoted 9 lines

include/net/mac80211.h void ieee80211_radar_detected(struct ieee80211_hw *hw); · line 6547

Quoted 1 line
include/net/mac80211.h +1 -0
+ *     false.

I would not call this being ignored:
+       link = rcu_dereference(sdata->link[link_id]); +       if (WARN_ON(!link)) {
+               rcu_read_unlock();
+               return;
+       }

Yeah - you're right. We don't need the link pointer in case success is false and yet we return here, I'll fix.

Quoted 37 lines
Quoted 10 lines
include/net/mac80211.h +2 -1
    *
    * Complete the channel switch post-process: set the new operational channel
    * and wake up the suspended queues.
    */
-void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success);
+void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success,
+                            unsigned int link_id);


  /**
   * ieee80211_channel_switch_disconnect - disconnect due to channel switch error

...

Quoted 26 lines
net/mac80211/mlme.c +0 -0
index f93eb38ae0b8..ca6045f56b4b 100644
@@ -1773,7 +1773,7 @@ static void ieee80211_chswitch_post_beacon(struct ieee80211_link_data
 *link)
          */
         link->u.mgd.beacon_crc_valid = false;


-       ret = drv_post_channel_switch(sdata);
+       ret = drv_post_channel_switch(link);
        if (ret) {
                sdata_info(sdata,
                           "driver post channel switch failed, disconnecting\n");

net/mac80211/mlme.c +0 -0
@@ -1785,25 +1785,36 @@ static void ieee80211_chswitch_post_beacon(struct ieee80211_link_data
 *link)
         cfg80211_ch_switch_notify(sdata->dev, &link->reserved_chandef, 0, 0);
   }

net/mac80211/mlme.c +2 -1
-void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success)
+void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success,
+                            unsigned int link_id)

  {
+       struct ieee80211_link_data *link;
        struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); -       struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;

Quoted 8 lines
Quoted 6 lines

-
-       if (WARN_ON(ieee80211_vif_is_mld(&sdata->vif))) -               success = false;
+       struct ieee80211_link_data_managed *ifmgd;
        trace_api_chswitch_done(sdata, success);

no value in tracing the link_id?

I can add it.

Quoted 21 lines
Quoted 21 lines
net/mac80211/mlme.c +11 -0
+
+       rcu_read_lock();
+
+       link = rcu_dereference(sdata->link[link_id]);
+       if (WARN_ON(!link)) {
+               rcu_read_unlock();
+               return;
+       }
+
+       ifmgd = &link->u.mgd;
+

        if (!success) {
                sdata_info(sdata,
                           "driver channel switch failed, disconnecting\n"); wiphy_work_queue(sdata->local->hw.wiphy,
-                                &ifmgd->csa_connection_drop_work); +                                &sdata->u.mgd.csa_connection_drop_work); } else {
                wiphy_delayed_work_queue(sdata->local->hw.wiphy, -                                        &sdata->deflink.u.mgd.chswitch_work,

Quoted 9 lines
Quoted 8 lines

-                                        0);
+                                        &ifmgd->chswitch_work, 0); }
+
+       rcu_read_unlock();
  }
  EXPORT_SYMBOL(ieee80211_chswitch_done);

Gregory / Johannes, I'll send a patch internally to fix the issues raised here and you'll squash before resending?

#4 lore raw

PATCH 2/15 wifi: cfg80211: fix off-by-one in element defrag

In reply to [email protected]

From: Johannes Berg <[email protected]>

If a fragment is the last element, it's erroneously not accepted. Fix that.

Fixes f837a653a097 ("wifi: cfg80211: add element defragmentation helper")
---
 net/wireless/scan.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/wireless/scan.c +2 -2
index 0cf1ce7b6934..19516073c6d5 100644
@@ -2354,8 +2354,8 @@ ssize_t cfg80211_defragment_element(const struct element *elem, const u8 *ies,
 
 	/* elem might be invalid after the memmove */
 	next = (void *)(elem->data + elem->datalen);
-
 	elem_datalen = elem->datalen;
+
 	if (elem->id == WLAN_EID_EXTENSION) {
 		copied = elem->datalen - 1;
 		if (copied > data_len)
@@ -2376,7 +2376,7 @@ ssize_t cfg80211_defragment_element(const struct element *elem, const u8 *ies,
 
 	for (elem = next;
 	     elem->data < ies + ieslen &&
-		elem->data + elem->datalen < ies + ieslen;
+		elem->data + elem->datalen <= ies + ieslen;
 	     elem = next) {
 		/* elem might be invalid after the memmove */
 		next = (void *)(elem->data + elem->datalen);
Signature · 1 line
2.38.1
#5 lore raw

PATCH 3/15 wifi: cfg80211: add first kunit tests, for element defrag

In reply to [email protected]

From: Johannes Berg <[email protected]>

Add a couple of tests for element defragmentation, to see that the function works correctly.

---
 net/wireless/Kconfig               |  11 ++
 net/wireless/Makefile              |   1 +
 net/wireless/tests/Makefile        |   3 +
 net/wireless/tests/fragmentation.c | 157 +++++++++++++++++++++++++++++
 net/wireless/tests/module.c        |  10 ++
 5 files changed, 182 insertions(+)
 create mode 100644 net/wireless/tests/Makefile
 create mode 100644 net/wireless/tests/fragmentation.c
 create mode 100644 net/wireless/tests/module.c
net/wireless/Kconfig +11 -0
index f620acd2a0f5..a9ac85e09af3 100644
@@ -201,6 +201,17 @@ config CFG80211_WEXT_EXPORT
 	  Drivers should select this option if they require cfg80211's
 	  wext compatibility symbols to be exported.
 
+config CFG80211_KUNIT_TEST
+	tristate "KUnit tests for cfg80211" if !KUNIT_ALL_TESTS
+	depends on KUNIT
+	depends on CFG80211
+	default KUNIT_ALL_TESTS
+	depends on !KERNEL_6_2
+	help
+	  Enable this option to test cfg80211 functions with kunit.
+
+	  If unsure, say N.
+
 endif # CFG80211
 
 config LIB80211
net/wireless/Makefile +1 -0
index 527ae669f6f7..089c841528c8 100644
@@ -4,6 +4,7 @@ obj-$(CONFIG_LIB80211) += lib80211.o
 obj-$(CONFIG_LIB80211_CRYPT_WEP) += lib80211_crypt_wep.o
 obj-$(CONFIG_LIB80211_CRYPT_CCMP) += lib80211_crypt_ccmp.o
 obj-$(CONFIG_LIB80211_CRYPT_TKIP) += lib80211_crypt_tkip.o
+obj-y += tests/
 
 obj-$(CONFIG_WEXT_CORE) += wext-core.o
 obj-$(CONFIG_WEXT_PROC) += wext-proc.o
net/wireless/tests/Makefile new file +3 -0
new file mode 100644
index 000000000000..fa8e297bbc5e
@@ -0,0 +1,3 @@
+cfg80211-tests-y += module.o fragmentation.o
+
+obj-$(CONFIG_CFG80211_KUNIT_TEST) += cfg80211-tests.o
net/wireless/tests/fragmentation.c new file +157 -0

157 lines not on this page · raw message

net/wireless/tests/module.c new file +10 -0
new file mode 100644
index 000000000000..9ff7b2c12312
@@ -0,0 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * This is just module boilerplate for the cfg80211 kunit module.
+ *
+ * Copyright (C) 2023 Intel Corporation
+ */
+#include <linux/module.h>
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("tests for cfg80211");
Signature · 1 line
2.38.1
#6 lore raw

PATCH 4/15 wifi: mac80211: add an element parsing unit test

In reply to [email protected]

From: Johannes Berg <[email protected]>

Add a unit test for the parsing of a fragmented sta profile sub-element inside a fragmented multi-link element.

---
 net/mac80211/Kconfig        |  11 ++++
 net/mac80211/Makefile       |   2 +
 net/mac80211/tests/Makefile |   3 ++
 net/mac80211/tests/elems.c  | 101 ++++++++++++++++++++++++++++++++++++
 net/mac80211/tests/module.c |  10 ++++
 net/mac80211/util.c         |   3 ++
 6 files changed, 130 insertions(+)
 create mode 100644 net/mac80211/tests/Makefile
 create mode 100644 net/mac80211/tests/elems.c
 create mode 100644 net/mac80211/tests/module.c
net/mac80211/Kconfig +11 -0
index 51ec8256b7fa..037ab74f5ade 100644
@@ -57,6 +57,17 @@ endif
 comment "Some wireless drivers require a rate control algorithm"
 	depends on MAC80211 && MAC80211_HAS_RC=n
 
+config MAC80211_KUNIT_TEST
+	tristate "KUnit tests for mac80211" if !KUNIT_ALL_TESTS
+	depends on KUNIT
+	depends on MAC80211
+	default KUNIT_ALL_TESTS
+	depends on !KERNEL_6_2
+	help
+	  Enable this option to test mac80211 internals with kunit.
+
+	  If unsure, say N.
+
 config MAC80211_MESH
 	bool "Enable mac80211 mesh networking support"
 	depends on MAC80211
net/mac80211/Makefile +2 -0
index b8de44da1fb8..c9eb52768133 100644
@@ -65,4 +65,6 @@ rc80211_minstrel-$(CONFIG_MAC80211_DEBUGFS) += \
 
 mac80211-$(CONFIG_MAC80211_RC_MINSTREL) += $(rc80211_minstrel-y)
 
+obj-y += tests/
+
 ccflags-y += -DDEBUG
net/mac80211/tests/Makefile new file +3 -0
new file mode 100644
index 000000000000..4814584f8a14
@@ -0,0 +1,3 @@
+mac80211-tests-y += module.o elems.o
+
+obj-$(CONFIG_MAC80211_KUNIT_TEST) += mac80211-tests.o
net/mac80211/tests/elems.c new file +101 -0

101 lines not on this page · raw message

net/mac80211/tests/module.c new file +10 -0
new file mode 100644
index 000000000000..9d05f2943935
@@ -0,0 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * This is just module boilerplate for the mac80211 kunit module.
+ *
+ * Copyright (C) 2023 Intel Corporation
+ */
+#include <linux/module.h>
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("tests for mac80211");
net/mac80211/util.c +3 -0
index 8a6917cf63cf..d430093d14af 100644
@@ -24,6 +24,7 @@
 #include <net/net_namespace.h>
 #include <net/cfg80211.h>
 #include <net/rtnetlink.h>
+#include <kunit/visibility.h>
 
 #include "ieee80211_i.h"
 #include "driver-ops.h"
@@ -1654,6 +1655,7 @@ ieee802_11_parse_elems_full(struct ieee80211_elems_parse_params *params)
 
 	return elems;
 }
+EXPORT_SYMBOL_IF_KUNIT(ieee802_11_parse_elems_full);
 
 void ieee80211_regulatory_limit_wmm_params(struct ieee80211_sub_if_data *sdata,
 					   struct ieee80211_tx_queue_params
@@ -5146,3 +5148,4 @@ void ieee80211_fragment_element(struct sk_buff *skb, u8 *len_pos, u8 frag_id)
 
 	*len_pos = elem_len;
 }
+EXPORT_SYMBOL_IF_KUNIT(ieee80211_fragment_element);
Signature · 1 line
2.38.1
#7 lore raw

Re: [PATCH 04/15] wifi: mac80211: add an element parsing unit test

Quoted 27 lines · [email protected] writes:

From: Johannes Berg <[email protected]>

Add a unit test for the parsing of a fragmented sta profile sub-element inside a fragmented multi-link element.

---
 net/mac80211/Kconfig        |  11 ++++
 net/mac80211/Makefile       |   2 +
 net/mac80211/tests/Makefile |   3 ++
 net/mac80211/tests/elems.c  | 101 ++++++++++++++++++++++++++++++++++++
 net/mac80211/tests/module.c |  10 ++++
 net/mac80211/util.c         |   3 ++
 6 files changed, 130 insertions(+)
 create mode 100644 net/mac80211/tests/Makefile
 create mode 100644 net/mac80211/tests/elems.c
 create mode 100644 net/mac80211/tests/module.c
net/mac80211/Kconfig +0 -0
index 51ec8256b7fa..037ab74f5ade 100644
@@ -57,6 +57,17 @@ endif
 comment "Some wireless drivers require a rate control algorithm"
 	depends on MAC80211 && MAC80211_HAS_RC=n
 

net/mac80211/Kconfig endif · line 69

Quoted 10 lines
net/mac80211/Kconfig +10 -0
+config MAC80211_KUNIT_TEST
+	tristate "KUnit tests for mac80211" if !KUNIT_ALL_TESTS
+	depends on KUNIT
+	depends on MAC80211
+	default KUNIT_ALL_TESTS
+	depends on !KERNEL_6_2
+	help
+	  Enable this option to test mac80211 internals with kunit.
+
+	  If unsure, say N.

Just wanted to say that this is great. Hopefully we will have more tests in the future.

But what's KERNEL_6_2? I tried to grep for that in wireless-next but didn't find anything.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#8 lore raw

PATCH 5/15 wifi: cfg80211: add ieee80211_fragment_element to public API

In reply to [email protected]

From: Benjamin Berg <[email protected]>

This function will be used by the kunit tests within cfg80211. As it is generally useful, move it from mac80211 to cfg80211.

---
 include/net/cfg80211.h     | 12 ++++++++++++
 net/mac80211/ieee80211_i.h |  2 --
 net/mac80211/util.c        | 29 -----------------------------
 net/wireless/util.c        | 29 +++++++++++++++++++++++++++++
 4 files changed, 41 insertions(+), 31 deletions(-)
include/net/cfg80211.h +12 -0
index 3a4b684f89bf..630db8601ee5 100644
@@ -8807,6 +8807,18 @@ static inline size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
 	return ieee80211_ie_split_ric(ies, ielen, ids, n_ids, NULL, 0, offset);
 }
 
+/**
+ * ieee80211_fragment_element - fragment the last element in skb
+ * @skb: The skbuf that the element was added to
+ * @len_pos: Pointer to length of the element to fragment
+ * @frag_id: The element ID to use for fragments
+ *
+ * This function fragments all data after @len_pos, adding fragmentation
+ * elements with the given ID as appropriate. The SKB will grow in size
+ * accordingly.
+ */
+void ieee80211_fragment_element(struct sk_buff *skb, u8 *len_pos, u8 frag_id);
+
 /**
  * cfg80211_report_wowlan_wakeup - report wakeup from WoWLAN
  * @wdev: the wireless device reporting the wakeup
net/mac80211/ieee80211_i.h +0 -2
index 06bd406846d2..8afeb1398b33 100644
@@ -2333,8 +2333,6 @@ ieee802_11_parse_elems(const u8 *start, size_t len, bool action,
 	return ieee802_11_parse_elems_crc(start, len, action, 0, 0, bss);
 }
 
-void ieee80211_fragment_element(struct sk_buff *skb, u8 *len_pos, u8 frag_id);
-
 extern const int ieee802_1d_to_ac[8];
 
 static inline int ieee80211_ac_from_tid(int tid)
net/mac80211/util.c +0 -29
index d430093d14af..07fbd04b362c 100644
@@ -5120,32 +5120,3 @@ u8 *ieee80211_ie_build_eht_cap(u8 *pos,
 
 	return pos;
 }
-
-void ieee80211_fragment_element(struct sk_buff *skb, u8 *len_pos, u8 frag_id)
-{
-	unsigned int elem_len;
-
-	if (!len_pos)
-		return;
-
-	elem_len = skb->data + skb->len - len_pos - 1;
-
-	while (elem_len > 255) {
-		/* this one is 255 */
-		*len_pos = 255;
-		/* remaining data gets smaller */
-		elem_len -= 255;
-		/* make space for the fragment ID/len in SKB */
-		skb_put(skb, 2);
-		/* shift back the remaining data to place fragment ID/len */
-		memmove(len_pos + 255 + 3, len_pos + 255 + 1, elem_len);
-		/* place the fragment ID */
-		len_pos += 255 + 1;
-		*len_pos = frag_id;
-		/* and point to fragment length to update later */
-		len_pos++;
-	}
-
-	*len_pos = elem_len;
-}
-EXPORT_SYMBOL_IF_KUNIT(ieee80211_fragment_element);
net/wireless/util.c +29 -0
index 1783ab9d57a3..6a43f517727f 100644
@@ -1972,6 +1972,35 @@ size_t ieee80211_ie_split_ric(const u8 *ies, size_t ielen,
 }
 EXPORT_SYMBOL(ieee80211_ie_split_ric);
 
+void ieee80211_fragment_element(struct sk_buff *skb, u8 *len_pos, u8 frag_id)
+{
+	unsigned int elem_len;
+
+	if (!len_pos)
+		return;
+
+	elem_len = skb->data + skb->len - len_pos - 1;
+
+	while (elem_len > 255) {
+		/* this one is 255 */
+		*len_pos = 255;
+		/* remaining data gets smaller */
+		elem_len -= 255;
+		/* make space for the fragment ID/len in SKB */
+		skb_put(skb, 2);
+		/* shift back the remaining data to place fragment ID/len */
+		memmove(len_pos + 255 + 3, len_pos + 255 + 1, elem_len);
+		/* place the fragment ID */
+		len_pos += 255 + 1;
+		*len_pos = frag_id;
+		/* and point to fragment length to update later */
+		len_pos++;
+	}
+
+	*len_pos = elem_len;
+}
+EXPORT_SYMBOL(ieee80211_fragment_element);
+
 bool ieee80211_operating_class_to_band(u8 operating_class,
 				       enum nl80211_band *band)
 {
Signature · 1 line
2.38.1
#9 lore raw

PATCH 6/15 wifi: mac80211: add more warnings about inserting sta info

In reply to [email protected]

From: Benjamin Berg <[email protected]>

The sta info needs to be inserted before its links may be modified. Add a few warnings to prevent accidental usage of these functions.

---
 net/mac80211/sta_info.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
net/mac80211/sta_info.c +6 -2
index 7751f8ba960e..86f8bb878dbd 100644
@@ -2874,6 +2874,8 @@ int ieee80211_sta_allocate_link(struct sta_info *sta, unsigned int link_id)
 
 	lockdep_assert_held(&sdata->local->sta_mtx);
 
+	WARN_ON(!test_sta_flag(sta, WLAN_STA_INSERTED));
+
 	/* must represent an MLD from the start */
 	if (WARN_ON(!sta->sta.valid_links))
 		return -EINVAL;
@@ -2903,6 +2905,8 @@ void ieee80211_sta_free_link(struct sta_info *sta, unsigned int link_id)
 {
 	lockdep_assert_held(&sta->sdata->local->sta_mtx);
 
+	WARN_ON(!test_sta_flag(sta, WLAN_STA_INSERTED));
+
 	sta_remove_link(sta, link_id, false);
 }
 
@@ -2930,7 +2934,7 @@ int ieee80211_sta_activate_link(struct sta_info *sta, unsigned int link_id)
 
 	sta->sta.valid_links = new_links;
 
-	if (!test_sta_flag(sta, WLAN_STA_INSERTED))
+	if (WARN_ON(!test_sta_flag(sta, WLAN_STA_INSERTED)))
 		goto hash;
 
 	ieee80211_recalc_min_chandef(sdata, link_id);
@@ -2963,7 +2967,7 @@ void ieee80211_sta_remove_link(struct sta_info *sta, unsigned int link_id)
 
 	sta->sta.valid_links &= ~BIT(link_id);
 
-	if (test_sta_flag(sta, WLAN_STA_INSERTED))
+	if (!WARN_ON(!test_sta_flag(sta, WLAN_STA_INSERTED)))
 		drv_change_sta_links(sdata->local, sdata, &sta->sta,
 				     old_links, sta->sta.valid_links);
 
Signature · 1 line
2.38.1
#10 lore raw

PATCH 7/15 wifi: mac80211: remove unnecessary struct forward declaration

In reply to [email protected]

From: Johannes Berg <[email protected]>

This just causes kernel-doc to complain at this spot, but isn't actually needed anyway, so remove it.

---
 net/mac80211/ieee80211_i.h | 1 -
 1 file changed, 1 deletion(-)
net/mac80211/ieee80211_i.h +0 -1
index 8afeb1398b33..a260df25f592 100644
@@ -619,7 +619,6 @@ struct ieee80211_if_ocb {
  * vendor-specific mesh synchronization
  *
  */
-struct ieee802_11_elems;
 struct ieee80211_mesh_sync_ops {
 	void (*rx_bcn_presp)(struct ieee80211_sub_if_data *sdata, u16 stype,
 			     struct ieee80211_mgmt *mgmt, unsigned int len,
Signature · 1 line
2.38.1
#11 lore raw

PATCH 8/15 wifi: mac80211: fix various kernel-doc issues

In reply to [email protected]

From: Johannes Berg <[email protected]>

There are various kernel-doc issues here, fix them.

---
 net/mac80211/ieee80211_i.h | 18 +++++++++++-------
 net/mac80211/sta_info.h    |  4 +---
 2 files changed, 12 insertions(+), 10 deletions(-)
net/mac80211/ieee80211_i.h +11 -7
index a260df25f592..5381b9b959e7 100644
@@ -618,6 +618,8 @@ struct ieee80211_if_ocb {
  * these declarations define the interface, which enables
  * vendor-specific mesh synchronization
  *
+ * @rx_bcn_presp: beacon/probe response was received
+ * @adjust_tsf: TSF adjustment method
  */
 struct ieee80211_mesh_sync_ops {
 	void (*rx_bcn_presp)(struct ieee80211_sub_if_data *sdata, u16 stype,
@@ -858,12 +860,13 @@ enum txq_info_flags {
  * struct txq_info - per tid queue
  *
  * @tin: contains packets split into multiple flows
- * @def_flow: used as a fallback flow when a packet destined to @tin hashes to
- *	a fq_flow which is already owned by a different tin
- * @def_cvars: codel vars for @def_flow
+ * @def_cvars: codel vars for the @tin's default_flow
+ * @cstats: code statistics for this queue
  * @frags: used to keep fragments created after dequeue
  * @schedule_order: used with ieee80211_local->active_txqs
  * @schedule_round: counter to prevent infinite loops on TXQ scheduling
+ * @flags: TXQ flags from &enum txq_info_flags
+ * @txq: the driver visible part
  */
 struct txq_info {
 	struct fq_tin tin;
@@ -892,7 +895,8 @@ struct ieee80211_if_mntr {
  * struct ieee80211_if_nan - NAN state
  *
  * @conf: current NAN configuration
- * @func_ids: a bitmap of available instance_id's
+ * @func_lock: lock for @func_inst_ids
+ * @function_inst_ids: a bitmap of available instance_id's
  */
 struct ieee80211_if_nan {
 	struct cfg80211_nan_conf conf;
@@ -1253,7 +1257,7 @@ struct tpt_led_trigger {
 #endif
 
 /**
- * mac80211 scan flags - currently active scan mode
+ * enum mac80211_scan_flags - currently active scan mode
  *
  * @SCAN_SW_SCANNING: We're currently in the process of scanning but may as
  *	well be on the operating channel
@@ -1271,7 +1275,7 @@ struct tpt_led_trigger {
  *	and could send a probe request after receiving a beacon.
  * @SCAN_BEACON_DONE: Beacon received, we can now send a probe request
  */
-enum {
+enum mac80211_scan_flags {
 	SCAN_SW_SCANNING,
 	SCAN_HW_SCANNING,
 	SCAN_ONCHANNEL_SCANNING,
@@ -2204,7 +2208,7 @@ void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
  *	flags from &enum ieee80211_conn_flags.
  * @bssid: the currently connected bssid (for reporting)
  * @csa_ie: parsed 802.11 csa elements on count, mode, chandef and mesh ttl.
-	All of them will be filled with if success only.
+ *	All of them will be filled with if success only.
  * Return: 0 on success, <0 on error and >0 if there is nothing to parse.
  */
 int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
net/mac80211/sta_info.h +1 -3
index 195b563132d6..bcf8472e0964 100644
@@ -3,7 +3,7 @@
  * Copyright 2002-2005, Devicescape Software, Inc.
  * Copyright 2013-2014  Intel Mobile Communications GmbH
  * Copyright(c) 2015-2017 Intel Deutschland GmbH
- * Copyright(c) 2020-2022 Intel Corporation
+ * Copyright(c) 2020-2023 Intel Corporation
  */
 
 #ifndef STA_INFO_H
@@ -618,8 +618,6 @@ struct link_sta_info {
  * @sta: station information we share with the driver
  * @sta_state: duplicates information about station state (for debug)
  * @rcu_head: RCU head used for freeing this station struct
- * @cur_max_bandwidth: maximum bandwidth to use for TX to the station,
- *	taken from HT/VHT capabilities or VHT operating mode notification
  * @cparams: CoDel parameters for this station.
  * @reserved_tid: reserved TID (if any, otherwise IEEE80211_TID_UNRESERVED)
  * @amsdu_mesh_control: track the mesh A-MSDU format used by the peer:
Signature · 1 line
2.38.1
#12 lore raw

PATCH 9/15 wifi: cfg80211: reg: fix various kernel-doc issues

In reply to [email protected]

From: Johannes Berg <[email protected]>

Clean up the kernel-doc comments in reg.h.

---
 net/wireless/reg.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
net/wireless/reg.h +8 -8
index f3707f729024..a703e53c23ee 100644
@@ -5,7 +5,7 @@
 
 /*
  * Copyright 2008-2011	Luis R. Rodriguez <[email protected]>
- * Copyright (C) 2019 Intel Corporation
+ * Copyright (C) 2019, 2023 Intel Corporation
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -133,7 +133,7 @@ void regulatory_hint_disconnect(void);
 /**
  * cfg80211_get_unii - get the U-NII band for the frequency
  * @freq: the frequency for which we want to get the UNII band.
-
+ *
  * Get a value specifying the U-NII band frequency belongs to.
  * U-NII bands are defined by the FCC in C.F.R 47 part 15.
  *
@@ -156,11 +156,11 @@ bool regulatory_indoor_allowed(void);
 
 /**
  * regulatory_propagate_dfs_state - Propagate DFS channel state to other wiphys
- * @wiphy - wiphy on which radar is detected and the event will be propagated
+ * @wiphy: wiphy on which radar is detected and the event will be propagated
  *	to other available wiphys having the same DFS domain
- * @chandef - Channel definition of radar detected channel
- * @dfs_state - DFS channel state to be set
- * @event - Type of radar event which triggered this DFS state change
+ * @chandef: Channel definition of radar detected channel
+ * @dfs_state: DFS channel state to be set
+ * @event: Type of radar event which triggered this DFS state change
  *
  * This function should be called with rtnl lock held.
  */
@@ -171,8 +171,8 @@ void regulatory_propagate_dfs_state(struct wiphy *wiphy,
 
 /**
  * reg_dfs_domain_same - Checks if both wiphy have same DFS domain configured
- * @wiphy1 - wiphy it's dfs_region to be checked against that of wiphy2
- * @wiphy2 - wiphy it's dfs_region to be checked against that of wiphy1
+ * @wiphy1: wiphy it's dfs_region to be checked against that of wiphy2
+ * @wiphy2: wiphy it's dfs_region to be checked against that of wiphy1
  */
 bool reg_dfs_domain_same(struct wiphy *wiphy1, struct wiphy *wiphy2);
 
Signature · 1 line
2.38.1
#13 lore raw

PATCH 10/15 wifi: mac80211_hwsim: clean up kernel-doc

In reply to [email protected]

From: Johannes Berg <[email protected]>

Clean up kernel-doc in hwsim's header file.

---
 drivers/net/wireless/virtual/mac80211_hwsim.h | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/net/wireless/virtual/mac80211_hwsim.h +9 -10
index 92126f02c58f..4676cdaf4cfd 100644
@@ -3,7 +3,7 @@
  * mac80211_hwsim - software simulator of 802.11 radio(s) for mac80211
  * Copyright (c) 2008, Jouni Malinen <[email protected]>
  * Copyright (c) 2011, Javier Lopez <[email protected]>
- * Copyright (C) 2020, 2022 Intel Corporation
+ * Copyright (C) 2020, 2022-2023 Intel Corporation
  */
 
 #ifndef __MAC80211_HWSIM_H
@@ -86,7 +86,7 @@ enum hwsim_tx_control_flags {
  *	with %HWSIM_CMD_REPORT_PMSR.
  * @__HWSIM_CMD_MAX: enum limit
  */
-enum {
+enum hwsim_commands {
 	HWSIM_CMD_UNSPEC,
 	HWSIM_CMD_REGISTER,
 	HWSIM_CMD_FRAME,
@@ -117,11 +117,11 @@ enum {
  *	the frame was broadcasted from
  * @HWSIM_ATTR_FRAME: Data array
  * @HWSIM_ATTR_FLAGS: mac80211 transmission flags, used to process
-	properly the frame at user space
+ *	properly the frame at user space
  * @HWSIM_ATTR_RX_RATE: estimated rx rate index for this frame at user
-	space
+ *	space
  * @HWSIM_ATTR_SIGNAL: estimated RX signal for this frame at user
-	space
+ *	space
  * @HWSIM_ATTR_TX_INFO: ieee80211_tx_rate array
  * @HWSIM_ATTR_COOKIE: sk_buff cookie to identify the frame
  * @HWSIM_ATTR_CHANNELS: u32 attribute used with the %HWSIM_CMD_CREATE_RADIO
@@ -140,6 +140,7 @@ enum {
  *	command to force radio removal when process that created the radio dies
  * @HWSIM_ATTR_RADIO_NAME: Name of radio, e.g. phy666
  * @HWSIM_ATTR_NO_VIF:  Do not create vif (wlanX) when creating radio.
+ * @HWSIM_ATTR_PAD: padding attribute for 64-bit values, ignore
  * @HWSIM_ATTR_FREQ: Frequency at which packet is transmitted or received.
  * @HWSIM_ATTR_TX_INFO_FLAGS: additional flags for corresponding
  *	rates of %HWSIM_ATTR_TX_INFO
@@ -156,9 +157,7 @@ enum {
  *	to provide peer measurement result (nl80211_peer_measurement_attrs)
  * @__HWSIM_ATTR_MAX: enum limit
  */
-
-
-enum {
+enum hwsim_attrs {
 	HWSIM_ATTR_UNSPEC,
 	HWSIM_ATTR_ADDR_RECEIVER,
 	HWSIM_ATTR_ADDR_TRANSMITTER,
@@ -259,7 +258,7 @@ enum hwsim_tx_rate_flags {
  * struct hwsim_tx_rate - rate selection/status
  *
  * @idx: rate index to attempt to send with
- * @count: number of tries in this rate before going to the next rate
+ * @flags: the rate flags according to &enum hwsim_tx_rate_flags
  *
  * A value of -1 for @idx indicates an invalid rate and, if used
  * in an array of retry rates, that no more rates should be tried.
@@ -287,7 +286,7 @@ struct hwsim_tx_rate_flag {
  * @HWSIM_VQ_RX: receive frames and transmission info reports
  * @HWSIM_NUM_VQS: enum limit
  */
-enum {
+enum hwsim_vqs {
 	HWSIM_VQ_TX,
 	HWSIM_VQ_RX,
 	HWSIM_NUM_VQS,
Signature · 1 line
2.38.1
#14 lore raw

PATCH 11/15 wifi: mac80211: fix # of MSDU in A-MSDU calculation

In reply to [email protected]

From: Johannes Berg <[email protected]>

During my refactoring I wanted to get rid of the switch, but replaced it with the wrong calculation. Fix that.

Fixes 175ad2ec89fe ("wifi: mac80211: limit A-MSDU subframes for client too")
---
 net/mac80211/sta_info.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/sta_info.c +1 -1
index 86f8bb878dbd..bf249e77acad 100644
@@ -2994,7 +2994,7 @@ void ieee80211_sta_set_max_amsdu_subframes(struct sta_info *sta,
 				   WLAN_EXT_CAPA9_MAX_MSDU_IN_AMSDU_MSB) << 1;
 
 	if (val)
-		sta->sta.max_amsdu_subframes = 4 << val;
+		sta->sta.max_amsdu_subframes = 4 << (4 - val);
 }
 
 #ifdef CONFIG_LOCKDEP
Signature · 1 line
2.38.1
#15 lore raw

PATCH 12/15 wifi: mac80211: Print local link address during authentication

In reply to [email protected]

From: Ilan Peer <[email protected]>

To ease debugging, mostly in cases that authentication fails.

---
 net/mac80211/mlme.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
net/mac80211/mlme.c +14 -2
index ca6045f56b4b..a93fbed69a70 100644
@@ -7085,6 +7085,7 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
 	struct ieee80211_local *local = sdata->local;
 	struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
 	struct ieee80211_mgd_auth_data *auth_data;
+	struct ieee80211_link_data *link;
 	u16 auth_alg;
 	int err;
 	bool cont_auth;
@@ -7208,8 +7209,6 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
 					    false);
 	}
 
-	sdata_info(sdata, "authenticate with %pM\n", auth_data->ap_addr);
-
 	/* needed for transmitting the auth frame(s) properly */
 	memcpy(sdata->vif.cfg.ap_addr, auth_data->ap_addr, ETH_ALEN);
 
@@ -7218,6 +7217,19 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
 	if (err)
 		goto err_clear;
 
+	if (req->link_id > 0)
+		link = sdata_dereference(sdata->link[req->link_id], sdata);
+	else
+		link = sdata_dereference(sdata->link[0], sdata);
+
+	if (WARN_ON(!link)) {
+		err = -ENOLINK;
+		goto err_clear;
+	}
+
+	sdata_info(sdata, "authenticate with %pM (local address=%pM)\n",
+		   auth_data->ap_addr, link->conf->addr);
+
 	err = ieee80211_auth(sdata);
 	if (err) {
 		sta_info_destroy_addr(sdata, auth_data->ap_addr);
Signature · 1 line
2.38.1
#16 lore raw

Re: [PATCH 12/15] wifi: mac80211: Print local link address during authentication

On 8/27/2023 7:05 PM, [email protected] wrote:
[...]

net/mac80211/mlme.c int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, · line 7224

Quoted 9 lines
net/mac80211/mlme.c +5 -0
@@ -7218,6 +7217,19 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,
  	if (err)
  		goto err_clear;
 
+	if (req->link_id > 0)
+		link = sdata_dereference(sdata->link[req->link_id], sdata);
+	else
+		link = sdata_dereference(sdata->link[0], sdata);
+

req->link_id >= 0 means MLD.
For non-MLD, req->link_id < 0, is it better to use sdata->deflink for non-MLD? Is sdata->link[0] always pointer to sdata->deflink for non-MLD?

It has a comment for deflink of struct ieee80211_sta, but no comment for deflink
of struct ieee80211_sub_if_data.

Quoted 11 lines
net/mac80211/mlme.c +8 -0
+	if (WARN_ON(!link)) {
+		err = -ENOLINK;
+		goto err_clear;
+	}
+
+	sdata_info(sdata, "authenticate with %pM (local address=%pM)\n",
+		   auth_data->ap_addr, link->conf->addr);
+
  	err = ieee80211_auth(sdata);
  	if (err) {
  		sta_info_destroy_addr(sdata, auth_data->ap_addr);
#17 lore raw

PATCH 13/15 wifi: mac80211: take MBSSID/EHT data also from probe resp

In reply to [email protected]

From: Johannes Berg <[email protected]>

The code that sets up the assoc link will currently take the BSS element data from the beacon only. This is correct for some of the data, notably the timing and the "have_beacon", but all the data about MBSSID and EHT really doesn't need to be taken from there, and if the EHT puncturing is misconfigured on the AP but we didn't receive a beacon yet, this causes us to connect but immediately disconnect upon receiving the first beacon, rather than connecting without EHT in the first place.

Change the code to take MBSSID and EHT data also from the probe response, for a better picture of what the BSS capabilities are and to avoid that EHT puncturing problem.

---
 net/mac80211/mlme.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)
net/mac80211/mlme.c +15 -10
index a93fbed69a70..8abd4301f278 100644
@@ -7262,7 +7262,7 @@ ieee80211_setup_assoc_link(struct ieee80211_sub_if_data *sdata,
 			   unsigned int link_id)
 {
 	struct ieee80211_local *local = sdata->local;
-	const struct cfg80211_bss_ies *beacon_ies;
+	const struct cfg80211_bss_ies *bss_ies;
 	struct ieee80211_supported_band *sband;
 	const struct element *ht_elem, *vht_elem;
 	struct ieee80211_link_data *link;
@@ -7337,32 +7337,37 @@ ieee80211_setup_assoc_link(struct ieee80211_sub_if_data *sdata,
 	link->conf->eht_puncturing = 0;
 
 	rcu_read_lock();
-	beacon_ies = rcu_dereference(cbss->beacon_ies);
-	if (beacon_ies) {
-		const struct ieee80211_eht_operation *eht_oper;
-		const struct element *elem;
+	bss_ies = rcu_dereference(cbss->beacon_ies);
+	if (bss_ies) {
 		u8 dtim_count = 0;
 
-		ieee80211_get_dtim(beacon_ies, &dtim_count,
+		ieee80211_get_dtim(bss_ies, &dtim_count,
 				   &link->u.mgd.dtim_period);
 
 		sdata->deflink.u.mgd.have_beacon = true;
 
 		if (ieee80211_hw_check(&local->hw, TIMING_BEACON_ONLY)) {
-			link->conf->sync_tsf = beacon_ies->tsf;
+			link->conf->sync_tsf = bss_ies->tsf;
 			link->conf->sync_device_ts = bss->device_ts_beacon;
 			link->conf->sync_dtim_count = dtim_count;
 		}
+	} else {
+		bss_ies = rcu_dereference(cbss->ies);
+	}
+
+	if (bss_ies) {
+		const struct ieee80211_eht_operation *eht_oper;
+		const struct element *elem;
 
 		elem = cfg80211_find_ext_elem(WLAN_EID_EXT_MULTIPLE_BSSID_CONFIGURATION,
-					      beacon_ies->data, beacon_ies->len);
+					      bss_ies->data, bss_ies->len);
 		if (elem && elem->datalen >= 3)
 			link->conf->profile_periodicity = elem->data[2];
 		else
 			link->conf->profile_periodicity = 0;
 
 		elem = cfg80211_find_elem(WLAN_EID_EXT_CAPABILITY,
-					  beacon_ies->data, beacon_ies->len);
+					  bss_ies->data, bss_ies->len);
 		if (elem && elem->datalen >= 11 &&
 		    (elem->data[10] & WLAN_EXT_CAPA11_EMA_SUPPORT))
 			link->conf->ema_ap = true;
@@ -7370,7 +7375,7 @@ ieee80211_setup_assoc_link(struct ieee80211_sub_if_data *sdata,
 			link->conf->ema_ap = false;
 
 		elem = cfg80211_find_ext_elem(WLAN_EID_EXT_EHT_OPERATION,
-					      beacon_ies->data, beacon_ies->len);
+					      bss_ies->data, bss_ies->len);
 		eht_oper = (const void *)(elem->data + 1);
 
 		if (elem &&
Signature · 1 line
2.38.1
#18 lore raw

PATCH 14/15 wifi: mac80211: Do not force off-channel for management Tx with MLO

In reply to [email protected]

From: Ilan Peer <[email protected]>

When user space transmits a management frame it is expected to use the MLD addresses if the connection is an MLD one. Thus, in case the management Tx is using the MLD address and no channel is configured off-channel should not be used (as one of the active links would be used).

---
 net/mac80211/offchannel.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
net/mac80211/offchannel.c +7 -1
index cdf991e74ab9..18fc984f1b82 100644
@@ -837,8 +837,14 @@ int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
 		if (!sdata->u.mgd.associated ||
 		    (params->offchan && params->wait &&
 		     local->ops->remain_on_channel &&
-		     memcmp(sdata->vif.cfg.ap_addr, mgmt->bssid, ETH_ALEN)))
+		     memcmp(sdata->vif.cfg.ap_addr, mgmt->bssid, ETH_ALEN))) {
 			need_offchan = true;
+		} else if (sdata->u.mgd.associated &&
+			   ether_addr_equal(sdata->vif.cfg.ap_addr, mgmt->da)) {
+			sta = sta_info_get_bss(sdata, mgmt->da);
+			mlo_sta = sta && sta->sta.mlo;
+		}
+
 		sdata_unlock(sdata);
 		break;
 	case NL80211_IFTYPE_P2P_DEVICE:
Signature · 1 line
2.38.1
#19 lore raw

PATCH 15/15 wifi: mac80211: fix channel switch link data

In reply to [email protected]

From: Johannes Berg <[email protected]>

Use the correct link ID and per-link puncturing data instead of hardcoding link ID 0 and using deflink puncturing.

---
 net/mac80211/cfg.c  | 9 +++++----
 net/mac80211/mlme.c | 3 ++-
 2 files changed, 7 insertions(+), 5 deletions(-)
net/mac80211/cfg.c +5 -4
index ae5017edd09f..3d5d9468ee68 100644
@@ -3668,7 +3668,7 @@ static int __ieee80211_csa_finalize(struct ieee80211_link_data *link_data)
 		return ieee80211_link_use_reserved_context(&sdata->deflink);
 	}
 
-	if (!cfg80211_chandef_identical(&sdata->vif.bss_conf.chandef,
+	if (!cfg80211_chandef_identical(&link_data->conf->chandef,
 					&link_data->csa_chandef))
 		return -EINVAL;
 
@@ -3684,7 +3684,7 @@ static int __ieee80211_csa_finalize(struct ieee80211_link_data *link_data)
 		changed |= BSS_CHANGED_EHT_PUNCTURING;
 	}
 
-	ieee80211_link_info_change_notify(sdata, &sdata->deflink, changed);
+	ieee80211_link_info_change_notify(sdata, link_data, changed);
 
 	if (link_data->csa_block_tx) {
 		ieee80211_wake_vif_queues(local, sdata,
@@ -3696,8 +3696,9 @@ static int __ieee80211_csa_finalize(struct ieee80211_link_data *link_data)
 	if (err)
 		return err;
 
-	cfg80211_ch_switch_notify(sdata->dev, &link_data->csa_chandef, 0,
-				  sdata->vif.bss_conf.eht_puncturing);
+	cfg80211_ch_switch_notify(sdata->dev, &link_data->csa_chandef,
+				  link_data->link_id,
+				  link_data->conf->eht_puncturing);
 
 	return 0;
 }
net/mac80211/mlme.c +2 -1
index 8abd4301f278..e4d229814911 100644
@@ -1782,7 +1782,8 @@ static void ieee80211_chswitch_post_beacon(struct ieee80211_link_data *link)
 		return;
 	}
 
-	cfg80211_ch_switch_notify(sdata->dev, &link->reserved_chandef, 0, 0);
+	cfg80211_ch_switch_notify(sdata->dev, &link->reserved_chandef,
+				  link->link_id, 0);
 }
 
 void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success,
Signature · 1 line
2.38.1