2020年12月29日 星期二

Enable linux hostapd run on 5GHZ frequencies (also enable DFS support)

how to create virtual AP

1: create virtual wifi interface 

 iw dev wlp5s0 interface add wlan0_vap1 type __ap 

 

2: change mac address for new created interface (please note, last 8 bits must be 0 and cannot be the same as other devices. the maximum number of AP that the chipset can support can refer to output of iw list)

ip link set wlan0_vap1 address 02:05:b4:4a:fa:60

channels <= 1 means that the chipset only support 1 frequency. All softap need to run on exactly the same frequency. 

check supported frequencies: iw list

usually "no IR, radar detection" refers to the frequency cannot be used.
if the output includes "DFS state: usable", the frequency can be used only when kernel is supported.
* 5520 MHz [104] (23.0 dBm) (no IR, radar detection)
                          DFS state: usable (for 641 sec)
                    DFS CAC time: 60000 ms

To use DFS bands, ensure following kernel options are enabled.
"Configure standard kernel features (expert users)" under "General Setup"
"cfg80211 certification onus" under "Networking support" -> "Wireless"
"Ministrel 802.11ac support" under "Networking support" -> "Wireless"
"Atheros DFS support for certified platforms" under "Device Drivers" -> "Network device support" -> "Wireless LAN" -> "Atheros Wireless Cards"
"Atheros dynamic user regulatory hints" under "Device Drivers" -> "Network device support" -> "Wireless LAN" -> "Atheros Wireless Cards" (*)
"Atheros dynamic user regulatory testing" under "Device Drivers" -> "Network device support" -> "Wireless LAN" ->"Atheros Wireless Cards" (*)

Please note, crda package is required for DFS enablement.

to ignore regulation, apply openwrt patches to kernel.
1: download kernel source
2: download openwrt patches
3: change to extracted kernel source directoy
4: copy downloaded openwrt paches to working directory

patch -p1 <./mac80211/patches/ath/402-ath_regd_optional.patch 

patch -p1 <./mac80211/patches/ath/404-regd_no_assoc_hints.patch 


sample configuration file: only need to focus on vht_oper_centr_freq_seg0_idx and channel setup

interface=wlan0_vap1
driver=nl80211
logger_syslog=-1
logger_syslog_level=0
logger_stdout=-1
logger_stdout_level=0
country_code=US
ieee80211d=1
ssid=uCPE1
channel=116
hw_mode=a
ieee80211h=1
ieee80211ac=1
ht_capab=[DSSS_CCK-40][LDPC][TX-STBC][RX-STBC-1][MAX-AMSDU-7935][HT40+][SHORT-GI-40][SHORT-GI-20]
wme_enabled=1
vht_oper_centr_freq_seg0_idx=122
vht_oper_chwidth=1
vht_capab=[TX-STBC-2BY1][RX-STBC-1][RXLDPC][RX-ANTENNA-PATTERN][TX-ANTENNA-PATTERN][MAX-MPDU-11454][MAX-A-MPDU-LEN-EXP-7][SHORT-GI-80]
ieee80211n=1
macaddr_acl=0
max_num_sta=100
wpa=2
rsn_pairwise=CCMP
auth_algs=1
wpa_passphrase=test12345
wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256
tx_queue_data3_aifs=7
tx_queue_data3_cwmin=15
tx_queue_data3_cwmax=1023
tx_queue_data3_burst=0
tx_queue_data2_aifs=3
tx_queue_data2_cwmin=15
tx_queue_data2_cwmax=63
tx_queue_data2_burst=0
tx_queue_data1_aifs=1
tx_queue_data1_cwmin=7
tx_queue_data1_cwmax=15
tx_queue_data1_burst=3.0
tx_queue_data0_aifs=1
tx_queue_data0_cwmin=3
tx_queue_data0_cwmax=7
tx_queue_data0_burst=1.5
wmm_enabled=1
wmm_ac_bk_cwmin=4
wmm_ac_bk_cwmax=10
wmm_ac_bk_aifs=7
wmm_ac_bk_txop_limit=0
wmm_ac_bk_acm=0
wmm_ac_be_aifs=3
wmm_ac_be_cwmin=4
wmm_ac_be_cwmax=10
wmm_ac_be_txop_limit=0
wmm_ac_be_acm=0
wmm_ac_vi_aifs=2
wmm_ac_vi_cwmin=3
wmm_ac_vi_cwmax=4
wmm_ac_vi_txop_limit=94
wmm_ac_vi_acm=0
wmm_ac_vo_aifs=2
wmm_ac_vo_cwmin=2
wmm_ac_vo_cwmax=3
wmm_ac_vo_txop_limit=47
wmm_ac_vo_acm=0

dracut module for squashfs plus overlay

 kernel parameter:

QCT QCT.session=devel

dracut module

2020年11月2日 星期一

ipxe example

#!ipxe

#set QCTFILENAME http://10.5.15.10/test/echo.ipxe

#set bdf 0000:3d:00.3

#set QCTBDF 0000:00:08.0

#set QCTMAC 08:00:27:6b:53:eb

#set QCTMAC 08:00:27:89:ea:ad

set QCTIP 10.102.14.110

set QCTNETMASK 255.255.255.0

set QCTGATEWAY 10.102.14.1

set QCTFILENAME file:/utils/rhel8.2.ipxe

set QCTDNS 8.8.8.8


========================================================================

 #!ipxe

imgfree

set base-url http://10.7.21.51/adt

initrd ${base-url}/rhel8.2/isolinux/initrd.img

chain ${base-url}/rhel8.2/isolinux/vmlinuz initrd=initrd.img ro fips=1 inst.sshd inst.ks=${base-url}/rhel8.php inst.stage2=${base-url}/rhel8.2/ ip=${ip}::${gateway}:${netmask}:::none::${mac}

2020年11月1日 星期日

ipxe script example for nic selection

 #!ipxe

#set bdf 0000:3d:00.3

#set QCTBDF 0000:00:08.0

#set QCTMAC 08:00:27:6b:53:eb

#set QCTMAC 08:00:27:89:ea:ad

#set QCTIP 10.5.12.120

#set QCTNETMASK 255.255.255.0

#set QCTGATEWAY 10.5.12.1

#set QCTFILENAME http://10.5.15.10/test/bdf.ipxe

#set QCTDNS 8.8.8.8


chain file:/utils/QCT.ipxe ||

console


isset ${QCTFILENAME} && set filename ${QCTFILENAME} ||

isset ${QCTBDF} && goto boot_via_bdf ||

isset ${QCTMAC} && goto boot_via_mac ||

goto default_boot

exit


:exit_ipxe

exit


:boot_via_bdf

echo BOOT via BDF

set idx:int32 0

set loop_count:int32 1

:loop_bdf isset ${net${idx}/mac} || goto exit_ipxe

  echo net${idx} is a ${net${idx}/chip} with MAC ${net${idx}/mac}  bdf ${net${idx}/busloc:busdevfn}

  iseq ${net${idx}/busloc:busdevfn} ${QCTBDF} && set target_dev net${idx} ||

  isset ${target_dev} && goto configure_ip ||

  inc idx && goto loop_bdf

#:loop_done

exit



:boot_via_mac

echo BOOT via MAC

set idx:int32 0

set loop_count:int32 1

:loop_mac isset ${net${idx}/mac} || goto exit_ipxe

  #echo net${idx} is a ${net${idx}/chip} with MAC ${net${idx}/mac} bdf ${net${idx}/busloc:busdevfn}

  iseq ${net${idx}/mac} ${QCTMAC} && set target_dev net${idx} ||

  isset ${target_dev} && goto configure_ip ||

  inc idx && goto loop_mac

#:loop_done

exit



:configure_ip

  echo Configure IP address for ${target_dev}

  isset ${QCTDNS} && set ${target_dev}/dns ${QCTDNS} ||

  isset ${QCTIP} || goto use_dhcp

  i ||sset ${QCTNETMASK} || goto use_dhcp

  isset ${QCTGATEWAY} || goto use_dhcp

  goto use_static_ip

exit


:use_dhcp

  echo use dhcp

  dhcp ${target_dev} || goto default_boot

  isset ${QCTDNS} && set ${target_dev}/dns ${QCTDNS} ||

  isset ${QCTFILENAME} && set filename ${QCTFILENAME} ||

  chain -r -a ${filename} ||

exit


:use_static_ip

  echo use static ip

  echo set ${target_dev}/ip ${QCTIP}

  set ${target_dev}/ip ${QCTIP}

  echo set ${target_dev}/netmask ${QCTNETMASK}

  set ${target_dev}/netmask ${QCTNETMASK}

  echo set ${target_dev}/gateway ${QCTGATEWAY}

  set ${target_dev}/gateway ${QCTGATEWAY}

  echo set ${filename}

  chain -r -a ${filename} ||

exit


:default_boot

  clear target_dev

  isset ${QCTIP} || goto default_dhcp

  isset ${QCTNETMASK} || goto default_dhcp

  isset ${QCTGATEWAY} || goto default_dhcp

  goto default_static_ip

exit


:default_dhcp

  echo Default DHCP

  set idx:int32 0

  set loop_count:int32 1

  :loop_dhcp isset ${net${idx}/mac} || goto exit_ipxe

   ifopen net${idx}

   echo Connectivity check for net${idx}

   dhcp && goto chain_boot ||

   ifclose net${idx}

   inc idx

   goto loop_dhcp

  shell

exit


:default_static_ip

  echo Default Static

  set idx:int32 0

  set loop_count:int32 1

  :loop_static isset ${net${idx}/mac} || goto exit_ipxe

   ifopen net${idx}

   echo set net${idx}/ip ${QCTIP}

   set net${idx}/ip ${QCTIP}

   echo set net${idx}/netmask ${QCTNETMASK}

   set net${idx}/netmask ${QCTNETMASK}

   echo set net${idx}/gateway ${QCTGATEWAY}

   set net${idx}/gateway ${QCTGATEWAY}

   echo Connectivity check for net${idx}

   ping -c 2 -q ${QCTGATEWAY} && goto chain_boot ||

   ifclose net${idx}

   inc idx

   goto loop_static

  shell

exit


:chain_boot

echo QCT Chain Boot

sleep 2

chain -r -a ${filename}

shell

exit