]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Extend the listen time based on the active concurrent session
authorRashmi Ramanna <c_ramanr@qti.qualcomm.com>
Mon, 20 Jan 2014 20:55:09 +0000 (22:55 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 20 Jan 2014 20:55:09 +0000 (22:55 +0200)
A P2P Device while in the Listen state waiting to respond for the
obtained group negotiation request shall give a fair chance for other
concurrent sessions to use the shared radio by inducing an idle time
between the successive listen states. However, if there are no
concurrent operations, this idle time can be reduced.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

src/p2p/p2p.c
src/p2p/p2p.h
wpa_supplicant/p2p_supplicant.c

index 138ba16bdb008fec57790da552b06062edf6282b..0f722fb33e5c750c1eb1be9d33ceb6f7c9a05472 100644 (file)
@@ -3149,13 +3149,13 @@ static void p2p_timeout_connect_listen(struct p2p_data *p2p)
 
 static void p2p_timeout_wait_peer_connect(struct p2p_data *p2p)
 {
-       /*
-        * TODO: could remain constantly in Listen state for some time if there
-        * are no other concurrent uses for the radio. For now, go to listen
-        * state once per second to give other uses a chance to use the radio.
-        */
        p2p_set_state(p2p, P2P_WAIT_PEER_IDLE);
-       p2p_set_timeout(p2p, 0, 500000);
+
+       if (p2p->cfg->is_concurrent_session_active &&
+           p2p->cfg->is_concurrent_session_active(p2p->cfg->cb_ctx))
+               p2p_set_timeout(p2p, 0, 500000);
+       else
+               p2p_set_timeout(p2p, 0, 200000);
 }
 
 
index 25a91e77ee3837138a320ddcbdfbfad396f7d4d1..2ce6ea6a8324c852bdc0d426c7b405463c80d4e4 100644 (file)
@@ -789,6 +789,15 @@ struct p2p_config {
         */
        void (*presence_resp)(void *ctx, const u8 *src, u8 status,
                              const u8 *noa, size_t noa_len);
+
+       /**
+        * is_concurrent_session_active - Check whether concurrent session is
+        * active on other virtual interfaces
+        * @ctx: Callback context from cb_ctx
+        * Returns: 1 if concurrent session is active on other virtual interface
+        * or 0 if not.
+        */
+       int (*is_concurrent_session_active)(void *ctx);
 };
 
 
index 91ed508d29362c8617b0e2c7b9241b5ff235437b..5ef76148997ad77b8d3ca4cd29d2e2e419018f69 100644 (file)
@@ -3571,6 +3571,21 @@ static int wpas_go_connected(void *ctx, const u8 *dev_addr)
 }
 
 
+static int wpas_is_concurrent_session_active(void *ctx)
+{
+       struct wpa_supplicant *wpa_s = ctx;
+       struct wpa_supplicant *ifs;
+
+       for (ifs = wpa_s->global->ifaces; ifs; ifs = ifs->next) {
+               if (ifs == wpa_s)
+                       continue;
+               if (ifs->wpa_state > WPA_ASSOCIATED)
+                       return 1;
+       }
+       return 0;
+}
+
+
 static void wpas_p2p_debug_print(void *ctx, int level, const char *msg)
 {
        struct wpa_supplicant *wpa_s = ctx;
@@ -3685,6 +3700,7 @@ int wpas_p2p_init(struct wpa_global *global, struct wpa_supplicant *wpa_s)
        p2p.get_noa = wpas_get_noa;
        p2p.go_connected = wpas_go_connected;
        p2p.presence_resp = wpas_presence_resp;
+       p2p.is_concurrent_session_active = wpas_is_concurrent_session_active;
 
        os_memcpy(wpa_s->global->p2p_dev_addr, wpa_s->own_addr, ETH_ALEN);
        os_memcpy(p2p.dev_addr, wpa_s->global->p2p_dev_addr, ETH_ALEN);