[][MAC80211][misc][rework hostapd and mac80211 patches]

[Description]
Fix missing subject of "mtk" in hostapd and mac80211 patches.

[Release-log]
N/A

iChange-Id: Ifcb9794269732be3a27c9b7cf031f0e0c3547064
Change-Id: I43591694c8dabec9f9bd8cf55e9017d62f09f8c4
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/6836847
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/99900-hostapd-mtk-Add-hostapd_neighbor_count-and-hostapd_neighbor_ins.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/99900-hostapd-mtk-Add-hostapd_neighbor_count-and-hostapd_neighbor_ins.patch
deleted file mode 100644
index e8e8b8c..0000000
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/99900-hostapd-mtk-Add-hostapd_neighbor_count-and-hostapd_neighbor_ins.patch
+++ /dev/null
@@ -1,72 +0,0 @@
-From 194a2405c98852358de25d96cb9d1c7c56ea4bdc Mon Sep 17 00:00:00 2001
-From: "howard.hsu" <howard-yh.hsu@mediatek.com>
-Date: Wed, 19 Jan 2022 19:18:07 +0800
-Subject: [PATCH 99900/99917] Add hostapd_neighbor_count() and
- hostapd_neighbor_insert_buffer ()
-
-The first function can count the number of neighbor report in neighbore report
-database. The second can iterate neighbor report database to build up neighbor
-report data.
----
- src/ap/neighbor_db.c | 32 ++++++++++++++++++++++++++++++++
- src/ap/neighbor_db.h |  3 +++
- 2 files changed, 35 insertions(+)
-
-diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c
-index 52f25eb..c121390 100644
---- a/src/ap/neighbor_db.c
-+++ b/src/ap/neighbor_db.c
-@@ -89,6 +89,38 @@ int hostapd_neighbor_show(struct hostapd_data *hapd, char *buf, size_t buflen)
- }
- 
- 
-+int hostapd_neighbor_count(struct hostapd_data *hapd)
-+{
-+	struct hostapd_neighbor_entry *nr;
-+	int count = 0;
-+
-+	dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry,
-+			 list) {
-+		count++;
-+	}
-+	return count;
-+}
-+
-+
-+int hostapd_neighbor_insert_buffer(struct hostapd_data *hapd, char *buf,
-+        size_t buflen)
-+{
-+	struct hostapd_neighbor_entry *nr;
-+	char *pos = buf;
-+
-+	dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry,
-+			 list) {
-+		/* For neighbor report IE, we only need bssid and nr*/
-+		*pos++ = WLAN_EID_NEIGHBOR_REPORT;
-+		*pos++ = wpabuf_len(nr->nr);
-+		os_memcpy(pos, wpabuf_head(nr->nr), wpabuf_len(nr->nr));
-+		pos += wpabuf_len(nr->nr);
-+	}
-+
-+	return pos - buf;
-+}
-+
-+
- static void hostapd_neighbor_clear_entry(struct hostapd_neighbor_entry *nr)
- {
- 	wpabuf_free(nr->nr);
-diff --git a/src/ap/neighbor_db.h b/src/ap/neighbor_db.h
-index 992671b..1ae194d 100644
---- a/src/ap/neighbor_db.h
-+++ b/src/ap/neighbor_db.h
-@@ -24,4 +24,7 @@ int hostapd_neighbor_remove(struct hostapd_data *hapd, const u8 *bssid,
- 			    const struct wpa_ssid_value *ssid);
- void hostapd_free_neighbor_db(struct hostapd_data *hapd);
- 
-+int hostapd_neighbor_count(struct hostapd_data *hapd);
-+int hostapd_neighbor_insert_buffer(struct hostapd_data *hapd, char *buf,
-+        size_t buflen);
- #endif /* NEIGHBOR_DB_H */
--- 
-2.36.1
-
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/99900-hostapd-mtk-Add-neighbor-report-and-BSS-Termination.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/99900-hostapd-mtk-Add-neighbor-report-and-BSS-Termination.patch
new file mode 100644
index 0000000..28af8ef
--- /dev/null
+++ b/autobuild_mac80211_release/package/network/services/hostapd/patches/99900-hostapd-mtk-Add-neighbor-report-and-BSS-Termination.patch
@@ -0,0 +1,475 @@
+From af1bd5256cc764fb222f9809996851ff3d879699 Mon Sep 17 00:00:00 2001
+From: "howard.hsu" <howard-yh.hsu@mediatek.com>
+Date: Wed, 19 Jan 2022 19:18:07 +0800
+Subject: [PATCH 99900/99909] hostapd: mtk: Add neighbor report and BSS
+ Termination for MBO certification
+
+1. Add hostapd_neighbor_count() and hostapd_neighbor_insert_buffer ()
+The first function can count the number of neighbor report in neighbore report
+database. The second can iterate neighbor report database to build up neighbor
+report data.
+
+2. Support including neighbor report elements in ANQP response
+3. Support including neignbor report elements in BTM response
+4. Support configuring BSS Termination TSF by using hostapd_cli command
+5. Disable interface if BSS Termination TSF is set
+6. Add set_send_disassoc_frame_timer() to send disassociate frame
+Function set_disassoc_timer() may fail if key was deleted first. This new
+function will not ask to delete key as set_disassoc_timer() did.
+7. Support including neighbor report elements in BTM request
+8. Add hostapd_neighbor_set_own_report_pref()
+9. Add hostapd_neighbor_set_pref_by_non_pref_chan()
+---
+ hostapd/ctrl_iface.c   |   5 ++
+ src/ap/ap_config.c     |   1 +
+ src/ap/ap_config.h     |   1 +
+ src/ap/ctrl_iface_ap.c |  19 ++++++-
+ src/ap/gas_serv.c      |  29 ++++++++++
+ src/ap/gas_serv.h      |   2 +
+ src/ap/neighbor_db.c   | 119 +++++++++++++++++++++++++++++++++++++++++
+ src/ap/neighbor_db.h   |   9 ++++
+ src/ap/wnm_ap.c        |  72 +++++++++++++++++++++++--
+ 9 files changed, 252 insertions(+), 5 deletions(-)
+
+diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
+index a258492..c2a2822 100644
+--- a/hostapd/ctrl_iface.c
++++ b/hostapd/ctrl_iface.c
+@@ -1338,6 +1338,11 @@ static int hostapd_ctrl_iface_set(struct hostapd_data *hapd, char *cmd)
+ #endif /* CONFIG_DPP */
+ 	} else if (os_strcasecmp(cmd, "setband") == 0) {
+ 		ret = hostapd_ctrl_iface_set_band(hapd, value);
++	} else if (os_strcasecmp(cmd, "bss_termination_tsf") == 0) {
++		int termination_sec = atoi(value);
++		hapd->conf->bss_termination_tsf = termination_sec;
++		wpa_printf(MSG_DEBUG, "BSS Termination TSF: value = %d",
++                termination_sec);
+ 	} else {
+ 		ret = hostapd_set_iface(hapd->iconf, hapd->conf, cmd, value);
+ 		if (ret)
+diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c
+index d7a0c7c..4a20eb4 100644
+--- a/src/ap/ap_config.c
++++ b/src/ap/ap_config.c
+@@ -170,6 +170,7 @@ void hostapd_config_defaults_bss(struct hostapd_bss_config *bss)
+ 	/* comeback after 10 TUs */
+ 	bss->pasn_comeback_after = 10;
+ #endif /* CONFIG_PASN */
++	bss->bss_termination_tsf = 0;
+ }
+ 
+ 
+diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
+index ed3bec7..3f68e76 100644
+--- a/src/ap/ap_config.h
++++ b/src/ap/ap_config.h
+@@ -557,6 +557,7 @@ struct hostapd_bss_config {
+ 	int wnm_sleep_mode;
+ 	int wnm_sleep_mode_no_keys;
+ 	int bss_transition;
++	unsigned int bss_termination_tsf;
+ 
+ 	/* IEEE 802.11u - Interworking */
+ 	int interworking;
+diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c
+index 96209ce..18bae5c 100644
+--- a/src/ap/ctrl_iface_ap.c
++++ b/src/ap/ctrl_iface_ap.c
+@@ -1203,6 +1203,10 @@ int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd,
+ 			wpa_printf(MSG_DEBUG, "Invalid bss_term data");
+ 			return -1;
+ 		}
++		if (hapd->conf->bss_termination_tsf) {
++			WPA_PUT_LE64(&bss_term_dur[2], hapd->conf->bss_termination_tsf);
++		}
++
+ 		end++;
+ 		WPA_PUT_LE16(&bss_term_dur[10], atoi(end));
+ 	}
+@@ -1229,14 +1233,25 @@ int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd,
+ 		req_mode |= WNM_BSS_TM_REQ_ESS_DISASSOC_IMMINENT;
+ 	}
+ 
+-	if (os_strstr(cmd, " pref=1"))
++	if (os_strstr(cmd, " pref=1")) {
+ 		req_mode |= WNM_BSS_TM_REQ_PREF_CAND_LIST_INCLUDED;
++		if (nei_len == 0) {
++			// Add neigibor report from neighbor report db to nei_rep buffer
++			nei_len = hostapd_neighbor_insert_buffer (hapd, nei_rep, 1000);
++		}
++	}
+ 	if (os_strstr(cmd, " abridged=1"))
+ 		req_mode |= WNM_BSS_TM_REQ_ABRIDGED;
+-	if (os_strstr(cmd, " disassoc_imminent=1"))
++	if (os_strstr(cmd, " disassoc_imminent=1")) {
+ 		req_mode |= WNM_BSS_TM_REQ_DISASSOC_IMMINENT;
++		/* Set own BSS neighbor report preference value as 0 */
++		hostapd_neighbor_set_own_report_pref(hapd, nei_rep, nei_len, 0);
++	}
++
+ 
+ #ifdef CONFIG_MBO
++	hostapd_neighbor_set_pref_by_non_pref_chan(hapd, sta, nei_rep, nei_len);
++
+ 	pos = os_strstr(cmd, "mbo=");
+ 	if (pos) {
+ 		unsigned int mbo_reason, cell_pref, reassoc_delay;
+diff --git a/src/ap/gas_serv.c b/src/ap/gas_serv.c
+index 90f1577..5845ff8 100644
+--- a/src/ap/gas_serv.c
++++ b/src/ap/gas_serv.c
+@@ -19,6 +19,7 @@
+ #include "dpp_hostapd.h"
+ #include "sta_info.h"
+ #include "gas_serv.h"
++#include "neighbor_db.h"
+ 
+ 
+ #ifdef CONFIG_DPP
+@@ -369,6 +370,24 @@ static void anqp_add_network_auth_type(struct hostapd_data *hapd,
+ 	}
+ }
+ 
++static void anqp_add_neighbor_report(struct hostapd_data *hapd,
++				       struct wpabuf *buf)
++{
++	struct hostapd_neighbor_entry *nr;
++	u8 *len_pos = gas_anqp_add_element(buf, ANQP_NEIGHBOR_REPORT);
++	if (dl_list_empty(&hapd->nr_db)) {
++		wpabuf_put_le16(buf, 0);
++	}
++	else {
++		dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry, list ) {
++			wpabuf_put_u8(buf, WLAN_EID_NEIGHBOR_REPORT);
++			wpabuf_put_u8(buf, wpabuf_len(nr->nr));
++			wpabuf_put_buf(buf, nr->nr);
++		}
++	}
++	gas_anqp_set_element_len(buf, len_pos);
++}
++
+ 
+ static void anqp_add_roaming_consortium(struct hostapd_data *hapd,
+ 					struct wpabuf *buf)
+@@ -986,6 +1005,9 @@ gas_serv_build_gas_resp_payload(struct hostapd_data *hapd,
+ 		len += 1000;
+ 	if (request & ANQP_REQ_ICON_REQUEST)
+ 		len += 65536;
++    if (request & ANQP_REQ_NEIGHBOR_REPORT) {
++        len += (40 * hostapd_neighbor_count(hapd));
++    }
+ #ifdef CONFIG_FILS
+ 	if (request & ANQP_FILS_REALM_INFO)
+ 		len += 2 * dl_list_len(&hapd->conf->fils_realms);
+@@ -1028,6 +1050,8 @@ gas_serv_build_gas_resp_payload(struct hostapd_data *hapd,
+ 		anqp_add_elem(hapd, buf, ANQP_TDLS_CAPABILITY);
+ 	if (request & ANQP_REQ_EMERGENCY_NAI)
+ 		anqp_add_elem(hapd, buf, ANQP_EMERGENCY_NAI);
++	if (request & ANQP_REQ_NEIGHBOR_REPORT)
++		anqp_add_neighbor_report(hapd, buf);
+ 
+ 	for (i = 0; i < num_extra_req; i++) {
+ #ifdef CONFIG_FILS
+@@ -1172,6 +1196,11 @@ static void rx_anqp_query_list_id(struct hostapd_data *hapd, u16 info_id,
+ 			     "Emergency NAI",
+ 			     get_anqp_elem(hapd, info_id) != NULL, qi);
+ 		break;
++	case ANQP_NEIGHBOR_REPORT:
++		set_anqp_req(ANQP_REQ_NEIGHBOR_REPORT,
++			     "Neighbor Report",
++			     get_anqp_elem(hapd, info_id) != NULL, qi);
++		break;
+ 	default:
+ #ifdef CONFIG_FILS
+ 		if (info_id == ANQP_FILS_REALM_INFO &&
+diff --git a/src/ap/gas_serv.h b/src/ap/gas_serv.h
+index 1528af4..d0241f2 100644
+--- a/src/ap/gas_serv.h
++++ b/src/ap/gas_serv.h
+@@ -40,6 +40,8 @@
+ 	(1 << (ANQP_TDLS_CAPABILITY - ANQP_QUERY_LIST))
+ #define ANQP_REQ_EMERGENCY_NAI \
+ 	(1 << (ANQP_EMERGENCY_NAI - ANQP_QUERY_LIST))
++#define ANQP_REQ_NEIGHBOR_REPORT \
++	(1 << (ANQP_NEIGHBOR_REPORT - ANQP_QUERY_LIST))
+ /*
+  * First 15 Hotspot 2.0 vendor specific ANQP-elements can be included in the
+  * optimized bitmap.
+diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c
+index 52f25eb..9254d09 100644
+--- a/src/ap/neighbor_db.c
++++ b/src/ap/neighbor_db.c
+@@ -89,6 +89,38 @@ int hostapd_neighbor_show(struct hostapd_data *hapd, char *buf, size_t buflen)
+ }
+ 
+ 
++int hostapd_neighbor_count(struct hostapd_data *hapd)
++{
++	struct hostapd_neighbor_entry *nr;
++	int count = 0;
++
++	dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry,
++			 list) {
++		count++;
++	}
++	return count;
++}
++
++
++int hostapd_neighbor_insert_buffer(struct hostapd_data *hapd, char *buf,
++        size_t buflen)
++{
++	struct hostapd_neighbor_entry *nr;
++	char *pos = buf;
++
++	dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry,
++			 list) {
++		/* For neighbor report IE, we only need bssid and nr*/
++		*pos++ = WLAN_EID_NEIGHBOR_REPORT;
++		*pos++ = wpabuf_len(nr->nr);
++		os_memcpy(pos, wpabuf_head(nr->nr), wpabuf_len(nr->nr));
++		pos += wpabuf_len(nr->nr);
++	}
++
++	return pos - buf;
++}
++
++
+ static void hostapd_neighbor_clear_entry(struct hostapd_neighbor_entry *nr)
+ {
+ 	wpabuf_free(nr->nr);
+@@ -325,3 +357,90 @@ void hostapd_neighbor_set_own_report(struct hostapd_data *hapd)
+ 	wpabuf_free(nr);
+ #endif /* NEED_AP_MLME */
+ }
++
++
++void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_buf,
++			 size_t buflen, const int pref)
++{
++	struct hostapd_neighbor_entry *nr;
++	char *pos, *next_nr;
++
++	pos = nei_buf;
++	next_nr = nei_buf;
++
++	dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry,
++			 list) {
++		pos = next_nr;
++		next_nr = pos + 2 + wpabuf_len(nr->nr);
++		/* Shift 2 bytes for Element ID and Neighbor report length */
++		pos = pos + 2;
++		if(os_memcmp(pos, hapd->own_addr, ETH_ALEN) == 0) {
++			/* Shift for BSSID + BSSID info + Op_class + channel num + PHY type */
++			pos = pos + 6 + 4 + 1 + 1 + 1;
++
++			/* Iterate Subelement */
++			while (next_nr - pos > 0) {
++				if (*pos == 3) {
++					pos = pos + 2;
++					*pos = pref;
++					return;
++				} else {
++					pos++;
++					int shift_len = *pos++;
++					pos = pos + shift_len;
++				}
++			}
++		}
++	}
++}
++
++#ifdef CONFIG_MBO
++void hostapd_neighbor_set_pref_by_non_pref_chan(struct hostapd_data *hapd,
++			 struct sta_info* sta, char *nei_buf, size_t buflen)
++{
++	struct hostapd_neighbor_entry *nr;
++	struct mbo_non_pref_chan_info *info;
++	u8 i;
++
++	for(info = sta->non_pref_chan; info; info = info->next) {
++		/* Check OP_Class and Channel num */
++		for(i = 0; i < info->num_channels; i++) {
++			char *pos, *next_nr;
++
++			pos = nei_buf;
++			next_nr = nei_buf;
++
++			/* Iterate Neighbor report database */
++			dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry,
++					 list) {
++				pos = next_nr;
++				next_nr = pos + 2 + wpabuf_len(nr->nr);
++				/**
++				 * Shift 12 bytes for Element ID, Neighbor report length,
++				 * BSSID and BSSID info.
++				 */
++				pos = pos + 12;
++				int nr_op_class = *pos++;
++				int nr_channel = *pos;
++				if(info->op_class == nr_op_class && info->channels[i] == nr_channel) {
++					/* Shift for Channel Num + PHY type */
++					pos = pos + 1 + 1;
++
++					// Iterate Subelement
++					while(next_nr - pos > 0) {
++						if(*pos == 3) {
++							pos = pos + 2;
++							*pos = info->pref;
++							break;
++						}else {
++							pos++;
++							int shift_len = *pos++;
++							pos = pos + shift_len;
++						}
++					}
++				}
++			}
++		}
++	}
++}
++#endif
+diff --git a/src/ap/neighbor_db.h b/src/ap/neighbor_db.h
+index 992671b..a1ddc07 100644
+--- a/src/ap/neighbor_db.h
++++ b/src/ap/neighbor_db.h
+@@ -24,4 +24,13 @@ int hostapd_neighbor_remove(struct hostapd_data *hapd, const u8 *bssid,
+ 			    const struct wpa_ssid_value *ssid);
+ void hostapd_free_neighbor_db(struct hostapd_data *hapd);
+ 
++int hostapd_neighbor_count(struct hostapd_data *hapd);
++int hostapd_neighbor_insert_buffer(struct hostapd_data *hapd, char *buf,
++        size_t buflen);
++void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_buf,
++			 size_t buflen, const int pref);
++#ifdef CONFIG_MBO
++void hostapd_neighbor_set_pref_by_non_pref_chan(struct hostapd_data *hapd,
++			 struct sta_info* sta, char *nei_buf, size_t buflen);
++#endif
+ #endif /* NEIGHBOR_DB_H */
+diff --git a/src/ap/wnm_ap.c b/src/ap/wnm_ap.c
+index 3ea92af..4349e1d 100644
+--- a/src/ap/wnm_ap.c
++++ b/src/ap/wnm_ap.c
+@@ -20,6 +20,7 @@
+ #include "ap/wpa_auth.h"
+ #include "mbo_ap.h"
+ #include "wnm_ap.h"
++#include "ap/neighbor_db.h"
+ 
+ #define MAX_TFS_IE_LEN  1024
+ 
+@@ -370,9 +371,21 @@ static int ieee802_11_send_bss_trans_mgmt_request(struct hostapd_data *hapd,
+ 	u8 *pos;
+ 	int res;
+ 
+-	mgmt = os_zalloc(sizeof(*mgmt));
+-	if (mgmt == NULL)
++	int nr_num = hostapd_neighbor_count(hapd);
++	int nr_size = ETH_ALEN + 4 + 1 + 1 + 1 + 5;
++	int total_nr_size = nr_num * nr_size;
++	u8 *nr_data = os_malloc(total_nr_size);
++	int nr_data_len = 0;
++	if(nr_data == NULL) {
++		wpa_printf (MSG_ERROR, "Failed to allocate memory");
++	} else {
++	    nr_data_len = hostapd_neighbor_insert_buffer(hapd, nr_data, total_nr_size);
++	}
++	mgmt = os_zalloc(sizeof(*mgmt) + nr_data_len);
++	if (mgmt == NULL) {
++		wpa_printf (MSG_ERROR, "Failed to allocate memory for mgmt frame");
+ 		return -1;
++	}
+ 	os_memcpy(mgmt->da, addr, ETH_ALEN);
+ 	os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
+ 	os_memcpy(mgmt->bssid, hapd->own_addr, ETH_ALEN);
+@@ -382,10 +395,18 @@ static int ieee802_11_send_bss_trans_mgmt_request(struct hostapd_data *hapd,
+ 	mgmt->u.action.u.bss_tm_req.action = WNM_BSS_TRANS_MGMT_REQ;
+ 	mgmt->u.action.u.bss_tm_req.dialog_token = dialog_token;
+ 	mgmt->u.action.u.bss_tm_req.req_mode = 0;
++	if(nr_num) {
++		mgmt->u.action.u.bss_tm_req.req_mode |= WNM_BSS_TM_REQ_PREF_CAND_LIST_INCLUDED;
++	}
+ 	mgmt->u.action.u.bss_tm_req.disassoc_timer = host_to_le16(0);
+ 	mgmt->u.action.u.bss_tm_req.validity_interval = 1;
+ 	pos = mgmt->u.action.u.bss_tm_req.variable;
+ 
++	if(nr_num) {
++		os_memcpy(pos, nr_data, nr_data_len);
++		pos += nr_data_len;
++	}
++
+ 	hapd->openwrt_stats.wnm.bss_transition_request_tx++;
+ 	wpa_printf(MSG_DEBUG, "WNM: Send BSS Transition Management Request to "
+ 		   MACSTR " dialog_token=%u req_mode=0x%x disassoc_timer=%u "
+@@ -759,6 +780,50 @@ static void set_disassoc_timer(struct hostapd_data *hapd, struct sta_info *sta,
+ }
+ 
+ 
++static void set_send_disassoc_frame_timer(struct hostapd_data *hapd, struct sta_info *sta,
++			       int disassoc_timer)
++{
++	int timeout, beacon_int;
++
++	/*
++	 * Prevent STA from reconnecting using cached PMKSA to force
++	 * full authentication with the authentication server (which may
++	 * decide to reject the connection),
++	 */
++	wpa_auth_pmksa_remove(hapd->wpa_auth, sta->addr);
++
++	beacon_int = hapd->iconf->beacon_int;
++	if (beacon_int < 1)
++		beacon_int = 100; /* best guess */
++	/* Calculate timeout in ms based on beacon_int in TU */
++	timeout = disassoc_timer * beacon_int * 128 / 125;
++	wpa_printf(MSG_DEBUG, "Disassociation timer for " MACSTR
++		   " set to %d ms", MAC2STR(sta->addr), timeout);
++
++	u16 reason = WLAN_REASON_PREV_AUTH_NOT_VALID;
++
++	hostapd_drv_sta_disassoc(hapd, sta->addr, reason);
++	if (sta)
++		ap_sta_disassociate(hapd, sta, reason);
++}
++
++
++void bss_termination_disable_iface(void *eloop_ctx, void *timeout_ctx)
++{
++	struct hostapd_data *hapd = eloop_ctx;
++	hostapd_disable_iface(hapd->iface);
++}
++
++
++static void set_disable_iface_timer(struct hostapd_data *hapd, struct sta_info *sta,
++			       int disable_iface_timer)
++{
++	wpa_printf(MSG_DEBUG, "Disable interface timer set to %d secs", disable_iface_timer);
++	eloop_register_timeout(disable_iface_timer, 0,
++			       bss_termination_disable_iface, hapd, NULL);
++}
++
++
+ int wnm_send_ess_disassoc_imminent(struct hostapd_data *hapd,
+ 				   struct sta_info *sta, const char *url,
+ 				   int disassoc_timer)
+@@ -848,6 +913,7 @@ int wnm_send_bss_tm_req(struct hostapd_data *hapd, struct sta_info *sta,
+ 	    bss_term_dur) {
+ 		os_memcpy(pos, bss_term_dur, 12);
+ 		pos += 12;
++		set_disable_iface_timer(hapd, sta, hapd->conf->bss_termination_tsf);
+ 	}
+ 
+ 	if (url) {
+@@ -884,7 +950,7 @@ int wnm_send_bss_tm_req(struct hostapd_data *hapd, struct sta_info *sta,
+ 	hapd->openwrt_stats.wnm.bss_transition_request_tx++;
+ 	if (disassoc_timer) {
+ 		/* send disassociation frame after time-out */
+-		set_disassoc_timer(hapd, sta, disassoc_timer);
++		set_send_disassoc_frame_timer(hapd, sta, disassoc_timer);
+ 	}
+ 
+ 	return 0;
+-- 
+2.36.1
+
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/99901-hostapd-mtk-Support-including-neighbor-report-elements-in-ANQP-.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/99901-hostapd-mtk-Support-including-neighbor-report-elements-in-ANQP-.patch
deleted file mode 100644
index 752584b..0000000
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/99901-hostapd-mtk-Support-including-neighbor-report-elements-in-ANQP-.patch
+++ /dev/null
@@ -1,95 +0,0 @@
-From 0a4f464da1089e59eb5155b5479ceff785697881 Mon Sep 17 00:00:00 2001
-From: "howard.hsu" <howard-yh.hsu@mediatek.com>
-Date: Wed, 19 Jan 2022 19:25:05 +0800
-Subject: [PATCH 99901/99917] Support including neighbor report elements in
- ANQP response
-
----
- src/ap/gas_serv.c | 29 +++++++++++++++++++++++++++++
- src/ap/gas_serv.h |  2 ++
- 2 files changed, 31 insertions(+)
-
-diff --git a/src/ap/gas_serv.c b/src/ap/gas_serv.c
-index 90f1577..5845ff8 100644
---- a/src/ap/gas_serv.c
-+++ b/src/ap/gas_serv.c
-@@ -19,6 +19,7 @@
- #include "dpp_hostapd.h"
- #include "sta_info.h"
- #include "gas_serv.h"
-+#include "neighbor_db.h"
- 
- 
- #ifdef CONFIG_DPP
-@@ -369,6 +370,24 @@ static void anqp_add_network_auth_type(struct hostapd_data *hapd,
- 	}
- }
- 
-+static void anqp_add_neighbor_report(struct hostapd_data *hapd,
-+				       struct wpabuf *buf)
-+{
-+	struct hostapd_neighbor_entry *nr;
-+	u8 *len_pos = gas_anqp_add_element(buf, ANQP_NEIGHBOR_REPORT);
-+	if (dl_list_empty(&hapd->nr_db)) {
-+		wpabuf_put_le16(buf, 0);
-+	}
-+	else {
-+		dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry, list ) {
-+			wpabuf_put_u8(buf, WLAN_EID_NEIGHBOR_REPORT);
-+			wpabuf_put_u8(buf, wpabuf_len(nr->nr));
-+			wpabuf_put_buf(buf, nr->nr);
-+		}
-+	}
-+	gas_anqp_set_element_len(buf, len_pos);
-+}
-+
- 
- static void anqp_add_roaming_consortium(struct hostapd_data *hapd,
- 					struct wpabuf *buf)
-@@ -986,6 +1005,9 @@ gas_serv_build_gas_resp_payload(struct hostapd_data *hapd,
- 		len += 1000;
- 	if (request & ANQP_REQ_ICON_REQUEST)
- 		len += 65536;
-+    if (request & ANQP_REQ_NEIGHBOR_REPORT) {
-+        len += (40 * hostapd_neighbor_count(hapd));
-+    }
- #ifdef CONFIG_FILS
- 	if (request & ANQP_FILS_REALM_INFO)
- 		len += 2 * dl_list_len(&hapd->conf->fils_realms);
-@@ -1028,6 +1050,8 @@ gas_serv_build_gas_resp_payload(struct hostapd_data *hapd,
- 		anqp_add_elem(hapd, buf, ANQP_TDLS_CAPABILITY);
- 	if (request & ANQP_REQ_EMERGENCY_NAI)
- 		anqp_add_elem(hapd, buf, ANQP_EMERGENCY_NAI);
-+	if (request & ANQP_REQ_NEIGHBOR_REPORT)
-+		anqp_add_neighbor_report(hapd, buf);
- 
- 	for (i = 0; i < num_extra_req; i++) {
- #ifdef CONFIG_FILS
-@@ -1172,6 +1196,11 @@ static void rx_anqp_query_list_id(struct hostapd_data *hapd, u16 info_id,
- 			     "Emergency NAI",
- 			     get_anqp_elem(hapd, info_id) != NULL, qi);
- 		break;
-+	case ANQP_NEIGHBOR_REPORT:
-+		set_anqp_req(ANQP_REQ_NEIGHBOR_REPORT,
-+			     "Neighbor Report",
-+			     get_anqp_elem(hapd, info_id) != NULL, qi);
-+		break;
- 	default:
- #ifdef CONFIG_FILS
- 		if (info_id == ANQP_FILS_REALM_INFO &&
-diff --git a/src/ap/gas_serv.h b/src/ap/gas_serv.h
-index 1528af4..d0241f2 100644
---- a/src/ap/gas_serv.h
-+++ b/src/ap/gas_serv.h
-@@ -40,6 +40,8 @@
- 	(1 << (ANQP_TDLS_CAPABILITY - ANQP_QUERY_LIST))
- #define ANQP_REQ_EMERGENCY_NAI \
- 	(1 << (ANQP_EMERGENCY_NAI - ANQP_QUERY_LIST))
-+#define ANQP_REQ_NEIGHBOR_REPORT \
-+	(1 << (ANQP_NEIGHBOR_REPORT - ANQP_QUERY_LIST))
- /*
-  * First 15 Hotspot 2.0 vendor specific ANQP-elements can be included in the
-  * optimized bitmap.
--- 
-2.36.1
-
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/99909-hostapd-mtk-print-sae-groups-by-hostapd-ctrl.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/99901-hostapd-mtk-print-sae-groups-by-hostapd-ctrl.patch
similarity index 86%
rename from autobuild_mac80211_release/package/network/services/hostapd/patches/99909-hostapd-mtk-print-sae-groups-by-hostapd-ctrl.patch
rename to autobuild_mac80211_release/package/network/services/hostapd/patches/99901-hostapd-mtk-print-sae-groups-by-hostapd-ctrl.patch
index 12e0e36..054dfb0 100644
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/99909-hostapd-mtk-print-sae-groups-by-hostapd-ctrl.patch
+++ b/autobuild_mac80211_release/package/network/services/hostapd/patches/99901-hostapd-mtk-print-sae-groups-by-hostapd-ctrl.patch
@@ -1,7 +1,7 @@
-From b7a74dbae4ff2bdbc5c84d0299bc18020fe86d13 Mon Sep 17 00:00:00 2001
+From f5c37c459c33bb8e228a88ba8efdea68bb75abd3 Mon Sep 17 00:00:00 2001
 From: Shayne Chen <shayne.chen@mediatek.com>
 Date: Tue, 20 Sep 2022 19:33:45 +0800
-Subject: [PATCH 99909/99917] print sae groups by hostapd ctrl
+Subject: [PATCH 99901/99909] hostapd: mtk: print sae groups by hostapd ctrl
 
 ---
  hostapd/ctrl_iface.c | 13 +++++++++++++
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/99902-hostapd-mtk-Support-including-neignbor-report-elements-in-BTM-r.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/99902-hostapd-mtk-Support-including-neignbor-report-elements-in-BTM-r.patch
deleted file mode 100644
index 99bea80..0000000
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/99902-hostapd-mtk-Support-including-neignbor-report-elements-in-BTM-r.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-From d283e4c84ece2f6b6dc21889b6b326ea3de11545 Mon Sep 17 00:00:00 2001
-From: "howard.hsu" <howard-yh.hsu@mediatek.com>
-Date: Wed, 19 Jan 2022 19:49:09 +0800
-Subject: [PATCH 99902/99917] Support including neignbor report elements in BTM
- response
-
----
- src/ap/wnm_ap.c | 25 +++++++++++++++++++++++--
- 1 file changed, 23 insertions(+), 2 deletions(-)
-
-diff --git a/src/ap/wnm_ap.c b/src/ap/wnm_ap.c
-index 3ea92af..532d9db 100644
---- a/src/ap/wnm_ap.c
-+++ b/src/ap/wnm_ap.c
-@@ -20,6 +20,7 @@
- #include "ap/wpa_auth.h"
- #include "mbo_ap.h"
- #include "wnm_ap.h"
-+#include "ap/neighbor_db.h"
- 
- #define MAX_TFS_IE_LEN  1024
- 
-@@ -370,9 +371,21 @@ static int ieee802_11_send_bss_trans_mgmt_request(struct hostapd_data *hapd,
- 	u8 *pos;
- 	int res;
- 
--	mgmt = os_zalloc(sizeof(*mgmt));
--	if (mgmt == NULL)
-+	int nr_num = hostapd_neighbor_count(hapd);
-+	int nr_size = ETH_ALEN + 4 + 1 + 1 + 1 + 5;
-+	int total_nr_size = nr_num * nr_size;
-+	u8 *nr_data = os_malloc(total_nr_size);
-+	int nr_data_len = 0;
-+	if(nr_data == NULL) {
-+		wpa_printf (MSG_ERROR, "Failed to allocate memory");
-+	} else {
-+	    nr_data_len = hostapd_neighbor_insert_buffer(hapd, nr_data, total_nr_size);
-+	}
-+	mgmt = os_zalloc(sizeof(*mgmt) + nr_data_len);
-+	if (mgmt == NULL) {
-+		wpa_printf (MSG_ERROR, "Failed to allocate memory for mgmt frame");
- 		return -1;
-+	}
- 	os_memcpy(mgmt->da, addr, ETH_ALEN);
- 	os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
- 	os_memcpy(mgmt->bssid, hapd->own_addr, ETH_ALEN);
-@@ -382,10 +395,18 @@ static int ieee802_11_send_bss_trans_mgmt_request(struct hostapd_data *hapd,
- 	mgmt->u.action.u.bss_tm_req.action = WNM_BSS_TRANS_MGMT_REQ;
- 	mgmt->u.action.u.bss_tm_req.dialog_token = dialog_token;
- 	mgmt->u.action.u.bss_tm_req.req_mode = 0;
-+	if(nr_num) {
-+		mgmt->u.action.u.bss_tm_req.req_mode |= WNM_BSS_TM_REQ_PREF_CAND_LIST_INCLUDED;
-+	}
- 	mgmt->u.action.u.bss_tm_req.disassoc_timer = host_to_le16(0);
- 	mgmt->u.action.u.bss_tm_req.validity_interval = 1;
- 	pos = mgmt->u.action.u.bss_tm_req.variable;
- 
-+	if(nr_num) {
-+		os_memcpy(pos, nr_data, nr_data_len);
-+		pos += nr_data_len;
-+	}
-+
- 	hapd->openwrt_stats.wnm.bss_transition_request_tx++;
- 	wpa_printf(MSG_DEBUG, "WNM: Send BSS Transition Management Request to "
- 		   MACSTR " dialog_token=%u req_mode=0x%x disassoc_timer=%u "
--- 
-2.36.1
-
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/99910-hostapd-mtk-hostapd-add-support-for-runtime-set-in-band-discove.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/99902-hostapd-mtk-add-support-for-runtime-set-in-band-dis.patch
similarity index 97%
rename from autobuild_mac80211_release/package/network/services/hostapd/patches/99910-hostapd-mtk-hostapd-add-support-for-runtime-set-in-band-discove.patch
rename to autobuild_mac80211_release/package/network/services/hostapd/patches/99902-hostapd-mtk-add-support-for-runtime-set-in-band-dis.patch
index 2af1d8e..6fa23c0 100644
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/99910-hostapd-mtk-hostapd-add-support-for-runtime-set-in-band-discove.patch
+++ b/autobuild_mac80211_release/package/network/services/hostapd/patches/99902-hostapd-mtk-add-support-for-runtime-set-in-band-dis.patch
@@ -1,7 +1,7 @@
-From 7a7b2284ad75cd20c788dad6e253bc2940203ff9 Mon Sep 17 00:00:00 2001
+From ce684a1adac0b5b699482924eb86f8f1b8205e57 Mon Sep 17 00:00:00 2001
 From: MeiChia Chiu <meichia.chiu@mediatek.com>
 Date: Tue, 31 May 2022 21:15:54 +0800
-Subject: [PATCH 99910/99917] hostapd: add support for runtime set in-band
+Subject: [PATCH 99902/99909] hostapd: mtk: add support for runtime set in-band
  discovery
 
 Usage:
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/99911-hostapd-mtk-Add-mtk_vendor.h.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/99903-hostapd-mtk-Add-mtk_vendor.h.patch
similarity index 97%
rename from autobuild_mac80211_release/package/network/services/hostapd/patches/99911-hostapd-mtk-Add-mtk_vendor.h.patch
rename to autobuild_mac80211_release/package/network/services/hostapd/patches/99903-hostapd-mtk-Add-mtk_vendor.h.patch
index ff4d232..a15287e 100644
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/99911-hostapd-mtk-Add-mtk_vendor.h.patch
+++ b/autobuild_mac80211_release/package/network/services/hostapd/patches/99903-hostapd-mtk-Add-mtk_vendor.h.patch
@@ -1,7 +1,7 @@
-From f5ba1e7e33d0736602957f8131540202cec1c7ad Mon Sep 17 00:00:00 2001
+From e4b9b5847090d25009a4cf104052ba0490e95ffe Mon Sep 17 00:00:00 2001
 From: Howard Hsu <howard-yh.hsu@mediatek.com>
 Date: Mon, 30 May 2022 15:04:57 +0800
-Subject: [PATCH 99911/99917] Add mtk_vendor.h
+Subject: [PATCH 99903/99909] hostapd: mtk: Add mtk_vendor.h
 
 ---
  src/common/mtk_vendor.h | 195 ++++++++++++++++++++++++++++++++++++++++
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/99903-hostapd-mtk-Support-configuring-BSS-Termination-TSF-by-using-ho.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/99903-hostapd-mtk-Support-configuring-BSS-Termination-TSF-by-using-ho.patch
deleted file mode 100644
index cac4092..0000000
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/99903-hostapd-mtk-Support-configuring-BSS-Termination-TSF-by-using-ho.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-From de13e08cb3e1210bfed2de824c6a19e8dbed057e Mon Sep 17 00:00:00 2001
-From: Howard Hsu <howard-yh.hsu@mediatek.com>
-Date: Thu, 9 Jun 2022 19:56:18 +0800
-Subject: [PATCH 99903/99917] Support configuring BSS Termination TSF by using
- hostapd_cli command
-
----
- hostapd/ctrl_iface.c   | 5 +++++
- src/ap/ap_config.c     | 1 +
- src/ap/ap_config.h     | 1 +
- src/ap/ctrl_iface_ap.c | 4 ++++
- 4 files changed, 11 insertions(+)
-
-diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
-index a258492..c2a2822 100644
---- a/hostapd/ctrl_iface.c
-+++ b/hostapd/ctrl_iface.c
-@@ -1338,6 +1338,11 @@ static int hostapd_ctrl_iface_set(struct hostapd_data *hapd, char *cmd)
- #endif /* CONFIG_DPP */
- 	} else if (os_strcasecmp(cmd, "setband") == 0) {
- 		ret = hostapd_ctrl_iface_set_band(hapd, value);
-+	} else if (os_strcasecmp(cmd, "bss_termination_tsf") == 0) {
-+		int termination_sec = atoi(value);
-+		hapd->conf->bss_termination_tsf = termination_sec;
-+		wpa_printf(MSG_DEBUG, "BSS Termination TSF: value = %d",
-+                termination_sec);
- 	} else {
- 		ret = hostapd_set_iface(hapd->iconf, hapd->conf, cmd, value);
- 		if (ret)
-diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c
-index d7a0c7c..4a20eb4 100644
---- a/src/ap/ap_config.c
-+++ b/src/ap/ap_config.c
-@@ -170,6 +170,7 @@ void hostapd_config_defaults_bss(struct hostapd_bss_config *bss)
- 	/* comeback after 10 TUs */
- 	bss->pasn_comeback_after = 10;
- #endif /* CONFIG_PASN */
-+	bss->bss_termination_tsf = 0;
- }
- 
- 
-diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
-index ed3bec7..3f68e76 100644
---- a/src/ap/ap_config.h
-+++ b/src/ap/ap_config.h
-@@ -557,6 +557,7 @@ struct hostapd_bss_config {
- 	int wnm_sleep_mode;
- 	int wnm_sleep_mode_no_keys;
- 	int bss_transition;
-+	unsigned int bss_termination_tsf;
- 
- 	/* IEEE 802.11u - Interworking */
- 	int interworking;
-diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c
-index 96209ce..46a8609 100644
---- a/src/ap/ctrl_iface_ap.c
-+++ b/src/ap/ctrl_iface_ap.c
-@@ -1203,6 +1203,10 @@ int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd,
- 			wpa_printf(MSG_DEBUG, "Invalid bss_term data");
- 			return -1;
- 		}
-+		if (hapd->conf->bss_termination_tsf) {
-+			WPA_PUT_LE64(&bss_term_dur[2], hapd->conf->bss_termination_tsf);
-+		}
-+
- 		end++;
- 		WPA_PUT_LE16(&bss_term_dur[10], atoi(end));
- 	}
--- 
-2.36.1
-
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/99904-hostapd-mtk-Disable-interface-if-BSS-Termination-TSF-is-set.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/99904-hostapd-mtk-Disable-interface-if-BSS-Termination-TSF-is-set.patch
deleted file mode 100644
index 7334217..0000000
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/99904-hostapd-mtk-Disable-interface-if-BSS-Termination-TSF-is-set.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From cdd0a088a13000d67a5bd821a609546f8b79c7e0 Mon Sep 17 00:00:00 2001
-From: "howard.hsu" <howard-yh.hsu@mediatek.com>
-Date: Wed, 19 Jan 2022 21:03:38 +0800
-Subject: [PATCH 99904/99917] Disable interface if BSS Termination TSF is set
-
----
- src/ap/wnm_ap.c | 17 +++++++++++++++++
- 1 file changed, 17 insertions(+)
-
-diff --git a/src/ap/wnm_ap.c b/src/ap/wnm_ap.c
-index 532d9db..f6761ab 100644
---- a/src/ap/wnm_ap.c
-+++ b/src/ap/wnm_ap.c
-@@ -780,6 +780,22 @@ static void set_disassoc_timer(struct hostapd_data *hapd, struct sta_info *sta,
- }
- 
- 
-+void bss_termination_disable_iface(void *eloop_ctx, void *timeout_ctx)
-+{
-+	struct hostapd_data *hapd = eloop_ctx;
-+	hostapd_disable_iface(hapd->iface);
-+}
-+
-+
-+static void set_disable_iface_timer(struct hostapd_data *hapd, struct sta_info *sta,
-+			       int disable_iface_timer)
-+{
-+	wpa_printf(MSG_DEBUG, "Disable interface timer set to %d secs", disable_iface_timer);
-+	eloop_register_timeout(disable_iface_timer, 0,
-+			       bss_termination_disable_iface, hapd, NULL);
-+}
-+
-+
- int wnm_send_ess_disassoc_imminent(struct hostapd_data *hapd,
- 				   struct sta_info *sta, const char *url,
- 				   int disassoc_timer)
-@@ -869,6 +885,7 @@ int wnm_send_bss_tm_req(struct hostapd_data *hapd, struct sta_info *sta,
- 	    bss_term_dur) {
- 		os_memcpy(pos, bss_term_dur, 12);
- 		pos += 12;
-+		set_disable_iface_timer(hapd, sta, hapd->conf->bss_termination_tsf);
- 	}
- 
- 	if (url) {
--- 
-2.36.1
-
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/99912-hostapd-mtk-Support-new-hostapd-configuration-edcca_enable-and-.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/99904-hostapd-mtk-Support-EDCCA-hostapd-configuration.patch
similarity index 98%
rename from autobuild_mac80211_release/package/network/services/hostapd/patches/99912-hostapd-mtk-Support-new-hostapd-configuration-edcca_enable-and-.patch
rename to autobuild_mac80211_release/package/network/services/hostapd/patches/99904-hostapd-mtk-Support-EDCCA-hostapd-configuration.patch
index e1161f8..40dded6 100644
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/99912-hostapd-mtk-Support-new-hostapd-configuration-edcca_enable-and-.patch
+++ b/autobuild_mac80211_release/package/network/services/hostapd/patches/99904-hostapd-mtk-Support-EDCCA-hostapd-configuration.patch
@@ -1,9 +1,9 @@
-From 27645d8206ad1a0276f05faa175f2ed4ffb8202e Mon Sep 17 00:00:00 2001
+From cef7f515eafeeaa99933cc9e66c79b705e3ab065 Mon Sep 17 00:00:00 2001
 From: Howard Hsu <howard-yh.hsu@mediatek.com>
 Date: Mon, 30 May 2022 16:31:34 +0800
-Subject: [PATCH 99912/99917] Support new hostapd configuration, edcca_enable
- and edcca_compensation and implement edcca related handlers.
+Subject: [PATCH 99904/99909] hostapd: mtk: Support EDCCA hostapd configuration
 
+edcca_enable and edcca_compensation and implement edcca related handlers.
 ---
  hostapd/config_file.c             |  32 ++++++
  hostapd/ctrl_iface.c              | 125 ++++++++++++++++++++++
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/99913-hostapd-mtk-Add-hostapd-HEMU-SET-GET-control.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/99905-hostapd-mtk-Add-hostapd-HEMU-SET-GET-control.patch
similarity index 98%
rename from autobuild_mac80211_release/package/network/services/hostapd/patches/99913-hostapd-mtk-Add-hostapd-HEMU-SET-GET-control.patch
rename to autobuild_mac80211_release/package/network/services/hostapd/patches/99905-hostapd-mtk-Add-hostapd-HEMU-SET-GET-control.patch
index 572cdd1..18617be 100644
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/99913-hostapd-mtk-Add-hostapd-HEMU-SET-GET-control.patch
+++ b/autobuild_mac80211_release/package/network/services/hostapd/patches/99905-hostapd-mtk-Add-hostapd-HEMU-SET-GET-control.patch
@@ -1,7 +1,7 @@
-From fe664c759cb79e130d35f6dd0236e9cb33320f70 Mon Sep 17 00:00:00 2001
+From a288f97e708bc579e285b509f7c0655c2f27a76c Mon Sep 17 00:00:00 2001
 From: TomLiu <tomml.liu@mediatek.com>
 Date: Tue, 9 Aug 2022 10:23:44 -0700
-Subject: [PATCH 99913/99917] Add hostapd HEMU SET/GET control
+Subject: [PATCH 99905/99909] hostapd: mtk: Add hostapd HEMU SET/GET control
 
 ---
  hostapd/config_file.c             |   9 +++
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/99905-hostapd-mtk-Add-set_send_disassoc_frame_timer-to-send-disassoci.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/99905-hostapd-mtk-Add-set_send_disassoc_frame_timer-to-send-disassoci.patch
deleted file mode 100644
index 83d9814..0000000
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/99905-hostapd-mtk-Add-set_send_disassoc_frame_timer-to-send-disassoci.patch
+++ /dev/null
@@ -1,63 +0,0 @@
-From bd1816cb396a071cc5ae2fe13992362fcbf45fe9 Mon Sep 17 00:00:00 2001
-From: "howard.hsu" <howard-yh.hsu@mediatek.com>
-Date: Wed, 19 Jan 2022 21:15:07 +0800
-Subject: [PATCH 99905/99917] Add set_send_disassoc_frame_timer() to send
- disassociate frame
-
-Function set_disassoc_timer() may fail if key was deleted first. This new
-function will not ask to delete key as set_disassoc_timer() did.
----
- src/ap/wnm_ap.c | 30 +++++++++++++++++++++++++++++-
- 1 file changed, 29 insertions(+), 1 deletion(-)
-
-diff --git a/src/ap/wnm_ap.c b/src/ap/wnm_ap.c
-index f6761ab..4349e1d 100644
---- a/src/ap/wnm_ap.c
-+++ b/src/ap/wnm_ap.c
-@@ -780,6 +780,34 @@ static void set_disassoc_timer(struct hostapd_data *hapd, struct sta_info *sta,
- }
- 
- 
-+static void set_send_disassoc_frame_timer(struct hostapd_data *hapd, struct sta_info *sta,
-+			       int disassoc_timer)
-+{
-+	int timeout, beacon_int;
-+
-+	/*
-+	 * Prevent STA from reconnecting using cached PMKSA to force
-+	 * full authentication with the authentication server (which may
-+	 * decide to reject the connection),
-+	 */
-+	wpa_auth_pmksa_remove(hapd->wpa_auth, sta->addr);
-+
-+	beacon_int = hapd->iconf->beacon_int;
-+	if (beacon_int < 1)
-+		beacon_int = 100; /* best guess */
-+	/* Calculate timeout in ms based on beacon_int in TU */
-+	timeout = disassoc_timer * beacon_int * 128 / 125;
-+	wpa_printf(MSG_DEBUG, "Disassociation timer for " MACSTR
-+		   " set to %d ms", MAC2STR(sta->addr), timeout);
-+
-+	u16 reason = WLAN_REASON_PREV_AUTH_NOT_VALID;
-+
-+	hostapd_drv_sta_disassoc(hapd, sta->addr, reason);
-+	if (sta)
-+		ap_sta_disassociate(hapd, sta, reason);
-+}
-+
-+
- void bss_termination_disable_iface(void *eloop_ctx, void *timeout_ctx)
- {
- 	struct hostapd_data *hapd = eloop_ctx;
-@@ -922,7 +950,7 @@ int wnm_send_bss_tm_req(struct hostapd_data *hapd, struct sta_info *sta,
- 	hapd->openwrt_stats.wnm.bss_transition_request_tx++;
- 	if (disassoc_timer) {
- 		/* send disassociation frame after time-out */
--		set_disassoc_timer(hapd, sta, disassoc_timer);
-+		set_send_disassoc_frame_timer(hapd, sta, disassoc_timer);
- 	}
- 
- 	return 0;
--- 
-2.36.1
-
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/99914-hostapd-mtk-Add-three-wire-PTA-ctrl-hostapd-vendor-command.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/99906-hostapd-mtk-Add-three-wire-PTA-ctrl-hostapd-vendor-.patch
similarity index 97%
rename from autobuild_mac80211_release/package/network/services/hostapd/patches/99914-hostapd-mtk-Add-three-wire-PTA-ctrl-hostapd-vendor-command.patch
rename to autobuild_mac80211_release/package/network/services/hostapd/patches/99906-hostapd-mtk-Add-three-wire-PTA-ctrl-hostapd-vendor-.patch
index ca64eb8..fc81ed1 100644
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/99914-hostapd-mtk-Add-three-wire-PTA-ctrl-hostapd-vendor-command.patch
+++ b/autobuild_mac80211_release/package/network/services/hostapd/patches/99906-hostapd-mtk-Add-three-wire-PTA-ctrl-hostapd-vendor-.patch
@@ -1,7 +1,8 @@
-From 4707ed85884be2ffe7860e28de80df5a6e479824 Mon Sep 17 00:00:00 2001
+From 26c6be11e7597490ccc4d7704542c78dec6c4cd1 Mon Sep 17 00:00:00 2001
 From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
 Date: Fri, 2 Sep 2022 01:03:23 +0800
-Subject: [PATCH 99914/99917] Add three wire PTA ctrl hostapd vendor command
+Subject: [PATCH 99906/99909] hostapd: mtk: Add three wire PTA ctrl hostapd
+ vendor command
 
 Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
 ---
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/99906-hostapd-mtk-Support-including-neighbor-report-elements-in-BTM-r.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/99906-hostapd-mtk-Support-including-neighbor-report-elements-in-BTM-r.patch
deleted file mode 100644
index 174d8a9..0000000
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/99906-hostapd-mtk-Support-including-neighbor-report-elements-in-BTM-r.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From 99665874b76ccacd85e56ea8767ebb0b8d4b3b1e Mon Sep 17 00:00:00 2001
-From: Howard Hsu <howard-yh.hsu@mediatek.com>
-Date: Thu, 9 Jun 2022 19:58:57 +0800
-Subject: [PATCH 99906/99917] Support including neighbor report elements in BTM
- request
-
----
- src/ap/ctrl_iface_ap.c | 7 ++++++-
- 1 file changed, 6 insertions(+), 1 deletion(-)
-
-diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c
-index 46a8609..1cbec53 100644
---- a/src/ap/ctrl_iface_ap.c
-+++ b/src/ap/ctrl_iface_ap.c
-@@ -1233,8 +1233,13 @@ int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd,
- 		req_mode |= WNM_BSS_TM_REQ_ESS_DISASSOC_IMMINENT;
- 	}
- 
--	if (os_strstr(cmd, " pref=1"))
-+	if (os_strstr(cmd, " pref=1")) {
- 		req_mode |= WNM_BSS_TM_REQ_PREF_CAND_LIST_INCLUDED;
-+		if (nei_len == 0) {
-+			// Add neigibor report from neighbor report db to nei_rep buffer
-+			nei_len = hostapd_neighbor_insert_buffer (hapd, nei_rep, 1000);
-+		}
-+	}
- 	if (os_strstr(cmd, " abridged=1"))
- 		req_mode |= WNM_BSS_TM_REQ_ABRIDGED;
- 	if (os_strstr(cmd, " disassoc_imminent=1"))
--- 
-2.36.1
-
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/99915-hostapd-mtk-Add-hostapd-iBF-control.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/99907-hostapd-mtk-Add-hostapd-iBF-control.patch
similarity index 98%
rename from autobuild_mac80211_release/package/network/services/hostapd/patches/99915-hostapd-mtk-Add-hostapd-iBF-control.patch
rename to autobuild_mac80211_release/package/network/services/hostapd/patches/99907-hostapd-mtk-Add-hostapd-iBF-control.patch
index a50cb9e..50a08ba 100644
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/99915-hostapd-mtk-Add-hostapd-iBF-control.patch
+++ b/autobuild_mac80211_release/package/network/services/hostapd/patches/99907-hostapd-mtk-Add-hostapd-iBF-control.patch
@@ -1,7 +1,7 @@
-From e177f5069ff7e8f024676cf9d0e4af135cfea95b Mon Sep 17 00:00:00 2001
+From 1f60afd21c6dd7dfe3d504dee7507654a981033b Mon Sep 17 00:00:00 2001
 From: mtk27835 <shurong.wen@mediatek.com>
 Date: Wed, 7 Sep 2022 14:41:51 -0700
-Subject: [PATCH 99915/99917] Add hostapd iBF control
+Subject: [PATCH 99907/99909] hostapd: mtk: Add hostapd iBF control
 
 Signed-off-by: mtk27835 <shurong.wen@mediatek.com>
 ---
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/99907-hostapd-mtk-Add-hostapd_neighbor_set_own_report_pref.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/99907-hostapd-mtk-Add-hostapd_neighbor_set_own_report_pref.patch
deleted file mode 100644
index 63658c9..0000000
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/99907-hostapd-mtk-Add-hostapd_neighbor_set_own_report_pref.patch
+++ /dev/null
@@ -1,87 +0,0 @@
-From bc2244e766d863c35369cc1641b058d062681abe Mon Sep 17 00:00:00 2001
-From: Howard Hsu <howard-yh.hsu@mediatek.com>
-Date: Thu, 9 Jun 2022 20:00:49 +0800
-Subject: [PATCH 99907/99917] Add hostapd_neighbor_set_own_report_pref()
-
----
- src/ap/ctrl_iface_ap.c |  6 +++++-
- src/ap/neighbor_db.c   | 36 ++++++++++++++++++++++++++++++++++++
- src/ap/neighbor_db.h   |  2 ++
- 3 files changed, 43 insertions(+), 1 deletion(-)
-
-diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c
-index 1cbec53..274b435 100644
---- a/src/ap/ctrl_iface_ap.c
-+++ b/src/ap/ctrl_iface_ap.c
-@@ -1242,8 +1242,12 @@ int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd,
- 	}
- 	if (os_strstr(cmd, " abridged=1"))
- 		req_mode |= WNM_BSS_TM_REQ_ABRIDGED;
--	if (os_strstr(cmd, " disassoc_imminent=1"))
-+	if (os_strstr(cmd, " disassoc_imminent=1")) {
- 		req_mode |= WNM_BSS_TM_REQ_DISASSOC_IMMINENT;
-+		/* Set own BSS neighbor report preference value as 0 */
-+		hostapd_neighbor_set_own_report_pref(hapd, nei_rep, nei_len, 0);
-+	}
-+
- 
- #ifdef CONFIG_MBO
- 	pos = os_strstr(cmd, "mbo=");
-diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c
-index c121390..134ed4a 100644
---- a/src/ap/neighbor_db.c
-+++ b/src/ap/neighbor_db.c
-@@ -357,3 +357,39 @@ void hostapd_neighbor_set_own_report(struct hostapd_data *hapd)
- 	wpabuf_free(nr);
- #endif /* NEED_AP_MLME */
- }
-+
-+
-+void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_buf,
-+			 size_t buflen, const int pref)
-+{
-+	struct hostapd_neighbor_entry *nr;
-+	char *pos, *next_nr;
-+
-+	pos = nei_buf;
-+	next_nr = nei_buf;
-+
-+	dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry,
-+			 list) {
-+		pos = next_nr;
-+		next_nr = pos + 2 + wpabuf_len(nr->nr);
-+		/* Shift 2 bytes for Element ID and Neighbor report length */
-+		pos = pos + 2;
-+		if(os_memcmp(pos, hapd->own_addr, ETH_ALEN) == 0) {
-+			/* Shift for BSSID + BSSID info + Op_class + channel num + PHY type */
-+			pos = pos + 6 + 4 + 1 + 1 + 1;
-+
-+			/* Iterate Subelement */
-+			while (next_nr - pos > 0) {
-+				if (*pos == 3) {
-+					pos = pos + 2;
-+					*pos = pref;
-+					return;
-+				} else {
-+					pos++;
-+					int shift_len = *pos++;
-+					pos = pos + shift_len;
-+				}
-+			}
-+		}
-+	}
-+}
-diff --git a/src/ap/neighbor_db.h b/src/ap/neighbor_db.h
-index 1ae194d..2e16f72 100644
---- a/src/ap/neighbor_db.h
-+++ b/src/ap/neighbor_db.h
-@@ -27,4 +27,6 @@ void hostapd_free_neighbor_db(struct hostapd_data *hapd);
- int hostapd_neighbor_count(struct hostapd_data *hapd);
- int hostapd_neighbor_insert_buffer(struct hostapd_data *hapd, char *buf,
-         size_t buflen);
-+void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_buf,
-+			 size_t buflen, const int pref);
- #endif /* NEIGHBOR_DB_H */
--- 
-2.36.1
-
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/99908-hostapd-mtk-Add-hostapd_neighbor_set_pref_by_non_pref_chan.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/99908-hostapd-mtk-Add-hostapd_neighbor_set_pref_by_non_pref_chan.patch
deleted file mode 100644
index 8d23b84..0000000
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/99908-hostapd-mtk-Add-hostapd_neighbor_set_pref_by_non_pref_chan.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-From 952404e8327c98817a2d975b5595ca5d9a15e739 Mon Sep 17 00:00:00 2001
-From: Howard Hsu <howard-yh.hsu@mediatek.com>
-Date: Thu, 9 Jun 2022 20:02:06 +0800
-Subject: [PATCH 99908/99917] Add hostapd_neighbor_set_pref_by_non_pref_chan()
-
----
- src/ap/ctrl_iface_ap.c |  2 ++
- src/ap/neighbor_db.c   | 51 ++++++++++++++++++++++++++++++++++++++++++
- src/ap/neighbor_db.h   |  4 ++++
- 3 files changed, 57 insertions(+)
-
-diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c
-index 274b435..18bae5c 100644
---- a/src/ap/ctrl_iface_ap.c
-+++ b/src/ap/ctrl_iface_ap.c
-@@ -1250,6 +1250,8 @@ int hostapd_ctrl_iface_bss_tm_req(struct hostapd_data *hapd,
- 
- 
- #ifdef CONFIG_MBO
-+	hostapd_neighbor_set_pref_by_non_pref_chan(hapd, sta, nei_rep, nei_len);
-+
- 	pos = os_strstr(cmd, "mbo=");
- 	if (pos) {
- 		unsigned int mbo_reason, cell_pref, reassoc_delay;
-diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c
-index 134ed4a..9254d09 100644
---- a/src/ap/neighbor_db.c
-+++ b/src/ap/neighbor_db.c
-@@ -393,3 +393,54 @@ void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_b
- 		}
- 	}
- }
-+
-+#ifdef CONFIG_MBO
-+void hostapd_neighbor_set_pref_by_non_pref_chan(struct hostapd_data *hapd,
-+			 struct sta_info* sta, char *nei_buf, size_t buflen)
-+{
-+	struct hostapd_neighbor_entry *nr;
-+	struct mbo_non_pref_chan_info *info;
-+	u8 i;
-+
-+	for(info = sta->non_pref_chan; info; info = info->next) {
-+		/* Check OP_Class and Channel num */
-+		for(i = 0; i < info->num_channels; i++) {
-+			char *pos, *next_nr;
-+
-+			pos = nei_buf;
-+			next_nr = nei_buf;
-+
-+			/* Iterate Neighbor report database */
-+			dl_list_for_each(nr, &hapd->nr_db, struct hostapd_neighbor_entry,
-+					 list) {
-+				pos = next_nr;
-+				next_nr = pos + 2 + wpabuf_len(nr->nr);
-+				/**
-+				 * Shift 12 bytes for Element ID, Neighbor report length,
-+				 * BSSID and BSSID info.
-+				 */
-+				pos = pos + 12;
-+				int nr_op_class = *pos++;
-+				int nr_channel = *pos;
-+				if(info->op_class == nr_op_class && info->channels[i] == nr_channel) {
-+					/* Shift for Channel Num + PHY type */
-+					pos = pos + 1 + 1;
-+
-+					// Iterate Subelement
-+					while(next_nr - pos > 0) {
-+						if(*pos == 3) {
-+							pos = pos + 2;
-+							*pos = info->pref;
-+							break;
-+						}else {
-+							pos++;
-+							int shift_len = *pos++;
-+							pos = pos + shift_len;
-+						}
-+					}
-+				}
-+			}
-+		}
-+	}
-+}
-+#endif
-diff --git a/src/ap/neighbor_db.h b/src/ap/neighbor_db.h
-index 2e16f72..a1ddc07 100644
---- a/src/ap/neighbor_db.h
-+++ b/src/ap/neighbor_db.h
-@@ -29,4 +29,8 @@ int hostapd_neighbor_insert_buffer(struct hostapd_data *hapd, char *buf,
-         size_t buflen);
- void hostapd_neighbor_set_own_report_pref(struct hostapd_data *hapd, char *nei_buf,
- 			 size_t buflen, const int pref);
-+#ifdef CONFIG_MBO
-+void hostapd_neighbor_set_pref_by_non_pref_chan(struct hostapd_data *hapd,
-+			 struct sta_info* sta, char *nei_buf, size_t buflen);
-+#endif
- #endif /* NEIGHBOR_DB_H */
--- 
-2.36.1
-
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/99916-hostapd-mtk-Do-not-include-HE-capab-IE-if-associated-sta-s-HE-c.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/99908-hostapd-mtk-Do-not-include-HE-capab-IE-if-associate.patch
similarity index 81%
rename from autobuild_mac80211_release/package/network/services/hostapd/patches/99916-hostapd-mtk-Do-not-include-HE-capab-IE-if-associated-sta-s-HE-c.patch
rename to autobuild_mac80211_release/package/network/services/hostapd/patches/99908-hostapd-mtk-Do-not-include-HE-capab-IE-if-associate.patch
index b1769a1..9b96d98 100644
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/99916-hostapd-mtk-Do-not-include-HE-capab-IE-if-associated-sta-s-HE-c.patch
+++ b/autobuild_mac80211_release/package/network/services/hostapd/patches/99908-hostapd-mtk-Do-not-include-HE-capab-IE-if-associate.patch
@@ -1,8 +1,8 @@
-From dbd8120e47621784647deb776bf4b4d0a97fb49e Mon Sep 17 00:00:00 2001
+From 28228a96980512f30c8c8aac0f819c36f7241b68 Mon Sep 17 00:00:00 2001
 From: Howard Hsu <howard-yh.hsu@mediatek.com>
 Date: Thu, 22 Sep 2022 16:08:09 +0800
-Subject: [PATCH 99916/99917] Do not include HE capab IE if associated sta's HE
- capab IE is invalid
+Subject: [PATCH 99908/99909] hostapd: mtk: Do not include HE capab IE if
+ associated sta's HE capab IE is invalid
 
 ---
  src/ap/ieee802_11.c | 3 ++-
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/99917-hostapd-mtk-Add-DFS-and-ZWDFS-support.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/99909-hostapd-mtk-Add-DFS-and-ZWDFS-support.patch
similarity index 98%
rename from autobuild_mac80211_release/package/network/services/hostapd/patches/99917-hostapd-mtk-Add-DFS-and-ZWDFS-support.patch
rename to autobuild_mac80211_release/package/network/services/hostapd/patches/99909-hostapd-mtk-Add-DFS-and-ZWDFS-support.patch
index 83eac6e..8da9b5f 100644
--- a/autobuild_mac80211_release/package/network/services/hostapd/patches/99917-hostapd-mtk-Add-DFS-and-ZWDFS-support.patch
+++ b/autobuild_mac80211_release/package/network/services/hostapd/patches/99909-hostapd-mtk-Add-DFS-and-ZWDFS-support.patch
@@ -1,7 +1,7 @@
-From 80ecd3e0398aa668e683ff582a0594f88b290f44 Mon Sep 17 00:00:00 2001
+From 737d21c64ab0ac49e9cce7185f1f79bb0b71f50e Mon Sep 17 00:00:00 2001
 From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
 Date: Fri, 7 Oct 2022 10:46:29 +0800
-Subject: [PATCH 99917/99917] Add DFS and ZWDFS support
+Subject: [PATCH 99909/99909] hostapd: mtk: Add DFS and ZWDFS support
 
 Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
 ---