iwlwifi: Logic to control how frequent radio should be reset if needed
authorWey-Yi Guy <wey-yi.w.guy@intel.com>
Fri, 22 Jan 2010 22:22:45 +0000 (14:22 -0800)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 25 Jan 2010 21:36:20 +0000 (16:36 -0500)
Add additional logic for internal scan routine to control how
frequent this function should be performed.

The intent of this function is to reset/re-tune the radio and bring the
RF/PHY back to normal state, it does not make sense calling it too
frequent,
if reset the radio can not bring it back to normal state, it indicate
there are other reason to cause the radio not operate correctly.

Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/iwlwifi/iwl-dev.h
drivers/net/wireless/iwlwifi/iwl-scan.c

index 42cf1810b451c589ef0bb09722d0a17b527b6bc7..86d38ae2ec7e25ed09f5cab5ae51f14f484f9a40 100644 (file)
@@ -1076,6 +1076,7 @@ struct iwl_priv {
        unsigned long scan_start;
        unsigned long scan_pass_start;
        unsigned long scan_start_tsf;
+       unsigned long last_internal_scan_jiffies;
        void *scan;
        int scan_bands;
        struct cfg80211_scan_request *scan_request;
index 07fabbbfd567859e013a3f1e62f3b2347508a24e..08faafae8497722f1f45cf39d36883152b83d35a 100644 (file)
@@ -201,7 +201,8 @@ static void iwl_rx_scan_results_notif(struct iwl_priv *priv,
                       le32_to_cpu(notif->tsf_low) - priv->scan_start_tsf);
 #endif
 
-       priv->next_scan_jiffies = 0;
+       if (!priv->is_internal_short_scan)
+               priv->next_scan_jiffies = 0;
 }
 
 /* Service SCAN_COMPLETE_NOTIFICATION (0x84) */
@@ -247,7 +248,11 @@ static void iwl_rx_scan_complete_notif(struct iwl_priv *priv,
                        goto reschedule;
        }
 
-       priv->next_scan_jiffies = 0;
+       if (!priv->is_internal_short_scan)
+               priv->next_scan_jiffies = 0;
+       else
+               priv->last_internal_scan_jiffies = jiffies;
+
        IWL_DEBUG_INFO(priv, "Setting scan to off\n");
 
        clear_bit(STATUS_SCANNING, &priv->status);
@@ -546,6 +551,8 @@ EXPORT_SYMBOL(iwl_mac_hw_scan);
  * internal short scan, this function should only been called while associated.
  * It will reset and tune the radio to prevent possible RF related problem
  */
+#define IWL_DELAY_NEXT_INTERNAL_SCAN (HZ*1)
+
 int iwl_internal_short_hw_scan(struct iwl_priv *priv)
 {
        int ret = 0;
@@ -565,6 +572,13 @@ int iwl_internal_short_hw_scan(struct iwl_priv *priv)
                ret = -EAGAIN;
                goto out;
        }
+       if (priv->last_internal_scan_jiffies &&
+           time_after(priv->last_internal_scan_jiffies +
+                      IWL_DELAY_NEXT_INTERNAL_SCAN, jiffies)) {
+               IWL_DEBUG_SCAN(priv, "internal scan rejected\n");
+               goto out;
+       }
+
        priv->scan_bands = 0;
        if (priv->band == IEEE80211_BAND_5GHZ)
                priv->scan_bands |= BIT(IEEE80211_BAND_5GHZ);