[][MAC80211][WiFi7][misc][change the place to sleep to prevent race STA's condition]

[Description]
Change the place to sleep to prevent STA's race condition.

Originally, the sleep was added for preventing race condition during AP
interface setup. In single-wiphy, STAs setup concurrently might also
lead to race condition.

[Release-log]
N/A

Change-Id: I8d52fb39b9b6e57cf8420fe392120dea9c2b9ca1
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/9060879
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 5b2e8bd..561a8d3 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
@@ -416,7 +416,7 @@
  		echo "wps_cred_processing=1" >> "$_config"
  	else
 diff --git a/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh b/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh
-index bc59c303..66bdf5cf 100755
+index bc59c303..2508d9cf 100755
 --- a/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh
 +++ b/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh
 @@ -29,10 +29,12 @@ drv_mac80211_init_device_config() {
@@ -837,7 +837,7 @@
  		macaddr="$(mac80211_generate_mac $phy)"
  		macidx="$(($macidx + 1))"
  		default_macaddr=1
-@@ -917,12 +1076,28 @@ wpa_supplicant_set_config() {
+@@ -917,6 +1076,14 @@ wpa_supplicant_set_config() {
  }
  
  hostapd_set_config() {
@@ -852,21 +852,7 @@
  	[ -n "$hostapd_ctrl" ] || {
  		ubus_call hostapd config_set '{ "phy": "'"$phy"'", "config": "", "prev_config": "'"${hostapd_conf_file}.prev"'" }' > /dev/null
  		return 0;
- 	}
- 
- 	ubus wait_for hostapd
-+
-+	# each phy sleeps different times to prevent for ubus race condition.
-+	if [ "$phy" = "phy1" ]; then
-+		sleep 3;
-+	elif [ "$phy" = "phy2" ]; then
-+		sleep 6;
-+	fi
-+
- 	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" ] && {
-@@ -1000,6 +1175,9 @@ mac80211_setup_vif() {
+@@ -1000,6 +1167,9 @@ mac80211_setup_vif() {
  
  	json_select ..
  	[ -n "$failed" ] || wireless_add_vif "$name" "$ifname"
@@ -876,7 +862,7 @@
  }
  
  get_freq() {
-@@ -1051,6 +1229,25 @@ mac80211_reset_config() {
+@@ -1051,6 +1221,25 @@ mac80211_reset_config() {
  	wdev_tool "$phy" set_config '{}'
  }
  
@@ -902,7 +888,7 @@
  drv_mac80211_setup() {
  	json_select config
  	json_get_vars \
-@@ -1059,7 +1256,8 @@ drv_mac80211_setup() {
+@@ -1059,7 +1248,8 @@ drv_mac80211_setup() {
  		txpower \
  		rxantenna txantenna \
  		frag rts beacon_int:100 htmode \
@@ -912,7 +898,18 @@
  	json_get_values basic_rate_list basic_rate
  	json_get_values scan_list scan_list
  	json_select ..
-@@ -1094,6 +1292,7 @@ drv_mac80211_setup() {
+@@ -1090,10 +1280,18 @@ drv_mac80211_setup() {
+ 		}
+ 	}
+ 
++	# each phy sleeps different times to prevent for ubus race condition.
++	if [ "$phy" = "phy1" ]; then
++		sleep 3;
++	elif [ "$phy" = "phy2" ]; then
++		sleep 6;
++	fi
++
+ 	hostapd_conf_file="/var/run/hostapd-$phy.conf"
  
  	macidx=0
  	staidx=0
@@ -920,7 +917,7 @@
  
  	[ -n "$chanbw" ] && {
  		for file in /sys/kernel/debug/ieee80211/$phy/ath9k*/chanbw /sys/kernel/debug/ieee80211/$phy/ath5k/bwmode; do
-@@ -1142,14 +1341,29 @@ drv_mac80211_setup() {
+@@ -1142,14 +1340,29 @@ drv_mac80211_setup() {
  
  	wpa_supplicant_init_config