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

[Description]
8b4a500 [MAC80211][hostapd][Fix CCA issue]
9d560e7 [MAC80211][hostapd][Fix -EALREADY in setting beacon]
be5cabf [MAC80211][misc][Rebase hostapd Makefile patch]
5719a22 [MAC80211][mt76][remove mt7915 BW160 support]
1233fab [mac80211][mt76][update mpdu density setting]
6b97089 [MAC80211][misc][noscan in 2.4G/5G by default]
93f732f [MAC80211][mt76][rebase patch]
d36d021 [MAC80211][mt76][enhance coredump function]
420b283 [mac80211][misc][Fix hostapd script to add wds interface to bridge]

[Release-log]

Change-Id: Ibfc1a98b2a6f06a10227716bcc2ff65e17b0581e
diff --git a/recipes-wifi/hostapd/files/patches/mtk-0031-hostapd-mtk-Fix-CCA-issue.patch b/recipes-wifi/hostapd/files/patches/mtk-0031-hostapd-mtk-Fix-CCA-issue.patch
new file mode 100644
index 0000000..35a0b4d
--- /dev/null
+++ b/recipes-wifi/hostapd/files/patches/mtk-0031-hostapd-mtk-Fix-CCA-issue.patch
@@ -0,0 +1,97 @@
+From 7bd78e612a73df62599a3826eafd49fbc4138d10 Mon Sep 17 00:00:00 2001
+From: Michael Lee <michael-cy.lee@mediatek.com>
+Date: Wed, 3 May 2023 14:55:18 +0800
+Subject: [PATCH] hostapd: mtk: Fix CCA issue
+
+When receiving CCA-related nl80211 commands, hostapd used to work on
+struct wpa_driver_nl80211_data, whose ctx always points to
+hostpad_iface->bss[0]. However, CCA commands are sent on a per-BSS based.
+This patch makes hostapd handle CCA-related commands on a per-BSS based.
+
+Signed-off-by: Michael Lee <michael-cy.lee@mediatek.com>
+---
+ src/drivers/driver_nl80211_event.c | 24 ++++++++++++------------
+ 1 file changed, 12 insertions(+), 12 deletions(-)
+
+diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c
+index ee922ac..585d207 100644
+--- a/src/drivers/driver_nl80211_event.c
++++ b/src/drivers/driver_nl80211_event.c
+@@ -2930,7 +2930,7 @@ static void nl80211_assoc_comeback(struct wpa_driver_nl80211_data *drv,
+ 
+ #ifdef CONFIG_IEEE80211AX
+ 
+-static void nl80211_obss_color_collision(struct wpa_driver_nl80211_data *drv,
++static void nl80211_obss_color_collision(struct i802_bss *bss,
+ 					 struct nlattr *tb[])
+ {
+ 	union wpa_event_data data;
+@@ -2944,37 +2944,37 @@ static void nl80211_obss_color_collision(struct wpa_driver_nl80211_data *drv,
+ 
+ 	wpa_printf(MSG_DEBUG, "nl80211: BSS color collision - bitmap %08lx",
+ 		   data.bss_color_collision.bitmap);
+-	wpa_supplicant_event(drv->ctx, EVENT_BSS_COLOR_COLLISION, &data);
++	wpa_supplicant_event(bss->ctx, EVENT_BSS_COLOR_COLLISION, &data);
+ }
+ 
+ 
+ static void
+-nl80211_color_change_announcement_started(struct wpa_driver_nl80211_data *drv)
++nl80211_color_change_announcement_started(struct i802_bss *bss)
+ {
+ 	union wpa_event_data data = {};
+ 
+ 	wpa_printf(MSG_DEBUG, "nl80211: CCA started");
+-	wpa_supplicant_event(drv->ctx, EVENT_CCA_STARTED_NOTIFY, &data);
++	wpa_supplicant_event(bss->ctx, EVENT_CCA_STARTED_NOTIFY, &data);
+ }
+ 
+ 
+ static void
+-nl80211_color_change_announcement_aborted(struct wpa_driver_nl80211_data *drv)
++nl80211_color_change_announcement_aborted(struct i802_bss *bss)
+ {
+ 	union wpa_event_data data = {};
+ 
+ 	wpa_printf(MSG_DEBUG, "nl80211: CCA aborted");
+-	wpa_supplicant_event(drv->ctx, EVENT_CCA_ABORTED_NOTIFY, &data);
++	wpa_supplicant_event(bss->ctx, EVENT_CCA_ABORTED_NOTIFY, &data);
+ }
+ 
+ 
+ static void
+-nl80211_color_change_announcement_completed(struct wpa_driver_nl80211_data *drv)
++nl80211_color_change_announcement_completed(struct i802_bss *bss)
+ {
+ 	union wpa_event_data data = {};
+ 
+ 	wpa_printf(MSG_DEBUG, "nl80211: CCA completed");
+-	wpa_supplicant_event(drv->ctx, EVENT_CCA_NOTIFY, &data);
++	wpa_supplicant_event(bss->ctx, EVENT_CCA_NOTIFY, &data);
+ }
+ 
+ #endif /* CONFIG_IEEE80211AX */
+@@ -3230,16 +3230,16 @@ static void do_process_drv_event(struct i802_bss *bss, int cmd,
+ 		break;
+ #ifdef CONFIG_IEEE80211AX
+ 	case NL80211_CMD_OBSS_COLOR_COLLISION:
+-		nl80211_obss_color_collision(drv, tb);
++		nl80211_obss_color_collision(bss, tb);
+ 		break;
+ 	case NL80211_CMD_COLOR_CHANGE_STARTED:
+-		nl80211_color_change_announcement_started(drv);
++		nl80211_color_change_announcement_started(bss);
+ 		break;
+ 	case NL80211_CMD_COLOR_CHANGE_ABORTED:
+-		nl80211_color_change_announcement_aborted(drv);
++		nl80211_color_change_announcement_aborted(bss);
+ 		break;
+ 	case NL80211_CMD_COLOR_CHANGE_COMPLETED:
+-		nl80211_color_change_announcement_completed(drv);
++		nl80211_color_change_announcement_completed(bss);
+ 		break;
+ #endif /* CONFIG_IEEE80211AX */
+ 	default:
+-- 
+2.25.1
+
diff --git a/recipes-wifi/hostapd/files/patches/mtk-0032-hostapd-mtk-Fix-unexpected-AP-beacon-state-transitio.patch b/recipes-wifi/hostapd/files/patches/mtk-0032-hostapd-mtk-Fix-unexpected-AP-beacon-state-transitio.patch
new file mode 100644
index 0000000..d3c7b26
--- /dev/null
+++ b/recipes-wifi/hostapd/files/patches/mtk-0032-hostapd-mtk-Fix-unexpected-AP-beacon-state-transitio.patch
@@ -0,0 +1,36 @@
+From f5e235b80b57583caf590c3745022327493675a6 Mon Sep 17 00:00:00 2001
+From: Michael Lee <michael-cy.lee@mediatek.com>
+Date: Wed, 3 May 2023 16:10:57 +0800
+Subject: [PATCH] hostapd: mtk: Fix unexpected AP beacon state transition
+
+When AP fails to set the beacon, it assigns bss->beacon_set to 0 no
+matter what the error number is.
+However, in the case that the error number is -EBUSY, the driver might
+not free the beacon and expect a later beacon re-setting. If hostapd set
+a new beacon under this case, the driver will return -EALREADY.
+This patch checks the error number after hostapd fails to set the
+beacon. If the error number is -EBUSY, bss->beacon_set will not be
+assigned to 0.
+
+Signed-off-by: Michael Lee <michael-cy.lee@mediatek.com>
+---
+ src/drivers/driver_nl80211.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
+index 945ce3e..89c7d20 100644
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -4912,7 +4912,8 @@ static int wpa_driver_nl80211_set_ap(void *priv,
+ 			   ret, strerror(-ret));
+ 		if (!bss->beacon_set)
+ 			ret = 0;
+-		bss->beacon_set = 0;
++		if (ret != -EBUSY)
++			bss->beacon_set = 0;
+ 	} else {
+ 		bss->beacon_set = 1;
+ 		nl80211_set_bss(bss, params->cts_protect, params->preamble,
+-- 
+2.25.1
+
diff --git a/recipes-wifi/hostapd/files/patches/patches.inc b/recipes-wifi/hostapd/files/patches/patches.inc
index 13cb2d5..3851812 100644
--- a/recipes-wifi/hostapd/files/patches/patches.inc
+++ b/recipes-wifi/hostapd/files/patches/patches.inc
@@ -93,4 +93,6 @@
     file://mtk-0028-hostapd-mtk-avoid-setting-beacon-after-wpa_supplican.patch \
     file://mtk-0029-hostapd-mtk-Fix-setting-wrong-seg0-index-for-5G-cent.patch \
     file://mtk-0030-hostapd-mtk-Add-muru-user-number-debug-command.patch \
+    file://mtk-0031-hostapd-mtk-Fix-CCA-issue.patch \
+    file://mtk-0032-hostapd-mtk-Fix-unexpected-AP-beacon-state-transitio.patch \
     "