[][MAC80211][wifi7][hostapd][Bandwidth Synchronization in AP/STA Mode]

[Description]
Add support for bandwidth synchronization in AP/STA mode after the ucode
re-implementation.
After association, Extender STA provides more infomation with Extender
AP so that it can use the same channel/bandwidth as Root AP.
Note that the PHY mode is still NOT synchronized.

[Release-log]
N/A

Change-Id: I5f54e4e9a6cdd54a8bc2f19907e54f3f75e243dd
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7957827
diff --git a/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/network/services/hostapd/patches/mtk-1003-hostapd-mtk-synchronize-bandwidth-in-AP-STA-support.patch b/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/network/services/hostapd/patches/mtk-1003-hostapd-mtk-synchronize-bandwidth-in-AP-STA-support.patch
new file mode 100644
index 0000000..74c685b
--- /dev/null
+++ b/autobuild_mac80211_release/mt7988_mt7996_mac80211/package/network/services/hostapd/patches/mtk-1003-hostapd-mtk-synchronize-bandwidth-in-AP-STA-support.patch
@@ -0,0 +1,61 @@
+From 25b1c0f5e4f674ea2b72949bce83c05204d19653 Mon Sep 17 00:00:00 2001
+From: Michael-CY Lee <michael-cy.lee@mediatek.com>
+Date: Thu, 24 Aug 2023 16:44:30 +0800
+Subject: [PATCH] hostapd: mtk: synchronize bandwidth in AP/STA support
+
+Signed-off-by: Michael Lee <michael-cy.lee@mediatek.com>
+---
+ src/utils/ucode.c      |  1 +
+ wpa_supplicant/ucode.c | 10 ++++++++++
+ 2 files changed, 11 insertions(+)
+
+diff --git a/src/utils/ucode.c b/src/utils/ucode.c
+index 44169f0..41c19fb 100644
+--- a/src/utils/ucode.c
++++ b/src/utils/ucode.c
+@@ -115,6 +115,7 @@ uc_value_t *uc_wpa_freq_info(uc_vm_t *vm, size_t nargs)
+ 	ucv_object_add(ret, "hw_mode_str", ucv_get(ucv_string_new(modestr)));
+ 	ucv_object_add(ret, "sec_channel", ucv_int64_new(sec_channel));
+ 	ucv_object_add(ret, "frequency", ucv_int64_new(freq_val));
++	ucv_object_add(ret, "oper_chwidth", ucv_int64_new(chanwidth));
+ 
+ 	if (!sec_channel)
+ 		return ret;
+diff --git a/wpa_supplicant/ucode.c b/wpa_supplicant/ucode.c
+index d0a78d1..dbf57fa 100644
+--- a/wpa_supplicant/ucode.c
++++ b/wpa_supplicant/ucode.c
+@@ -6,6 +6,7 @@
+ #include "wps_supplicant.h"
+ #include "bss.h"
+ #include "ucode.h"
++#include "driver_i.h"
+ 
+ static struct wpa_global *wpa_global;
+ static uc_resource_type_t *global_type, *iface_type;
+@@ -194,6 +195,9 @@ uc_wpas_iface_status(uc_vm_t *vm, size_t nargs)
+ 	struct wpa_supplicant *wpa_s = uc_fn_thisval("wpas.iface");
+ 	struct wpa_bss *bss;
+ 	uc_value_t *ret, *val;
++	struct wpa_channel_info ci;
++	u8 op_class, channel;
++	enum oper_chan_width ch_width;
+ 
+ 	if (!wpa_s)
+ 		return NULL;
+@@ -222,6 +226,12 @@ uc_wpas_iface_status(uc_vm_t *vm, size_t nargs)
+ 
+ 		ucv_object_add(ret, "sec_chan_offset", ucv_int64_new(sec_chan));
+ 		ucv_object_add(ret, "frequency", ucv_int64_new(bss->freq));
++
++		wpa_drv_channel_info(wpa_s, &ci);
++		ieee80211_chaninfo_to_channel(ci.frequency, ci.chanwidth,
++					      sec_chan, &op_class, &channel);
++		ch_width = op_class_to_ch_width(op_class);
++		ucv_object_add(ret, "ch_width", ucv_int64_new(ch_width));
+ 	}
+ 
+ 	return ret;
+-- 
+2.25.1
+
diff --git a/autobuild_mac80211_release/openwrt_patches-21.02/hostapd/0002-hostapd-ucode-mtk-synchronize-bandwidt.patch b/autobuild_mac80211_release/openwrt_patches-21.02/hostapd/0002-hostapd-ucode-mtk-synchronize-bandwidt.patch
new file mode 100644
index 0000000..2a7a690
--- /dev/null
+++ b/autobuild_mac80211_release/openwrt_patches-21.02/hostapd/0002-hostapd-ucode-mtk-synchronize-bandwidt.patch
@@ -0,0 +1,32 @@
+diff --git a/package/network/services/hostapd/files/hostapd.uc b/package/network/services/hostapd/files/hostapd.uc
+index 43637ac..feba364 100644
+--- a/package/network/services/hostapd/files/hostapd.uc
++++ b/package/network/services/hostapd/files/hostapd.uc
+@@ -84,6 +84,7 @@ function iface_freq_info(iface, config, params)
+ 	if (freq < 4000)
+ 		width = 0;
+ 
++	width = req.args.ch_width;
+ 	return hostapd.freq_info(freq, sec_offset, width);
+ }
+ 
+@@ -386,6 +387,7 @@ let main_obj = {
+ 			up: true,
+ 			frequency: 0,
+ 			sec_chan_offset: 0,
++			ch_width: 0,
+ 			csa: true,
+ 			csa_count: 0,
+ 		},
+diff --git a/package/network/services/hostapd/files/wpa_supplicant.uc b/package/network/services/hostapd/files/wpa_supplicant.uc
+index f8a3fcb..45ddbb7 100644
+--- a/package/network/services/hostapd/files/wpa_supplicant.uc
++++ b/package/network/services/hostapd/files/wpa_supplicant.uc
+@@ -240,6 +240,7 @@ function iface_hostapd_notify(phy, ifname, iface, state)
+ 		msg.up = true;
+ 		msg.frequency = status.frequency;
+ 		msg.sec_chan_offset = status.sec_chan_offset;
++		msg.ch_width = status.ch_width;
+ 		break;
+ 	default:
+ 		return;