P2P: Do not stop Listen state if it is on correct channel

This is needed to optimize response to GO Negotiation Request frames.
The extra remain-on-channel cancel followed by new remain-on-channel for
the same channel takes too much time with some driver/firmware
designs for the response to go out quickly enough to avoid peer
timing out while waiting for our response.
This commit is contained in:
Jouni Malinen 2010-10-20 19:37:47 +03:00 committed by Jouni Malinen
parent 35c5d61037
commit 0b8889d8e5
3 changed files with 24 additions and 3 deletions

View file

@ -783,7 +783,7 @@ int p2p_find(struct p2p_data *p2p, unsigned int timeout,
}
void p2p_stop_find(struct p2p_data *p2p)
void p2p_stop_find_for_freq(struct p2p_data *p2p, int freq)
{
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Stopping find");
eloop_cancel_timeout(p2p_find_timeout, p2p, NULL);
@ -793,10 +793,21 @@ void p2p_stop_find(struct p2p_data *p2p)
p2p->go_neg_peer = NULL;
p2p->sd_peer = NULL;
p2p->invite_peer = NULL;
if (freq > 0 && p2p->drv_in_listen == freq && p2p->in_listen) {
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Skip stop_listen "
"since we are on correct channel for response");
return;
}
p2p->cfg->stop_listen(p2p->cfg->cb_ctx);
}
void p2p_stop_find(struct p2p_data *p2p)
{
p2p_stop_find_for_freq(p2p, 0);
}
static int p2p_prepare_channel(struct p2p_data *p2p, unsigned int force_freq)
{
if (force_freq) {
@ -2193,7 +2204,7 @@ void p2p_listen_cb(struct p2p_data *p2p, unsigned int freq,
p2p->pending_listen_sec, p2p->pending_listen_usec,
p2p->pending_listen_freq);
p2p->in_listen = 1;
p2p->drv_in_listen = 1;
p2p->drv_in_listen = freq;
if (p2p->pending_listen_sec || p2p->pending_listen_usec) {
/*
* Add 20 msec extra wait to avoid race condition with driver