diff mbox series

[3/4] ACS: add supported channel BW checking

Message ID 20180301114929.420-4-dlebed@quantenna.com
State Accepted
Headers show
Series Implement supported channel BW checking | expand

Commit Message

Dmitrii Lebed March 1, 2018, 11:49 a.m. UTC
From: Dmitry Lebed <dlebed@quantenna.com>

While doing automatic channel selection we need
to take into account supported BW for each channel
provided via nl80211.
Without this modification hostapd can select unsupported
channel, will fail to use it and eventually will not start.

Signed-off-by: Dmitry Lebed <dlebed@quantenna.com>
---
 src/ap/acs.c | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

--
2.16.1



This email, including its contents and any attachment(s), may contain confidential information of Quantenna Communications, Inc. and is solely for the intended recipient(s). If you may have received this in error, please contact the sender and permanently delete this email, its contents and any attachment(s).
diff mbox series

Patch

diff --git a/src/ap/acs.c b/src/ap/acs.c
index aa5905894..9ce5ca8f6 100644
--- a/src/ap/acs.c
+++ b/src/ap/acs.c
@@ -13,6 +13,7 @@ 
 #include "utils/common.h"
 #include "utils/list.h"
 #include "common/ieee802_11_defs.h"
+#include "common/hw_features_common.h"
 #include "common/wpa_ctrl.h"
 #include "drivers/driver.h"
 #include "hostapd.h"
@@ -565,6 +566,7 @@  acs_find_ideal_chan(struct hostapd_iface *iface)
        long double factor, ideal_factor = 0;
        int i, j;
        int n_chans = 1;
+       u32 bw;
        unsigned int k;

        /* TODO: HT40- support */
@@ -583,12 +585,12 @@  acs_find_ideal_chan(struct hostapd_iface *iface)
            iface->conf->vht_oper_chwidth == 1)
                n_chans = 4;

+       bw = num_chan_to_bw(n_chans);
+
        /* TODO: VHT80+80, VHT160. Update acs_adjust_vht_center_freq() too. */

-       wpa_printf(MSG_DEBUG, "ACS: Survey analysis for selected bandwidth %d MHz",
-                  n_chans == 1 ? 20 :
-                  n_chans == 2 ? 40 :
-                  80);
+       wpa_printf(MSG_DEBUG, "ACS: Survey analysis for selected bandwidth %u MHz",
+                  bw);

        for (i = 0; i < iface->current_mode->num_channels; i++) {
                double total_weight;
@@ -596,12 +598,22 @@  acs_find_ideal_chan(struct hostapd_iface *iface)

                chan = &iface->current_mode->channels[i];

-               if (chan->flag & HOSTAPD_CHAN_DISABLED)
+               /* Since in current ACS implementation first channel is
+                * always a primary channel, skip channels not available as
+                * primary until more sophisticated channel selection will be
+                * implemented */
+               if (!chan_pri_allowed(chan))
                        continue;

                if (!is_in_chanlist(iface, chan))
                        continue;

+               if (!chan_bw_allowed(chan, bw, 1, 1)) {
+                       wpa_printf(MSG_DEBUG, "ACS: Channel %d: BW %u is not supported",
+                                  chan->chan, bw);
+                       continue;
+               }
+
                /* HT40 on 5 GHz has a limited set of primary channels as per
                 * 11n Annex J */
                if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A &&
@@ -632,6 +644,12 @@  acs_find_ideal_chan(struct hostapd_iface *iface)
                        if (!adj_chan)
                                break;

+                       if (!chan_bw_allowed(adj_chan, bw, 1, 0)) {
+                               wpa_printf(MSG_DEBUG, "ACS: PRI Channel %d: secondary channel %d BW %u is not supported",
+                                          chan->chan, adj_chan->chan, bw);
+                               break;
+                       }
+
                        if (acs_usable_chan(adj_chan)) {
                                factor += adj_chan->interference_factor;
                                total_weight += 1;