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: Haim Dreyfuss <haim.dreyfuss@intel.com>,
	Alexander Bondar <alexander.bondar@intel.com>,
	Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Subject: [PATCH 42/47] iwlwifi: mvm: Add support for Energy based scan (EBS)
Date: Sun, 13 Apr 2014 22:19:57 +0300	[thread overview]
Message-ID: <1397416802-32403-42-git-send-email-egrumbach@gmail.com> (raw)
In-Reply-To: <534AE330.2020805@gmail.com>

From: Haim Dreyfuss <haim.dreyfuss@intel.com>

This patch enables Energy Based Scan (EBS) - intended to detect energy
on 5 GHz band channels. Passive scan on this band takes up to 2.64 sec
assuming 110mSec per-channel * 24 channels. EBS is designed to detect
energy on channels with intensive Wifi activity as well as those where
only beacons are transmitted. EBS completes sampling all channels within
shortest beacon frame transmission time. Total EBS duration is about 100
msec (typical beacon interval).
Detecting Wifi activity on 5 GHz band channels can significantly reduce
scan duration thus saving time and power. EBS failure reported by FW
disables EBS for current connection. It is re-enabled upon new
connection attempt on any WLAN interface.

Signed-off-by: Haim Dreyfuss <haim.dreyfuss@intel.com>
Signed-off-by: Alexander Bondar <alexander.bondar@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/iwl-fw.h          |  2 ++
 drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h | 18 ++++++++++++++----
 drivers/net/wireless/iwlwifi/mvm/fw-api.h      |  1 +
 drivers/net/wireless/iwlwifi/mvm/mac80211.c    |  5 +++++
 drivers/net/wireless/iwlwifi/mvm/mvm.h         |  2 ++
 drivers/net/wireless/iwlwifi/mvm/scan.c        | 15 +++++++++++++--
 6 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-fw.h b/drivers/net/wireless/iwlwifi/iwl-fw.h
index 265d6f1..f5927d0c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-fw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-fw.h
@@ -91,6 +91,7 @@
  * @IWL_UCODE_TLV_FLAGS_P2P_PS_UAPSD: P2P client supports uAPSD power save
  * @IWL_UCODE_TLV_FLAGS_BCAST_FILTERING: uCode supports broadcast filtering.
  * @IWL_UCODE_TLV_FLAGS_GO_UAPSD: AP/GO interfaces support uAPSD clients
+ * @IWL_UCODE_TLV_FLAGS_EBS_SUPPORT: this uCode image supports EBS.
  */
 enum iwl_ucode_tlv_flag {
 	IWL_UCODE_TLV_FLAGS_PAN			= BIT(0),
@@ -106,6 +107,7 @@ enum iwl_ucode_tlv_flag {
 	IWL_UCODE_TLV_FLAGS_P2P_PM		= BIT(21),
 	IWL_UCODE_TLV_FLAGS_BSS_P2P_PS_DCM	= BIT(22),
 	IWL_UCODE_TLV_FLAGS_BSS_P2P_PS_SCM	= BIT(23),
+	IWL_UCODE_TLV_FLAGS_EBS_SUPPORT		= BIT(25),
 	IWL_UCODE_TLV_FLAGS_P2P_PS_UAPSD	= BIT(26),
 	IWL_UCODE_TLV_FLAGS_BCAST_FILTERING	= BIT(29),
 	IWL_UCODE_TLV_FLAGS_GO_UAPSD		= BIT(30),
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h b/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
index 0373f44..6959fda 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
+++ b/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
@@ -538,13 +538,16 @@ struct iwl_scan_offload_schedule {
  *
  * IWL_SCAN_OFFLOAD_FLAG_PASS_ALL: pass all results - no filtering.
  * IWL_SCAN_OFFLOAD_FLAG_CACHED_CHANNEL: add cached channels to partial scan.
- * IWL_SCAN_OFFLOAD_FLAG_ENERGY_SCAN: use energy based scan before partial scan
- *	on A band.
+ * IWL_SCAN_OFFLOAD_FLAG_EBS_QUICK_MODE: EBS duration is 100mSec - typical
+ *	beacon period. Finding channel activity in this mode is not guaranteed.
+ * IWL_SCAN_OFFLOAD_FLAG_EBS_ACCURATE_MODE: EBS duration is 200mSec.
+ *	Assuming beacon period is 100ms finding channel activity is guaranteed.
  */
 enum iwl_scan_offload_flags {
 	IWL_SCAN_OFFLOAD_FLAG_PASS_ALL		= BIT(0),
 	IWL_SCAN_OFFLOAD_FLAG_CACHED_CHANNEL	= BIT(2),
-	IWL_SCAN_OFFLOAD_FLAG_ENERGY_SCAN	= BIT(3),
+	IWL_SCAN_OFFLOAD_FLAG_EBS_QUICK_MODE	= BIT(5),
+	IWL_SCAN_OFFLOAD_FLAG_EBS_ACCURATE_MODE	= BIT(6),
 };
 
 /**
@@ -567,17 +570,24 @@ enum iwl_scan_offload_compleate_status {
 	IWL_SCAN_OFFLOAD_ABORTED	= 2,
 };
 
+enum iwl_scan_ebs_status {
+	IWL_SCAN_EBS_SUCCESS,
+	IWL_SCAN_EBS_FAILED,
+	IWL_SCAN_EBS_CHAN_NOT_FOUND,
+};
+
 /**
  * iwl_scan_offload_complete - SCAN_OFFLOAD_COMPLETE_NTF_API_S_VER_1
  * @last_schedule_line:		last schedule line executed (fast or regular)
  * @last_schedule_iteration:	last scan iteration executed before scan abort
  * @status:			enum iwl_scan_offload_compleate_status
+ * @ebs_status: last EBS status, see IWL_SCAN_EBS_*
  */
 struct iwl_scan_offload_complete {
 	u8 last_schedule_line;
 	u8 last_schedule_iteration;
 	u8 status;
-	u8 reserved;
+	u8 ebs_status;
 } __packed;
 
 /**
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api.h b/drivers/net/wireless/iwlwifi/mvm/fw-api.h
index 48554da..309a9b9 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/iwlwifi/mvm/fw-api.h
@@ -71,6 +71,7 @@
 #include "fw-api-power.h"
 #include "fw-api-d3.h"
 #include "fw-api-coex.h"
+#include "fw-api-scan.h"
 
 /* maximal number of Tx queues in any platform */
 #define IWL_MVM_MAX_QUEUES	20
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index dc9069b..374ecd4 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -1694,6 +1694,11 @@ static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw,
 		ret = iwl_mvm_add_sta(mvm, vif, sta);
 	} else if (old_state == IEEE80211_STA_NONE &&
 		   new_state == IEEE80211_STA_AUTH) {
+		/*
+		 * EBS may be disabled due to previous failures reported by FW.
+		 * Reset EBS status here assuming environment has been changed.
+		 */
+		mvm->last_ebs_successful = true;
 		ret = 0;
 	} else if (old_state == IEEE80211_STA_AUTH &&
 		   new_state == IEEE80211_STA_ASSOC) {
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h
index ed22201..41184a4 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h
@@ -535,6 +535,8 @@ struct iwl_mvm {
 	/* Internal station */
 	struct iwl_mvm_int_sta aux_sta;
 
+	bool last_ebs_successful;
+
 	u8 scan_last_antenna_idx; /* to toggle TX between antennas */
 	u8 mgmt_last_antenna_idx;
 
diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index ea17745..84e7c66 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -575,9 +575,13 @@ int iwl_mvm_rx_scan_offload_complete_notif(struct iwl_mvm *mvm,
 	/* scan status must be locked for proper checking */
 	lockdep_assert_held(&mvm->mutex);
 
-	IWL_DEBUG_SCAN(mvm, "Scheduled scan completed, status %s\n",
+	IWL_DEBUG_SCAN(mvm,
+		       "Scheduled scan completed, status %s EBS status %s:%d\n",
 		       scan_notif->status == IWL_SCAN_OFFLOAD_COMPLETED ?
-		       "completed" : "aborted");
+		       "completed" : "aborted", scan_notif->ebs_status ==
+		       IWL_SCAN_EBS_SUCCESS ? "success" : "failed",
+		       scan_notif->ebs_status);
+
 
 	/* only call mac80211 completion if the stop was initiated by FW */
 	if (mvm->scan_status == IWL_MVM_SCAN_SCHED) {
@@ -585,6 +589,8 @@ int iwl_mvm_rx_scan_offload_complete_notif(struct iwl_mvm *mvm,
 		ieee80211_sched_scan_stopped(mvm->hw);
 	}
 
+	mvm->last_ebs_successful = !scan_notif->ebs_status;
+
 	return 0;
 }
 
@@ -921,6 +927,11 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
 		scan_req.flags |= cpu_to_le16(IWL_SCAN_OFFLOAD_FLAG_PASS_ALL);
 	}
 
+	if (mvm->last_ebs_successful &&
+	    mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_EBS_SUPPORT)
+		scan_req.flags |=
+			cpu_to_le16(IWL_SCAN_OFFLOAD_FLAG_EBS_ACCURATE_MODE);
+
 	return iwl_mvm_send_cmd_pdu(mvm, SCAN_OFFLOAD_REQUEST_CMD, CMD_SYNC,
 				    sizeof(scan_req), &scan_req);
 }
-- 
1.8.3.2


  parent reply	other threads:[~2014-04-13 19:21 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-13 19:19 pull request: iwlwifi 2014-04-13 Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 01/47] iwlwifi: mvm: Handle power management constraints for additional use-cases Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 02/47] iwlwifi: mvm: fix the number of channels in family 8000 Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 03/47] iwlwifi: pcie: don't leave the new NICs awake for commands Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 04/47] iwlwifi: mvm: add lq_cmd/tx_resp reduced_tpc field Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 05/47] iwlwifi: mvm: add ATPC implementation Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 06/47] iwlwifi: mvm: add debugfs file for fixed reduced tx power Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 07/47] iwlwifi: pcie: implement GRO without NAPI Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 08/47] iwlwifi: pcie: clarify RX queue need_update handling and locking Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 09/47] iwlwifi: pcie: use bool for TX queue where appropriate Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 10/47] iwlwifi: pcie: fix TX queue locking Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 11/47] iwlwifi: pcie: clarify TX queue need_update handling Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 12/47] iwlwifi: pcie: unify iwl_rx_replenish and iwl_rx_replenish_now Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 13/47] iwlwifi: move CPU1_CPU2_SEPARATOR_SECTION to iwl-fw.h Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 14/47] iwlwifi: mvm: remove redundant empty line Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 15/47] iwlwifi: mvm: propagate the beamforming status from firmware Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 16/47] iwlwifi: mvm: don't set AP STA to EINVAL Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 17/47] iwlwifi: allow to wait for a subset of the queues Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 18/47] iwlwifi: pcie: WARN upon traffic while flushing TX queues Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 19/47] iwlwifi: mvm: dump Rx FIFO when the firmware asserts Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 20/47] iwlwifi: mvm: Fix warning message when exit thermal throttling Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 21/47] iwlwifi: mvm: Fix tx-backoff when NIC " Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 22/47] iwlwifi: mvm: don't enable bcast filtering on P2P client Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 23/47] iwlwifi: mvm: Use RCU_INIT_POINTER(x, NULL) Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 24/47] iwlwifi: mvm: add per rate tx stats Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 25/47] iwlwifi: mvm: replace BUG_ON by WARN_ON in scan.c Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 26/47] iwlwifi: mvm: deprecate -7 firmware Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 27/47] iwlwifi: mvm: Change scan fragmentation condition Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 28/47] iwlwifi: mvm: Fix scan parameters units Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 29/47] iwlwifi: remove IWL_UCODE_TLV_FLAGS_NEWBT_COEX TLV flag Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 30/47] iwlwifi: remove IWL_UCODE_TLV_FLAGS_PM_CMD_SUPPORT flag Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 31/47] iwlwifi: remove IWL_UCODE_TLV_FLAGS_RX_ENERGY_API flag Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 32/47] iwlwifi: remove IWL_UCODE_TLV_FLAGS_TIME_EVENT_API_V2 flag Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 33/47] iwlwifi: remove IWL_UCODE_TLV_FLAGS_BF_UPDATED flag Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 34/47] iwlwifi: remove IWL_UCODE_TLV_FLAGS_D3_CONTINUITY_API flag Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 35/47] iwlwifi: remove IWL_UCODE_TLV_FLAGS_SCHED_SCAN flag Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 36/47] iwlwifi: remove IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT flag Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 37/47] iwlwifi: remove IWL_UCODE_TLV_FLAGS_STA_KEY_CMD flag Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 38/47] iwlwifi: remove IWL_UCODE_TLV_FLAGS_DEVICE_PS_CMD flag Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 39/47] iwlwifi: mvm: BT Coex - don't use comma operator Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 40/47] iwlwifi: mvm: BT Coex - minor API change Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 41/47] iwlwifi: mvm: BT Coex - send priority tables from iwl_send_bt_init_conf Emmanuel Grumbach
2014-04-13 19:19 ` Emmanuel Grumbach [this message]
2014-04-13 19:19 ` [PATCH 43/47] iwlwifi: 7000: bump firmware API version to 9 Emmanuel Grumbach
2014-04-13 19:19 ` [PATCH 44/47] iwlwifi: mvm: don't use d3 fw if d0i3 is used Emmanuel Grumbach
2014-04-13 19:20 ` [PATCH 45/47] iwlwifi: mvm: replace leading spaces by tabs Emmanuel Grumbach
2014-04-13 19:20 ` [PATCH 46/47] iwlwifi: mvm: Re-factor enabling uAPSD logic Emmanuel Grumbach
2014-04-13 19:20 ` [PATCH 47/47] iwlwifi: don't disable SCD chain extension on newer devices Emmanuel Grumbach
2014-04-13 19:25 ` pull request: iwlwifi 2014-04-13 Emmanuel Grumbach
2014-04-22 20:07   ` 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=1397416802-32403-42-git-send-email-egrumbach@gmail.com \
    --to=egrumbach@gmail.com \
    --cc=alexander.bondar@intel.com \
    --cc=emmanuel.grumbach@intel.com \
    --cc=haim.dreyfuss@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).