[PATCH 24/26] ap: Handle VHT operating classes correctly

Ilan Peer ilan.peer
Tue Sep 8 02:46:31 PDT 2015


From: Andrei Otcheretianski <andrei.otcheretianski at intel.com>

Fix and extend the ieee80211_freq_to_channel_ext function to deal
correctly with VHT operating classes (128, 129, 130).

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
 src/ap/hostapd.c               | 19 +++++++++++++++++--
 src/common/ieee802_11_common.c | 43 +++++++++++++++++++++---------------------
 2 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index 0dbd753..83c519e 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -2828,16 +2828,31 @@ static int hostapd_fill_csa_settings(struct hostapd_data *hapd,
 	struct hostapd_iface *iface = hapd->iface;
 	struct hostapd_freq_params old_freq;
 	int ret;
-	u8 chan;
+	u8 chan, vht_bandwidth;
 
 	os_memset(&old_freq, 0, sizeof(old_freq));
 	if (!iface || !iface->freq || hapd->csa_in_progress)
 		return -1;
 
+	switch (settings->freq_params.bandwidth) {
+	case 80:
+		if (settings->freq_params.center_freq2)
+			vht_bandwidth = VHT_CHANWIDTH_80P80MHZ;
+		else
+			vht_bandwidth = VHT_CHANWIDTH_80MHZ;
+
+		break;
+	case 160:
+		vht_bandwidth = VHT_CHANWIDTH_160MHZ;
+		break;
+	default:
+		vht_bandwidth = VHT_CHANWIDTH_USE_HT;
+	}
+
 	if (ieee80211_freq_to_channel_ext(
 		    settings->freq_params.freq,
 		    settings->freq_params.sec_channel_offset,
-		    settings->freq_params.vht_enabled,
+		    vht_bandwidth,
 		    &hapd->iface->cs_oper_class,
 		    &chan) == NUM_HOSTAPD_MODES) {
 		wpa_printf(MSG_DEBUG,
diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c
index 8be5b26..8eda612 100644
--- a/src/common/ieee802_11_common.c
+++ b/src/common/ieee802_11_common.c
@@ -579,7 +579,7 @@ enum hostapd_hw_mode ieee80211_freq_to_chan(int freq, u8 *channel)
  * for HT40 and VHT. DFS channels are not covered.
  * @freq: Frequency (MHz) to convert
  * @sec_channel: 0 = non-HT40, 1 = sec. channel above, -1 = sec. channel below
- * @vht: 0 - non-VHT, 1 - 80 MHz
+ * @vht: VHT channel width (VHT_CHANWIDTH_*)
  * @op_class: Buffer for returning operating class
  * @channel: Buffer for returning channel number
  * Returns: hw_mode on success, NUM_HOSTAPD_MODES on failure
@@ -588,6 +588,8 @@ enum hostapd_hw_mode ieee80211_freq_to_channel_ext(unsigned int freq,
 						   int sec_channel, int vht,
 						   u8 *op_class, u8 *channel)
 {
+	u8 vht_opclass = 0;
+
 	/* TODO: more operating classes */
 
 	if (sec_channel > 1 || sec_channel < -1)
@@ -631,17 +633,24 @@ enum hostapd_hw_mode ieee80211_freq_to_channel_ext(unsigned int freq,
 		return HOSTAPD_MODE_IEEE80211A;
 	}
 
+	if (vht == VHT_CHANWIDTH_80MHZ)
+		vht_opclass = 128;
+	else if (vht == VHT_CHANWIDTH_160MHZ)
+		vht_opclass = 129;
+	else if (vht == VHT_CHANWIDTH_80P80MHZ)
+		vht_opclass = 130;
+
 	/* 5 GHz, channels 36..48 */
 	if (freq >= 5180 && freq <= 5240) {
 		if ((freq - 5000) % 5)
 			return NUM_HOSTAPD_MODES;
 
-		if (sec_channel == 1)
+		if (vht_opclass)
+			*op_class = vht_opclass;
+		else if (sec_channel == 1)
 			*op_class = 116;
 		else if (sec_channel == -1)
 			*op_class = 117;
-		else if (vht)
-			*op_class = 128;
 		else
 			*op_class = 115;
 
@@ -650,31 +659,21 @@ enum hostapd_hw_mode ieee80211_freq_to_channel_ext(unsigned int freq,
 		return HOSTAPD_MODE_IEEE80211A;
 	}
 
-	/* 5 GHz, channels 149..161 */
-	if (freq >= 5745 && freq <= 5805) {
+	/* 5 GHz, channels 149..169 */
+	if (freq >= 5745 && freq <= 5845) {
 		if ((freq - 5000) % 5)
 			return NUM_HOSTAPD_MODES;
 
-		if (sec_channel == 1)
+		if (vht_opclass)
+			*op_class = vht_opclass;
+		else if (sec_channel == 1)
 			*op_class = 126;
 		else if (sec_channel == -1)
 			*op_class = 127;
-		else if (vht)
-			*op_class = 128;
-		else
+		else if (freq <= 5805)
 			*op_class = 124;
-
-		*channel = (freq - 5000) / 5;
-
-		return HOSTAPD_MODE_IEEE80211A;
-	}
-
-	/* 5 GHz, channels 149..169 */
-	if (freq >= 5745 && freq <= 5845) {
-		if ((freq - 5000) % 5)
-			return NUM_HOSTAPD_MODES;
-
-		*op_class = 125;
+		else
+			*op_class = 125;
 
 		*channel = (freq - 5000) / 5;
 
-- 
1.9.1




More information about the Hostap mailing list