diff mbox series

HE: dynamically enable TWT responder support

Message ID 20191218193318.GA8929@zen.lan
State Changes Requested
Headers show
Series HE: dynamically enable TWT responder support | expand

Commit Message

Mikhail Karpenko Dec. 18, 2019, 7:33 p.m. UTC
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@fastmail.com>
---
 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(+)

Comments

Johannes Berg Dec. 18, 2019, 9:33 p.m. UTC | #1
On Wed, 2019-12-18 at 22:33 +0300, Mikhail Karpenko wrote:

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

If that's the case, you should probably not

> Signed-off-by: Mikhail Karpenko <karpenko@fastmail.com>

remove his signed-off-by ...

Probably better to just send a patch on top?

johannes
John Crispin Dec. 18, 2019, 11:20 p.m. UTC | #2
On 18/12/2019 22:33, Johannes Berg wrote:
> On Wed, 2019-12-18 at 22:33 +0300, Mikhail Karpenko wrote:
> 
>> This patch is a modified version of the patch sent by John Crispin:
>> https://patchwork.ozlabs.org/patch/1146385/
> 
> If that's the case, you should probably not
> 
>> Signed-off-by: Mikhail Karpenko <karpenko@fastmail.com>
> 
> remove his signed-off-by ...
> 
> Probably better to just send a patch on top?
> 
> johannes
> 

I'll be reseeding in the next days, so pleases ignore this one
	John
> _______________________________________________
> Hostap mailing list
> Hostap@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/hostap
>
Sergey Matyukevich Jan. 20, 2020, 1:26 p.m. UTC | #3
> [External Email]: This email arrived from an external source - Please exercise caution when opening any attachments or clicking on links.
> 
> On 18/12/2019 22:33, Johannes Berg wrote:
> > On Wed, 2019-12-18 at 22:33 +0300, Mikhail Karpenko wrote:
> > 
> > > This patch is a modified version of the patch sent by John Crispin:
> > > https://urldefense.proofpoint.com/v2/url?u=https-3A__patchwork.ozlabs.org_patch_1146385_&d=DwICAg&c=MHZppzMdXMt3JYjCV71UsQ&r=8cgexqCLKvlxueeX60auiFI0HuWfr8XkvM5QshJSEkUOT2UjeCCljcTIuC8JXX_c&m=OWgbxubk_VmK-q_LsBfJba5Cu5roUcBgSbwoSWdMSls&s=EImlAQAYI1CmNBbpMw6MBWeuQ3IwWupih9oAKbjStDs&e=
> > 
> > If that's the case, you should probably not
> > 
> > > Signed-off-by: Mikhail Karpenko <karpenko@fastmail.com>
> > 
> > remove his signed-off-by ...
> > 
> > Probably better to just send a patch on top?
> > 
> > johannes
> > 
> 
> I'll be reseeding in the next days, so pleases ignore this one
> 	John

Hello John,

Do you still plan to re-send a TWT patch ? Or we can proceed with
an update of our version, keeping proper signed-off-by ?

Regards,
Sergey
diff mbox series

Patch

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);