[PATCH 2/3] HE: add code to dynamically turn on TWT responder support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This allows us to dynamically turn TWT on responder support using a nl80211
attribute.

Signed-off-by: John Crispin <john@xxxxxxxxxxx>
---
 src/ap/beacon.c              | 3 +++
 src/ap/ieee802_11.h          | 1 +
 src/ap/ieee802_11_he.c       | 7 +++++++
 src/common/ieee802_11_defs.h | 2 ++
 src/drivers/driver.h         | 5 +++++
 src/drivers/driver_nl80211.c | 8 ++++++++
 6 files changed, 26 insertions(+)

diff --git a/src/ap/beacon.c b/src/ap/beacon.c
index a51b94960..756dde926 100644
--- a/src/ap/beacon.c
+++ b/src/ap/beacon.c
@@ -1421,6 +1421,9 @@ int ieee802_11_set_beacon(struct hostapd_data *hapd)
 	params.proberesp_ies = proberesp;
 	params.assocresp_ies = assocresp;
 	params.reenable = hapd->reenable_beacon;
+#ifdef CONFIG_IEEE80211AX
+	params.twt_responder = hostapd_get_he_twt_responder(hapd);
+#endif
 	hapd->reenable_beacon = 0;
 
 	if (cmode &&
diff --git a/src/ap/ieee802_11.h b/src/ap/ieee802_11.h
index b8453c992..01b1baa5c 100644
--- a/src/ap/ieee802_11.h
+++ b/src/ap/ieee802_11.h
@@ -95,6 +95,7 @@ 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);
 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,
diff --git a/src/ap/ieee802_11_he.c b/src/ap/ieee802_11_he.c
index c785aab23..72bc9bf09 100644
--- a/src/ap/ieee802_11_he.c
+++ b/src/ap/ieee802_11_he.c
@@ -373,3 +373,10 @@ 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)
+{
+	u8 *mac_cap = hapd->iface->current_mode->he_capab->mac_cap;
+
+	return mac_cap[0] & HE_MACCAP_TWT_RESPONDER;
+}
diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h
index 214ba0e0f..1d302559e 100644
--- a/src/common/ieee802_11_defs.h
+++ b/src/common/ieee802_11_defs.h
@@ -2139,6 +2139,8 @@ struct ieee80211_spatial_reuse {
 
 /* HE Capabilities Information defines */
 
+#define HE_MACCAP_TWT_RESPONDER			((u8) BIT(3))
+
 #define HE_PHYCAP_CHANNEL_WIDTH_SET_IDX		0
 #define HE_PHYCAP_CHANNEL_WIDTH_MASK		((u8) (BIT(1) | BIT(2) | \
 						      BIT(3) | BIT(4)))
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 2a8459ae3..198745ca6 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -1442,6 +1442,11 @@ struct wpa_driver_ap_params {
 	 * type 11 as defined in IEEE Std 802.11-2016, 9.4.2.22.13
 	 */
 	const struct wpabuf *civic;
+
+	/**
+	 * twt_responder - Whether Target Wait Time responder is enabled
+	 */
+	int twt_responder;
 };
 
 struct wpa_driver_mesh_bss_params {
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index d71511cb5..e0f69c967 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -4286,6 +4286,14 @@ static int wpa_driver_nl80211_set_ap(void *priv,
 		nla_nest_end(msg, ftm);
 	}
 
+#ifdef CONFIG_IEEE80211AX
+	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
 	ret = send_and_recv_msgs(drv, msg, NULL, NULL);
 	if (ret) {
 		wpa_printf(MSG_DEBUG, "nl80211: Beacon set failed: %d (%s)",
-- 
2.20.1


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux