Commit 3249ba73 authored by Amitkumar Karwar's avatar Amitkumar Karwar Committed by John W. Linville

mwifiex: fix simultaneous scan and Tx traffic problem

If scan operation is started when Tx traffic is already running,
driver locks Tx queue until it gets completed. With this logic
there is a delay for Tx packets.

This patch implements new approach to give Tx path higher priority
in this case. Driver internally sends multiple synchronous scan
commands to firmware when scan is requested by user. Now we will
make sure that Tx queue is empty everytime before sending next scan
command. If Tx queue isn't empty scan command will be postponsed by
20msec. This rule will be followed until Tx queue becomes empty or
timeout of 1 second happens. In case of timeout scan operation will
be aborted.
Signed-off-by: default avatarAmitkumar Karwar <akarwar@marvell.com>
Signed-off-by: default avatarBing Zhao <bzhao@marvell.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 38e8b7d9
...@@ -57,6 +57,68 @@ static int mwifiex_add_bss_prio_tbl(struct mwifiex_private *priv) ...@@ -57,6 +57,68 @@ static int mwifiex_add_bss_prio_tbl(struct mwifiex_private *priv)
return 0; return 0;
} }
static void scan_delay_timer_fn(unsigned long data)
{
struct mwifiex_private *priv = (struct mwifiex_private *)data;
struct mwifiex_adapter *adapter = priv->adapter;
struct cmd_ctrl_node *cmd_node, *tmp_node;
unsigned long flags;
if (!mwifiex_wmm_lists_empty(adapter)) {
if (adapter->scan_delay_cnt == MWIFIEX_MAX_SCAN_DELAY_CNT) {
/*
* Abort scan operation by cancelling all pending scan
* command
*/
spin_lock_irqsave(&adapter->scan_pending_q_lock, flags);
list_for_each_entry_safe(cmd_node, tmp_node,
&adapter->scan_pending_q,
list) {
list_del(&cmd_node->list);
cmd_node->wait_q_enabled = false;
mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
}
spin_unlock_irqrestore(&adapter->scan_pending_q_lock,
flags);
spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
adapter->scan_processing = false;
spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock,
flags);
if (priv->user_scan_cfg) {
dev_dbg(priv->adapter->dev,
"info: %s: scan aborted\n", __func__);
cfg80211_scan_done(priv->scan_request, 1);
priv->scan_request = NULL;
kfree(priv->user_scan_cfg);
priv->user_scan_cfg = NULL;
}
} else {
/*
* Tx data queue is still not empty, delay scan
* operation further by 20msec.
*/
mod_timer(&priv->scan_delay_timer, jiffies +
msecs_to_jiffies(MWIFIEX_SCAN_DELAY_MSEC));
adapter->scan_delay_cnt++;
}
} else {
/*
* Tx data queue is empty. Get scan command from scan_pending_q
* and put to cmd_pending_q to resume scan operation
*/
adapter->scan_delay_cnt = 0;
spin_lock_irqsave(&adapter->scan_pending_q_lock, flags);
cmd_node = list_first_entry(&adapter->scan_pending_q,
struct cmd_ctrl_node, list);
list_del(&cmd_node->list);
spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags);
mwifiex_insert_cmd_to_pending_q(adapter, cmd_node, true);
}
}
/* /*
* This function initializes the private structure and sets default * This function initializes the private structure and sets default
* values to the members. * values to the members.
...@@ -136,6 +198,9 @@ static int mwifiex_init_priv(struct mwifiex_private *priv) ...@@ -136,6 +198,9 @@ static int mwifiex_init_priv(struct mwifiex_private *priv)
priv->scan_block = false; priv->scan_block = false;
setup_timer(&priv->scan_delay_timer, scan_delay_timer_fn,
(unsigned long)priv);
return mwifiex_add_bss_prio_tbl(priv); return mwifiex_add_bss_prio_tbl(priv);
} }
......
...@@ -244,8 +244,8 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter) ...@@ -244,8 +244,8 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter)
} }
} }
if (!adapter->scan_processing && !adapter->data_sent && if ((!adapter->scan_processing || adapter->scan_delay_cnt) &&
!mwifiex_wmm_lists_empty(adapter)) { !adapter->data_sent && !mwifiex_wmm_lists_empty(adapter)) {
mwifiex_wmm_process_tx(adapter); mwifiex_wmm_process_tx(adapter);
if (adapter->hs_activated) { if (adapter->hs_activated) {
adapter->is_hs_configured = false; adapter->is_hs_configured = false;
......
...@@ -87,6 +87,9 @@ enum { ...@@ -87,6 +87,9 @@ enum {
#define MWIFIEX_MAX_TOTAL_SCAN_TIME (MWIFIEX_TIMER_10S - MWIFIEX_TIMER_1S) #define MWIFIEX_MAX_TOTAL_SCAN_TIME (MWIFIEX_TIMER_10S - MWIFIEX_TIMER_1S)
#define MWIFIEX_MAX_SCAN_DELAY_CNT 50
#define MWIFIEX_SCAN_DELAY_MSEC 20
#define RSN_GTK_OUI_OFFSET 2 #define RSN_GTK_OUI_OFFSET 2
#define MWIFIEX_OUI_NOT_PRESENT 0 #define MWIFIEX_OUI_NOT_PRESENT 0
...@@ -482,6 +485,7 @@ struct mwifiex_private { ...@@ -482,6 +485,7 @@ struct mwifiex_private {
u16 proberesp_idx; u16 proberesp_idx;
u16 assocresp_idx; u16 assocresp_idx;
u16 rsn_idx; u16 rsn_idx;
struct timer_list scan_delay_timer;
}; };
enum mwifiex_ba_status { enum mwifiex_ba_status {
...@@ -686,6 +690,7 @@ struct mwifiex_adapter { ...@@ -686,6 +690,7 @@ struct mwifiex_adapter {
struct completion fw_load; struct completion fw_load;
u8 country_code[IEEE80211_COUNTRY_STRING_LEN]; u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
u16 max_mgmt_ie_index; u16 max_mgmt_ie_index;
u8 scan_delay_cnt;
}; };
int mwifiex_init_lock_list(struct mwifiex_adapter *adapter); int mwifiex_init_lock_list(struct mwifiex_adapter *adapter);
......
...@@ -1771,15 +1771,24 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, ...@@ -1771,15 +1771,24 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
kfree(priv->user_scan_cfg); kfree(priv->user_scan_cfg);
priv->user_scan_cfg = NULL; priv->user_scan_cfg = NULL;
} }
} else {
if (!mwifiex_wmm_lists_empty(adapter)) {
spin_unlock_irqrestore(&adapter->scan_pending_q_lock,
flags);
adapter->scan_delay_cnt = 1;
mod_timer(&priv->scan_delay_timer, jiffies +
msecs_to_jiffies(MWIFIEX_SCAN_DELAY_MSEC));
} else { } else {
/* Get scan command from scan_pending_q and put to /* Get scan command from scan_pending_q and put to
cmd_pending_q */ cmd_pending_q */
cmd_node = list_first_entry(&adapter->scan_pending_q, cmd_node = list_first_entry(&adapter->scan_pending_q,
struct cmd_ctrl_node, list); struct cmd_ctrl_node, list);
list_del(&cmd_node->list); list_del(&cmd_node->list);
spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags); spin_unlock_irqrestore(&adapter->scan_pending_q_lock,
flags);
mwifiex_insert_cmd_to_pending_q(adapter, cmd_node, true); mwifiex_insert_cmd_to_pending_q(adapter, cmd_node,
true);
}
} }
done: done:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment