[PATCH v2 2/4] ACS: introduce acs_get_bw_center_chan

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When using 40/80/160MHz, instead of computing the segment center freq
based on the selected channel, lets look it up in the bw_desc table.

This is preparative work to allow selecting a primary channel which is
not the first of the segment.

Signed-off-by: Nicolas Escande <nico.escande@xxxxxxxxx>
---
 src/ap/acs.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/ap/acs.c b/src/ap/acs.c
index db9adb8e1..a6cdfb962 100644
--- a/src/ap/acs.c
+++ b/src/ap/acs.c
@@ -436,6 +436,21 @@ static int acs_usable_bw_chan(const struct hostapd_channel_data *chan,
 }
 
 
+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 + 1)
+			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)) {
@@ -929,19 +944,21 @@ bw_selected:
 
 static void acs_adjust_center_freq(struct hostapd_iface *iface)
 {
-	int offset;
+	int center;
 
 	wpa_printf(MSG_DEBUG, "ACS: Adjusting VHT center frequency");
 
 	switch (hostapd_get_oper_chwidth(iface->conf)) {
 	case CHANWIDTH_USE_HT:
-		offset = 2 * iface->conf->secondary_channel;
+		center = (iface->conf->secondary_channel) ?
+			  acs_get_bw_center_chan(iface->freq, ACS_BW40):
+			  iface->conf->channel;
 		break;
 	case CHANWIDTH_80MHZ:
-		offset = 6;
+		center = acs_get_bw_center_chan(iface->freq, ACS_BW80);
 		break;
 	case CHANWIDTH_160MHZ:
-		offset = 14;
+		center = acs_get_bw_center_chan(iface->freq, ACS_BW160);
 		break;
 	default:
 		/* TODO: How can this be calculated? Adjust
@@ -951,8 +968,7 @@ static void acs_adjust_center_freq(struct hostapd_iface *iface)
 		return;
 	}
 
-	hostapd_set_oper_centr_freq_seg0_idx(iface->conf,
-					     iface->conf->channel + offset);
+	hostapd_set_oper_centr_freq_seg0_idx(iface->conf, center);
 }
 
 
-- 
2.36.0


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux