Re: [PATCH 4/4] mac80211: add AX support

2021-02-15 Thread Philip Prindeville
AX support. Cool.

Is there any UCI defaults stuff that needs to be touched for first boot and 
discovery?

Comments:



> On Feb 15, 2021, at 3:19 AM, John Crispin  wrote:
> 
> Signed-off-by: John Crispin 
> ---
> .../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() {
>   short_gi_40 \
>   max_amsdu \
>   dsss_cck_40
> + config_add_int \
> + he_su_beamformer \
> + he_su_beamformee \
> + he_mu_beamformer \
> + he_bss_color \
> + he_spr_sr_control \
> + he_spr_non_srg_obss_pd_max_offset
> }
> 
> drv_mac80211_init_iface_config() {
> @@ -69,6 +76,7 @@ drv_mac80211_init_iface_config() {
>   config_add_int max_listen_int
>   config_add_int dtim_period
>   config_add_int start_disabled
> + config_add_int he_twt_required he_spr_sr_control
> 
>   # mesh
>   config_add_string mesh_id
> @@ -96,6 +104,77 @@ mac80211_add_capabilities() {
>   export -n -- "$__var=$__out"
> }
> 
> +mac80211_add_he_capabilities() {
> + local __out= oifs
> +
> + oifs="$IFS"
> + IFS=:

Can't we just do:

local IFS=:

and get rid of oifs, etc.


% cat /tmp/foo
#!/bin/sh

func() {
  local IFS="b"

  echo "IFS=$IFS"
}

IFS="a"

echo "IFS=$IFS"
func

echo "IFS=$IFS"


% /tmp/foo
IFS=a
IFS=b
IFS=a
%




> + for capab in "$@"; do
> + set -- $capab
> + [ "$(($4))" -gt 0 ] || continue
> + [ "$(((0x$2) & $3))" -gt 0 ] || continue
> + append base_cfg "$1=1" "$N"
> + done
> + IFS="$oifs"
> +}
> +
> +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"
> +}
> +
> 

Re: [PATCH 4/4] mac80211: add AX support

2021-02-15 Thread Felix Fietkau


On 2021-02-15 11:19, John Crispin wrote:
> Signed-off-by: John Crispin 
> ---
>  .../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 

[PATCH 4/4] mac80211: add AX support

2021-02-15 Thread John Crispin
Signed-off-by: John Crispin 
---
 .../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() {
short_gi_40 \
max_amsdu \
dsss_cck_40
+   config_add_int \
+   he_su_beamformer \
+   he_su_beamformee \
+   he_mu_beamformer \
+   he_bss_color \
+   he_spr_sr_control \
+   he_spr_non_srg_obss_pd_max_offset
 }
 
 drv_mac80211_init_iface_config() {
@@ -69,6 +76,7 @@ drv_mac80211_init_iface_config() {
config_add_int max_listen_int
config_add_int dtim_period
config_add_int start_disabled
+   config_add_int he_twt_required he_spr_sr_control
 
# mesh
config_add_string mesh_id
@@ -96,6 +104,77 @@ mac80211_add_capabilities() {
export -n -- "$__var=$__out"
 }
 
+mac80211_add_he_capabilities() {
+   local __out= oifs
+
+   oifs="$IFS"
+   IFS=:
+   for capab in "$@"; do
+   set -- $capab
+   [ "$(($4))" -gt 0 ] || continue
+   [ "$(((0x$2) & $3))" -gt 0 ] || continue
+   append base_cfg "$1=1" "$N"
+   done
+   IFS="$oifs"
+}
+
+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"
+}
+
 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
+   ;;
+