UPSTREAM: mwifiex: scan less channels per scan command to improve Tx traffic
authorAmitkumar Karwar <akarwar@marvell.com>
Thu, 7 Jun 2012 04:12:42 +0000 (21:12 -0700)
committerOlof Johansson <olofj@chromium.org>
Wed, 20 Jun 2012 19:08:04 +0000 (12:08 -0700)
Currently 4 channels are scanned per scan command. if scan request
is issued by user during Tx traffic, radio will be out of channel
for "4 * per_chan_scan_time" for each scan command and will not be
able to receive Rx packets. This adds delay in data traffic. We can
minimize it by reducing number of channels scanned per scan command
in this scenario.

We can not always scan 1 channel per scan command due to limitation
of number of command buffers. So we add code to decide number of
channels scanned per scan command in associated state.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
BUG=chrome-os-partner:8707
TEST=ping+scan test

Change-Id: Ie18901f9306704509ddf7e42825b823131dc9a1d
Reviewed-on: https://gerrit-int.chromium.org/19352
Commit-Ready: Sam Leffler <sleffler@google.com>
Reviewed-by: Sam Leffler <sleffler@google.com>
Tested-by: Sam Leffler <sleffler@google.com>
drivers/net/wireless/mwifiex/scan.c

index d924afe..1b271ca 100644 (file)
 /* The maximum number of channels the firmware can scan per command */
 #define MWIFIEX_MAX_CHANNELS_PER_SPECIFIC_SCAN   14
 
-#define MWIFIEX_CHANNELS_PER_SCAN_CMD            4
+#define MWIFIEX_DEF_CHANNELS_PER_SCAN_CMD      4
+#define MWIFIEX_LIMIT_1_CHANNEL_PER_SCAN_CMD   15
+#define MWIFIEX_LIMIT_2_CHANNELS_PER_SCAN_CMD  27
+#define MWIFIEX_LIMIT_3_CHANNELS_PER_SCAN_CMD  35
 
 /* Memory needed to store a max sized Channel List TLV for a firmware scan */
 #define CHAN_TLV_MAX_SIZE  (sizeof(struct mwifiex_ie_types_header)         \
@@ -471,7 +474,7 @@ mwifiex_is_network_compatible(struct mwifiex_private *priv,
  * This routine is used for any scan that is not provided with a
  * specific channel list to scan.
  */
-static void
+static int
 mwifiex_scan_create_channel_list(struct mwifiex_private *priv,
                                 const struct mwifiex_user_scan_cfg
                                                        *user_scan_in,
@@ -528,6 +531,7 @@ mwifiex_scan_create_channel_list(struct mwifiex_private *priv,
                }
 
        }
+       return chan_idx;
 }
 
 /*
@@ -727,6 +731,7 @@ mwifiex_config_scan(struct mwifiex_private *priv,
        u32 num_probes;
        u32 ssid_len;
        u32 chan_idx;
+       u32 chan_num;
        u32 scan_type;
        u16 scan_dur;
        u8 channel;
@@ -850,7 +855,7 @@ mwifiex_config_scan(struct mwifiex_private *priv,
        if (*filtered_scan)
                *max_chan_per_scan = MWIFIEX_MAX_CHANNELS_PER_SPECIFIC_SCAN;
        else
-               *max_chan_per_scan = MWIFIEX_CHANNELS_PER_SCAN_CMD;
+               *max_chan_per_scan = MWIFIEX_DEF_CHANNELS_PER_SCAN_CMD;
 
        /* If the input config or adapter has the number of Probes set,
           add tlv */
@@ -962,13 +967,28 @@ mwifiex_config_scan(struct mwifiex_private *priv,
                        dev_dbg(adapter->dev,
                                "info: Scan: Scanning current channel only\n");
                }
-
+               chan_num = chan_idx;
        } else {
                dev_dbg(adapter->dev,
                        "info: Scan: Creating full region channel list\n");
-               mwifiex_scan_create_channel_list(priv, user_scan_in,
-                                                scan_chan_list,
-                                                *filtered_scan);
+               chan_num = mwifiex_scan_create_channel_list(priv, user_scan_in,
+                                                           scan_chan_list,
+                                                           *filtered_scan);
+       }
+
+       /*
+        * In associated state we will reduce the number of channels scanned per
+        * scan command to avoid any traffic delay/loss. This number is decided
+        * based on total number of channels to be scanned due to constraints
+        * of command buffers.
+        */
+       if (priv->media_connected) {
+               if (chan_num < MWIFIEX_LIMIT_1_CHANNEL_PER_SCAN_CMD)
+                       *max_chan_per_scan = 1;
+               else if (chan_num < MWIFIEX_LIMIT_2_CHANNELS_PER_SCAN_CMD)
+                       *max_chan_per_scan = 2;
+               else if (chan_num < MWIFIEX_LIMIT_3_CHANNELS_PER_SCAN_CMD)
+                       *max_chan_per_scan = 3;
        }
 }