From patchwork Thu May 22 06:55:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jithu Jance X-Patchwork-Id: 351367 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0DE9A14007C for ; Thu, 22 May 2014 16:56:25 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id C9D3B9C184; Thu, 22 May 2014 02:56:21 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bwb+A6LTSCm7; Thu, 22 May 2014 02:56:21 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id C813E9C192; Thu, 22 May 2014 02:56:15 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 241DD9C184 for ; Thu, 22 May 2014 02:56:14 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XZTpGePVW4FD for ; Thu, 22 May 2014 02:56:07 -0400 (EDT) Received: from mail-gw2-out.broadcom.com (mail-gw2-out.broadcom.com [216.31.210.63]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 366D09C192 for ; Thu, 22 May 2014 02:56:06 -0400 (EDT) X-IronPort-AV: E=Sophos;i="4.98,885,1392192000"; d="scan'208";a="30601552" Received: from irvexchcas07.broadcom.com (HELO IRVEXCHCAS07.corp.ad.broadcom.com) ([10.9.208.55]) by mail-gw2-out.broadcom.com with ESMTP; 21 May 2014 23:56:27 -0700 Received: from IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) by IRVEXCHCAS07.corp.ad.broadcom.com (10.9.208.55) with Microsoft SMTP Server (TLS) id 14.3.174.1; Wed, 21 May 2014 23:55:55 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) with Microsoft SMTP Server id 14.3.174.1; Wed, 21 May 2014 23:55:56 -0700 Received: from jithu?broadcom.com (lbblr-jithu01.ban.broadcom.com [10.132.24.37]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 4FBCD9F9F9 for ; Wed, 21 May 2014 23:55:55 -0700 (PDT) Date: Thu, 22 May 2014 12:25:53 +0530 From: Jithu Jance To: Subject: [PATCH 1/1] P2P: Avoid resetting pending_listen_freq if p2p_listen is pending Message-ID: MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com > > + p2p->pending_listen_freq = freq; > > + p2p->pending_listen_sec = timeout / 1000; > > + p2p->pending_listen_usec = (timeout % 1000) * 1000; > > It's not shown in the context here, but this moving of > p2p->pending_listen_{sec,usec} would lose information from the > p2p->p2p_scan_running case. That uses p2p->start_after_scan to > postpone > start of the listen operation and p2p_run_after_scan() expects > p2p->pending_listen_{sec,usec} to be set fror the > P2P_AFTER_SCAN_LISTEN > case. > I re-organised the code to take care of this case. Hope this is fine now. If p2p_listen is called while previous listen command's remain_on_channel event is pending, the p2p_listen would fail and it used to clear pending_listen_freq. Now when the remain- on-channel event comes from the driver, the pending_listen_freq doesn't match and gets ignored. This was leading to a case where listen state was getting stuck (in case of WAIT_PEER_CONNECT state). Signed-off-by: Jithu Jance --- src/p2p/p2p.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) -- 1.7.9.5 - Jithu Jance diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index c2f8d9b..08aecc1 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -238,6 +238,12 @@ static void p2p_listen_in_find(struct p2p_data *p2p, int dev_disc) p2p_dbg(p2p, "Starting short listen state (state=%s)", p2p_state_txt(p2p->state)); + if (p2p->pending_listen_freq) { + /* We have a pending p2p_listen request */ + p2p_dbg(p2p, "p2p_listen command pending already"); + return; + } + freq = p2p_channel_to_freq(p2p->cfg->reg_class, p2p->cfg->channel); if (freq < 0) { p2p_dbg(p2p, "Unknown regulatory class/channel"); @@ -260,14 +266,14 @@ static void p2p_listen_in_find(struct p2p_data *p2p, int dev_disc) return; } - p2p->pending_listen_freq = freq; - p2p->pending_listen_sec = 0; - p2p->pending_listen_usec = 1024 * tu; - ies = p2p_build_probe_resp_ies(p2p); if (ies == NULL) return; + p2p->pending_listen_freq = freq; + p2p->pending_listen_sec = 0; + p2p->pending_listen_usec = 1024 * tu; + if (p2p->cfg->start_listen(p2p->cfg->cb_ctx, freq, 1024 * tu / 1000, ies) < 0) { p2p_dbg(p2p, "Failed to start listen mode"); @@ -284,16 +290,21 @@ int p2p_listen(struct p2p_data *p2p, unsigned int timeout) p2p_dbg(p2p, "Going to listen(only) state"); + p2p->pending_listen_sec = timeout / 1000; + p2p->pending_listen_usec = (timeout % 1000) * 1000; + + if (p2p->pending_listen_freq) { + /* We have a pending p2p_listen request */ + p2p_dbg(p2p, "p2p_listen command pending already"); + return -1; + } + freq = p2p_channel_to_freq(p2p->cfg->reg_class, p2p->cfg->channel); if (freq < 0) { p2p_dbg(p2p, "Unknown regulatory class/channel"); return -1; } - p2p->pending_listen_freq = freq; - p2p->pending_listen_sec = timeout / 1000; - p2p->pending_listen_usec = (timeout % 1000) * 1000; - if (p2p->p2p_scan_running) { if (p2p->start_after_scan == P2P_AFTER_SCAN_CONNECT) { p2p_dbg(p2p, "p2p_scan running - connect is already pending - skip listen"); @@ -308,6 +319,8 @@ int p2p_listen(struct p2p_data *p2p, unsigned int timeout) if (ies == NULL) return -1; + p2p->pending_listen_freq = freq; + if (p2p->cfg->start_listen(p2p->cfg->cb_ctx, freq, timeout, ies) < 0) { p2p_dbg(p2p, "Failed to start listen mode"); p2p->pending_listen_freq = 0;