HT: Let the driver advertise its supported SMPS modes for AP mode
authorEliad Peller <eliad@wizery.com>
Mon, 20 Oct 2014 03:21:39 +0000 (23:21 -0400)
committerJouni Malinen <j@w1.fi>
Thu, 23 Oct 2014 22:25:29 +0000 (01:25 +0300)
Add smps_modes field, and let the driver fill it with its supported SMPS
modes (static/dynamic). This will let us start an AP with specific SMPS
mode (e.g., dynamic) that will allow it to reduce its power usage.

Signed-off-by: Eliad Peller <eliad@wizery.com>
hostapd/main.c
src/ap/hostapd.h
src/ap/hw_features.c
src/drivers/driver.h
wpa_supplicant/ap.c
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index a9d91b9..5a47711 100644 (file)
@@ -213,6 +213,7 @@ static int hostapd_driver_init(struct hostapd_iface *iface)
        if (hapd->driver->get_capa &&
            hapd->driver->get_capa(hapd->drv_priv, &capa) == 0) {
                iface->drv_flags = capa.flags;
+               iface->smps_modes = capa.smps_modes;
                iface->probe_resp_offloads = capa.probe_resp_offloads;
                iface->extended_capa = capa.extended_capa;
                iface->extended_capa_mask = capa.extended_capa_mask;
index 50ebe0e..be9d43a 100644 (file)
@@ -296,6 +296,9 @@ struct hostapd_iface {
 
        unsigned int drv_flags;
 
+       /* SMPS modes supported by the driver (WPA_DRIVER_SMPS_MODE_*) */
+       unsigned int smps_modes;
+
        /*
         * A bitmap of supported protocols for probe response offload. See
         * struct wpa_driver_capa in driver.h
index 4e66d1b..d7d5e83 100644 (file)
@@ -746,11 +746,24 @@ static int ieee80211n_supported_ht_capab(struct hostapd_iface *iface)
                return 0;
        }
 
-       if ((conf & HT_CAP_INFO_SMPS_MASK) != (hw & HT_CAP_INFO_SMPS_MASK) &&
-           (conf & HT_CAP_INFO_SMPS_MASK) != HT_CAP_INFO_SMPS_DISABLED) {
-               wpa_printf(MSG_ERROR, "Driver does not support configured "
-                          "HT capability [SMPS-*]");
-               return 0;
+       switch (conf & HT_CAP_INFO_SMPS_MASK) {
+       case HT_CAP_INFO_SMPS_STATIC:
+               if (!(iface->smps_modes & WPA_DRIVER_SMPS_MODE_STATIC)) {
+                       wpa_printf(MSG_ERROR,
+                                  "Driver does not support configured HT capability [SMPS-STATIC]");
+                       return 0;
+               }
+               break;
+       case HT_CAP_INFO_SMPS_DYNAMIC:
+               if (!(iface->smps_modes & WPA_DRIVER_SMPS_MODE_DYNAMIC)) {
+                       wpa_printf(MSG_ERROR,
+                                  "Driver does not support configured HT capability [SMPS-DYNAMIC]");
+                       return 0;
+               }
+               break;
+       case HT_CAP_INFO_SMPS_DISABLED:
+       default:
+               break;
        }
 
        if ((conf & HT_CAP_INFO_GREEN_FIELD) &&
index 7f1ee82..5fecd04 100644 (file)
@@ -1056,6 +1056,10 @@ struct wpa_driver_capa {
 #define WPA_DRIVER_FLAGS_MESH                  0x0000000100000000ULL
        u64 flags;
 
+#define WPA_DRIVER_SMPS_MODE_STATIC                    0x00000001
+#define WPA_DRIVER_SMPS_MODE_DYNAMIC                   0x00000002
+       unsigned int smps_modes;
+
        int max_scan_ssids;
        int max_sched_scan_ssids;
        int sched_scan_supported;
index 7555c42..ec6e868 100644 (file)
@@ -555,6 +555,7 @@ int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
                return -1;
        hapd_iface->owner = wpa_s;
        hapd_iface->drv_flags = wpa_s->drv_flags;
+       hapd_iface->smps_modes = wpa_s->drv_smps_modes;
        hapd_iface->probe_resp_offloads = wpa_s->probe_resp_offloads;
        hapd_iface->extended_capa = wpa_s->extended_capa;
        hapd_iface->extended_capa_mask = wpa_s->extended_capa_mask;
index 044a964..353a54d 100644 (file)
@@ -3804,6 +3804,7 @@ static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s,
                wpa_s->drv_capa_known = 1;
                wpa_s->drv_flags = capa.flags;
                wpa_s->drv_enc = capa.enc;
+               wpa_s->drv_smps_modes = capa.smps_modes;
                wpa_s->probe_resp_offloads = capa.probe_resp_offloads;
                wpa_s->max_scan_ssids = capa.max_scan_ssids;
                wpa_s->max_sched_scan_ssids = capa.max_sched_scan_ssids;
index 0adbeb0..a0acf3c 100644 (file)
@@ -574,6 +574,7 @@ struct wpa_supplicant {
 
        u64 drv_flags;
        unsigned int drv_enc;
+       unsigned int drv_smps_modes;
 
        /*
         * A bitmap of supported protocols for probe response offload. See