]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Optimize 40 MHz HT co-ex scan on AP
authorJouni Malinen <j@w1.fi>
Sun, 3 Nov 2013 15:43:40 +0000 (17:43 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 3 Nov 2013 17:51:06 +0000 (19:51 +0200)
Only scan the affected channels instead of all enabled channels when
determining whether the primary and secondary channel for HT40 needs to
be swapped. This speed up HT40 setup considerably on 5 GHz band.

Signed-hostap: Jouni Malinen <j@w1.fi>

src/ap/hw_features.c

index 7c4ef12ca8ad0ff750374dbc40b26cce777bdc70..e95e0e1af51992373ef0752f446c12ab80d5f66d 100644 (file)
@@ -532,6 +532,47 @@ static void ieee80211n_scan_channels_2g4(struct hostapd_iface *iface,
 }
 
 
+static void ieee80211n_scan_channels_5g(struct hostapd_iface *iface,
+                                       struct wpa_driver_scan_params *params)
+{
+       /* Scan only the affected frequency range */
+       int pri_freq;
+       int affected_start, affected_end;
+       int i, pos;
+       struct hostapd_hw_modes *mode;
+
+       if (iface->current_mode == NULL)
+               return;
+
+       pri_freq = hostapd_hw_get_freq(iface->bss[0], iface->conf->channel);
+       if (iface->conf->secondary_channel > 0) {
+               affected_start = pri_freq - 10;
+               affected_end = pri_freq + 30;
+       } else {
+               affected_start = pri_freq - 30;
+               affected_end = pri_freq + 10;
+       }
+       wpa_printf(MSG_DEBUG, "40 MHz affected channel range: [%d,%d] MHz",
+                  affected_start, affected_end);
+
+       mode = iface->current_mode;
+       params->freqs = os_calloc(mode->num_channels + 1, sizeof(int));
+       if (params->freqs == NULL)
+               return;
+       pos = 0;
+
+       for (i = 0; i < mode->num_channels; i++) {
+               struct hostapd_channel_data *chan = &mode->channels[i];
+               if (chan->flag & HOSTAPD_CHAN_DISABLED)
+                       continue;
+               if (chan->freq < affected_start ||
+                   chan->freq > affected_end)
+                       continue;
+               params->freqs[pos++] = chan->freq;
+       }
+}
+
+
 static int ieee80211n_check_40mhz(struct hostapd_iface *iface)
 {
        struct wpa_driver_scan_params params;
@@ -545,6 +586,8 @@ static int ieee80211n_check_40mhz(struct hostapd_iface *iface)
        os_memset(&params, 0, sizeof(params));
        if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G)
                ieee80211n_scan_channels_2g4(iface, &params);
+       else
+               ieee80211n_scan_channels_5g(iface, &params);
        if (hostapd_driver_scan(iface->bss[0], &params) < 0) {
                wpa_printf(MSG_ERROR, "Failed to request a scan of "
                           "neighboring BSSes");