[PATCH 1/2] wpa_supplicant: Enable HT40 automatically when setting up AP mode operation
Jose Blanquicet
blanquicet at gmail.com
Thu Aug 25 06:30:38 PDT 2016
This patch aims to automatically enable 40MHz channel width based on
driver capabilities when setting up an AP mode operation. It can also be
prevented that using the disable_ht40 network parameter.
---
wpa_supplicant/ap.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 75 insertions(+), 8 deletions(-)
diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index 7710a8d..2826c28 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -96,6 +96,52 @@ no_vht:
}
#endif /* CONFIG_IEEE80211N */
+#ifdef CONFIG_IEEE80211N
+static int wpas_conf_ap_mode_ht_chwidth(struct hostapd_hw_modes *mode, u8 channel)
+{
+ int j, secondary_channel = 0;
+ struct hostapd_channel_data *pri_chan = NULL, *sec_chan = NULL;
+ int ht40plus[] = { 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157,
+ 184, 192 };
+
+ /*
+ * Only HT40+ is supported.
+ * TODO: Select HT40+ or HT40- based on Beacons detection.
+ */
+
+ for (j = 0; j < mode->num_channels; j++) {
+ pri_chan = &mode->channels[j];
+ if (pri_chan->chan == channel)
+ break;
+ pri_chan = NULL;
+ }
+ if (!pri_chan || (pri_chan->flag & (HOSTAPD_CHAN_DISABLED |
+ HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR)) ||
+ !(pri_chan->flag & HOSTAPD_CHAN_HT40PLUS))
+ return 0;
+
+ for (j = 0; j < ARRAY_SIZE(ht40plus); j++) {
+ if (ht40plus[j] == channel) {
+ secondary_channel = 1;
+ break;
+ }
+ }
+ if (!secondary_channel)
+ return 0;
+
+ for (j = 0; j < mode->num_channels; j++) {
+ sec_chan = &mode->channels[j];
+ if (sec_chan->chan == channel + 4)
+ break;
+ sec_chan = NULL;
+ }
+ if (!sec_chan || (sec_chan->flag & (HOSTAPD_CHAN_DISABLED |
+ HOSTAPD_CHAN_RADAR | HOSTAPD_CHAN_NO_IR)))
+ return 0;
+
+ return secondary_channel;
+}
+#endif /* CONFIG_IEEE80211N */
int wpa_supplicant_conf_ap_ht(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid,
@@ -110,7 +156,7 @@ int wpa_supplicant_conf_ap_ht(struct wpa_supplicant *wpa_s,
return -1;
}
- /* TODO: enable HT40 if driver supports it;
+ /* TODO: enable HT40 if driver supports it for non-AP use cases;
* drop to 11b if driver does not support 11g */
#ifdef CONFIG_IEEE80211N
@@ -140,18 +186,39 @@ int wpa_supplicant_conf_ap_ht(struct wpa_supplicant *wpa_s,
if (!no_ht && mode && mode->ht_capab) {
conf->ieee80211n = 1;
-#ifdef CONFIG_P2P
+
if (conf->hw_mode == HOSTAPD_MODE_IEEE80211A &&
(mode->ht_capab &
- HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) &&
- ssid->ht40)
- conf->secondary_channel =
- wpas_p2p_get_ht40_mode(wpa_s, mode,
- conf->channel);
+ HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET)) {
+
+ /* Enable HT40 when AP mode operation if the driver
+ * supports it unless it was specifically prevented.*/
+ if (ssid->mode == WPAS_MODE_AP) {
+ ssid->ht40 = 1;
+#ifdef CONFIG_HT_OVERRIDES
+ if (ssid->disable_ht40)
+ ssid->ht40 = 0;
+#endif /* CONFIG_HT_OVERRIDES */
+ }
+
+ if (ssid->ht40) {
+ if (ssid->mode == WPAS_MODE_AP) {
+ conf->secondary_channel =
+ wpas_conf_ap_mode_ht_chwidth(mode,
+ conf->channel);
+ } else {
+#ifdef CONFIG_P2P
+ conf->secondary_channel =
+ wpas_p2p_get_ht40_mode(wpa_s, mode,
+ conf->channel);
+#endif /* CONFIG_P2P */
+ }
+ }
+ }
+
if (conf->secondary_channel)
conf->ht_capab |=
HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
-#endif /* CONFIG_P2P */
/*
* white-list capabilities that won't cause issues
--
1.9.1
More information about the Hostap
mailing list