[PATCH 24/24] P2P: do not perform P2P GO CS in some cases

Ilan Peer ilan.peer
Mon May 19 00:06:21 PDT 2014


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 |   31 +++++++++++++++++++++++++------
 wpa_supplicant/p2p_supplicant.h |   14 +++++++++++++-
 4 files changed, 42 insertions(+), 10 deletions(-)

diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 167bf4b..fd0b421 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -4668,7 +4668,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 be0d35a..205337c 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -2775,7 +2775,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 */
 }
 
@@ -2887,7 +2887,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 1488d7c..dabdf7a 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -148,7 +148,8 @@ static void wpas_p2p_move_go(void *eloop_ctx, void *timeout_ctx);
 static void wpas_p2p_reconsider_moving_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);
+					 unsigned int num,
+					 enum wpas_p2p_channel_update_trig trig);
 
 /*
  * Get the number of concurrent channels that the HW can operate, but that are
@@ -6807,7 +6808,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, ind_chan;
 	struct wpa_used_freq_data *freqs = NULL;
@@ -6843,7 +6845,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);
 }
@@ -8188,7 +8190,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);
 }
@@ -8288,7 +8291,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;
 
@@ -8307,6 +8311,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_STATE_CHANGE ||
+		     trig == WPAS_P2P_CHANNEL_UPDATE_CS)) {
+			wpa_dbg(wpa_s, MSG_DEBUG, "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);
 	}
 }
@@ -8330,5 +8348,6 @@ void wpas_p2p_indicate_state_change(struct wpa_supplicant *wpa_s)
 		break;
 	}
 
-	wpas_p2p_update_channel_list(wpa_s);
+	wpas_p2p_update_channel_list(wpa_s,
+				     WPAS_P2P_CHANNEL_UPDATE_STATE_CHANGE);
 }
diff --git a/wpa_supplicant/p2p_supplicant.h b/wpa_supplicant/p2p_supplicant.h
index da67e0f..c7c6f71 100644
--- a/wpa_supplicant/p2p_supplicant.h
+++ b/wpa_supplicant/p2p_supplicant.h
@@ -119,7 +119,19 @@ int wpas_p2p_set_cross_connect(struct wpa_supplicant *wpa_s, int enabled);
 void wpas_p2p_notif_connected(struct wpa_supplicant *wpa_s);
 void wpas_p2p_notif_disconnected(struct wpa_supplicant *wpa_s);
 int wpas_p2p_notif_pbc_overlap(struct wpa_supplicant *wpa_s);
-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_STATE_CHANGE,
+	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);
+
 int wpas_p2p_cancel(struct wpa_supplicant *wpa_s);
 void wpas_p2p_interface_unavailable(struct wpa_supplicant *wpa_s);
 void wpas_p2p_update_best_channels(struct wpa_supplicant *wpa_s,
-- 
1.7.10.4




More information about the Hostap mailing list