[PATCH 4/4] mac80211: add AX support

Felix Fietkau nbd at nbd.name
Mon Feb 15 10:50:39 EST 2021


On 2021-02-15 11:19, John Crispin wrote:
> Signed-off-by: John Crispin <john at phrozen.org>
> ---
>  .../files/lib/netifd/wireless/mac80211.sh     | 193 +++++++++++++++++-
>  .../mac80211/files/lib/wifi/mac80211.sh       |  19 +-
>  2 files changed, 195 insertions(+), 17 deletions(-)
> 
> diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
> index 92c56afd24..b717770d5e 100644
> --- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
> +++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
> @@ -56,6 +56,13 @@ drv_mac80211_init_device_config() {
[...]
> +mac80211_get_seg0() {
> +	local ht_mode="$1"
> +	local seg0=0
> +
> +	case "$ht_mode" in
> +		40)
> +			if [ $freq -gt 5950 ] && [ $freq -le 7115 ]; then
> +				case "$(( ($channel / 4) % 2 ))" in
> +					1) seg0=$(($channel - 2));;
> +					0) seg0=$(($channel + 2));;
> +				esac
> +			elif [ $freq != 5935 ]; then
> +				case "$(( ($channel / 4) % 2 ))" in
> +					1) seg0=$(($channel + 2));;
> +					0) seg0=$(($channel - 2));;
> +				esac
> +			fi
> +			;;
> +		80)
> +			if [ $freq -gt 5950 ] && [ $freq -le 7115 ]; then
> +				case "$(( ($channel / 4) % 4 ))" in
> +					0) seg0=$(($channel + 6));;
> +					1) seg0=$(($channel + 2));;
> +					2) seg0=$(($channel - 2));;
> +					3) seg0=$(($channel - 6));;
> +				esac
> +			elif [ $freq != 5935 ]; then
> +				case "$(( ($channel / 4) % 4 ))" in
> +					1) seg0=$(($channel + 6));;
> +					2) seg0=$(($channel + 2));;
> +					3) seg0=$(($channel - 2));;
> +					0) seg0=$(($channel - 6));;
> +				esac
> +			fi
> +			;;
> +		160)
> +			if [ $freq -gt 5950 ] && [ $freq -le 7115 ]; then
> +				case "$channel" in
> +					1|5|9|13|17|21|25|29) seg0=15;;
> +					33|37|41|45|49|53|57|61) seg0=47;;
> +					65|69|73|77|81|85|89|93) seg0=79;;
> +					97|101|105|109|113|117|121|125) seg0=111;;
> +					129|133|137|141|145|149|153|157) seg0=143;;
> +					161|165|169|173|177|181|185|189) seg0=175;;
> +					193|197|201|205|209|213|217|221) seg0=207;;
> +				esac
> +			elif [ $freq != 5935 ]; then
> +				case "$channel" in
> +					36|40|44|48|52|56|60|64) seg0=50;;
> +					100|104|108|112|116|120|124|128) seg0=114;;
> +				esac
> +			fi
> +			;;
> +	esac
> +	printf "$seg0"
> +}
This function duplicates the seg0 that's already done for VHT+HE and
simply adds some extra conditions for 6 GHz. Those extra conditions
should be folded into the existing code.

> +
>  mac80211_hostapd_setup_base() {
>  	local phy="$1"
>  
> @@ -333,20 +412,105 @@ mac80211_hostapd_setup_base() {
>  	# 802.11ax
>  	enable_ax=0
>  	case "$htmode" in
> -		HE*) enable_ax=1 ;;
> +		HE20)   enable_ax=1
> +			if [ $freq -gt 5950 ] && [ $freq -le 7115 ]; then
> +				append base_cfg "op_class=131" "$N"
> +			fi
> +			;;
> +		HE40)
> +			enable_ax=1
> +			idx="$(mac80211_get_seg0 "40")"
> +			if [ $freq -ge 5180 ] && [ $freq != 5935 ]; then
> +				if [ $freq -gt 5950 ] && [ $freq -le 7115 ]; then
> +					append base_cfg "op_class=132" "$N"
> +				fi
> +				append base_cfg "he_oper_chwidth=0" "$N"
> +				append base_cfg "he_oper_centr_freq_seg0_idx=$idx" "$N"
> +			fi
> +			;;
> +		HE80)
> +			enable_ax=1
> +			idx="$(mac80211_get_seg0 "80")"
> +			if [ $freq != 5935 ]; then
> +				if [ $freq -gt 5950 ] && [ $freq -le 7115 ]; then
> +					append base_cfg "op_class=133" "$N"
> +				fi
> +				append base_cfg "he_oper_chwidth=1" "$N"
> +				append base_cfg "he_oper_centr_freq_seg0_idx=$idx" "$N"
> +			fi
> +			;;
> +		HE160)
> +			enable_ax=1
> +			idx="$(mac80211_get_seg0 "160")"
> +			if [ $freq != 5935 ]; then
> +				if [ $freq -gt 5950 ] && [ $freq -le 7115 ]; then
> +					append base_cfg "op_class=134" "$N"
> +				fi
> +				append base_cfg "he_oper_chwidth=2" "$N"
> +				append base_cfg "he_oper_centr_freq_seg0_idx=$idx" "$N"
> +			fi
> +		;;
>  	esac
Please remove this chunk entirely and replace it with a simple extra
case/esac for adding op_class.
he_oper_chwidth and he_oper_centr_freq_seg0_idx is already handled
elsewhere.

[...]
> @@ -401,6 +565,7 @@ mac80211_get_addr() {
>  
>  mac80211_generate_mac() {
>  	local phy="$1"
> +	local multiple_bssid="$2"
>  	local id="${macidx:-0}"
>  
>  	local ref="$(cat /sys/class/ieee80211/${phy}/macaddress)"
> @@ -425,6 +590,11 @@ mac80211_generate_mac() {
>  
>  	local oIFS="$IFS"; IFS=":"; set -- $ref; IFS="$oIFS"
>  
> +	[ "$multiple_bssid" -eq 1 ] && {
> +		printf "02:%s:%s:%s:%s:%02x" $b1 $2 $3 $4 $5 $macidx
This looks wrong to me. first byte should be:
b0 = orig_b0 | 0x2
b5 = orig_b5 & ~mac_mask | mac_idx
mac_mask should be set based on the number of mbssid entries to leave
enough room for macidx.

- Felix



More information about the openwrt-devel mailing list