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

Ilan Peer ilan.peer
Mon Jul 7 04:21:16 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 3af6bd3..3d50b89 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -4737,7 +4737,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 5d9bf56..dc896e5 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -2773,7 +2773,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 */
 }
 
@@ -2884,7 +2884,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 c043950..89d1d0a 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -143,7 +143,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
@@ -6851,7 +6852,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;
@@ -6887,7 +6889,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);
 }
@@ -8234,7 +8236,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);
 }
@@ -8334,7 +8337,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;
 
@@ -8353,6 +8357,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);
 	}
 }
@@ -8376,7 +8394,8 @@ 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 841d6df..197f0ad 100644
--- a/wpa_supplicant/p2p_supplicant.h
+++ b/wpa_supplicant/p2p_supplicant.h
@@ -144,7 +144,19 @@ int wpas_p2p_probe_req_rx(struct wpa_supplicant *wpa_s, const u8 *addr,
 			  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_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);
+
 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.7.10.4




More information about the Hostap mailing list