[][[MAC80211][hospad] add config to disable_eht disable_he capabilitiy for STA connection ]

[Description]
Add patch adjusting STA side wiremode from wpa_supplicant

[Release-log]


Change-Id: I0e6290903826d3be5c892337adb02c0ea9012089
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7282636
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/mtk-0024-hostapd-mtk-Add-support-for-masking-EHT-capabilities.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/mtk-0024-hostapd-mtk-Add-support-for-masking-EHT-capabilities.patch
new file mode 100644
index 0000000..778d74d
--- /dev/null
+++ b/autobuild_mac80211_release/package/network/services/hostapd/patches/mtk-0024-hostapd-mtk-Add-support-for-masking-EHT-capabilities.patch
@@ -0,0 +1,227 @@
+From 626077ef532dd21d8f19ef7c8b521348aedc74d7 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] 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 ba34fd4..efc7594 100644
+--- a/wpa_supplicant/wpa_supplicant.c
++++ b/wpa_supplicant/wpa_supplicant.c
+@@ -4082,6 +4082,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
+ 	/*
+@@ -5877,6 +5881,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
+