]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
USD: Improve concurrency with other interfaces
authorIlan Peer <ilan.peer@intel.com>
Thu, 23 Oct 2025 10:45:31 +0000 (13:45 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 25 Jan 2026 16:51:04 +0000 (18:51 +0200)
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 to allow P2P2 handshakes to complete during USD
  channel dwells.
- When a peer is locally authorized for connection, consider this as an
  indication that USD dwell time should be longer to allow the complete
  pairing, etc.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
wpa_supplicant/nan_usd.c
wpa_supplicant/nan_usd.h
wpa_supplicant/p2p_supplicant.c
wpa_supplicant/wpa_supplicant.c

index 30e9012074f6815b16d361620a74e064836dfbb8..ed7929206ab503b2c24e9ca92d23e878b091ee12 100644 (file)
@@ -663,3 +663,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;
+       unsigned int n_active = 0;
+       struct nan_de_cfg cfg;
+
+       if (!wpa_s->radio)
+               return;
+
+       os_memset(&cfg, 0, sizeof(cfg));
+
+       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);
+       }
+}
index dd70409648cceb3756c9d2c6819acd473d3f2ba8..394a09c469bc615c4b60d2eb3a960393f2d337b6 100644 (file)
@@ -49,5 +49,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 */
index 05dd8bfa3f7d6a19effce4e8ff0c377ba3ad923e..875a1676e1eedfd32f193016118807b75fa5d0c9 100644 (file)
@@ -40,6 +40,7 @@
 #include "wps_supplicant.h"
 #include "p2p_supplicant.h"
 #include "wifi_display.h"
+#include "nan_usd.h"
 
 
 /*
@@ -2899,6 +2900,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;
 
@@ -2954,6 +2961,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",
@@ -6168,15 +6179,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;
 }
 
 
index aa620ef4e0809eb45973a94316af8ae064fc4c35..500ee97a40482ac1e69cdc1faeaef4b2a754cd04 100644 (file)
@@ -1323,6 +1323,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 */
 }