[PATCH 10/17] P2P: Do not perform P2P GO CS in some cases

Ilan Peer ilan.peer
Mon Jul 27 12:24:27 PDT 2015


A P2P GO channel switch should not be triggered in all cases that
require channel list update. Specifically, a P2P GO CS should not
be triggered in case that the P2P GO state changed or in case that
that the P2P GO has just completed a CS.

To fix this, add reason code to wpas_p2p_channel_list_update() and
trigger CS flow only for the relevant cases.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 wpa_supplicant/ctrl_iface.c     |  2 +-
 wpa_supplicant/events.c         |  5 +++--
 wpa_supplicant/p2p_supplicant.c | 32 +++++++++++++++++++++++++-------
 wpa_supplicant/p2p_supplicant.h | 13 ++++++++++++-
 4 files changed, 41 insertions(+), 11 deletions(-)

diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index f7882ca..f3cedaa 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -5774,7 +5774,7 @@ static int p2p_ctrl_disallow_freq(struct wpa_supplicant *wpa_s,
 			   freq->min, freq->max);
 	}
 
-	wpas_p2p_update_channel_list(wpa_s);
+	wpas_p2p_update_channel_list(wpa_s, WPAS_P2P_CHANNEL_UPDATE_DISALLOW);
 	return 0;
 }
 
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 762e4bb..62d5cef 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -3019,7 +3019,7 @@ static void wpa_supplicant_update_channel_list(
 	}
 
 #ifdef CONFIG_P2P
-	wpas_p2p_update_channel_list(wpa_s);
+	wpas_p2p_update_channel_list(wpa_s, WPAS_P2P_CHANNEL_UPDATE_DRIVER);
 #endif /* CONFIG_P2P */
 }
 
@@ -3159,7 +3159,8 @@ static void wpa_supplicant_notify_avoid_freq(struct wpa_supplicant *wpa_s,
 		 * The update channel flow will also take care of moving a GO
 		 * from the unsafe frequency if needed
 		 */
-		wpas_p2p_update_channel_list(wpa_s);
+		wpas_p2p_update_channel_list(wpa_s,
+					     WPAS_P2P_CHANNEL_UPDATE_AVOID);
 	}
 #endif /* CONFIG_P2P */
 
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index b08bf09..b52580a 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -145,9 +145,10 @@ static void wpas_p2p_optimize_listen_channel(struct wpa_supplicant *wpa_s,
 					     struct wpa_used_freq_data *freqs,
 					     unsigned int num);
 static void wpas_p2p_move_go(void *eloop_ctx, void *timeout_ctx);
-static void wpas_p2p_consider_moving_gos(struct wpa_supplicant *wpa_s,
-					 struct wpa_used_freq_data *freqs,
-					 unsigned int num);
+static void
+wpas_p2p_consider_moving_gos(struct wpa_supplicant *wpa_s,
+			     struct wpa_used_freq_data *freqs, unsigned int num,
+			     enum wpas_p2p_channel_update_trig trig);
 static void wpas_p2p_reconsider_moving_go(void *eloop_ctx, void *timeout_ctx);
 
 
@@ -7000,7 +7001,8 @@ void wpas_p2p_pbc_overlap_cb(void *eloop_ctx, void *timeout_ctx)
 }
 
 
-void wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s)
+void wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s,
+				  enum wpas_p2p_channel_update_trig trig)
 {
 	struct p2p_channels chan, cli_chan;
 	struct wpa_used_freq_data *freqs = NULL;
@@ -7033,7 +7035,7 @@ void wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s)
 	 * possible that due to policy consideration, it would preferable to
 	 * move it to a frequency already used by other station interfaces.
 	 */
-	wpas_p2p_consider_moving_gos(wpa_s, freqs, num);
+	wpas_p2p_consider_moving_gos(wpa_s, freqs, num, trig);
 
 	os_free(freqs);
 }
@@ -8412,7 +8414,8 @@ static void wpas_p2p_reconsider_moving_go(void *eloop_ctx, void *timeout_ctx)
 	num = get_shared_radio_freqs_data(wpa_s, freqs, num);
 
 	/* previous attempt to move a GO was not possible try again. */
-	wpas_p2p_consider_moving_gos(wpa_s, freqs, num);
+	wpas_p2p_consider_moving_gos(wpa_s, freqs, num,
+				     WPAS_P2P_CHANNEL_UPDATE_ANY);
 
 	os_free(freqs);
 }
@@ -8513,7 +8516,8 @@ reschedule:
 
 static void wpas_p2p_consider_moving_gos(struct wpa_supplicant *wpa_s,
 					 struct wpa_used_freq_data *freqs,
-					 unsigned int num)
+					 unsigned int num,
+					 enum wpas_p2p_channel_update_trig trig)
 {
 	struct wpa_supplicant *ifs;
 
@@ -8532,6 +8536,20 @@ static void wpas_p2p_consider_moving_gos(struct wpa_supplicant *wpa_s,
 		    ifs->current_ssid->mode != WPAS_MODE_P2P_GO)
 			continue;
 
+		/*
+		 * The GO was just started or completed channel switch, no need
+		 * to move it
+		 */
+		if (wpa_s == ifs &&
+		    (trig == WPAS_P2P_CHANNEL_UPDATE_CS)) {
+			wpa_dbg(wpa_s, MSG_DEBUG,
+				"P2P: GO move - schedule re-consideration");
+			eloop_register_timeout(P2P_RECONSIDER_GO_MOVE_DELAY, 0,
+					       wpas_p2p_reconsider_moving_go,
+					       wpa_s, NULL);
+			continue;
+		}
+
 		wpas_p2p_consider_moving_one_go(ifs, freqs, num);
 	}
 }
diff --git a/wpa_supplicant/p2p_supplicant.h b/wpa_supplicant/p2p_supplicant.h
index b02f924..feaf2ca 100644
--- a/wpa_supplicant/p2p_supplicant.h
+++ b/wpa_supplicant/p2p_supplicant.h
@@ -161,7 +161,18 @@ int wpas_p2p_probe_req_rx(struct wpa_supplicant *wpa_s, const u8 *addr,
 			  unsigned int rx_freq, int ssi_signal);
 void wpas_p2p_wps_success(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
 			  int registrar);
-void wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s);
+
+enum wpas_p2p_channel_update_trig {
+	WPAS_P2P_CHANNEL_UPDATE_ANY = 0,
+	WPAS_P2P_CHANNEL_UPDATE_DRIVER,
+	WPAS_P2P_CHANNEL_UPDATE_AVOID,
+	WPAS_P2P_CHANNEL_UPDATE_DISALLOW,
+	WPAS_P2P_CHANNEL_UPDATE_CS,
+};
+
+void wpas_p2p_update_channel_list(struct wpa_supplicant *wpa_s,
+				  enum wpas_p2p_channel_update_trig trig);
+
 void wpas_p2p_update_best_channels(struct wpa_supplicant *wpa_s,
 				   int freq_24, int freq_5, int freq_overall);
 void wpas_p2p_rx_action(struct wpa_supplicant *wpa_s, const u8 *da,
-- 
1.9.1




More information about the Hostap mailing list