From 217cf4991d8c434aa2f6881c3837979a2ed13893 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 5 Nov 2013 11:07:51 +0200 Subject: [PATCH] P2P: Add more debug prints for frequency selection This prints out get_shared_radio_freqs() results and related information from P2P operations to make debug logs more helpful for figuring out issues related to multi-channel concurrency. Signed-hostap: Jouni Malinen --- wpa_supplicant/p2p_supplicant.c | 8 ++++++-- wpa_supplicant/wpa_supplicant.c | 22 +++++++++++++++++++++- wpa_supplicant/wpa_supplicant_i.h | 2 ++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 25bf4e7e7..226acd691 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -124,7 +124,7 @@ static int wpas_p2p_stop_find_oper(struct wpa_supplicant *wpa_s); static int wpas_p2p_num_unused_channels(struct wpa_supplicant *wpa_s) { int *freqs; - int num; + int num, unused; freqs = os_calloc(wpa_s->num_multichan_concurrent, sizeof(int)); if (!freqs) @@ -134,7 +134,9 @@ static int wpas_p2p_num_unused_channels(struct wpa_supplicant *wpa_s) wpa_s->num_multichan_concurrent); os_free(freqs); - return wpa_s->num_multichan_concurrent - num; + unused = wpa_s->num_multichan_concurrent - num; + wpa_dbg(wpa_s, MSG_DEBUG, "P2P: num_unused_channels: %d", unused); + return unused; } @@ -164,6 +166,8 @@ static int wpas_p2p_valid_oper_freqs(struct wpa_supplicant *wpa_s, os_free(freqs); + dump_freq_array(wpa_s, "valid for P2P", p2p_freqs, j); + return j; } diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index c058a6e73..4388ad6b5 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -4009,6 +4009,18 @@ int wpas_wpa_is_in_progress(struct wpa_supplicant *wpa_s, int include_current) } +void dump_freq_array(struct wpa_supplicant *wpa_s, const char *title, + int *freq_array, unsigned int len) +{ + unsigned int i; + + wpa_dbg(wpa_s, MSG_DEBUG, "Shared frequencies (len=%u): %s", + len, title); + for (i = 0; i < len; i++) + wpa_dbg(wpa_s, MSG_DEBUG, "freq[%u]: %d", i, freq_array[i]); +} + + /* * Find the operating frequencies of any of the virtual interfaces that * are using the same radio as the current interface. @@ -4022,6 +4034,8 @@ int get_shared_radio_freqs(struct wpa_supplicant *wpa_s, int freq; unsigned int idx = 0, i; + wpa_dbg(wpa_s, MSG_DEBUG, + "Determining shared radio frequencies (max len %u)", len); os_memset(freq_array, 0, sizeof(int) * len); /* First add the frequency of the local interface */ @@ -4039,12 +4053,16 @@ int get_shared_radio_freqs(struct wpa_supplicant *wpa_s, if (freq > 0 && idx < len && (idx == 0 || freq_array[0] != freq)) freq_array[idx++] = freq; + dump_freq_array(wpa_s, "No get_radio_name", freq_array, idx); return idx; } rn = wpa_s->driver->get_radio_name(wpa_s->drv_priv); - if (rn == NULL || rn[0] == '\0') + if (rn == NULL || rn[0] == '\0') { + dump_freq_array(wpa_s, "get_radio_name failed", + freq_array, idx); return idx; + } for (ifs = wpa_s->global->ifaces; ifs && idx < len; ifs = ifs->next) { @@ -4074,5 +4092,7 @@ int get_shared_radio_freqs(struct wpa_supplicant *wpa_s, if (i == idx) freq_array[idx++] = freq; } + + dump_freq_array(wpa_s, "completed iteration", freq_array, idx); return idx; } diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index da536cb20..eed1053ad 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -863,6 +863,8 @@ int wpas_network_disabled(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid); int wpas_init_ext_pw(struct wpa_supplicant *wpa_s); +void dump_freq_array(struct wpa_supplicant *wpa_s, const char *title, + int *freq_array, unsigned int len); int get_shared_radio_freqs(struct wpa_supplicant *wpa_s, int *freq_array, unsigned int len);