[rdkb][common][bsp][Refactor and sync wifi from openwrt]

[Description]
1776d62e [MAC80211][WiFi6/7][app][Fix atenl sync eeprom all issue]
f27a8bc9 [MAC80211][WiFi6][misc][Add coredump support for MT7981]
8ae764db [mac80211][netifd][wifi7][Fix patch fail]
db2ba4ea [mac80211][netifd][wifi7][Fix patch fail]
1671230e [MAC80211][WiFi6][mt76][Fix dump PFMU tag kernel calltrace]
537408c4 [MAC80211][WiFi6][Rebase][Fix patch error]
9a4c64fa [mac80211][wifi6][mt76][Fix txpower sku issues]
8276145f [MAC80211][WiFi6][mt76][not send RTS before sending BSRP]
2c6e3189 [MAC80211][WiFi6][Rebase Patches][Fix patch error]
6b529b8c [[MAC80211][WiFi6][mt76][add per-bss counter for mt7915]
95df57b3 [MAC80211][WiFi6][app][Add atenl support for cheetah]
94705cb2 [MAC80211][WiFi6][mt76][Add support for cheetah]
4ff10eee [mac80211][wifi6][mt76][Add debugfs address map for Cheetah MT76]
85af3247 [MAC80211[WiFi6]][hostapd][Add extender behavior log]
04302ac4 [MAC80211[WiFi7]][hostapd][Add eht_bw320_offset configuration option]
88013859 [MAC80211][WiFi6/7][app][Fix atenl cannot support binfile mode precal issue]
c1cad928 [MAC80211][WiFi6][mt76][Fix binfile cannot sync precal data to atenl]
8fd441fb [MAC80211][WiFi6/7][misc][remove internal patch for ucode package]
4653100b [MAC80211][WiFi6][mt76][rename bf debug cmd to align connac3]
9edd5444 [MAC80211][WiFi6][mt76][Fixed null pointer dereference issue]

[Release-log]

Change-Id: Ia7013b21497826cdf4d9c6192d6812aff5f948ae
diff --git a/recipes-wifi/hostapd/files/003-rdkb-uc-script-support.patch b/recipes-wifi/hostapd/files/003-rdkb-uc-script-support.patch
index a6d1aba..09183c1 100644
--- a/recipes-wifi/hostapd/files/003-rdkb-uc-script-support.patch
+++ b/recipes-wifi/hostapd/files/003-rdkb-uc-script-support.patch
@@ -1,28 +1,17 @@
-From 85f654326e723173bc1c8329624ecbf75a0f98be Mon Sep 17 00:00:00 2001
+From f02136395a9d534f3255a7ee1232aa9554c3e01c Mon Sep 17 00:00:00 2001
 From: mtk27745 <rex.lu@mediatek.com>
-Date: Wed, 25 Oct 2023 16:20:01 +0800
+Date: Tue, 14 Nov 2023 16:40:57 +0800
 Subject: [PATCH] rdkb uc script support
 
 ---
- common.uc         | 22 ++++++++++++----------
- hostapd.uc        |  6 +++---
- wdev.uc           | 20 ++++++++++----------
- wpa_supplicant.uc |  4 ++--
- 4 files changed, 27 insertions(+), 25 deletions(-)
+ common.uc | 2 ++
+ 1 file changed, 2 insertions(+)
 
 diff --git a/common.uc b/common.uc
-index ccffe3e..2b48d3e 100644
+index 4c33779..ee30df9 100644
 --- a/common.uc
 +++ b/common.uc
-@@ -1,6 +1,6 @@
- import * as nl80211 from "nl80211";
- import * as rtnl from "rtnl";
--import { readfile, glob, basename, readlink } from "fs";
-+import * as fs from "fs";
- 
- const iftypes = {
- 	ap: nl80211.const.NL80211_IFTYPE_AP,
-@@ -19,12 +19,14 @@ function __phy_is_fullmac(phyidx)
+@@ -49,6 +49,8 @@ function __phy_is_fullmac(phyidx)
  {
  	let data = nl80211.request(nl80211.const.NL80211_CMD_GET_WIPHY, 0, { wiphy: phyidx });
  
@@ -31,198 +20,6 @@
  	return !data.software_iftypes.ap_vlan;
  }
  
- function phy_is_fullmac(phy)
- {
--	let phyidx = int(trim(readfile(`/sys/class/ieee80211/${phy}/index`)));
-+	let phyidx = int(trim(fs.readfile(`/sys/class/ieee80211/${phy}/index`)));
- 
- 	return __phy_is_fullmac(phyidx);
- }
-@@ -39,14 +41,14 @@ function find_reusable_wdev(phyidx)
- 		nl80211.const.NLM_F_DUMP,
- 		{ wiphy: phyidx });
- 	for (let res in data)
--		if (trim(readfile(`/sys/class/net/${res.ifname}/operstate`)) == "down")
-+		if (trim(fs.readfile(`/sys/class/net/${res.ifname}/operstate`)) == "down")
- 			return res.ifname;
- 	return null;
- }
- 
- function wdev_create(phy, name, data)
- {
--	let phyidx = int(readfile(`/sys/class/ieee80211/${phy}/index`));
-+	let phyidx = int(fs.readfile(`/sys/class/ieee80211/${phy}/index`));
- 
- 	wdev_remove(name);
- 
-@@ -96,7 +98,7 @@ function wdev_create(phy, name, data)
- 
- function phy_sysfs_file(phy, name)
- {
--	return trim(readfile(`/sys/class/ieee80211/${phy}/${name}`));
-+	return trim(fs.readfile(`/sys/class/ieee80211/${phy}/${name}`));
- }
- 
- function macaddr_split(str)
-@@ -111,7 +113,7 @@ function macaddr_join(addr)
- 
- function wdev_macaddr(wdev)
- {
--	return trim(readfile(`/sys/class/net/${wdev}/address`));
-+	return trim(fs.readfile(`/sys/class/net/${wdev}/address`));
- }
- 
- const phy_proto = {
-@@ -221,10 +223,10 @@ const phy_proto = {
- 	},
- 
- 	for_each_wdev: function(cb) {
--		let wdevs = glob(`/sys/class/ieee80211/${this.name}/device/net/*`);
--		wdevs = map(wdevs, (arg) => basename(arg));
-+		let wdevs = fs.glob(`/sys/class/ieee80211/${this.name}/device/net/*`);
-+		wdevs = map(wdevs, (arg) => fs.basename(arg));
- 		for (let wdev in wdevs) {
--			if (basename(readlink(`/sys/class/net/${wdev}/phy80211`)) != this.name)
-+			if (fs.basename(fs.readlink(`/sys/class/net/${wdev}/phy80211`)) != this.name)
- 				continue;
- 
- 			cb(wdev);
-@@ -234,7 +236,7 @@ const phy_proto = {
- 
- function phy_open(phy)
- {
--	let phyidx = readfile(`/sys/class/ieee80211/${phy}/index`);
-+	let phyidx = fs.readfile(`/sys/class/ieee80211/${phy}/index`);
- 	if (!phyidx)
- 		return null;
- 
-diff --git a/hostapd.uc b/hostapd.uc
-index 1bce754..5f5ca35 100644
---- a/hostapd.uc
-+++ b/hostapd.uc
-@@ -1,5 +1,5 @@
- let libubus = require("ubus");
--import { open, readfile } from "fs";
-+import * as fs from "fs";
- import { wdev_create, wdev_remove, is_equal, vlist_new, phy_is_fullmac, phy_open } from "common";
- 
- let ubus = libubus.connect();
-@@ -562,7 +562,7 @@ function config_add_bss(config, name)
- 
- function iface_load_config(filename)
- {
--	let f = open(filename, "r");
-+	let f = fs.open(filename, "r");
- 	if (!f)
- 		return null;
- 
-@@ -620,7 +620,7 @@ function iface_load_config(filename)
- 		}
- 
- 		if (hostapd.data.file_fields[val[0]])
--			bss.hash[val[0]] = hostapd.sha1(readfile(val[1]));
-+			bss.hash[val[0]] = hostapd.sha1(fs.readfile(val[1]));
- 
- 		push(bss.data, line);
- 	}
-diff --git a/wdev.uc b/wdev.uc
-index cf438f7..5eb5e3c 100644
---- a/wdev.uc
-+++ b/wdev.uc
-@@ -1,7 +1,7 @@
- #!/usr/bin/env ucode
- 'use strict';
- import { vlist_new, is_equal, wdev_create, wdev_remove, phy_open } from "/usr/share/hostap/common.uc";
--import { readfile, writefile, basename, readlink, glob } from "fs";
-+import * as fs from "fs";
- let libubus = require("ubus");
- 
- let keep_devices = {};
-@@ -32,7 +32,7 @@ function iface_start(wdev)
- {
- 	let ifname = wdev.ifname;
- 
--	if (readfile(`/sys/class/net/${ifname}/ifindex`)) {
-+	if (fs.readfile(`/sys/class/net/${ifname}/ifindex`)) {
- 		system([ "ip", "link", "set", "dev", ifname, "down" ]);
- 		wdev_remove(ifname);
- 	}
-@@ -89,7 +89,7 @@ function iface_cb(new_if, old_if)
- function drop_inactive(config)
- {
- 	for (let key in config) {
--		if (!readfile(`/sys/class/net/${key}/ifindex`))
-+		if (!fs.readfile(`/sys/class/net/${key}/ifindex`))
- 			delete config[key];
- 	}
- }
-@@ -108,23 +108,23 @@ function delete_ifname(config)
- 
- function add_existing(phy, config)
- {
--	let wdevs = glob(`/sys/class/ieee80211/${phy}/device/net/*`);
--	wdevs = map(wdevs, (arg) => basename(arg));
-+	let wdevs = fs.glob(`/sys/class/ieee80211/${phy}/device/net/*`);
-+	wdevs = map(wdevs, (arg) => fs.basename(arg));
- 	for (let wdev in wdevs) {
- 		if (config[wdev])
- 			continue;
- 
--		if (basename(readlink(`/sys/class/net/${wdev}/phy80211`)) != phy)
-+		if (fs.basename(fs.readlink(`/sys/class/net/${wdev}/phy80211`)) != phy)
- 			continue;
- 
--		if (trim(readfile(`/sys/class/net/${wdev}/operstate`)) == "down")
-+		if (trim(fs.readfile(`/sys/class/net/${wdev}/operstate`)) == "down")
- 			config[wdev] = {};
- 	}
- }
- 
- function usage()
- {
--	warn(`Usage: ${basename(sourcepath())} <phy> <command> [<arguments>]
-+	warn(`Usage: ${fs.basename(sourcepath())} <phy> <command> [<arguments>]
- 
- Commands:
- 	set_config <config> [<device]...] - set phy configuration
-@@ -150,7 +150,7 @@ const commands = {
- 			exit(1);
- 		}
- 
--		let old_config = readfile(statefile);
-+		let old_config = fs.readfile(statefile);
- 		if (old_config)
- 			old_config = json(old_config);
- 
-@@ -175,7 +175,7 @@ const commands = {
- 
- 		drop_inactive(config.data);
- 		delete_ifname(config.data);
--		writefile(statefile, sprintf("%J", config.data));
-+		fs.writefile(statefile, sprintf("%J", config.data));
- 	},
- 	get_macaddr: function(args) {
- 		let data = {};
-diff --git a/wpa_supplicant.uc b/wpa_supplicant.uc
-index 2a9de67..cd149dc 100644
---- a/wpa_supplicant.uc
-+++ b/wpa_supplicant.uc
-@@ -1,5 +1,5 @@
- let libubus = require("ubus");
--import { open, readfile } from "fs";
-+import * as fs from "fs";
- import { wdev_create, wdev_remove, is_equal, vlist_new, phy_open } from "common";
- 
- let ubus = libubus.connect();
-@@ -62,7 +62,7 @@ function iface_cb(new_if, old_if)
- 
- function prepare_config(config)
- {
--	config.config_data = readfile(config.config);
-+	config.config_data = fs.readfile(config.config);
- 
- 	return { config: config };
- }
 -- 
 2.18.0
 
diff --git a/recipes-wifi/hostapd/files/common.uc b/recipes-wifi/hostapd/files/common.uc
index ccffe3e..4c33779 100644
--- a/recipes-wifi/hostapd/files/common.uc
+++ b/recipes-wifi/hostapd/files/common.uc
@@ -10,6 +10,36 @@
 	monitor: nl80211.const.NL80211_IFTYPE_MONITOR,
 };
 
+const mesh_params = {
+	mesh_retry_timeout: "retry_timeout",
+	mesh_confirm_timeout: "confirm_timeout",
+	mesh_holding_timeout: "holding_timeout",
+	mesh_max_peer_links: "max_peer_links",
+	mesh_max_retries: "max_retries",
+	mesh_ttl: "ttl",
+	mesh_element_ttl: "element_ttl",
+	mesh_auto_open_plinks: "auto_open_plinks",
+	mesh_hwmp_max_preq_retries: "hwmp_max_preq_retries",
+	mesh_path_refresh_time: "path_refresh_time",
+	mesh_min_discovery_timeout: "min_discovery_timeout",
+	mesh_hwmp_active_path_timeout: "hwmp_active_path_timeout",
+	mesh_hwmp_preq_min_interval: "hwmp_preq_min_interval",
+	mesh_hwmp_net_diameter_traversal_time: "hwmp_net_diam_trvs_time",
+	mesh_hwmp_rootmode: "hwmp_rootmode",
+	mesh_hwmp_rann_interval: "hwmp_rann_interval",
+	mesh_gate_announcements: "gate_announcements",
+	mesh_sync_offset_max_neighor: "sync_offset_max_neighbor",
+	mesh_rssi_threshold: "rssi_threshold",
+	mesh_hwmp_active_path_to_root_timeout: "hwmp_path_to_root_timeout",
+	mesh_hwmp_root_interval: "hwmp_root_interval",
+	mesh_hwmp_confirmation_interval: "hwmp_confirmation_interval",
+	mesh_awake_window: "awake_window",
+	mesh_plink_timeout: "plink_timeout",
+	mesh_fwding: "forwarding",
+	mesh_power_mode: "power_mode",
+	mesh_nolearn: "nolearn"
+};
+
 function wdev_remove(name)
 {
 	nl80211.request(nl80211.const.NL80211_CMD_DEL_INTERFACE, 0, { dev: name });
@@ -94,6 +124,31 @@
 	return null;
 }
 
+function wdev_set_mesh_params(name, data)
+{
+	let mesh_cfg = {};
+
+	for (let key in mesh_params) {
+		let val = data[key];
+		if (val == null)
+			continue;
+		mesh_cfg[mesh_params[key]] = int(val);
+	}
+
+	if (!length(mesh_cfg))
+		return null;
+
+	nl80211.request(nl80211.const.NL80211_CMD_SET_MESH_CONFIG, 0,
+		{ dev: name, mesh_params: mesh_cfg });
+
+	return nl80211.error();
+}
+
+function wdev_set_up(name, up)
+{
+	rtnl.request(rtnl.const.RTM_SETLINK, 0, { dev: name, change: 1, flags: up ? 1 : 0 });
+}
+
 function phy_sysfs_file(phy, name)
 {
 	return trim(readfile(`/sys/class/ieee80211/${phy}/${name}`));
@@ -315,4 +370,4 @@
 		}, vlist_proto);
 }
 
-export { wdev_remove, wdev_create, is_equal, vlist_new, phy_is_fullmac, phy_open };
+export { wdev_remove, wdev_create, wdev_set_mesh_params, wdev_set_up, is_equal, vlist_new, phy_is_fullmac, phy_open };
diff --git a/recipes-wifi/hostapd/files/hostapd.uc b/recipes-wifi/hostapd/files/hostapd.uc
index 1bce754..593840c 100644
--- a/recipes-wifi/hostapd/files/hostapd.uc
+++ b/recipes-wifi/hostapd/files/hostapd.uc
@@ -60,7 +60,6 @@
 function iface_freq_info(iface, config, params)
 {
 	let freq = params.frequency;
-	let bw320_offset = params.bw320_offset;
 	if (!freq)
 		return null;
 
@@ -69,29 +68,25 @@
 		sec_offset = 0;
 
 	let width = 0;
-	if (params.ch_width >= 0){
-		width = params.ch_width;
-	} else {
-		for (let line in config.radio.data) {
-			if (!sec_offset && match(line, /^ht_capab=.*HT40/)) {
-				sec_offset = null; // auto-detect
-				continue;
-			}
+	for (let line in config.radio.data) {
+		if (!sec_offset && match(line, /^ht_capab=.*HT40/)) {
+			sec_offset = null; // auto-detect
+			continue;
+		}
 
-			let val = match(line, /^(vht_oper_chwidth|he_oper_chwidth|eht_oper_chwidth)=(\d+)/);
-			if (!val)
-				continue;
+		let val = match(line, /^(vht_oper_chwidth|he_oper_chwidth)=(\d+)/);
+		if (!val)
+			continue;
 
-			val = int(val[2]);
-			if (val > width)
-				width = val;
-		}
+		val = int(val[2]);
+		if (val > width)
+			width = val;
 	}
 
 	if (freq < 4000)
 		width = 0;
 
-	return hostapd.freq_info(freq, sec_offset, width, bw320_offset);
+	return hostapd.freq_info(freq, sec_offset, width);
 }
 
 function iface_add(phy, config, phy_status)
@@ -576,7 +571,7 @@
 
 	let bss;
 	let line;
-	while ((line = trim(f.read("line"))) != null) {
+	while ((line = rtrim(f.read("line"), "\n")) != null) {
 		let val = split(line, "=", 2);
 		if (!val[0])
 			continue;
@@ -598,7 +593,7 @@
 		push(config.radio.data, line);
 	}
 
-	while ((line = trim(f.read("line"))) != null) {
+	while ((line = rtrim(f.read("line"), "\n")) != null) {
 		if (line == "#default_macaddr")
 			bss.default_macaddr = true;
 
@@ -663,8 +658,6 @@
 			up: true,
 			frequency: 0,
 			sec_chan_offset: 0,
-			ch_width: -1,
-			bw320_offset: 1,
 			csa: true,
 			csa_count: 0,
 		},
@@ -672,15 +665,6 @@
 			if (req.args.up == null || !req.args.phy)
 				return libubus.STATUS_INVALID_ARGUMENT;
 
-			hostapd.printf(`ucode: mtk: apsta state update`);
-			hostapd.printf(`    * phy: ${req.args.phy}`);
-			hostapd.printf(`    * up: ${req.args.up}`);
-			hostapd.printf(`    * freqeuncy: ${req.args.frequency}`);
-			hostapd.printf(`    * sec_chan_offset: ${req.args.sec_chan_offset}`);
-			hostapd.printf(`    * ch_width: ${req.args.ch_width}`);
-			hostapd.printf(`    * bw320_offset: ${req.args.bw320_offset}`);
-			hostapd.printf(`    * csa: ${req.args.csa}`);
-
 			let phy = req.args.phy;
 			let config = hostapd.data.config[phy];
 			if (!config || !config.bss || !config.bss[0] || !config.bss[0].ifname)
diff --git a/recipes-wifi/hostapd/files/patches-2.10.3/135-mbedtls-fix-owe-association.patch b/recipes-wifi/hostapd/files/patches-2.10.3/135-mbedtls-fix-owe-association.patch
new file mode 100644
index 0000000..0c29432
--- /dev/null
+++ b/recipes-wifi/hostapd/files/patches-2.10.3/135-mbedtls-fix-owe-association.patch
@@ -0,0 +1,91 @@
+The code for hostapd-mbedtls did not work when used for OWE association.
+
+When handling association requests, the buffer offsets and length assumptions were incorrect, leading to never calculating the y point, thus denying association.
+
+Also when crafting the association response, the buffer contained the trailing key-type.
+
+Fix up both issues to adhere to the specification and make hostapd-mbedtls work with the OWE security type.
+
+--- a/src/crypto/crypto_mbedtls.c
++++ b/src/crypto/crypto_mbedtls.c
+@@ -2299,25 +2299,30 @@ struct crypto_ecdh * crypto_ecdh_init2(i
+ struct wpabuf * crypto_ecdh_get_pubkey(struct crypto_ecdh *ecdh, int inc_y)
+ {
+ 	mbedtls_ecp_group *grp = &ecdh->grp;
+-	size_t len = CRYPTO_EC_plen(grp);
++	size_t prime_len = CRYPTO_EC_plen(grp);
++	size_t output_len = prime_len;
++	u8 output_offset = 0;
++	u8 buf[256];
++
+   #ifdef MBEDTLS_ECP_MONTGOMERY_ENABLED
+ 	/* len */
+   #endif
+   #ifdef MBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLED
+-	if (mbedtls_ecp_get_type(grp) == MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS)
+-		len = inc_y ? len*2+1 : len+1;
++	if (mbedtls_ecp_get_type(grp) == MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS) {
++		output_len = inc_y ? prime_len * 2 + 1 : prime_len + 1;
++		output_offset = 1;
++	}
+   #endif
+-	struct wpabuf *buf = wpabuf_alloc(len);
+-	if (buf == NULL)
++
++	if (output_len > sizeof(buf))
+ 		return NULL;
++
+ 	inc_y = inc_y ? MBEDTLS_ECP_PF_UNCOMPRESSED : MBEDTLS_ECP_PF_COMPRESSED;
+-	if (mbedtls_ecp_point_write_binary(grp, &ecdh->Q, inc_y, &len,
+-	                                   wpabuf_mhead_u8(buf), len) == 0) {
+-		wpabuf_put(buf, len);
+-		return buf;
++	if (mbedtls_ecp_point_write_binary(grp, &ecdh->Q, inc_y, &output_len,
++	                                   buf, output_len) == 0) {
++		return wpabuf_alloc_copy(buf + output_offset, output_len - output_offset);
+ 	}
+ 
+-	wpabuf_free(buf);
+ 	return NULL;
+ }
+ 
+@@ -2379,10 +2384,7 @@ struct wpabuf * crypto_ecdh_set_peerkey(
+ 				os_memcpy(buf+2, key, len);
+ 			}
+ 			len >>= 1; /*(repurpose len to prime_len)*/
+-		}
+-		else if (key[0] == 0x02 || key[0] == 0x03) { /* (inc_y == 0) */
+-			--len; /*(repurpose len to prime_len)*/
+-
++		} else { /* (inc_y == 0) */
+ 			/* mbedtls_ecp_point_read_binary() does not currently support
+ 			 * MBEDTLS_ECP_PF_COMPRESSED format (buf[1] = 0x02 or 0x03)
+ 			 * (returns MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE) */
+@@ -2390,22 +2392,21 @@ struct wpabuf * crypto_ecdh_set_peerkey(
+ 			/* derive y, amend buf[] with y for UNCOMPRESSED format */
+ 			if (sizeof(buf)-2 < len*2 || len == 0)
+ 				return NULL;
++
+ 			buf[0] = (u8)(1+len*2);
+ 			buf[1] = 0x04;
++			os_memcpy(buf+2, key, len);
++
+ 			mbedtls_mpi bn;
+ 			mbedtls_mpi_init(&bn);
+-			int ret = mbedtls_mpi_read_binary(&bn, key+1, len)
+-			       || crypto_mbedtls_short_weierstrass_derive_y(grp, &bn,
+-			                                                    key[0] & 1)
++			int ret = mbedtls_mpi_read_binary(&bn, key, len)
++			       || crypto_mbedtls_short_weierstrass_derive_y(grp, &bn, 0)
+ 			       || mbedtls_mpi_write_binary(&bn, buf+2+len, len);
+ 			mbedtls_mpi_free(&bn);
+ 			if (ret != 0)
+ 				return NULL;
+ 		}
+ 
+-		if (key[0] == 0) /*(repurpose len to prime_len)*/
+-			len = CRYPTO_EC_plen(grp);
+-
+ 		if (mbedtls_ecdh_read_public(&ecdh->ctx, buf, buf[0]+1))
+ 			return NULL;
+ 	}
diff --git a/recipes-wifi/hostapd/files/patches-2.10.3/301-mesh-noscan.patch b/recipes-wifi/hostapd/files/patches-2.10.3/301-mesh-noscan.patch
index 6b5416f..ceb6d0c 100644
--- a/recipes-wifi/hostapd/files/patches-2.10.3/301-mesh-noscan.patch
+++ b/recipes-wifi/hostapd/files/patches-2.10.3/301-mesh-noscan.patch
@@ -24,8 +24,8 @@
  			   frequency);
  		goto out_free;
  	}
-+	if (ssid->noscan)
-+		conf->noscan = 1;
++	if (conf->noscan)
++		ssid->noscan = 1;
  
  	if (ssid->mesh_basic_rates == NULL) {
  		/*
@@ -45,7 +45,7 @@
  	unsigned int j;
  	static const int ht40plus[] = {
 -		36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157, 165, 173,
-+		1, 2, 3, 4, 5, 6, 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157, 165, 173,
++		1, 2, 3, 4, 5, 6, 7, 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157, 165, 173,
  		184, 192
  	};
  	int ht40 = -1;
@@ -58,6 +58,15 @@
  	u8 channel;
  	bool is_6ghz;
  	bool dfs_enabled = wpa_s->conf->country[0] && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_RADAR);
+@@ -3080,6 +3080,8 @@ void ibss_mesh_setup_freq(struct wpa_sup
+ 		freq->he_enabled = ibss_mesh_can_use_he(wpa_s, ssid, mode,
+ 							ieee80211_mode);
+ 	freq->channel = channel;
++	if (mode->mode == HOSTAPD_MODE_IEEE80211G && ssid->noscan)
++		ibss_mesh_select_40mhz(wpa_s, ssid, mode, freq, obss_scan, dfs_enabled);
+ 	/* Setup higher BW only for 5 GHz */
+ 	if (mode->mode == HOSTAPD_MODE_IEEE80211A) {
+ 		ibss_mesh_select_40mhz(wpa_s, ssid, mode, freq, obss_scan, dfs_enabled);
 --- a/wpa_supplicant/config_ssid.h
 +++ b/wpa_supplicant/config_ssid.h
 @@ -1035,6 +1035,8 @@ struct wpa_ssid {
diff --git a/recipes-wifi/hostapd/files/patches-2.10.3/310-rescan_immediately.patch b/recipes-wifi/hostapd/files/patches-2.10.3/310-rescan_immediately.patch
index e12b205..6e0244b 100644
--- a/recipes-wifi/hostapd/files/patches-2.10.3/310-rescan_immediately.patch
+++ b/recipes-wifi/hostapd/files/patches-2.10.3/310-rescan_immediately.patch
@@ -1,6 +1,6 @@
 --- a/wpa_supplicant/wpa_supplicant.c
 +++ b/wpa_supplicant/wpa_supplicant.c
-@@ -5767,7 +5767,7 @@ wpa_supplicant_alloc(struct wpa_supplica
+@@ -5769,7 +5769,7 @@ wpa_supplicant_alloc(struct wpa_supplica
  	if (wpa_s == NULL)
  		return NULL;
  	wpa_s->scan_req = INITIAL_SCAN_REQ;
diff --git a/recipes-wifi/hostapd/files/patches-2.10.3/460-wpa_supplicant-add-new-config-params-to-be-used-with.patch b/recipes-wifi/hostapd/files/patches-2.10.3/460-wpa_supplicant-add-new-config-params-to-be-used-with.patch
index c6fe54e..dc19553 100644
--- a/recipes-wifi/hostapd/files/patches-2.10.3/460-wpa_supplicant-add-new-config-params-to-be-used-with.patch
+++ b/recipes-wifi/hostapd/files/patches-2.10.3/460-wpa_supplicant-add-new-config-params-to-be-used-with.patch
@@ -174,7 +174,7 @@
  	 * macsec_policy - Determines the policy for MACsec secure session
 --- a/wpa_supplicant/wpa_supplicant.c
 +++ b/wpa_supplicant/wpa_supplicant.c
-@@ -4175,6 +4175,12 @@ static void wpas_start_assoc_cb(struct w
+@@ -4177,6 +4177,12 @@ static void wpas_start_assoc_cb(struct w
  			params.beacon_int = ssid->beacon_int;
  		else
  			params.beacon_int = wpa_s->conf->beacon_int;
diff --git a/recipes-wifi/hostapd/files/patches-2.10.3/600-ubus_support.patch b/recipes-wifi/hostapd/files/patches-2.10.3/600-ubus_support.patch
index bc80ef0..a6ccf83 100644
--- a/recipes-wifi/hostapd/files/patches-2.10.3/600-ubus_support.patch
+++ b/recipes-wifi/hostapd/files/patches-2.10.3/600-ubus_support.patch
@@ -348,7 +348,7 @@
  CFLAGS += -DEAP_SERVER -DEAP_SERVER_IDENTITY
 --- a/wpa_supplicant/wpa_supplicant.c
 +++ b/wpa_supplicant/wpa_supplicant.c
-@@ -7593,6 +7593,8 @@ struct wpa_supplicant * wpa_supplicant_a
+@@ -7595,6 +7595,8 @@ struct wpa_supplicant * wpa_supplicant_a
  	}
  #endif /* CONFIG_P2P */
  
@@ -357,7 +357,7 @@
  	return wpa_s;
  }
  
-@@ -7619,6 +7621,8 @@ int wpa_supplicant_remove_iface(struct w
+@@ -7621,6 +7623,8 @@ int wpa_supplicant_remove_iface(struct w
  	struct wpa_supplicant *parent = wpa_s->parent;
  #endif /* CONFIG_MESH */
  
@@ -366,7 +366,7 @@
  	/* Remove interface from the global list of interfaces */
  	prev = global->ifaces;
  	if (prev == wpa_s) {
-@@ -7965,8 +7969,12 @@ int wpa_supplicant_run(struct wpa_global
+@@ -7967,8 +7971,12 @@ int wpa_supplicant_run(struct wpa_global
  	eloop_register_signal_terminate(wpa_supplicant_terminate, global);
  	eloop_register_signal_reconfig(wpa_supplicant_reconfig, global);
  
diff --git a/recipes-wifi/hostapd/files/patches-2.10.3/601-ucode_support.patch b/recipes-wifi/hostapd/files/patches-2.10.3/601-ucode_support.patch
index de182b9..23f535b 100644
--- a/recipes-wifi/hostapd/files/patches-2.10.3/601-ucode_support.patch
+++ b/recipes-wifi/hostapd/files/patches-2.10.3/601-ucode_support.patch
@@ -196,7 +196,7 @@
  
  #ifdef CONFIG_BGSCAN
  	if (state == WPA_COMPLETED && wpa_s->current_ssid != wpa_s->bgscan_ssid)
-@@ -7594,6 +7595,7 @@ struct wpa_supplicant * wpa_supplicant_a
+@@ -7596,6 +7597,7 @@ struct wpa_supplicant * wpa_supplicant_a
  #endif /* CONFIG_P2P */
  
  	wpas_ubus_add_bss(wpa_s);
@@ -204,7 +204,7 @@
  
  	return wpa_s;
  }
-@@ -7621,6 +7623,7 @@ int wpa_supplicant_remove_iface(struct w
+@@ -7623,6 +7625,7 @@ int wpa_supplicant_remove_iface(struct w
  	struct wpa_supplicant *parent = wpa_s->parent;
  #endif /* CONFIG_MESH */
  
@@ -212,7 +212,7 @@
  	wpas_ubus_free_bss(wpa_s);
  
  	/* Remove interface from the global list of interfaces */
-@@ -7931,6 +7934,7 @@ struct wpa_global * wpa_supplicant_init(
+@@ -7933,6 +7936,7 @@ struct wpa_global * wpa_supplicant_init(
  
  	eloop_register_timeout(WPA_SUPPLICANT_CLEANUP_INTERVAL, 0,
  			       wpas_periodic, global, NULL);
@@ -220,7 +220,7 @@
  
  	return global;
  }
-@@ -7969,12 +7973,8 @@ int wpa_supplicant_run(struct wpa_global
+@@ -7971,12 +7975,8 @@ int wpa_supplicant_run(struct wpa_global
  	eloop_register_signal_terminate(wpa_supplicant_terminate, global);
  	eloop_register_signal_reconfig(wpa_supplicant_reconfig, global);
  
@@ -233,7 +233,7 @@
  	return 0;
  }
  
-@@ -8007,6 +8007,8 @@ void wpa_supplicant_deinit(struct wpa_gl
+@@ -8009,6 +8009,8 @@ void wpa_supplicant_deinit(struct wpa_gl
  
  	wpas_notify_supplicant_deinitialized(global);
  
diff --git a/recipes-wifi/hostapd/files/patches-2.10.3/992-nl80211-add-extra-ies-only-if-allowed-by-driver.patch b/recipes-wifi/hostapd/files/patches-2.10.3/992-nl80211-add-extra-ies-only-if-allowed-by-driver.patch
new file mode 100644
index 0000000..c7b595d
--- /dev/null
+++ b/recipes-wifi/hostapd/files/patches-2.10.3/992-nl80211-add-extra-ies-only-if-allowed-by-driver.patch
@@ -0,0 +1,62 @@
+From: David Bauer <mail@david-bauer.net>
+To: hostap@lists.infradead.org
+Cc: =?utf-8?q?=C3=89tienne_Morice?= <neon.emorice@mail.com>
+Subject: [PATCH] nl80211: add extra-ies only if allowed by driver
+Date: Sun, 30 Jan 2022 20:22:00 +0100
+Message-Id: <20220130192200.10883-1-mail@david-bauer.net>
+List-Id: <hostap.lists.infradead.org>
+
+Upgrading wpa_supplicant from 2.9 to 2.10 breaks broadcom-wl
+based adapters. The reason for it is hostapd tries to install additional
+IEs for scanning while the driver does not support this.
+
+The kernel indicates the maximum number of bytes for additional scan IEs
+using the NL80211_ATTR_MAX_SCAN_IE_LEN attribute. Save this value and
+only add additional scan IEs in case the driver can accommodate these
+additional IEs.
+
+Reported-by: Étienne Morice <neon.emorice@mail.com>
+Tested-by: Étienne Morice <neon.emorice@mail.com>
+Signed-off-by: David Bauer <mail@david-bauer.net>
+---
+ src/drivers/driver.h              | 3 +++
+ src/drivers/driver_nl80211_capa.c | 4 ++++
+ src/drivers/driver_nl80211_scan.c | 2 +-
+ 3 files changed, 8 insertions(+), 1 deletion(-)
+
+--- a/src/drivers/driver.h
++++ b/src/drivers/driver.h
+@@ -2283,6 +2283,9 @@ struct wpa_driver_capa {
+ 	/** Maximum number of iterations in a single scan plan */
+ 	u32 max_sched_scan_plan_iterations;
+ 
++	/** Maximum number of extra IE bytes for scans */
++	u16 max_scan_ie_len;
++
+ 	/** Whether sched_scan (offloaded scanning) is supported */
+ 	int sched_scan_supported;
+ 
+--- a/src/drivers/driver_nl80211_capa.c
++++ b/src/drivers/driver_nl80211_capa.c
+@@ -949,6 +949,10 @@ static int wiphy_info_handler(struct nl_
+ 			nla_get_u32(tb[NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS]);
+ 	}
+ 
++	if (tb[NL80211_ATTR_MAX_SCAN_IE_LEN])
++		capa->max_scan_ie_len =
++			nla_get_u16(tb[NL80211_ATTR_MAX_SCAN_IE_LEN]);
++
+ 	if (tb[NL80211_ATTR_MAX_MATCH_SETS])
+ 		capa->max_match_sets =
+ 			nla_get_u8(tb[NL80211_ATTR_MAX_MATCH_SETS]);
+--- a/src/drivers/driver_nl80211_scan.c
++++ b/src/drivers/driver_nl80211_scan.c
+@@ -222,7 +222,7 @@ nl80211_scan_common(struct i802_bss *bss
+ 		wpa_printf(MSG_DEBUG, "nl80211: Passive scan requested");
+ 	}
+ 
+-	if (params->extra_ies) {
++	if (params->extra_ies && drv->capa.max_scan_ie_len >= params->extra_ies_len) {
+ 		wpa_hexdump(MSG_MSGDUMP, "nl80211: Scan extra IEs",
+ 			    params->extra_ies, params->extra_ies_len);
+ 		if (nla_put(msg, NL80211_ATTR_IE, params->extra_ies_len,
diff --git a/recipes-wifi/hostapd/files/patches-2.10.3/patches.inc b/recipes-wifi/hostapd/files/patches-2.10.3/patches.inc
index 4c214c1..600fad1 100644
--- a/recipes-wifi/hostapd/files/patches-2.10.3/patches.inc
+++ b/recipes-wifi/hostapd/files/patches-2.10.3/patches.inc
@@ -12,6 +12,7 @@
     file://110-mbedtls-TLS-crypto-option-initial-port.patch \
     file://120-mbedtls-fips186_2_prf.patch \
     file://130-mbedtls-annotate-with-TEST_FAIL-for-hwsim-tests.patch \
+    file://135-mbedtls-fix-owe-association.patch \
     file://140-tests-Makefile-make-run-tests-with-CONFIG_TLS.patch \
     file://150-add-NULL-checks-encountered-during-tests-hwsim.patch \
     file://160-dpp_pkex-EC-point-mul-w-value-prime.patch \
@@ -60,6 +61,7 @@
     file://770-radius_server.patch \
     file://990-ctrl-make-WNM_AP-functions-dependant-on-CONFIG_AP.patch \
     file://991-Fix-OpenWrt-13156.patch \
+    file://992-nl80211-add-extra-ies-only-if-allowed-by-driver.patch \
     file://mtk-0001-hostapd-mtk-Add-neighbor-report-and-BSS-Termination-.patch \
     file://mtk-0002-hostapd-mtk-print-sae-groups-by-hostapd-ctrl.patch \
     file://mtk-0003-hostapd-mtk-add-support-for-runtime-set-in-band-disc.patch \
diff --git a/recipes-wifi/hostapd/files/patches/mtk-0045-hostapd-mtk-add-log-in-extender-mode.patch b/recipes-wifi/hostapd/files/patches/mtk-0045-hostapd-mtk-add-log-in-extender-mode.patch
new file mode 100644
index 0000000..b0530a0
--- /dev/null
+++ b/recipes-wifi/hostapd/files/patches/mtk-0045-hostapd-mtk-add-log-in-extender-mode.patch
@@ -0,0 +1,51 @@
+From ffd6770c6cb58a8b7cb6bd4ec7a1c5f161e86d1d Mon Sep 17 00:00:00 2001
+From: Michael-CY Lee <michael-cy.lee@mediatek.com>
+Date: Fri, 27 Oct 2023 10:12:59 +0800
+Subject: [PATCH] hostapd: mtk: add log in extender mode
+
+---
+ hostapd/ctrl_iface.c   | 8 ++++++++
+ src/ap/ctrl_iface_ap.c | 1 +
+ 2 files changed, 9 insertions(+)
+
+diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
+index 89594ec..aa435ee 100644
+--- a/hostapd/ctrl_iface.c
++++ b/hostapd/ctrl_iface.c
+@@ -186,6 +186,13 @@ static struct hostapd_config *hostapd_ctrl_iface_config_read(const char *fname)
+ 			break;
+ 	}
+ 
++	wpa_printf(MSG_INFO, "mtk: new channel information: channel=%u, "
++		   "secondary_channel=%d, center_segment0=%u, "
++		   "center_segment1=%u, op_class=%u\n",
++		   conf->channel, conf->secondary_channel,
++		   hostapd_get_oper_centr_freq_seg0_idx(conf),
++		   hostapd_get_oper_centr_freq_seg1_idx(conf), conf->op_class);
++
+ 	return conf;
+ }
+ 
+@@ -199,6 +206,7 @@ static int hostapd_ctrl_iface_update(struct hostapd_data *hapd, char *txt)
+ 	iface->interfaces->config_read_cb = hostapd_ctrl_iface_config_read;
+ 	reload_opts = txt;
+ 
++	wpa_printf(MSG_INFO, "mtk: update iface for %s\n", iface->phy);
+ 	for (j = 0; j < iface->num_bss; j++)
+ 		iface->bss[j]->stopped_by_supplicant = 0;
+ 
+diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c
+index 1ad37c5..86e8729 100644
+--- a/src/ap/ctrl_iface_ap.c
++++ b/src/ap/ctrl_iface_ap.c
+@@ -951,6 +951,7 @@ int hostapd_ctrl_iface_stop_ap(struct hostapd_data *hapd)
+ 	struct hostapd_iface *iface = hapd->iface;
+ 	int i;
+ 
++	wpa_printf(MSG_INFO, "mtk: stop iface for %s\n", iface->phy);
+ 	for (i = 0; i < iface->num_bss; i++){
+ 		iface->bss[i]->stopped_by_supplicant = 1;
+ 		hostapd_drv_stop_ap(iface->bss[i]);
+-- 
+2.25.1
+
diff --git a/recipes-wifi/hostapd/files/patches/patches.inc b/recipes-wifi/hostapd/files/patches/patches.inc
index 0574840..9121a2f 100644
--- a/recipes-wifi/hostapd/files/patches/patches.inc
+++ b/recipes-wifi/hostapd/files/patches/patches.inc
@@ -106,4 +106,5 @@
     file://mtk-0041-hostapd-mtk-6g-bss-connect-ignore-ht-opera.patch \
     file://mtk-0042-hostapd-mtk-avoid-unnecessary-beacon-update-for-6-GH.patch \
     file://mtk-0044-hostapd-mtk-Add-ACS-chanlist-info-in-get_config.patch \
+    file://mtk-0045-hostapd-mtk-add-log-in-extender-mode.patch \
     "
diff --git a/recipes-wifi/hostapd/files/wdev.uc b/recipes-wifi/hostapd/files/wdev.uc
index cf438f7..ff4d629 100644
--- a/recipes-wifi/hostapd/files/wdev.uc
+++ b/recipes-wifi/hostapd/files/wdev.uc
@@ -1,6 +1,6 @@
 #!/usr/bin/env ucode
 'use strict';
-import { vlist_new, is_equal, wdev_create, wdev_remove, phy_open } from "/usr/share/hostap/common.uc";
+import { vlist_new, is_equal, wdev_create, wdev_set_mesh_params, wdev_remove, wdev_set_up, phy_open } from "/usr/share/hostap/common.uc";
 import { readfile, writefile, basename, readlink, glob } from "fs";
 let libubus = require("ubus");
 
@@ -9,17 +9,6 @@
 let command = shift(ARGV);
 let phydev;
 
-const mesh_params = [
-	"mesh_retry_timeout", "mesh_confirm_timeout", "mesh_holding_timeout", "mesh_max_peer_links",
-	"mesh_max_retries", "mesh_ttl", "mesh_element_ttl", "mesh_hwmp_max_preq_retries",
-	"mesh_path_refresh_time", "mesh_min_discovery_timeout", "mesh_hwmp_active_path_timeout",
-	"mesh_hwmp_preq_min_interval", "mesh_hwmp_net_diameter_traversal_time", "mesh_hwmp_rootmode",
-	"mesh_hwmp_rann_interval", "mesh_gate_announcements", "mesh_sync_offset_max_neighor",
-	"mesh_rssi_threshold", "mesh_hwmp_active_path_to_root_timeout", "mesh_hwmp_root_interval",
-	"mesh_hwmp_confirmation_interval", "mesh_awake_window", "mesh_plink_timeout",
-	"mesh_auto_open_plinks", "mesh_fwding", "mesh_power_mode"
-];
-
 function iface_stop(wdev)
 {
 	if (keep_devices[wdev.ifname])
@@ -33,7 +22,7 @@
 	let ifname = wdev.ifname;
 
 	if (readfile(`/sys/class/net/${ifname}/ifindex`)) {
-		system([ "ip", "link", "set", "dev", ifname, "down" ]);
+		wdev_set_up(ifname, false);
 		wdev_remove(ifname);
 	}
 	let wdev_config = {};
@@ -42,7 +31,7 @@
 	if (!wdev_config.macaddr && wdev.mode != "monitor")
 		wdev_config.macaddr = phydev.macaddr_next();
 	wdev_create(phy, ifname, wdev_config);
-	system([ "ip", "link", "set", "dev", ifname, "up" ]);
+	wdev_set_up(ifname, true);
 	if (wdev.freq)
 		system(`iw dev ${ifname} set freq ${wdev.freq} ${wdev.htmode}`);
 	if (wdev.mode == "adhoc") {
@@ -60,19 +49,8 @@
 				push(cmd, key, wdev[key]);
 		system(cmd);
 
-		cmd = ["iw", "dev", ifname, "set", "mesh_param" ];
-		let len = length(cmd);
-
-		for (let param in mesh_params)
-			if (wdev[param])
-				push(cmd, param, wdev[param]);
-
-		if (len == length(cmd))
-			return;
-
-		system(cmd);
+		wdev_set_mesh_params(ifname, wdev);
 	}
-
 }
 
 function iface_cb(new_if, old_if)
diff --git a/recipes-wifi/hostapd/files/wpa_supplicant.uc b/recipes-wifi/hostapd/files/wpa_supplicant.uc
index 2a9de67..d624f27 100644
--- a/recipes-wifi/hostapd/files/wpa_supplicant.uc
+++ b/recipes-wifi/hostapd/files/wpa_supplicant.uc
@@ -1,6 +1,6 @@
 let libubus = require("ubus");
 import { open, readfile } from "fs";
-import { wdev_create, wdev_remove, is_equal, vlist_new, phy_open } from "common";
+import { wdev_create, wdev_set_mesh_params, wdev_remove, is_equal, wdev_set_up, vlist_new, phy_open } from "common";
 
 let ubus = libubus.connect();
 
@@ -40,6 +40,7 @@
 	let ret = wdev_create(phy, ifname, wdev_config);
 	if (ret)
 		wpas.printf(`Failed to create device ${ifname}: ${ret}`);
+	wdev_set_up(ifname, true);
 	wpas.add_iface(iface.config);
 	iface.running = true;
 }
@@ -261,7 +262,6 @@
 	let status = iface.status();
 	let msg = { phy: phy };
 
-	wpas.printf(`ucode: mtk: wpa_s in state ${state} notifies hostapd`);
 	switch (state) {
 	case "DISCONNECTED":
 	case "AUTHENTICATING":
@@ -276,8 +276,6 @@
 		msg.up = true;
 		msg.frequency = status.frequency;
 		msg.sec_chan_offset = status.sec_chan_offset;
-		msg.ch_width = status.ch_width;
-		msg.bw320_offset = status.bw320_offset;
 		break;
 	default:
 		return;
@@ -294,8 +292,6 @@
 		csa: true,
 		csa_count: info.csa_count ? info.csa_count - 1 : 0,
 		frequency: info.frequency,
-		ch_width: info.ch_width,
-		bw320_offset: info.bw320_offset,
 		sec_chan_offset: info.sec_chan_offset,
 	};
 	ubus.call("hostapd", "apsta_state", msg);
@@ -321,6 +317,23 @@
 		}
 
 		iface_hostapd_notify(phy, ifname, iface, state);
+
+		if (state != "COMPLETED")
+			return;
+
+		let phy_data = wpas.data.config[phy];
+		if (!phy_data)
+			return;
+
+		let iface_data = phy_data.data[ifname];
+		if (!iface_data)
+			return;
+
+		let wdev_config = iface_data.config;
+		if (!wdev_config || wdev_config.mode != "mesh")
+			return;
+
+		wdev_set_mesh_params(ifname, wdev_config);
 	},
 	event: function(ifname, iface, ev, info) {
 		let phy = wpas.data.iface_phy[ifname];