[PATCH 2/5] wpa_supplicant: NAN: USD: Improve concurrency with other interfaces

Andrei Otcheretianski andrei.otcheretianski at intel.com
Thu Oct 23 03:45:31 PDT 2025


From: Ilan Peer <ilan.peer at intel.com>

Notify USD logic about interface state changes so it could configure
the USD (and NAN DE) operation to take into consideration the
concurrency with other interfaces sharing the same radio.
In particular:
- Consider P2P state, in order to allow P2P2 handshakes to
  complete during USD channel dwells.
- When a peer is locally authorized for connection, consider
  this as a indication that USD dwell time should be longer to
  allow the complete paring etc.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 wpa_supplicant/nan_usd.c        | 49 +++++++++++++++++++++++++++++++++
 wpa_supplicant/nan_usd.h        |  1 +
 wpa_supplicant/p2p_supplicant.c | 33 +++++++++++++++++-----
 wpa_supplicant/wpa_supplicant.c |  4 +++
 4 files changed, 80 insertions(+), 7 deletions(-)

diff --git a/wpa_supplicant/nan_usd.c b/wpa_supplicant/nan_usd.c
index b8eb4c41b7..63402027c4 100644
--- a/wpa_supplicant/nan_usd.c
+++ b/wpa_supplicant/nan_usd.c
@@ -615,3 +615,52 @@ int * wpas_nan_usd_all_freqs(struct wpa_supplicant *wpa_s)
 
 	return freqs;
 }
+
+
+void wpas_nan_usd_state_change_notif(struct wpa_supplicant *wpa_s)
+{
+	struct wpa_supplicant *ifs;
+	u32 n_active = 0;
+	struct nan_de_cfg cfg;
+
+	os_memset(&cfg, 0, sizeof(cfg));
+
+	if (!wpa_s->radio)
+		return;
+
+	dl_list_for_each(ifs, &wpa_s->radio->ifaces, struct wpa_supplicant,
+			 radio_list) {
+		if (ifs->wpa_state >= WPA_AUTHENTICATING)
+			n_active++;
+	}
+
+	wpa_printf(MSG_DEBUG,
+		   "NAN: state change notif: n_active=%u, p2p_in_progress=%u",
+		   n_active, wpas_p2p_in_progress(wpa_s));
+
+	if (n_active) {
+		cfg.n_max = 3;
+
+		if (!wpas_p2p_in_progress(wpa_s)) {
+			/* limit the USD operation on channel to 100 - 300 TUs
+			 * to allow more time for other interfaces
+			 */
+			cfg.n_min = 1;
+		} else {
+			/* limit the USD operation on channel to 200 - 300 TUs
+			 * to allow P2P operation to complete
+			 */
+			cfg.n_min = 2;
+		}
+
+		/* each 500 ms suspend USD operation for 300 ms */
+		cfg.cycle = 500;
+		cfg.suspend = 300;
+	}
+
+	dl_list_for_each(ifs, &wpa_s->radio->ifaces, struct wpa_supplicant,
+			 radio_list) {
+		if (ifs->nan_de)
+			nan_de_config(ifs->nan_de, &cfg);
+	}
+}
diff --git a/wpa_supplicant/nan_usd.h b/wpa_supplicant/nan_usd.h
index 6a43fb2417..f19cfb7c9d 100644
--- a/wpa_supplicant/nan_usd.h
+++ b/wpa_supplicant/nan_usd.h
@@ -45,5 +45,6 @@ void wpas_nan_usd_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s,
 					      unsigned int freq);
 void wpas_nan_usd_tx_wait_expire(struct wpa_supplicant *wpa_s);
 int * wpas_nan_usd_all_freqs(struct wpa_supplicant *wpa_s);
+void wpas_nan_usd_state_change_notif(struct wpa_supplicant *wpa_s);
 
 #endif /* NAN_USD_H */
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index da9d9bd41c..26f3513e13 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -39,7 +39,7 @@
 #include "wps_supplicant.h"
 #include "p2p_supplicant.h"
 #include "wifi_display.h"
-
+#include "nan_usd.h"
 
 /*
  * How many times to try to scan to find the GO before giving up on join
@@ -2898,6 +2898,12 @@ static void wpas_set_go_security_config(void *ctx,
 	struct wpa_supplicant *tmp, *ifs = NULL;
 	struct hostapd_data *hapd;
 
+	wpa_printf(MSG_DEBUG, "P2P: GO Security Config callback");
+
+#ifdef CONFIG_NAN_USD
+	wpas_nan_usd_state_change_notif(wpa_s);
+#endif /* CONFIG_NAN_USD */
+
 	if (!params->p2p2)
 		return;
 
@@ -2953,6 +2959,10 @@ static void wpas_go_neg_completed(void *ctx, struct p2p_go_neg_results *res)
 	}
 #endif /* CONFIG_PASN */
 
+#ifdef CONFIG_NAN_USD
+	wpas_nan_usd_state_change_notif(wpa_s);
+#endif /* CONFIG_NAN_USD */
+
 	if (res->status) {
 		wpa_msg_global(wpa_s, MSG_INFO,
 			       P2P_EVENT_GO_NEG_FAILURE "status=%d",
@@ -6167,15 +6177,24 @@ static int wpas_p2p_auth_go_neg(struct wpa_supplicant *wpa_s,
 				struct wpa_ssid *ssid, unsigned int pref_freq,
 				u16 bootstrap, const char *password)
 {
+	int ret;
+
 	if (persistent_group && wpa_s->conf->persistent_reconnect)
 		persistent_group = 2;
 
-	return p2p_authorize(wpa_s->global->p2p, peer_addr, wps_method,
-			     go_intent, own_interface_addr, force_freq,
-			     persistent_group, ssid ? ssid->ssid : NULL,
-			     ssid ? ssid->ssid_len : 0, pref_freq,
-			     wps_method == WPS_NFC ? wpa_s->p2p_oob_dev_pw_id :
-			     0, bootstrap, password);
+	ret = p2p_authorize(wpa_s->global->p2p, peer_addr, wps_method,
+			    go_intent, own_interface_addr, force_freq,
+			    persistent_group, ssid ? ssid->ssid : NULL,
+			    ssid ? ssid->ssid_len : 0, pref_freq,
+			    wps_method == WPS_NFC ? wpa_s->p2p_oob_dev_pw_id :
+			    0, bootstrap, password);
+	if (!ret) {
+		wpa_printf(MSG_DEBUG, "P2P: Peer authorized");
+#ifdef CONFIG_NAN_USD
+		wpas_nan_usd_state_change_notif(wpa_s);
+#endif /* CONFIG_NAN_USD */
+	}
+	return ret;
 }
 
 
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 317ca3d57d..b34d33944d 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -1335,6 +1335,10 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
 	if (update_fils_connect_params)
 		wpas_update_fils_connect_params(wpa_s);
 #endif /* CONFIG_FILS && IEEE8021X_EAPOL */
+
+#ifdef CONFIG_NAN_USD
+	wpas_nan_usd_state_change_notif(wpa_s);
+#endif /* CONFIG_NAN_USD */
 }
 
 
-- 
2.49.0




More information about the Hostap mailing list