blob: 1ecf08b22fcb0a980ee99f7c2e7243504e8a981c [file] [log] [blame]
From f910e307237f20440fd1664918fe3b8399267b45 Mon Sep 17 00:00:00 2001
From: Amit Khatri <amit.khatri@mediatek.com>
Date: Thu, 23 Mar 2023 14:26:46 +0800
Subject: [PATCH 24/25] hostapd: mtk: Add support for masking EHT capabilities.
If STA want to disable EHT mode connection.
STA can set
disable_eht=1 in netowrk bloack of AP configuration.
e.g.
wpa_cli -iapcli0 set_network 0 disable_eht=1
It will make EHT capability on driver level.
Signed-off-by: Amit Khatri <amit.khatri@mediatek.com>
---
src/drivers/driver.h | 8 ++++++++
src/drivers/driver_nl80211.c | 9 +++++++++
src/drivers/nl80211_copy.h | 2 ++
wpa_supplicant/Makefile | 4 ++++
wpa_supplicant/config.c | 3 +++
wpa_supplicant/config_file.c | 3 +++
wpa_supplicant/config_ssid.h | 11 +++++++++++
wpa_supplicant/sme.c | 4 ++++
wpa_supplicant/wpa_cli.c | 3 +++
wpa_supplicant/wpa_supplicant.c | 15 +++++++++++++++
wpa_supplicant/wpa_supplicant_i.h | 6 ++++++
11 files changed, 68 insertions(+)
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 7f6392f..1bf0cd6 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -1151,6 +1151,14 @@ struct wpa_driver_associate_params {
int disable_he;
#endif /* CONFIG_HE_OVERRIDES */
+#ifdef CONFIG_EHT_OVERRIDES
+ /**
+ * disable_eht - Disable EHT for this connection
+ */
+ int disable_eht;
+#endif /* CONFIG_EHT_OVERRIDES */
+
+
/**
* req_key_mgmt_offload - Request key management offload for connection
*
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index f9a8763..945ce3e 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -6058,6 +6058,15 @@ static int nl80211_ht_vht_overrides(struct nl_msg *msg,
}
#endif /* CONFIG_HE_OVERRIDES */
+#ifdef CONFIG_EHT_OVERRIDES
+ if (params->disable_eht) {
+ wpa_printf(MSG_DEBUG, " * EHT disabled");
+ if (nla_put_flag(msg, NL80211_ATTR_DISABLE_EHT))
+ return -1;
+ }
+#endif /* CONFIG_EHT_OVERRIDES */
+
+
return 0;
}
diff --git a/src/drivers/nl80211_copy.h b/src/drivers/nl80211_copy.h
index 0937752..ce8ee58 100644
--- a/src/drivers/nl80211_copy.h
+++ b/src/drivers/nl80211_copy.h
@@ -3175,6 +3175,8 @@ enum nl80211_attrs {
NL80211_ATTR_EHT_CAPABILITY,
+ NL80211_ATTR_DISABLE_EHT,
+
/* add attributes here, update the policy in nl80211.c */
__NL80211_ATTR_AFTER_LAST,
diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile
index ef36b56..40cdb59 100644
--- a/wpa_supplicant/Makefile
+++ b/wpa_supplicant/Makefile
@@ -208,6 +208,10 @@ ifdef CONFIG_HE_OVERRIDES
CFLAGS += -DCONFIG_HE_OVERRIDES
endif
+ifdef CONFIG_EHT_OVERRIDES
+CFLAGS += -DCONFIG_EHT_OVERRIDES
+endif
+
ifndef CONFIG_BACKEND
CONFIG_BACKEND=file
endif
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index f9880ed..994ee5e 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -2718,6 +2718,9 @@ static const struct parse_data ssid_fields[] = {
#ifdef CONFIG_HE_OVERRIDES
{ INT_RANGE(disable_he, 0, 1)},
#endif /* CONFIG_HE_OVERRIDES */
+#ifdef CONFIG_EHT_OVERRIDES
+ { INT_RANGE(disable_eht, 0, 1)},
+#endif /* CONFIG_EHT_OVERRIDES */
{ INT(ap_max_inactivity) },
{ INT(dtim_period) },
{ INT(beacon_int) },
diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index 24c2998..056b265 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -881,6 +881,9 @@ static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid)
#ifdef CONFIG_HE_OVERRIDES
INT(disable_he);
#endif /* CONFIG_HE_OVERRIDES */
+#ifdef CONFIG_EHT_OVERRIDES
+ INT(disable_eht);
+#endif /* CONFIG_EHT_OVERRIDES */
#undef STR
#undef INT
diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h
index 9a389cc..cc9aa8e 100644
--- a/wpa_supplicant/config_ssid.h
+++ b/wpa_supplicant/config_ssid.h
@@ -810,6 +810,17 @@ struct wpa_ssid {
int disable_he;
#endif /* CONFIG_HE_OVERRIDES */
+#ifdef CONFIG_EHT_OVERRIDES
+ /**
+ * disable_eht - Disable EHT (IEEE 802.11be) for this network
+ *
+ * By default, use it if it is available, but this can be configured
+ * to 1 to have it disabled.
+ */
+ int disable_eht;
+#endif /* CONFIG_EHT_OVERRIDES */
+
+
/**
* ap_max_inactivity - Timeout in seconds to detect STA's inactivity
*
diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c
index 2dad36d..e7aadf6 100644
--- a/wpa_supplicant/sme.c
+++ b/wpa_supplicant/sme.c
@@ -2001,6 +2001,10 @@ mscs_fail:
#ifdef CONFIG_HE_OVERRIDES
wpa_supplicant_apply_he_overrides(wpa_s, ssid, &params);
#endif /* CONFIG_HE_OVERRIDES */
+#ifdef CONFIG_EHT_OVERRIDES
+ wpa_supplicant_apply_eht_overrides(wpa_s, ssid, &params);
+#endif /* CONFIG_EHT_OVERRIDES */
+
#ifdef CONFIG_IEEE80211R
if (auth_type == WLAN_AUTH_FT && wpa_s->sme.ft_ies &&
get_ie(wpa_s->sme.ft_ies, wpa_s->sme.ft_ies_len,
diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
index 8443f54..ea251db 100644
--- a/wpa_supplicant/wpa_cli.c
+++ b/wpa_supplicant/wpa_cli.c
@@ -1476,6 +1476,9 @@ static const char *network_fields[] = {
#ifdef CONFIG_HE_OVERRIDES
"disable_he",
#endif /* CONFIG_HE_OVERRIDES */
+#ifdef CONFIG_EHT_OVERRIDES
+ "disable_eht",
+#endif /* CONFIG_EHT_OVERRIDES */
"ap_max_inactivity", "dtim_period", "beacon_int",
#ifdef CONFIG_MACSEC
"macsec_policy",
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 04c37b1..67c801d 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -4084,6 +4084,10 @@ static void wpas_start_assoc_cb(struct wpa_radio_work *work, int deinit)
#ifdef CONFIG_HE_OVERRIDES
wpa_supplicant_apply_he_overrides(wpa_s, ssid, &params);
#endif /* CONFIG_HE_OVERRIDES */
+#ifdef CONFIG_EHT_OVERRIDES
+ wpa_supplicant_apply_eht_overrides(wpa_s, ssid, &params);
+#endif /* CONFIG_EHT_OVERRIDES */
+
#ifdef CONFIG_P2P
/*
@@ -5879,6 +5883,17 @@ void wpa_supplicant_apply_he_overrides(
}
#endif /* CONFIG_HE_OVERRIDES */
+#ifdef CONFIG_EHT_OVERRIDES
+void wpa_supplicant_apply_eht_overrides(
+ struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
+ struct wpa_driver_associate_params *params)
+{
+ if (!ssid)
+ return;
+
+ params->disable_eht = ssid->disable_eht;
+}
+#endif /* CONFIG_EHT_OVERRIDES */
static int pcsc_reader_init(struct wpa_supplicant *wpa_s)
{
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index 3285af3..76607c5 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -1576,6 +1576,12 @@ void wpa_supplicant_apply_vht_overrides(
void wpa_supplicant_apply_he_overrides(
struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
struct wpa_driver_associate_params *params);
+#ifdef CONFIG_EHT_OVERRIDES
+void wpa_supplicant_apply_eht_overrides(
+ struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
+ struct wpa_driver_associate_params *params);
+#endif CONFIG_EHT_OVERRIDES
+
int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
int wpa_supplicant_set_wpa_none_key(struct wpa_supplicant *wpa_s,
--
2.18.0