[][MAC80211][WiFi6][Misc][Add lpi, duplicate mode and sku index]

[Description]
Add lpi, duplicate mode and sku index config.

[Release-log]
N/A

Change-Id: I0197b55cf7cf69aa5ab3c157e26cd8a2212ddc8d
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8434865
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 4f31708..a7cd41f 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,7 +32,7 @@
  		$(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..c353d6a 100644
+index ed28052..95ee503 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() {
@@ -43,7 +43,7 @@
  	config_add_string distance
  	config_add_int beacon_int chanbw frag rts
  	config_add_int rxantenna txantenna antenna_gain txpower min_tx_power
-@@ -53,7 +54,10 @@ drv_mac80211_init_device_config() {
+@@ -53,7 +54,12 @@ drv_mac80211_init_device_config() {
  		he_spr_sr_control \
  		he_spr_psr_enabled \
  		he_bss_color_enabled \
@@ -51,17 +51,29 @@
 +		he_twt_required \
 +		he_twt_responder \
 +		etxbfen \
-+		itxbfen
++		itxbfen \
++		lpi_enable \
++		beacon_dup
  	config_add_int \
  		beamformer_antennas \
  		beamformee_antennas \
-@@ -140,13 +144,11 @@ mac80211_hostapd_setup_base() {
+@@ -64,7 +70,8 @@ drv_mac80211_init_device_config() {
+ 		rx_stbc \
+ 		tx_stbc \
+ 		he_bss_color \
+-		he_spr_non_srg_obss_pd_max_offset
++		he_spr_non_srg_obss_pd_max_offset \
++		sku_idx
+ 	config_add_boolean \
+ 		ldpc \
+ 		greenfield \
+@@ -140,13 +147,11 @@ mac80211_hostapd_setup_base() {
  	[ -n "$acs_exclude_dfs" ] && [ "$acs_exclude_dfs" -gt 0 ] &&
  		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 obss_interval
-+	json_get_vars etxbfen:1 itxbfen:0
++	json_get_vars etxbfen:1 itxbfen:0 lpi_enable:0 sku_idx:0 beacon_dup:1
  	json_get_values ht_capab_list ht_capab
  	json_get_values channel_list channels
  
@@ -71,7 +83,7 @@
  	[ "$min_tx_power" -gt 0 ] && append base_cfg "min_tx_power=$min_tx_power"
  
  	set_default noscan 0
-@@ -160,21 +162,42 @@ mac80211_hostapd_setup_base() {
+@@ -160,21 +165,42 @@ mac80211_hostapd_setup_base() {
  	ieee80211n=1
  	ht_capab=
  	case "$htmode" in
@@ -119,7 +131,7 @@
  								ht_capab="[HT40+]"
  							else
  								ht_capab="[HT40-]"
-@@ -183,7 +206,6 @@ mac80211_hostapd_setup_base() {
+@@ -183,7 +209,6 @@ mac80211_hostapd_setup_base() {
  					esac
  				;;
  			esac
@@ -127,7 +139,7 @@
  		;;
  		*) ieee80211n= ;;
  	esac
-@@ -193,6 +215,10 @@ mac80211_hostapd_setup_base() {
+@@ -193,6 +218,10 @@ mac80211_hostapd_setup_base() {
  
  		set_default ht_coex 0
  		append base_cfg "ht_coex=$ht_coex" "$N"
@@ -138,7 +150,7 @@
  
  		json_get_vars \
  			ldpc:1 \
-@@ -205,7 +231,7 @@ mac80211_hostapd_setup_base() {
+@@ -205,7 +234,7 @@ mac80211_hostapd_setup_base() {
  			dsss_cck_40:1
  
  		ht_cap_mask=0
@@ -147,7 +159,7 @@
  			ht_cap_mask="$(($ht_cap_mask | $cap))"
  		done
  
-@@ -236,8 +262,8 @@ mac80211_hostapd_setup_base() {
+@@ -236,8 +265,8 @@ mac80211_hostapd_setup_base() {
  
  	idx="$channel"
  	case "$htmode" in
@@ -158,7 +170,7 @@
  			case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in
  				1) idx=$(($channel + 2));;
  				0) idx=$(($channel - 2));;
-@@ -245,7 +271,7 @@ mac80211_hostapd_setup_base() {
+@@ -245,7 +274,7 @@ mac80211_hostapd_setup_base() {
  			enable_ac=1
  			vht_center_seg0=$idx
  		;;
@@ -167,7 +179,7 @@
  			case "$(( (($channel / 4) + $chan_ofs) % 4 ))" in
  				1) idx=$(($channel + 6));;
  				2) idx=$(($channel + 2));;
-@@ -256,7 +282,7 @@ mac80211_hostapd_setup_base() {
+@@ -256,7 +285,7 @@ mac80211_hostapd_setup_base() {
  			vht_oper_chwidth=1
  			vht_center_seg0=$idx
  		;;
@@ -176,7 +188,7 @@
  			if [ "$band" = "6g" ]; then
  				case "$channel" in
  					1|5|9|13|17|21|25|29) idx=15;;
-@@ -271,12 +297,43 @@ mac80211_hostapd_setup_base() {
+@@ -271,12 +300,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;;
@@ -220,7 +232,7 @@
  	esac
  	[ "$band" = "5g" ] && {
  		json_get_vars background_radar:0
-@@ -286,8 +343,9 @@ mac80211_hostapd_setup_base() {
+@@ -286,8 +346,9 @@ mac80211_hostapd_setup_base() {
  	[ "$band" = "6g" ] && {
  		op_class=
  		case "$htmode" in
@@ -232,7 +244,7 @@
  		esac
  		[ -n "$op_class" ] && append base_cfg "op_class=$op_class" "$N"
  	}
-@@ -315,7 +373,6 @@ mac80211_hostapd_setup_base() {
+@@ -315,7 +376,6 @@ mac80211_hostapd_setup_base() {
  			vht_link_adapt:3 \
  			vht160:2
  
@@ -240,7 +252,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 +386,12 @@ mac80211_hostapd_setup_base() {
+@@ -329,6 +389,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) ))"
  
@@ -253,7 +265,7 @@
  		mac80211_add_capabilities vht_capab $vht_cap \
  			RXLDPC:0x10::$rxldpc \
  			SHORT-GI-80:0x20::$short_gi_80 \
-@@ -410,7 +473,7 @@ mac80211_hostapd_setup_base() {
+@@ -410,7 +476,7 @@ mac80211_hostapd_setup_base() {
  	# 802.11ax
  	enable_ax=0
  	case "$htmode" in
@@ -262,7 +274,7 @@
  	esac
  
  	if [ "$enable_ax" != "0" ]; then
-@@ -419,10 +482,11 @@ mac80211_hostapd_setup_base() {
+@@ -419,10 +485,11 @@ mac80211_hostapd_setup_base() {
  			he_su_beamformee:1 \
  			he_mu_beamformer:1 \
  			he_twt_required:0 \
@@ -275,7 +287,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 +500,11 @@ mac80211_hostapd_setup_base() {
+@@ -436,6 +503,11 @@ mac80211_hostapd_setup_base() {
  			append base_cfg "he_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N"
  		}
  
@@ -287,7 +299,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 +512,14 @@ mac80211_hostapd_setup_base() {
+@@ -443,7 +515,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
  
@@ -302,7 +314,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 +560,47 @@ mac80211_hostapd_setup_base() {
+@@ -484,12 +563,50 @@ mac80211_hostapd_setup_base() {
  		append base_cfg "he_mu_edca_ac_vo_timer=255" "$N"
  	fi
  
@@ -346,11 +358,14 @@
 +${mbssid:+mbssid=$mbssid}
 +${mu_onoff:+mu_onoff=$mu_onoff}
 +${itxbfen:+ibf_enable=$itxbfen}
++${lpi_enable:+lpi_enable=$lpi_enable}
++${sku_idx:+sku_idx=$sku_idx}
++${beacon_dup:+beacon_dup=$beacon_dup}
 +${rnr:+rnr=$rnr}
  $base_cfg
  
  EOF
-@@ -517,7 +628,7 @@ mac80211_hostapd_setup_bss() {
+@@ -517,7 +634,7 @@ mac80211_hostapd_setup_bss() {
  		append hostapd_cfg "wds_sta=1" "$N"
  		[ -n "$wds_bridge" ] && append hostapd_cfg "wds_bridge=$wds_bridge" "$N"
  	}
@@ -359,7 +374,7 @@
  
  	cat >> /var/run/hostapd-$phy.conf <<EOF
  $hostapd_cfg
-@@ -527,6 +638,31 @@ ${max_listen_int:+max_listen_interval=$max_listen_int}
+@@ -527,6 +644,31 @@ ${max_listen_int:+max_listen_interval=$max_listen_int}
  EOF
  }
  
@@ -391,7 +406,7 @@
  mac80211_get_addr() {
  	local phy="$1"
  	local idx="$(($2 + 1))"
-@@ -757,7 +893,19 @@ mac80211_prepare_vif() {
+@@ -757,7 +899,19 @@ mac80211_prepare_vif() {
  
  	json_select ..
  
@@ -412,7 +427,7 @@
  		macaddr="$(mac80211_generate_mac $phy)"
  		macidx="$(($macidx + 1))"
  	elif [ "$macaddr" = 'random' ]; then
-@@ -1058,6 +1206,9 @@ mac80211_setup_vif() {
+@@ -1058,6 +1212,9 @@ mac80211_setup_vif() {
  
  	json_select ..
  	[ -n "$failed" ] || wireless_add_vif "$name" "$ifname"
@@ -422,7 +437,7 @@
  }
  
  get_freq() {
-@@ -1122,6 +1273,25 @@ drv_mac80211_cleanup() {
+@@ -1122,6 +1279,25 @@ drv_mac80211_cleanup() {
  	hostapd_common_cleanup
  }
  
@@ -448,7 +463,7 @@
  drv_mac80211_setup() {
  	json_select config
  	json_get_vars \
-@@ -1129,7 +1299,8 @@ drv_mac80211_setup() {
+@@ -1129,7 +1305,8 @@ drv_mac80211_setup() {
  		country chanbw distance \
  		txpower antenna_gain \
  		rxantenna txantenna \
@@ -458,7 +473,7 @@
  	json_get_values basic_rate_list basic_rate
  	json_get_values scan_list scan_list
  	json_select ..
-@@ -1180,6 +1351,7 @@ drv_mac80211_setup() {
+@@ -1180,6 +1357,7 @@ drv_mac80211_setup() {
  	no_ap=1
  	macidx=0
  	staidx=0
@@ -466,7 +481,7 @@
  
  	[ -n "$chanbw" ] && {
  		for file in /sys/kernel/debug/ieee80211/$phy/ath9k*/chanbw /sys/kernel/debug/ieee80211/$phy/ath5k/bwmode; do
-@@ -1219,6 +1391,16 @@ drv_mac80211_setup() {
+@@ -1219,6 +1397,16 @@ drv_mac80211_setup() {
  	for_each_interface "sta adhoc mesh" mac80211_set_noscan
  	[ -n "$has_ap" ] && mac80211_hostapd_setup_base "$phy"
  
@@ -483,7 +498,7 @@
  	mac80211_prepare_iw_htmode
  	for_each_interface "sta adhoc mesh monitor" mac80211_prepare_vif
  	NEWAPLIST=
-@@ -1249,8 +1431,22 @@ drv_mac80211_setup() {
+@@ -1249,8 +1437,22 @@ drv_mac80211_setup() {
  			}
  		fi
  		if [ "$no_reload" != "0" ]; then
@@ -506,7 +521,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 +1462,9 @@ drv_mac80211_setup() {
+@@ -1266,6 +1468,9 @@ drv_mac80211_setup() {
  	[ "${add_ap}" = 1 ] && sleep 1
  	for_each_interface "ap" mac80211_setup_vif