mwifiex: bring in scan channel gap feature
authorAvinash Patil <patila@marvell.com>
Fri, 12 Sep 2014 14:38:54 +0000 (20:08 +0530)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 15 Sep 2014 19:00:52 +0000 (15:00 -0400)
With scan channel gap when any station/AP is active, FW comes back
to connected channel for any pending data transfter after scanning each
channel.
We set scan channel gap TLV to FW in scan command when any of the
interface is active. This enables scan channel gap in FW.
Also when scan channel gap is enabled, we would scan maximum channels
allowed by FW.

Scan channel gap is supported only on FW with V15 FW API.

Signed-off-by: Avinash Patil <patila@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Marc Yang <yangyang@marvell.com>
Signed-off-by: Cathy Luo <cluo@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/mwifiex/cfg80211.c
drivers/net/wireless/mwifiex/cmdevt.c
drivers/net/wireless/mwifiex/fw.h
drivers/net/wireless/mwifiex/init.c
drivers/net/wireless/mwifiex/main.h
drivers/net/wireless/mwifiex/scan.c

index 740f7d0..2066abb 100644 (file)
@@ -1991,6 +1991,11 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy,
                user_scan_cfg->chan_list[i].scan_time = 0;
        }
 
+       if (priv->adapter->scan_chan_gap_enabled &&
+           mwifiex_is_any_intf_active(priv))
+               user_scan_cfg->scan_chan_gap =
+                                             priv->adapter->scan_chan_gap_time;
+
        ret = mwifiex_scan_networks(priv, user_scan_cfg);
        kfree(user_scan_cfg);
        if (ret) {
index fcc70ae..8559720 100644 (file)
@@ -1613,5 +1613,8 @@ int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
                adapter->if_ops.update_mp_end_port(adapter,
                                        le16_to_cpu(hw_spec->mp_end_port));
 
+       if (adapter->fw_api_ver == MWIFIEX_FW_V15)
+               adapter->scan_chan_gap_enabled = true;
+
        return 0;
 }
index 6a703ea..1eb6173 100644 (file)
@@ -170,7 +170,8 @@ enum MWIFIEX_802_11_PRIVACY_FILTER {
 #define TLV_TYPE_COALESCE_RULE      (PROPRIETARY_TLV_BASE_ID + 154)
 #define TLV_TYPE_KEY_PARAM_V2       (PROPRIETARY_TLV_BASE_ID + 156)
 #define TLV_TYPE_TDLS_IDLE_TIMEOUT  (PROPRIETARY_TLV_BASE_ID + 194)
-#define TLV_TYPE_API_REV           (PROPRIETARY_TLV_BASE_ID + 199)
+#define TLV_TYPE_SCAN_CHANNEL_GAP   (PROPRIETARY_TLV_BASE_ID + 197)
+#define TLV_TYPE_API_REV            (PROPRIETARY_TLV_BASE_ID + 199)
 
 #define MWIFIEX_TX_DATA_BUF_SIZE_2K        2048
 
@@ -653,6 +654,12 @@ struct mwifiex_ie_types_num_probes {
        __le16 num_probes;
 } __packed;
 
+struct mwifiex_ie_types_scan_chan_gap {
+       struct mwifiex_ie_types_header header;
+       /* time gap in TUs to be used between two consecutive channels scan */
+       __le16 chan_gap;
+} __packed;
+
 struct mwifiex_ie_types_wildcard_ssid_params {
        struct mwifiex_ie_types_header header;
        u8 max_ssid_length;
@@ -1249,6 +1256,7 @@ struct mwifiex_user_scan_cfg {
        u8 num_ssids;
        /* Variable number (fixed maximum) of channels to scan up */
        struct mwifiex_user_scan_chan chan_list[MWIFIEX_USER_SCAN_CHAN_MAX];
+       u16 scan_chan_gap;
 } __packed;
 
 struct ie_body {
index 80bda80..d99c6f6 100644 (file)
@@ -212,6 +212,7 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter)
        adapter->specific_scan_time = MWIFIEX_SPECIFIC_SCAN_CHAN_TIME;
        adapter->active_scan_time = MWIFIEX_ACTIVE_SCAN_CHAN_TIME;
        adapter->passive_scan_time = MWIFIEX_PASSIVE_SCAN_CHAN_TIME;
+       adapter->scan_chan_gap_time = MWIFIEX_DEF_SCAN_CHAN_GAP_TIME;
 
        adapter->scan_probes = 1;
 
index 5439963..c3d097c 100644 (file)
@@ -84,6 +84,7 @@ enum {
 #define MWIFIEX_PASSIVE_SCAN_CHAN_TIME 110
 #define MWIFIEX_ACTIVE_SCAN_CHAN_TIME  30
 #define MWIFIEX_SPECIFIC_SCAN_CHAN_TIME        30
+#define MWIFIEX_DEF_SCAN_CHAN_GAP_TIME  50
 
 #define SCAN_RSSI(RSSI)                                        (0x100 - ((u8)(RSSI)))
 
@@ -770,6 +771,7 @@ struct mwifiex_adapter {
        u16 specific_scan_time;
        u16 active_scan_time;
        u16 passive_scan_time;
+       u16 scan_chan_gap_time;
        u8 fw_bands;
        u8 adhoc_start_band;
        u8 config_bands;
@@ -839,6 +841,7 @@ struct mwifiex_adapter {
        struct memory_type_mapping *mem_type_mapping_tbl;
        u8 num_mem_types;
        u8 curr_mem_idx;
+       bool scan_chan_gap_enabled;
 };
 
 int mwifiex_init_lock_list(struct mwifiex_adapter *adapter);
@@ -1139,6 +1142,25 @@ mwifiex_11h_get_csa_closed_channel(struct mwifiex_private *priv)
        return priv->csa_chan;
 }
 
+static inline u8 mwifiex_is_any_intf_active(struct mwifiex_private *priv)
+{
+       struct mwifiex_private *priv_num;
+       int i;
+
+       for (i = 0; i < priv->adapter->priv_num; i++) {
+               priv_num = priv->adapter->priv[i];
+               if (priv_num) {
+                       if ((GET_BSS_ROLE(priv_num) == MWIFIEX_BSS_ROLE_UAP &&
+                            priv_num->bss_started) ||
+                           (GET_BSS_ROLE(priv_num) == MWIFIEX_BSS_ROLE_STA &&
+                            priv_num->media_connected))
+                               return 1;
+               }
+       }
+
+       return 0;
+}
+
 int mwifiex_init_shutdown_fw(struct mwifiex_private *priv,
                             u32 func_init_shutdown);
 int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *, u8);
@@ -1274,6 +1296,7 @@ void mwifiex_disable_all_tdls_links(struct mwifiex_private *priv);
 bool mwifiex_is_bss_in_11ac_mode(struct mwifiex_private *priv);
 u8 mwifiex_get_center_freq_index(struct mwifiex_private *priv, u8 band,
                                 u32 pri_chan, u8 chan_bw);
+int mwifiex_init_channel_scan_gap(struct mwifiex_adapter *adapter);
 
 #ifdef CONFIG_DEBUG_FS
 void mwifiex_debugfs_init(void);
index 0c9ed2c..2f86bb6 100644 (file)
@@ -799,6 +799,7 @@ mwifiex_config_scan(struct mwifiex_private *priv,
 {
        struct mwifiex_adapter *adapter = priv->adapter;
        struct mwifiex_ie_types_num_probes *num_probes_tlv;
+       struct mwifiex_ie_types_scan_chan_gap *chan_gap_tlv;
        struct mwifiex_ie_types_wildcard_ssid_params *wildcard_ssid_tlv;
        struct mwifiex_ie_types_bssid_list *bssid_tlv;
        u8 *tlv_pos;
@@ -939,6 +940,22 @@ mwifiex_config_scan(struct mwifiex_private *priv,
        else
                *max_chan_per_scan = MWIFIEX_DEF_CHANNELS_PER_SCAN_CMD;
 
+       if (user_scan_in->scan_chan_gap) {
+               *max_chan_per_scan = MWIFIEX_MAX_CHANNELS_PER_SPECIFIC_SCAN;
+               dev_dbg(adapter->dev, "info: scan: channel gap = %d\n",
+                       user_scan_in->scan_chan_gap);
+
+               chan_gap_tlv = (void *)tlv_pos;
+               chan_gap_tlv->header.type =
+                                        cpu_to_le16(TLV_TYPE_SCAN_CHANNEL_GAP);
+               chan_gap_tlv->header.len =
+                       cpu_to_le16(sizeof(chan_gap_tlv->chan_gap));
+               chan_gap_tlv->chan_gap =
+                                    cpu_to_le16((user_scan_in->scan_chan_gap));
+
+               tlv_pos += sizeof(struct mwifiex_ie_types_scan_chan_gap);
+       }
+
        /* If the input config or adapter has the number of Probes set,
           add tlv */
        if (num_probes) {