linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
To: linux-wireless@vger.kernel.org
Cc: Arik Nemtsov <arik@wizery.com>,
	Arik Nemtsov <arikx.nemtsov@intel.com>,
	Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Subject: [PATCH 11/19] iwlwifi: mvm: ignore stale TDLS ch-switch responses
Date: Tue,  3 Feb 2015 09:14:30 +0200	[thread overview]
Message-ID: <1422947678-16917-11-git-send-email-emmanuel.grumbach@intel.com> (raw)
In-Reply-To: <1422947482.30742.8.camel@egrumbacBox>

From: Arik Nemtsov <arik@wizery.com>

During out-of-channel activities (e.g. scan) TDLS ch-switch responses from
a peer are kept in FW. These packets arrive only after the out-of-channel
activity is complete, which can be in the order of several seconds.

Since TDLS ch-sw has no dialog-token-like mechanism for distinguishing
sessions, use the GP2 time of the incoming ch-switch response to discern
validity. For this purpose record the GP2 time of an outgoing TDLS ch-sw
request and compare to the Rx time of the ch-sw response.
The methods works in practice since the GP2 time of FW-deferred Rx is
accurate and contains the real Rx timestamp.

Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/mvm.h  |  3 +++
 drivers/net/wireless/iwlwifi/mvm/tdls.c | 15 +++++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h
index fc80b7b..ed09726 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h
@@ -798,6 +798,9 @@ struct iwl_mvm {
 			struct cfg80211_chan_def chandef;
 			struct sk_buff *skb; /* ch sw template */
 			u32 ch_sw_tm_ie;
+
+			/* timestamp of last ch-sw request sent (GP2 time) */
+			u32 sent_timestamp;
 		} peer;
 	} tdls_cs;
 
diff --git a/drivers/net/wireless/iwlwifi/mvm/tdls.c b/drivers/net/wireless/iwlwifi/mvm/tdls.c
index ea1831c..a87b506 100644
--- a/drivers/net/wireless/iwlwifi/mvm/tdls.c
+++ b/drivers/net/wireless/iwlwifi/mvm/tdls.c
@@ -64,6 +64,8 @@
 #include <linux/etherdevice.h>
 #include "mvm.h"
 #include "time-event.h"
+#include "iwl-io.h"
+#include "iwl-prph.h"
 
 #define TU_TO_US(x) (x * 1024)
 #define TU_TO_MS(x) (TU_TO_US(x) / 1000)
@@ -250,6 +252,11 @@ static void iwl_mvm_tdls_update_cs_state(struct iwl_mvm *mvm,
 		       iwl_mvm_tdls_cs_state_str(state));
 	mvm->tdls_cs.state = state;
 
+	/* we only send requests to our switching peer - update sent time */
+	if (state == IWL_MVM_TDLS_SW_REQ_SENT)
+		mvm->tdls_cs.peer.sent_timestamp =
+			iwl_read_prph(mvm->trans, DEVICE_SYSTEM_TIME_REG);
+
 	if (state == IWL_MVM_TDLS_SW_IDLE)
 		mvm->tdls_cs.cur_sta_id = IWL_MVM_STATION_COUNT;
 }
@@ -302,7 +309,7 @@ out:
 static int
 iwl_mvm_tdls_check_action(struct iwl_mvm *mvm,
 			  enum iwl_tdls_channel_switch_type type,
-			  const u8 *peer, bool peer_initiator)
+			  const u8 *peer, bool peer_initiator, u32 timestamp)
 {
 	bool same_peer = false;
 	int ret = 0;
@@ -341,6 +348,9 @@ iwl_mvm_tdls_check_action(struct iwl_mvm *mvm,
 		else if (type == TDLS_SEND_CHAN_SW_REQ)
 			/* wait for idle before sending another request */
 			ret = -EBUSY;
+		else if (timestamp <= mvm->tdls_cs.peer.sent_timestamp)
+			/* we got a stale response - ignore it */
+			ret = -EINVAL;
 		break;
 	case IWL_MVM_TDLS_SW_RESP_RCVD:
 		/*
@@ -399,7 +409,8 @@ iwl_mvm_tdls_config_channel_switch(struct iwl_mvm *mvm,
 
 	lockdep_assert_held(&mvm->mutex);
 
-	ret = iwl_mvm_tdls_check_action(mvm, type, peer, peer_initiator);
+	ret = iwl_mvm_tdls_check_action(mvm, type, peer, peer_initiator,
+					timestamp);
 	if (ret)
 		return ret;
 
-- 
1.9.1


  parent reply	other threads:[~2015-02-03  7:15 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-03  7:11 pull request: iwlwifi-next 2015-02-03 Grumbach, Emmanuel
2015-02-03  7:14 ` [PATCH 01/19] iwlwifi: mvm: check IWL_UCODE_TLV_API_SCD_CFG in API and not in capa Emmanuel Grumbach
2015-02-03  7:14 ` [PATCH 02/19] iwlwifi: mvm: don't reprobe if we fail during reconfig and fw_restart is false Emmanuel Grumbach
2015-02-03  7:14 ` [PATCH 03/19] iwlwifi: mvm: remove space padding after sysassert description Emmanuel Grumbach
2015-02-03  7:14 ` [PATCH 04/19] iwlwifi: mvm: always use mac color zero Emmanuel Grumbach
2015-02-03  7:14 ` [PATCH 05/19] iwlwifi: pcie: don't dump useless data when a TFD queue hangs Emmanuel Grumbach
2015-02-03  7:14 ` [PATCH 06/19] iwlwifi: mvm: add beamformer support Emmanuel Grumbach
2015-02-03  7:14 ` [PATCH 07/19] iwlwifi: mvm: rs: enable forcing single stream Tx decision Emmanuel Grumbach
2015-02-03  7:14 ` [PATCH 08/19] iwlwifi: pcie: prepare the enablement of 31 TFD queues Emmanuel Grumbach
2015-02-03  7:14 ` [PATCH 09/19] iwlwifi: pcie: disable the SCD_BASE_ADDR when we resume from WoWLAN Emmanuel Grumbach
2015-02-03  7:14 ` [PATCH 10/19] iwlwifi: mvm: improve TDLS ch-sw state machine Emmanuel Grumbach
2015-02-03  7:14 ` Emmanuel Grumbach [this message]
2015-02-03  7:14 ` [PATCH 12/19] iwlwifi: mvm: enable watchdog on Tx queues for mvm Emmanuel Grumbach
2015-02-03  7:14 ` [PATCH 13/19] iwlwifi: allow to define the stuck queue timer per queue Emmanuel Grumbach
2015-02-03  7:14 ` [PATCH 14/19] iwlwifi: mvm: Fix a few EBS error handling bugs Emmanuel Grumbach
2015-02-03  7:14 ` [PATCH 15/19] iwlwifi: mvm: fix failure path when power_update fails in add_interface Emmanuel Grumbach
2015-02-03  7:14 ` [PATCH 16/19] iwlwifi: mvm: Enable EBS also in single scan on umac interface Emmanuel Grumbach
2015-02-03  7:14 ` [PATCH 17/19] iwlwifi: mvm: Fix building channels in scan_config_cmd Emmanuel Grumbach
2015-02-03  7:14 ` [PATCH 18/19] iwlwifi: mvm: don't send a command the firmware doesn't know Emmanuel Grumbach
2015-02-03  7:14 ` [PATCH 19/19] iwlwifi: mvm: reduce quota threshold Emmanuel Grumbach
2015-02-06  6:59 ` pull request: iwlwifi-next 2015-02-03 Kalle Valo

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=1422947678-16917-11-git-send-email-emmanuel.grumbach@intel.com \
    --to=emmanuel.grumbach@intel.com \
    --cc=arik@wizery.com \
    --cc=arikx.nemtsov@intel.com \
    --cc=linux-wireless@vger.kernel.org \
    /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).