[PATCH] HE: dynamically enable TWT responder support

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

 



Turn TWT responder support on/off based on HE capabilities
retrieved from interface.

This patch is a modified version of the patch sent by John Crispin:
https://patchwork.ozlabs.org/patch/1146385/

Signed-off-by: Mikhail Karpenko <karpenko@xxxxxxxxxxxx>
---
 src/ap/beacon.c              |  2 ++
 src/ap/ieee802_11.h          |  2 ++
 src/ap/ieee802_11_he.c       | 12 ++++++++++++
 src/ap/ieee802_11_shared.c   |  9 +++++++++
 src/common/ieee802_11_defs.h |  2 ++
 src/drivers/driver.h         |  5 +++++
 src/drivers/driver_nl80211.c |  7 +++++++
 7 files changed, 39 insertions(+)

diff --git a/src/ap/beacon.c b/src/ap/beacon.c
index 331c09bc2..27d2b5fde 100644
--- a/src/ap/beacon.c
+++ b/src/ap/beacon.c
@@ -1425,6 +1425,8 @@ int ieee802_11_set_beacon(struct hostapd_data *hapd)
 	params.assocresp_ies = assocresp;
 	params.reenable = hapd->reenable_beacon;
 #ifdef CONFIG_IEEE80211AX
+	params.twt_responder = hapd->iconf->ieee80211ax &&
+		hostapd_get_he_twt_responder(hapd, IEEE80211_MODE_AP);
 	params.he_spr = !!hapd->iface->conf->spr.sr_control;
 	params.he_spr_srg_obss_pd_min_offset =
 		hapd->iface->conf->spr.srg_obss_pd_min_offset;
diff --git a/src/ap/ieee802_11.h b/src/ap/ieee802_11.h
index f592da54a..48a09ca6e 100644
--- a/src/ap/ieee802_11.h
+++ b/src/ap/ieee802_11.h
@@ -95,6 +95,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 opmode);
 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 abd39409e..bf1ebdeef 100644
--- a/src/ap/ieee802_11_he.c
+++ b/src/ap/ieee802_11_he.c
@@ -402,3 +402,15 @@ 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)
+{
+	if (hapd->iface->current_mode) {
+		u8 *mac_cap = hapd->iface->current_mode->he_capab[mode].mac_cap;
+
+		return mac_cap[0] & HE_MACCAP_TWT_RESPONDER;
+	}
+
+	return 0;
+}
diff --git a/src/ap/ieee802_11_shared.c b/src/ap/ieee802_11_shared.c
index 1e1cc3825..4f6f4609f 100644
--- a/src/ap/ieee802_11_shared.c
+++ b/src/ap/ieee802_11_shared.c
@@ -375,6 +375,10 @@ static void hostapd_ext_capab_byte(struct hostapd_data *hapd, u8 *pos, int idx)
 		    wpa_key_mgmt_fils(hapd->conf->wpa_key_mgmt))
 			*pos |= 0x01;
 #endif /* CONFIG_FILS */
+#ifdef CONFIG_IEEE80211AX
+		if (hostapd_get_he_twt_responder(hapd, IEEE80211_MODE_AP))
+			*pos |= 0x40; /* Bit 78 - TWT responder */
+#endif /* CONFIG_IEEE80211AX */
 		break;
 	case 10: /* Bits 80-87 */
 #ifdef CONFIG_SAE
@@ -438,6 +442,11 @@ u8 * hostapd_eid_ext_capab(struct hostapd_data *hapd, u8 *eid)
 	     !wpa_key_mgmt_fils(hapd->conf->wpa_key_mgmt)) && len < 10)
 		len = 10;
 #endif /* CONFIG_FILS */
+#ifdef CONFIG_IEEE80211AX
+	if (len < 10 && hapd->iconf->ieee80211ax &&
+			hostapd_get_he_twt_responder(hapd, IEEE80211_MODE_AP))
+		len = 10;
+#endif /* CONFIG_IEEE80211AX */
 #ifdef CONFIG_SAE
 	if (len < 11 && hapd->conf->wpa &&
 	    wpa_key_mgmt_sae(hapd->conf->wpa_key_mgmt) &&
diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h
index fbed05119..6c4092c57 100644
--- a/src/common/ieee802_11_defs.h
+++ b/src/common/ieee802_11_defs.h
@@ -2150,6 +2150,8 @@ struct ieee80211_spatial_reuse {
 
 /* HE Capabilities Information defines */
 
+#define HE_MACCAP_TWT_RESPONDER			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)))
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index c6b7db8c2..7e45651f1 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -1487,6 +1487,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 Wake 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 02b952719..0c75a2b8d 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -4322,6 +4322,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);
-- 
2.17.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