<div dir="ltr"><div><span style="font-family:arial,sans-serif">Hi Jouni,</span></div><span style="font-family:arial,sans-serif"><div><span style="font-family:arial,sans-serif"><br></span></div>&gt;This seems to be causing failures in hwsim test cases. I&#39;m not</span><br style="font-family:arial,sans-serif">


<span style="font-family:arial,sans-serif">&gt;completely sure why, but the logs seems to imply that this case is hit</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">&gt;and the P2P state machine is then stuck in waiting for something that</span><br style="font-family:arial,sans-serif">


<span style="font-family:arial,sans-serif">&gt;never happens. It looks like this can happen at least when P2P_LISTEN is</span><br style="font-family:arial,sans-serif"><span style="font-family:arial,sans-serif">&gt;issued while a p2p_scan from a previously started P2P_FIND is in</span><br style="font-family:arial,sans-serif">


<span style="font-family:arial,sans-serif">&gt;progress.</span><br><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">I ran hwsim and fixed a case where the listen was getting stuck (the p2p_find case that you mentioned). Please</span></div>

<div><span style="font-family:arial,sans-serif">find the revised patch below. But when I run the hwsim there were other failures which seems to occur with or without this patch.</span></div><div><span style="font-family:arial,sans-serif">I couldn&#39;t figure out the cause of the failure as the group formation seems to succeed, but the result shows as failed. :(</span></div>

<div><span style="font-family:arial,sans-serif"><br></span></div><div><div style><font face="arial, sans-serif">Signed-off-by: Jithu Jance &lt;<a href="mailto:jithu@broadcom.com">jithu@broadcom.com</a>&gt;</font></div><div style>

<font face="arial, sans-serif">---</font></div><div style><font face="arial, sans-serif"> src/p2p/p2p.c |   28 ++++++++++++++++++++--------</font></div><div style><font face="arial, sans-serif"> 1 file changed, 20 insertions(+), 8 deletions(-)</font></div>

<div style><font face="arial, sans-serif"><br></font></div><div style><font face="arial, sans-serif">diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c</font></div><div style><font face="arial, sans-serif">index c2f8d9b..7b2d43b 100644</font></div>

<div style><font face="arial, sans-serif">--- a/src/p2p/p2p.c</font></div><div style><font face="arial, sans-serif">+++ b/src/p2p/p2p.c</font></div><div style><font face="arial, sans-serif">@@ -238,6 +238,12 @@ static void p2p_listen_in_find(struct p2p_data *p2p, int dev_disc)</font></div>

<div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">        </span>p2p_dbg(p2p, &quot;Starting short listen state (state=%s)&quot;,</font></div><div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">                </span>p2p_state_txt(p2p-&gt;state));</font></div>

<div style><font face="arial, sans-serif"><br></font></div><div style><font face="arial, sans-serif">+<span class="" style="white-space:pre">        </span>if (p2p-&gt;pending_listen_freq) {</font></div><div style><font face="arial, sans-serif">+<span class="" style="white-space:pre">                </span>/* We have a pending p2p_listen request */</font></div>

<div style><font face="arial, sans-serif">+<span class="" style="white-space:pre">                </span>p2p_dbg(p2p, &quot;p2p_listen command pending already&quot;);</font></div><div style><font face="arial, sans-serif">+<span class="" style="white-space:pre">                </span>return;</font></div>

<div style><font face="arial, sans-serif">+<span class="" style="white-space:pre">        </span>}</font></div><div style><font face="arial, sans-serif">+</font></div><div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">        </span>freq = p2p_channel_to_freq(p2p-&gt;cfg-&gt;reg_class, p2p-&gt;cfg-&gt;channel);</font></div>

<div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">        </span>if (freq &lt; 0) {</font></div><div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">                </span>p2p_dbg(p2p, &quot;Unknown regulatory class/channel&quot;);</font></div>

<div style><font face="arial, sans-serif">@@ -260,14 +266,14 @@ static void p2p_listen_in_find(struct p2p_data *p2p, int dev_disc)</font></div><div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">                </span>return;</font></div>

<div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">        </span>}</font></div><div style><font face="arial, sans-serif"><br></font></div><div style><font face="arial, sans-serif">-<span class="" style="white-space:pre">        </span>p2p-&gt;pending_listen_freq = freq;</font></div>

<div style><font face="arial, sans-serif">-<span class="" style="white-space:pre">        </span>p2p-&gt;pending_listen_sec = 0;</font></div><div style><font face="arial, sans-serif">-<span class="" style="white-space:pre">        </span>p2p-&gt;pending_listen_usec = 1024 * tu;</font></div>

<div style><font face="arial, sans-serif">-</font></div><div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">        </span>ies = p2p_build_probe_resp_ies(p2p);</font></div><div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">        </span>if (ies == NULL)</font></div>

<div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">                </span>return;</font></div><div style><font face="arial, sans-serif"><br></font></div><div style><font face="arial, sans-serif">+<span class="" style="white-space:pre">        </span>p2p-&gt;pending_listen_freq = freq;</font></div>

<div style><font face="arial, sans-serif">+<span class="" style="white-space:pre">        </span>p2p-&gt;pending_listen_sec = 0;</font></div><div style><font face="arial, sans-serif">+<span class="" style="white-space:pre">        </span>p2p-&gt;pending_listen_usec = 1024 * tu;</font></div>

<div style><font face="arial, sans-serif">+</font></div><div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">        </span>if (p2p-&gt;cfg-&gt;start_listen(p2p-&gt;cfg-&gt;cb_ctx, freq, 1024 * tu / 1000,</font></div>

<div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">                </span>    ies) &lt; 0) {</font></div><div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">                </span>p2p_dbg(p2p, &quot;Failed to start listen mode&quot;);</font></div>

<div style><font face="arial, sans-serif">@@ -284,16 +290,18 @@ int p2p_listen(struct p2p_data *p2p, unsigned int timeout)</font></div><div style><font face="arial, sans-serif"><br></font></div><div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">        </span>p2p_dbg(p2p, &quot;Going to listen(only) state&quot;);</font></div>

<div style><font face="arial, sans-serif"><br></font></div><div style><font face="arial, sans-serif">+<span class="" style="white-space:pre">        </span>if (p2p-&gt;pending_listen_freq) {</font></div><div style><font face="arial, sans-serif">+<span class="" style="white-space:pre">                </span>/* We have a pending p2p_listen request */</font></div>

<div style><font face="arial, sans-serif">+<span class="" style="white-space:pre">                </span>p2p_dbg(p2p, &quot;p2p_listen command pending already&quot;);</font></div><div style><font face="arial, sans-serif">+<span class="" style="white-space:pre">                </span>return -1;</font></div>

<div style><font face="arial, sans-serif">+<span class="" style="white-space:pre">        </span>}</font></div><div style><font face="arial, sans-serif">+</font></div><div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">        </span>freq = p2p_channel_to_freq(p2p-&gt;cfg-&gt;reg_class, p2p-&gt;cfg-&gt;channel);</font></div>

<div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">        </span>if (freq &lt; 0) {</font></div><div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">                </span>p2p_dbg(p2p, &quot;Unknown regulatory class/channel&quot;);</font></div>

<div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">                </span>return -1;</font></div><div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">        </span>}</font></div><div style>

<font face="arial, sans-serif"><br></font></div><div style><font face="arial, sans-serif">-<span class="" style="white-space:pre">        </span>p2p-&gt;pending_listen_freq = freq;</font></div><div style><font face="arial, sans-serif">-<span class="" style="white-space:pre">        </span>p2p-&gt;pending_listen_sec = timeout / 1000;</font></div>

<div style><font face="arial, sans-serif">-<span class="" style="white-space:pre">        </span>p2p-&gt;pending_listen_usec = (timeout % 1000) * 1000;</font></div><div style><font face="arial, sans-serif">-</font></div><div style>

<font face="arial, sans-serif"> <span class="" style="white-space:pre">        </span>if (p2p-&gt;p2p_scan_running) {</font></div><div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">                </span>if (p2p-&gt;start_after_scan == P2P_AFTER_SCAN_CONNECT) {</font></div>

<div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">                        </span>p2p_dbg(p2p, &quot;p2p_scan running - connect is already pending - skip listen&quot;);</font></div><div style><font face="arial, sans-serif">@@ -308,6 +316,10 @@ int p2p_listen(struct p2p_data *p2p, unsigned int timeout)</font></div>

<div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">        </span>if (ies == NULL)</font></div><div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">                </span>return -1;</font></div>

<div style><font face="arial, sans-serif"><br></font></div><div style><font face="arial, sans-serif">+<span class="" style="white-space:pre">        </span>p2p-&gt;pending_listen_freq = freq;</font></div><div style><font face="arial, sans-serif">+<span class="" style="white-space:pre">        </span>p2p-&gt;pending_listen_sec = timeout / 1000;</font></div>

<div style><font face="arial, sans-serif">+<span class="" style="white-space:pre">        </span>p2p-&gt;pending_listen_usec = (timeout % 1000) * 1000;</font></div><div style><font face="arial, sans-serif">+</font></div><div style>

<font face="arial, sans-serif"> <span class="" style="white-space:pre">        </span>if (p2p-&gt;cfg-&gt;start_listen(p2p-&gt;cfg-&gt;cb_ctx, freq, timeout, ies) &lt; 0) {</font></div><div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">                </span>p2p_dbg(p2p, &quot;Failed to start listen mode&quot;);</font></div>

<div style><font face="arial, sans-serif"> <span class="" style="white-space:pre">                </span>p2p-&gt;pending_listen_freq = 0;</font></div><div style><font face="arial, sans-serif">--</font></div><div style><font face="arial, sans-serif">1.7.9.5</font></div>

<div style="font-family:arial,sans-serif"><br></div></div>
<div class="gmail_extra"><br clear="all"><div><div><br></div><div><br></div><div><br></div><div><b style="color:rgb(102,102,102)"><font face="&#39;courier new&#39;, monospace">&gt; Jithu Jance</font></b></div><div><b style="color:rgb(102,102,102)"><font face="&#39;courier new&#39;, monospace"><br>


</font></b></div><div><br></div><div><b><font face="&#39;courier new&#39;, monospace"><br></font></b></div></div>
<br><br><div class="gmail_quote">On Mon, May 12, 2014 at 1:19 AM, Jouni Malinen <span dir="ltr">&lt;<a href="mailto:j@w1.fi" target="_blank">j@w1.fi</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


<div>On Wed, May 07, 2014 at 02:02:06PM +0530, Jithu Jance wrote:<br>
&gt; If p2p_listen is called while previous listen command&#39;s<br>
&gt; remain_on_channel event is pending, the p2p_listen would fail<br>
&gt; and it used to clear pending_listen_freq. Now when the remain-<br>
&gt; on-channel event comes from the driver, the pending_listen_freq<br>
&gt; doesn&#39;t match and gets ignored. This was leading to a case<br>
&gt; where listen state was getting stuck (in case of WAIT_PEER_CONNECT<br>
&gt; state).<br>
<br>
</div>&gt; diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c<br>
<div>&gt; @@ -284,6 +284,12 @@ int p2p_listen(struct p2p_data *p2p, unsigned int timeout)<br>
&gt;       p2p_dbg(p2p, &quot;Going to listen(only) state&quot;);<br>
&gt;<br>
&gt; +     if (p2p-&gt;pending_listen_freq) {<br>
&gt; +             /* We have a pending p2p_listen request */<br>
&gt; +             p2p_dbg(p2p, &quot;p2p_listen command pending already&quot;);<br>
&gt; +             return -1;<br>
&gt; +     }<br>
<br>
</div>This seems to be causing failures in hwsim test cases. I&#39;m not<br>
completely sure why, but the logs seems to imply that this case is hit<br>
and the P2P state machine is then stuck in waiting for something that<br>
never happens. It looks like this can happen at least when P2P_LISTEN is<br>
issued while a p2p_scan from a previously started P2P_FIND is in<br>
progress.<br>
<span><font color="#888888"><br>
--<br>
Jouni Malinen                                            PGP id EFC895FA<br>
</font></span><div><div>_______________________________________________<br>
HostAP mailing list<br>
<a href="mailto:HostAP@lists.shmoo.com" target="_blank">HostAP@lists.shmoo.com</a><br>
<a href="http://lists.shmoo.com/mailman/listinfo/hostap" target="_blank">http://lists.shmoo.com/mailman/listinfo/hostap</a><br>
</div></div></blockquote></div><br></div></div>