[][MAC80211][WiFi7][netifd][Add default on background radar and background cert mode for SQC]

[Description]
Add default on background radar to UCI settings
Add background cert mode UCI option for Eagle eFEM HWITS

[Release-log]
N/A

Change-Id: I041916caf6bb486ed00c3d6691a337c19e195545
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7961996
diff --git a/autobuild_mac80211_release/0001-wifi7-mac80211-generate-hostapd-setting-from-ap-cap.patch b/autobuild_mac80211_release/0001-wifi7-mac80211-generate-hostapd-setting-from-ap-cap.patch
index 87ae2e3..9820e67 100644
--- a/autobuild_mac80211_release/0001-wifi7-mac80211-generate-hostapd-setting-from-ap-cap.patch
+++ b/autobuild_mac80211_release/0001-wifi7-mac80211-generate-hostapd-setting-from-ap-cap.patch
@@ -31,10 +31,10 @@
  		$(PKG_BUILD_DIR)/include/linux/ssb \
  		$(PKG_BUILD_DIR)/include/linux/bcma \
 diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
-index 39683376..3b1b5a55 100644
+index 39683376..3c7a88dd 100644
 --- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
 +++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
-@@ -24,6 +24,7 @@ drv_mac80211_init_device_config() {
+@@ -24,10 +24,11 @@ drv_mac80211_init_device_config() {
  
  	config_add_string path phy 'macaddr:macaddr'
  	config_add_string tx_burst
@@ -42,6 +42,11 @@
  	config_add_string distance
  	config_add_int beacon_int chanbw frag rts
  	config_add_int rxantenna txantenna antenna_gain txpower min_tx_power
+-	config_add_boolean noscan ht_coex acs_exclude_dfs background_radar
++	config_add_boolean noscan ht_coex acs_exclude_dfs background_radar background_cert_mode
+ 	config_add_array ht_capab
+ 	config_add_array channels
+ 	config_add_array scan_list
 @@ -50,7 +51,10 @@ drv_mac80211_init_device_config() {
  		he_spr_sr_control \
  		he_spr_psr_enabled \
@@ -144,7 +149,7 @@
  			if [ "$band" = "6g" ]; then
  				case "$channel" in
  					1|5|9|13|17|21|25|29) idx=15;;
-@@ -268,12 +284,43 @@ mac80211_hostapd_setup_base() {
+@@ -268,23 +284,58 @@ mac80211_hostapd_setup_base() {
  				case "$channel" in
  					36|40|44|48|52|56|60|64) idx=50;;
  					100|104|108|112|116|120|124|128) idx=114;;
@@ -187,8 +192,14 @@
 +		;;
  	esac
  	[ "$band" = "5g" ] && {
- 		json_get_vars background_radar:0
-@@ -283,8 +330,9 @@ mac80211_hostapd_setup_base() {
+-		json_get_vars background_radar:0
++		json_get_vars \
++			background_radar:0 \
++			background_cert_mode:0 \
+ 
+ 		[ "$background_radar" -eq 1 ] && append base_cfg "enable_background_radar=1" "$N"
++		[ "$background_cert_mode" -eq 1 ] && append base_cfg "background_radar_mode=1" "$N"
+ 	}
  	[ "$band" = "6g" ] && {
  		op_class=
  		case "$htmode" in
@@ -200,7 +211,7 @@
  		esac
  		[ -n "$op_class" ] && append base_cfg "op_class=$op_class" "$N"
  	}
-@@ -312,7 +360,6 @@ mac80211_hostapd_setup_base() {
+@@ -312,7 +363,6 @@ mac80211_hostapd_setup_base() {
  			vht_link_adapt:3 \
  			vht160:2
  
@@ -208,7 +219,7 @@
  		append base_cfg "ieee80211ac=1" "$N"
  		vht_cap=0
  		for cap in $(iw phy "$phy" info | awk -F "[()]" '/VHT Capabilities/ { print $2 }'); do
-@@ -326,6 +373,12 @@ mac80211_hostapd_setup_base() {
+@@ -326,6 +376,12 @@ mac80211_hostapd_setup_base() {
  		[ "$rx_stbc" -lt "$cap_rx_stbc" ] && cap_rx_stbc="$rx_stbc"
  		vht_cap="$(( ($vht_cap & ~(0x700)) | ($cap_rx_stbc << 8) ))"
  
@@ -221,7 +232,7 @@
  		mac80211_add_capabilities vht_capab $vht_cap \
  			RXLDPC:0x10::$rxldpc \
  			SHORT-GI-80:0x20::$short_gi_80 \
-@@ -407,7 +460,7 @@ mac80211_hostapd_setup_base() {
+@@ -407,7 +463,7 @@ mac80211_hostapd_setup_base() {
  	# 802.11ax
  	enable_ax=0
  	case "$htmode" in
@@ -230,7 +241,7 @@
  	esac
  
  	if [ "$enable_ax" != "0" ]; then
-@@ -416,10 +469,11 @@ mac80211_hostapd_setup_base() {
+@@ -416,10 +472,11 @@ mac80211_hostapd_setup_base() {
  			he_su_beamformee:1 \
  			he_mu_beamformer:1 \
  			he_twt_required:0 \
@@ -243,7 +254,7 @@
  			he_bss_color_enabled:1
  
  		he_phy_cap=$(iw phy "$phy" info | sed -n '/HE Iftypes: AP/,$p' | awk -F "[()]" '/HE PHY Capabilities/ { print $2 }' | head -1)
-@@ -433,6 +487,11 @@ mac80211_hostapd_setup_base() {
+@@ -433,6 +490,11 @@ mac80211_hostapd_setup_base() {
  			append base_cfg "he_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N"
  		}
  
@@ -255,7 +266,7 @@
  		mac80211_add_he_capabilities \
  			he_su_beamformer:${he_phy_cap:6:2}:0x80:$he_su_beamformer \
  			he_su_beamformee:${he_phy_cap:8:2}:0x1:$he_su_beamformee \
-@@ -440,7 +499,14 @@ mac80211_hostapd_setup_base() {
+@@ -440,7 +502,14 @@ mac80211_hostapd_setup_base() {
  			he_spr_psr_enabled:${he_phy_cap:14:2}:0x1:$he_spr_psr_enabled \
  			he_twt_required:${he_mac_cap:0:2}:0x6:$he_twt_required
  
@@ -270,7 +281,7 @@
  			append base_cfg "he_bss_color=$he_bss_color" "$N"
  			[ "$he_spr_non_srg_obss_pd_max_offset" -gt 0 ] && { \
  				append base_cfg "he_spr_non_srg_obss_pd_max_offset=$he_spr_non_srg_obss_pd_max_offset" "$N"
-@@ -459,34 +525,69 @@ mac80211_hostapd_setup_base() {
+@@ -459,34 +528,69 @@ mac80211_hostapd_setup_base() {
  		append base_cfg "he_mu_edca_qos_info_q_ack=0" "$N"
  		append base_cfg "he_mu_edca_qos_info_queue_request=0" "$N"
  		append base_cfg "he_mu_edca_qos_info_txop_request=0" "$N"
@@ -344,7 +355,7 @@
  $base_cfg
  
  EOF
-@@ -512,7 +613,7 @@ mac80211_hostapd_setup_bss() {
+@@ -512,7 +616,7 @@ mac80211_hostapd_setup_bss() {
  		append hostapd_cfg "wds_sta=1" "$N"
  		[ -n "$wds_bridge" ] && append hostapd_cfg "wds_bridge=$wds_bridge" "$N"
  	}
@@ -353,7 +364,7 @@
  
  	cat >> /var/run/hostapd-$phy.conf <<EOF
  $hostapd_cfg
-@@ -522,6 +623,31 @@ ${max_listen_int:+max_listen_interval=$max_listen_int}
+@@ -522,6 +626,31 @@ ${max_listen_int:+max_listen_interval=$max_listen_int}
  EOF
  }
  
@@ -385,7 +396,7 @@
  mac80211_get_addr() {
  	local phy="$1"
  	local idx="$(($2 + 1))"
-@@ -684,7 +810,19 @@ mac80211_prepare_vif() {
+@@ -684,7 +813,19 @@ mac80211_prepare_vif() {
  	set_default powersave 0
  	json_add_string _ifname "$ifname"
  
@@ -406,7 +417,7 @@
  		macaddr="$(mac80211_generate_mac $phy)"
  		macidx="$(($macidx + 1))"
  	elif [ "$macaddr" = 'random' ]; then
-@@ -948,6 +1086,14 @@ hostapd_set_config() {
+@@ -948,6 +1089,14 @@ hostapd_set_config() {
  	}
  
  	ubus wait_for hostapd
@@ -421,7 +432,7 @@
  	local hostapd_res="$(ubus call hostapd config_set "{ \"phy\": \"$phy\", \"config\":\"${hostapd_conf_file}\", \"prev_config\": \"${hostapd_conf_file}.prev\"}")"
  	ret="$?"
  	[ "$ret" != 0 -o -z "$hostapd_res" ] && {
-@@ -1024,6 +1170,9 @@ mac80211_setup_vif() {
+@@ -1024,6 +1173,9 @@ mac80211_setup_vif() {
  
  	json_select ..
  	[ -n "$failed" ] || wireless_add_vif "$name" "$ifname"
@@ -431,7 +442,7 @@
  }
  
  get_freq() {
-@@ -1075,6 +1224,10 @@ mac80211_reset_config() {
+@@ -1075,6 +1227,10 @@ mac80211_reset_config() {
  	wdev_tool "$phy" '{}'
  }
  
@@ -442,7 +453,7 @@
  drv_mac80211_setup() {
  	json_select config
  	json_get_vars \
-@@ -1082,7 +1235,8 @@ drv_mac80211_setup() {
+@@ -1082,7 +1238,8 @@ drv_mac80211_setup() {
  		country chanbw distance \
  		txpower antenna_gain \
  		rxantenna txantenna \
@@ -452,7 +463,7 @@
  	json_get_values basic_rate_list basic_rate
  	json_get_values scan_list scan_list
  	json_select ..
-@@ -1117,6 +1271,7 @@ drv_mac80211_setup() {
+@@ -1117,6 +1274,7 @@ drv_mac80211_setup() {
  
  	macidx=0
  	staidx=0
@@ -460,7 +471,7 @@
  
  	[ -n "$chanbw" ] && {
  		for file in /sys/kernel/debug/ieee80211/$phy/ath9k*/chanbw /sys/kernel/debug/ieee80211/$phy/ath5k/bwmode; do
-@@ -1167,6 +1322,16 @@ drv_mac80211_setup() {
+@@ -1167,6 +1325,16 @@ drv_mac80211_setup() {
  
  	wpa_supplicant_init_config
  
@@ -477,7 +488,7 @@
  	mac80211_prepare_iw_htmode
  	active_ifnames=
  	for_each_interface "ap sta adhoc mesh monitor" mac80211_prepare_vif
-@@ -1175,6 +1340,9 @@ drv_mac80211_setup() {
+@@ -1175,6 +1343,9 @@ drv_mac80211_setup() {
  	[ -x /usr/sbin/wpa_supplicant ] && wpa_supplicant_set_config "$phy"
  	[ -x /usr/sbin/hostapd ] && hostapd_set_config "$phy"
  
@@ -488,7 +499,7 @@
  
  	json_set_namespace wdev_uc prev
 diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
-index e24a2a63..20e60688 100644
+index e24a2a63..da3ee8cc 100644
 --- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh
 +++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
 @@ -60,6 +60,9 @@ BEGIN {
@@ -528,7 +539,7 @@
  $1 == "*" && $3 == "MHz" && $0 !~ /disabled/ && band && !channel {
          channel = $4
  }
-@@ -120,6 +136,19 @@ get_band_defaults() {
+@@ -120,6 +136,25 @@ get_band_defaults() {
  		mode_band="$band"
  		channel="$chan"
  		htmode="$mode"
@@ -540,6 +551,12 @@
 +			ieee80211w=2
 +			channel=37
 +			mbssid=1
++		elif [ "$band" = "5g" ]
++		then
++			noscan=1
++			encryption=none
++			rnr=1
++			background_radar=1
 +		else
 +			noscan=1
 +			encryption=none
@@ -548,7 +565,7 @@
  	done
  }
  
-@@ -153,6 +182,10 @@ detect_mac80211() {
+@@ -153,6 +188,10 @@ detect_mac80211() {
  
  	json_load_file /etc/board.json
  
@@ -559,7 +576,7 @@
  	for _dev in /sys/class/ieee80211/*; do
  		[ -e "$_dev" ] || continue
  
-@@ -162,6 +195,13 @@ detect_mac80211() {
+@@ -162,6 +201,14 @@ detect_mac80211() {
  		channel=""
  		htmode=""
  		ht_capab=""
@@ -570,10 +587,11 @@
 +		ieee80211w=""
 +		mbssid=""
 +		rnr=""
++		background_radar=""
  
  		get_band_defaults "$dev"
  
-@@ -196,6 +236,14 @@ detect_mac80211() {
+@@ -196,6 +243,14 @@ detect_mac80211() {
  				;;
  		esac
  
@@ -588,7 +606,7 @@
  		uci -q batch <<-EOF
  			set wireless.${name}=wifi-device
  			set wireless.${name}.type=mac80211
-@@ -203,15 +251,40 @@ detect_mac80211() {
+@@ -203,15 +258,43 @@ detect_mac80211() {
  			set wireless.${name}.channel=${channel}
  			set wireless.${name}.band=${mode_band}
  			set wireless.${name}.htmode=$htmode
@@ -603,6 +621,9 @@
 +		[ -n "$rnr" ] && {
 +			uci -q set wireless.${name}.rnr=${rnr}
 +		}
++		[ -n "$background_radar" ] && {
++			uci -q set wireless.${name}.background_radar=${background_radar}
++		}
  
 +		uci -q batch <<-EOF
  			set wireless.default_${name}=wifi-iface