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

[Description]
3a2eef0b [MAC80211][Release][Update release note for Filogic 880/860 MLO Beta release]
cfbd2411 [MAC80211][Release][Filogic 880/860 MLO Beta release]
6c180e3f [MAC80211][WiFi7][misc][Add Eagle BE14000 efem default bin]
a55f34db [MAC80211][Release][Prepare for Filogic 880/860 release]
5b45ebca [MAC80211][WiFi7][hostapd][Add puncture bitmap to ucode]
95bbea73 [MAC80211][WiFi6][mt76][Add PID to only report data-frame TX rate]
b15ced26 [MAC80211][WiFi6][hostapd][Fix DFS channel selection issue]
d59133cb [MAC80211][WiFi6][mt76][Fix pse info not correct information]
3921b4b2 [MAC80211][WiFi6][mt76][Fix incomplete QoS-map setting to FW]
4e7690c7 [MAC80211][WiFi6/7][app][Change ATECHANNEL mapping cmd]
eb37af90 [MAC80211][WiFi7][app][Add support for per-packet bw & primary selection]
0ea82adf [MAC80211][WiFi6][core][Fix DFS CAC issue after CSA]

[Release-log]

Change-Id: I9bec97ec1b2e1c49ed43a812a07a5b21fcbb70a6
diff --git a/recipes-wifi/hostapd/files/patches-2.10.3/0053-mtk-hostapd-add-zwdfs-mode-ctrl-for-eagle-efem.patch b/recipes-wifi/hostapd/files/patches-2.10.3/0053-mtk-hostapd-add-zwdfs-mode-ctrl-for-eagle-efem.patch
new file mode 100644
index 0000000..5c5547a
--- /dev/null
+++ b/recipes-wifi/hostapd/files/patches-2.10.3/0053-mtk-hostapd-add-zwdfs-mode-ctrl-for-eagle-efem.patch
@@ -0,0 +1,290 @@
+From fe8560c4ccea682bb471816a1e5200ef7f3cde60 Mon Sep 17 00:00:00 2001
+From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+Date: Wed, 2 Aug 2023 19:00:34 +0800
+Subject: [PATCH 053/126] mtk: hostapd: add zwdfs mode ctrl for eagle efem
+
+Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
+---
+ hostapd/config_file.c             |  2 ++
+ hostapd/ctrl_iface.c              | 30 +++++++++++++++++++++++++++
+ src/ap/ap_config.h                |  6 ++++++
+ src/ap/ap_drv_ops.c               | 14 +++++++++++++
+ src/ap/ap_drv_ops.h               |  1 +
+ src/ap/dfs.c                      |  6 ++++++
+ src/common/mtk_vendor.h           | 12 +++++++++++
+ src/drivers/driver.h              |  7 +++++++
+ src/drivers/driver_nl80211.c      | 34 +++++++++++++++++++++++++++++++
+ src/drivers/driver_nl80211.h      |  1 +
+ src/drivers/driver_nl80211_capa.c |  3 +++
+ 11 files changed, 116 insertions(+)
+
+diff --git a/hostapd/config_file.c b/hostapd/config_file.c
+index dc05738db..b941ec5fa 100644
+--- a/hostapd/config_file.c
++++ b/hostapd/config_file.c
+@@ -3662,6 +3662,8 @@ static int hostapd_config_fill(struct hostapd_config *conf,
+ 		conf->acs_exclude_6ghz_non_psc = atoi(pos);
+ 	} else if (os_strcmp(buf, "enable_background_radar") == 0) {
+ 		conf->enable_background_radar = atoi(pos);
++	} else if (os_strcmp(buf, "background_radar_mode") == 0) {
++		conf->background_radar_mode = atoi(pos);
+ 	} else if (os_strcmp(buf, "min_tx_power") == 0) {
+ 		int val = atoi(pos);
+ 
+diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
+index 53924b265..61d69902d 100644
+--- a/hostapd/ctrl_iface.c
++++ b/hostapd/ctrl_iface.c
+@@ -4919,6 +4919,33 @@ hostapd_ctrl_iface_dump_amnt(struct hostapd_data *hapd, char *cmd,
+ 		return pos - buf;
+ }
+ 
++static int
++hostapd_ctrl_iface_set_background_radar_mode(struct hostapd_data *hapd, char *cmd,
++					     char *buf, size_t buflen)
++{
++	struct hostapd_iface *iface = hapd->iface;
++	char *pos, *param;
++
++	param = os_strchr(cmd, ' ');
++	if (!param)
++		return -1;
++	*param++ = '\0';
++
++	pos = os_strstr(param, "mode=");
++	if (!pos)
++		return -1;
++
++	if (os_strncmp(pos + 5, "cert", 4) == 0)
++		iface->conf->background_radar_mode = BACKGROUND_RADAR_CERT_MODE;
++	else if (os_strncmp(pos + 5, "normal", 6) == 0)
++		iface->conf->background_radar_mode = BACKGROUND_RADAR_NORMAL_MODE;
++
++	if (hostapd_drv_background_radar_mode(hapd) < 0)
++		return -1;
++
++	return os_snprintf(buf, buflen, "OK\n");
++}
++
+ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
+ 					      char *buf, char *reply,
+ 					      int reply_size,
+@@ -5568,6 +5595,9 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
+ 		if (pos)
+ 			*pos = ' ';
+ 		reply_len = hostapd_ctrl_iface_set_mu(hapd, buf + 23, reply, reply_size);
++	} else if (os_strncmp(buf, "SET_BACKGROUND_RADAR_MODE", 25) == 0) {
++		reply_len = hostapd_ctrl_iface_set_background_radar_mode(hapd, buf + 25,
++									 reply, reply_size);
+ 	} else {
+ 		os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
+ 		reply_len = 16;
+diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
+index 0c51d2ab9..cffde344f 100644
+--- a/src/ap/ap_config.h
++++ b/src/ap/ap_config.h
+@@ -1101,6 +1101,7 @@ struct hostapd_config {
+ 	bool hw_mode_set;
+ 	int acs_exclude_6ghz_non_psc;
+ 	int enable_background_radar;
++	int background_radar_mode;
+ 	enum {
+ 		LONG_PREAMBLE = 0,
+ 		SHORT_PREAMBLE = 1
+@@ -1359,6 +1360,11 @@ enum three_wire_mode {
+ 		NUM_THREE_WIRE_MODE - 1
+ };
+ 
++enum background_radar_mode {
++	BACKGROUND_RADAR_NORMAL_MODE,
++	BACKGROUND_RADAR_CERT_MODE,
++};
++
+ enum dfs_mode {
+ 	DFS_DETECT_MODE_DISABLE,
+ 	DFS_DETECT_MODE_AP_ENABLE,
+diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c
+index ccd0cb939..6f8f329b0 100644
+--- a/src/ap/ap_drv_ops.c
++++ b/src/ap/ap_drv_ops.c
+@@ -1401,3 +1401,17 @@ int hostapd_drv_amnt_dump(struct hostapd_data *hapd, u8 amnt_idx, u8 *amnt_dump_
+ 		return 0;
+ 	return hapd->driver->amnt_dump(hapd->drv_priv, amnt_idx, amnt_dump_buf);
+ }
++
++int hostapd_drv_background_radar_mode(struct hostapd_data *hapd)
++{
++	if (!hapd->driver || !hapd->driver->background_radar_mode ||
++	    !(hapd->iface->drv_flags2 & WPA_DRIVER_FLAGS2_RADAR_BACKGROUND) ||
++	    !hapd->iface->conf->enable_background_radar)
++		return 0;
++	if (hapd->iconf->background_radar_mode > BACKGROUND_RADAR_CERT_MODE) {
++		wpa_printf(MSG_INFO, "Invalid value for background radar mode\n");
++		return 0;
++	}
++	return hapd->driver->background_radar_mode(hapd->drv_priv,
++						   hapd->iconf->background_radar_mode);
++}
+diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h
+index 659154f56..53075ea94 100644
+--- a/src/ap/ap_drv_ops.h
++++ b/src/ap/ap_drv_ops.h
+@@ -171,6 +171,7 @@ int hostapd_drv_ap_trig_type(struct hostapd_data *hapd, u8 enable, u8 type);
+ 
+ int hostapd_drv_amnt_set(struct hostapd_data *hapd, u8 amnt_idx, u8 *amnt_sta_mac);
+ int hostapd_drv_amnt_dump(struct hostapd_data *hapd, u8 amnt_idx, u8 *amnt_dump_buf);
++int hostapd_drv_background_radar_mode(struct hostapd_data *hapd);
+ 
+ #include "drivers/driver.h"
+ 
+diff --git a/src/ap/dfs.c b/src/ap/dfs.c
+index 72bb469a6..db26f6536 100644
+--- a/src/ap/dfs.c
++++ b/src/ap/dfs.c
+@@ -986,6 +986,9 @@ int hostapd_handle_dfs(struct hostapd_iface *iface)
+ 		if (res < 0)
+ 			return res;
+ 
++		if (hostapd_drv_background_radar_mode(iface->bss[0]) < 0)
++			return -1;
++
+ 		iface->radar_background.temp_ch = 1;
+ 		return 1;
+ 	} else if (dfs_use_radar_background(iface)) {
+@@ -1026,6 +1029,9 @@ int hostapd_handle_dfs(struct hostapd_iface *iface)
+ 		iface->radar_background.secondary_channel = sec;
+ 		iface->radar_background.centr_freq_seg0_idx = cf1;
+ 		iface->radar_background.centr_freq_seg1_idx = cf2;
++
++		if (hostapd_drv_background_radar_mode(iface->bss[0]) < 0)
++			return -1;
+ 	}
+ 
+ 	return 0;
+diff --git a/src/common/mtk_vendor.h b/src/common/mtk_vendor.h
+index f0abcb6b1..3fb4c38f3 100644
+--- a/src/common/mtk_vendor.h
++++ b/src/common/mtk_vendor.h
+@@ -16,6 +16,7 @@ enum mtk_nl80211_vendor_subcmds {
+ 	MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8,
+ 	MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL = 0xc9,
+ 	MTK_NL80211_VENDOR_SUBCMD_BSS_COLOR_CTRL = 0xca,
++	MTK_NL80211_VENDOR_SUBCMD_BACKGROUND_RADAR_CTRL = 0xcb,
+ };
+ 
+ enum mtk_vendor_attr_edcca_ctrl {
+@@ -247,6 +248,17 @@ enum mtk_vendor_attr_bss_color_ctrl {
+ 		NUM_MTK_VENDOR_ATTRS_BSS_COLOR_CTRL - 1
+ };
+ 
++enum mtk_vendor_attr_background_radar_ctrl {
++	MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_UNSPEC,
++
++	MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_MODE,
++
++	/* keep last */
++	NUM_MTK_VENDOR_ATTRS_BACKGROUND_RADAR_CTRL,
++	MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_MAX =
++		NUM_MTK_VENDOR_ATTRS_BACKGROUND_RADAR_CTRL - 1
++};
++
+ #define CSI_MAX_COUNT 256
+ #define ETH_ALEN 6
+ 
+diff --git a/src/drivers/driver.h b/src/drivers/driver.h
+index 8457f4703..35c02937d 100644
+--- a/src/drivers/driver.h
++++ b/src/drivers/driver.h
+@@ -5346,6 +5346,13 @@ struct wpa_driver_ops {
+ 	* @amnt_dump_buf: Buffer to print
+ 	*/
+ 	int (*amnt_dump)(void *priv, u8 amnt_idx, u8 *amnt_dump_buf);
++
++	/**
++	 * background_radar_mode - set background radar mode
++	 * @priv: Private driver interface data
++	 * @background_radar_mode: background radar mode
++	 */
++	int (*background_radar_mode)(void *priv, u8 background_radar_mode);
+ };
+ 
+ /**
+diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
+index 8a8f8abe8..2d2b47456 100644
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -15080,6 +15080,39 @@ fail:
+ 	return -ENOBUFS;
+ }
+ 
++static int nl80211_background_radar_mode(void *priv, const u8 background_radar_mode)
++{
++	struct i802_bss *bss = priv;
++	struct wpa_driver_nl80211_data *drv = bss->drv;
++	/* Prepare nl80211 cmd */
++	struct nl_msg *msg;
++	struct nlattr *data;
++	int ret;
++
++	if (!drv->mtk_background_radar_vendor_cmd_avail) {
++		wpa_printf(MSG_INFO,
++			   "nl80211: Driver does not support setting background radar mode");
++		return 0;
++	}
++
++	if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR)) ||
++	    nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_MTK) ||
++	    nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD,
++			MTK_NL80211_VENDOR_SUBCMD_BACKGROUND_RADAR_CTRL) ||
++	    !(data = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA)) ||
++	    nla_put_u8(msg, MTK_VENDOR_ATTR_BACKGROUND_RADAR_CTRL_MODE, background_radar_mode)) {
++		nlmsg_free(msg);
++		return -ENOBUFS;
++	}
++	nla_nest_end(msg, data);
++	ret = send_and_recv_cmd(drv, msg);
++	if (ret) {
++		wpa_printf(MSG_ERROR, "Failed to set background radar mode. ret=%d (%s) ",
++			   ret, strerror(-ret));
++	}
++	return ret;
++}
++
+ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
+ 	.name = "nl80211",
+ 	.desc = "Linux nl80211/cfg80211",
+@@ -15257,4 +15290,5 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
+ 	.ap_trigtype = nl80211_ap_trigtype,
+ 	.amnt_set = nl80211_amnt_set,
+ 	.amnt_dump = nl80211_amnt_dump,
++	.background_radar_mode = nl80211_background_radar_mode,
+ };
+diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h
+index adc1b9bf7..e9aae8d14 100644
+--- a/src/drivers/driver_nl80211.h
++++ b/src/drivers/driver_nl80211.h
+@@ -208,6 +208,7 @@ struct wpa_driver_nl80211_data {
+ 	unsigned int mtk_bss_color_vendor_cmd_avail:1;
+ 	unsigned int mtk_rfeatures_vendor_cmd_avail:1;
+ 	unsigned int mtk_amnt_vendor_cmd_avail:1;
++	unsigned int mtk_background_radar_vendor_cmd_avail:1;
+ 
+ 	u32 ignore_next_local_disconnect;
+ 	u32 ignore_next_local_deauth;
+diff --git a/src/drivers/driver_nl80211_capa.c b/src/drivers/driver_nl80211_capa.c
+index 4a6ff0f28..fd8c7b0ad 100644
+--- a/src/drivers/driver_nl80211_capa.c
++++ b/src/drivers/driver_nl80211_capa.c
+@@ -1164,6 +1164,9 @@ static int wiphy_info_handler(struct nl_msg *msg, void *arg)
+ 				case MTK_NL80211_VENDOR_SUBCMD_RFEATURE_CTRL:
+ 					drv->mtk_rfeatures_vendor_cmd_avail = 1;
+ 					break;
++				case MTK_NL80211_VENDOR_SUBCMD_BACKGROUND_RADAR_CTRL:
++					drv->mtk_background_radar_vendor_cmd_avail = 1;
++					break;
+ 				}
+ 			}
+ 
+-- 
+2.18.0
+