[PATCH 2/2] ibss: enable HT40 if supported

Janusz Dziedzic janusz.dziedzic
Sun Dec 28 23:14:59 PST 2014


Setup HT40+/HT40- if supported by driver.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic at tieto.com>
---
 wpa_supplicant/wpa_supplicant.c | 70 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 69 insertions(+), 1 deletion(-)

diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 4e1bd55..086b382 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -1599,8 +1599,10 @@ static void ibss_setup_freq(struct wpa_supplicant *wpa_s, const struct wpa_ssid
 {
 	enum hostapd_hw_mode hw_mode;
 	struct hostapd_hw_modes *mode = NULL;
+	int allowed_40[] = { 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157, 184, 192 };
+	struct hostapd_channel_data *pri_chan = NULL, *sec_chan = NULL;
+	int i, chan_idx, ht40 = -1;
 	u8 channel;
-	int i;
 
 	freq->freq = ssid->frequency;
 
@@ -1620,6 +1622,72 @@ static void ibss_setup_freq(struct wpa_supplicant *wpa_s, const struct wpa_ssid
 
 	freq->ht_enabled = ht_supported(mode);
 
+	if (!freq->ht_enabled)
+		return;
+
+	/* Setup higher BW only for 5GHz */
+	if (mode->mode != HOSTAPD_MODE_IEEE80211A)
+		return;
+
+	for (chan_idx = 0; chan_idx < mode->num_channels; chan_idx++) {
+		pri_chan = &mode->channels[chan_idx];
+		if (pri_chan->chan == channel)
+			break;
+	}
+
+	if (chan_idx == mode->num_channels)
+		return;
+
+	/* Check primary channel flags */
+	if (pri_chan->flag & HOSTAPD_CHAN_DISABLED)
+		return;
+
+	if (pri_chan->flag & HOSTAPD_CHAN_NO_IR)
+		return;
+
+	/* Check/setup HT40+/HT40- */
+	for (i = 0; i < ARRAY_SIZE(allowed_40); i++) {
+		if (allowed_40[i] == channel) {
+			ht40 = 1;
+			break;
+		}
+	}
+
+	/* Find secondary channel */
+	for (i = 0; i < mode->num_channels; i++) {
+		sec_chan = &mode->channels[i];
+		if (sec_chan->chan == channel + ht40 * 4)
+			break;
+	}
+
+	if (sec_chan->chan != pri_chan->chan + ht40 * 4)
+		return;
+
+	/* Check secondary channel flags */
+	if (sec_chan->flag & HOSTAPD_CHAN_DISABLED)
+		return;
+
+	if (sec_chan->flag & HOSTAPD_CHAN_NO_IR)
+		return;
+
+	switch (ht40) {
+	case -1:
+		if (!(pri_chan->flag & HOSTAPD_CHAN_HT40MINUS))
+			return;
+		freq->sec_channel_offset = -1;
+		break;
+	case 1:
+		if (!(pri_chan->flag & HOSTAPD_CHAN_HT40PLUS))
+			return;
+		freq->sec_channel_offset = 1;
+		break;
+	default:
+		break;
+	}
+
+	wpa_printf(MSG_DEBUG, "ibss setup freq channel %d, sec_channel_offset %d",
+		   pri_chan->chan, freq->sec_channel_offset);
+
 	return;
 }
 
-- 
1.9.1




More information about the Hostap mailing list