[][MAC80211][WiFi6][mt76][Add obss_interval config add with ht_coex]

[Description]
Add obss_interval config add with ht_coex.

[Release-log]
N/A

Change-Id: Ic841aacefb6b1e83135a35d7a840a518308d3393
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7962958
diff --git a/autobuild_mac80211_release/0001-wifi6-mac80211-generate-hostapd-setting-from-ap-cap.patch b/autobuild_mac80211_release/0001-wifi6-mac80211-generate-hostapd-setting-from-ap-cap.patch
index 540dff6..13bfc9d 100644
--- a/autobuild_mac80211_release/0001-wifi6-mac80211-generate-hostapd-setting-from-ap-cap.patch
+++ b/autobuild_mac80211_release/0001-wifi6-mac80211-generate-hostapd-setting-from-ap-cap.patch
@@ -32,14 +32,14 @@
  		$(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 ed28052..13c385f 100644
+index ed28052..e450e86 100644
 --- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
 +++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
 @@ -27,6 +27,7 @@ drv_mac80211_init_device_config() {
  
  	config_add_string path phy 'macaddr:macaddr'
  	config_add_string tx_burst
-+	config_add_int mbssid mu_onoff sr_enable sr_enhanced rnr
++	config_add_int mbssid mu_onoff sr_enable sr_enhanced rnr obss_interval
  	config_add_string distance
  	config_add_int beacon_int chanbw frag rts
  	config_add_int rxantenna txantenna antenna_gain txpower min_tx_power
@@ -60,7 +60,7 @@
  		append base_cfg "acs_exclude_dfs=1" "$N"
  
 -	json_get_vars noscan ht_coex min_tx_power:0 tx_burst
-+	json_get_vars noscan ht_coex min_tx_power:0 tx_burst mbssid mu_onoff rnr
++	json_get_vars noscan ht_coex min_tx_power:0 tx_burst mbssid mu_onoff rnr obss_interval
 +	json_get_vars etxbfen:1 itxbfen:0
  	json_get_values ht_capab_list ht_capab
  	json_get_values channel_list channels
@@ -107,7 +107,18 @@
  						*)
  							if [ "$channel" -lt 7 ]; then
  								ht_capab="[HT40+]"
-@@ -205,7 +221,7 @@ mac80211_hostapd_setup_base() {
+@@ -193,6 +209,10 @@ mac80211_hostapd_setup_base() {
+ 
+ 		set_default ht_coex 0
+ 		append base_cfg "ht_coex=$ht_coex" "$N"
++		[ "$ht_coex" -eq 1 ] && {
++			set_default obss_interval 300
++			append base_cfg "obss_interval=$obss_interval" "$N"
++		}
+ 
+ 		json_get_vars \
+ 			ldpc:1 \
+@@ -205,7 +225,7 @@ mac80211_hostapd_setup_base() {
  			dsss_cck_40:1
  
  		ht_cap_mask=0
@@ -116,7 +127,7 @@
  			ht_cap_mask="$(($ht_cap_mask | $cap))"
  		done
  
-@@ -236,8 +252,8 @@ mac80211_hostapd_setup_base() {
+@@ -236,8 +256,8 @@ mac80211_hostapd_setup_base() {
  
  	idx="$channel"
  	case "$htmode" in
@@ -127,7 +138,7 @@
  			case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in
  				1) idx=$(($channel + 2));;
  				0) idx=$(($channel - 2));;
-@@ -245,7 +261,7 @@ mac80211_hostapd_setup_base() {
+@@ -245,7 +265,7 @@ mac80211_hostapd_setup_base() {
  			enable_ac=1
  			vht_center_seg0=$idx
  		;;
@@ -136,7 +147,7 @@
  			case "$(( (($channel / 4) + $chan_ofs) % 4 ))" in
  				1) idx=$(($channel + 6));;
  				2) idx=$(($channel + 2));;
-@@ -256,7 +272,7 @@ mac80211_hostapd_setup_base() {
+@@ -256,7 +276,7 @@ mac80211_hostapd_setup_base() {
  			vht_oper_chwidth=1
  			vht_center_seg0=$idx
  		;;
@@ -145,7 +156,7 @@
  			if [ "$band" = "6g" ]; then
  				case "$channel" in
  					1|5|9|13|17|21|25|29) idx=15;;
-@@ -271,12 +287,43 @@ mac80211_hostapd_setup_base() {
+@@ -271,12 +291,43 @@ 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;;
@@ -189,7 +200,7 @@
  	esac
  	[ "$band" = "5g" ] && {
  		json_get_vars background_radar:0
-@@ -286,8 +333,9 @@ mac80211_hostapd_setup_base() {
+@@ -286,8 +337,9 @@ mac80211_hostapd_setup_base() {
  	[ "$band" = "6g" ] && {
  		op_class=
  		case "$htmode" in
@@ -201,7 +212,7 @@
  		esac
  		[ -n "$op_class" ] && append base_cfg "op_class=$op_class" "$N"
  	}
-@@ -315,7 +363,6 @@ mac80211_hostapd_setup_base() {
+@@ -315,7 +367,6 @@ mac80211_hostapd_setup_base() {
  			vht_link_adapt:3 \
  			vht160:2
  
@@ -209,7 +220,7 @@
  		append base_cfg "ieee80211ac=1" "$N"
  		vht_cap=0
  		for cap in $(iw phy "$phy" info | awk -F "[()]" '/VHT Capabilities/ { print $2 }'); do
-@@ -329,6 +376,12 @@ mac80211_hostapd_setup_base() {
+@@ -329,6 +380,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) ))"
  
@@ -222,7 +233,7 @@
  		mac80211_add_capabilities vht_capab $vht_cap \
  			RXLDPC:0x10::$rxldpc \
  			SHORT-GI-80:0x20::$short_gi_80 \
-@@ -410,7 +463,7 @@ mac80211_hostapd_setup_base() {
+@@ -410,7 +467,7 @@ mac80211_hostapd_setup_base() {
  	# 802.11ax
  	enable_ax=0
  	case "$htmode" in
@@ -231,7 +242,7 @@
  	esac
  
  	if [ "$enable_ax" != "0" ]; then
-@@ -419,10 +472,11 @@ mac80211_hostapd_setup_base() {
+@@ -419,10 +476,11 @@ mac80211_hostapd_setup_base() {
  			he_su_beamformee:1 \
  			he_mu_beamformer:1 \
  			he_twt_required:0 \
@@ -244,7 +255,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)
-@@ -436,6 +490,11 @@ mac80211_hostapd_setup_base() {
+@@ -436,6 +494,11 @@ mac80211_hostapd_setup_base() {
  			append base_cfg "he_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N"
  		}
  
@@ -256,7 +267,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 \
-@@ -443,7 +502,14 @@ mac80211_hostapd_setup_base() {
+@@ -443,7 +506,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
  
@@ -271,7 +282,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"
-@@ -484,12 +550,47 @@ mac80211_hostapd_setup_base() {
+@@ -484,12 +554,47 @@ mac80211_hostapd_setup_base() {
  		append base_cfg "he_mu_edca_ac_vo_timer=255" "$N"
  	fi
  
@@ -319,7 +330,7 @@
  $base_cfg
  
  EOF
-@@ -517,7 +618,7 @@ mac80211_hostapd_setup_bss() {
+@@ -517,7 +622,7 @@ mac80211_hostapd_setup_bss() {
  		append hostapd_cfg "wds_sta=1" "$N"
  		[ -n "$wds_bridge" ] && append hostapd_cfg "wds_bridge=$wds_bridge" "$N"
  	}
@@ -328,7 +339,7 @@
  
  	cat >> /var/run/hostapd-$phy.conf <<EOF
  $hostapd_cfg
-@@ -527,6 +628,31 @@ ${max_listen_int:+max_listen_interval=$max_listen_int}
+@@ -527,6 +632,31 @@ ${max_listen_int:+max_listen_interval=$max_listen_int}
  EOF
  }
  
@@ -360,7 +371,7 @@
  mac80211_get_addr() {
  	local phy="$1"
  	local idx="$(($2 + 1))"
-@@ -757,7 +883,19 @@ mac80211_prepare_vif() {
+@@ -757,7 +887,19 @@ mac80211_prepare_vif() {
  
  	json_select ..
  
@@ -381,7 +392,7 @@
  		macaddr="$(mac80211_generate_mac $phy)"
  		macidx="$(($macidx + 1))"
  	elif [ "$macaddr" = 'random' ]; then
-@@ -1058,6 +1196,9 @@ mac80211_setup_vif() {
+@@ -1058,6 +1200,9 @@ mac80211_setup_vif() {
  
  	json_select ..
  	[ -n "$failed" ] || wireless_add_vif "$name" "$ifname"
@@ -391,7 +402,7 @@
  }
  
  get_freq() {
-@@ -1122,6 +1263,10 @@ drv_mac80211_cleanup() {
+@@ -1122,6 +1267,10 @@ drv_mac80211_cleanup() {
  	hostapd_common_cleanup
  }
  
@@ -402,7 +413,7 @@
  drv_mac80211_setup() {
  	json_select config
  	json_get_vars \
-@@ -1129,7 +1274,8 @@ drv_mac80211_setup() {
+@@ -1129,7 +1278,8 @@ drv_mac80211_setup() {
  		country chanbw distance \
  		txpower antenna_gain \
  		rxantenna txantenna \
@@ -412,7 +423,7 @@
  	json_get_values basic_rate_list basic_rate
  	json_get_values scan_list scan_list
  	json_select ..
-@@ -1180,6 +1326,7 @@ drv_mac80211_setup() {
+@@ -1180,6 +1330,7 @@ drv_mac80211_setup() {
  	no_ap=1
  	macidx=0
  	staidx=0
@@ -420,7 +431,7 @@
  
  	[ -n "$chanbw" ] && {
  		for file in /sys/kernel/debug/ieee80211/$phy/ath9k*/chanbw /sys/kernel/debug/ieee80211/$phy/ath5k/bwmode; do
-@@ -1219,6 +1366,16 @@ drv_mac80211_setup() {
+@@ -1219,6 +1370,16 @@ drv_mac80211_setup() {
  	for_each_interface "sta adhoc mesh" mac80211_set_noscan
  	[ -n "$has_ap" ] && mac80211_hostapd_setup_base "$phy"
  
@@ -437,7 +448,7 @@
  	mac80211_prepare_iw_htmode
  	for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif
  	NEWAPLIST=
-@@ -1251,6 +1408,14 @@ drv_mac80211_setup() {
+@@ -1251,6 +1412,14 @@ drv_mac80211_setup() {
  		if [ "$no_reload" != "0" ]; then
  			add_ap=1
  			ubus wait_for hostapd
@@ -452,7 +463,7 @@
  			local hostapd_res="$(ubus call hostapd config_add "{\"iface\":\"$primary_ap\", \"config\":\"${hostapd_conf_file}\"}")"
  			ret="$?"
  			[ "$ret" != 0 -o -z "$hostapd_res" ] && {
-@@ -1266,6 +1431,9 @@ drv_mac80211_setup() {
+@@ -1266,6 +1435,9 @@ drv_mac80211_setup() {
  	[ "${add_ap}" = 1 ] && sleep 1
  	for_each_interface "ap" mac80211_setup_vif