/*
 * ACS - Automatic Channel Selection module
 * Copyright (c) 2011, Atheros Communications
 * Copyright (c) 2013, Qualcomm Atheros, Inc.
 *
 * This software may be distributed under the terms of the BSD license.
 * See README for more details.
 */

#include "utils/includes.h"
#include <math.h>

#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"
#include "ap_drv_ops.h"
#include "ap_config.h"
#include "hw_features.h"
#include "acs.h"

/*
 * Automatic Channel Selection
 * ===========================
 *
 * More info at
 * ------------
 * http://wireless.kernel.org/en/users/Documentation/acs
 *
 * How to use
 * ----------
 * - make sure you have CONFIG_ACS=y in hostapd's .config
 * - use channel=0 or channel=acs to enable ACS
 *
 * How does it work
 * ----------------
 * 1. passive scans are used to collect survey data
 *    (it is assumed that scan trigger collection of survey data in driver)
 * 2. interference factor is calculated for each channel
 * 3. ideal channel is picked depending on channel width by using adjacent
 *    channel interference factors
 *
 * Known limitations
 * -----------------
 * - Current implementation depends heavily on the amount of time willing to
 *   spend gathering survey data during hostapd startup. Short traffic bursts
 *   may be missed and a suboptimal channel may be picked.
 * - Ideal channel may end up overlapping a channel with 40 MHz intolerant BSS
 *
 * Todo / Ideas
 * ------------
 * - implement other interference computation methods
 *   - BSS/RSSI based
 *   - spectral scan based
 *   (should be possibly to hook this up with current ACS scans)
 * - add wpa_supplicant support (for P2P)
 * - collect a histogram of interference over time allowing more educated
 *   guess about an ideal channel (perhaps CSA could be used to migrate AP to a
 *   new "better" channel while running)
 * - include neighboring BSS scan to avoid conflicts with 40 MHz intolerant BSSs
 *   when choosing the ideal channel
 *
 * Survey interference factor implementation details
 * -------------------------------------------------
 * Generic interference_factor in struct hostapd_channel_data is used.
 *
 * The survey interference factor is defined as the ratio of the
 * observed busy time over the time we spent on the channel,
 * this value is then amplified by the observed noise floor on
 * the channel in comparison to the lowest noise floor observed
 * on the entire band.
 *
 * This corresponds to:
 * ---
 * (busy time - tx time) / (active time - tx time) * 2^(chan_nf + band_min_nf)
 * ---
 *
 * The coefficient of 2 reflects the way power in "far-field"
 * radiation decreases as the square of distance from the antenna [1].
 * What this does is it decreases the observed busy time ratio if the
 * noise observed was low but increases it if the noise was high,
 * proportionally to the way "far field" radiation changes over
 * distance.
 *
 * If channel busy time is not available the fallback is to use channel RX time.
 *
 * Since noise floor is in dBm it is necessary to convert it into Watts so that
 * combined channel interference (e.g., HT40, which uses two channels) can be
 * calculated easily.
 * ---
 * (busy time - tx time) / (active time - tx time) *
 *    2^(10^(chan_nf/10) + 10^(band_min_nf/10))
 * ---
 *
 * However to account for cases where busy/rx time is 0 (channel load is then
 * 0%) channel noise floor signal power is combined into the equation so a
 * channel with lower noise floor is preferred. The equation becomes:
 * ---
 * 10^(chan_nf/5) + (busy time - tx time) / (active time - tx time) *
 *    2^(10^(chan_nf/10) + 10^(band_min_nf/10))
 * ---
 *
 * All this "interference factor" is purely subjective and only time
 * will tell how usable this is. By using the minimum noise floor we
 * remove any possible issues due to card calibration. The computation
 * of the interference factor then is dependent on what the card itself
 * picks up as the minimum noise, not an actual real possible card
 * noise value.
 *
 * Total interference computation details
 * --------------------------------------
 * The above channel interference factor is calculated with no respect to
 * target operational bandwidth.
 *
 * To find an ideal channel the above data is combined by taking into account
 * the target operational bandwidth and selected band. E.g., on 2.4 GHz channels
 * overlap with 20 MHz bandwidth, but there is no overlap for 20 MHz bandwidth
 * on 5 GHz.
 *
 * Each valid and possible channel spec (i.e., channel + width) is taken and its
 * interference factor is computed by summing up interferences of each channel
 * it overlaps. The one with least total interference is picked up.
 *
 * Note: This implies base channel interference factor must be non-negative
 * allowing easy summing up.
 *
 * Example ACS analysis printout
 * -----------------------------
 *
 * ACS: Trying survey-based ACS
 * ACS: Survey analysis for channel 1 (2412 MHz)
 * ACS:  1: min_nf=-113 interference_factor=0.0802469 nf=-113 time=162 busy=0 rx=13
 * ACS:  2: min_nf=-113 interference_factor=0.0745342 nf=-113 time=161 busy=0 rx=12
 * ACS:  3: min_nf=-113 interference_factor=0.0679012 nf=-113 time=162 busy=0 rx=11
 * ACS:  4: min_nf=-113 interference_factor=0.0310559 nf=-113 time=161 busy=0 rx=5
 * ACS:  5: min_nf=-113 interference_factor=0.0248447 nf=-113 time=161 busy=0 rx=4
 * ACS:  * interference factor average: 0.0557166
 * ACS: Survey analysis for channel 2 (2417 MHz)
 * ACS:  1: min_nf=-113 interference_factor=0.0185185 nf=-113 time=162 busy=0 rx=3
 * ACS:  2: min_nf=-113 interference_factor=0.0246914 nf=-113 time=162 busy=0 rx=4
 * ACS:  3: min_nf=-113 interference_factor=0.037037 nf=-113 time=162 busy=0 rx=6
 * ACS:  4: min_nf=-113 interference_factor=0.149068 nf=-113 time=161 busy=0 rx=24
 * ACS:  5: min_nf=-113 interference_factor=0.0248447 nf=-113 time=161 busy=0 rx=4
 * ACS:  * interference factor average: 0.050832
 * ACS: Survey analysis for channel 3 (2422 MHz)
 * ACS:  1: min_nf=-113 interference_factor=2.51189e-23 nf=-113 time=162 busy=0 rx=0
 * ACS:  2: min_nf=-113 interference_factor=0.0185185 nf=-113 time=162 busy=0 rx=3
 * ACS:  3: min_nf=-113 interference_factor=0.0186335 nf=-113 time=161 busy=0 rx=3
 * ACS:  4: min_nf=-113 interference_factor=0.0186335 nf=-113 time=161 busy=0 rx=3
 * ACS:  5: min_nf=-113 interference_factor=0.0186335 nf=-113 time=161 busy=0 rx=3
 * ACS:  * interference factor average: 0.0148838
 * ACS: Survey analysis for channel 4 (2427 MHz)
 * ACS:  1: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=162 busy=0 rx=0
 * ACS:  2: min_nf=-114 interference_factor=0.0555556 nf=-114 time=162 busy=0 rx=9
 * ACS:  3: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=161 busy=0 rx=0
 * ACS:  4: min_nf=-114 interference_factor=0.0186335 nf=-114 time=161 busy=0 rx=3
 * ACS:  5: min_nf=-114 interference_factor=0.00621118 nf=-114 time=161 busy=0 rx=1
 * ACS:  * interference factor average: 0.0160801
 * ACS: Survey analysis for channel 5 (2432 MHz)
 * ACS:  1: min_nf=-114 interference_factor=0.409938 nf=-113 time=161 busy=0 rx=66
 * ACS:  2: min_nf=-114 interference_factor=0.0432099 nf=-113 time=162 busy=0 rx=7
 * ACS:  3: min_nf=-114 interference_factor=0.0124224 nf=-113 time=161 busy=0 rx=2
 * ACS:  4: min_nf=-114 interference_factor=0.677019 nf=-113 time=161 busy=0 rx=109
 * ACS:  5: min_nf=-114 interference_factor=0.0186335 nf=-114 time=161 busy=0 rx=3
 * ACS:  * interference factor average: 0.232244
 * ACS: Survey analysis for channel 6 (2437 MHz)
 * ACS:  1: min_nf=-113 interference_factor=0.552795 nf=-113 time=161 busy=0 rx=89
 * ACS:  2: min_nf=-113 interference_factor=0.0807453 nf=-112 time=161 busy=0 rx=13
 * ACS:  3: min_nf=-113 interference_factor=0.0310559 nf=-113 time=161 busy=0 rx=5
 * ACS:  4: min_nf=-113 interference_factor=0.434783 nf=-112 time=161 busy=0 rx=70
 * ACS:  5: min_nf=-113 interference_factor=0.0621118 nf=-113 time=161 busy=0 rx=10
 * ACS:  * interference factor average: 0.232298
 * ACS: Survey analysis for channel 7 (2442 MHz)
 * ACS:  1: min_nf=-113 interference_factor=0.440994 nf=-112 time=161 busy=0 rx=71
 * ACS:  2: min_nf=-113 interference_factor=0.385093 nf=-113 time=161 busy=0 rx=62
 * ACS:  3: min_nf=-113 interference_factor=0.0372671 nf=-113 time=161 busy=0 rx=6
 * ACS:  4: min_nf=-113 interference_factor=0.0372671 nf=-113 time=161 busy=0 rx=6
 * ACS:  5: min_nf=-113 interference_factor=0.0745342 nf=-113 time=161 busy=0 rx=12
 * ACS:  * interference factor average: 0.195031
 * ACS: Survey analysis for channel 8 (2447 MHz)
 * ACS:  1: min_nf=-114 interference_factor=0.0496894 nf=-112 time=161 busy=0 rx=8
 * ACS:  2: min_nf=-114 interference_factor=0.0496894 nf=-114 time=161 busy=0 rx=8
 * ACS:  3: min_nf=-114 interference_factor=0.0372671 nf=-113 time=161 busy=0 rx=6
 * ACS:  4: min_nf=-114 interference_factor=0.12963 nf=-113 time=162 busy=0 rx=21
 * ACS:  5: min_nf=-114 interference_factor=0.166667 nf=-114 time=162 busy=0 rx=27
 * ACS:  * interference factor average: 0.0865885
 * ACS: Survey analysis for channel 9 (2452 MHz)
 * ACS:  1: min_nf=-114 interference_factor=0.0124224 nf=-114 time=161 busy=0 rx=2
 * ACS:  2: min_nf=-114 interference_factor=0.0310559 nf=-114 time=161 busy=0 rx=5
 * ACS:  3: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=161 busy=0 rx=0
 * ACS:  4: min_nf=-114 interference_factor=0.00617284 nf=-114 time=162 busy=0 rx=1
 * ACS:  5: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=162 busy=0 rx=0
 * ACS:  * interference factor average: 0.00993022
 * ACS: Survey analysis for channel 10 (2457 MHz)
 * ACS:  1: min_nf=-114 interference_factor=0.00621118 nf=-114 time=161 busy=0 rx=1
 * ACS:  2: min_nf=-114 interference_factor=0.00621118 nf=-114 time=161 busy=0 rx=1
 * ACS:  3: min_nf=-114 interference_factor=0.00621118 nf=-114 time=161 busy=0 rx=1
 * ACS:  4: min_nf=-114 interference_factor=0.0493827 nf=-114 time=162 busy=0 rx=8
 * ACS:  5: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=162 busy=0 rx=0
 * ACS:  * interference factor average: 0.0136033
 * ACS: Survey analysis for channel 11 (2462 MHz)
 * ACS:  1: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=161 busy=0 rx=0
 * ACS:  2: min_nf=-114 interference_factor=2.51189e-23 nf=-113 time=161 busy=0 rx=0
 * ACS:  3: min_nf=-114 interference_factor=2.51189e-23 nf=-113 time=161 busy=0 rx=0
 * ACS:  4: min_nf=-114 interference_factor=0.0432099 nf=-114 time=162 busy=0 rx=7
 * ACS:  5: min_nf=-114 interference_factor=0.0925926 nf=-114 time=162 busy=0 rx=15
 * ACS:  * interference factor average: 0.0271605
 * ACS: Survey analysis for channel 12 (2467 MHz)
 * ACS:  1: min_nf=-114 interference_factor=0.0621118 nf=-113 time=161 busy=0 rx=10
 * ACS:  2: min_nf=-114 interference_factor=0.00621118 nf=-114 time=161 busy=0 rx=1
 * ACS:  3: min_nf=-114 interference_factor=2.51189e-23 nf=-113 time=162 busy=0 rx=0
 * ACS:  4: min_nf=-114 interference_factor=2.51189e-23 nf=-113 time=162 busy=0 rx=0
 * ACS:  5: min_nf=-114 interference_factor=0.00617284 nf=-113 time=162 busy=0 rx=1
 * ACS:  * interference factor average: 0.0148992
 * ACS: Survey analysis for channel 13 (2472 MHz)
 * ACS:  1: min_nf=-114 interference_factor=0.0745342 nf=-114 time=161 busy=0 rx=12
 * ACS:  2: min_nf=-114 interference_factor=0.0555556 nf=-114 time=162 busy=0 rx=9
 * ACS:  3: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=162 busy=0 rx=0
 * ACS:  4: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=162 busy=0 rx=0
 * ACS:  5: min_nf=-114 interference_factor=1.58489e-23 nf=-114 time=162 busy=0 rx=0
 * ACS:  * interference factor average: 0.0260179
 * ACS: Survey analysis for selected bandwidth 20MHz
 * ACS:  * channel 1: total interference = 0.121432
 * ACS:  * channel 2: total interference = 0.137512
 * ACS:  * channel 3: total interference = 0.369757
 * ACS:  * channel 4: total interference = 0.546338
 * ACS:  * channel 5: total interference = 0.690538
 * ACS:  * channel 6: total interference = 0.762242
 * ACS:  * channel 7: total interference = 0.756092
 * ACS:  * channel 8: total interference = 0.537451
 * ACS:  * channel 9: total interference = 0.332313
 * ACS:  * channel 10: total interference = 0.152182
 * ACS:  * channel 11: total interference = 0.0916111
 * ACS:  * channel 12: total interference = 0.0816809
 * ACS:  * channel 13: total interference = 0.0680776
 * ACS: Ideal channel is 13 (2472 MHz) with total interference factor of 0.0680776
 *
 * [1] http://en.wikipedia.org/wiki/Near_and_far_field
 */

enum bw_type {
	ACS_BW40,
	ACS_BW80,
	ACS_BW160,
};

struct bw_item {
	int first;
	int last;
	int center_chan;
};

static const struct bw_item bw_40[] = {
	{ 5180, 5200, 38 }, { 5220, 5240, 46 }, { 5260, 5280, 54 },
	{ 5300, 5320, 62 }, { 5500, 5520, 102 }, { 5540, 5560, 110 },
	{ 5580, 5600, 110 }, { 5620, 5640, 126}, { 5660, 5680, 134 },
	{ 5700, 5720, 142 }, { 5745, 5765, 151 }, { 5785, 5805, 159 },
	{ 5825, 5845, 167 }, { 5865, 5885, 175 },
	{ 5955, 5975, 3 }, { 5995, 6015, 11 }, { 6035, 6055, 19 },
	{ 6075, 6095, 27 }, { 6115, 6135, 35 }, { 6155, 6175, 43 },
	{ 6195, 6215, 51 }, { 6235, 6255, 59 }, { 6275, 6295, 67 },
	{ 6315, 6335, 75 }, { 6355, 6375, 83 }, { 6395, 6415, 91 },
	{ 6435, 6455, 99 }, { 6475, 6495, 107 }, { 6515, 6535, 115 },
	{ 6555, 6575, 123 }, { 6595, 6615, 131 }, { 6635, 6655, 139 },
	{ 6675, 6695, 147 }, { 6715, 6735, 155 }, { 6755, 6775, 163 },
	{ 6795, 6815, 171 }, { 6835, 6855, 179 }, { 6875, 6895, 187 },
	{ 6915, 6935, 195 }, { 6955, 6975, 203 }, { 6995, 7015, 211 },
	{ 7035, 7055, 219 }, { 7075, 7095, 227}, { -1, -1, -1 }
};
static const struct bw_item bw_80[] = {
	{ 5180, 5240, 42 }, { 5260, 5320, 58 }, { 5500, 5560, 106 },
	{ 5580, 5640, 122 }, { 5660, 5720, 138 }, { 5745, 5805, 155 },
	{ 5825, 5885, 171},
	{ 5955, 6015, 7 }, { 6035, 6095, 23 }, { 6115, 6175, 39 },
	{ 6195, 6255, 55 }, { 6275, 6335, 71 }, { 6355, 6415, 87 },
	{ 6435, 6495, 103 }, { 6515, 6575, 119 }, { 6595, 6655, 135 },
	{ 6675, 6735, 151 }, { 6755, 6815, 167 }, { 6835, 6895, 183 },
	{ 6915, 6975, 199 }, { 6995, 7055, 215 }, { -1, -1, -1 }
};
static const struct bw_item bw_160[] = {
	{ 5180, 5320, 50 }, { 5500, 5640, 114 }, { 5745, 5885, 163 },
	{ 5955, 6095, 15 }, { 6115, 6255, 47 }, { 6275, 6415, 79 },
	{ 6435, 6575, 111 }, { 6595, 6735, 143 },
	{ 6755, 6895, 175 }, { 6915, 7055, 207 }, { -1, -1, -1 }
};
static const struct bw_item *bw_desc[] = {
	[ACS_BW40] = bw_40,
	[ACS_BW80] = bw_80,
	[ACS_BW160] = bw_160,
};


static int acs_request_scan(struct hostapd_iface *iface);
static int acs_survey_is_sufficient(struct freq_survey *survey);


static void acs_clean_chan_surveys(struct hostapd_channel_data *chan)
{
	struct freq_survey *survey, *tmp;

	if (dl_list_empty(&chan->survey_list))
		return;

	dl_list_for_each_safe(survey, tmp, &chan->survey_list,
			      struct freq_survey, list) {
		dl_list_del(&survey->list);
		os_free(survey);
	}
}


static void acs_cleanup_mode(struct hostapd_hw_modes *mode)
{
	int i;
	struct hostapd_channel_data *chan;

	for (i = 0; i < mode->num_channels; i++) {
		chan = &mode->channels[i];

		if (chan->flag & HOSTAPD_CHAN_SURVEY_LIST_INITIALIZED)
			acs_clean_chan_surveys(chan);

		dl_list_init(&chan->survey_list);
		chan->flag |= HOSTAPD_CHAN_SURVEY_LIST_INITIALIZED;
		chan->min_nf = 0;
		chan->punct_bitmap = 0;
	}
}


void acs_cleanup(struct hostapd_iface *iface)
{
	int i;

	for (i = 0; i < iface->num_hw_features; i++)
		acs_cleanup_mode(&iface->hw_features[i]);

	iface->chans_surveyed = 0;
	iface->acs_num_completed_scans = 0;
}


static void acs_fail(struct hostapd_iface *iface)
{
	wpa_printf(MSG_ERROR, "ACS: Failed to start");
	acs_cleanup(iface);
	hostapd_disable_iface(iface);
}


static long double
acs_survey_interference_factor(struct freq_survey *survey, s8 min_nf)
{
	long double factor, busy, total;

	if (survey->filled & SURVEY_HAS_CHAN_TIME_BUSY)
		busy = survey->channel_time_busy;
	else if (survey->filled & SURVEY_HAS_CHAN_TIME_RX)
		busy = survey->channel_time_rx;
	else {
		wpa_printf(MSG_ERROR, "ACS: Survey data missing");
		return 0;
	}

	total = survey->channel_time;

	if (survey->filled & SURVEY_HAS_CHAN_TIME_TX) {
		busy -= survey->channel_time_tx;
		total -= survey->channel_time_tx;
	}

	/* TODO: figure out the best multiplier for noise floor base */
	factor = pow(10, survey->nf / 5.0L) +
		(total ? (busy / total) : 0) *
		pow(2, pow(10, (long double) survey->nf / 10.0L) -
		    pow(10, (long double) min_nf / 10.0L));

	return factor;
}


static void
acs_survey_chan_interference_factor(struct hostapd_iface *iface,
				    struct hostapd_channel_data *chan)
{
	struct freq_survey *survey;
	unsigned int i = 0;
	long double int_factor = 0;
	unsigned count = 0;

	if (dl_list_empty(&chan->survey_list) ||
	    (chan->flag & HOSTAPD_CHAN_DISABLED))
		return;

	chan->interference_factor = 0;

	dl_list_for_each(survey, &chan->survey_list, struct freq_survey, list)
	{
		i++;

		if (!acs_survey_is_sufficient(survey)) {
			wpa_printf(MSG_DEBUG, "ACS: %d: insufficient data", i);
			continue;
		}

		count++;
		int_factor = acs_survey_interference_factor(survey,
							    iface->lowest_nf);
		chan->interference_factor += int_factor;
		wpa_printf(MSG_DEBUG, "ACS: %d: min_nf=%d interference_factor=%Lg nf=%d time=%lu busy=%lu rx=%lu",
			   i, chan->min_nf, int_factor,
			   survey->nf, (unsigned long) survey->channel_time,
			   (unsigned long) survey->channel_time_busy,
			   (unsigned long) survey->channel_time_rx);
	}

	if (count)
		chan->interference_factor /= count;
}


static bool acs_usable_bw_chan(const struct hostapd_channel_data *chan,
			       enum bw_type bw)
{
	unsigned int i = 0;

	while (bw_desc[bw][i].first != -1) {
		if (chan->freq == bw_desc[bw][i].first)
			return true;
		i++;
	}

	return false;
}


static int acs_get_bw_center_chan(int freq, enum bw_type bw)
{
	unsigned int i = 0;

	while (bw_desc[bw][i].first != -1) {
		if (freq >= bw_desc[bw][i].first &&
		    freq <= bw_desc[bw][i].last)
			return bw_desc[bw][i].center_chan;
		i++;
	}

	return 0;
}


static int acs_survey_is_sufficient(struct freq_survey *survey)
{
	if (!(survey->filled & SURVEY_HAS_NF)) {
		wpa_printf(MSG_INFO,
			   "ACS: Survey for freq %d is missing noise floor",
			   survey->freq);
		return 0;
	}

	if (!(survey->filled & SURVEY_HAS_CHAN_TIME)) {
		wpa_printf(MSG_INFO,
			   "ACS: Survey for freq %d is missing channel time",
			   survey->freq);
		return 0;
	}

	if (!(survey->filled & SURVEY_HAS_CHAN_TIME_BUSY) &&
	    !(survey->filled & SURVEY_HAS_CHAN_TIME_RX)) {
		wpa_printf(MSG_INFO,
			   "ACS: Survey for freq %d is missing RX and busy time (at least one is required)",
			   survey->freq);
		return 0;
	}

	return 1;
}


static int acs_survey_list_is_sufficient(struct hostapd_channel_data *chan)
{
	struct freq_survey *survey;
	int ret = -1;

	dl_list_for_each(survey, &chan->survey_list, struct freq_survey, list)
	{
		if (acs_survey_is_sufficient(survey)) {
			ret = 1;
			break;
		}
		ret = 0;
	}

	if (ret == -1)
		ret = 1; /* no survey list entries */

	if (!ret) {
		wpa_printf(MSG_INFO,
			   "ACS: Channel %d has insufficient survey data",
			   chan->chan);
	}

	return ret;
}


static int acs_surveys_are_sufficient_mode(struct hostapd_hw_modes *mode)
{
	int i;
	struct hostapd_channel_data *chan;

	for (i = 0; i < mode->num_channels; i++) {
		chan = &mode->channels[i];
		if (!(chan->flag & HOSTAPD_CHAN_DISABLED) &&
		    acs_survey_list_is_sufficient(chan))
			return 1;
	}

	return 0;
}


static int acs_surveys_are_sufficient(struct hostapd_iface *iface)
{
	int i;
	struct hostapd_hw_modes *mode;

	for (i = 0; i < iface->num_hw_features; i++) {
		mode = &iface->hw_features[i];
		if (!hostapd_hw_skip_mode(iface, mode) &&
		    acs_surveys_are_sufficient_mode(mode))
			return 1;
	}

	return 0;
}


static int acs_usable_chan(struct hostapd_channel_data *chan)
{
	return !dl_list_empty(&chan->survey_list) &&
		!(chan->flag & HOSTAPD_CHAN_DISABLED) &&
		acs_survey_list_is_sufficient(chan);
}


static int is_in_chanlist(struct hostapd_iface *iface,
			  struct hostapd_channel_data *chan)
{
	if (!iface->conf->acs_ch_list.num)
		return 1;

	return freq_range_list_includes(&iface->conf->acs_ch_list, chan->chan);
}


static int is_in_freqlist(struct hostapd_iface *iface,
			  struct hostapd_channel_data *chan)
{
	if (!iface->conf->acs_freq_list.num)
		return 1;

	return freq_range_list_includes(&iface->conf->acs_freq_list,
					chan->freq);
}


static void acs_survey_mode_interference_factor(
	struct hostapd_iface *iface, struct hostapd_hw_modes *mode)
{
	int i;
	struct hostapd_channel_data *chan;

	for (i = 0; i < mode->num_channels; i++) {
		chan = &mode->channels[i];

		if (!acs_usable_chan(chan))
			continue;

		if ((chan->flag & HOSTAPD_CHAN_RADAR) &&
		    iface->conf->acs_exclude_dfs)
			continue;

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

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

		if (chan->max_tx_power < iface->conf->min_tx_power)
			continue;

		if ((chan->flag & HOSTAPD_CHAN_INDOOR_ONLY) &&
		    iface->conf->country[2] == 0x4f)
			continue;

		wpa_printf(MSG_DEBUG, "ACS: Survey analysis for channel %d (%d MHz)",
			   chan->chan, chan->freq);

		acs_survey_chan_interference_factor(iface, chan);

		wpa_printf(MSG_DEBUG, "ACS:  * interference factor average: %Lg",
			   chan->interference_factor);
	}
}


static void acs_survey_all_chans_interference_factor(
	struct hostapd_iface *iface)
{
	int i;
	struct hostapd_hw_modes *mode;

	for (i = 0; i < iface->num_hw_features; i++) {
		mode = &iface->hw_features[i];
		if (!hostapd_hw_skip_mode(iface, mode))
			acs_survey_mode_interference_factor(iface, mode);
	}
}


static struct hostapd_channel_data *
acs_find_chan_mode(struct hostapd_hw_modes *mode, int freq)
{
	struct hostapd_channel_data *chan;
	int i;

	for (i = 0; i < mode->num_channels; i++) {
		chan = &mode->channels[i];

		if (chan->flag & HOSTAPD_CHAN_DISABLED)
			continue;

		if (chan->freq == freq)
			return chan;
	}

	return NULL;
}


static enum hostapd_hw_mode
acs_find_mode(struct hostapd_iface *iface, int freq)
{
	int i;
	struct hostapd_hw_modes *mode;
	struct hostapd_channel_data *chan;

	for (i = 0; i < iface->num_hw_features; i++) {
		mode = &iface->hw_features[i];
		if (!hostapd_hw_skip_mode(iface, mode)) {
			chan = acs_find_chan_mode(mode, freq);
			if (chan)
				return mode->mode;
		}
	}

	return HOSTAPD_MODE_IEEE80211ANY;
}


static struct hostapd_channel_data *
acs_find_chan(struct hostapd_iface *iface, int freq)
{
	int i;
	struct hostapd_hw_modes *mode;
	struct hostapd_channel_data *chan;

	for (i = 0; i < iface->num_hw_features; i++) {
		mode = &iface->hw_features[i];
		if (!hostapd_hw_skip_mode(iface, mode)) {
			chan = acs_find_chan_mode(mode, freq);
			if (chan)
				return chan;
		}
	}

	return NULL;
}


static int is_24ghz_mode(enum hostapd_hw_mode mode)
{
	return mode == HOSTAPD_MODE_IEEE80211B ||
		mode == HOSTAPD_MODE_IEEE80211G;
}


static int is_common_24ghz_chan(int chan)
{
	return chan == 1 || chan == 6 || chan == 11;
}


#ifndef ACS_ADJ_WEIGHT
#define ACS_ADJ_WEIGHT 0.85
#endif /* ACS_ADJ_WEIGHT */

#ifndef ACS_NEXT_ADJ_WEIGHT
#define ACS_NEXT_ADJ_WEIGHT 0.55
#endif /* ACS_NEXT_ADJ_WEIGHT */

#ifndef ACS_24GHZ_PREFER_1_6_11
/*
 * Select commonly used channels 1, 6, 11 by default even if a neighboring
 * channel has a smaller interference factor as long as it is not better by more
 * than this multiplier.
 */
#define ACS_24GHZ_PREFER_1_6_11 0.8
#endif /* ACS_24GHZ_PREFER_1_6_11 */


#ifdef CONFIG_IEEE80211BE
static void acs_update_puncturing_bitmap(struct hostapd_iface *iface,
					 struct hostapd_hw_modes *mode, u32 bw,
					 int n_chans,
					 struct hostapd_channel_data *chan,
					 long double factor,
					 int index_primary)
{
	struct hostapd_config *conf = iface->conf;
	struct hostapd_channel_data *adj_chan = NULL, *first_chan = chan;
	int i;
	long double threshold;

	/*
	 * If threshold is 0 or user configured puncturing pattern is
	 * available then don't add additional puncturing.
	 */
	if (!conf->punct_acs_threshold || conf->punct_bitmap)
		return;

	if (is_24ghz_mode(mode->mode) || bw < 80)
		return;

	threshold = factor * conf->punct_acs_threshold / 100;
	for (i = 0; i < n_chans; i++) {
		int adj_freq;

		if (i == index_primary)
			continue; /* Cannot puncture primary channel */

		if (i > index_primary)
			adj_freq = chan->freq + (i - index_primary) * 20;
		else
			adj_freq = chan->freq - (index_primary - i) * 20;

		adj_chan = acs_find_chan(iface, adj_freq);
		if (!adj_chan) {
			chan->punct_bitmap = 0;
			return;
		}

		if (i == 0)
			first_chan = adj_chan;

		if (adj_chan->interference_factor > threshold)
			chan->punct_bitmap |= BIT(i);
	}

	if (!is_punct_bitmap_valid(bw, (chan->freq - first_chan->freq) / 20,
				   chan->punct_bitmap))
		chan->punct_bitmap = 0;
}
#endif /* CONFIG_IEEE80211BE */


static void
acs_find_ideal_chan_mode(struct hostapd_iface *iface,
			 struct hostapd_hw_modes *mode,
			 int n_chans, u32 bw,
			 struct hostapd_channel_data **rand_chan,
			 struct hostapd_channel_data **ideal_chan,
			 long double *ideal_factor)
{
	struct hostapd_channel_data *chan, *adj_chan = NULL, *best;
	long double factor;
	int i, j;
	unsigned int k;

	for (i = 0; i < mode->num_channels; i++) {
		double total_weight;
		struct acs_bias *bias, tmp_bias;
		bool update_best = true;

		best = chan = &mode->channels[i];

		/* Since in the current ACS implementation the first channel is
		 * always a primary channel, skip channels not available as
		 * primary until more sophisticated channel selection is
		 * implemented.
		 *
		 * If this implementation is changed to allow any channel in
		 * the bandwidth to be the primary one, the last parameter to
		 * acs_update_puncturing_bitmap() should be changed to the index
		 * of the primary channel
		 */
		if (!chan_pri_allowed(chan))
			continue;

		if ((chan->flag & HOSTAPD_CHAN_RADAR) &&
		    iface->conf->acs_exclude_dfs)
			continue;

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

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

		if (chan->max_tx_power < iface->conf->min_tx_power)
			continue;

		if ((chan->flag & HOSTAPD_CHAN_INDOOR_ONLY) &&
		    iface->conf->country[2] == 0x4f)
			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 (mode->mode == HOSTAPD_MODE_IEEE80211A &&
		    ((iface->conf->ieee80211n &&
		      iface->conf->secondary_channel) ||
		     is_6ghz_freq(chan->freq)) &&
		    !acs_usable_bw_chan(chan, ACS_BW40)) {
			wpa_printf(MSG_DEBUG,
				   "ACS: Channel %d: not allowed as primary channel for 40 MHz bandwidth",
				   chan->chan);
			continue;
		}

		if (mode->mode == HOSTAPD_MODE_IEEE80211A &&
		    (iface->conf->ieee80211ac || iface->conf->ieee80211ax)) {
			if (hostapd_get_oper_chwidth(iface->conf) ==
			    CONF_OPER_CHWIDTH_80MHZ &&
			    !acs_usable_bw_chan(chan, ACS_BW80)) {
				wpa_printf(MSG_DEBUG,
					   "ACS: Channel %d: not allowed as primary channel for 80 MHz bandwidth",
					   chan->chan);
				continue;
			}

			if (hostapd_get_oper_chwidth(iface->conf) ==
			    CONF_OPER_CHWIDTH_160MHZ &&
			    !acs_usable_bw_chan(chan, ACS_BW160)) {
				wpa_printf(MSG_DEBUG,
					   "ACS: Channel %d: not allowed as primary channel for 160 MHz bandwidth",
					   chan->chan);
				continue;
			}
		}

		factor = 0;
		if (acs_usable_chan(chan))
			factor = chan->interference_factor;
		total_weight = 1;

		for (j = 1; j < n_chans; j++) {
			adj_chan = acs_find_chan(iface, chan->freq + (j * 20));
			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;
			} else {
				update_best = false;
			}

			/* find the best channel in this segment */
			if (update_best &&
			    adj_chan->interference_factor <
			    best->interference_factor)
				best = adj_chan;
		}

		if (j != n_chans) {
			wpa_printf(MSG_DEBUG, "ACS: Channel %d: not enough bandwidth",
				   chan->chan);
			continue;
		}

		/* If the AP is in the 5 GHz or 6 GHz band, lets prefer a less
		 * crowded primary channel if one was found in the segment */
		if (iface->current_mode->mode == HOSTAPD_MODE_IEEE80211A &&
		    chan != best) {
			wpa_printf(MSG_DEBUG,
				   "ACS: promoting channel %d over %d (less interference %Lg/%Lg)",
				   best->chan, chan->chan,
				   chan->interference_factor,
				   best->interference_factor);
			chan = best;
		}

		/* 2.4 GHz has overlapping 20 MHz channels. Include adjacent
		 * channel interference factor. */
		if (is_24ghz_mode(mode->mode)) {
			for (j = 0; j < n_chans; j++) {
				adj_chan = acs_find_chan(iface, chan->freq +
							 (j * 20) - 5);
				if (adj_chan && acs_usable_chan(adj_chan)) {
					factor += ACS_ADJ_WEIGHT *
						adj_chan->interference_factor;
					total_weight += ACS_ADJ_WEIGHT;
				}

				adj_chan = acs_find_chan(iface, chan->freq +
							 (j * 20) - 10);
				if (adj_chan && acs_usable_chan(adj_chan)) {
					factor += ACS_NEXT_ADJ_WEIGHT *
						adj_chan->interference_factor;
					total_weight += ACS_NEXT_ADJ_WEIGHT;
				}

				adj_chan = acs_find_chan(iface, chan->freq +
							 (j * 20) + 5);
				if (adj_chan && acs_usable_chan(adj_chan)) {
					factor += ACS_ADJ_WEIGHT *
						adj_chan->interference_factor;
					total_weight += ACS_ADJ_WEIGHT;
				}

				adj_chan = acs_find_chan(iface, chan->freq +
							 (j * 20) + 10);
				if (adj_chan && acs_usable_chan(adj_chan)) {
					factor += ACS_NEXT_ADJ_WEIGHT *
						adj_chan->interference_factor;
					total_weight += ACS_NEXT_ADJ_WEIGHT;
				}
			}
		}

		factor /= total_weight;

		bias = NULL;
		if (iface->conf->acs_chan_bias) {
			for (k = 0; k < iface->conf->num_acs_chan_bias; k++) {
				bias = &iface->conf->acs_chan_bias[k];
				if (bias->channel == chan->chan)
					break;
				bias = NULL;
			}
		} else if (is_24ghz_mode(mode->mode) &&
			   is_common_24ghz_chan(chan->chan)) {
			tmp_bias.channel = chan->chan;
			tmp_bias.bias = ACS_24GHZ_PREFER_1_6_11;
			bias = &tmp_bias;
		}

		if (bias) {
			factor *= bias->bias;
			wpa_printf(MSG_DEBUG,
				   "ACS:  * channel %d: total interference = %Lg (%f bias)",
				   chan->chan, factor, bias->bias);
		} else {
			wpa_printf(MSG_DEBUG,
				   "ACS:  * channel %d: total interference = %Lg",
				   chan->chan, factor);
		}

		if (acs_usable_chan(chan) &&
		    (!*ideal_chan || factor < *ideal_factor)) {
			/* Reset puncturing bitmap for the previous ideal
			 * channel */
			if (*ideal_chan)
				(*ideal_chan)->punct_bitmap = 0;

			*ideal_factor = factor;
			*ideal_chan = chan;

#ifdef CONFIG_IEEE80211BE
			if (iface->conf->ieee80211be)
				acs_update_puncturing_bitmap(iface, mode, bw,
							     n_chans, chan,
							     factor, 0);
#endif /* CONFIG_IEEE80211BE */
		}

		/* This channel would at least be usable */
		if (!(*rand_chan))
			*rand_chan = chan;
	}
}


/*
 * At this point it's assumed chan->interference_factor has been computed.
 * This function should be reusable regardless of interference computation
 * option (survey, BSS, spectral, ...). chan->interference factor must be
 * summable (i.e., must be always greater than zero).
 */
static struct hostapd_channel_data *
acs_find_ideal_chan(struct hostapd_iface *iface)
{
	struct hostapd_channel_data *ideal_chan = NULL,
		*rand_chan = NULL;
	long double ideal_factor = 0;
	int i;
	int n_chans = 1;
	u32 bw;
	struct hostapd_hw_modes *mode;

	if (is_6ghz_op_class(iface->conf->op_class)) {
		bw = op_class_to_bandwidth(iface->conf->op_class);
		n_chans = bw / 20;
		goto bw_selected;
	}

	/* TODO: HT40- support */

	if (iface->conf->ieee80211n &&
	    iface->conf->secondary_channel == -1) {
		wpa_printf(MSG_ERROR, "ACS: HT40- is not supported yet. Please try HT40+");
		return NULL;
	}

	if (iface->conf->ieee80211n &&
	    iface->conf->secondary_channel)
		n_chans = 2;

	if (iface->conf->ieee80211ac || iface->conf->ieee80211ax) {
		switch (hostapd_get_oper_chwidth(iface->conf)) {
		case CONF_OPER_CHWIDTH_80MHZ:
			n_chans = 4;
			break;
		case CONF_OPER_CHWIDTH_160MHZ:
			n_chans = 8;
			break;
		default:
			break;
		}
	}

	bw = num_chan_to_bw(n_chans);

bw_selected:
	/* TODO: VHT/HE80+80. Update acs_adjust_center_freq() too. */

	wpa_printf(MSG_DEBUG,
		   "ACS: Survey analysis for selected bandwidth %d MHz", bw);

	for (i = 0; i < iface->num_hw_features; i++) {
		mode = &iface->hw_features[i];
		if (!hostapd_hw_skip_mode(iface, mode))
			acs_find_ideal_chan_mode(iface, mode, n_chans, bw,
						 &rand_chan, &ideal_chan,
						 &ideal_factor);
	}

	if (ideal_chan) {
		wpa_printf(MSG_DEBUG, "ACS: Ideal channel is %d (%d MHz) with total interference factor of %Lg",
			   ideal_chan->chan, ideal_chan->freq, ideal_factor);

#ifdef CONFIG_IEEE80211BE
		if (iface->conf->punct_acs_threshold)
			wpa_printf(MSG_DEBUG, "ACS: RU puncturing bitmap 0x%x",
				   ideal_chan->punct_bitmap);
#endif /* CONFIG_IEEE80211BE */

		return ideal_chan;
	}

#ifdef CONFIG_IEEE80211BE
	if (iface->conf->punct_acs_threshold)
		wpa_printf(MSG_DEBUG, "ACS: RU puncturing bitmap 0x%x",
			   ideal_chan->punct_bitmap);
#endif /* CONFIG_IEEE80211BE */

	return rand_chan;
}


static void acs_adjust_secondary(struct hostapd_iface *iface)
{
	unsigned int i;

	/* When working with bandwidth over 20 MHz on the 5 GHz or 6 GHz band,
	 * ACS can return a secondary channel which is not the first channel of
	 * the segment and we need to adjust. */
	if (!iface->conf->secondary_channel ||
	    acs_find_mode(iface, iface->freq) != HOSTAPD_MODE_IEEE80211A)
		return;

	wpa_printf(MSG_DEBUG, "ACS: Adjusting HT/VHT/HE secondary frequency");

	for (i = 0; bw_desc[ACS_BW40][i].first != -1; i++) {
		if (iface->freq == bw_desc[ACS_BW40][i].first)
			iface->conf->secondary_channel = 1;
		else if (iface->freq == bw_desc[ACS_BW40][i].last)
			iface->conf->secondary_channel = -1;
	}
}


static void acs_adjust_center_freq(struct hostapd_iface *iface)
{
	int center;

	wpa_printf(MSG_DEBUG, "ACS: Adjusting VHT center frequency");

	switch (hostapd_get_oper_chwidth(iface->conf)) {
	case CONF_OPER_CHWIDTH_USE_HT:
		if (iface->conf->secondary_channel &&
		    iface->freq >= 2400 && iface->freq < 2500)
			center = iface->conf->channel +
				2 * iface->conf->secondary_channel;
		else if (iface->conf->secondary_channel)
			center = acs_get_bw_center_chan(iface->freq, ACS_BW40);
		else
			center = iface->conf->channel;
		break;
	case CONF_OPER_CHWIDTH_80MHZ:
		center = acs_get_bw_center_chan(iface->freq, ACS_BW80);
		break;
	case CONF_OPER_CHWIDTH_160MHZ:
		center = acs_get_bw_center_chan(iface->freq, ACS_BW160);
		break;
	default:
		/* TODO: How can this be calculated? Adjust
		 * acs_find_ideal_chan() */
		wpa_printf(MSG_INFO,
			   "ACS: Only VHT20/40/80/160 is supported now");
		return;
	}

	hostapd_set_oper_centr_freq_seg0_idx(iface->conf, center);
}


static int acs_study_survey_based(struct hostapd_iface *iface)
{
	wpa_printf(MSG_DEBUG, "ACS: Trying survey-based ACS");

	if (!iface->chans_surveyed) {
		wpa_printf(MSG_ERROR, "ACS: Unable to collect survey data");
		return -1;
	}

	if (!acs_surveys_are_sufficient(iface)) {
		wpa_printf(MSG_ERROR, "ACS: Surveys have insufficient data");
		return -1;
	}

	acs_survey_all_chans_interference_factor(iface);
	return 0;
}


static int acs_study_options(struct hostapd_iface *iface)
{
	if (acs_study_survey_based(iface) == 0)
		return 0;

	/* TODO: If no surveys are available/sufficient this is a good
	 * place to fallback to BSS-based ACS */

	return -1;
}


static void acs_study(struct hostapd_iface *iface)
{
	struct hostapd_channel_data *ideal_chan;
	int err;

	err = acs_study_options(iface);
	if (err < 0) {
		wpa_printf(MSG_ERROR, "ACS: All study options have failed");
		goto fail;
	}

	ideal_chan = acs_find_ideal_chan(iface);
	if (!ideal_chan) {
		wpa_printf(MSG_ERROR, "ACS: Failed to compute ideal channel");
		err = -1;
		goto fail;
	}

	iface->conf->channel = ideal_chan->chan;
	iface->freq = ideal_chan->freq;
#ifdef CONFIG_IEEE80211BE
	iface->conf->punct_bitmap = ideal_chan->punct_bitmap;
#endif /* CONFIG_IEEE80211BE */

	if (iface->conf->ieee80211ac || iface->conf->ieee80211ax) {
		acs_adjust_secondary(iface);
		acs_adjust_center_freq(iface);
	}

	err = hostapd_select_hw_mode(iface);
	if (err) {
		wpa_printf(MSG_ERROR,
			   "ACS: Could not (err: %d) select hw_mode for freq=%d channel=%d",
			err, iface->freq, iface->conf->channel);
		err = -1;
		goto fail;
	}

	err = 0;
fail:
	/*
	 * hostapd_setup_interface_complete() will return -1 on failure,
	 * 0 on success and 0 is HOSTAPD_CHAN_VALID :)
	 */
	if (hostapd_acs_completed(iface, err) == HOSTAPD_CHAN_VALID) {
		acs_cleanup(iface);
		return;
	}

	/* This can possibly happen if channel parameters (secondary
	 * channel, center frequencies) are misconfigured */
	wpa_printf(MSG_ERROR, "ACS: Possibly channel configuration is invalid, please report this along with your config file.");
	acs_fail(iface);
}


static void acs_scan_complete(struct hostapd_iface *iface)
{
	int err;

	iface->scan_cb = NULL;

	wpa_printf(MSG_DEBUG, "ACS: Using survey based algorithm (acs_num_scans=%d)",
		   iface->conf->acs_num_scans);

	err = hostapd_drv_get_survey(iface->bss[0], 0);
	if (err) {
		wpa_printf(MSG_ERROR, "ACS: Failed to get survey data");
		goto fail;
	}

	if (++iface->acs_num_completed_scans < iface->conf->acs_num_scans) {
		err = acs_request_scan(iface);
		if (err) {
			wpa_printf(MSG_ERROR, "ACS: Failed to request scan");
			goto fail;
		}

		return;
	}

	acs_study(iface);
	return;
fail:
	hostapd_acs_completed(iface, 1);
	acs_fail(iface);
}


static int * acs_request_scan_add_freqs(struct hostapd_iface *iface,
					struct hostapd_hw_modes *mode,
					int *freq)
{
	struct hostapd_channel_data *chan;
	int i;

	for (i = 0; i < mode->num_channels; i++) {
		chan = &mode->channels[i];
		if ((chan->flag & HOSTAPD_CHAN_DISABLED) ||
		    ((chan->flag & HOSTAPD_CHAN_RADAR) &&
		     iface->conf->acs_exclude_dfs))
			continue;

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

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

		if (chan->max_tx_power < iface->conf->min_tx_power)
			continue;

		if ((chan->flag & HOSTAPD_CHAN_INDOOR_ONLY) &&
		    iface->conf->country[2] == 0x4f)
			continue;

		*freq++ = chan->freq;
	}

	return freq;
}


static int acs_request_scan(struct hostapd_iface *iface)
{
	struct wpa_driver_scan_params params;
	int i, *freq;
	int num_channels;
	struct hostapd_hw_modes *mode;

	os_memset(&params, 0, sizeof(params));

	num_channels = 0;
	for (i = 0; i < iface->num_hw_features; i++) {
		mode = &iface->hw_features[i];
		if (!hostapd_hw_skip_mode(iface, mode))
			num_channels += mode->num_channels;
	}

	params.freqs = os_calloc(num_channels + 1, sizeof(params.freqs[0]));
	if (params.freqs == NULL)
		return -1;

	freq = params.freqs;

	for (i = 0; i < iface->num_hw_features; i++) {
		mode = &iface->hw_features[i];
		if (!hostapd_hw_skip_mode(iface, mode))
			freq = acs_request_scan_add_freqs(iface, mode, freq);
	}

	*freq = 0;

	if (params.freqs == freq) {
		wpa_printf(MSG_ERROR, "ACS: No available channels found");
		os_free(params.freqs);
		return -1;
	}

	iface->scan_cb = acs_scan_complete;

	wpa_printf(MSG_DEBUG, "ACS: Scanning %d / %d",
		   iface->acs_num_completed_scans + 1,
		   iface->conf->acs_num_scans);

	if (hostapd_driver_scan(iface->bss[0], &params) < 0) {
		wpa_printf(MSG_ERROR, "ACS: Failed to request initial scan");
		acs_cleanup(iface);
		os_free(params.freqs);
		return -1;
	}

	os_free(params.freqs);
	return 0;
}


enum hostapd_chan_status acs_init(struct hostapd_iface *iface)
{
	wpa_printf(MSG_INFO, "ACS: Automatic channel selection started, this may take a bit");

	if (iface->drv_flags & WPA_DRIVER_FLAGS_ACS_OFFLOAD) {
		wpa_printf(MSG_INFO, "ACS: Offloading to driver");
		if (hostapd_drv_do_acs(iface->bss[0]))
			return HOSTAPD_CHAN_INVALID;
		return HOSTAPD_CHAN_ACS;
	}

	if (!iface->current_mode &&
	    iface->conf->hw_mode != HOSTAPD_MODE_IEEE80211ANY)
		return HOSTAPD_CHAN_INVALID;

	acs_cleanup(iface);

	if (acs_request_scan(iface) < 0)
		return HOSTAPD_CHAN_INVALID;

	hostapd_set_state(iface, HAPD_IFACE_ACS);
	wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, ACS_EVENT_STARTED);

	return HOSTAPD_CHAN_ACS;
}
