P2P: Run full P2P_FIND scan after pending scan completes

If a P2P_FIND command is issued for running the initial full scan and
the attempt to start that full scan fails, the previous behavior was to
wait for the ongoing scan to complete and then continue p2p_find scan
iterations. However, this continued with the social channels scan
instead of the initial full scan. This could end up missing the full
scan completely.

Fix this by marking the full scan pending if the new scan cannot be
started immediately. Then start the initial full scan after the ongoing
scan completes before moving to social channel only scan iterations.
This applies both for the P2P_FIND_START_WITH_FULL (no specific
frequency set) and P2P_FIND_PROGRESSIVE cases since both of them start
with a single full scan round.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2017-03-13 17:05:55 +02:00 committed by Jouni Malinen
parent 8a5b0bbda6
commit 2c0ac6d613
2 changed files with 12 additions and 1 deletions

View File

@ -1010,7 +1010,13 @@ static void p2p_search(struct p2p_data *p2p)
}
p2p->cfg->stop_listen(p2p->cfg->cb_ctx);
if ((p2p->find_type == P2P_FIND_PROGRESSIVE &&
if (p2p->find_pending_full &&
(p2p->find_type == P2P_FIND_PROGRESSIVE ||
p2p->find_type == P2P_FIND_START_WITH_FULL)) {
type = P2P_SCAN_FULL;
p2p_dbg(p2p, "Starting search (pending full scan)");
p2p->find_pending_full = 0;
} else if ((p2p->find_type == P2P_FIND_PROGRESSIVE &&
(freq = p2p_get_next_prog_freq(p2p)) > 0) ||
(p2p->find_type == P2P_FIND_START_WITH_FULL &&
(freq = p2p->find_specified_freq) > 0)) {
@ -1236,6 +1242,7 @@ int p2p_find(struct p2p_data *p2p, unsigned int timeout,
p2p->pending_listen_freq = 0;
}
p2p->cfg->stop_listen(p2p->cfg->cb_ctx);
p2p->find_pending_full = 0;
p2p->find_type = type;
if (freq != 2412 && freq != 2437 && freq != 2462 && freq != 60480)
p2p->find_specified_freq = freq;
@ -1285,6 +1292,9 @@ int p2p_find(struct p2p_data *p2p, unsigned int timeout,
if (res != 0 && p2p->p2p_scan_running) {
p2p_dbg(p2p, "Failed to start p2p_scan - another p2p_scan was already running");
/* wait for the previous p2p_scan to complete */
if (type == P2P_FIND_PROGRESSIVE ||
(type == P2P_FIND_START_WITH_FULL && freq == 0))
p2p->find_pending_full = 1;
res = 0; /* do not report failure */
} else if (res != 0) {
p2p_dbg(p2p, "Failed to start p2p_scan");

View File

@ -441,6 +441,7 @@ struct p2p_data {
unsigned int last_p2p_find_timeout;
u8 last_prog_scan_class;
u8 last_prog_scan_chan;
unsigned int find_pending_full:1;
int p2p_scan_running;
enum p2p_after_scan {
P2P_AFTER_SCAN_NOTHING,