linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Emmanuel Grumbach <egrumbach@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: Luciano Coelho <luciano.coelho@intel.com>
Subject: [PATCH 57/75] iwlwifi: mvm: add CSA absent time event for clients
Date: Mon, 24 Nov 2014 16:34:33 +0200	[thread overview]
Message-ID: <1416839691-28533-57-git-send-email-egrumbach@gmail.com> (raw)
In-Reply-To: <CANUX_P32q7EFvuOvm+c=yYP9okVEfSUvdDg0gDHHCSg2G+gA0g@mail.gmail.com>

From: Luciano Coelho <luciano.coelho@intel.com>

Add an absent time event when pre_channel_switch is called and use the
time event started indication to set the disable_tx bit instead of
doing it in unassign_vif().  This is done so that the firmware queues
are stopped before the actual switch takes place to avoid losing
packets while the AP/GO is performing its actual switch.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/mac80211.c   | 19 +++++++++-----
 drivers/net/wireless/iwlwifi/mvm/mvm.h        | 27 ++++++++++++++++---
 drivers/net/wireless/iwlwifi/mvm/sta.c        | 15 +++++++++++
 drivers/net/wireless/iwlwifi/mvm/sta.h        |  1 +
 drivers/net/wireless/iwlwifi/mvm/time-event.c | 37 +++++++++++++++++++++------
 5 files changed, 81 insertions(+), 18 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index fdeaab3..ac1cef6 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -2891,7 +2891,6 @@ static void __iwl_mvm_unassign_vif_chanctx(struct iwl_mvm *mvm,
 {
 	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
 	struct ieee80211_vif *disabled_vif = NULL;
-	struct iwl_mvm_sta *mvmsta;
 
 	lockdep_assert_held(&mvm->mutex);
 
@@ -2925,12 +2924,6 @@ static void __iwl_mvm_unassign_vif_chanctx(struct iwl_mvm *mvm,
 
 		disabled_vif = vif;
 
-		mvmsta = iwl_mvm_sta_from_staid_protected(mvm,
-							  mvmvif->ap_sta_id);
-
-		if (!WARN_ON(!mvmsta))
-			iwl_mvm_sta_modify_disable_tx(mvm, mvmsta, true);
-
 		iwl_mvm_mac_ctxt_changed(mvm, vif, true, NULL);
 		break;
 	default:
@@ -3167,6 +3160,7 @@ static int iwl_mvm_pre_channel_switch(struct ieee80211_hw *hw,
 	struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
 	struct ieee80211_vif *csa_vif;
 	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
+	u32 apply_time;
 	int ret;
 
 	mutex_lock(&mvm->mutex);
@@ -3194,6 +3188,17 @@ static int iwl_mvm_pre_channel_switch(struct ieee80211_hw *hw,
 		}
 
 		break;
+	case NL80211_IFTYPE_STATION:
+		apply_time = chsw->timestamp +
+			(vif->bss_conf.beacon_int * chsw->count * 1024);
+
+		if (chsw->block_tx)
+			iwl_mvm_csa_client_absent(mvm, vif);
+
+		iwl_mvm_schedule_csa_period(mvm, vif,
+					    IWL_MVM_CHANNEL_SWITCH_TIME_CLIENT,
+					    apply_time);
+		break;
 	default:
 		break;
 	}
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h
index 2c54c52..2816c6b 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h
@@ -87,11 +87,12 @@
 /* A TimeUnit is 1024 microsecond */
 #define MSEC_TO_TU(_msec)	(_msec*1000/1024)
 
-/* This value represents the number of TUs before CSA "beacon 0" TBTT
- * when the CSA time-event needs to be scheduled to start.  It must be
- * big enough to ensure that we switch in time.
+/* These values represent the number of TUs before CSA "beacon 0" TBTT
+ * when the CSA time-event needs to be scheduled to start.  They must
+ * be big enough to ensure that we switch in time.
  */
 #define IWL_MVM_CHANNEL_SWITCH_TIME_GO		40
+#define IWL_MVM_CHANNEL_SWITCH_TIME_CLIENT	110
 
 /*
  * This value (in TUs) is used to fine tune the CSA NoA end time which should
@@ -797,6 +798,26 @@ static inline bool iwl_mvm_is_radio_killed(struct iwl_mvm *mvm)
 	       test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status);
 }
 
+/* Must be called with rcu_read_lock() held and it can only be
+ * released when mvmsta is not needed anymore.
+ */
+static inline struct iwl_mvm_sta *
+iwl_mvm_sta_from_staid_rcu(struct iwl_mvm *mvm, u8 sta_id)
+{
+	struct ieee80211_sta *sta;
+
+	if (sta_id >= ARRAY_SIZE(mvm->fw_id_to_mac_id))
+		return NULL;
+
+	sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
+
+	/* This can happen if the station has been removed right now */
+	if (IS_ERR_OR_NULL(sta))
+		return NULL;
+
+	return iwl_mvm_sta_from_mac80211(sta);
+}
+
 static inline struct iwl_mvm_sta *
 iwl_mvm_sta_from_staid_protected(struct iwl_mvm *mvm, u8 sta_id)
 {
diff --git a/drivers/net/wireless/iwlwifi/mvm/sta.c b/drivers/net/wireless/iwlwifi/mvm/sta.c
index a38f1f1..d86fe43 100644
--- a/drivers/net/wireless/iwlwifi/mvm/sta.c
+++ b/drivers/net/wireless/iwlwifi/mvm/sta.c
@@ -1732,3 +1732,18 @@ void iwl_mvm_modify_all_sta_disable_tx(struct iwl_mvm *mvm,
 		iwl_mvm_sta_modify_disable_tx_ap(mvm, sta, disable);
 	}
 }
+
+void iwl_mvm_csa_client_absent(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
+{
+	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
+	struct iwl_mvm_sta *mvmsta;
+
+	rcu_read_lock();
+
+	mvmsta = iwl_mvm_sta_from_staid_rcu(mvm, mvmvif->ap_sta_id);
+
+	if (!WARN_ON(!mvmsta))
+		iwl_mvm_sta_modify_disable_tx(mvm, mvmsta, true);
+
+	rcu_read_unlock();
+}
diff --git a/drivers/net/wireless/iwlwifi/mvm/sta.h b/drivers/net/wireless/iwlwifi/mvm/sta.h
index 2c869bc..d8f48975 100644
--- a/drivers/net/wireless/iwlwifi/mvm/sta.h
+++ b/drivers/net/wireless/iwlwifi/mvm/sta.h
@@ -422,5 +422,6 @@ void iwl_mvm_sta_modify_disable_tx_ap(struct iwl_mvm *mvm,
 void iwl_mvm_modify_all_sta_disable_tx(struct iwl_mvm *mvm,
 				       struct iwl_mvm_vif *mvmvif,
 				       bool disable);
+void iwl_mvm_csa_client_absent(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
 
 #endif /* __sta_h__ */
diff --git a/drivers/net/wireless/iwlwifi/mvm/time-event.c b/drivers/net/wireless/iwlwifi/mvm/time-event.c
index 8cf246b..1a537be 100644
--- a/drivers/net/wireless/iwlwifi/mvm/time-event.c
+++ b/drivers/net/wireless/iwlwifi/mvm/time-event.c
@@ -191,6 +191,33 @@ static bool iwl_mvm_te_check_disconnect(struct iwl_mvm *mvm,
 	return true;
 }
 
+static void
+iwl_mvm_te_handle_notify_csa(struct iwl_mvm *mvm,
+			     struct iwl_mvm_time_event_data *te_data,
+			     struct iwl_time_event_notif *notif)
+{
+	if (!le32_to_cpu(notif->status)) {
+		IWL_DEBUG_TE(mvm, "CSA time event failed to start\n");
+		return;
+	}
+
+	switch (te_data->vif->type) {
+	case NL80211_IFTYPE_AP:
+		iwl_mvm_csa_noa_start(mvm);
+		break;
+	case NL80211_IFTYPE_STATION:
+		iwl_mvm_csa_client_absent(mvm, te_data->vif);
+		break;
+	default:
+		/* should never happen */
+		WARN_ON_ONCE(1);
+		break;
+	}
+
+	/* we don't need it anymore */
+	iwl_mvm_te_clear_data(mvm, te_data);
+}
+
 /*
  * Handles a FW notification for an event that is known to the driver.
  *
@@ -252,14 +279,8 @@ static void iwl_mvm_te_handle_notif(struct iwl_mvm *mvm,
 			set_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status);
 			iwl_mvm_ref(mvm, IWL_MVM_REF_ROC);
 			ieee80211_ready_on_channel(mvm->hw);
-		} else if (te_data->vif->type == NL80211_IFTYPE_AP) {
-			if (le32_to_cpu(notif->status))
-				iwl_mvm_csa_noa_start(mvm);
-			else
-				IWL_DEBUG_TE(mvm, "CSA NOA failed to start\n");
-
-			/* we don't need it anymore */
-			iwl_mvm_te_clear_data(mvm, te_data);
+		} else if (te_data->id == TE_CHANNEL_SWITCH_PERIOD) {
+			iwl_mvm_te_handle_notify_csa(mvm, te_data, notif);
 		}
 	} else {
 		IWL_WARN(mvm, "Got TE with unknown action\n");
-- 
1.9.1


  parent reply	other threads:[~2014-11-24 14:36 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-24 14:34 pull request: iwlwifi-next 2014-11-24 Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 01/75] iwlwfifi: fix WANT_DEV_COREDUMP selection in Kconfig Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 02/75] iwlwifi: mvm: handle error from iwl_trans_update_sf Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 03/75] iwlwifi: mvm: use correct type for firmware status Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 04/75] iwlwifi: mvm: expose some static APIs for use by TDLS code Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 05/75] iwlwifi: mvm: rs: don't use shadowing variable Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 06/75] iwlwifi: mvm: fix init_dbg flow to work as expected Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 07/75] iwlwifi: mvm: rs: fix a WARNING in case of STBC and VHT Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 08/75] iwlwifi: mvm/trans: abort d0i3_enter in case of held ref Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 09/75] iwlwifi: mvm: rs: fix getting stuck in a test window Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 10/75] iwlwifi: mvm: rs - don't use the shared antenna when BT load is high Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 11/75] iwlwifi: mvm: don't capture firmware coredump for D3->D0 reconfig Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 12/75] iwlwifi: mvm: refactor temperature notification handling Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 13/75] iwlwifi: mvm: handle unsolicited DTS_MEASUREMENT_NOTIFICATIONs Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 14/75] iwlwifi: pcie: introduce delay when waking up the device Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 15/75] iwlwifi: pcie: newer platform needs a OS alive indication Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 16/75] iwlwifi: mvm: wake up d0i3_exit_waitq when aborting d0i3 Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 17/75] iwlwifi: mvm: Insert DS Parameter Set placeholder in probes Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 18/75] iwlwifi: change max HT and VHT A-MPDU exponent Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 19/75] iwlwifi: mvm: add support for WMM Access Control Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 20/75] iwlwifi: mvm: move deferred d0i3 exit to resume_complete op Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 21/75] iwlwifi: mvm: New skip over dtim policy Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 22/75] iwlwifi: mvm: Fix the keep_alive calculation Emmanuel Grumbach
2014-11-24 14:33 ` [PATCH 23/75] iwlwifi: mvm: implement UMAC scan API Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 24/75] iwlwifi: mvm: BT Coex - add support for TTC / RRC Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 25/75] iwlwifi: mvm: rs: consider a missing BA as a single tx failure Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 26/75] iwlwifi: mvm: go to umac scan even if lmac tlv bit is on Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 27/75] iwlwifi: mvm: support random MAC address for scanning Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 28/75] iwlwifi: pcie: properly reset the device Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 29/75] iwlwifi: mvm: make nd_ies part of the mvm struct Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 30/75] iwlwifi: mvm: disable beacon filtering escape timer Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 31/75] iwlwifi: pcie: support loading FW with extended mem range Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 32/75] iwlwifi: pcie: support 7265-D devices Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 33/75] iwlwifi: mvm: use unsigned for ssid_bitmap Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 34/75] iwlwifi: mvm: remove warning on unknown scan complete Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 35/75] iwlwifi: mvm: add remove flow for AUX ROC time events Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 36/75] iwlwifi: mvm: refactor key add/remove functions Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 37/75] iwlwifi: mvm: add WEP RX hardware offload support Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 38/75] iwlwifi: build mac80211 rx_status in place Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 39/75] iwlwifi: mvm: pull crypto header into skb->head Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 40/75] iwlwifi: mvm: pull SNAP " Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 41/75] iwlwifi: mvm: declare TDLS support Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 42/75] iwlwifi: mvm: add TDLS channel switch FW APIs Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 43/75] iwlwifi: mvm: configure TDLS peers to FW Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 44/75] iwlwifi: mvm: allow private per-STA TFD queues Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 45/75] iwlwifi: mvm: disconnect TDLS peers on reconfig Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 46/75] iwlwifi: mvm: use private TFD queues for TDLS stations Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 47/75] iwlwifi: mvm: block TID when using TDLS Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 48/75] iwlwifi: mvm: implement mac80211 TDLS channel-switch APIs Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 49/75] iwlwifi: mvm: use new pre_channel_switch op instead of channel_switch_beacon Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 50/75] iwlwifi: mvm: only save csa_vif in AP/GO mode Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 51/75] iwlwifi: mvm: refactor iwl_mvm_switch_vif_chanctx to support other modes Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 52/75] iwlwifi: mvm: add support for CHANCTX_SWMODE_REASSIGN_VIF Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 53/75] iwlwifi: mvm: return the actual error code when switch_vif_chanctx fails Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 54/75] iwlwifi: mvm: Handle failed beacon transmissions during CSA Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 55/75] iwlwifi: mvm: disable PS during channel switch Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 56/75] iwlwifi: mvm: use switching_chanctx argument instead of csa_active Emmanuel Grumbach
2014-11-24 14:34 ` Emmanuel Grumbach [this message]
2014-11-24 14:34 ` [PATCH 58/75] iwlwifi: mvm: schedule CSA time event a bit before beacon 1 Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 59/75] iwlwifi: mvm: finalize on post_switch instead of unassign Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 60/75] iwlwifi: mvm: add a channel_switch op to bypass mac80211 timer Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 61/75] iwlwifi: mvm: disable beacon filtering during CSA Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 62/75] iwlwifi: mvm: clear TE data if CSA time event fails to start Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 63/75] iwlwifi: mvm: protect session during CSA Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 64/75] iwlwifi: mvm: add support for net detect Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 65/75] iwlwifi: mvm: refactor wowlan and netdetect configuration when suspending Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 66/75] iwlwifi: mvm: refactor iwl_mvm_query_wakeup_reasons() Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 67/75] iwlwifi: mvm: treat netdetect wake up separately Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 68/75] iwlwifi: trans: add suspend/resume ops Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 69/75] iwlwifi: mvm: call iwl_trans_suspend/resume Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 70/75] iwlwifi: mvm: add support to MFUART loading notification Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 71/75] iwlwifi: mvm: declare support for VHT BF info in radiotap Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 72/75] iwlwifi: mvm: disconnect TDLS peers before channel switch Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 73/75] iwlwifi: declare d0i3 support for IWL_DEVICE_8000 Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 74/75] iwlwifi: sdio: new SDIO card id for 4165 series Emmanuel Grumbach
2014-11-24 14:34 ` [PATCH 75/75] iwlwifi: update the secure mem space and for the CPUs Emmanuel Grumbach
2014-11-24 19:00 ` pull request: iwlwifi-next 2014-11-24 John W. Linville

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1416839691-28533-57-git-send-email-egrumbach@gmail.com \
    --to=egrumbach@gmail.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luciano.coelho@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).