Blame SOURCES/0076-Revert-iwlwifi-mvm-disconnect-in-case-of-bad-channel.patch

deb259
From af78069a8e25027e8ea2d3cb3fdbe545b398db34 Mon Sep 17 00:00:00 2001
deb259
From: Eugene Syromiatnikov <esyr@redhat.com>
deb259
Date: Fri, 6 Sep 2019 01:44:00 +0200
deb259
Subject: [PATCH 3/6] Revert "iwlwifi: mvm: disconnect in case of bad channel
deb259
 switch parameters"
deb259
deb259
This reverts commit f67806140220caa3d4337e6c60989b520e13f9a8.
deb259
---
deb259
 drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c  |   7 +-
deb259
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c  | 171 +++++++++------------
deb259
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h       |   1 -
deb259
 .../net/wireless/intel/iwlwifi/mvm/time-event.c    |   5 +-
deb259
 4 files changed, 77 insertions(+), 107 deletions(-)
deb259
deb259
Index: src/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
deb259
===================================================================
deb259
--- src.orig/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c	2019-09-06 01:36:13.967210247 +0200
deb259
+++ src/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c	2019-09-06 01:45:49.470800771 +0200
deb259
@@ -8,7 +8,7 @@
deb259
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
deb259
  * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
deb259
  * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
deb259
- * Copyright(c) 2018 - 2019 Intel Corporation
deb259
+ * Copyright(c) 2018 Intel Corporation
deb259
  *
deb259
  * This program is free software; you can redistribute it and/or modify
deb259
  * it under the terms of version 2 of the GNU General Public License as
deb259
@@ -31,7 +31,7 @@
deb259
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
deb259
  * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
deb259
  * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
deb259
- * Copyright(c) 2018 - 2019 Intel Corporation
deb259
+ * Copyright(c) 2018 Intel Corporation
deb259
  * All rights reserved.
deb259
  *
deb259
  * Redistribution and use in source and binary forms, with or without
deb259
@@ -1631,7 +1631,6 @@
deb259
 
deb259
 	rcu_read_lock();
deb259
 	vif = rcu_dereference(mvm->vif_id_to_mac[mac_id]);
deb259
-	mvmvif = iwl_mvm_vif_from_mac80211(vif);
deb259
 
deb259
 	switch (vif->type) {
deb259
 	case NL80211_IFTYPE_AP:
deb259
@@ -1640,6 +1639,7 @@
deb259
 			    csa_vif != vif))
deb259
 			goto out_unlock;
deb259
 
deb259
+		mvmvif = iwl_mvm_vif_from_mac80211(csa_vif);
deb259
 		csa_id = FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color);
deb259
 		if (WARN(csa_id != id_n_color,
deb259
 			 "channel switch noa notification on unexpected vif (csa_vif=%d, notif=%d)",
deb259
@@ -1660,7 +1660,6 @@
deb259
 		return;
deb259
 	case NL80211_IFTYPE_STATION:
deb259
 		iwl_mvm_csa_client_absent(mvm, vif);
deb259
-		cancel_delayed_work(&mvmvif->csa_work);
deb259
 		ieee80211_chswitch_done(vif, true);
deb259
 		break;
deb259
 	default:
deb259
Index: src/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
deb259
===================================================================
deb259
--- src.orig/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c	2019-09-06 01:45:49.284803166 +0200
deb259
+++ src/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c	2019-09-06 01:45:49.471800758 +0200
deb259
@@ -1337,91 +1337,6 @@
deb259
 	return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, 0, len, &cmd);
deb259
 }
deb259
 
deb259
-static int iwl_mvm_post_channel_switch(struct ieee80211_hw *hw,
deb259
-				       struct ieee80211_vif *vif)
deb259
-{
deb259
-	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
deb259
-	struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
deb259
-	int ret;
deb259
-
deb259
-	mutex_lock(&mvm->mutex);
deb259
-
deb259
-	if (mvmvif->csa_failed) {
deb259
-		mvmvif->csa_failed = false;
deb259
-		ret = -EIO;
deb259
-		goto out_unlock;
deb259
-	}
deb259
-
deb259
-	if (vif->type == NL80211_IFTYPE_STATION) {
deb259
-		struct iwl_mvm_sta *mvmsta;
deb259
-
deb259
-		mvmvif->csa_bcn_pending = false;
deb259
-		mvmsta = iwl_mvm_sta_from_staid_protected(mvm,
deb259
-							  mvmvif->ap_sta_id);
deb259
-
deb259
-		if (WARN_ON(!mvmsta)) {
deb259
-			ret = -EIO;
deb259
-			goto out_unlock;
deb259
-		}
deb259
-
deb259
-		iwl_mvm_sta_modify_disable_tx(mvm, mvmsta, false);
deb259
-
deb259
-		iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL);
deb259
-
deb259
-		ret = iwl_mvm_enable_beacon_filter(mvm, vif, 0);
deb259
-		if (ret)
deb259
-			goto out_unlock;
deb259
-
deb259
-		iwl_mvm_stop_session_protection(mvm, vif);
deb259
-	}
deb259
-
deb259
-	mvmvif->ps_disabled = false;
deb259
-
deb259
-	ret = iwl_mvm_power_update_ps(mvm);
deb259
-
deb259
-out_unlock:
deb259
-	mutex_unlock(&mvm->mutex);
deb259
-
deb259
-	return ret;
deb259
-}
deb259
-
deb259
-static void iwl_mvm_abort_channel_switch(struct ieee80211_hw *hw,
deb259
-					 struct ieee80211_vif *vif)
deb259
-{
deb259
-	struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
deb259
-	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
deb259
-	struct iwl_chan_switch_te_cmd cmd = {
deb259
-		.mac_id = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
deb259
-							  mvmvif->color)),
deb259
-		.action = cpu_to_le32(FW_CTXT_ACTION_REMOVE),
deb259
-	};
deb259
-
deb259
-	IWL_DEBUG_MAC80211(mvm, "Abort CSA on mac %d\n", mvmvif->id);
deb259
-
deb259
-	mutex_lock(&mvm->mutex);
deb259
-	WARN_ON(iwl_mvm_send_cmd_pdu(mvm,
deb259
-				     WIDE_ID(MAC_CONF_GROUP,
deb259
-					     CHANNEL_SWITCH_TIME_EVENT_CMD),
deb259
-				     0, sizeof(cmd), &cmd));
deb259
-	mutex_unlock(&mvm->mutex);
deb259
-
deb259
-	WARN_ON(iwl_mvm_post_channel_switch(hw, vif));
deb259
-}
deb259
-
deb259
-static void iwl_mvm_channel_switch_disconnect_wk(struct work_struct *wk)
deb259
-{
deb259
-	struct iwl_mvm *mvm;
deb259
-	struct iwl_mvm_vif *mvmvif;
deb259
-	struct ieee80211_vif *vif;
deb259
-
deb259
-	mvmvif = container_of(wk, struct iwl_mvm_vif, csa_work.work);
deb259
-	vif = container_of((void *)mvmvif, struct ieee80211_vif, drv_priv);
deb259
-	mvm = mvmvif->mvm;
deb259
-
deb259
-	iwl_mvm_abort_channel_switch(mvm->hw, vif);
deb259
-	ieee80211_chswitch_done(vif, false);
deb259
-}
deb259
-
deb259
 static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,
deb259
 				     struct ieee80211_vif *vif)
deb259
 {
deb259
@@ -1548,8 +1463,6 @@
deb259
 	}
deb259
 
deb259
 	iwl_mvm_tcm_add_vif(mvm, vif);
deb259
-	INIT_DELAYED_WORK(&mvmvif->csa_work,
deb259
-			  iwl_mvm_channel_switch_disconnect_wk);
deb259
 
deb259
 	if (vif->type == NL80211_IFTYPE_MONITOR)
deb259
 		mvm->monitor_on = true;
deb259
@@ -4106,7 +4019,6 @@
deb259
 				    0, sizeof(cmd), &cmd);
deb259
 }
deb259
 
deb259
-#define IWL_MAX_CSA_BLOCK_TX 1500
deb259
 static int iwl_mvm_pre_channel_switch(struct ieee80211_hw *hw,
deb259
 				      struct ieee80211_vif *vif,
deb259
 				      struct ieee80211_channel_switch *chsw)
deb259
@@ -4171,18 +4083,8 @@
deb259
 				((vif->bss_conf.beacon_int * (chsw->count - 1) -
deb259
 				  IWL_MVM_CHANNEL_SWITCH_TIME_CLIENT) * 1024);
deb259
 
deb259
-		if (chsw->block_tx) {
deb259
+		if (chsw->block_tx)
deb259
 			iwl_mvm_csa_client_absent(mvm, vif);
deb259
-			/*
deb259
-			 * In case of undetermined / long time with immediate
deb259
-			 * quiet monitor status to gracefully disconnect
deb259
-			 */
deb259
-			if (!chsw->count ||
deb259
-			    chsw->count * vif->bss_conf.beacon_int >
deb259
-			    IWL_MAX_CSA_BLOCK_TX)
deb259
-				schedule_delayed_work(&mvmvif->csa_work,
deb259
-						      msecs_to_jiffies(IWL_MAX_CSA_BLOCK_TX));
deb259
-		}
deb259
 
deb259
 		if (mvmvif->bf_data.bf_enabled) {
deb259
 			ret = iwl_mvm_disable_beacon_filter(mvm, vif, 0);
deb259
@@ -4217,6 +4119,54 @@
deb259
 	return ret;
deb259
 }
deb259
 
deb259
+static int iwl_mvm_post_channel_switch(struct ieee80211_hw *hw,
deb259
+				       struct ieee80211_vif *vif)
deb259
+{
deb259
+	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
deb259
+	struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
deb259
+	int ret;
deb259
+
deb259
+	mutex_lock(&mvm->mutex);
deb259
+
deb259
+	if (mvmvif->csa_failed) {
deb259
+		mvmvif->csa_failed = false;
deb259
+		ret = -EIO;
deb259
+		goto out_unlock;
deb259
+	}
deb259
+
deb259
+	if (vif->type == NL80211_IFTYPE_STATION) {
deb259
+		struct iwl_mvm_sta *mvmsta;
deb259
+
deb259
+		mvmvif->csa_bcn_pending = false;
deb259
+		mvmsta = iwl_mvm_sta_from_staid_protected(mvm,
deb259
+							  mvmvif->ap_sta_id);
deb259
+
deb259
+		if (WARN_ON(!mvmsta)) {
deb259
+			ret = -EIO;
deb259
+			goto out_unlock;
deb259
+		}
deb259
+
deb259
+		iwl_mvm_sta_modify_disable_tx(mvm, mvmsta, false);
deb259
+
deb259
+		iwl_mvm_mac_ctxt_changed(mvm, vif, false, NULL);
deb259
+
deb259
+		ret = iwl_mvm_enable_beacon_filter(mvm, vif, 0);
deb259
+		if (ret)
deb259
+			goto out_unlock;
deb259
+
deb259
+		iwl_mvm_stop_session_protection(mvm, vif);
deb259
+	}
deb259
+
deb259
+	mvmvif->ps_disabled = false;
deb259
+
deb259
+	ret = iwl_mvm_power_update_ps(mvm);
deb259
+
deb259
+out_unlock:
deb259
+	mutex_unlock(&mvm->mutex);
deb259
+
deb259
+	return ret;
deb259
+}
deb259
+
deb259
 static void iwl_mvm_channel_switch_rx_beacon(struct ieee80211_hw *hw,
deb259
 					     struct ieee80211_vif *vif,
deb259
 					     struct ieee80211_channel_switch *chsw)
deb259
@@ -4243,6 +4193,29 @@
deb259
 				     CMD_ASYNC, sizeof(cmd), &cmd));
deb259
 }
deb259
 
deb259
+static void iwl_mvm_abort_channel_switch(struct ieee80211_hw *hw,
deb259
+					 struct ieee80211_vif *vif)
deb259
+{
deb259
+	struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
deb259
+	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
deb259
+	struct iwl_chan_switch_te_cmd cmd = {
deb259
+		.mac_id = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
deb259
+							  mvmvif->color)),
deb259
+		.action = cpu_to_le32(FW_CTXT_ACTION_REMOVE),
deb259
+	};
deb259
+
deb259
+	IWL_DEBUG_MAC80211(mvm, "Abort CSA on mac %d\n", mvmvif->id);
deb259
+
deb259
+	mutex_lock(&mvm->mutex);
deb259
+	WARN_ON(iwl_mvm_send_cmd_pdu(mvm,
deb259
+				     WIDE_ID(MAC_CONF_GROUP,
deb259
+					     CHANNEL_SWITCH_TIME_EVENT_CMD),
deb259
+				     0, sizeof(cmd), &cmd));
deb259
+	mutex_unlock(&mvm->mutex);
deb259
+
deb259
+	WARN_ON(iwl_mvm_post_channel_switch(hw, vif));
deb259
+}
deb259
+
deb259
 static void iwl_mvm_flush_no_vif(struct iwl_mvm *mvm, u32 queues, bool drop)
deb259
 {
deb259
 	int i;
deb259
Index: src/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
deb259
===================================================================
deb259
--- src.orig/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h	2019-09-06 01:45:49.284803166 +0200
deb259
+++ src/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h	2019-09-06 01:45:49.471800758 +0200
deb259
@@ -490,7 +490,6 @@
deb259
 	bool csa_countdown;
deb259
 	bool csa_failed;
deb259
 	u16 csa_target_freq;
deb259
-	struct delayed_work csa_work;
deb259
 
deb259
 	/* Indicates that we are waiting for a beacon on a new channel */
deb259
 	bool csa_bcn_pending;
deb259
Index: src/drivers/net/wireless/intel/iwlwifi/mvm/time-event.c
deb259
===================================================================
deb259
--- src.orig/drivers/net/wireless/intel/iwlwifi/mvm/time-event.c	2019-06-27 14:54:04.140678253 +0200
deb259
+++ src/drivers/net/wireless/intel/iwlwifi/mvm/time-event.c	2019-09-06 01:45:49.472800745 +0200
deb259
@@ -8,7 +8,7 @@
deb259
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
deb259
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
deb259
  * Copyright(c) 2017 Intel Deutschland GmbH
deb259
- * Copyright(c) 2018 - 2019 Intel Corporation
deb259
+ * Copyright(c) 2018 Intel Corporation
deb259
  *
deb259
  * This program is free software; you can redistribute it and/or modify
deb259
  * it under the terms of version 2 of the GNU General Public License as
deb259
@@ -31,7 +31,7 @@
deb259
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
deb259
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
deb259
  * Copyright(c) 2017 Intel Deutschland GmbH
deb259
- * Copyright(c) 2018 - 2019 Intel Corporation
deb259
+ * Copyright(c) 2018 Intel Corporation
deb259
  * All rights reserved.
deb259
  *
deb259
  * Redistribution and use in source and binary forms, with or without
deb259
@@ -234,7 +234,6 @@
deb259
 			break;
deb259
 		}
deb259
 		iwl_mvm_csa_client_absent(mvm, te_data->vif);
deb259
-		cancel_delayed_work(&mvmvif->csa_work);
deb259
 		ieee80211_chswitch_done(te_data->vif, true);
deb259
 		break;
deb259
 	default: