[][MAC80211][hostapd][Avoid color switch when beacon is not set]

[Description]
Fix the beacon set failure caused by a color switch during AP CAC.

After an AP interface is disabled then enabled by hostapd_cli, when it
is doing CAC, a color collision event might happen and then trigger a
color change request.
A color change request leads to a beacon asignment in MAC80211, which
hostapd is not aware of.
After the CAC, hsotapd tries to set beacon but gets a -EINVAL since the
beacon is already set in MAC80211.

This patch avoids a color switch diring AP CAC.

[Release-log]
N/A

Change-Id: I3c9f030abd540598ff4b61e2ab6eff506ff056d5
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7958049
diff --git a/autobuild_mac80211_release/package/network/services/hostapd/patches/mtk-0039-hostapd-mtk-avoid-color-switch-when-beacon-is-not-se.patch b/autobuild_mac80211_release/package/network/services/hostapd/patches/mtk-0039-hostapd-mtk-avoid-color-switch-when-beacon-is-not-se.patch
new file mode 100755
index 0000000..2883c1f
--- /dev/null
+++ b/autobuild_mac80211_release/package/network/services/hostapd/patches/mtk-0039-hostapd-mtk-avoid-color-switch-when-beacon-is-not-se.patch
@@ -0,0 +1,28 @@
+From 33117ec15f94315f7671cfdaf47e8d5eeddee4ae Mon Sep 17 00:00:00 2001
+From: MeiChia Chiu <meichia.chiu@mediatek.com>
+Date: Fri, 1 Sep 2023 15:20:19 +0800
+Subject: [PATCH] hostapd: mtk: avoid color switch when beacon is not set
+
+Signed-off-by: MeiChia Chiu <meichia.chiu@mediatek.com>
+Signed-off-by: Michael-CY Lee <michael-cy.lee@mediatek.com>
+---
+ src/ap/hostapd.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
+index abc6156..f2eb638 100644
+--- a/src/ap/hostapd.c
++++ b/src/ap/hostapd.c
+@@ -4024,7 +4024,8 @@ void hostapd_switch_color(struct hostapd_data *hapd, u64 bitmap)
+ {
+ 	struct os_reltime now;
+ 
+-	if (hapd->cca_in_progress || hapd->stopped_by_supplicant)
++	if (hapd->cca_in_progress || hapd->stopped_by_supplicant ||
++	    !hapd->beacon_set_done)
+ 		return;
+ 
+ 	if (os_get_reltime(&now))
+-- 
+2.39.0
+
diff --git a/autobuild_mac80211_release/package/network/services/hostapd_new/patches/mtk-0042-hostapd-mtk-avoid-color-switch-when-beacon-is-not-se.patch b/autobuild_mac80211_release/package/network/services/hostapd_new/patches/mtk-0042-hostapd-mtk-avoid-color-switch-when-beacon-is-not-se.patch
new file mode 100644
index 0000000..1beb25c
--- /dev/null
+++ b/autobuild_mac80211_release/package/network/services/hostapd_new/patches/mtk-0042-hostapd-mtk-avoid-color-switch-when-beacon-is-not-se.patch
@@ -0,0 +1,27 @@
+From 4b81632a07367f9664158b52364caa3e1b522607 Mon Sep 17 00:00:00 2001
+From: Michael-CY Lee <michael-cy.lee@mediatek.com>
+Date: Fri, 1 Sep 2023 15:31:24 +0800
+Subject: [PATCH] hostapd: mtk: avoid color switch when beacon is not set
+
+Signed-off-by: Michael-CY Lee <michael-cy.lee@mediatek.com>
+---
+ src/ap/hostapd.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
+index 4b7ebc5..97b4a59 100644
+--- a/src/ap/hostapd.c
++++ b/src/ap/hostapd.c
+@@ -4299,7 +4299,8 @@ void hostapd_switch_color(struct hostapd_data *hapd, u64 bitmap)
+ {
+ 	struct os_reltime now;
+ 
+-	if (hapd->cca_in_progress || hapd->stopped_by_supplicant)
++	if (hapd->cca_in_progress || hapd->stopped_by_supplicant ||
++	    !hapd->beacon_set_done)
+ 		return;
+ 
+ 	if (os_get_reltime(&now))
+-- 
+2.25.1
+