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

[Description]
d34487c3 [MAC80211][WiFi6][mt76][Add mt7981 mt7916 mt7915 fw_wm_info support]
327eaf76 [MAC80211][wifi7][Release][Update WiFi7 Filogic680/660 Firmware]
fa03d7ea [MAC80211][WiFi6][hostapd][Fix 2/6G channel switch fail issue]
c0bf67d9 [MAC80211][misc][Add Filogic 880 Non-MLO SDK Release]
e5d03217 [MAC80211][WiFi6][Rebase Patches][Refactor set_offchan_ctrl]
6cad79ae [MAC80211][WiFi6][hostapd][Add support for DFS channel switch with CSA sent]
cde50012 [MAC80211][WiFi6][core][Add DFS channel CSA flow]
0142fd16 [MAC80211][WiFi6][mt76][Add post channel switch callback for DFS channel switch support]
cb3f4c58 [MAC80211][WiFi6][mt76][Update Connac2 CSI Feature]
1b66ac4c [MAC80211][WiFi6][mt76][Refactor precal loading and binfile mode to align upstream]
0ece467b [MAC80211][WiFi6][mt76][Fix scs feature calltrace issue]
1dca03f1 [MAC80211][WiFi6/7][Misc][Change group mgmt cipher setting to align group cipher]
0aa52762 [MAC80211][WiFi6][mt76][Fix muru_onoff as all enabled by default]
c3e5f505 [MAC80211][WiFi6][hostapd][Fix mu_onoff was overwritten with unexpected values]
7090eabe [MAC80211][WiFi6/7][core][Add tx_burst option in wireless configuration file for Kite]
669d3071 [MAC80211][WiFi6][mt76][rebase patches]
c5d6b3e7 [mac80211][mt76][Fix patch fail]
55ef4059 [MAC80211][WiFi6][mt76][Fix TxS ACK is incorrectly reported]
e166eae1 [MAC80211][WiFi6][Misc][Add Filogic 820 Build]
118ffd7e [mac80211][wifi6][mt76][Fix crash caused by per-BSS counter updating]
68015098 [MAC80211][WiFi7][mt76][Add Eagle 2adie TBTC default bin]
eae6e8c0 [MAC80211][WiFi7][mt76][Add Eagle 2adie TBTC support in mt76 Makefile]
cccc8eb9 [MAC80211[WiFi6][hostapd][Fix wds AP interface adding issue]
173fe3b0 [MAC80211][WiFi6][mt76][Add scs feature for connac2 mt76]
1b8af8d9 [MAC80211][WiFi6][mt76][rebase patches]
6dc40325 [MAC80211][WiFi7][misc][fix hostapd udebug init fail]
aa4b39ae [[mt76][csi][mt7915][mt7986] update csi feature]
7d458da2 [MAC80211][WiFi6][hostapd][Auto Channel Selection channel time issue]
f0b5502f [MAC80211][WiFi7][misc][fix build error]
b63c9cf6 [MAC80211][WiFi6/7][misc][fix ucode and backport 6.5 patch fail]
ce056dc7 [mac80211][wifi6][mt76][Add variant support for Cheetah MT76]
c5ae3f9c [MAC80211][WiFi6/7][Misc][Add country setting consistent check before enable AP.]
d57d9c5a [mac80211][misc][wifi6/7][Update libubox to the latest version]
be7dbf21 [mac80211][misc][wifi7][Revert libubox to 20230523 to prevent build fail]
ae9b4428 [MAC80211][WiFi6][mt76][Add cal free data support]
52fd5d80 [MAC80211][WiFi7][Misc][Adjust MU EDCA timer in mac80211.sh]
66c649de [mac80211][hostapd][netifd][Revert udebug for build pass]
136c7f11 [MAC80211][hostapd][wifi7][Fix build fail]
8911e727 [MAC80211][WiFi6][hostapd][Auto Channel Selection issue and patch sync]
75161456 [MAC80211][WiFi7][mt76][Fix issue for testmode bit in eagle defaut bin]
4dc2d646 [MAC80211][WiFi6][mt76][Fix cheetah 5G ibf issue]
d4561158 [MAC80211][WiFi6][Misc][Add Filogic 820 Build]
2e5a1997 [MAC80211][WiFi6][hostapd][Backport hostapd ACS patches and some ACS fixes]
b0305b6e [MAC80211][WiFi6/7][Misc][Add 6g band default enable mbo IE]

[Release-log]

Change-Id: I872b422c1fc56ebd3a1cff3252cb403a2015eabe
diff --git a/recipes-wifi/hostapd/files/patches-2.10.3/mtk-0041-mtk-hostapd-refactor-the-flow-to-create-Wide-Bandwid.patch b/recipes-wifi/hostapd/files/patches-2.10.3/mtk-0041-mtk-hostapd-refactor-the-flow-to-create-Wide-Bandwid.patch
new file mode 100644
index 0000000..d1e24d5
--- /dev/null
+++ b/recipes-wifi/hostapd/files/patches-2.10.3/mtk-0041-mtk-hostapd-refactor-the-flow-to-create-Wide-Bandwid.patch
@@ -0,0 +1,168 @@
+From 5daee94e29d5d7a3db5b8c8f03b15aa4a914f85f Mon Sep 17 00:00:00 2001
+From: Michael-CY Lee <michael-cy.lee@mediatek.com>
+Date: Thu, 24 Aug 2023 10:04:15 +0800
+Subject: [PATCH 41/54] mtk: hostapd: refactor the flow to create Wide
+ Bandwidth Channel Switch IE
+
+This patch changes the flow to create Wide Bandwidth Channel Switch IE:
+1. 2 GHz: Wide Bandwidth Channel Switch IE should not present.
+2. 5 GHz: fill the subfields according to VHT operation.
+3. 6 GHz: fill the subfields according to VHT operation and HE operation
+   in HE mode and EHT mode, respectively.
+   This is because the definition of the subfields of Wide Bandwidth
+   Channel Switch IE is ambiguous:
+   1. 802.11ac: the definition of subfields follows VHT operation
+      (IEEE80211-2020 9.4.2.160)
+   2. 802.11ax: the definition of subfields is not specified
+   3. 802.11be: the definition of subfields follows VHT operation in 5
+      GHz and HE operation in 6 GHz (IEEE P802.11be D3.2 9.4.2.159)
+
+To support 320 MHz
+   channel switch, set width to 4
+
+Signed-off-by: Michael-CY Lee <michael-cy.lee@mediatek.com>
+---
+ src/ap/ieee802_11.c | 99 ++++++++++++++++++++++++++++++++++-----------
+ 1 file changed, 76 insertions(+), 23 deletions(-)
+
+diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
+index 38fce3e82..d46c5a42b 100644
+--- a/src/ap/ieee802_11.c
++++ b/src/ap/ieee802_11.c
+@@ -7083,57 +7083,110 @@ u8 * hostapd_eid_txpower_envelope(struct hostapd_data *hapd, u8 *eid)
+ 
+ u8 * hostapd_eid_wb_chsw_wrapper(struct hostapd_data *hapd, u8 *eid)
+ {
+-	u8 bw, chan1, chan2 = 0;
+-	int freq1;
++	u8 new_bw_field, ccfs0_chan, ccfs1_chan = 0;
++	int ccfs0_freq = 0, ccfs1_freq = 0;
++	int control_freq, center_freq1, center_freq2, bandwidth;
++	int base_freq, offset;
++	bool is_6ghz, use_he_oper;
+ 
+ 	if (!hapd->cs_freq_params.channel ||
++	    hapd->cs_freq_params.bandwidth == 20 ||
+ 	    (!hapd->cs_freq_params.vht_enabled &&
+ 	     !hapd->cs_freq_params.he_enabled &&
+ 	     !hapd->cs_freq_params.eht_enabled))
+ 		return eid;
+ 
+-	/* bandwidth: 0: 40, 1: 80, 2: 160, 3: 80+80, 4: 320 */
+-	switch (hapd->cs_freq_params.bandwidth) {
++	control_freq = hapd->cs_freq_params.freq;
++	center_freq1 = hapd->cs_freq_params.center_freq1;
++	center_freq2 = hapd->cs_freq_params.center_freq2;
++	bandwidth = hapd->cs_freq_params.bandwidth;
++
++	/* center_freq2 is used if and only if bandwidth is
++	 * 80+80 MHz and phy mode is not EHT
++	 */
++	if (center_freq2 &&
++	    (bandwidth != 80 || hapd->cs_freq_params.eht_enabled))
++		return eid;
++
++	is_6ghz = is_6ghz_freq(control_freq);
++	use_he_oper = is_6ghz && hapd->cs_freq_params.eht_enabled;
++	base_freq = is_6ghz ? 5955 : 5180;
++
++	/* About the subfields of the Wide Bandwidth Channel Switch IE,
++	 * IEEE802.11-2020 9.4.2.160 specifies that the subfields New
++	 * Channel Width, New Channel Center Frequency Segment 0 and New
++	 * Channel Center Frequency Segment 1 have the same definition as
++	 * they are in the VHT operation information field.
++	 * However, the standard does not specify the definition of these
++	 * subfields when it comes to HE phy-mode in 6 GHz.
++	 * And in IEEE P802.11be D3.2 9.4.2.159, it specifies that the
++	 * defition should follow VHT operation in 5 GHz, and follow HE
++	 * oepration in 6 GHz.
++	 * Problem happens here for some HE STAs in 6 GHz, they might still
++	 * use VHT operation to parse these subfields.
++	 *
++	 * Here we follow the new Standard to build the IE, meanwhile we have
++	 * a workaround for HE mode in 6 GHz.
++	 *
++	 * 5 GHz: VHT operation
++	 * HE mode in 6 GHz: VHT operation
++	 * EHT mode in 6 GHz: HE operation
++	 */
++	ccfs0_freq = center_freq1;
++	ccfs1_freq = center_freq2;
++	switch (bandwidth) {
+ 	case 40:
+-		bw = 0;
++		new_bw_field = use_he_oper ? 1 : 0;
+ 		break;
+ 	case 80:
+-		/* check if it's 80+80 */
+-		if (!hapd->cs_freq_params.center_freq2)
+-			bw = 1;
++		if (ccfs1_freq)
++			new_bw_field = use_he_oper ? 3 : 1;
+ 		else
+-			bw = 3;
++			new_bw_field = use_he_oper ? 2 : 1;
+ 		break;
+ 	case 160:
+-		bw = 2;
++		new_bw_field = use_he_oper ? 3 : 1;
++
++		/* ccfs0 is primary 80 MHz
++		 * ccfs1 is center frequency
++		 */
++		offset = (control_freq - base_freq) / 20;
++		ccfs0_freq = control_freq + 30 - (offset & 3) * 20;
++		ccfs1_freq = center_freq1;
+ 		break;
+ 	case 320:
+-		bw = 4;
++		/* TODO switch to bandwidth 320 MHz should be
++		 * indicated by Bandwidth indication IE.
++		 */
++		new_bw_field = 4;
++
++		/* ccfs0 is primary 160 MHz
++		 * ccfs1 is center frequency
++		 */
++		offset = (control_freq - base_freq) / 20;
++		ccfs0_freq = control_freq + 70 - (offset & 7) * 20;
++		ccfs1_freq = center_freq1;
+ 		break;
+ 	default:
+-		/* not valid VHT bandwidth or not in CSA */
++		/* not a valid VHT/HE bandwidth or not in CSA */
+ 		return eid;
+ 	}
+ 
+-	freq1 = hapd->cs_freq_params.center_freq1 ?
+-		hapd->cs_freq_params.center_freq1 :
+-		hapd->cs_freq_params.freq;
+-	if (ieee80211_freq_to_chan(freq1, &chan1) !=
+-	    HOSTAPD_MODE_IEEE80211A)
++	if (ieee80211_freq_to_chan(ccfs0_freq, &ccfs0_chan) !=
++			HOSTAPD_MODE_IEEE80211A)
+ 		return eid;
+ 
+-	if (hapd->cs_freq_params.center_freq2 &&
+-	    ieee80211_freq_to_chan(hapd->cs_freq_params.center_freq2,
+-				   &chan2) != HOSTAPD_MODE_IEEE80211A)
++	if (ccfs1_freq && ieee80211_freq_to_chan(ccfs1_freq, &ccfs1_chan) !=
++			HOSTAPD_MODE_IEEE80211A)
+ 		return eid;
+ 
+ 	*eid++ = WLAN_EID_CHANNEL_SWITCH_WRAPPER;
+ 	*eid++ = 5; /* Length of Channel Switch Wrapper */
+ 	*eid++ = WLAN_EID_WIDE_BW_CHSWITCH;
+ 	*eid++ = 3; /* Length of Wide Bandwidth Channel Switch element */
+-	*eid++ = bw; /* New Channel Width */
+-	*eid++ = chan1; /* New Channel Center Frequency Segment 0 */
+-	*eid++ = chan2; /* New Channel Center Frequency Segment 1 */
++	*eid++ = new_bw_field; /* New Channel Width */
++	*eid++ = ccfs0_chan; /* New Channel Center Frequency Segment 0 */
++	*eid++ = ccfs1_chan; /* New Channel Center Frequency Segment 1 */
+ 
+ 	return eid;
+ }
+-- 
+2.18.0
+