]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
HE: Dynamically turn on TWT responder support
authorJohn Crispin <john@phrozen.org>
Tue, 4 Feb 2020 08:05:40 +0000 (09:05 +0100)
committerJouni Malinen <j@w1.fi>
Sun, 16 Feb 2020 10:37:47 +0000 (12:37 +0200)
This allows us to dynamically turn on TWT responder support using an
nl80211 attribute.

Signed-off-by: John Crispin <john@phrozen.org>
src/ap/beacon.c
src/ap/ieee802_11.h
src/ap/ieee802_11_he.c
src/common/ieee802_11_defs.h
src/drivers/driver.h
src/drivers/driver_nl80211.c

index ecee27aa62b8c658902798b565e832bcc9d50691..3646245c0c37183955eccf346f7e8bb6cd5b9323 100644 (file)
@@ -1422,6 +1422,8 @@ int ieee802_11_set_beacon(struct hostapd_data *hapd)
                hapd->iface->conf->spr.srg_obss_pd_min_offset;
        params.he_spr_srg_obss_pd_max_offset =
                hapd->iface->conf->spr.srg_obss_pd_max_offset;
+       params.twt_responder = hostapd_get_he_twt_responder(hapd,
+                                                           IEEE80211_MODE_AP);
 #endif /* CONFIG_IEEE80211AX */
        hapd->reenable_beacon = 0;
 
index 0a035c5642c375a622b185f04af1fd2fd7ef929d..ab61eca9de661c6de88a7e7b4727636290dfbfe3 100644 (file)
@@ -96,6 +96,8 @@ u16 set_sta_vht_opmode(struct hostapd_data *hapd, struct sta_info *sta,
 u16 copy_sta_he_capab(struct hostapd_data *hapd, struct sta_info *sta,
                      enum ieee80211_op_mode opmode, const u8 *he_capab,
                      size_t he_capab_len);
+int hostapd_get_he_twt_responder(struct hostapd_data *hapd,
+                                enum ieee80211_op_mode mode);
 void hostapd_tx_status(struct hostapd_data *hapd, const u8 *addr,
                       const u8 *buf, size_t len, int ack);
 void hostapd_eapol_tx_status(struct hostapd_data *hapd, const u8 *dst,
index 31cf8d786ce41c1d066d3ea2f9f372cb6f8ee937..4b23e48c7bc81594e394491a359077372d824ee4 100644 (file)
@@ -413,3 +413,18 @@ u16 copy_sta_he_capab(struct hostapd_data *hapd, struct sta_info *sta,
 
        return WLAN_STATUS_SUCCESS;
 }
+
+
+int hostapd_get_he_twt_responder(struct hostapd_data *hapd,
+                                enum ieee80211_op_mode mode)
+{
+       u8 *mac_cap;
+
+       if (!hapd->iface->current_mode ||
+           !hapd->iface->current_mode->he_capab)
+               return 0;
+
+       mac_cap = hapd->iface->current_mode->he_capab[mode].mac_cap;
+
+       return mac_cap[HE_MAC_CAPAB_0] & HE_MACCAP_TWT_RESPONDER;
+}
index 748106a9c4bf60b6159b246df5ffb817c5c41d64..f7192705327c81da2b13874a24e138a701f54229 100644 (file)
@@ -2156,6 +2156,8 @@ struct ieee80211_spatial_reuse {
 
 /* HE Capabilities Information defines */
 
+#define HE_MACCAP_TWT_RESPONDER                        ((u8) BIT(2))
+
 #define HE_PHYCAP_CHANNEL_WIDTH_SET_IDX                0
 #define HE_PHYCAP_CHANNEL_WIDTH_MASK           ((u8) (BIT(1) | BIT(2) | \
                                                      BIT(3) | BIT(4)))
index d23e436be75cc69adfe46f22551823eb511f8362..caa555bb7580822797ebc84dd0d647913af89d1d 100644 (file)
@@ -182,6 +182,7 @@ struct hostapd_channel_data {
        struct hostapd_wmm_rule wmm_rules[WMM_AC_NUM];
 };
 
+#define HE_MAC_CAPAB_0         0
 #define HE_MAX_MAC_CAPAB_SIZE  6
 #define HE_MAX_PHY_CAPAB_SIZE  11
 #define HE_MAX_MCS_CAPAB_SIZE  12
@@ -1487,6 +1488,11 @@ struct wpa_driver_ap_params {
         * he_spr_srg_obss_pd_max_offset - Maximum TX power offset
         */
         int he_spr_srg_obss_pd_max_offset;
+
+       /**
+        * twt_responder - Whether Target Wait Time responder is enabled
+        */
+       int twt_responder;
 };
 
 struct wpa_driver_mesh_bss_params {
index 7305ed60b39ef6e57dfc6a4bd9612431c5aa55d0..f1c98b90b9e47b1e865cfebdc408da1fca3457f5 100644 (file)
@@ -4348,6 +4348,13 @@ static int wpa_driver_nl80211_set_ap(void *priv,
 
                nla_nest_end(msg, spr);
        }
+
+       if (params->twt_responder) {
+               wpa_printf(MSG_DEBUG, "nl80211: twt_responder=%d",
+                          params->twt_responder);
+               if (nla_put_flag(msg, NL80211_ATTR_TWT_RESPONDER))
+                       goto fail;
+       }
 #endif /* CONFIG_IEEE80211AX */
 
        ret = send_and_recv_msgs(drv, msg, NULL, NULL);