From f18705756b7000d16646fbf0bde46e91dfa70d87 Mon Sep 17 00:00:00 2001 From: Fugang Duan Date: Fri, 11 Sep 2020 14:42:57 +0800 Subject: [PATCH] mxm_wifiex: update nxp mxm_wifiex sdk to 186.p4 changes: 1. Added get_txpwrlimit cmd to mlanutl 2. Added source code of mlanutl for supported commands 3. Removed unnecessary .conf files from bin_wlan/config folder Signed-off-by: Fugang Duan --- mxm_wifiex/wlan_src/mapp/mlanconfig/Makefile | 2 - .../mapp/mlanconfig/config/11axcfg.conf | 49 - .../mapp/mlanconfig/config/11n_2040coex.conf | 21 - .../mapp/mlanconfig/config/auto_tx.conf | 54 - .../mlanconfig/config/band_steer_cfg.conf | 16 - .../mapp/mlanconfig/config/bg_scan.conf | 157 - .../mlanconfig/config/bg_scan_wifidirect.conf | 88 - .../mapp/mlanconfig/config/crypto_test.conf | 58 - .../mapp/mlanconfig/config/cwmode.conf | 51 - .../mapp/mlanconfig/config/debug.conf | 89 - .../config/ed_mac_ctrl_V2_8887.conf | 29 - .../config/ed_mac_ctrl_V2_8897.conf | 29 - .../config/ed_mac_ctrl_V3_8977.conf | 23 - .../config/ed_mac_ctrl_V3_8978.conf | 23 - .../config/ed_mac_ctrl_V3_8997.conf | 23 - .../config/ed_mac_ctrl_V3_909x.conf | 23 - .../mapp/mlanconfig/config/init_cfg.conf | 14 - .../wlan_src/mapp/mlanconfig/config/mef.conf | 167 - .../mapp/mlanconfig/config/mef_mdns.conf | 204 - .../mlanconfig/config/mef_ws_discovery.conf | 204 - .../wlan_src/mapp/mlanconfig/config/mem.conf | 17 - .../mapp/mlanconfig/config/mgmt_frame.conf | 30 - .../mapp/mlanconfig/config/mgmtfilter.conf | 15 - .../mapp/mlanconfig/config/or_data.conf | 7 - .../mapp/mlanconfig/config/pad_cfg.conf | 29 - .../mapp/mlanconfig/config/requesttpc.conf | 15 - .../mapp/mlanconfig/config/robust_btc.conf | 211 - .../mlanconfig/config/rutxpower_limit.conf | 674 - .../mapp/mlanconfig/config/sdio_pulldown.conf | 27 - .../mapp/mlanconfig/config/small_debug.conf | 62 - .../wlan_src/mapp/mlanconfig/config/smc.conf | 124 - .../wlan_src/mapp/mlanconfig/config/ssu.conf | 13 - .../mapp/mlanconfig/config/subevent.conf | 103 - .../mapp/mlanconfig/config/tspecs.conf | 100 - .../mapp/mlanconfig/config/turbo_mode.conf | 12 - .../mapp/mlanconfig/config/tx_ctrl.conf | 58 - ...imit_cfg.conf => txpwrlimit_cfg_8987.conf} | 296 +- .../mapp/mlanconfig/config/txrate_cfg.conf | 172 - .../mapp/mlanconfig/config/wifi_mod_para.conf | 1 - .../wlan_src/mapp/mlanconfig/mlanconfig.c | 2963 --- .../wlan_src/mapp/mlanconfig/mlanconfig.h | 249 - .../wlan_src/mapp/mlanconfig/mlanhostcmd.c | 923 - .../wlan_src/mapp/mlanconfig/mlanhostcmd.h | 385 - .../wlan_src/mapp/mlanconfig/mlanmisc.c | 1162 - .../wlan_src/mapp/mlanconfig/mlanmisc.h | 705 - mxm_wifiex/wlan_src/mapp/mlanutl/Makefile | 1 - .../wlan_src/mapp/mlanutl/mlanhostcmd.c | 895 - .../wlan_src/mapp/mlanutl/mlanhostcmd.h | 134 - .../wlan_src/mapp/mlanutl/mlanoffload.c | 3051 --- .../wlan_src/mapp/mlanutl/mlanoffload.h | 514 - .../wlan_src/mapp/mlanutl/mlanregclass.c | 540 - .../wlan_src/mapp/mlanutl/mlanregclass.h | 100 - .../wlan_src/mapp/mlanutl/mlanroamagent.c | 3670 --- .../wlan_src/mapp/mlanutl/mlanroamagent.h | 315 - .../wlan_src/mapp/mlanutl/mlanscanagent.c | 841 - .../wlan_src/mapp/mlanutl/mlanscanagent.h | 150 - mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.c | 19564 +--------------- mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.h | 2770 +-- mxm_wifiex/wlan_src/mapp/mlanutl/timestamp.c | 414 - mxm_wifiex/wlan_src/mapp/mlanutl/timestamp.h | 55 - 60 files changed, 898 insertions(+), 41793 deletions(-) delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/11axcfg.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/11n_2040coex.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/auto_tx.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/band_steer_cfg.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/bg_scan.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/bg_scan_wifidirect.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/crypto_test.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/cwmode.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/debug.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V2_8887.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V2_8897.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_8977.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_8978.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_8997.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_909x.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/init_cfg.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/mef.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/mef_mdns.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/mef_ws_discovery.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/mem.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/mgmt_frame.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/mgmtfilter.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/or_data.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/pad_cfg.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/requesttpc.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/robust_btc.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/rutxpower_limit.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/sdio_pulldown.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/small_debug.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/smc.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/ssu.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/subevent.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/tspecs.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/turbo_mode.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/tx_ctrl.conf rename mxm_wifiex/wlan_src/mapp/mlanconfig/config/{txpwrlimit_cfg.conf => txpwrlimit_cfg_8987.conf} (51%) delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/config/txrate_cfg.conf delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/mlanconfig.c delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/mlanconfig.h delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/mlanhostcmd.c delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/mlanhostcmd.h delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/mlanmisc.c delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanconfig/mlanmisc.h delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanutl/mlanhostcmd.c delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanutl/mlanhostcmd.h delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanutl/mlanoffload.c delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanutl/mlanoffload.h delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanutl/mlanregclass.c delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanutl/mlanregclass.h delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanutl/mlanroamagent.c delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanutl/mlanroamagent.h delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanutl/mlanscanagent.c delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanutl/mlanscanagent.h delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanutl/timestamp.c delete mode 100644 mxm_wifiex/wlan_src/mapp/mlanutl/timestamp.h diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/Makefile b/mxm_wifiex/wlan_src/mapp/mlanconfig/Makefile index fde2059..7e56b5c 100644 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/Makefile +++ b/mxm_wifiex/wlan_src/mapp/mlanconfig/Makefile @@ -22,8 +22,6 @@ CFLAGS := $(filter-out -I$(KERNELDIR)%, $(CFLAGS)) # # List of application executables to create # -libobjs:= mlanconfig.o mlanhostcmd.o mlanmisc.o -exectarget=mlanconfig TARGETS := $(exectarget) # diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/11axcfg.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/11axcfg.conf deleted file mode 100644 index 59ef45f..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/11axcfg.conf +++ /dev/null @@ -1,49 +0,0 @@ -#Band config -[Band] -# band config, 1: 2.4G, 2: 5G -02 -[/Band] -# HE Capability -[HECap] -# ID -ff 00 -# Length -1a 00 -# he capability id -23 -# HE MAC capability info -01 00 00 82 00 08 -# HE PHY capability info -04 70 7e c9 fd 01 a0 0e 03 3d 00 -# Tx Rx HE-MCS NSS support -fa ff fa ff -# PPE Thresholds (optional) -# PE: 16 us -e1 ff c7 71 -[/HECap] -####### UAP HE cap ############ -#Band config -#[Band] -# band config, 1: 2.4G, 2: 5G -#02 -#[/Band] -# HE Capability -#[HECap] -# ID -#ff 00 -# Length -#1a 00 -# he capability id -#23 -# HE MAC capability info -#00 00 00 00 00 00 -# Enable PPE Threshold -#04 20 0e c9 fe 0b a0 0e 01 20 00 -# Tx Rx HE-MCS NSS support -#fa ff fa ff -# PPE Thresholds (optional) -# PE: 16 us -#e1 ff c7 71 -#[/HECap] - - diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/11n_2040coex.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/11n_2040coex.conf deleted file mode 100644 index 1e8cda7..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/11n_2040coex.conf +++ /dev/null @@ -1,21 +0,0 @@ -# File : 11n_2040coex.conf - -######################### 20/40 Coex command ################## -2040coex={ - CmdCode=0x00e9 # do NOT change this line - - 2040CoexTlvType:1=0x48 - 2040CoexTlvLen:1={ - 2040CoexElement:1=0x04 - } - - 2040BssIntlChanTlvType:1=0x49 - 2040BssIntlChanTlvLen:1={ - RegulatoryDomain:1=32 # USA: 32 (1-7), 33 (5-11) - ChannelNum:1=1 - ChannelNum:1=2 - # ... - } -} - -################################################################## diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/auto_tx.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/auto_tx.conf deleted file mode 100644 index 6c35540..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/auto_tx.conf +++ /dev/null @@ -1,54 +0,0 @@ -# File : auto_tx.conf - -######################### Auto-TX command ################## -auto_tx_get={ - CmdCode=0x0082 # do NOT change this line - - Action:2=0 # GET -} - -auto_tx_unreg={ - CmdCode=0x0082 # do NOT change this line - - Action:2=1 # SET -} - -nat_keep_alive={ - CmdCode=0x0082 # do NOT change this line - - Action:2=1 # SET - - AutoTxTlvType:2=0x0118 - AutoTxTlvLength:2={ # 58 = 6 + 52 (FrameLen) - Interval:2=2 # 1 - 3600 seconds - Priority:1=7 # Priority, ignored if non-WMM - Reserved:1=0 - FrameLength:2={ # 52 = 6 (DA) + 6 (SA) + 2 + 38 (Length) - DestMacAddr:6='0x00,0x40,0xf4,0xbf,0x24,0xee' - SrcMacAddr:6='0x00,0x00,0x00,0x00,0x00,0x00' - Length:2='0x00,38' # 38 = 8 (SNAP hdr) + 29 (IP) + 1 (padding) - DSAP:1=0xaa # SNAP header - SSAP:1=0xaa - Ctrl:1=0x03 - SNAP_OUI:3='0x00,0x00,0x00' - SNAP_PID:2='0x08,0x00' # IP Packet - IPv4:1=0x45 - IP_TOS:1=0x00 - IP_LEN:2='0x00,29' # IP hdr 20 + payload 9 = 29 - IP_ID:2=0xefbe - IP_Flag_FragOffset:2=0x0000 - IP_TTL:1=128 - IP_Prot:1=17 # UDP protocol - IPhdr_cksum:2=0xc5f9 # may need re-calculation if changed - IPsrcAddr:4='192,168,0,201' # 192.168.0.201 - IPdstAddr:4='192,168,0,1' # 192.168.0.1 - UDPsrcPort:2='0x11,0x94' # 4500 - UDPdstPort:2='0x11,0x94' # 4500 - UDPlength:2='0x00,9' # UDP hdr 8 + payload 1 = 9 - UDPcksum:2=0x985b # may need re-calculation if changed - UDPpayload:1=0xff - padding:1=0 # MAC Padding for 32bit alignment, set to 0 - } - } -} -######################### Auto-TX command ################## diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/band_steer_cfg.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/band_steer_cfg.conf deleted file mode 100644 index 2c61e74..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/band_steer_cfg.conf +++ /dev/null @@ -1,16 +0,0 @@ -# File : band_steering_cfg.conf - - -######################### band steering configure command ################## -band_steering_cfg={ - CmdCode=0x026f # do NOT change this line - - Action:1=7 # Action = BIT0|BIT1|BIT2, - # BIT0: State take effect - # BIT1: or this bit if want change Block2gPrbReq - # BIT2: OR this bit if want change MaxBtmReqAllowed - State:1 = 1 # 0: disable Band steering, 1: enable bandsteering - Block2gPrbReq:1=5 # 0~15, the number of probe requests to block before allowing response for the STA - MaxBtmReqAllowed:1=3 # 0~15,max bss_transition requests to station -} - diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/bg_scan.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/bg_scan.conf deleted file mode 100644 index 7bc088e..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/bg_scan.conf +++ /dev/null @@ -1,157 +0,0 @@ -# File : bg_scan.conf - -######################### BG Scan Configuration command ################## -########### Sample configuration for Get BG Scan Configuration ##################### -#bgscfg={ -# CmdCode=0x006b # do NOT change this line -# Action:1=0 # 0- Get, 1- Set -# ConfigType:1=0 # 0- normal BG Scan config, 1-PPS or UAPSD BG Scan config -# Enable:1=1 # 0- Disable, 1-Enable -# BssType:1=0 # 1 - Infrastructure,2 - IBSS,3 - Any -# ChannelsPerScan:1=0 # Number of Channel to scan at one scan; maximum 14 -# Reserved1:3=0 -# ScanInterval:4=0 # Interval between consecutive scan (in milliseconds) -# Reserved2:4=0 -# ReportConditions:4=0 # bit0 - SSID match - # bit1 - SNR above SNR threshold - # bit2 - RSSI above RSSI threshold - # bit31 - All channels scanned at least once -# Reserved3:2=0 -#} - -########### SET BG Scan Configuration ##################### -bgscfg={ - CmdCode=0x006b # do NOT change this line - Action:1=1 # 0- Get, 1- Set - ConfigType:1=0 # 0- normal BG Scan config, 1-PPS or UAPSD BG Scan config - Enable:1=1 # 0- Disable, 1-Enable - BssType:1=3 # 1 - Infrastructure,2 - IBSS,3 - Any - ChannelsPerScan:1=14 # Number of Channel to scan at one scan; maximum 14 - Reserved1:3=0 - ScanInterval:4=1000 # Interval between consecutive scan (in milliseconds) - Reserved2:4=0 - ReportConditions:4=1 # bit0 - SSID match - # bit1 - SNR above SNR threshold - # bit2 - RSSI above RSSI threshold - # bit31 - All channels scanned at least once - Reserved3:2=0 - - # SSID parameter set: - # - # MaxSSIDLen entries: - # - # 1. MaxSSIDLen:1=0x00 - to denote match AP name exactly, - # generate SSID specific probes - # 2. MaxSSIDLen:1=maxlen - to denote AP name will be use to base match the - # SSID and SSID's max length is 'maxlen', - # do not generate SSID specific probes - # 3. MaxSSIDLen:1=wildcard match char ('*' or '?') - # - to denote wildcard AP name will be use to match the SSID - # 4. MaxSSIDLen:1=0xff - to denote unix pattern matching - # - # SSID entries: - # - # SSID="AP_NAME" - to mention the SSID to match - - # SSID Examples: - # - # - # Match SSID name "NXPAP" exactly, generate SSID specific probes - # - SSIDHeaderType:2=0x0112 - SSIDHeaderLen:2={ - MaxSSIDLen:1=0x00 - SSID:9="NXPAP" - } - - # - # NXPAP will be use to base match the SSID and SSID's max length is 12 - # -# SSIDHeaderType:2=0x0112 -# SSIDHeaderLen:2={ -# MaxSSIDLen:1=0x0c -# SSID:9="NXPAP" -# } - - # - # Match "NXPAP*" where '*' is a single char - # -# SSIDHeaderType:2=0x0112 -# SSIDHeaderLen:2={ -# MaxSSIDLen:1='*' -# SSID:10="NXPAP*" -# } - - # - # Match "Mar?ell*" with unix pattern matching - # -# SSIDHeaderType:2=0x0112 -# SSIDHeaderLen:2={ -# MaxSSIDLen:1=0xff # For unix pattern matching -# SSID:8="Mar?ell*" -# } - - # Number Probe requests to be sent for broadcast and - # for each SSID specific scan required. - # - # If any SSID in the list has a non-zero modifier (wildcard match char, - # unix pattern match, maxlen), "Numprobes" of broadcast probe requests - # will be transmitted once per channel and the results matched against - # all entries. - # - # Set to 0 to use global scan probes setting - # - ProbeHeaderType:2=0x0102 - ProbeHeaderLen:2={ - NumProbes:2=2 - } - - # ChannelList contains the channels to scan - # The ChannelList should be specified in the form of - # - # RadioType, ChanNumber, ScanType, MinScanTime, ScanTime; - # - # RadioType - 0 [B/G Band], 1 [A Band] - # ScanType - 2 [Active], 3 [Passive] - # - - ChannHeaderType:2=0x0101 - ChannHeaderLen:2={ - Chan1_RadioType:1=0 - Chan1_ChanNumber:1=10 - Chan1_ScanType:1=2 - Chan1_MinScanTime:2=10 - Chan1_ScanTime:2=100 - - Chan2_RadioType:1=0 - Chan2_ChanNumber:1=6 - Chan2_ScanType:1=3 - Chan2_MinScanTime:2=10 - Chan2_ScanTime:2=100 - } - - # SNR threshold used when ReportConditions bit1 is set - SNRHeaderType:2=0x0105 - SNRHeaderLen:2={ - SNRValue:1=40 #SNR Thereshold Value - SNRFreq:1=0 - } - - # RSSI threshold used when ReportConditions bit2 is set - # - # Threshold is absolute value and match value would - # therefore be less than or equal to trigger a report - RSSIHeaderType:2=0x0104 - RSSIHeaderLen:2={ - RSSIValue:1=50 #RSSI Thereshold Value - RSSIFreq:1=0 - } - - # StartLaterValue: 0 - BGScan start immediately - # 1 - BGScan will start later after "Scan Interval" - StartLaterHeaderType:2=0x011e - StartLaterHeaderLen:2={ - StartLaterValue:2=0 - } -} -######################### BG Scan Configuration command ################## diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/bg_scan_wifidirect.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/bg_scan_wifidirect.conf deleted file mode 100644 index f480a9c..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/bg_scan_wifidirect.conf +++ /dev/null @@ -1,88 +0,0 @@ -# File : bg_scan_wifidirect.conf - -######################### BG Scan Configuration command ################## -########### SET BG Scan Configuration ##################### -bgscfg={ - CmdCode=0x006b # do NOT change this line - Action:1=1 # 0- Get, 1- Set - ConfigType:1=0 # 0- normal BG Scan config, 1-PPS or UAPSD BG Scan config - Enable:1=1 # 0- Disable, 1-Enable - BssType:1=3 # 1 - Infrastructure,2 - IBSS,3 - Any - ChannelsPerScan:1=3 # Number of Channel to scan at one scan; maximum 14 - Reserved1:3=0 - ScanInterval:4=1000 # Interval between consecutive scan (in milliseconds) - StoreCondition:4=1 # 1 - SSID match (bit 0) - # 2 - SSID match AND SNR above SNR threshold (bit 1) - ReportConditions:4=1 # 1 - SSID match (bit 0) - # 2 - SSID match AND SNR above SNR threshold (bit 1) - Reserved3:2=0 - - # SSID parameter set: - # - SSIDHeaderType:2=0x0112 - SSIDHeaderLen:2={ - MaxSSIDLen:1=0x00 - SSID:7="DIRECT-" - } - - # Number Probe requests to be sent for broadcast and - # for each SSID specific scan required. - # - # If any SSID in the list has a non-zero modifier (wildcard match char, - # unix pattern match, maxlen), "Numprobes" of broadcast probe requests - # will be transmitted once per channel and the results matched against - # all entries. - # - # Set to 0 to use global scan probes setting - # - ProbeHeaderType:2=0x0102 - ProbeHeaderLen:2={ - NumProbes:2=2 - } - - # ChannelList contains the channels to scan - # The ChannelList should be specified in the form of - # - # RadioType, ChanNumber, ScanType, MinScanTime, ScanTime; - # - # RadioType - 0 [B/G Band], 1 [A Band] - # ScanType - 2 [Active], 3 [Passive] - # - - ChannHeaderType:2=0x0101 - ChannHeaderLen:2={ - Chan1_RadioType:1=0 - Chan1_ChanNumber:1=1 - Chan1_ScanType:1=2 - Chan1_MinScanTime:2=10 - Chan1_ScanTime:2=100 - - Chan2_RadioType:1=0 - Chan2_ChanNumber:1=6 - Chan2_ScanType:1=2 - Chan2_MinScanTime:2=10 - Chan2_ScanTime:2=100 - - Chan3_RadioType:1=0 - Chan3_ChanNumber:1=11 - Chan3_ScanType:1=2 - Chan3_MinScanTime:2=10 - Chan3_ScanTime:2=100 - } - - # SNR threshold to match, when StoreCondition - # or ReportConditions been set to 2 - SNRHeaderType:2=0x0105 - SNRHeaderLen:2={ - SNRValue:1=40 #SNR Thereshold Value - SNRFreq:1=0 - } - - # StartLaterValue: 0 - BGScan start immediately - # 1 - BGScan will start later after "Scan Interval" - StartLaterHeaderType:2=0x011e - StartLaterHeaderLen:2={ - StartLaterValue:2=0 - } -} -######################### BG Scan Configuration command ################## diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/crypto_test.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/crypto_test.conf deleted file mode 100644 index d35812f..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/crypto_test.conf +++ /dev/null @@ -1,58 +0,0 @@ -# File : crypto_test.conf - -######################### crypto_test command configuration ################## -# support algorithm:1-RC4, 2-AES, 3-AES_KEY_WRAP,4-AES-CCM - -crypto_test={ - CmdCode=0x0078 # do NOT change this line - #EncDec: 0-Decrypt, 1-Encrypt - EncDec:2=0 - #Algorithm: 1-RC4, 2-AES, 3-AES_KEY_WRAP - Algorithm:2=1 - #KeyIVLength: Length of KeyIV (bytes) - KeyIVLength:2=8 - #KeyIV: Key IV - KeyIV:32='0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11' - #KeyLength: Length of Key (bytes) - KeyLength:2=16 - #Key: Key - Key:32='0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22' - #DataType: DataType - DataType:2=0x0111 - #DataLength: Data Length - DataLength:2={ - #Data: Data - Data:8='0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33' - } -} - -#####Sample crypto_test command configuration for AES-CCM algorithm ######### - -#crypto_test={ -# CmdCode=0x0078 # do NOT change this line -# #EncDec: 0-Decrypt, 1-Encrypt -# EncDec:2=1 -# #Algorithm: 4-AES-CCM -# Algorithm:2=4 -# #KeyLength: Length of Key (bytes) -# KeyLength:2=16 -# #Key: Key -# Key:32='0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22' -# #NonceLength: Length of Nonce (bytes) -# NonceLength:2=10 -# #Nonce: Nonce -# Nonce:14='0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11' -# #AADLength: Length of AAD (bytes) -# AADLength:2=12 -# #AAD: AAD -# AAD:32='0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33' -# #DataType: DataType -# DataType:2=0x0111 -# #DataLength: Data Length -# DataLength:2={ -# #Data: Data -# Data:8='0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33' -# } -#} - -######################### End of crypto_test configuration command ################## diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/cwmode.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/cwmode.conf deleted file mode 100644 index 1f245a2..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/cwmode.conf +++ /dev/null @@ -1,51 +0,0 @@ -#CW_MODE settings configuration -# -CW_MODE={ -#Mode of operation 0: Disable current Tx Mode, 1: Continuous Tx Packet, 2: Continuous Wave/Tone -Mode=1 -#Channel number -Channel=6 -#channel Info -#bit [3:0] - channel offset 0: no secondary channel, 1: secondary channel above, 2: reserved, 3: secondary channel below -#bit [4:7] - channel band 0: 2.4G, 1: 5G, 2: 4G, 3: reserved -Chaninfo=0x00 -#Tx power for Cont Tx in dbm -TxPower=12 -# Packet Length for Cont Tx -# legacy rates: upto 2312, HT/VHT rates: upto 8K -PktLength=2048 -#RateInfo for Cont Tx -RateInfo=0x0000 -#rateInfo = 0x0732 : format = VHT, Bandwidth = 80MHz, datarate/MCS index = MCS7 -#rateInfo = 0x0000 : format = legacy, Bandwidth = 20MHz, datarate/MCS index = 1Mbps -#rateInfo = 0x0521 : format = HT, Bandwidth = 40MHz, datarate/MCS index = MCS5 -#rateInfo = 0x4521 : format = HT, Bandwidth = 40MHz, datarate/MCS index = MCS5, NSS = 1 -#rateInfo = 0x8921 : format = HT, Bandwidth = 40MHz, datarate/MCS index = MCS9, NSS = 2 -#bit [1:0] - Format 0: legacy, 1: 11n (HT), 2: 11ac (VHT) -#bit 2 - STBC (Not used for Cont Tx test) -#bit 3 - Beamforming (Not used for Cont Tx test) -#bit [5:4] - Bandwidth 0: 20MHz, 2: 40MHz, 3: 80MHz -#bit [7:6] - reserved -#bit [13:8] - index : data rate or MCS -#bit [15:14]- NSS (Used for 2x2 chips). Used in FW only for 2x2 chips. -# can take following values. -#If is 0 (LG), #If is 1 (HT) #If is 2 (VHT) -# NSS = 1 NSS = 1 or 2 -# 0 1 Mbps 0 MCS0 0 MCS0 -# 1 2 Mbps 1 MCS1 1 MCS1 -# 2 5.5 Mbps 2 MCS2 2 MCS2 -# 3 11 Mbps 3 MCS3 3 MCS3 -# 5 6 Mbps 4 MCS4 4 MCS4 -# 6 9 Mbps 5 MCS5 5 MCS5 -# 7 12 Mbps 6 MCS6 6 MCS6 -# 8 18 Mbps 7 MCS7 7 MCS7 -# Used only for NSS = 2 -# 9 24 Mbps 8 MCS8 -# 10 36 Mbps 9 MCS9 -# 11 48 Mbps 10 MCS10 -# 12 54 Mbps 11 MCS11 -# 12 MCS12 -# 13 MCS13 -# 14 MCS14 -# 15 MCS15 -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/debug.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/debug.conf deleted file mode 100644 index 09d40dc..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/debug.conf +++ /dev/null @@ -1,89 +0,0 @@ -# -# File: debug.conf -# 11ax configuration commands -# - -enable_thermal_mgmt={ - CmdCode=0x008b # do NOT change this line - Action:2=1 # 1 - SET - SUBID:2=0x113 # THERMAL_MANAGEMENT - Value:1=1 # 1 -- ENABLE; -} - -disable_thermal_mgmt={ - CmdCode=0x008b # do NOT change this line - Action:2=1 # 1 - SET - SUBID:2=0x113 # THERMAL_MANAGEMENT - Value:1=0 # 0 -- DISABLE; -} - -get_thermal_mgmt={ - CmdCode=0x008b # do NOT change this line - Action:2=0 # 0 - GET - SUBID:2=0x113 # THERMAL_MANAGEMENT - Value:1=0 # 1 -- ENABLE; - # 0 -- DISABLE; -} - -stop_su={ - CmdCode=0x008b # do NOT change this line - Action:2=1 # 1 - SET - SUBID:2=0x101 # DOT11AX_ULOFDMA - Value:4=1 # 1 -- stop_su; - # 0 -- resume su; -} - -start_su={ - CmdCode=0x008b # do NOT change this line - Action:2=1 # 1 - SET - SUBID:2=0x101 # DOT11AX_ULOFDMA - Value:4=0 # 1 -- stop_su; - # 0 -- resume su; -} - -stop_forceRTS={ - CmdCode=0x008b # do NOT change this line - Action:2=1 # 1 - SET - SUBID:2=0x104 # DOT11AX_ULOFDMA - Value:1=0 # 1 -- stop forceRTS; - # 0 -- start forceRTS; -} - -start_forceRTS={ - CmdCode=0x008b # do NOT change this line - Action:2=1 # 1 - SET - SUBID:2=0x104 # DOT11AX_ULOFDMA - Value:1=1 # 1 -- start forceRTS; - # 0 -- stop forceRTS; -} - -set_nonampdu_txctrl_watermark={ - CmdCode=0x008b # do NOT change this line - Action:2=1 # 1 - SET - SUBID:2=0x116 # NON_AMPDU_TX_CTRL - non_ampdu_tx_water_mark.TlvType:2=0x101 - non_ampdu_tx_water_mark.TlvLength:2={ - non_ampdu_tx_high_water_mark:1=0x20 - non_ampdu_tx_low_water_mark:1=0x8 - } -} - -enable_nonampdu_txctrl={ - CmdCode=0x008b # do NOT change this line - Action:2=1 # 1 - SET - SUBID:2=0x116 # NON_AMPDU_TX_CTRL - non_ampdu_tx_ctrl.TlvType:2=0x102 - non_ampdu_tx_ctrl.TlvLength:2={ - non_ampdu_tx_ctrl:1=0x1 - } -} - -disable_nonampdu_txctrl={ - CmdCode=0x008b # do NOT change this line - Action:2=1 # 1 - SET - SUBID:2=0x116 # NON_AMPDU_TX_CTRL - non_ampdu_tx_ctrl.TlvType:2=0x102 - non_ampdu_tx_ctrl.TlvLength:2={ - non_ampdu_tx_ctrl:1=0x0 - } -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V2_8887.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V2_8887.conf deleted file mode 100644 index adc9279..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V2_8887.conf +++ /dev/null @@ -1,29 +0,0 @@ -# File : ed_mac_ctrl_V2_8887.conf -# -# ed_mac_ctrl_v2 is used for 88W8897, 88W8887, 88W8797, 88W8782, 88W8787 -# ./mlanutl mlan0 hostcmd config/ed_mac_ctrl_V2_8887.conf ed_mac_ctrl_v2 -# -## Set Energy Detect Threshold for EU Adaptivity test - -ed_mac_ctrl_v2={ - CmdCode=0x0130 #Command code, DO NOT change this line - ed_ctrl_2g.enable:2=0x1 # 0 - disable EU adaptivity for 2.4GHz band - # 1 - enable EU adaptivity for 2.4GHz band - - ed_ctrl_2g.offset:2=0x0 # 0 - Default Energy Detect threshold - #offset value range: 0x80 to 0x7F - - ed_ctrl_2g.on_period:2=0x12 #DO NOT Change this line - ed_ctrl_2g.off_period:2=0x0 #DO NOT Change this line - ed_ctrl_2g.bitmap:2=0x1 #DO NOT Change this line - - ed_ctrl_5g.enable:2=0x1 # 0 - disable EU adaptivity for 5GHz band - # 1 - enable EU adaptivity for 5GHz band - - ed_ctrl_5g.offset:2=0x6 # 0 - Default Energy Detect threshold - #offset value range: 0x80 to 0x7F - - ed_ctrl_5g.on_period:2=0x12 #DO NOT Change this line - ed_ctrl_5g.off_period:2=0x0 #DO NOT Change this line - ed_ctrl_5g.bitmap:2=0x1 #DO NOT Change this line -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V2_8897.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V2_8897.conf deleted file mode 100644 index f472e81..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V2_8897.conf +++ /dev/null @@ -1,29 +0,0 @@ -# File : ed_mac_ctrl_V2_8897.conf -# -# ed_mac_ctrl_v2 is used for 88W8897, 88W8887, 88W8797, 88W8782, 88W8787 -# ./mlanutl mlan0 hostcmd config/ed_mac_ctrl_V2_8897.conf ed_mac_ctrl_v2 -# -## Set Energy Detect Threshold for EU Adaptivity test - -ed_mac_ctrl_v2={ - CmdCode=0x0130 #Command code, DO NOT change this line - ed_ctrl_2g.enable:2=0x1 # 0 - disable EU adaptivity for 2.4GHz band - # 1 - enable EU adaptivity for 2.4GHz band - - ed_ctrl_2g.offset:2=0x0 # 0 - Default Energy Detect threshold - #offset value range: 0x80 to 0x7F - - ed_ctrl_2g.on_period:2=0x12 #DO NOT Change this line - ed_ctrl_2g.off_period:2=0x0 #DO NOT Change this line - ed_ctrl_2g.bitmap:2=0x1 #DO NOT Change this line - - ed_ctrl_5g.enable:2=0x1 # 0 - disable EU adaptivity for 5GHz band - # 1 - enable EU adaptivity for 5GHz band - - ed_ctrl_5g.offset:2=0x4 # 0 - Default Energy Detect threshold - #offset value range: 0x80 to 0x7F - - ed_ctrl_5g.on_period:2=0x12 #DO NOT Change this line - ed_ctrl_5g.off_period:2=0x0 #DO NOT Change this line - ed_ctrl_5g.bitmap:2=0x1 #DO NOT Change this line -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_8977.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_8977.conf deleted file mode 100644 index 501f616..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_8977.conf +++ /dev/null @@ -1,23 +0,0 @@ -# File : ed_mac_ctrl_V3_8977.conf -# -# ed_mac_ctrl_v3 is used for 88W8997, 88W8987, 88W8977 -# ./mlanutl mlan0 hostcmd config/ed_mac_ctrl_V3_8977.conf ed_mac_ctrl_v3 -# -## Set Energy Detect Threshold for EU Adaptivity test - -ed_mac_ctrl_v3={ - CmdCode=0x0130 #Command code, DO NOT change this line - ed_ctrl_2g.enable:2=0x1 # 0 - disable EU adaptivity for 2.4GHz band - # 1 - enable EU adaptivity for 2.4GHz band - - ed_ctrl_2g.offset:2=0x9 # 0 - Default Energy Detect threshold - #offset value range: 0x80 to 0x7F - - ed_ctrl_5g.enable:2=0x1 # 0 - disable EU adaptivity for 5GHz band - # 1 - enable EU adaptivity for 5GHz band - - ed_ctrl_5g.offset:2=0xC # 0 - Default Energy Detect threshold - #offset value range: 0x80 to 0x7F - - ed_ctrl_txq_lock:4=0xFF #DO NOT Change this line -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_8978.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_8978.conf deleted file mode 100644 index 03563f1..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_8978.conf +++ /dev/null @@ -1,23 +0,0 @@ -# File : ed_mac_ctrl_V3_8978.conf -# -# ed_mac_ctrl_v3 is used for 88W8997, 88W8987, 88W8977, 88W8978 -# ./mlanutl mlan0 hostcmd config/ed_mac_ctrl_V3_8978.conf ed_mac_ctrl_v3 -# -## Set Energy Detect Threshold for EU Adaptivity test - -ed_mac_ctrl_v3={ - CmdCode=0x0130 #Command code, DO NOT change this line - ed_ctrl_2g.enable:2=0x1 # 0 - disable EU adaptivity for 2.4GHz band - # 1 - enable EU adaptivity for 2.4GHz band - - ed_ctrl_2g.offset:2=0x9 # 0 - Default Energy Detect threshold - #offset value range: 0x80 to 0x7F - - ed_ctrl_5g.enable:2=0x1 # 0 - disable EU adaptivity for 5GHz band - # 1 - enable EU adaptivity for 5GHz band - - ed_ctrl_5g.offset:2=0xC # 0 - Default Energy Detect threshold - #offset value range: 0x80 to 0x7F - - ed_ctrl_txq_lock:4=0xFF #DO NOT Change this line -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_8997.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_8997.conf deleted file mode 100644 index 6c86bd7..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_8997.conf +++ /dev/null @@ -1,23 +0,0 @@ -# File : ed_mac_ctrl_V3_8997.conf -# -# ed_mac_ctrl_v3 is used for 88W8997, 88W8987, 88W8977 -# ./mlanutl mlan0 hostcmd config/ed_mac_ctrl_V3_8997.conf ed_mac_ctrl_v3 -# -## Set Energy Detect Threshold for EU Adaptivity test - -ed_mac_ctrl_v3={ - CmdCode=0x0130 #Command code, DO NOT change this line - ed_ctrl_2g.enable:2=0x1 # 0 - disable EU adaptivity for 2.4GHz band - # 1 - enable EU adaptivity for 2.4GHz band - - ed_ctrl_2g.offset:2=0x0 # 0 - Default Energy Detect threshold - #offset value range: 0x80 to 0x7F - - ed_ctrl_5g.enable:2=0x1 # 0 - disable EU adaptivity for 5GHz band - # 1 - enable EU adaptivity for 5GHz band - - ed_ctrl_5g.offset:2=0x4 # 0 - Default Energy Detect threshold - #offset value range: 0x80 to 0x7F - - ed_ctrl_txq_lock:4=0xFF #DO NOT Change this line -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_909x.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_909x.conf deleted file mode 100644 index d4ba59c..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ed_mac_ctrl_V3_909x.conf +++ /dev/null @@ -1,23 +0,0 @@ -# File : ed_mac_ctrl_V3_909x.conf -# -# ed_mac_ctrl_v3 is used for 88W9098, 88W9097 -# ./mlanutl mlan0 hostcmd config/ed_mac_ctrl_V3_909x.conf ed_mac_ctrl_v3 -# -## Set Energy Detect Threshold for EU Adaptivity test - -ed_mac_ctrl_v3={ - CmdCode=0x0130 #Command code, DO NOT change this line - ed_ctrl_2g.enable:2=0x1 # 0 - disable EU adaptivity for 2.4GHz band - # 1 - enable EU adaptivity for 2.4GHz band - - ed_ctrl_2g.offset:2=0x5 # 0 - Default Energy Detect threshold - #offset value range: 0x80 to 0x7F - - ed_ctrl_5g.enable:2=0x1 # 0 - disable EU adaptivity for 5GHz band - # 1 - enable EU adaptivity for 5GHz band - - ed_ctrl_5g.offset:2=0x5 # 0 - Default Energy Detect threshold - #offset value range: 0x80 to 0x7F - - ed_ctrl_txq_lock:4=0x1e00FF #DO NOT Change this line -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/init_cfg.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/init_cfg.conf deleted file mode 100644 index 821c024..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/init_cfg.conf +++ /dev/null @@ -1,14 +0,0 @@ -# File : init_cfg.conf - -# MAC address (interface: address) -mac_addr=mlan0: 00:50:43:20:12:34 -mac_addr=mmlan0: 00:50:43:20:42:64 -mac_addr=uap0: 00:50:43:20:12:35 -mac_addr=muap0: 00:50:43:20:42:65 -mac_addr=wfd0: 00:50:43:20:12:36 -mac_addr=mwfd0: 00:40:43:20:42:66 - -# Register (type, offset, value) -# type 1:MAC/SOC, 2:BBP, 3:RF, 5:CAU -#wlan_reg=1,0xA794,0x55FF55FF - diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/mef.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/mef.conf deleted file mode 100644 index 37d19a4..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/mef.conf +++ /dev/null @@ -1,167 +0,0 @@ -# File : mef.conf - -######################### MEF Configuration command ################## -mefcfg={ - #Criteria: bit0-broadcast, bit1-unicast, bit3-multicast - Criteria=2 # Unicast frames are received during hostsleepmode - NumEntries=1 # Number of activated MEF entries - #mef_entry_0: example filters to match TCP destination port 80 send by 192.168.0.88 pkt or magic pkt. - mef_entry_0={ - #mode: bit0--hostsleep mode, bit1--non hostsleep mode - mode=1 # HostSleep mode - #action: 0--discard and not wake host, 1--discard and wake host 3--allow and wake host - action=3 # Allow and Wake host - filter_num=3 # Number of filter - #RPN only support "&&" and "||" operator,space can not be removed between operator. - RPN=Filter_0 && Filter_1 || Filter_2 - #Byte comparison filter's type is 0x41,Decimal comparison filter's type is 0x42, - #Bit comparison filter's type is 0x43 - #Filter_0 is decimal comparison filter, it always with type=0x42 - #Decimal filter always has type, pattern, offset, numbyte 4 field - #Filter_0 will match rx pkt with TCP destination port 80 - Filter_0={ - type=0x42 # decimal comparison filter - pattern=80 # 80 is the decimal constant to be compared - offset=44 # 44 is the byte offset of the field in RX pkt to be compare - numbyte=2 # 2 is the number of bytes of the field - } - #Filter_1 is Byte comparison filter, it always with type=0x41 - #Byte filter always has type, byte, repeat, offset 4 filed - #Filter_1 will match rx pkt send by IP address 192.168.0.88 - Filter_1={ - type=0x41 # Byte comparison filter - repeat=1 # 1 copies of 'c0:a8:00:58' - byte=c0:a8:00:58 # 'c0:a8:00:58' is the byte sequence constant with each byte - # in hex format, with ':' as delimiter between two byte. - offset=34 # 34 is the byte offset of the equal length field of rx'd pkt. - } - #Filter_2 is Magic packet, it will looking for 16 contiguous copies of '00:50:43:20:01:02' from - # the rx pkt's offset 14 - Filter_2={ - type=0x41 # Byte comparison filter - repeat=16 # 16 copies of '00:50:43:20:01:02' - byte=00:50:43:20:01:02 # '00:50:43:20:01:02' is the byte sequence constant - offset=14 # 14 is the byte offset of the equal length field of rx'd pkt. - } - } -} - - -#--------------------------examples for MEF filters-------------------------------- -# example: filters to match ARP packet with protocol addr 192.168.0.104 -# mef_entry_0={ -# mode=1 # HostSleep mode -# action=3 # Allow and Wake host -# filter_num=3 # Number of filter -# RPN=Filter_0 && Filter_1 && Filter_2 -# #Filter_0 looking for rx pkt with DA is broadcast address -# Filter_0={ -# type=0x41 -# repeat=6 -# byte=ff -# offset=0 -# } -# #Filter_1 looking for rx pkt with EtherType is 0x0806(ARP) -# Filter_1={ -# type=0x41 -# repeat=1 -# byte=08:06 -# offset=20 -# } -# #Filter_2 looking for rx pkt with ARP target protocol addr 192.168.0.104 -# Filter_2={ -# type=0x41 -# repeat=1 -# byte=c0:a8:00:68 -# offset=46 -# } -# } -#------------------------------------------------------------------------------------- -# example: filter to check if the destination MAC address is unicast pkt -# mef_entry_0={ -# mode=1 # HostSleep mode -# action=3 # Allow and Wake host -# filter_num=3 # Number of filter -# RPN=Filter_0 -# #Filter_0 is Bit comparison filter, it always with type=0x43 -# #Byte filter always has type, byte, mask, offset 4 filed -# #"byte" is the byte sequence constant with each byte in hex format, with ':' as delimiter between two byte -# #"mask" is also with each byte in hex format, with ':' as delimiter between two byte -# #"byte" should has the same length as "mask" -# #Filter_0 will check if the destination MAC address is unicast pkt -# Filter_0={ -# type=0x43 #Bit comparison filter -# byte=00 #00 is the 1-byte sequence constant -# offset=0 #0 is the byte offset of the rx pkt -# mask=01 #1 is the 1-byte mask -# } -# } -#-------------------------------------------------------------------------------------------------- -# example: Disable MEF filters -# mefcfg={ -# #Criteria: bit0-broadcast, bit1-unicast, bit3-multicast -# Criteria=2 # Unicast frames are received during hostsleepmode -# NumEntries=0 # Number of activated MEF entries -# } -#-------------------------------------------------------------------------------------------------- -# example: Test MEF filters -# mefcfg={ -# Criteria=1 -# NumEntries=1 -# mef_entry_0={ -# mode=4 # Test Mode -# action=16 # Invoke Test -# filter_num=0 -# } -# } -#----------------------------------------------------------------------------------------------------- -# example: Test MEF filters -# mefcfg={ -# Criteria=1 -# NumEntries=1 -# mef_entry_0={ -# mode=4 -# action=0 -# filter_num=1 -# RPN=Filter_0 -# Filter_0={ -# type=0x44 # test filter -# repeat=2 # 2 copies of 'BE:EF' -# byte=BE:EF # 'BE:EF' is the byte sequence constant -# offset=18 # 18 is the byte offset of the equal length field of rx'd pkt. -# dest=00:50:43:20:5a:82 # '00:50:43:20:5a:82' is the byte sequence constant -# } -# } -# } -#---------------------------------------------------------------------------------------------------- -#example: Filter broadcast/ipv4 multicast/ipv6 multicast packets in non hostsleep mode -#mefcfg={ -# Criteria=9 # broadcast and multicast frames -# NumEntries=1 # Number of activated MEF entries -# mef_entry_0={ -# mode=2 # non HostSleep mode -# action=0 # discard and not wake host -# filter_num=3 # Number of filter -# RPN=Filter_0 || Filter_1 || Filter_2 -# Filter_0={ # IPV4 multicast -# type=0x41 # byte comparison filter -# byte=01:00:5e # 01:00:5e is the byte constant to be compared -# offset=0 # 0 is the byte offset of the equal length field of rx'd pkt. -# repeat=1 # -# } -# Filter_1={ # broadcast packet check -# type=0x41 # Byte comparison filter -# repeat=6 # 6 copies of 'ff', means broadcast -# byte=ff # 'ff'(0xff) is the byte sequence constant with each byte -# # in hex format, with ':' as delimiter between two byte. -# offset=0 # 0 is the byte offset of the equal length field of rx'd pkt. -# } -# Filter_2={ # IPV6 multicast -# type=0x41 # byte comparison filter -# byte=33:33 # 33:33 is the byte constant to be compared -# offset=0 # 0 is the byte offset of the equal length field of rx'd pkt. -# repeat=1 # -# } -# } -#} -#------------------------------------------------------------------------------------------------------ diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/mef_mdns.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/mef_mdns.conf deleted file mode 100644 index 568ca6f..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/mef_mdns.conf +++ /dev/null @@ -1,204 +0,0 @@ -# File : mef_mdns.conf - -######################### MEF Configuration command ################## -mefcfg={ - #Criteria: bit0-broadcast, bit1-unicast, bit3-multicast - Criteria=8 # Multicast frames are received during hostsleepmode - NumEntries=2 # Number of activated MEF entries - #mef_entry_0: example filters to match WS-Discovery pkt for IPv4. - mef_entry_0={ - #mode: bit0--hostsleep mode, bit1--non hostsleep mode - mode=1 # HostSleep mode - #action: 0--discard and not wake host, 1--discard and wake host 3--allow and wake host - action=3 # Allow and Wake host - filter_num=4 # Number of filter - #RPN only support "&&" and "||" operator,space can not be removed between operator. - RPN=Filter_0 && Filter_1 && Filter_2 && Filter_3 - #Filter_0 will match IPv4 protocol packet - Filter_0={ - type=0x41 - repeat=1 - byte=08:00 - offset=20 - } - #Filter_1 will match dest multicast IPv4 address 224.0.0.251 - Filter_1={ - type=0x41 - repeat=1 - byte=e0:00:00:fb - offset=38 - } - #Filter_2 will match UDP packet - Filter_2={ - type=0x42 - pattern=17 - offset=31 - numbyte=1 - } - #Filter_3 will match UDP port 5353 - Filter_3={ - type=0x42 - pattern=5353 - offset=44 - numbyte=2 - } - } - #mef_entry_1: example filters to match WS-Discovery pkt for IPv6. - mef_entry_1={ - #mode: bit0--hostsleep mode, bit1--non hostsleep mode - mode=1 # HostSleep mode - #action: 0--discard and not wake host, 1--discard and wake host 3--allow and wake host - action=3 # Allow and Wake host - filter_num=4 # Number of filter - #RPN only support "&&" and "||" operator,space can not be removed between operator. - RPN=Filter_0 && Filter_1 && Filter_2 && Filter_3 - #Filter_0 will match IPv4 protocol packet - Filter_0={ - type=0x41 - repeat=1 - byte=86:dd - offset=20 - } - #Filter_1 will match dest multicast IPv6 address FF02::FB - Filter_1={ - type=0x41 - repeat=1 - byte=ff:02:00:00:00:00:00:00:00:00:00:00:00:00:00:fb - offset=46 - } - #Filter_2 will match UDP packet - Filter_2={ - type=0x42 - pattern=17 - offset=28 - numbyte=1 - } - #Filter_3 will match UDP port 5353 - Filter_3={ - type=0x42 - pattern=5353 - offset=64 - numbyte=2 - } - } -} - - -#--------------------------examples for MEF filters-------------------------------- -# example: filters to match ARP packet with protocol addr 192.168.0.104 -# mef_entry_0={ -# mode=1 # HostSleep mode -# action=3 # Allow and Wake host -# filter_num=3 # Number of filter -# RPN=Filter_0 && Filter_1 && Filter_2 -# #Filter_0 looking for rx pkt with DA is broadcast address -# Filter_0={ -# type=0x41 -# repeat=6 -# byte=ff -# offset=0 -# } -# #Filter_1 looking for rx pkt with EtherType is 0x0806(ARP) -# Filter_1={ -# type=0x41 -# repeat=1 -# byte=08:06 -# offset=20 -# } -# #Filter_2 looking for rx pkt with ARP target protocol addr 192.168.0.104 -# Filter_2={ -# type=0x41 -# repeat=1 -# byte=c0:a8:00:68 -# offset=46 -# } -# } -#------------------------------------------------------------------------------------- -# example: filter to check if the destination MAC address is unicast pkt -# mef_entry_0={ -# mode=1 # HostSleep mode -# action=3 # Allow and Wake host -# filter_num=3 # Number of filter -# RPN=Filter_0 -# #Filter_0 is Bit comparison filter, it always with type=0x43 -# #Byte filter always has type, byte, mask, offset 4 filed -# #"byte" is the byte sequence constant with each byte in hex format, with ':' as delimiter between two byte -# #"mask" is also with each byte in hex format, with ':' as delimiter between two byte -# #"byte" should has the same length as "mask" -# #Filter_0 will check if the destination MAC address is unicast pkt -# Filter_0={ -# type=0x43 #Bit comparison filter -# byte=00 #00 is the 1-byte sequence constant -# offset=0 #0 is the byte offset of the rx pkt -# mask=01 #1 is the 1-byte mask -# } -# } -#-------------------------------------------------------------------------------------------------- -# example: Disable MEF filters -# mefcfg={ -# #Criteria: bit0-broadcast, bit1-unicast, bit3-multicast -# Criteria=2 # Unicast frames are received during hostsleepmode -# NumEntries=0 # Number of activated MEF entries -# } -#-------------------------------------------------------------------------------------------------- -# example: Test MEF filters -# mefcfg={ -# Criteria=1 -# NumEntries=1 -# mef_entry_0={ -# mode=4 # Test Mode -# action=16 # Invoke Test -# filter_num=0 -# } -# } -#----------------------------------------------------------------------------------------------------- -# example: Test MEF filters -# mefcfg={ -# Criteria=1 -# NumEntries=1 -# mef_entry_0={ -# mode=4 -# action=0 -# filter_num=1 -# RPN=Filter_0 -# Filter_0={ -# type=0x44 # test filter -# repeat=2 # 2 copies of 'BE:EF' -# byte=BE:EF # 'BE:EF' is the byte sequence constant -# offset=18 # 18 is the byte offset of the equal length field of rx'd pkt. -# dest=00:50:43:20:5a:82 # '00:50:43:20:5a:82' is the byte sequence constant -# } -# } -# } -#---------------------------------------------------------------------------------------------------- -#example: Filter broadcast/ipv4 multicast/ipv6 multicast packets in non hostsleep mode -#mefcfg={ -# Criteria=9 # broadcast and multicast frames -# NumEntries=1 # Number of activated MEF entries -# mef_entry_0={ -# mode=2 # non HostSleep mode -# action=0 # discard and not wake host -# filter_num=3 # Number of filter -# RPN=Filter_0 || Filter_1 || Filter_2 -# Filter_0={ # IPV4 multicast -# type=0x41 # byte comparison filter -# byte=01:00:5e # 01:00:5e is the byte constant to be compared -# offset=0 # 0 is the byte offset of the equal length field of rx'd pkt. -# repeat=1 # -# } -# Filter_1={ # broadcast packet check -# type=0x41 # Byte comparison filter -# repeat=6 # 6 copies of 'ff', means broadcast -# byte=ff # 'ff'(0xff) is the byte sequence constant with each byte -# # in hex format, with ':' as delimiter between two byte. -# offset=0 # 0 is the byte offset of the equal length field of rx'd pkt. -# } -# Filter_2={ # IPV6 multicast -# type=0x41 # byte comparison filter -# byte=33:33 # 33:33 is the byte constant to be compared -# offset=0 # 0 is the byte offset of the equal length field of rx'd pkt. -# repeat=1 # -# } -# } -#} -#------------------------------------------------------------------------------------------------------ diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/mef_ws_discovery.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/mef_ws_discovery.conf deleted file mode 100644 index 518a240..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/mef_ws_discovery.conf +++ /dev/null @@ -1,204 +0,0 @@ -# File : mef_ws_discovery.conf - -######################### MEF Configuration command ################## -mefcfg={ - #Criteria: bit0-broadcast, bit1-unicast, bit3-multicast - Criteria=8 # Multicast frames are received during hostsleepmode - NumEntries=2 # Number of activated MEF entries - #mef_entry_0: example filters to match WS-Discovery pkt for IPv4. - mef_entry_0={ - #mode: bit0--hostsleep mode, bit1--non hostsleep mode - mode=1 # HostSleep mode - #action: 0--discard and not wake host, 1--discard and wake host 3--allow and wake host - action=3 # Allow and Wake host - filter_num=4 # Number of filter - #RPN only support "&&" and "||" operator,space can not be removed between operator. - RPN=Filter_0 && Filter_1 && Filter_2 && Filter_3 - #Filter_0 will match IPv4 protocol packet - Filter_0={ - type=0x41 - repeat=1 - byte=08:00 - offset=20 - } - #Filter_1 will match dest multicast IPv4 address 239.255.255.250 - Filter_1={ - type=0x41 - repeat=1 - byte=ef:ff:ff:fa - offset=38 - } - #Filter_2 will match UDP packet - Filter_2={ - type=0x42 - pattern=17 - offset=31 - numbyte=1 - } - #Filter_3 will match UDP port 3702 - Filter_3={ - type=0x42 - pattern=3702 - offset=44 - numbyte=2 - } - } - #mef_entry_1: example filters to match WS-Discovery pkt for IPv6. - mef_entry_1={ - #mode: bit0--hostsleep mode, bit1--non hostsleep mode - mode=1 # HostSleep mode - #action: 0--discard and not wake host, 1--discard and wake host 3--allow and wake host - action=3 # Allow and Wake host - filter_num=4 # Number of filter - #RPN only support "&&" and "||" operator,space can not be removed between operator. - RPN=Filter_0 && Filter_1 && Filter_2 && Filter_3 - #Filter_0 will match IPv4 protocol packet - Filter_0={ - type=0x41 - repeat=1 - byte=86:dd - offset=20 - } - #Filter_1 will match dest multicast IPv6 address FF02::C - Filter_1={ - type=0x41 - repeat=1 - byte=ff:02:00:00:00:00:00:00:00:00:00:00:00:00:00:0c - offset=46 - } - #Filter_2 will match UDP packet - Filter_2={ - type=0x42 - pattern=17 - offset=28 - numbyte=1 - } - #Filter_3 will match UDP port 3702 - Filter_3={ - type=0x42 - pattern=3702 - offset=64 - numbyte=2 - } - } -} - - -#--------------------------examples for MEF filters-------------------------------- -# example: filters to match ARP packet with protocol addr 192.168.0.104 -# mef_entry_0={ -# mode=1 # HostSleep mode -# action=3 # Allow and Wake host -# filter_num=3 # Number of filter -# RPN=Filter_0 && Filter_1 && Filter_2 -# #Filter_0 looking for rx pkt with DA is broadcast address -# Filter_0={ -# type=0x41 -# repeat=6 -# byte=ff -# offset=0 -# } -# #Filter_1 looking for rx pkt with EtherType is 0x0806(ARP) -# Filter_1={ -# type=0x41 -# repeat=1 -# byte=08:06 -# offset=20 -# } -# #Filter_2 looking for rx pkt with ARP target protocol addr 192.168.0.104 -# Filter_2={ -# type=0x41 -# repeat=1 -# byte=c0:a8:00:68 -# offset=46 -# } -# } -#------------------------------------------------------------------------------------- -# example: filter to check if the destination MAC address is unicast pkt -# mef_entry_0={ -# mode=1 # HostSleep mode -# action=3 # Allow and Wake host -# filter_num=3 # Number of filter -# RPN=Filter_0 -# #Filter_0 is Bit comparison filter, it always with type=0x43 -# #Byte filter always has type, byte, mask, offset 4 filed -# #"byte" is the byte sequence constant with each byte in hex format, with ':' as delimiter between two byte -# #"mask" is also with each byte in hex format, with ':' as delimiter between two byte -# #"byte" should has the same length as "mask" -# #Filter_0 will check if the destination MAC address is unicast pkt -# Filter_0={ -# type=0x43 #Bit comparison filter -# byte=00 #00 is the 1-byte sequence constant -# offset=0 #0 is the byte offset of the rx pkt -# mask=01 #1 is the 1-byte mask -# } -# } -#-------------------------------------------------------------------------------------------------- -# example: Disable MEF filters -# mefcfg={ -# #Criteria: bit0-broadcast, bit1-unicast, bit3-multicast -# Criteria=2 # Unicast frames are received during hostsleepmode -# NumEntries=0 # Number of activated MEF entries -# } -#-------------------------------------------------------------------------------------------------- -# example: Test MEF filters -# mefcfg={ -# Criteria=1 -# NumEntries=1 -# mef_entry_0={ -# mode=4 # Test Mode -# action=16 # Invoke Test -# filter_num=0 -# } -# } -#----------------------------------------------------------------------------------------------------- -# example: Test MEF filters -# mefcfg={ -# Criteria=1 -# NumEntries=1 -# mef_entry_0={ -# mode=4 -# action=0 -# filter_num=1 -# RPN=Filter_0 -# Filter_0={ -# type=0x44 # test filter -# repeat=2 # 2 copies of 'BE:EF' -# byte=BE:EF # 'BE:EF' is the byte sequence constant -# offset=18 # 18 is the byte offset of the equal length field of rx'd pkt. -# dest=00:50:43:20:5a:82 # '00:50:43:20:5a:82' is the byte sequence constant -# } -# } -# } -#---------------------------------------------------------------------------------------------------- -#example: Filter broadcast/ipv4 multicast/ipv6 multicast packets in non hostsleep mode -#mefcfg={ -# Criteria=9 # broadcast and multicast frames -# NumEntries=1 # Number of activated MEF entries -# mef_entry_0={ -# mode=2 # non HostSleep mode -# action=0 # discard and not wake host -# filter_num=3 # Number of filter -# RPN=Filter_0 || Filter_1 || Filter_2 -# Filter_0={ # IPV4 multicast -# type=0x41 # byte comparison filter -# byte=01:00:5e # 01:00:5e is the byte constant to be compared -# offset=0 # 0 is the byte offset of the equal length field of rx'd pkt. -# repeat=1 # -# } -# Filter_1={ # broadcast packet check -# type=0x41 # Byte comparison filter -# repeat=6 # 6 copies of 'ff', means broadcast -# byte=ff # 'ff'(0xff) is the byte sequence constant with each byte -# # in hex format, with ':' as delimiter between two byte. -# offset=0 # 0 is the byte offset of the equal length field of rx'd pkt. -# } -# Filter_2={ # IPV6 multicast -# type=0x41 # byte comparison filter -# byte=33:33 # 33:33 is the byte constant to be compared -# offset=0 # 0 is the byte offset of the equal length field of rx'd pkt. -# repeat=1 # -# } -# } -#} -#------------------------------------------------------------------------------------------------------ diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/mem.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/mem.conf deleted file mode 100644 index cf649c9..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/mem.conf +++ /dev/null @@ -1,17 +0,0 @@ -#File : memory/register update -# memory/register update file -mem_set={ - CmdCode=0x0086 #do NOT change this line - Action:2=1 # 1 - SET - Rsrvd:2=0 - Addr:4=0x8000a584 # memory/register address - Value:4=0x16161669 #Value -} - -mem_get={ - CmdCode=0x0086 #do NOT change this line - Action:2=0 # 1 - SET - Rsrvd:2=0 - Addr:4=0x8000a584 # memory/register address - Result:4=0 -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/mgmt_frame.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/mgmt_frame.conf deleted file mode 100644 index 22b19b1..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/mgmt_frame.conf +++ /dev/null @@ -1,30 +0,0 @@ -# Format of the packet data to be sent. -# Update the TxControl value for TxPD, else zero is sent. -# all packet data is written under "Data" block - -PktType=0x00 # should be zero for MGMT frames -PktSubType=0x05 - # Assoc Request 0 - # Assoc Response 1 - # Re-Assoc Request 2 - # Re-Assoc Response 3 - # Probe Request 4 - # Probe Response 5 - # Beacon 8 - # Atim 9 - # Dis-assoc 10 - # Auth 11 - # Deauth 12 - # Action Frame 13 - -FromDS=0 -ToDS=0 - -Addr1=00:50:43:27:B0:41 # Destination address -Addr2=00:50:43:21:0F:84 # Source address -Addr3=00:50:43:21:0F:84 # BSSID - -Data=0x01,0x01,0x00,0x0c,0x00,0x58,0x02,0x40 - -SeqNum=0 -FragNum=0 diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/mgmtfilter.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/mgmtfilter.conf deleted file mode 100644 index 8ee0298..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/mgmtfilter.conf +++ /dev/null @@ -1,15 +0,0 @@ -##############management frame filter to wake up host ########### -##### support two entries currently ###### -mgmtfilter={ - entry_num=1 - entry_0={ - action=1 # discard and wakeup host - type=0x1 # p2p frames - frame_mask=0x7 # Go neg req & rsp & cfm frame - } -# entry_1={ -# action=0 # discard and not wakeup host -# type=0xff # management frames -# frame_mask=0x3 # assoc req & rsp frame -# } -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/or_data.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/or_data.conf deleted file mode 100644 index 99154f5..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/or_data.conf +++ /dev/null @@ -1,7 +0,0 @@ - 07 01 03 3A 80 00 3A 00 ff ff 00 17 03 00 07 03 - 09 00 0e 10 16 02 19 25 1a 04 1c ff 32 5e 33 15 - 35 29 36 17 4b 74 4c 64 4d 3b 50 27 61 d6 62 98 - 6b ae 6f 5b 77 f2 79 ff 7f 2d - 07 01 12 16 c0 00 ff ff ff ff 00 05 03 10 32 5c - 33 1a 6b a2 7f 20 - diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/pad_cfg.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/pad_cfg.conf deleted file mode 100644 index dc996ee..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/pad_cfg.conf +++ /dev/null @@ -1,29 +0,0 @@ -# File : pad_cfg.conf - -## Get CFG data for PAD OR -pad_cfg_get={ - CmdCode=0x008f # do NOT change this line - Action:2=0 # 0 - GET - Type:2=5 # 5 - optimized pad reg - CfgLen:2={ - } -} - - -## Set CFG data for PAD OR -#pad_cfg_set={ -# CmdCode=0x008f # do NOT change this line -# Action:2=1 # 1 - SET -# Type:2=5 # 5 - optimized pad reg -# CfgLen:2={ # 9 entries for W8787 -# CFG1:4=0x00000000 # SDIO in sleep -# CFG2:4=0x55550004 # GPIO in sleep -# CFG3:4=0x00000001 -# CFG4:4=0x00000000 # RFCTRL in sleep -# CFG5:4=0x00000000 -# CFG6:4=0x0E001800 # GPIO/RFCTRL in power down -# CFG7:4=0x249A0000 -# CFG8:4=0x000000D2 -# CFG9:4=0x00000000 -# } -#} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/requesttpc.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/requesttpc.conf deleted file mode 100644 index 690c30d..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/requesttpc.conf +++ /dev/null @@ -1,15 +0,0 @@ -# File : requesttpc.conf - -######################### requesttpc command configuration ################## - -requesttpc={ - CmdCode=0x0060 # do NOT change this line - #DestMac: Destination STA address - DestMac:6='0x02,0x04,0x0e,0x06,0x01,0x12' - #RateIndex: IEEE Rate index to send request - RateIndex:1=22 - #Timeout: Response timeout in ms - Timeout:2=10 -} - -######################### End of requesttpc command configuration ################## diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/robust_btc.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/robust_btc.conf deleted file mode 100644 index 8e075f8..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/robust_btc.conf +++ /dev/null @@ -1,211 +0,0 @@ -# File : robust_btc.conf - -######################### Robust Coex command ############### -mode_get={ - CmdCode=0x00e0 # do NOT change this line - Action:2=0 # GET - RSVD:2=0 - - # Robust Coex Mode TLV - RobustCoexTlvType:2=0x0160 - RobustCoexTlvLength:2={ - Enable:1=0x00 # Read-back Coex mode(s) - Reserved:3=0 - } -} - -mode_timeshare={ - CmdCode=0x00e0 # do NOT change this line - Action:2=1 # SET - RSVD:2=0 - - # Robust Coex Mode TLV - RobustCoexTlvType:2=0x0160 - RobustCoexTlvLength:2={ - # All the modes below are mutually exclusive of each other; - Enable:1=0x01 # Bit0: Enable 2x2 or 1x1 Time Distribute(TMD) - # Robust Coex(RBC) mode, when uAP bss start, - # uAP TMD RBC scheme is enabled, - # STA TMD RBC scheme is disabled. - Reserved:3=0 - } -} - -mode_spatial={ - CmdCode=0x00e0 # do NOT change this line - Action:2=1 # SET - RSVD:2=0 - - # Robust Coex Mode TLV - RobustCoexTlvType:2=0x0160 - RobustCoexTlvLength:2={ - # All the modes below are mutually exclusive of each other; - Enable:1=0x82 # Bit1: Enable 1x1 SMPS Spatial RBC Mode, e.g. 0x02 - # Bit7: Enable uAP+STA SMPS RBC Mode, - # when uAP bss start, uAP SMPS RBC scheme enable, - # must combined with BIT1 or BIT2, e.g. 0x82, 0x84. - Reserved:3=0 - } -} - -mode_none={ - CmdCode=0x00e0 # do NOT change this line - Action:2=1 # SET - RSVD:2=0 - - # Robust Coex Mode TLV - RobustCoexTlvType:2=0x0160 - RobustCoexTlvLength:2={ - Enable:1=0 # Concurrent Coex mode. Used for chips which has - # separate antenna for BT - Reserved:3=0 - } -} - -mode_2={ - CmdCode=0x00e0 # do NOT change this line - Action:2=1 # SET - RSVD:2=0 - - # Robust Coex Mode TLV - RobustCoexTlvType:2=0x0160 - RobustCoexTlvLength:2={ - Enable:1=0x20 # Concurrent Coex mode with Tx power control and Rx De-sense. - # Used for chips which has separate antenna for BT - Reserved:3=0 - } -} - -gpio_cfg={ - CmdCode=0x00e0 # do NOT change this line - Action:2=1 # SET - RSVD:2=0 - - # Robust Coex Mode TLV - RobustCoexTlvType:2=0x021B - RobustCoexTlvLength:2={ - Enable:1=0x1 # enable GPIO cfg for external bt request - gpionum:1=4 # gpio 4 - gpiopolarity:1=1 # Polarity High - } -} - -external_coex_config={ - CmdCode=0x00e0 - Action:2=1 //0x0 get, 0x1 set - RSVD:2=0 - RobustCoexTlvType:2=0x0238 //TLV ID - RobustCoexTlvLength:2={ - Enabled:1=0x01 // 0x00 disable, 0x01 enalbe - - ExtHighInputPriority:1=0x02 // Input priority: 0x00 Input Low Priority, 0x01 Input Medium Priority, 0x02 Input High Priority - ExtLowInputPriority:1=0x02 - - ExtPriGPIONum:1=0x06; // Input Priority signal GPIO pin number - ExtPriGPIOPolarity:1=0x01; // Polarity: 0x00 Active Low, 0x01 Active High - - ExtReqGPIONum:1=0x07; // Input Request signal GPIO pin number - ExtReqGPIOPolarity:1=0x01; // Polarity: 0x00 Active Low, 0x01 Active High - - ExtGrntGPIONum:1=0x05; // Output Grant signal GPIO pin number - ExtGrntGPIOPolarity:1=0x01; // Polarity: 0x00 Active Low, 0x01 Active High - - } -} - -#In Station generic case -#BT time is set as BTTime -#Wlan time is set as Wlan Time -generictime={ - CmdCode=0x00e0 - Action:2=1 - RSVD:2=0 - RobustCoexTlvType:2=0x0390 - RobustCoexTlvLength:2={ - Enable:2=0x01 - BtTime:2=10000 #(10ms) BTTime must be less than 65535 - WlanTime:2=40000 #(40ms) WlanTime must be less than 65535 - } -} - -#In Station A2DP case -#BT time is set as BTTime -#Wlan time is set as Wlan Time -a2dptime={ - CmdCode=0x00e0 - Action:2=1 - RSVD:2=0 - RobustCoexTlvType:2=0x0391 - RobustCoexTlvLength:2={ - Enable:2=0x01 - BtTime:2=10000 #(10ms) BTTime must be less than 65535 - WlanTime:2=39500 #(39.5ms) WlanTime must be less than 65535 - } -} - -#In Station inquiry case -#BT time is set as BTTime -#Wlan time is set as Wlan Time -inquirytime={ - CmdCode=0x00e0 - Action:2=1 - RSVD:2=0 - RobustCoexTlvType:2=0x0392 - RobustCoexTlvLength:2={ - Enable:2=0x01 - BtTime:2=21215 #(21.215ms) BTTime must be less than 65535 - WlanTime:2=11000 #(11ms) WlanTime must be less than 65535 - } -} - -#In Ap generic case -#BT time is BTTimeBusy when BT has traffic -#BT time is BTTimeIdle when BT is idle -#Wlan time is WlanTimeBusy when Wlan has traffic -#Wlan time is WlanTimeIdle when Wlan is idle -ap_generictime={ - CmdCode=0x00e0 - Action:2=1 - RSVD:2=0 - RobustCoexTlvType:2=0x0393 - RobustCoexTlvLength:2={ - Enable:2=0x01 - BtTime_MAX:2=23000 #(23ms) BTTime(BT Busy) must be less than 28767 - BtTime_MIN:2=6500 #(6.5ms) BTTime(BT Idle) must be less than 28767 - WlanTime_MAX:2=18000 #(18ms) WlanTime(Wlan Busy) must be less than 32767 - WlanTime_MIN:2=5750 #(5.75ms) WlanTime(Wlan Idle) must be less than 32767 - } -} - -#In Ap A2DP case -#BT time is change from BTTimeMax to BTTimeMin -#Wlan time is change from WlanTimeMax to WlanTimeMin -ap_a2dptime={ - CmdCode=0x00e0 - Action:2=1 - RSVD:2=0 - RobustCoexTlvType:2=0x0394 - RobustCoexTlvLength:2={ - Enable:2=0x01 - BtTimebusy:2=23000 #(23ms) Maximum BTTime must be less than 32767 - BtTimeidle:2=6500 #(6.5ms) Minimum BTTime must be less than 32767 - WlanTimebusy:2=18000 #(18ms) Maximum WlanTime must be less than 32767 - WlanTimeidle:2=5750 #(5.75ms) Minimum WlanTime must be less than 32767 - } -} - -#In Ap inquiry case -#BT time is set as BTTime -#Wlan time is set as Wlan Time -ap_inquirytime={ - CmdCode=0x00e0 - Action:2=1 - RSVD:2=0 - RobustCoexTlvType:2=0x0395 - RobustCoexTlvLength:2={ - Enable:2=0x01 - BtTime:2=28750 #(28.75ms) BTTime must less than 32767 - WlanTime:2=20000 #(20ms) WlanTime must be less than 32767 - } -} -######################### Robust Coex command ############### diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/rutxpower_limit.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/rutxpower_limit.conf deleted file mode 100644 index d366a6e..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/rutxpower_limit.conf +++ /dev/null @@ -1,674 +0,0 @@ -# File: rutxpower_limit.conf - -## Get CFG data for RU based Tx power limit -rutxpowerlimit_cfg_get={ - CmdCode=0x026d #do not change this line - Action:2=0 #0 - GET - SubID:2=0x117 #RU POWER -} - - -## Set CFG data for RU based Tx power limit -## -## TLVStartFreq: Starting Frequency of the band for this channel -## 2407, 2414 or 2400 for 2.4 GHz -## 5000 -## 4000 -## TLVChanWidth: Channel Width -## 20 40 80 -## TLVChanNum : Channel Number -## TLVPwr[] : Power Limit in dBm (RU=26,52,106,242,484,996) -## range from -64dBm to +63dBm in steps of 1dBm -## - -rutxpowerlimit_cfg_set={ - CmdCode=0x026d #do not change this line - Action:2=1 #1 - SET - SubID:2=0x117 #RU POWER - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=2407 - TlvChanWidth:1=20 - TlvChanNum:1=1 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=2407 - TlvChanWidth:1=20 - TlvChanNum:1=2 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=2407 - TlvChanWidth:1=20 - TlvChanNum:1=3 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=2407 - TlvChanWidth:1=20 - TlvChanNum:1=4 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=2407 - TlvChanWidth:1=20 - TlvChanNum:1=5 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=2407 - TlvChanWidth:1=20 - TlvChanNum:1=6 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=2407 - TlvChanWidth:1=20 - TlvChanNum:1=7 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=2407 - TlvChanWidth:1=20 - TlvChanNum:1=8 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=2407 - TlvChanWidth:1=20 - TlvChanNum:1=9 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=2407 - TlvChanWidth:1=20 - TlvChanNum:1=10 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=2407 - TlvChanWidth:1=20 - TlvChanNum:1=11 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=2407 - TlvChanWidth:1=20 - TlvChanNum:1=12 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=2407 - TlvChanWidth:1=20 - TlvChanNum:1=13 - TlvPwr:6='-1,2,5,8,0,0' - } -} - -rutxpowerlimit_5g_cfg_set={ - CmdCode=0x026d #do not change this line - Action:2=1 #1 - SET - SubID:2=0x117 #RU POWER - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=36 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=40 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=44 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=48 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=52 - TlvPwr:6='-2,1,4,7,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=56 - TlvPwr:6='-2,1,4,7,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=60 - TlvPwr:6='-2,1,4,7,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=64 - TlvPwr:6='-2,1,4,7,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=100 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=104 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=108 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=112 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=116 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=120 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=124 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=128 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=132 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=136 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=140 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=144 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=149 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=153 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=157 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=161 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=20 - TlvChanNum:1=165 - TlvPwr:6='-1,2,5,8,0,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=36 - TlvPwr:6='-4,-1,2,5,8,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=40 - TlvPwr:6='-4,-1,2,5,8,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=44 - TlvPwr:6='-4,-1,2,5,8,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=48 - TlvPwr:6='-4,-1,2,5,8,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=52 - TlvPwr:6='-5,-2,1,4,7,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=56 - TlvPwr:6='-5,-2,1,4,7,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=60 - TlvPwr:6='-5,-2,1,4,7,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=64 - TlvPwr:6='-5,-2,1,4,7,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=100 - TlvPwr:6='-4,-1,2,5,8,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=104 - TlvPwr:6='-4,-1,2,5,8,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=108 - TlvPwr:6='-4,-1,2,5,8,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=112 - TlvPwr:6='-4,-1,2,5,8,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=116 - TlvPwr:6='-4,-1,2,5,8,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=120 - TlvPwr:6='-4,-1,2,5,8,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=124 - TlvPwr:6='-4,-1,2,5,8,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=128 - TlvPwr:6='-4,-1,2,5,8,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=132 - TlvPwr:6='-4,-1,2,5,8,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=136 - TlvPwr:6='-4,-1,2,5,8,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=149 - TlvPwr:6='-4,-1,2,5,8,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=153 - TlvPwr:6='-4,-1,2,5,8,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=157 - TlvPwr:6='-4,-1,2,5,8,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=40 - TlvChanNum:1=161 - TlvPwr:6='-4,-1,2,5,8,0' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=36 - TlvPwr:6='-7,-4,-1,2,5,8' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=40 - TlvPwr:6='-7,-4,-1,2,5,8' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=44 - TlvPwr:6='-7,-4,-1,2,5,8' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=48 - TlvPwr:6='-7,-4,-1,2,5,8' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=52 - TlvPwr:6='-8,-5,-2,1,4,7' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=56 - TlvPwr:6='-8,-5,-2,1,4,7' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=60 - TlvPwr:6='-8,-5,-2,1,4,7' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=64 - TlvPwr:6='-8,-5,-2,1,4,7' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=100 - TlvPwr:6='-7,-4,-1,2,5,8' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=104 - TlvPwr:6='-7,-4,-1,2,5,8' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=108 - TlvPwr:6='-7,-4,-1,2,5,8' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=112 - TlvPwr:6='-7,-4,-1,2,5,8' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=116 - TlvPwr:6='-7,-4,-1,2,5,8' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=120 - TlvPwr:6='-7,-4,-1,2,5,8' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=124 - TlvPwr:6='-7,-4,-1,2,5,8' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=128 - TlvPwr:6='-7,-4,-1,2,5,8' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=149 - TlvPwr:6='-7,-4,-1,2,5,8' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=153 - TlvPwr:6='-7,-4,-1,2,5,8' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=157 - TlvPwr:6='-7,-4,-1,2,5,8' - } - - PwrVal.TlvType:2=0x0244 - PwrVal.TlvLength:2={ - TLVStartFreq:2=5000 - TlvChanWidth:1=80 - TlvChanNum:1=161 - TlvPwr:6='-7,-4,-1,2,5,8' - } -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/sdio_pulldown.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/sdio_pulldown.conf deleted file mode 100644 index 745978b..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/sdio_pulldown.conf +++ /dev/null @@ -1,27 +0,0 @@ -# File : sdio_pulldown.conf - -######################### SDIO Pulldown command ############### -sdio_pulldown_get={ - CmdCode=0x0093 # do NOT change this line - - Action:2=0 # GET - PullUpDelay:2=0 - PullDownDelay:2=0 -} - -sdio_pulldown_set={ - CmdCode=0x0093 # do NOT change this line - - Action:2=1 # SET - PullUpDelay:2=0 - PullDownDelay:2=0 -} - -sdio_pulldown_disable={ - CmdCode=0x0093 # do NOT change this line - - Action:2=1 # SET - PullUpDelay:2=0xffff - PullDownDelay:2=0xffff -} -######################### SDIO Pulldown command ############### diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/small_debug.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/small_debug.conf deleted file mode 100644 index 1457426..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/small_debug.conf +++ /dev/null @@ -1,62 +0,0 @@ -# File : small_debug.conf - -######################### DBG Config command ############### -small_debug_enable={ - CmdCode=0x008b # do NOT change this line - - Dst:1=0x06 # dbgs_cfg_t - Air_Chan:1=0x00 - RSVD:1=0 - Num_Entries:1=0x81 # one entry global enable - - # dbgs_t - En_Mask:2=0x0000 # en_mask_id - BaseId:2=0x0000 # base_id -} - -small_debug_disable={ - CmdCode=0x008b # do NOT change this line - - Dst:1=0x00 - Air_Chan:1=0x00 - RSVD:1=0 - Num_Entries:1=0x00 -} - -######################### DBG Get Trace Memory ############### -# Disable Air and Host destinations to disable dbgs_drain -# Enable only the Power save ID - Host interface is a course enable - not on specific event -trace_enable={ - CmdCode=0x008b # do NOT change this line - - Dst:1=0x00 # dbgs_cfg_t - don't drain debug - Air_Chan:1=0x00 - RSVD:1=0 - Num_Entries:1=0x02 # 2 entry - - # dbgs_t - En_Mask:2=0x5fff # en_mask_id - enable single ID=0x80 - BaseId:2=0x0020 # base_id - En_Mask:2=0x5fff # en_mask_id - enable single ID=0x80 - BaseId:2=0x0021 # base_id -} - -get_trace={ - CmdCode=0x008c # do NOT change this line - - startAddress:4=0x02 # read trace memeory - not a generic memory read - len:2=0x0000 # First read=0 - for next reads use the returned next start -} - -trace_disable={ - CmdCode=0x008b # do NOT change this line - - Dst:1=0x00 # dbgs_cfg_t - don't drain debug - Air_Chan:1=0x00 - RSVD:1=0 - Num_Entries:1=0x01 # one entry - - # dbgs_t - En_Mask:2=0x0000 # en_mask_id - BaseId:2=0x0000 # base_id -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/smc.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/smc.conf deleted file mode 100644 index 3c58de7..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/smc.conf +++ /dev/null @@ -1,124 +0,0 @@ -# File : smc.conf - -smc_get={ - CmdCode=0x012d #do not change this - - Action:2=0 # GET -} - -smc_set={ - CmdCode=0x012d #do not change this - - Action:2=1 # SET - -# SSID - SSIDHeaderType:2=0x0000 - SSIDHeaderLen:2={ - SSID:10="NXP_SMC_1" - } - -# Beacon Period. -# This should be smaller than than MinScanTime. - BeaconHeaderType:2=0x012c - BeaconHeaderLen:2={ - beaconPeriod:2=30 - } - -# Channel list. -# ChanNumber, MinScanTime and ScanTime are mandatory. -# MinScanTime is minimum dwelling time for ChanNumber channel. -# ScanTime is maximum dwelling time for ChanNumber channel. - ChannHeaderType:2=0x0101 - ChannHeaderLen:2={ - -# Following four line define one channel. -# Please add similar four lines with different channel number for new channel. - Chan1_RadioType:1=0 - Chan1_ChanNumber:1=1 - Chan1_ScanType:1=2 - Chan1_MinScanTime:2=40 - Chan1_ScanTime:2=200 - - Chan2_RadioType:1=0 - Chan2_ChanNumber:1=6 - Chan2_ScanType:1=3 - Chan2_MinScanTime:2=40 - Chan2_ScanTime:2=200 - - Chan3_RadioType:1=0 - Chan3_ChanNumber:1=9 - Chan3_ScanType:1=2 - Chan3_MinScanTime:2=40 - Chan3_ScanTime:2=100 - - Chan2_RadioType:1=0 - Chan2_ChanNumber:1=11 - Chan2_ScanType:1=3 - Chan2_MinScanTime:2=40 - Chan2_ScanTime:2=200 - } - -#Custom IE -#Currently max size of custom IE supported is 50 bytes. -# -# CustomHeaderType:2=0x010a -# CustomHeaderLen:2={ -# start:1=0xdd -# start:1=0x10 -# start:1=0x00 -# start:1=0x01 -# start:1=0x02 -# start:1=0x03 -# start:1=0x04 -# start:1=0x05 -# start:1=0x06 -# start:1=0x07 -# start:1=0x08 -# start:1=0x09 -# start:1=0x0a -# start:1=0x0b -# start:1=0x0c -# start:1=0x0d -# start:1=0x0e -# start:1=0x0f -# } - -#Multicast mac filtering address -#All the multicast packets from starting mac address to ending mac address would -#be captured and sent to the host. - MACHeaderType:2=0x01cc - MACHeaderLen:2={ -#Staring Multicast mac address - start:1=0x01 - start:1=0x00 - start:1=0x5e - start:1=0x00 - start:1=0x00 - start:1=0x01 - -#Ending Multicast mac address - end:1=0x01 - end:1=0x00 - end:1=0x5e - end:1=0x7f - end:1=0xff - end:1=0xff - -#FilterType -# 1 for RX AP frames -# 2 for RX STA frames -# 3 for both - Filter:2=0x3 - } - -} -smc_start={ - CmdCode=0x012d #do not change this - - Action:2=2 # START -} -smc_stop={ - CmdCode=0x012d #do not change this - - Action:2=3 # STOP -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ssu.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ssu.conf deleted file mode 100644 index 6b6de37..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/ssu.conf +++ /dev/null @@ -1,13 +0,0 @@ -# File ssu.conf -ssu_params_cfg={ - nskip=3 #0-3; # of FFT samples to skip - nsel=2 #0-3: # of FFT samples selected to dump - adcdownsample=1 #0-3: Down sample ADC input for buffering - mask_adc_pkt=1 #0-1: Mask out ADC Data from spectral packet - out_16bits=1 #0-1: Enable 16-Bit FFT output data precision in spectral packet - spec_pwr_enable=1 #0-1: Enable power spectrum in dB for spectral packet - rate_reduction=1 #0-1: Enable spectral packet rae reduction in DB output format - n_pkt_avg=6 #0-7: Number of spectral packets over which spectral data is to be averaged. -} - - diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/subevent.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/subevent.conf deleted file mode 100644 index ac7f333..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/subevent.conf +++ /dev/null @@ -1,103 +0,0 @@ -# File : subevent.conf - -######################### Subscribe Events command ################## -subevent_get={ - CmdCode=0x0075 # do NOT change this line - - Action:2=0 # GET - Events:2=0 -} - -subevent_set={ - CmdCode=0x0075 # do NOT change this line - - Action:2=1 # SET - Events:2=0xbc8 # bit0 - Beacon RSSI_LOW - # bit1 - Beacon SNR_LOW - # bit2 - FAILED_COUNT - # bit3 - Beacon Missed - # bit4 - Beacon RSSI_HIGH - # bit5 - Beacon SNR_HIGH - # bit6 - Data RSSI_LOW - # bit7 - Data SNR_LOW - # bit8 - Data RSSI_HIGH - # bit9 - Data SNR_HIGH - # bit10 - LINK_QUALITY - # bit11 - PRE_BCN_LOST - # bit12-15 - Reserved - - LowRssiTlvType:2=0x0104 - LowRssiTlvLength:2={ - Threshold:1=70 - ReportingFreq:1=0 - } - - LowSnrTlvType:2=0x0105 - LowSnrTlvLength:2={ - Threshold:1=56 - ReportingFreq:1=0 - } - - FailedCountTlvType:2=0x0106 - FailedCountTlvLength:2={ - Threshold:1=5 - ReportingFreq:1=0 - } - - BeaconMissTlvType:2=0x0107 - BeaconMissTlvLength:2={ - BeaconMissed:1=60 - Reserved:1=0 - } - - HighRssiTlvType:2=0x0116 - HighRssiTlvLength:2={ - Threshold:1=40 - ReportingFreq:1=0 - } - - HighSnrTlvType:2=0x0117 - HighSnrTlvLength:2={ - Threshold:1=86 - ReportingFreq:1=0 - } - - DataLowRssiTlvType:2=0x0126 - DataLowRssiTlvLength:2={ - Threshold:1=10 - ReportingFreq:1=0 - } - - DataLowSnrTlvType:2=0x0127 - DataLowSnrTlvLength:2={ - Threshold:1=66 - ReportingFreq:1=0 - } - - DataHighRssiTlvType:2=0x0128 - DataHighRssiTlvLength:2={ - Threshold:1=50 - ReportingFreq:1=0 - } - - DataHighSnrTlvType:2=0x0129 - DataHighSnrTlvLength:2={ - Threshold:1=96 - ReportingFreq:1=1 - } - LinkQualityTlvType:2=0x0124 - LinkQualityTlvType:2={ - LinkSNRThreshold:2=0x0056 - LinkSNRFrequency:2=0x0003 - MinRateVal:2=0x0014 - MinRateFreq:2=0x0003 - TxLatencyVal:4=0x00C8 - TxLatencyThreshold:4=0x0003 - } - PreBcnLostTlvType:2=0x0149 - PreBcnLostTlvLength:2={ - PreBeaconCnt:1=30 - Reserved:1=0 - } -} -######################### Subscribe Events command ################## diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/tspecs.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/tspecs.conf deleted file mode 100644 index 86c1ac6..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/tspecs.conf +++ /dev/null @@ -1,100 +0,0 @@ -# TSPEC contents for TID=0, UserPriority = 6 -[tspec0] -# Element ID -dd -# Length -3d -# OUI -00 50 f2 -# OUI Type -02 -# OUI SubType -02 -# Version -01 -# TSInfo -e0 34 00 -# Nominal MSDU Size -d0 80 -# Maximum MSDU Size -d0 00 -# Min Service Interval -20 4e 00 00 -# Max Service Interval -20 4e 00 00 -# Inactivity Interval -80 96 98 00 -# Suspension Interval -ff ff ff ff -# Service Start Time -00 00 00 00 -# Minimum Data Rate -00 45 01 00 -# Mean Data Rate -00 45 01 00 -# Peak Data Rate -00 45 01 00 -# Max Burst Size -00 00 00 00 -# Delay Bound -00 00 00 00 -# Min PHY Rate -00 1b b7 00 -# Surplus Bandwidth Allowance -00 30 -# Medium Time -00 00 -# Extra Data Bytes -[/tspec0] - - -# TSPEC contents for TID=1, UserPriority = 4 -[tspec1] -# Element ID -dd -# Length -3d -# OUI -00 50 f2 -# OUI Type -02 -# OUI SubType -02 -# Version -01 -# TSInfo -e3 20 00 -# Nominal MSDU Size -96 00 -# Maximum MSDU Size -dc 05 -# Min Service Interval -00 00 00 00 -# Max Service Interval -00 00 00 00 -# Inactivity Interval -00 00 00 00 -# Suspension Interval -ff ff ff ff -# Service Start Time -00 00 00 00 -# Minimum Data Rate -a0 00 00 00 -# Mean Data Rate -a0 00 00 00 -# Peak Data Rate -a0 00 00 00 -# Max Burst Size -00 00 00 00 -# Delay Bound -00 00 00 00 -# Min PHY Rate -80 8d 5b 00 -# Surplus Bandwidth Allowance -00 30 -# Medium Time -00 00 -# Extra Data Bytes -dd 04 00 50 43 ff -[/tspec1] - diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/turbo_mode.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/turbo_mode.conf deleted file mode 100644 index a258673..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/turbo_mode.conf +++ /dev/null @@ -1,12 +0,0 @@ -#File : turbo_mode.conf -## WMM turbo mode config command -turbo_mode_set={ - CmdCode=0x0016 # do NOT change this line - Action:2=1 # 1 - SET - OID:2=0x27 # OID_WMM_TURBO_MODE - Size:2=1 - Value:1=3 # 1 -- Enable turbo_mode_1; - # 2 -- Enable turbo_mode_2; - # 3 -- Enable turbo_mode_3; - # otherwise, disable turbo_mode -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/tx_ctrl.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/tx_ctrl.conf deleted file mode 100644 index 013065b..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/tx_ctrl.conf +++ /dev/null @@ -1,58 +0,0 @@ -#protocol -Protocol=0x88dc - -# configure data rate in unit of 0.5Mbps -# 0 - auto rate determined by firmware -# Any other data rate except these data rates will -# be overwritten by default data rate. -# datarate index, unit in 0.5Mbps -# Index | 20MHz | 10MHz -# 12 | 6Mbps | 3Mbps -# 18 | 9Mbps | 4.5Mbps -# 24 | 12Mbps | 6Mbps -# 36 | 18Mbps | 9Mbps -# 48 | 24Mbps | 12Mbps -# 72 | 36Mbps | 18Mbps -# 96 | 48Mbps | 24Mbps -# 108 | 54Mbps | 27.5Mbps -Datarate=12 - -# configure Channel for the packet -# 0 - the channel set during the enable would be used -Channel=0 - -# configure Bandwith (only for 11p) -# 0: auto bandwith setting by firmware -# bit4: 1 use bit[3:0] bandwith setting -# bit[3:0]: -# 0 - 5MHz -# 1 - 10MHz -# 2 - 20MHz -# 3 - 40MHz -# 4 - 80MHz -Bandwidth=0x00 - -# configure power settings -# bit[7] host tx power control flag -# 0x0: use fw setting for tx power -# 0x1: value specified in bit[6] and bit[5:0] are valid -# bit[6] sign of the power specified in bit[5:0] -# 0x0: power specified in bit[5:0] is postive (+) -# 0x1: power specified in bit[5:0] is negative (-) -# bit[5:0] power to be used for transmission (in dBm) -Power=0x00 - -# configure Priority of the packet -# 1,2 - BK -# 0,3 - BE -# 4,5 - VI -# 6,7 - VO -Priority=0 - -# configure tx retry time -Retry_limit=0 - -# Destination MAC Address -Addr=00:50:43:22:0f:b0 - -Data=0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x8,0x9,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x8,0x9,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x8,0x9,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19 diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/txpwrlimit_cfg.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/txpwrlimit_cfg_8987.conf similarity index 51% rename from mxm_wifiex/wlan_src/mapp/mlanconfig/config/txpwrlimit_cfg.conf rename to mxm_wifiex/wlan_src/mapp/mlanconfig/config/txpwrlimit_cfg_8987.conf index c3e788d..74be6d6 100644 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/txpwrlimit_cfg.conf +++ b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/txpwrlimit_cfg_8987.conf @@ -93,525 +93,417 @@ txpwrlimit_5g_cfg_get_sub3={ ## 1: OFDM (6,9,12,18 Mbps) ## 2: OFDM (24,36 Mbps) ## 3: OFDM (48,54 Mbps) -## 4: HT20 (MCS0,1,2) -## 5: HT20 (MCS3,4) -## 6: HT20 (MCS5,6,7) -## 7: HT40 (MCS0,1,2) -## 8: HT40 (MCS3,4) -## 9: HT40 (MCS5,6,7) -## 10: HT2_20 (MCS8,9,10) -## 11: HT2_20 (MCS11,12) -## 12: HT2_20 (MCS13,14,15) -## 13: HT2_40 (MCS8,9,10) -## 14: HT2_40 (MCS11,12) -## 15: HT2_40 (MCS13,14,15) -## 16: VHT_QAM256 (MCS8) -## 17: VHT_40_QAM256 (MCS8,9) -## 18: VHT_80_PSK (MCS0,1,2) -## 19: VHT_80_QAM16 (MCS3,4) -## 20: VHT_80_QAM64 (MCS5,6,7) -## 21: VHT_80_QAM256 (MCS8,9) -## 22: VHT2_20_QAM256 (MCS8,9) -## 23: VHT2_40_QAM256 (MCS8,9) -## 24: VHT2_80_PSK (MCS0, 1, 2) -## 25: VHT2_80_QAM16 (MCS3,4) -## 26: VHT2_80_QAM64 (MCS5,6,7) -## 27: VHT2_80_QAM256 (MCS8,9) -## 28: HE_20_QAM256 (MCS8,9) -## 29: HE_20_QAM1024 (MCS10,11) -## 30: HE_40_QAM1024 (MCS10,11) -## 31: HE_80_QAM1024 (MCS10,11) -## 32: HE2_20_QAM256 (MCS8,9) -## 33: HE2_20_QAM1024 (MCS10,11) -## 34: HE2_40_QAM1024 (MCS10,11) -## 35: HE2_80_QAM1024 (MCS10,11) +## 4: HT20 (0,1,2) +## 5: HT20 (3,4) +## 6: HT20 (5,6,7) +## 7: HT40 (0,1,2) +## 8: HT40 (3,4) +## 9: HT40 (5,6,7) +## 10: VHT_QAM256 (MCS8) +## 11: VHT_40_QAM256 (MCS8,9) +## 12: VHT_80_PSK (MCS0,1,2) +## 13: VHT_80_QAM16 (MCS3,4) +## 14: VHT_80_QAM64 (MCS5,6,7) +## 15: VHT_80_QAM256 (MCS8,9) ## Power Limit in dBm ## -## Note: For KF, add VHT 20/40/80 1SS/2SS mod group. +## For 40MHz modulation groups, specify same Tx power value for a set of +## two consecutive channel frequencies +## Valid channel sets: +## (36, 40), (44, 48), (52, 56), (60, 64) +## (100, 104), (108, 112), (116, 120), (124, 128), (132, 136), (140, 144) +## (149, 153), (157, 161) +## +## For 80MHz modulation groups, specify same Tx power value for a set of +## four consecutive channel frequencies +## Valid channel sets: +## (36, 40, 44, 48), (52, 56, 60, 64) +## (100, 104, 108, 112), (116, 120, 124, 128), (132, 136, 140, 144) +## (149, 153, 157, 161) -## 2G subband0 Tx power limit CFG +## 2G Tx power limit CFG txpwrlimit_2g_cfg_set={ CmdCode=0x00fb # do NOT change this line Action:2=1 # 1 - SET - SubBand:2=0 # do NOT use this member in set cmd + RSVD:2=0 # do NOT change this line ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=2407 TLVChanWidth:1=20 TLVChanNum:1=1 - TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + TLVPwr:24='0,18,1,18,2,16,3,14,4,18,5,16,6,14,7,18,8,16,9,14,10,16,11,16' } ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=2407 TLVChanWidth:1=20 TLVChanNum:1=2 - TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + TLVPwr:24='0,18,1,18,2,16,3,14,4,18,5,16,6,14,7,18,8,16,9,14,10,16,11,16' } - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=2407 TLVChanWidth:1=20 TLVChanNum:1=3 - TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + TLVPwr:24='0,18,1,18,2,16,3,14,4,18,5,16,6,14,7,18,8,16,9,14,10,16,11,16' } ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=2407 TLVChanWidth:1=20 TLVChanNum:1=4 - TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + TLVPwr:24='0,18,1,18,2,16,3,14,4,18,5,16,6,14,7,18,8,16,9,14,10,16,11,16' } - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=2407 TLVChanWidth:1=20 TLVChanNum:1=5 - TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + TLVPwr:24='0,18,1,18,2,16,3,14,4,18,5,16,6,14,7,18,8,16,9,14,10,16,11,16' } ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=2407 TLVChanWidth:1=20 TLVChanNum:1=6 - TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + TLVPwr:24='0,18,1,18,2,16,3,14,4,18,5,16,6,14,7,18,8,16,9,14,10,16,11,16' } - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=2407 TLVChanWidth:1=20 TLVChanNum:1=7 - TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + TLVPwr:24='0,18,1,18,2,16,3,14,4,18,5,16,6,14,7,18,8,16,9,14,10,16,11,16' } ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=2407 TLVChanWidth:1=20 TLVChanNum:1=8 - TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + TLVPwr:24='0,18,1,18,2,16,3,14,4,18,5,16,6,14,7,18,8,16,9,14,10,16,11,16' } - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=2407 TLVChanWidth:1=20 TLVChanNum:1=9 - TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + TLVPwr:24='0,18,1,18,2,16,3,14,4,18,5,16,6,14,7,18,8,16,9,14,10,16,11,16' } ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=2407 TLVChanWidth:1=20 TLVChanNum:1=10 - TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + TLVPwr:24='0,18,1,18,2,16,3,14,4,18,5,16,6,14,7,18,8,16,9,14,10,16,11,16' } - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=2407 TLVChanWidth:1=20 TLVChanNum:1=11 - TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + TLVPwr:24='0,18,1,18,2,16,3,14,4,18,5,16,6,14,7,18,8,16,9,14,10,16,11,16' } ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=2407 TLVChanWidth:1=20 TLVChanNum:1=12 - TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + TLVPwr:24='0,16,1,16,2,16,3,14,4,16,5,16,6,14,7,16,8,16,9,14,10,16,11,16' } - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=2407 TLVChanWidth:1=20 TLVChanNum:1=13 - TLVPwr:32='0,17,1,15,2,15,3,13,4,15,5,15,6,13,7,15,8,15,9,13,10,15,11,15,12,15,13,15,14,15,15,15' + TLVPwr:24='0,16,1,16,2,16,3,14,4,16,5,16,6,14,7,16,8,16,9,14,10,16,11,16' } ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ - TLVStartFreq:2=2407 + TLVStartFreq:2=2414 TLVChanWidth:1=20 TLVChanNum:1=14 - TLVPwr:32='0,12,1,12,2,12,3,12,4,12,5,12,6,12,7,12,8,12,9,12,10,12,11,12,12,12,13,12,14,12,15,12' + TLVPwr:24='0,12,1,12,2,12,3,12,4,12,5,12,6,12,7,12,8,12,9,12,10,12,11,12' } } - -## 5G subband1 Tx power limit CFG -txpwrlimit_5g_cfg_set_sub0={ +## 5G Tx power limit CFG +txpwrlimit_5g_cfg_set={ CmdCode=0x00fb # do NOT change this line Action:2=1 # 1 - SET - SubBand:2=0 # do NOT use this member in set cmd + RSVD:2=0 # do NOT change this line ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=36 - TLVPwr:72='0,0,1,20,2,20,3,19,4,20,5,20,6,18,7,20,8,20,9,18,10,20,11,20,12,18,13,20,14,20,15,18,16,17,17,17,18,20,19,19,20,17,21,16,22,17,23,17,24,20,25,19,26,17,27,16,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,16,2,16,3,14,4,16,5,16,6,14,7,16,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=40 - TLVPwr:72='0,0,1,20,2,20,3,19,4,20,5,20,6,18,7,20,8,20,9,18,10,20,11,20,12,18,13,20,14,20,15,18,16,17,17,17,18,20,19,19,20,17,21,16,22,17,23,17,24,20,25,19,26,17,27,16,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,16,2,16,3,14,4,16,5,16,6,14,7,16,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=44 - TLVPwr:72='0,0,1,20,2,20,3,19,4,20,5,20,6,18,7,20,8,20,9,18,10,20,11,20,12,18,13,20,14,20,15,18,16,18,17,17,18,20,19,19,20,17,21,16,22,18,23,17,24,20,25,19,26,17,27,16,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,16,2,16,3,14,4,16,5,16,6,14,7,16,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=48 - TLVPwr:72='0,0,1,20,2,20,3,19,4,20,5,20,6,18,7,20,8,20,9,18,10,20,11,20,12,18,13,20,14,20,15,18,16,18,17,17,18,20,19,19,20,17,21,16,22,18,23,17,24,20,25,19,26,17,27,16,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,16,2,16,3,14,4,16,5,16,6,14,7,16,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=52 - TLVPwr:72='0,0,1,20,2,20,3,19,4,20,5,20,6,18,7,20,8,20,9,19,10,20,11,20,12,18,13,20,14,20,15,19,16,18,17,17,18,19,19,19,20,18,21,17,22,18,23,17,24,19,25,19,26,18,27,17,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=56 - TLVPwr:72='0,0,1,20,2,20,3,19,4,20,5,20,6,18,7,20,8,20,9,19,10,20,11,20,12,18,13,20,14,20,15,19,16,18,17,17,18,19,19,19,20,18,21,17,22,18,23,17,24,19,25,19,26,18,27,17,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=60 - TLVPwr:72='0,0,1,20,2,20,3,19,4,20,5,20,6,18,7,20,8,20,9,19,10,20,11,20,12,18,13,20,14,20,15,19,16,18,17,17,18,19,19,19,20,18,21,17,22,18,23,17,24,19,25,19,26,18,27,17,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=64 - TLVPwr:72='0,0,1,20,2,20,3,19,4,20,5,20,6,18,7,20,8,20,9,19,10,20,11,20,12,18,13,20,14,20,15,19,16,18,17,17,18,19,19,19,20,18,21,17,22,18,23,17,24,19,25,19,26,18,27,17,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } -} - -## 5G subband2 Tx power limit CFG -txpwrlimit_5g_cfg_set_sub1={ - CmdCode=0x00fb # do NOT change this line - Action:2=1 # 1 - SET - SubBand:2=0 # do NOT use this member in set cmd - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=100 - TLVPwr:72='0,0,1,20,2,20,3,20,4,18,5,18,6,19,7,18,8,18,9,18,10,18,11,18,12,19,13,18,14,18,15,18,16,18,17,16,18,18,19,19,20,18,21,16,22,18,23,16,24,18,25,19,26,18,27,16,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=104 - TLVPwr:72='0,0,1,20,2,20,3,20,4,18,5,18,6,18,7,18,8,18,9,18,10,18,11,18,12,18,13,18,14,18,15,18,16,18,17,16,18,18,19,19,20,18,21,16,22,18,23,16,24,18,25,19,26,18,27,16,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=108 - TLVPwr:72='0,0,1,20,2,20,3,20,4,18,5,18,6,19,7,18,8,18,9,17,10,18,11,18,12,19,13,18,14,18,15,17,16,18,17,16,18,18,19,19,20,18,21,16,22,18,23,16,24,18,25,19,26,18,27,16,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=112 - TLVPwr:72='0,0,1,20,2,20,3,20,4,18,5,18,6,19,7,18,8,18,9,17,10,18,11,18,12,19,13,18,14,18,15,17,16,17,17,16,18,18,19,19,20,18,21,16,22,17,23,16,24,18,25,19,26,18,27,16,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=116 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,18,6,18,7,18,8,18,9,17,10,18,11,18,12,18,13,18,14,18,15,17,16,16,17,15,18,18,19,18,20,17,21,15,22,16,23,15,24,18,25,18,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=120 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,18,6,18,7,18,8,18,9,17,10,18,11,18,12,18,13,18,14,18,15,17,16,17,17,15,18,18,19,18,20,17,21,15,22,17,23,15,24,18,25,18,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=124 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,18,6,18,7,18,8,18,9,18,10,18,11,18,12,18,13,18,14,18,15,18,16,17,17,15,18,18,19,18,20,17,21,15,22,17,23,15,24,18,25,18,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=128 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,18,6,18,7,18,8,18,9,18,10,18,11,18,12,18,13,18,14,18,15,18,16,17,17,15,18,18,19,18,20,17,21,15,22,17,23,15,24,18,25,18,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=132 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,18,6,18,7,18,8,17,9,18,10,18,11,18,12,18,13,18,14,17,15,18,16,16,17,15,18,18,19,18,20,18,21,15,22,16,23,15,24,18,25,18,26,18,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=136 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,18,6,18,7,18,8,17,9,18,10,18,11,18,12,18,13,18,14,17,15,18,16,17,17,15,18,18,19,18,20,18,21,15,22,17,23,15,24,18,25,18,26,18,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=140 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,18,6,18,7,18,8,17,9,17,10,18,11,18,12,18,13,18,14,17,15,17,16,18,17,16,18,18,19,18,20,18,21,15,22,18,23,16,24,18,25,18,26,18,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=144 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,18,6,18,7,18,8,17,9,17,10,18,11,18,12,18,13,18,14,17,15,17,16,18,17,16,18,18,19,18,20,18,21,15,22,18,23,16,24,18,25,18,26,18,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - -} - - -## 5G subband3 Tx power limit CFG -txpwrlimit_5g_cfg_set_sub2={ - CmdCode=0x00fb # do NOT change this line - Action:2=1 # 1 - SET - SubBand:2=0 # do NOT use this member in set cmd - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=149 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,19,6,18,7,18,8,18,9,18,10,18,11,19,12,18,13,18,14,18,15,18,16,17,17,17,18,18,19,19,20,17,21,15,22,17,23,17,24,18,25,19,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=153 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,19,6,19,7,18,8,18,9,18,10,18,11,19,12,19,13,18,14,18,15,18,16,17,17,17,18,18,19,19,20,17,21,15,22,17,23,17,24,18,25,19,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=157 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,19,6,19,7,18,8,18,9,18,10,18,11,19,12,19,13,18,14,18,15,18,16,17,17,17,18,18,19,19,20,17,21,15,22,17,23,17,24,18,25,19,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=161 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,19,6,19,7,18,8,18,9,18,10,18,11,19,12,19,13,18,14,18,15,18,16,17,17,17,18,18,19,19,20,17,21,15,22,17,23,17,24,18,25,19,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=165 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,19,6,19,7,18,8,18,9,18,10,18,11,19,12,19,13,18,14,18,15,18,16,17,17,17,18,18,19,19,20,17,21,15,22,17,23,17,24,18,25,19,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - -} - - -## 5G subband4 Tx power limit CFG -txpwrlimit_5g_cfg_set_sub3={ - CmdCode=0x00fb # do NOT change this line - Action:2=1 # 1 - SET - SubBand:2=0 # do NOT use this in set cmd - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ - TLVStartFreq:2=4000 + TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=183 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,19,6,19,7,18,8,18,9,18,10,18,11,19,12,19,13,18,14,18,15,18,16,17,17,17,18,18,19,19,20,17,21,15,22,17,23,17,24,18,25,19,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ - TLVStartFreq:2=4000 + TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=184 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,19,6,19,7,18,8,18,9,18,10,18,11,19,12,19,13,18,14,18,15,18,16,17,17,17,18,18,19,19,20,17,21,15,22,17,23,17,24,18,25,19,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ - TLVStartFreq:2=4000 + TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=185 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,19,6,19,7,18,8,18,9,18,10,18,11,19,12,19,13,18,14,18,15,18,16,17,17,17,18,18,19,19,20,17,21,15,22,17,23,17,24,18,25,19,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ - TLVStartFreq:2=4000 + TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=187 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,19,6,19,7,18,8,18,9,18,10,18,11,19,12,19,13,18,14,18,15,18,16,17,17,17,18,18,19,19,20,17,21,15,22,17,23,17,24,18,25,19,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ - TLVStartFreq:2=4000 + TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=188 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,19,6,19,7,18,8,18,9,18,10,18,11,19,12,19,13,18,14,18,15,18,16,17,17,17,18,18,19,19,20,17,21,15,22,17,23,17,24,18,25,19,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ - TLVStartFreq:2=4000 + TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=189 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,19,6,19,7,18,8,18,9,18,10,18,11,19,12,19,13,18,14,18,15,18,16,17,17,17,18,18,19,19,20,17,21,15,22,17,23,17,24,18,25,19,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ - TLVStartFreq:2=4000 + TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=192 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,19,6,19,7,18,8,18,9,18,10,18,11,19,12,19,13,18,14,18,15,18,16,17,17,17,18,18,19,19,20,17,21,15,22,17,23,17,24,18,25,19,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ - TLVStartFreq:2=4000 + TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=196 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,19,6,19,7,18,8,18,9,18,10,18,11,19,12,19,13,18,14,18,15,18,16,17,17,17,18,18,19,19,20,17,21,15,22,17,23,17,24,18,25,19,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=7 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,19,6,19,7,18,8,18,9,18,10,18,11,19,12,19,13,18,14,18,15,18,16,17,17,17,18,18,19,19,20,17,21,15,22,17,23,17,24,18,25,19,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=8 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,19,6,19,7,18,8,18,9,18,10,18,11,19,12,19,13,18,14,18,15,18,16,17,17,17,18,18,19,19,20,17,21,15,22,17,23,17,24,18,25,19,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=11 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,19,6,19,7,18,8,18,9,18,10,18,11,19,12,19,13,18,14,18,15,18,16,17,17,17,18,18,19,19,20,17,21,15,22,17,23,17,24,18,25,19,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=12 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,19,6,19,7,18,8,18,9,18,10,18,11,19,12,19,13,18,14,18,15,18,16,17,17,17,18,18,19,19,20,17,21,15,22,17,23,17,24,18,25,19,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=16 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,19,6,19,7,18,8,18,9,18,10,18,11,19,12,19,13,18,14,18,15,18,16,17,17,17,18,18,19,19,20,17,21,15,22,17,23,17,24,18,25,19,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - - ChanTRPC.TlvType:2=0x0189 ChanTRPC.TlvLength:2={ TLVStartFreq:2=5000 TLVChanWidth:1=20 TLVChanNum:1=34 - TLVPwr:72='0,0,1,20,2,20,3,19,4,18,5,19,6,19,7,18,8,18,9,18,10,18,11,19,12,19,13,18,14,18,15,18,16,17,17,17,18,18,19,19,20,17,21,15,22,17,23,17,24,18,25,19,26,17,27,15,28,5,29,5,30,5,31,5,32,5,33,5,34,5,35,5' + TLVPwr:32='0,0,1,17,2,16,3,14,4,17,5,16,6,14,7,17,8,16,9,14,10,15,11,14,12,15,13,15,14,14,15,13' } - } - +} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/txrate_cfg.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/txrate_cfg.conf deleted file mode 100644 index fbe4846..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/txrate_cfg.conf +++ /dev/null @@ -1,172 +0,0 @@ -# File : txrate_cfg.conf - -## Tx Rate Configuration command -txrate_cfg_get={ - CmdCode=0x00d6 # do NOT change this line - Action:2=0 # 0 - GET - Index:2=0 # do NOT change this line - - TxRateScope.TlvType:2=0x0153 - TxRateScope.TlvLength:2={ - } -} - -txrate_cfg_set_bg={ - CmdCode=0x00d6 # do NOT change this line - - Action:2=1 # 1 - SET - Index:2=0 # do NOT change this line - - TxRateScope.TlvType:2=0x0153 - TxRateScope.TlvLength:2={ - ################# TXRATE SCOPE ###################### - - # The following table shows the bitmap of the rates: - # (bit 0 is the least significant bit) - # Bit Data rate - # 0 1 Mbps - # 1 2 Mbps - # 2 5.5 Mbps - # 3 11 Mbps - # 4 Reserved - HRDSSS.RateScope:2=0x0000 - - # The following table shows the bitmap of the rates: - # (bit 0 is the least significant bit) - # Bit Data rate - # 0 6 Mbps - # 1 9 Mbps - # 2 12 Mbps - # 3 18 Mbps - # 4 24 Mbps - # 5 36 Mbps - # 6 48 Mbps - # 7 54 Mbps - OFDM.RateScope:2=0x0080 - - # The following table shows the bitmap of the rates: - # (bit 0 is the least significant bit) - # Bit Data rate - # 0 MCS0 - # 1 MCS1 - # 2 MCS2 - # 3 MCS3 - # 4 MCS4 - # 5 MCS5 - # 6 MCS6 - # 7 MCS7 - # 32 MCS32 - HT.RateScopeDword0:4=0x00000000 - HT.RateScopeDword1:4=0x00000000 - HT.RateScopeDword2:4=0x00000000 - HT.RateScopeDword3:4=0x00000000 - } - - TxRateDrop.TlvType:2=0x0151 - TxRateDrop.TlvLength:2={ - RateDrop.Mode:4=0x00000001 - } -} - -txrate_cfg_set_bgn={ - CmdCode=0x00d6 # do NOT change this line - - Action:2=1 # 1 - SET - Index:2=0 # do NOT change this line - - TxRateScope.TlvType:2=0x0153 - TxRateScope.TlvLength:2={ - ################# TXRATE SCOPE ###################### - - # The following table shows the bitmap of the rates: - # (bit 0 is the least significant bit) - # Bit Data rate - # 0 1 Mbps - # 1 2 Mbps - # 2 5.5 Mbps - # 3 11 Mbps - # 4 Reserved - HRDSSS.RateScope:2=0x0000 - - # The following table shows the bitmap of the rates: - # (bit 0 is the least significant bit) - # Bit Data rate - # 0 6 Mbps - # 1 9 Mbps - # 2 12 Mbps - # 3 18 Mbps - # 4 24 Mbps - # 5 36 Mbps - # 6 48 Mbps - # 7 54 Mbps - OFDM.RateScope:2=0x0000 - - # The following table shows the bitmap of the rates: - # (bit 0 is the least significant bit) - # Bit Data rate - # 0 MCS0 - # 1 MCS1 - # 2 MCS2 - # 3 MCS3 - # 4 MCS4 - # 5 MCS5 - # 6 MCS6 - # 7 MCS7 - # 32 MCS32 - HT.RateScopeDword0:4=0x00000080 - HT.RateScopeDword1:4=0x00000000 - HT.RateScopeDword2:4=0x00000000 - HT.RateScopeDword3:4=0x00000000 - } - - TxRateDrop.TlvType:2=0x0151 - TxRateDrop.TlvLength:2={ - RateDrop.Mode:4=0x00000001 - } -} - -########supported BasicRate setting########### -basic_rate_get={ - CmdCode=0x00d6 # do NOT change this line - Action:2=0 # 0 - GET - Index:2=0 # do NOT change this line - - TlvType:2=0x21a - TlvLength:2={ - } -} - -basic_rate_set={ - CmdCode=0x00d6 # do NOT change this line - - Action:2=1 # 1 - SET - Index:2=0 # do NOT change this line - - TlvType:2=0x21a - TlvLength:2={ - BasicRateSupport:2=0x000f #defalt value - - # The following table shows the bitmap of the rates: - # (bit 0 is the least significant bit) - # Bit BasicRateSupport - # 0 DBPSK1Mbps - # 1 DQPSK2Mbps - # 2 CCK5_5Mbps - # 3 CCK11Mbps - # 4 Not used. - # 5 OFDM6Mbps - # 6 OFDM9Mbps - # 7 OFDM12Mbps - # 8 OFDM18Mbps - # 9 OFDM24Mbps - # 10 OFDM36Mbps - # 11 OFDM48Mbps - # 12 OFDM54Mbps - # 13-15 Reserved - #note: value0x0 represents no setting value - #For example: - #BasicRateSupport:2=0x3 set supported BasicRate to DBPSK1Mbps, DQPSK2Mbps - #BasicRateSupport:2=0x180 set supported BasicRate to OFDM18Mbps, OFDM12Mbps - } -} - diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/wifi_mod_para.conf b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/wifi_mod_para.conf index a88d0a2..6ea3e59 100644 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/config/wifi_mod_para.conf +++ b/mxm_wifiex/wlan_src/mapp/mlanconfig/config/wifi_mod_para.conf @@ -115,7 +115,6 @@ PCIE9098_1 = { # req_fw_nowait=1 # fw_reload=3 # fw_serial=1 -# fw_region=0 # mac_addr=00:50:43:22:1e:3d # mfg_mode=0 # drv_mode=0x5 diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/mlanconfig.c b/mxm_wifiex/wlan_src/mapp/mlanconfig/mlanconfig.c deleted file mode 100644 index 0046aa4..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/mlanconfig.c +++ /dev/null @@ -1,2963 +0,0 @@ -/** @file mlanconfig.c - * - * @brief Program to configure addition parameters into the mlandriver - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 11/26/2008: initial version - 03/10/2009: add setuserscan, getscantable etc. commands - 08/11/2009: add addts, regclass, setra, scanagent etc. commands -************************************************************************/ - -#include "mlanconfig.h" -#include "mlanhostcmd.h" -#include "mlanmisc.h" - -/** mlanconfig version number */ -#define MLANCONFIG_VER "M2.0" - -/** Initial number of total private ioctl calls */ -#define IW_INIT_PRIV_NUM 128 -/** Maximum number of total private ioctl calls supported */ -#define IW_MAX_PRIV_NUM 1024 - -/******************************************************** - Local Variables -********************************************************/ - -/** Private ioctl commands */ -enum COMMANDS { - CMD_HOSTCMD, - CMD_MEFCFG, - CMD_CFG_DATA, -#ifdef SDIO - CMD_CMD52RW, - CMD_CMD53RW, -#endif - CMD_GET_SCAN_RSP, - CMD_SET_USER_SCAN, - CMD_ADD_TS, - CMD_DEL_TS, - CMD_QCONFIG, - CMD_QSTATS, - CMD_TS_STATUS, - CMD_WMM_QSTATUS, - CMD_REGRW, - CMD_MEMRW, - CMD_STA_CUSTOM_IE, - CMD_STA_MGMT_FRAME_TX, -#ifdef OPCHAN - CMD_OPCHAN, - CMD_CHANGROUP, -#endif -}; - -static t_s8 *commands[] = { - "hostcmd", - "mefcfg", - "cfgdata", -#ifdef SDIO - "sdcmd52rw", - "sdcmd53rw", -#endif - "getscantable", - "setuserscan", - "addts", - "delts", - "qconfig", - "qstats", - "ts_status", - "qstatus", - "regrdwr", - "memrdwr", - "customie", - "mgmtframetx", -#ifdef OPCHAN - "opchan", - "changroup", -#endif -}; - -static t_s8 *usage[] = { - "Usage: ", - " mlanconfig -v (version)", - " mlanconfig [...]", - " where", - " mlanX : wireless network interface", - " cmd : hostcmd", - " : mefcfg", - " : customie", - " : mgmtframetx", - " : cfgdata", -#ifdef SDIO - " : sdcmd52rw, sdcmd53rw", -#endif - " : getscantable, setuserscan", - " : addts, delts, qconfig, qstats, ts_status, qstatus", - " : regrdwr, memrdwr", -#ifdef OPCHAN - " : opchan, changroup", -#endif - " : additional parameter for hostcmd", - " : ", - " : additional parameters for mefcfg are:", - " : ", - " : additional parameters for customie are:", - " : ", - " : additional parameters for mgmtframetx are:", - " : ", - " : additional parameter for cfgdata", - " : ", -#ifdef SDIO - " : additional parameter for sdcmd52rw", - " : ", - " : additional parameter for sdcmd53rw", - " : ... ... ", -#endif - " : additional parameter for addts", - " : ", - " : additional parameter for delts", - " : ", - " : additional parameter for qconfig", - " : <[set msdu [Queue Id: 0-3]]", - " : [get [Queue Id: 0-3]] [def [Queue Id: 0-3]]>", - " : additional parameter for qstats", - " : <[get [User Priority: 0-7]]>", - " : additional parameter for regrdwr", - " : [value]", - " : additional parameter for memrdwr", - " :
[value]", -}; - -t_s32 sockfd; /**< socket */ -t_s8 dev_name[IFNAMSIZ + 1]; /**< device name */ -static struct iw_priv_args *priv_args = NULL; /**< private args */ -static int we_version_compiled = 0; - /**< version compiled */ - -/******************************************************** - Global Variables -********************************************************/ - -/******************************************************** - Local Functions -********************************************************/ -/** - * @brief isdigit for String. - * - * @param x Char string - * @return MLAN_STATUS_FAILURE for non-digit. - * MLAN_STATUS_SUCCESS for digit - */ -static int -ISDIGIT(t_s8 *x) -{ - unsigned int i; - for (i = 0; i < strlen(x); i++) - if (isdigit(x[i]) == 0) - return MLAN_STATUS_FAILURE; - return MLAN_STATUS_SUCCESS; -} - -/** - * Check of decimal or hex string - * @param num string - */ -#define IS_HEX_OR_DIGIT(num) \ - (strncasecmp("0x", (num), 2)?ISDIGIT((num)):ishexstring((num))) - -/** - * @brief Get private info. - * - * @param ifname A pointer to net name - * @return MLAN_STATUS_SUCCESS--success, otherwise --fail - */ -static int -get_private_info(const t_s8 *ifname) -{ - /* This function sends the SIOCGIWPRIV command, which is - * handled by the kernel and gets the total number of - * private ioctl's available in the host driver. - */ - struct iwreq iwr; - int s, ret = MLAN_STATUS_SUCCESS; - struct iw_priv_args *ppriv = NULL; - struct iw_priv_args *new_priv; - int result = 0; - size_t size = IW_INIT_PRIV_NUM; - - s = socket(PF_INET, SOCK_DGRAM, 0); - if (s < 0) { - perror("socket[PF_INET,SOCK_DGRAM]"); - return MLAN_STATUS_FAILURE; - } - - memset(&iwr, 0, sizeof(iwr)); - strncpy(iwr.ifr_name, ifname, IFNAMSIZ - 1); - - do { - /* (Re)allocate the buffer */ - new_priv = realloc(ppriv, size * sizeof(ppriv[0])); - if (new_priv == NULL) { - printf("Error: Buffer allocation failed\n"); - ret = MLAN_STATUS_FAILURE; - break; - } - ppriv = new_priv; - - iwr.u.data.pointer = (caddr_t) ppriv; - iwr.u.data.length = size; - iwr.u.data.flags = 0; - - if (ioctl(s, SIOCGIWPRIV, &iwr) < 0) { - result = errno; - ret = MLAN_STATUS_FAILURE; - if (result == E2BIG) { - /* We need a bigger buffer. Check if kernel gave us any hints. */ - if (iwr.u.data.length > size) { - /* Kernel provided required size */ - size = iwr.u.data.length; - } else { - /* No hint from kernel, double the buffer size */ - size *= 2; - } - } else { - /* ioctl error */ - perror("ioctl[SIOCGIWPRIV]"); - break; - } - } else { - /* Success. Return the number of private ioctls */ - priv_args = ppriv; - ret = iwr.u.data.length; - break; - } - } while (size <= IW_MAX_PRIV_NUM); - - if ((ret == MLAN_STATUS_FAILURE) && (ppriv)) - free(ppriv); - - close(s); - - return ret; -} - -/** - * @brief Get Sub command ioctl number - * - * @param i command index - * @param priv_cnt Total number of private ioctls availabe in driver - * @param ioctl_val A pointer to return ioctl number - * @param subioctl_val A pointer to return sub-ioctl number - * @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE - */ -static int -nxp_get_subioctl_no(t_s32 i, t_s32 priv_cnt, int *ioctl_val, int *subioctl_val) -{ - t_s32 j; - - if (priv_args[i].cmd >= SIOCDEVPRIVATE) { - *ioctl_val = priv_args[i].cmd; - *subioctl_val = 0; - return MLAN_STATUS_SUCCESS; - } - - j = -1; - - /* Find the matching *real* ioctl */ - - while ((++j < priv_cnt) - && ((priv_args[j].name[0] != '\0') || - (priv_args[j].set_args != priv_args[i].set_args) || - (priv_args[j].get_args != priv_args[i].get_args))) { - } - - /* If not found... */ - if (j == priv_cnt) { - printf("%s: Invalid private ioctl definition for: 0x%x\n", - dev_name, priv_args[i].cmd); - return MLAN_STATUS_FAILURE; - } - - /* Save ioctl numbers */ - *ioctl_val = priv_args[j].cmd; - *subioctl_val = priv_args[i].cmd; - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Get ioctl number - * - * @param ifname A pointer to net name - * @param priv_cmd A pointer to priv command buffer - * @param ioctl_val A pointer to return ioctl number - * @param subioctl_val A pointer to return sub-ioctl number - * @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE - */ -static int -nxp_get_ioctl_no(const t_s8 *ifname, - const t_s8 *priv_cmd, int *ioctl_val, int *subioctl_val) -{ - t_s32 i; - t_s32 priv_cnt; - int ret = MLAN_STATUS_FAILURE; - - priv_cnt = get_private_info(ifname); - - /* Are there any private ioctls? */ - if (priv_cnt <= 0 || priv_cnt > IW_MAX_PRIV_NUM) { - /* Could skip this message ? */ - printf("%-8.8s no private ioctls.\n", ifname); - } else { - for (i = 0; i < priv_cnt; i++) { - if (priv_args[i].name[0] && - !strcmp(priv_args[i].name, priv_cmd)) { - ret = nxp_get_subioctl_no(i, priv_cnt, - ioctl_val, - subioctl_val); - break; - } - } - } - - if (priv_args) { - free(priv_args); - priv_args = NULL; - } - - return ret; -} - -/** - * @brief Retrieve the ioctl and sub-ioctl numbers for the given ioctl string - * - * @param ioctl_name Private IOCTL string name - * @param ioctl_val A pointer to return ioctl number - * @param subioctl_val A pointer to return sub-ioctl number - * - * @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE - */ -int -get_priv_ioctl(char *ioctl_name, int *ioctl_val, int *subioctl_val) -{ - int retval; - - retval = nxp_get_ioctl_no(dev_name, - ioctl_name, ioctl_val, subioctl_val); - - return retval; -} - -/** - * @brief Process host_cmd - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_host_cmd(int argc, char *argv[]) -{ - t_s8 cmdname[256]; - t_u8 *buf; - HostCmd_DS_GEN *hostcmd; - struct iwreq iwr; - int ret = MLAN_STATUS_SUCCESS; - int ioctl_val, subioctl_val; - FILE *fp = NULL; - - if (get_priv_ioctl("hostcmd", - &ioctl_val, &subioctl_val) == MLAN_STATUS_FAILURE) { - return -EOPNOTSUPP; - } - - if (argc < 5) { - printf("Error: invalid no of arguments\n"); - printf("Syntax: ./mlanconfig mlanX hostcmd \n"); - exit(1); - } - - if ((fp = fopen(argv[3], "r")) == NULL) { - fprintf(stderr, "Cannot open file %s\n", argv[3]); - exit(1); - } - - buf = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (buf == NULL) { - printf("Error: allocate memory for hostcmd failed\n"); - fclose(fp); - return -ENOMEM; - } - snprintf(cmdname, sizeof(cmdname), "%s", argv[4]); - ret = prepare_host_cmd_buffer(fp, cmdname, buf); - fclose(fp); - - if (ret == MLAN_STATUS_FAILURE) - goto _exit_; - - hostcmd = (HostCmd_DS_GEN *)buf; - memset(&iwr, 0, sizeof(iwr)); - strncpy(iwr.ifr_name, dev_name, IFNAMSIZ - 1); - iwr.u.data.pointer = (t_u8 *)hostcmd; - iwr.u.data.length = le16_to_cpu(hostcmd->size); - - iwr.u.data.flags = 0; - if (ioctl(sockfd, ioctl_val, &iwr)) { - fprintf(stderr, - "mlanconfig: MLANHOSTCMD is not supported by %s\n", - dev_name); - ret = MLAN_STATUS_FAILURE; - goto _exit_; - } - ret = process_host_cmd_resp(buf); - -_exit_: - if (buf) - free(buf); - - return ret; -} - -/** - * @brief get range - * - * @return MLAN_STATUS_SUCCESS--success, otherwise --fail - */ -static int -get_range(t_void) -{ - struct iw_range *range; - struct iwreq iwr; - size_t buf_len; - - buf_len = sizeof(struct iw_range) + 500; - range = malloc(buf_len); - if (range == NULL) { - printf("Error: allocate memory for iw_range failed\n"); - return -ENOMEM; - } - memset(range, 0, buf_len); - memset(&iwr, 0, sizeof(struct iwreq)); - iwr.u.data.pointer = (caddr_t) range; - iwr.u.data.length = buf_len; - strncpy(iwr.ifr_name, dev_name, IFNAMSIZ - 1); - - if ((ioctl(sockfd, SIOCGIWRANGE, &iwr)) < 0) { - printf("Get Range Results Failed\n"); - free(range); - return MLAN_STATUS_FAILURE; - } - we_version_compiled = range->we_version_compiled; - printf("Driver build with Wireless Extension %d\n", - range->we_version_compiled); - free(range); - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Display usage - * - * @return NA - */ -static t_void -display_usage(t_void) -{ - t_u32 i; - for (i = 0; i < NELEMENTS(usage); i++) - fprintf(stderr, "%s\n", usage[i]); -} - -/** - * @brief Find command - * - * @param maxcmds max command number - * @param cmds A pointer to commands buffer - * @param cmd A pointer to command buffer - * @return index of command or MLAN_STATUS_FAILURE - */ -static int -findcommand(t_s32 maxcmds, t_s8 *cmds[], t_s8 *cmd) -{ - t_s32 i; - - for (i = 0; i < maxcmds; i++) { - if (!strcasecmp(cmds[i], cmd)) { - return i; - } - } - - return MLAN_STATUS_FAILURE; -} - -/** - * @brief Process cfgdata - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_cfg_data(int argc, char *argv[]) -{ - t_u8 *buf; - HostCmd_DS_GEN *hostcmd; - struct iwreq iwr; - int ret = MLAN_STATUS_SUCCESS; - int ioctl_val, subioctl_val; - FILE *fp = NULL; - - if (get_priv_ioctl("hostcmd", - &ioctl_val, &subioctl_val) == MLAN_STATUS_FAILURE) { - return -EOPNOTSUPP; - } - - if (argc < 4 || argc > 5) { - printf("Error: invalid no of arguments\n"); - printf("Syntax: ./mlanconfig mlanX cfgdata \n"); - exit(1); - } - - if (argc == 5) { - if ((fp = fopen(argv[4], "r")) == NULL) { - fprintf(stderr, "Cannot open file %s\n", argv[3]); - exit(1); - } - } - buf = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (buf == NULL) { - printf("Error: allocate memory for hostcmd failed\n"); - if (argc == 5) - fclose(fp); - return -ENOMEM; - } - ret = prepare_cfg_data_buffer(argc, argv, fp, buf); - if (argc == 5) - fclose(fp); - - if (ret == MLAN_STATUS_FAILURE) - goto _exit_; - - hostcmd = (HostCmd_DS_GEN *)buf; - memset(&iwr, 0, sizeof(iwr)); - strncpy(iwr.ifr_name, dev_name, IFNAMSIZ - 1); - iwr.u.data.pointer = (t_u8 *)hostcmd; - iwr.u.data.length = le16_to_cpu(hostcmd->size); - - iwr.u.data.flags = 0; - if (ioctl(sockfd, ioctl_val, &iwr)) { - fprintf(stderr, - "mlanconfig: MLANHOSTCMD is not supported by %s\n", - dev_name); - ret = MLAN_STATUS_FAILURE; - goto _exit_; - } - ret = process_host_cmd_resp(buf); - -_exit_: - if (buf) - free(buf); - - return ret; -} - -/** - * @brief read current command - * @param ptr A pointer to data - * @param curCmd A pointer to the buf which will hold current command - * @return NULL or the pointer to the left command buf - */ -static t_s8 * -readCurCmd(t_s8 *ptr, t_s8 *curCmd) -{ - t_s32 i = 0; -#define MAX_CMD_SIZE 64 /**< Max command size */ - - while (*ptr != ']' && i < (MAX_CMD_SIZE - 1)) - curCmd[i++] = *(++ptr); - - if (*ptr != ']') - return NULL; - - curCmd[i - 1] = '\0'; - - return ++ptr; -} - -/** - * @brief parse command and hex data - * @param fp A pointer to FILE stream - * @param dst A pointer to the dest buf - * @param cmd A pointer to command buf for search - * @return Length of hex data or MLAN_STATUS_FAILURE - */ -static int -fparse_for_cmd_and_hex(FILE * fp, t_u8 *dst, t_u8 *cmd) -{ - t_s8 *ptr; - t_u8 *dptr; - t_s8 buf[256], curCmd[64]; - t_s32 isCurCmd = 0; - - dptr = dst; - while (fgets(buf, sizeof(buf), fp)) { - ptr = buf; - - while (*ptr) { - /* skip leading spaces */ - while (*ptr && isspace(*ptr)) - ptr++; - - /* skip blank lines and lines beginning with '#' */ - if (*ptr == '\0' || *ptr == '#') - break; - - if (*ptr == '[' && *(ptr + 1) != '/') { - if (!(ptr = readCurCmd(ptr, curCmd))) - return MLAN_STATUS_FAILURE; - - if (strcasecmp(curCmd, (char *)cmd)) /* Not equal */ - isCurCmd = 0; - else - isCurCmd = 1; - } - - /* Ignore the rest if it is not correct cmd */ - if (!isCurCmd) - break; - - if (*ptr == '[' && *(ptr + 1) == '/') - return (dptr - dst); - - if (isxdigit(*ptr)) { - ptr = convert2hex(ptr, dptr++); - } else { - /* Invalid character on data line */ - ptr++; - } - } - } - - return MLAN_STATUS_FAILURE; -} - -/** - * @brief Send an ADDTS command to the associated AP - * - * Process a given conf file for a specific TSPEC data block. Send the - * TSPEC along with any other IEs to the driver/firmware for transmission - * in an ADDTS request to the associated AP. - * - * Return the execution status of the command as well as the ADDTS response - * from the AP if any. - * - * mlanconfig mlanX addts - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_addts(int argc, char *argv[]) -{ - int ioctl_val, subioctl_val; - struct iwreq iwr; - wlan_ioctl_wmm_addts_req_t addtsReq; - - FILE *fp = NULL; - char filename[48]; - char config_id[20]; - - memset(&addtsReq, 0x00, sizeof(addtsReq)); - memset(filename, 0x00, sizeof(filename)); - - if (get_priv_ioctl("addts", - &ioctl_val, &subioctl_val) == MLAN_STATUS_FAILURE) { - return -EOPNOTSUPP; - } - - if (argc != 6) { - fprintf(stderr, "Invalid number of parameters!\n"); - return -EINVAL; - } - - strncpy(filename, argv[3], sizeof(filename) - 1); - - if ((fp = fopen(filename, "r")) == NULL) { - perror("fopen"); - fprintf(stderr, "Cannot open file %s\n", argv[3]); - return -EFAULT;; - } - - snprintf(config_id, sizeof(config_id), "tspec%d", atoi(argv[4])); - - addtsReq.ieDataLen = fparse_for_cmd_and_hex(fp, - addtsReq.ieData, - (t_u8 *)config_id); - - if (addtsReq.ieDataLen > 0) { - printf("Found %d bytes in the %s section of conf file %s\n", - (int)addtsReq.ieDataLen, config_id, filename); - } else { - fprintf(stderr, "section %s not found in %s\n", - config_id, filename); - if (fp) - fclose(fp); - return -EFAULT; - } - - addtsReq.timeout_ms = atoi(argv[5]); - - printf("Cmd Input:\n"); - hexdump(config_id, addtsReq.ieData, addtsReq.ieDataLen, ' '); - - strncpy(iwr.ifr_name, dev_name, IFNAMSIZ - 1); - iwr.u.data.flags = subioctl_val; - iwr.u.data.pointer = (caddr_t) & addtsReq; - iwr.u.data.length = (sizeof(addtsReq) - - sizeof(addtsReq.ieData) - + addtsReq.ieDataLen); - - if (ioctl(sockfd, ioctl_val, &iwr) < 0) { - perror("mlanconfig: addts ioctl"); - if (fp) - fclose(fp); - return -EFAULT; - } - - printf("Cmd Output:\n"); - printf("ADDTS Command Result = %d\n", addtsReq.commandResult); - printf("ADDTS IEEE Status = %d\n", addtsReq.ieeeStatusCode); - hexdump(config_id, addtsReq.ieData, addtsReq.ieDataLen, ' '); - - if (fp) - fclose(fp); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Send a DELTS command to the associated AP - * - * Process a given conf file for a specific TSPEC data block. Send the - * TSPEC along with any other IEs to the driver/firmware for transmission - * in a DELTS request to the associated AP. - * - * Return the execution status of the command. There is no response to a - * DELTS from the AP. - * - * mlanconfig mlanX delts - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_delts(int argc, char *argv[]) -{ - int ioctl_val, subioctl_val; - struct iwreq iwr; - wlan_ioctl_wmm_delts_req_t deltsReq; - - FILE *fp = NULL; - char filename[48]; - char config_id[20]; - - memset(&deltsReq, 0x00, sizeof(deltsReq)); - memset(filename, 0x00, sizeof(filename)); - - if (get_priv_ioctl("delts", - &ioctl_val, &subioctl_val) == MLAN_STATUS_FAILURE) { - return -EOPNOTSUPP; - } - - if (argc != 5) { - fprintf(stderr, "Invalid number of parameters!\n"); - return -EINVAL; - } - - strncpy(filename, argv[3], sizeof(filename) - 1); - - if ((fp = fopen(filename, "r")) == NULL) { - perror("fopen"); - fprintf(stderr, "Cannot open file %s\n", argv[3]); - return -EFAULT; - } - - snprintf(config_id, sizeof(config_id), "tspec%d", atoi(argv[4])); - - deltsReq.ieDataLen = fparse_for_cmd_and_hex(fp, - deltsReq.ieData, - (t_u8 *)config_id); - - if (deltsReq.ieDataLen > 0) { - printf("Found %d bytes in the %s section of conf file %s\n", - (int)deltsReq.ieDataLen, config_id, filename); - } else { - fprintf(stderr, "section %s not found in %s\n", - config_id, filename); - if (fp) - fclose(fp); - return -EFAULT; - } - - printf("Cmd Input:\n"); - hexdump(config_id, deltsReq.ieData, deltsReq.ieDataLen, ' '); - - strncpy(iwr.ifr_name, dev_name, IFNAMSIZ - 1); - iwr.u.data.flags = subioctl_val; - iwr.u.data.pointer = (caddr_t) & deltsReq; - iwr.u.data.length = (sizeof(deltsReq) - - sizeof(deltsReq.ieData) - + deltsReq.ieDataLen); - - if (ioctl(sockfd, ioctl_val, &iwr) < 0) { - perror("mlanconfig: delts ioctl"); - if (fp) - fclose(fp); - return -EFAULT; - } - - printf("Cmd Output:\n"); - printf("DELTS Command Result = %d\n", deltsReq.commandResult); - if (fp) - fclose(fp); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Send a WMM AC Queue configuration command to get/set/default params - * - * Configure or get the parameters of a WMM AC queue. The command takes - * an optional Queue Id as a last parameter. Without the queue id, all - * queues will be acted upon. - * - * mlanconfig mlanX qconfig set msdu [Queue Id: 0-3] - * mlanconfig mlanX qconfig get [Queue Id: 0-3] - * mlanconfig mlanX qconfig def [Queue Id: 0-3] - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_qconfig(int argc, char *argv[]) -{ - int ioctl_val, subioctl_val; - struct iwreq iwr; - wlan_ioctl_wmm_queue_config_t queue_config_cmd; - mlan_wmm_ac_e ac_idx; - mlan_wmm_ac_e ac_idx_start; - mlan_wmm_ac_e ac_idx_stop; - - const char *ac_str_tbl[] = { "BK", "BE", "VI", "VO" }; - - if (argc < 4) { - fprintf(stderr, "Invalid number of parameters!\n"); - return -EINVAL; - } - - if (get_priv_ioctl("qconfig", - &ioctl_val, &subioctl_val) == MLAN_STATUS_FAILURE) { - return -EOPNOTSUPP; - } - - memset(&queue_config_cmd, 0x00, sizeof(queue_config_cmd)); - strncpy(iwr.ifr_name, dev_name, IFNAMSIZ - 1); - iwr.u.data.pointer = (caddr_t) & queue_config_cmd; - iwr.u.data.length = sizeof(queue_config_cmd); - iwr.u.data.flags = subioctl_val; - - if (strcmp(argv[3], "get") == 0) { - /* 3 4 5 */ - /* qconfig get [qid] */ - if (argc == 4) { - ac_idx_start = WMM_AC_BK; - ac_idx_stop = WMM_AC_VO; - } else if (argc == 5) { - if (atoi(argv[4]) < WMM_AC_BK || - atoi(argv[4]) > WMM_AC_VO) { - fprintf(stderr, "ERROR: Invalid Queue ID!\n"); - return -EINVAL; - } - ac_idx_start = atoi(argv[4]); - ac_idx_stop = ac_idx_start; - } else { - fprintf(stderr, "Invalid number of parameters!\n"); - return -EINVAL; - } - queue_config_cmd.action = WMM_QUEUE_CONFIG_ACTION_GET; - - for (ac_idx = ac_idx_start; ac_idx <= ac_idx_stop; ac_idx++) { - queue_config_cmd.accessCategory = ac_idx; - if (ioctl(sockfd, ioctl_val, &iwr) < 0) { - perror("qconfig ioctl"); - } else { - printf("qconfig %s(%d): MSDU Lifetime GET = 0x%04x (%d)\n", ac_str_tbl[ac_idx], ac_idx, queue_config_cmd.msduLifetimeExpiry, queue_config_cmd.msduLifetimeExpiry); - } - } - } else if (strcmp(argv[3], "set") == 0) { - if ((argc >= 5) && strcmp(argv[4], "msdu") == 0) { - /* 3 4 5 6 7 */ - /* qconfig set msdu [qid] */ - if (argc == 6) { - ac_idx_start = WMM_AC_BK; - ac_idx_stop = WMM_AC_VO; - } else if (argc == 7) { - if (atoi(argv[6]) < WMM_AC_BK || - atoi(argv[6]) > WMM_AC_VO) { - fprintf(stderr, - "ERROR: Invalid Queue ID!\n"); - return -EINVAL; - } - ac_idx_start = atoi(argv[6]); - ac_idx_stop = ac_idx_start; - } else { - fprintf(stderr, - "Invalid number of parameters!\n"); - return -EINVAL; - } - queue_config_cmd.action = WMM_QUEUE_CONFIG_ACTION_SET; - queue_config_cmd.msduLifetimeExpiry = atoi(argv[5]); - - for (ac_idx = ac_idx_start; ac_idx <= ac_idx_stop; - ac_idx++) { - queue_config_cmd.accessCategory = ac_idx; - if (ioctl(sockfd, ioctl_val, &iwr) < 0) { - perror("qconfig ioctl"); - } else { - printf("qconfig %s(%d): MSDU Lifetime SET = 0x%04x (%d)\n", ac_str_tbl[ac_idx], ac_idx, queue_config_cmd.msduLifetimeExpiry, queue_config_cmd.msduLifetimeExpiry); - } - } - } else { - /* Only MSDU Lifetime provisioning accepted for now */ - fprintf(stderr, "Invalid set parameter: s/b [msdu]\n"); - return -EINVAL; - } - } else if (strncmp(argv[3], "def", strlen("def")) == 0) { - /* 3 4 5 */ - /* qconfig def [qid] */ - if (argc == 4) { - ac_idx_start = WMM_AC_BK; - ac_idx_stop = WMM_AC_VO; - } else if (argc == 5) { - if (atoi(argv[4]) < WMM_AC_BK || - atoi(argv[4]) > WMM_AC_VO) { - fprintf(stderr, "ERROR: Invalid Queue ID!\n"); - return -EINVAL; - } - ac_idx_start = atoi(argv[4]); - ac_idx_stop = ac_idx_start; - } else { - fprintf(stderr, "Invalid number of parameters!\n"); - return -EINVAL; - } - queue_config_cmd.action = WMM_QUEUE_CONFIG_ACTION_DEFAULT; - - for (ac_idx = ac_idx_start; ac_idx <= ac_idx_stop; ac_idx++) { - queue_config_cmd.accessCategory = ac_idx; - if (ioctl(sockfd, ioctl_val, &iwr) < 0) { - perror("qconfig ioctl"); - } else { - printf("qconfig %s(%d): MSDU Lifetime DEFAULT = 0x%04x (%d)\n", ac_str_tbl[ac_idx], ac_idx, queue_config_cmd.msduLifetimeExpiry, queue_config_cmd.msduLifetimeExpiry); - } - } - } else { - fprintf(stderr, - "Invalid qconfig command; s/b [set, get, default]\n"); - return -EINVAL; - } - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Turn on/off or retrieve and clear the queue statistics for a UP - * - * Turn the statistics collection on/off for a given UP or retrieve the - * current accumulated stats and clear them from the firmware. The command - * takes an optional Queue Id as a last parameter. Without the queue id, - * all queues will be acted upon. - * - * mlanconfig mlanX qstats get [User Priority: 0-7] - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_qstats(int argc, char *argv[]) -{ - int ioctl_val, subioctl_val; - struct iwreq iwr; - wlan_ioctl_wmm_queue_stats_t queue_stats_cmd; - t_u8 up_idx; - t_u8 up_idx_start; - t_u8 up_idx_stop; - t_u16 usedTime[MAX_USER_PRIORITIES]; - t_u16 policedTime[MAX_USER_PRIORITIES]; - - const char *ac_str_tbl[] = { "BE", "BK", "BK", "BE", - "VI", "VI", "VO", "VO" - }; - - if (argc < 3) { - fprintf(stderr, "Invalid number of parameters!\n"); - return -EINVAL; - } - - if (get_priv_ioctl("qstats", - &ioctl_val, &subioctl_val) == MLAN_STATUS_FAILURE) { - return -EOPNOTSUPP; - } - - printf("\n"); - - memset(usedTime, 0x00, sizeof(usedTime)); - memset(policedTime, 0x00, sizeof(policedTime)); - memset(&queue_stats_cmd, 0x00, sizeof(queue_stats_cmd)); - - strncpy(iwr.ifr_name, dev_name, IFNAMSIZ - 1); - iwr.u.data.pointer = (caddr_t) & queue_stats_cmd; - iwr.u.data.length = sizeof(queue_stats_cmd); - iwr.u.data.flags = subioctl_val; - - if ((argc > 3) && strcmp(argv[3], "on") == 0) { - if (argc == 4) { - up_idx_start = 0; - up_idx_stop = 7; - } else if (argc == 5) { - if (atoi(argv[4]) < 0 || atoi(argv[4]) > 7) { - fprintf(stderr, - "ERROR: Invalid User Priority!\n"); - return -EINVAL; - } - up_idx_start = atoi(argv[4]); - up_idx_stop = up_idx_start; - } else { - fprintf(stderr, "Invalid number of parameters!\n"); - return -EINVAL; - } - queue_stats_cmd.action = WMM_STATS_ACTION_START; - for (up_idx = up_idx_start; up_idx <= up_idx_stop; up_idx++) { - queue_stats_cmd.userPriority = up_idx; - if (ioctl(sockfd, ioctl_val, &iwr) < 0) { - perror("qstats ioctl"); - } else { - printf("qstats UP%d, %s turned on\n", - up_idx, ac_str_tbl[up_idx]); - } - } - } else if ((argc > 3) && strcmp(argv[3], "off") == 0) { - if (argc == 4) { - up_idx_start = 0; - up_idx_stop = 7; - } else if (argc == 5) { - if (atoi(argv[4]) < 0 || atoi(argv[4]) > 7) { - fprintf(stderr, - "ERROR: Invalid User Priority!\n"); - return -EINVAL; - } - up_idx_start = atoi(argv[4]); - up_idx_stop = up_idx_start; - } else { - fprintf(stderr, "Invalid number of parameters!\n"); - return -EINVAL; - } - queue_stats_cmd.action = WMM_STATS_ACTION_STOP; - for (up_idx = up_idx_start; up_idx <= up_idx_stop; up_idx++) { - queue_stats_cmd.userPriority = up_idx; - if (ioctl(sockfd, ioctl_val, &iwr) < 0) { - perror("qstats ioctl"); - } else { - printf("qstats UP%d, %s turned off\n", - up_idx, ac_str_tbl[up_idx]); - } - } - } else if ((argc >= 3) && - ((argc == 3) ? 1 : (strcmp(argv[3], "get") == 0))) { - /* If the user types: "mlanconfig mlanX qstats" without get argument. - * The mlanconfig application invokes "get" option for all UPs - */ - if ((argc == 4) || (argc == 3)) { - up_idx_start = 0; - up_idx_stop = 7; - } else if (argc == 5) { - if (atoi(argv[4]) < 0 || atoi(argv[4]) > 7) { - fprintf(stderr, - "ERROR: Invalid User Priority!\n"); - return -EINVAL; - } - up_idx_start = atoi(argv[4]); - up_idx_stop = up_idx_start; - } else { - fprintf(stderr, "Invalid number of parameters!\n"); - return -EINVAL; - } - printf("%s %6s %5s %8s %8s %6s %6s %6s %6s %6s %6s\n", - "AC-UP", "Count", "Loss", "TxDly", "QDly", - "<=5", "<=10", "<=20", "<=30", "<=50", ">50"); - printf("----------------------------------" - "---------------------------------------------\n"); - queue_stats_cmd.action = WMM_STATS_ACTION_GET_CLR; - - for (up_idx = up_idx_start; up_idx <= up_idx_stop; up_idx++) { - queue_stats_cmd.userPriority = up_idx; - if (ioctl(sockfd, ioctl_val, &iwr) < 0) { - perror("qstats ioctl"); - } else { - printf(" %s-%d %6u %5u %8u %8u %6u %6u %6u %6u %6u %6u\n", ac_str_tbl[up_idx], up_idx, queue_stats_cmd.pktCount, queue_stats_cmd.pktLoss, (unsigned int)queue_stats_cmd.avgTxDelay, (unsigned int)queue_stats_cmd.avgQueueDelay, queue_stats_cmd.delayHistogram[0], queue_stats_cmd.delayHistogram[1], queue_stats_cmd.delayHistogram[2], queue_stats_cmd.delayHistogram[3], (queue_stats_cmd.delayHistogram[4] + queue_stats_cmd.delayHistogram[5]), queue_stats_cmd.delayHistogram[6]); - - usedTime[up_idx] = queue_stats_cmd.usedTime; - policedTime[up_idx] = - queue_stats_cmd.policedTime; - } - } - - printf("----------------------------------" - "---------------------------------------------\n"); - printf("\nAC-UP UsedTime PolicedTime\n"); - printf("------------------------------------\n"); - - for (up_idx = up_idx_start; up_idx <= up_idx_stop; up_idx++) { - printf(" %s-%d %6u %6u\n", - ac_str_tbl[up_idx], - up_idx, - (unsigned int)usedTime[up_idx], - (unsigned int)policedTime[up_idx]); - } - } else { - fprintf(stderr, "Invalid qstats command;\n"); - return -EINVAL; - } - printf("\n"); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Get the current status of the WMM Queues - * - * Command: mlanconfig mlanX qstatus - * - * Retrieve the following information for each AC if wmm is enabled: - * - WMM IE ACM Required - * - Firmware Flow Required - * - Firmware Flow Established - * - Firmware Queue Enabled - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_wmm_qstatus(int argc, char *argv[]) -{ - int ioctl_val, subioctl_val; - struct iwreq iwr; - wlan_ioctl_wmm_queue_status_t qstatus; - mlan_wmm_ac_e acVal; - - if (get_priv_ioctl("qstatus", - &ioctl_val, &subioctl_val) == MLAN_STATUS_FAILURE) { - return -EOPNOTSUPP; - } - - memset(&qstatus, 0x00, sizeof(qstatus)); - - strncpy(iwr.ifr_name, dev_name, IFNAMSIZ - 1); - iwr.u.data.flags = subioctl_val; - iwr.u.data.pointer = (caddr_t) & qstatus; - iwr.u.data.length = (sizeof(qstatus)); - - if (ioctl(sockfd, ioctl_val, &iwr) < 0) { - perror("mlanconfig: qstatus ioctl"); - return -EFAULT; - } - - for (acVal = WMM_AC_BK; acVal <= WMM_AC_VO; acVal++) { - switch (acVal) { - case WMM_AC_BK: - printf("BK: "); - break; - case WMM_AC_BE: - printf("BE: "); - break; - case WMM_AC_VI: - printf("VI: "); - break; - case WMM_AC_VO: - printf("VO: "); - break; - default: - printf("??: "); - } - - printf("ACM[%c], FlowReq[%c], FlowCreated[%c], Enabled[%c]," - " DE[%c], TE[%c]\n", - (qstatus.acStatus[acVal].wmmAcm ? 'X' : ' '), - (qstatus.acStatus[acVal].flowRequired ? 'X' : ' '), - (qstatus.acStatus[acVal].flowCreated ? 'X' : ' '), - (qstatus.acStatus[acVal].disabled ? ' ' : 'X'), - (qstatus.acStatus[acVal].deliveryEnabled ? 'X' : ' '), - (qstatus.acStatus[acVal].triggerEnabled ? 'X' : ' ')); - } - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Get the current status of the WMM Traffic Streams - * - * Command: mlanconfig mlanX ts_status - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_wmm_ts_status(int argc, char *argv[]) -{ - int ioctl_val, subioctl_val; - struct iwreq iwr; - wlan_ioctl_wmm_ts_status_t ts_status; - int tid; - - const char *ac_str_tbl[] = { "BK", "BE", "VI", "VO" }; - - if (get_priv_ioctl("ts_status", - &ioctl_val, &subioctl_val) == MLAN_STATUS_FAILURE) { - return -EOPNOTSUPP; - } - - printf("\nTID Valid AC UP PSB FlowDir MediumTime\n"); - printf("---------------------------------------------------\n"); - - for (tid = 0; tid <= 7; tid++) { - memset(&ts_status, 0x00, sizeof(ts_status)); - ts_status.tid = tid; - - strncpy(iwr.ifr_name, dev_name, IFNAMSIZ - 1); - iwr.u.data.flags = subioctl_val; - iwr.u.data.pointer = (caddr_t) & ts_status; - iwr.u.data.length = (sizeof(ts_status)); - - if (ioctl(sockfd, ioctl_val, &iwr) < 0) { - perror("mlanconfig: ts_status ioctl"); - return -EFAULT; - } - - printf(" %02d %3s %2s %u %c ", - ts_status.tid, - (ts_status.valid ? "Yes" : "No"), - (ts_status. - valid ? ac_str_tbl[ts_status.accessCategory] : "--"), - ts_status.userPriority, (ts_status.psb ? 'U' : 'L')); - - if ((ts_status.flowDir & 0x03) == 0) { - printf("%s", " ---- "); - } else { - printf("%2s%4s", - (ts_status.flowDir & 0x01 ? "Up" : ""), - (ts_status.flowDir & 0x02 ? "Down" : "")); - } - - printf("%12u\n", ts_status.mediumTime); - } - - printf("\n"); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Provides interface to perform read/write operations on regsiter - * - * Command: mlanconfig mlanX regrdwr [value] - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_regrdwr(int argc, char *argv[]) -{ - struct iwreq iwr; - int ioctl_val, subioctl_val; - t_u32 type, offset, value; - t_u8 buf[100]; - HostCmd_DS_GEN *hostcmd = (HostCmd_DS_GEN *)buf; - int ret = MLAN_STATUS_SUCCESS; - - /* Check arguments */ - if ((argc < 5) || (argc > 6)) { - printf("Parameters for regrdwr: [value]\n"); - return -EINVAL; - } - - if (get_priv_ioctl("hostcmd", - &ioctl_val, &subioctl_val) == MLAN_STATUS_FAILURE) { - return -EOPNOTSUPP; - } - - type = a2hex_or_atoi(argv[3]); - offset = a2hex_or_atoi(argv[4]); - if (argc > 5) - value = a2hex_or_atoi(argv[5]); - if ((ret = prepare_hostcmd_regrdwr(type, offset, - (argc > 5) ? &value : NULL, buf))) { - return ret; - } - - memset(&iwr, 0, sizeof(iwr)); - strncpy(iwr.ifr_name, dev_name, IFNAMSIZ - 1); - iwr.u.data.pointer = buf; - iwr.u.data.length = le16_to_cpu(hostcmd->size); - iwr.u.data.flags = 0; - - if (ioctl(sockfd, ioctl_val, &iwr)) { - fprintf(stderr, - "mlanconfig: MLANHOSTCMD is not supported by %s\n", - dev_name); - return MLAN_STATUS_FAILURE; - } - ret = process_host_cmd_resp(buf); - - return ret; -} - -/** - * @brief Provides interface to perform read/write the adapter memory - * - * Command: mlanconfig mlanX memrdwr
[value] - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_memrdwr(int argc, char *argv[]) -{ - struct iwreq iwr; - int ioctl_val, subioctl_val; - t_u32 address, value; - t_u8 buf[100] = { 0 }; - HostCmd_DS_MEM *pmem; - HostCmd_DS_GEN *hostcmd = (HostCmd_DS_GEN *)buf; - int ret = MLAN_STATUS_SUCCESS; - - pmem = (HostCmd_DS_MEM *)(buf + S_DS_GEN); - - /* Check arguments */ - if ((argc < 4) || (argc > 5)) { - printf("Parameters for memrdwr:
[value]\n"); - return -EINVAL; - } - - if (get_priv_ioctl("hostcmd", - &ioctl_val, &subioctl_val) == MLAN_STATUS_FAILURE) { - return -EOPNOTSUPP; - } - - address = a2hex_or_atoi(argv[3]); - pmem->addr = cpu_to_le32(address); - if (argc > 4) { - pmem->action = cpu_to_le16(HostCmd_ACT_GEN_SET); - value = a2hex_or_atoi(argv[4]); - pmem->value = cpu_to_le32(value); - } else { - pmem->action = cpu_to_le16(HostCmd_ACT_GEN_GET); - pmem->value = 0; - } - hostcmd->command = cpu_to_le16(HostCmd_CMD_MEM_ACCESS); - hostcmd->size = cpu_to_le16(S_DS_GEN + sizeof(HostCmd_DS_MEM)); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - memset(&iwr, 0, sizeof(iwr)); - strncpy(iwr.ifr_name, dev_name, IFNAMSIZ - 1); - iwr.u.data.pointer = buf; - iwr.u.data.length = le16_to_cpu(hostcmd->size); - iwr.u.data.flags = 0; - - if (ioctl(sockfd, ioctl_val, &iwr)) { - fprintf(stderr, - "mlanconfig: MLANHOSTCMD is not supported by %s\n", - dev_name); - return MLAN_STATUS_FAILURE; - } - ret = process_host_cmd_resp(buf); - - return ret; -} - -/** custom IE, auto mask value */ -#define CUSTOM_IE_AUTO_MASK 0xffff - -/** - * @brief Show usage information for the customie - * command - * - * $return N/A - **/ -void -print_custom_ie_usage(void) -{ - printf("\nUsage : customie [INDEX] [MASK] [IEBuffer]"); - printf("\n empty - Get all IE settings\n"); - printf("\n INDEX: 0 - Get/Set IE index 0 setting"); - printf("\n 1 - Get/Set IE index 1 setting"); - printf("\n 2 - Get/Set IE index 2 setting"); - printf("\n 3 - Get/Set IE index 3 setting"); - printf("\n . "); - printf("\n . "); - printf("\n . "); - printf("\n -1 - Append/Delete IE automatically"); - printf("\n Delete will delete the IE from the matching IE buffer"); - printf("\n Append will append the IE to the buffer with the same mask"); - printf("\n MASK : Management subtype mask value as per bit defintions"); - printf("\n : Bit 0 - Association request."); - printf("\n : Bit 1 - Association response."); - printf("\n : Bit 2 - Reassociation request."); - printf("\n : Bit 3 - Reassociation response."); - printf("\n : Bit 4 - Probe request."); - printf("\n : Bit 5 - Probe response."); - printf("\n : Bit 8 - Beacon."); - printf("\n MASK : MASK = 0 to clear the mask and the IE buffer"); - printf("\n IEBuffer : IE Buffer in hex (max 256 bytes)\n\n"); - return; -} - -/** - * @brief Converts a string to hex value - * - * @param str A pointer to the string - * @param raw A pointer to the raw data buffer - * @return Number of bytes read - **/ -int -string2raw(char *str, unsigned char *raw) -{ - int len = (strlen(str) + 1) / 2; - - do { - if (!isxdigit(*str)) { - return -1; - } - *str = toupper(*str); - *raw = CHAR2INT(*str) << 4; - ++str; - *str = toupper(*str); - if (*str == '\0') - break; - *raw |= CHAR2INT(*str); - ++raw; - } while (*++str != '\0'); - return len; -} - -/** - * @brief Creates a hostcmd request for custom IE settings - * and sends to the driver - * - * Usage: "customie [INDEX] [MASK] [IEBuffer]" - * - * Options: INDEX : 0 - Get/Delete IE index 0 setting - * 1 - Get/Delete IE index 1 setting - * 2 - Get/Delete IE index 2 setting - * 3 - Get/Delete IE index 3 setting - * . - * . - * . - * -1 - Append IE at the IE buffer with same MASK - * MASK : Management subtype mask value - * IEBuffer: IE Buffer in hex - * empty - Get all IE settings - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return N/A - **/ -static int -process_custom_ie(int argc, char *argv[]) -{ - tlvbuf_custom_ie *tlv = NULL; - tlvbuf_max_mgmt_ie *max_mgmt_ie_tlv = NULL; - custom_ie *ie_ptr = NULL; - t_u8 *buffer = NULL; - t_u16 buf_len = 0; - t_u16 mgmt_subtype_mask = 0; - int ie_buf_len = 0, ie_len = 0, i = 0; - struct ifreq ifr; - - /* mlanconfig mlan0 customie idx flag buf */ - if (argc > 6) { - printf("ERR:Too many arguments.\n"); - print_custom_ie_usage(); - return MLAN_STATUS_FAILURE; - } - /* Error checks and initialize the command length */ - if (argc > 3) { - if (((IS_HEX_OR_DIGIT(argv[3]) == MLAN_STATUS_FAILURE) && - (atoi(argv[3]) != -1)) || (atoi(argv[3]) < -1)) { - printf("ERR:Illegal index %s\n", argv[3]); - print_custom_ie_usage(); - return MLAN_STATUS_FAILURE; - } - } - switch (argc) { - case 3: - buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - break; - case 4: - if (atoi(argv[3]) < 0) { - printf("ERR:Illegal index %s. Must be either greater than or equal to 0 for Get Operation \n", argv[3]); - print_custom_ie_usage(); - return MLAN_STATUS_FAILURE; - } - buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; - break; - case 5: - if (MLAN_STATUS_FAILURE == ishexstring(argv[4]) || - A2HEXDECIMAL(argv[4]) != 0) { - printf("ERR: Mask value should be 0 to clear IEBuffers.\n"); - print_custom_ie_usage(); - return MLAN_STATUS_FAILURE; - } - if (atoi(argv[3]) == -1) { - printf("ERR: You must provide buffer for automatic deletion.\n"); - print_custom_ie_usage(); - return MLAN_STATUS_FAILURE; - } - buf_len = sizeof(tlvbuf_custom_ie) + sizeof(custom_ie); - break; - case 6: - /* This is to check negative numbers and special symbols */ - if (MLAN_STATUS_FAILURE == IS_HEX_OR_DIGIT(argv[4])) { - printf("ERR:Mask value must be 0 or hex digits\n"); - print_custom_ie_usage(); - return MLAN_STATUS_FAILURE; - } - /* If above check is passed and mask is not hex, then it must be 0 */ - if ((ISDIGIT(argv[4]) == MLAN_STATUS_SUCCESS) && atoi(argv[4])) { - printf("ERR:Mask value must be 0 or hex digits\n "); - print_custom_ie_usage(); - return MLAN_STATUS_FAILURE; - } - if (MLAN_STATUS_FAILURE == ishexstring(argv[5])) { - printf("ERR:Only hex digits are allowed\n"); - print_custom_ie_usage(); - return MLAN_STATUS_FAILURE; - } - ie_buf_len = strlen(argv[5]); - if (!strncasecmp("0x", argv[5], 2)) { - ie_len = (ie_buf_len - 2 + 1) / 2; - argv[5] += 2; - } else - ie_len = (ie_buf_len + 1) / 2; - if (ie_len > MAX_IE_BUFFER_LEN) { - printf("ERR:Incorrect IE length %d\n", ie_buf_len); - print_custom_ie_usage(); - return MLAN_STATUS_FAILURE; - } - mgmt_subtype_mask = (t_u16)A2HEXDECIMAL(argv[4]); - buf_len = sizeof(tlvbuf_custom_ie) + sizeof(custom_ie) + ie_len; - break; - } - /* Initialize the command buffer */ - buffer = (t_u8 *)malloc(buf_len); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - memset(buffer, 0, buf_len); - tlv = (tlvbuf_custom_ie *)buffer; - tlv->tag = MRVL_MGMT_IE_LIST_TLV_ID; - if (argc == 3 || argc == 4) { - if (argc == 3) - tlv->length = 0; - else { - tlv->length = sizeof(t_u16); - ie_ptr = (custom_ie *)(tlv->ie_data); - ie_ptr->ie_index = (t_u16)(atoi(argv[3])); - } - } else { - /* Locate headers */ - ie_ptr = (custom_ie *)(tlv->ie_data); - /* Set TLV fields */ - tlv->length = sizeof(custom_ie) + ie_len; - ie_ptr->ie_index = atoi(argv[3]); - ie_ptr->mgmt_subtype_mask = mgmt_subtype_mask; - ie_ptr->ie_length = ie_len; - if (argc == 6) - string2raw(argv[5], ie_ptr->ie_buffer); - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)buffer; - /* Perform ioctl */ - if (ioctl(sockfd, CUSTOM_IE_CFG, &ifr)) { - perror("ioctl[CUSTOM_IE_CFG]"); - printf("ERR:Command sending failed!\n"); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - /* Print response */ - if (argc > 4) { - printf("custom IE setting successful\n"); - } else { - printf("Querying custom IE successful\n"); - tlv = (tlvbuf_custom_ie *)buffer; - ie_len = tlv->length; - ie_ptr = (custom_ie *)(tlv->ie_data); - while ((unsigned int)ie_len >= sizeof(custom_ie)) { - printf("Index [%d]\n", ie_ptr->ie_index); - if (ie_ptr->ie_length) - printf("Management Subtype Mask = 0x%02x\n", - (ie_ptr->mgmt_subtype_mask) == 0 ? - CUSTOM_IE_AUTO_MASK : - (ie_ptr->mgmt_subtype_mask)); - else - printf("Management Subtype Mask = 0x%02x\n", - (ie_ptr->mgmt_subtype_mask)); - hexdump("IE Buffer", (void *)ie_ptr->ie_buffer, - ie_ptr->ie_length, ' '); - ie_len -= sizeof(custom_ie) + ie_ptr->ie_length; - ie_ptr = (custom_ie *)((t_u8 *)ie_ptr + - sizeof(custom_ie) + - ie_ptr->ie_length); - } - } - max_mgmt_ie_tlv = - (tlvbuf_max_mgmt_ie *)(buffer + sizeof(tlvbuf_custom_ie) + - tlv->length); - if (max_mgmt_ie_tlv) { - if (max_mgmt_ie_tlv->tag == MRVL_MAX_MGMT_IE_TLV_ID) { - for (i = 0; i < max_mgmt_ie_tlv->count; i++) { - printf("buf%d_size = %d\n", i, - max_mgmt_ie_tlv->info[i].buf_size); - printf("number of buffers = %d\n", - max_mgmt_ie_tlv->info[i].buf_count); - printf("\n"); - } - } - } - if (buffer) - free(buffer); - - return MLAN_STATUS_SUCCESS; -} - -/******************************************************** - Global Functions -********************************************************/ -/** - * @brief Get one line from the File - * - * @param fp File handler - * @param str Storage location for data. - * @param size Maximum number of characters to read. - * @param lineno A pointer to return current line number - * @return returns string or NULL - */ -char * -mlan_config_get_line(FILE * fp, t_s8 *str, t_s32 size, int *lineno) -{ - char *start, *end; - int out, next_line; - - if (!fp || !str) - return NULL; - - do { -read_line: - if (!fgets(str, size, fp)) - break; - start = str; - start[size - 1] = '\0'; - end = start + strlen(str); - (*lineno)++; - - out = 1; - while (out && (start < end)) { - next_line = 0; - /* Remove empty lines and lines starting with # */ - switch (start[0]) { - case ' ': /* White space */ - case '\t': /* Tab */ - start++; - break; - case '#': - case '\n': - case '\0': - next_line = 1; - break; - case '\r': - if (start[1] == '\n') - next_line = 1; - else - start++; - break; - default: - out = 0; - break; - } - if (next_line) - goto read_line; - } - - /* Remove # comments unless they are within a double quoted - * string. Remove trailing white space. */ - if ((end = strstr(start, "\""))) { - if (!(end = strstr(end + 1, "\""))) - end = start; - } else - end = start; - - if ((end = strstr(end + 1, "#"))) - *end-- = '\0'; - else - end = start + strlen(start) - 1; - - out = 1; - while (out && (start < end)) { - switch (*end) { - case ' ': /* White space */ - case '\t': /* Tab */ - case '\n': - case '\r': - *end = '\0'; - end--; - break; - default: - out = 0; - break; - } - } - - if (*start == '\0') - continue; - - return start; - } while (1); - - return NULL; -} - -/** - * @brief parse hex data - * @param fp File handler - * @param dst A pointer to receive hex data - * @return length of hex data - */ -int -fparse_for_hex(FILE * fp, t_u8 *dst) -{ - t_s8 *ptr; - t_u8 *dptr; - t_s8 buf[256]; - - dptr = dst; - while (fgets(buf, sizeof(buf), fp)) { - ptr = buf; - - while (*ptr) { - /* skip leading spaces */ - while (*ptr && (isspace(*ptr) || *ptr == '\t')) - ptr++; - - /* skip blank lines and lines beginning with '#' */ - if (*ptr == '\0' || *ptr == '#') - break; - - if (isxdigit(*ptr)) { - ptr = convert2hex(ptr, dptr++); - } else { - /* Invalid character on data line */ - ptr++; - } - } - } - - return (dptr - dst); -} - -#define STACK_NBYTES 100 /**< Number of bytes in stack */ -#define MAX_BYTESEQ 6 /**< Maximum byte sequence */ -#define TYPE_DNUM 1 /**< decimal number */ -#define TYPE_BYTESEQ 2 /**< byte sequence */ -#define MAX_OPERAND 0x40 /**< Maximum operands */ -#define TYPE_EQ (MAX_OPERAND+1) /**< byte comparison: == operator */ -#define TYPE_EQ_DNUM (MAX_OPERAND+2) /**< decimal comparison: =d operator */ -#define TYPE_EQ_BIT (MAX_OPERAND+3) /**< bit comparison: =b operator */ -#define TYPE_AND (MAX_OPERAND+4) /**< && operator */ -#define TYPE_OR (MAX_OPERAND+5) /**< || operator */ - -typedef struct { - t_u16 sp; /**< Stack pointer */ - t_u8 byte[STACK_NBYTES]; /**< Stack */ -} mstack_t; - -typedef struct { - t_u8 type; /**< Type */ - t_u8 reserve[3]; /**< so 4-byte align val array */ - /* byte sequence is the largest among all the operands and operators. */ - /* byte sequence format: 1 byte of num of bytes, then variable num bytes */ - t_u8 val[MAX_BYTESEQ + 1];/**< Value */ -} op_t; - -/** - * @brief push data to stack - * - * @param s a pointer to mstack_t structure - * - * @param nbytes number of byte to push to stack - * - * @param val a pointer to data buffer - * - * @return TRUE-- sucess , FALSE -- fail - * - */ -static int -push_n(mstack_t * s, t_u8 nbytes, t_u8 *val) -{ - if ((s->sp + nbytes) < STACK_NBYTES) { - memcpy((void *)(s->byte + s->sp), (const void *)val, - (size_t) nbytes); - s->sp += nbytes; - /* printf("push: n %d sp %d\n", nbytes, s->sp); */ - return TRUE; - } else /* stack full */ - return FALSE; -} - -/** - * @brief push data to stack - * - * @param s a pointer to mstack_t structure - * - * @param op a pointer to op_t structure - * - * @return TRUE-- sucess , FALSE -- fail - * - */ -static int -push(mstack_t * s, op_t * op) -{ - t_u8 nbytes; - switch (op->type) { - case TYPE_DNUM: - if (push_n(s, 4, op->val)) - return (push_n(s, 1, &op->type)); - return FALSE; - case TYPE_BYTESEQ: - nbytes = op->val[0]; - if (push_n(s, nbytes, op->val + 1) && - push_n(s, 1, op->val) && push_n(s, 1, &op->type)) - return TRUE; - return FALSE; - default: - return (push_n(s, 1, &op->type)); - } -} - -/** - * @brief parse RPN string - * - * @param s a pointer to Null-terminated string to scan. - * - * @param first_time a pointer to return first_time - * - * @return A pointer to the last token found in string. - * NULL is returned when there are no more tokens to be found. - * - */ -static char * -getop(char *s, int *first_time) -{ - const char delim[] = " \t\n"; - char *p; - if (*first_time) { - p = strtok(s, delim); - *first_time = FALSE; - } else { - p = strtok(NULL, delim); - } - return (p); -} - -/** - * @brief Verify hex digit. - * - * @param c input ascii char - * @param h a pointer to return integer value of the digit char. - * @return TURE -- c is hex digit, FALSE -- c is not hex digit. - */ -static int -ishexdigit(char c, t_u8 *h) -{ - if (c >= '0' && c <= '9') { - *h = c - '0'; - return (TRUE); - } else if (c >= 'a' && c <= 'f') { - *h = c - 'a' + 10; - return (TRUE); - } else if (c >= 'A' && c <= 'F') { - *h = c - 'A' + 10; - return (TRUE); - } - return (FALSE); -} - -/** - * @brief convert hex string to integer. - * - * @param s A pointer to hex string, string length up to 2 digits. - * @return integer value. - */ -static t_u8 -hex_atoi(char *s) -{ - int i; - t_u8 digit; /* digital value */ - t_u8 t = 0; /* total value */ - - for (i = 0, t = 0; ishexdigit(s[i], &digit) && i < 2; i++) - t = 16 * t + digit; - return (t); -} - -/** - * @brief Parse byte sequence in hex format string to a byte sequence. - * - * @param opstr A pointer to byte sequence in hex format string, with ':' as delimiter between two byte. - * @param val A pointer to return byte sequence string - * @return NA - */ -static void -parse_hex(char *opstr, t_u8 *val) -{ - char delim = ':'; - char *p; - char *q; - t_u8 i; - - /* +1 is for skipping over the preceding h character. */ - p = opstr + 1; - - /* First byte */ - val[1] = hex_atoi(p++); - - /* Parse subsequent bytes. */ - /* Each byte is preceded by the : character. */ - for (i = 1; *p; i++) { - q = strchr(p, delim); - if (!q) - break; - p = q + 1; - val[i + 1] = hex_atoi(p); - } - /* Set num of bytes */ - val[0] = i; -} - -/** - * @brief str2bin, convert RPN string to binary format - * - * @param str A pointer to rpn string - * @param stack A pointer to mstack_t structure - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -str2bin(char *str, mstack_t * stack) -{ - int first_time; - char *opstr; - op_t op; /* operator/operand */ - int dnum; - int ret = MLAN_STATUS_SUCCESS; - - memset(stack, 0, sizeof(mstack_t)); - first_time = TRUE; - while ((opstr = getop(str, &first_time)) != NULL) { - if (isdigit(*opstr)) { - op.type = TYPE_DNUM; - dnum = cpu_to_le32(atoi(opstr)); - memcpy((t_u8 *)op.val, &dnum, sizeof(dnum)); - if (!push(stack, &op)) { - printf("push decimal number failed\n"); - ret = MLAN_STATUS_FAILURE; - break; - } - } else if (*opstr == 'h') { - op.type = TYPE_BYTESEQ; - parse_hex(opstr, op.val); - if (!push(stack, &op)) { - printf("push byte sequence failed\n"); - ret = MLAN_STATUS_FAILURE; - break; - } - } else if (!strcmp(opstr, "==")) { - op.type = TYPE_EQ; - if (!push(stack, &op)) { - printf("push byte cmp operator failed\n"); - ret = MLAN_STATUS_FAILURE; - break; - } - } else if (!strcmp(opstr, "=d")) { - op.type = TYPE_EQ_DNUM; - if (!push(stack, &op)) { - printf("push decimal cmp operator failed\n"); - ret = MLAN_STATUS_FAILURE; - break; - } - } else if (!strcmp(opstr, "=b")) { - op.type = TYPE_EQ_BIT; - if (!push(stack, &op)) { - printf("push bit cmp operator failed\n"); - ret = MLAN_STATUS_FAILURE; - break; - } - } else if (!strcmp(opstr, "&&")) { - op.type = TYPE_AND; - if (!push(stack, &op)) { - printf("push AND operator failed\n"); - ret = MLAN_STATUS_FAILURE; - break; - } - } else if (!strcmp(opstr, "||")) { - op.type = TYPE_OR; - if (!push(stack, &op)) { - printf("push OR operator failed\n"); - ret = MLAN_STATUS_FAILURE; - break; - } - } else { - printf("Unknown operand\n"); - ret = MLAN_STATUS_FAILURE; - break; - } - } - return ret; -} - -/** - * @brief Converts colon separated MAC address to hex value - * - * @param mac A pointer to the colon separated MAC string - * @param raw A pointer to the hex data buffer - * @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE - * MAC_BROADCAST - if breadcast mac - * MAC_MULTICAST - if multicast mac - */ -static int -mac2raw(char *mac, t_u8 *raw) -{ - unsigned int temp_raw[ETH_ALEN]; - int num_tokens = 0; - int i; - - if (strlen(mac) != ((2 * ETH_ALEN) + (ETH_ALEN - 1))) { - return MLAN_STATUS_FAILURE; - } - num_tokens = sscanf(mac, "%2x:%2x:%2x:%2x:%2x:%2x", - temp_raw + 0, temp_raw + 1, temp_raw + 2, - temp_raw + 3, temp_raw + 4, temp_raw + 5); - if (num_tokens != ETH_ALEN) { - return MLAN_STATUS_FAILURE; - } - for (i = 0; i < num_tokens; i++) - raw[i] = (t_u8)temp_raw[i]; - - if (memcmp(raw, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) == 0) { - return MAC_BROADCAST; - } else if (raw[0] & 0x01) { - return MAC_MULTICAST; - } - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Parse function for a configuration line - * - * @param s Storage buffer for data - * @param size Maximum size of data - * @param stream File stream pointer - * @param line Pointer to current line within the file - * @param _pos Output string or NULL - * @return String or NULL - */ -static char * -config_get_line(char *s, int size, FILE * stream, int *line, char **_pos) -{ - *_pos = mlan_config_get_line(stream, s, size, line); - return *_pos; -} - -/** - * @brief Parses a command line - * - * @param line The line to parse - * @param args Pointer to the argument buffer to be filled in - * @return Number of arguments in the line or EOF - */ -static int -parse_line(char *line, char *args[]) -{ - int arg_num = 0; - int is_start = 0; - int is_quote = 0; - int length = 0; - int i = 0; - - arg_num = 0; - length = strlen(line); - /* Process line */ - - /* Find number of arguments */ - is_start = 0; - is_quote = 0; - for (i = 0; i < length; i++) { - /* Ignore leading spaces */ - if (is_start == 0) { - if (line[i] == ' ') { - continue; - } else if (line[i] == '\t') { - continue; - } else if (line[i] == '\n') { - break; - } else { - is_start = 1; - args[arg_num] = &line[i]; - arg_num++; - } - } - if (is_start == 1) { - /* Ignore comments */ - if (line[i] == '#') { - if (is_quote == 0) { - line[i] = '\0'; - arg_num--; - } - break; - } - /* Separate by '=' */ - if (line[i] == '=') { - line[i] = '\0'; - is_start = 0; - continue; - } - /* Separate by ',' */ - if (line[i] == ',') { - line[i] = '\0'; - is_start = 0; - continue; - } - /* Change ',' to ' ', but not inside quotes */ - if ((line[i] == ',') && (is_quote == 0)) { - line[i] = ' '; - continue; - } - } - /* Remove newlines */ - if (line[i] == '\n') { - line[i] = '\0'; - } - /* Check for quotes */ - if (line[i] == '"') { - is_quote = (is_quote == 1) ? 0 : 1; - continue; - } - if (((line[i] == ' ') || (line[i] == '\t')) && (is_quote == 0)) { - line[i] = '\0'; - is_start = 0; - continue; - } - } - return arg_num; -} - -#define FILTER_BYTESEQ TYPE_EQ /**< byte sequence */ -#define FILTER_DNUM TYPE_EQ_DNUM /**< decimal number */ -#define FILTER_BITSEQ TYPE_EQ_BIT /**< bit sequence */ -#define FILTER_TEST FILTER_BITSEQ+1 /**< test */ - -#define NAME_TYPE 1 /**< Field name 'type' */ -#define NAME_PATTERN 2 /**< Field name 'pattern' */ -#define NAME_OFFSET 3 /**< Field name 'offset' */ -#define NAME_NUMBYTE 4 /**< Field name 'numbyte' */ -#define NAME_REPEAT 5 /**< Field name 'repeat' */ -#define NAME_BYTE 6 /**< Field name 'byte' */ -#define NAME_MASK 7 /**< Field name 'mask' */ -#define NAME_DEST 8 /**< Field name 'dest' */ - -static struct mef_fields { - t_s8 *name; - /**< Name */ - t_s8 nameid; - /**< Name Id. */ -} mef_fields[] = { - { - "type", NAME_TYPE}, { - "pattern", NAME_PATTERN}, { - "offset", NAME_OFFSET}, { - "numbyte", NAME_NUMBYTE}, { - "repeat", NAME_REPEAT}, { - "byte", NAME_BYTE}, { - "mask", NAME_MASK}, { - "dest", NAME_DEST} -}; - -/** - * @brief get filter data - * - * @param fp A pointer to file stream - * @param ln A pointer to line number - * @param buf A pointer to hostcmd data - * @param size A pointer to the return size of hostcmd buffer - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -mlan_get_filter_data(FILE * fp, int *ln, t_u8 *buf, t_u16 *size) -{ - t_s32 errors = 0, i; - t_s8 line[256], *pos, *pos1; - t_u16 type = 0; - t_u32 pattern = 0; - t_u16 repeat = 0; - t_u16 offset = 0; - t_s8 byte_seq[50]; - t_s8 mask_seq[50]; - t_u16 numbyte = 0; - t_s8 type_find = 0; - t_s8 pattern_find = 0; - t_s8 offset_find = 0; - t_s8 numbyte_find = 0; - t_s8 repeat_find = 0; - t_s8 byte_find = 0; - t_s8 mask_find = 0; - t_s8 dest_find = 0; - t_s8 dest_seq[50]; - - *size = 0; - while ((pos = mlan_config_get_line(fp, line, sizeof(line), ln))) { - if (strcmp(pos, "}") == 0) { - break; - } - pos1 = strchr(pos, '='); - if (pos1 == NULL) { - printf("Line %d: Invalid mef_filter line '%s'\n", *ln, - pos); - errors++; - continue; - } - *pos1++ = '\0'; - for (i = 0; (t_u32)i < NELEMENTS(mef_fields); i++) { - if (strncmp - (pos, mef_fields[i].name, - strlen(mef_fields[i].name)) == 0) { - switch (mef_fields[i].nameid) { - case NAME_TYPE: - type = a2hex_or_atoi(pos1); - if ((type != FILTER_DNUM) && - (type != FILTER_BYTESEQ) - && (type != FILTER_BITSEQ) && - (type != FILTER_TEST)) { - printf("Invalid filter type:%d\n", type); - return MLAN_STATUS_FAILURE; - } - type_find = 1; - break; - case NAME_PATTERN: - pattern = a2hex_or_atoi(pos1); - pattern_find = 1; - break; - case NAME_OFFSET: - offset = a2hex_or_atoi(pos1); - offset_find = 1; - break; - case NAME_NUMBYTE: - numbyte = a2hex_or_atoi(pos1); - numbyte_find = 1; - break; - case NAME_REPEAT: - repeat = a2hex_or_atoi(pos1); - repeat_find = 1; - break; - case NAME_BYTE: - memset(byte_seq, 0, sizeof(byte_seq)); - strncpy(byte_seq, pos1, - (sizeof(byte_seq) - 1)); - byte_find = 1; - break; - case NAME_MASK: - memset(mask_seq, 0, sizeof(mask_seq)); - strncpy(mask_seq, pos1, - (sizeof(mask_seq) - 1)); - mask_find = 1; - break; - case NAME_DEST: - memset(dest_seq, 0, sizeof(dest_seq)); - strncpy(dest_seq, pos1, - (sizeof(dest_seq) - 1)); - dest_find = 1; - break; - } - break; - } - } - if (i == NELEMENTS(mef_fields)) { - printf("Line %d: unknown mef field '%s'.\n", - *line, pos); - errors++; - } - } - if (type_find == 0) { - printf("Can not find filter type\n"); - return MLAN_STATUS_FAILURE; - } - switch (type) { - case FILTER_DNUM: - if (!pattern_find || !offset_find || !numbyte_find) { - printf("Missing field for FILTER_DNUM: pattern=%d,offset=%d,numbyte=%d\n", pattern_find, offset_find, numbyte_find); - return MLAN_STATUS_FAILURE; - } - memset(line, 0, sizeof(line)); - snprintf(line, sizeof(line), "%d %d %d =d ", pattern, offset, - numbyte); - break; - case FILTER_BYTESEQ: - if (!byte_find || !offset_find || !repeat_find) { - printf("Missing field for FILTER_BYTESEQ: byte=%d,offset=%d,repeat=%d\n", byte_find, offset_find, repeat_find); - return MLAN_STATUS_FAILURE; - } - memset(line, 0, sizeof(line)); - snprintf(line, sizeof(line), "%d h%s %d == ", repeat, byte_seq, - offset); - break; - case FILTER_BITSEQ: - if (!byte_find || !offset_find || !mask_find) { - printf("Missing field for FILTER_BITSEQ: byte=%d,offset=%d,mask_find=%d\n", byte_find, offset_find, mask_find); - return MLAN_STATUS_FAILURE; - } - if (strlen(byte_seq) != strlen(mask_seq)) { - printf("byte string's length is different with mask's length!\n"); - return MLAN_STATUS_FAILURE; - } - memset(line, 0, sizeof(line)); - snprintf(line, sizeof(line), "h%s %d h%s =b ", byte_seq, offset, - mask_seq); - break; - case FILTER_TEST: - if (!byte_find || !offset_find || !repeat_find || !dest_find) { - printf("Missing field for FILTER_TEST: byte=%d,offset=%d,repeat=%d,dest=%d\n", byte_find, offset_find, repeat_find, dest_find); - return MLAN_STATUS_FAILURE; - } - memset(line, 0, sizeof(line)); - snprintf(line, sizeof(line), "h%s %d h%s %d ", dest_seq, repeat, - byte_seq, offset); - break; - } - memcpy(buf, line, strlen(line)); - *size = strlen(line); - return MLAN_STATUS_SUCCESS; -} - -#define NAME_MODE 1 /**< Field name 'mode' */ -#define NAME_ACTION 2 /**< Field name 'action' */ -#define NAME_FILTER_NUM 3 /**< Field name 'filter_num' */ -#define NAME_RPN 4 /**< Field name 'RPN' */ -static struct mef_entry_fields { - t_s8 *name; - /**< Name */ - t_s8 nameid; - /**< Name id */ -} mef_entry_fields[] = { - { - "mode", NAME_MODE}, { - "action", NAME_ACTION}, { - "filter_num", NAME_FILTER_NUM}, { -"RPN", NAME_RPN},}; - -typedef struct _MEF_ENTRY { - /** Mode */ - t_u8 Mode; - /** Size */ - t_u8 Action; - /** Size of expression */ - t_u16 ExprSize; -} MEF_ENTRY; - -/** - * @brief get mef_entry data - * - * @param fp A pointer to file stream - * @param ln A pointer to line number - * @param buf A pointer to hostcmd data - * @param size A pointer to the return size of hostcmd buffer - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -mlan_get_mef_entry_data(FILE * fp, int *ln, t_u8 *buf, t_u16 *size) -{ - t_s8 line[256], *pos, *pos1; - t_u8 mode, action, filter_num = 0; - t_s8 rpn[256]; - t_s8 mode_find = 0; - t_s8 action_find = 0; - t_s8 filter_num_find = 0; - t_s8 rpn_find = 0; - t_s8 rpn_str[256]; - int rpn_len = 0; - t_s8 filter_name[50]; - t_s8 name_found = 0; - t_u16 len = 0; - int i; - int first_time = TRUE; - char *opstr; - t_s8 filter_action[10]; - t_s32 errors = 0; - MEF_ENTRY *pMefEntry = (MEF_ENTRY *) buf; - mstack_t stack; - while ((pos = mlan_config_get_line(fp, line, sizeof(line), ln))) { - if (strcmp(pos, "}") == 0) { - break; - } - pos1 = strchr(pos, '='); - if (pos1 == NULL) { - printf("Line %d: Invalid mef_entry line '%s'\n", *ln, - pos); - errors++; - continue; - } - *pos1++ = '\0'; - if (!mode_find || !action_find || !filter_num_find || !rpn_find) { - for (i = 0; - (unsigned int)i < NELEMENTS(mef_entry_fields); - i++) { - if (strncmp - (pos, mef_entry_fields[i].name, - strlen(mef_entry_fields[i].name)) == 0) { - switch (mef_entry_fields[i].nameid) { - case NAME_MODE: - mode = a2hex_or_atoi(pos1); - if (mode & ~0x7) { - printf("invalid mode=%d\n", mode); - return MLAN_STATUS_FAILURE; - } - pMefEntry->Mode = mode; - mode_find = 1; - break; - case NAME_ACTION: - action = a2hex_or_atoi(pos1); - if (action & ~0xff) { - printf("invalid action=%d\n", action); - return MLAN_STATUS_FAILURE; - } - pMefEntry->Action = action; - action_find = 1; - break; - case NAME_FILTER_NUM: - filter_num = - a2hex_or_atoi(pos1); - filter_num_find = 1; - break; - case NAME_RPN: - memset(rpn, 0, sizeof(rpn)); - strncpy(rpn, pos1, - (sizeof(rpn) - 1)); - rpn_find = 1; - break; - } - break; - } - } - if (i == NELEMENTS(mef_fields)) { - printf("Line %d: unknown mef_entry field '%s'.\n", *line, pos); - return MLAN_STATUS_FAILURE; - } - } - if (mode_find && action_find && filter_num_find && rpn_find) { - for (i = 0; i < filter_num; i++) { - opstr = getop(rpn, &first_time); - if (opstr == NULL) - break; - snprintf(filter_name, sizeof(filter_name), - "%s={", opstr); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, - sizeof(line), - ln))) { - if (strncmp - (pos, filter_name, - strlen(filter_name)) == 0) { - name_found = 1; - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanconfig: %s not found in file\n", - filter_name); - return MLAN_STATUS_FAILURE; - } - if (MLAN_STATUS_FAILURE == - mlan_get_filter_data(fp, ln, - (t_u8 *)(rpn_str + - rpn_len), - &len)) - break; - rpn_len += len; - if (i > 0) { - memcpy(rpn_str + rpn_len, filter_action, - strlen(filter_action)); - rpn_len += strlen(filter_action); - } - opstr = getop(rpn, &first_time); - if (opstr == NULL) - break; - memset(filter_action, 0, sizeof(filter_action)); - snprintf(filter_action, sizeof(filter_action), - "%s ", opstr); - } - /* Remove the last space */ - if (rpn_len > 0) { - rpn_len--; - rpn_str[rpn_len] = 0; - } - if (MLAN_STATUS_FAILURE == str2bin(rpn_str, &stack)) { - printf("Fail on str2bin!\n"); - return MLAN_STATUS_FAILURE; - } - *size = sizeof(MEF_ENTRY); - pMefEntry->ExprSize = cpu_to_le16(stack.sp); - memmove(buf + sizeof(MEF_ENTRY), stack.byte, stack.sp); - *size += stack.sp; - break; - } else if (mode_find && action_find && filter_num_find && - (filter_num == 0)) { - pMefEntry->ExprSize = 0; - *size = sizeof(MEF_ENTRY); - break; - } - } - return MLAN_STATUS_SUCCESS; -} - -#define MEFCFG_CMDCODE 0x009a -/** - * @brief Process mef cfg - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_mef_cfg(int argc, char *argv[]) -{ - int ioctl_val, subioctl_val; - t_s8 line[256], cmdname[256], *pos; - int cmdname_found = 0, name_found = 0; - int ln = 0; - int ret = MLAN_STATUS_SUCCESS; - int i; - t_u8 *buf; - t_u16 buf_len = 0; - t_u16 len = 0; - struct iwreq iwr; - HostCmd_DS_MEF_CFG *mefcmd; - HostCmd_DS_GEN *hostcmd; - FILE *fp = NULL; - - if (argc < 4) { - printf("Error: invalid no of arguments\n"); - printf("Syntax: ./mlanconfig eth1 mefcfg \n"); - exit(1); - } - if (get_priv_ioctl("hostcmd", - &ioctl_val, &subioctl_val) == MLAN_STATUS_FAILURE) { - return -EOPNOTSUPP; - } - snprintf(cmdname, sizeof(cmdname), "%s={", argv[2]); - cmdname_found = 0; - if ((fp = fopen(argv[3], "r")) == NULL) { - fprintf(stderr, "Cannot open file %s\n", argv[4]); - exit(1); - } - - buf = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (buf == NULL) { - fclose(fp); - fprintf(stderr, "Cannot alloc memory\n"); - exit(1); - } - memset(buf, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - - hostcmd = (HostCmd_DS_GEN *)(buf); - hostcmd->command = cpu_to_le16(MEFCFG_CMDCODE); - mefcmd = (HostCmd_DS_MEF_CFG *)(buf + S_DS_GEN); - buf_len = sizeof(HostCmd_DS_MEF_CFG) + S_DS_GEN; - - while ((pos = mlan_config_get_line(fp, line, sizeof(line), &ln))) { - if (strcmp(pos, cmdname) == 0) { - cmdname_found = 1; - snprintf(cmdname, sizeof(cmdname), "Criteria="); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, sizeof(line), - &ln))) { - if (strncmp(pos, cmdname, strlen(cmdname)) == 0) { - name_found = 1; - mefcmd->Criteria = - a2hex_or_atoi(pos + - strlen(cmdname)); - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanconfig: criteria not found in file '%s'\n", - argv[3]); - break; - } - snprintf(cmdname, sizeof(cmdname), "NumEntries="); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, sizeof(line), - &ln))) { - if (strncmp(pos, cmdname, strlen(cmdname)) == 0) { - name_found = 1; - mefcmd->NumEntries = - a2hex_or_atoi(pos + - strlen(cmdname)); - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanconfig: NumEntries not found in file '%s'\n", - argv[3]); - break; - } - for (i = 0; i < mefcmd->NumEntries; i++) { - snprintf(cmdname, sizeof(cmdname), - "mef_entry_%d={", i); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, - sizeof(line), - &ln))) { - if (strncmp - (pos, cmdname, - strlen(cmdname)) == 0) { - name_found = 1; - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanconfig: %s not found in file '%s'\n", - cmdname, argv[3]); - break; - } - if (MLAN_STATUS_FAILURE == - mlan_get_mef_entry_data(fp, &ln, - buf + buf_len, - &len)) { - ret = MLAN_STATUS_FAILURE; - break; - } - buf_len += len; - } - break; - } - } - fclose(fp); - /* hexdump("mef_cfg",buf,buf_len, ' '); */ - if (!cmdname_found) - fprintf(stderr, - "mlanconfig: cmdname '%s' not found in file '%s'\n", - argv[4], argv[3]); - - if (!cmdname_found || !name_found) { - ret = MLAN_STATUS_FAILURE; - goto mef_exit; - } - hostcmd->size = cpu_to_le16(buf_len); - mefcmd->Criteria = cpu_to_le32(mefcmd->Criteria); - mefcmd->NumEntries = cpu_to_le16(mefcmd->NumEntries); - - strncpy(iwr.ifr_name, dev_name, IFNAMSIZ - 1); - iwr.u.data.pointer = buf; - iwr.u.data.length = buf_len; - iwr.u.data.flags = 0; - if (ioctl(sockfd, ioctl_val, &iwr)) { - fprintf(stderr, "mlanconfig: MEFCFG is not supported by %s\n", - dev_name); - ret = MLAN_STATUS_FAILURE; - goto mef_exit; - } - ret = process_host_cmd_resp(buf); - -mef_exit: - if (buf) - free(buf); - return ret; - -} - -/** - * @brief Process transmission of mgmt frames - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_mgmt_frame_tx(int argc, char *argv[]) -{ - struct ifreq ifr; - char *line = NULL; - FILE *config_file = NULL; - int li = 0, arg_num = 0, ret = 0, i = 0; - char *args[100] = { NULL }, *pos = NULL, mac_addr[20]; - t_u8 peer_mac[ETH_ALEN]; - t_u16 data_len = 0, subtype = 0; - wlan_mgmt_frame_tx *pmgmt_frame; - t_u8 *buffer = NULL; - pkt_header *hdr = NULL; - - /* Check arguments */ - if (argc != 4) { - printf("ERR:Incorrect number of arguments.\n"); - printf("Syntax: ./mlanconfig mlanX mgmtframetx \n"); - exit(1); - } - - data_len = sizeof(wlan_mgmt_frame_tx); - - buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - hdr = (pkt_header *)buffer; - pmgmt_frame = (wlan_mgmt_frame_tx *)(buffer + sizeof(pkt_header)); - - /* Check if file exists */ - config_file = fopen(argv[3], "r"); - if (config_file == NULL) { - printf("\nERR:Config file can not open.\n"); - goto done; - } - line = (char *)malloc(MAX_CONFIG_LINE); - if (!line) { - printf("ERR:Cannot allocate memory for line\n"); - goto done; - } - memset(line, 0, MAX_CONFIG_LINE); - - /* Parse file and process */ - while (config_get_line(line, MAX_CONFIG_LINE, config_file, &li, &pos)) { - arg_num = parse_line(line, args); - if (strcmp(args[0], "PktSubType") == 0) { - subtype = (t_u16)A2HEXDECIMAL(args[1]); - pmgmt_frame->frm_ctl |= subtype << 4; - } else if (strncmp(args[0], "Addr", 4) == 0) { - strncpy(mac_addr, args[1], 20); - if ((ret = - mac2raw(mac_addr, - peer_mac)) != MLAN_STATUS_SUCCESS) { - printf("ERR: %s Address \n", - ret == - MLAN_STATUS_FAILURE ? "Invalid MAC" : ret - == - MAC_BROADCAST ? "Broadcast" : - "Multicast"); - goto done; - } - i = atoi(args[0] + 4); - switch (i) { - case 1: - memcpy(pmgmt_frame->addr1, peer_mac, ETH_ALEN); - break; - case 2: - memcpy(pmgmt_frame->addr2, peer_mac, ETH_ALEN); - break; - case 3: - memcpy(pmgmt_frame->addr3, peer_mac, ETH_ALEN); - break; - case 4: - memcpy(pmgmt_frame->addr4, peer_mac, ETH_ALEN); - break; - } - } else if (strcmp(args[0], "Data") == 0) { - for (i = 0; i < arg_num - 1; i++) - pmgmt_frame->payload[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - data_len += arg_num - 1; - } - } - pmgmt_frame->frm_len = data_len - sizeof(pmgmt_frame->frm_len); -#define MRVL_PKT_TYPE_MGMT_FRAME 0xE5 - hdr->pkt_len = data_len; - hdr->TxPktType = MRVL_PKT_TYPE_MGMT_FRAME; - hdr->TxControl = 0; - hexdump("Frame Tx", buffer, data_len + sizeof(pkt_header), ' '); - /* Send collective command */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)buffer; - - /* Perform ioctl */ - if (ioctl(sockfd, FRAME_TX_IOCTL, &ifr)) { - perror(""); - printf("ERR:Could not send management frame.\n"); - } else { - printf("Mgmt Frame sucessfully sent.\n"); - } - -done: - if (config_file) - fclose(config_file); - if (buffer) - free(buffer); - if (line) - free(line); - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Entry function for mlanconfig - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -main(int argc, char *argv[]) -{ - t_s32 cmd; - - if ((argc == 2) && (strcmp(argv[1], "-v") == 0)) { - fprintf(stdout, "NXP mlanconfig version %s\n", MLANCONFIG_VER); - exit(0); - } - if (argc < 3) { - fprintf(stderr, "Invalid number of parameters!\n"); - display_usage(); - exit(1); - } - - strncpy(dev_name, argv[1], IFNAMSIZ - 1); - - /* - * create a socket - */ - if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - fprintf(stderr, "mlanconfig: Cannot open socket.\n"); - exit(1); - } - if (get_range() < 0) { - fprintf(stderr, "mlanconfig: Cannot get range.\n"); - close(sockfd); - exit(1); - } - switch ((cmd = findcommand(NELEMENTS(commands), commands, argv[2]))) { - case CMD_HOSTCMD: - process_host_cmd(argc, argv); - break; - case CMD_MEFCFG: - process_mef_cfg(argc, argv); - break; - case CMD_CFG_DATA: - process_cfg_data(argc, argv); - break; -#ifdef SDIO - case CMD_CMD52RW: - process_sdcmd52rw(argc, argv); - break; - case CMD_CMD53RW: - process_sdcmd53rw(argc, argv); - break; -#endif - case CMD_GET_SCAN_RSP: - process_getscantable(argc, argv); - break; - case CMD_SET_USER_SCAN: - process_setuserscan(argc, argv); - break; - case CMD_ADD_TS: - process_addts(argc, argv); - break; - case CMD_DEL_TS: - process_delts(argc, argv); - break; - case CMD_QCONFIG: - process_qconfig(argc, argv); - break; - case CMD_QSTATS: - process_qstats(argc, argv); - break; - case CMD_TS_STATUS: - process_wmm_ts_status(argc, argv); - break; - case CMD_WMM_QSTATUS: - process_wmm_qstatus(argc, argv); - break; - case CMD_REGRW: - process_regrdwr(argc, argv); - break; - case CMD_MEMRW: - process_memrdwr(argc, argv); - break; -#ifdef OPCHAN - case CMD_OPCHAN: - process_opchan(argc, argv); - break; - - case CMD_CHANGROUP: - process_changroup(argc, argv); - break; -#endif - case CMD_STA_CUSTOM_IE: - process_custom_ie(argc, argv); - break; - case CMD_STA_MGMT_FRAME_TX: - process_mgmt_frame_tx(argc, argv); - break; - default: - fprintf(stderr, "Invalid command specified!\n"); - display_usage(); - close(sockfd); - exit(1); - } - - close(sockfd); - return MLAN_STATUS_SUCCESS; -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/mlanconfig.h b/mxm_wifiex/wlan_src/mapp/mlanconfig/mlanconfig.h deleted file mode 100644 index e575077..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/mlanconfig.h +++ /dev/null @@ -1,249 +0,0 @@ -/** @file mlanconfig.h - * - * @brief This file contains definitions for application - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 11/26/2008: initial version -************************************************************************/ -#ifndef _MLANCONFIG_H_ -#define _MLANCONFIG_H_ - -/** Include header files */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if (BYTE_ORDER == LITTLE_ENDIAN) -#undef BIG_ENDIAN_SUPPORT -#endif - -/** Type definition: boolean */ -typedef enum { FALSE, TRUE } boolean; - -/** - * This macro specifies the attribute pack used for structure packing - */ -#ifndef __ATTRIB_PACK__ -#define __ATTRIB_PACK__ __attribute__((packed)) -#endif - -/** 16 bits byte swap */ -#define swap_byte_16(x) \ -((t_u16)((((t_u16)(x) & 0x00ffU) << 8) | \ - (((t_u16)(x) & 0xff00U) >> 8))) - -/** 32 bits byte swap */ -#define swap_byte_32(x) \ -((t_u32)((((t_u32)(x) & 0x000000ffUL) << 24) | \ - (((t_u32)(x) & 0x0000ff00UL) << 8) | \ - (((t_u32)(x) & 0x00ff0000UL) >> 8) | \ - (((t_u32)(x) & 0xff000000UL) >> 24))) - -/** Convert to correct endian format */ -#ifdef BIG_ENDIAN_SUPPORT -/** CPU to little-endian convert for 16-bit */ -#define cpu_to_le16(x) swap_byte_16(x) -/** CPU to little-endian convert for 32-bit */ -#define cpu_to_le32(x) swap_byte_32(x) -/** Little-endian to CPU convert for 16-bit */ -#define le16_to_cpu(x) swap_byte_16(x) -/** Little-endian to CPU convert for 32-bit */ -#define le32_to_cpu(x) swap_byte_32(x) -#else -/** Do nothing */ -#define cpu_to_le16(x) (x) -/** Do nothing */ -#define cpu_to_le32(x) (x) -/** Do nothing */ -#define le16_to_cpu(x) (x) -/** Do nothing */ -#define le32_to_cpu(x) (x) -#endif - -/** Character, 1 byte */ -typedef char t_s8; -/** Unsigned character, 1 byte */ -typedef unsigned char t_u8; - -/** Short integer */ -typedef signed short t_s16; -/** Unsigned short integer */ -typedef unsigned short t_u16; - -/** Integer */ -typedef signed int t_s32; -/** Unsigned integer */ -typedef unsigned int t_u32; - -/** Long long integer */ -typedef signed long long t_s64; -/** Unsigned long long integer */ -typedef unsigned long long t_u64; - -/** Void pointer (4-bytes) */ -typedef void t_void; - -/** Success */ -#define MLAN_STATUS_SUCCESS (0) -/** Failure */ -#define MLAN_STATUS_FAILURE (-1) - -t_s8 *mlan_config_get_line(FILE * fp, t_s8 *s, t_s32 size, int *line); -int get_priv_ioctl(char *ioctl_name, int *ioctl_val, int *subioctl_val); -int fparse_for_hex(FILE * fp, t_u8 *dst); - -/** - * Hex or Decimal to Integer - * @param num string to convert into decimal or hex - */ -#define A2HEXDECIMAL(num) \ - (strncasecmp("0x", (num), 2)?(unsigned int) strtoll((num),NULL,0):a2hex((num))) - -/** Convert character to integer */ -#define CHAR2INT(x) (((x) >= 'A') ? ((x) - 'A' + 10) : ((x) - '0')) - -/** Convert TLV header from little endian format to CPU format */ -#define endian_convert_tlv_header_in(x) \ - { \ - (x)->tag = le16_to_cpu((x)->tag); \ - (x)->length = le16_to_cpu((x)->length); \ - } - -/** Convert TLV header to little endian format from CPU format */ -#define endian_convert_tlv_header_out(x) \ - { \ - (x)->tag = cpu_to_le16((x)->tag); \ - (x)->length = cpu_to_le16((x)->length); \ - } -/** Private command ID to pass custom IE list */ -#define CUSTOM_IE_CFG (SIOCDEVPRIVATE + 13) -/* TLV Definitions */ -/** TLV header */ -#define TLVHEADER /** Tag */ \ - t_u16 tag; \ - /** Length */ \ - t_u16 length - -/** Maximum IE buffer length */ -#define MAX_IE_BUFFER_LEN 256 - -/** TLV: Management IE list */ -#define MRVL_MGMT_IE_LIST_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x69) //0x0169 - -/** TLV: Max Management IE */ -#define MRVL_MAX_MGMT_IE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0xaa) //0x01aa - -/** custom IE info */ -typedef struct _custom_ie_info { - /** size of buffer */ - t_u16 buf_size; - /** no of buffers of buf_size */ - t_u16 buf_count; -} __ATTRIB_PACK__ custom_ie_info; - -/** TLV buffer : custom IE */ -typedef struct _tlvbuf_max_mgmt_ie { - /** Header */ - TLVHEADER; - /** No of tuples */ - t_u16 count; - /** custom IE info tuples */ - custom_ie_info info[]; -} __ATTRIB_PACK__ tlvbuf_max_mgmt_ie; - -/** custom IE */ -typedef struct _custom_ie { - /** IE Index */ - t_u16 ie_index; - /** Mgmt Subtype Mask */ - t_u16 mgmt_subtype_mask; - /** IE Length */ - t_u16 ie_length; - /** IE buffer */ - t_u8 ie_buffer[]; -} __ATTRIB_PACK__ custom_ie; - -/** TLV buffer : custom IE */ -typedef struct _tlvbuf_custom_ie { - /** Header */ - TLVHEADER; - /** custom IE data */ - custom_ie ie_data[]; -} __ATTRIB_PACK__ tlvbuf_custom_ie; - -/** Maximum length of lines in configuration file */ -#define MAX_CONFIG_LINE 1024 -/** Ethernet address length */ -#define ETH_ALEN 6 -/** MAC BROADCAST */ -#define MAC_BROADCAST 0x1FF -/** MAC MULTICAST */ -#define MAC_MULTICAST 0x1FE - -/** pkt_header */ -typedef struct _pkt_header { - /** pkt_len */ - t_u32 pkt_len; - /** pkt_type */ - t_u32 TxPktType; - /** tx control */ - t_u32 TxControl; -} pkt_header; - -/** wlan_802_11_header packet from FW with length */ -typedef struct _wlan_mgmt_frame_tx { - /** Packet Length */ - t_u16 frm_len; - /** Frame Control */ - t_u16 frm_ctl; - /** Duration ID */ - t_u16 duration_id; - /** Address1 */ - t_u8 addr1[ETH_ALEN]; - /** Address2 */ - t_u8 addr2[ETH_ALEN]; - /** Address3 */ - t_u8 addr3[ETH_ALEN]; - /** Sequence Control */ - t_u16 seq_ctl; - /** Address4 */ - t_u8 addr4[ETH_ALEN]; - /** Frame payload */ - t_u8 payload[]; -} __ATTRIB_PACK__ wlan_mgmt_frame_tx; - -/** frame tx ioctl number */ -#define FRAME_TX_IOCTL (SIOCDEVPRIVATE + 12) - -extern t_s32 sockfd; /**< socket */ -extern t_s8 dev_name[IFNAMSIZ + 1]; /**< device name */ - -#endif /* _MLANCONFIG_H_ */ diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/mlanhostcmd.c b/mxm_wifiex/wlan_src/mapp/mlanconfig/mlanhostcmd.c deleted file mode 100644 index ab767b6..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/mlanhostcmd.c +++ /dev/null @@ -1,923 +0,0 @@ -/** @file mlanhostcmd.c - * - * @brief This file contains mlanconfig helper functions - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 11/26/2008: initial version -************************************************************************/ - -#include "mlanconfig.h" -#include "mlanhostcmd.h" - -#ifndef MIN -/** Find minimum value */ -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif /* MIN */ - -/******************************************************** - Local Variables -********************************************************/ - -/******************************************************** - Global Variables -********************************************************/ - -/******************************************************** - Local Functions -********************************************************/ -/** - * @brief get hostcmd data - * - * @param ln A pointer to line number - * @param buf A pointer to hostcmd data - * @param size A pointer to the return size of hostcmd buffer - * @return MLAN_STATUS_SUCCESS - */ -static int -mlan_get_hostcmd_data(FILE * fp, int *ln, t_u8 *buf, t_u16 *size) -{ - t_s32 errors = 0, i; - t_s8 line[512], *pos, *pos1, *pos2, *pos3; - t_u16 len; - - while ((pos = mlan_config_get_line(fp, line, sizeof(line), ln))) { - (*ln)++; - if (strcmp(pos, "}") == 0) { - break; - } - - pos1 = strchr(pos, ':'); - if (pos1 == NULL) { - printf("Line %d: Invalid hostcmd line '%s'\n", *ln, - pos); - errors++; - continue; - } - *pos1++ = '\0'; - - pos2 = strchr(pos1, '='); - if (pos2 == NULL) { - printf("Line %d: Invalid hostcmd line '%s'\n", *ln, - pos); - errors++; - continue; - } - *pos2++ = '\0'; - - len = a2hex_or_atoi(pos1); - if (len < 1 || len > MRVDRV_SIZE_OF_CMD_BUFFER) { - printf("Line %d: Invalid hostcmd line '%s'\n", *ln, - pos); - errors++; - continue; - } - - *size += len; - - if (*pos2 == '"') { - pos2++; - if ((pos3 = strchr(pos2, '"')) == NULL) { - printf("Line %d: invalid quotation '%s'\n", *ln, - pos); - errors++; - continue; - } - *pos3 = '\0'; - memset(buf, 0, len); - memmove(buf, pos2, MIN(strlen(pos2), len)); - buf += len; - } else if (*pos2 == '\'') { - pos2++; - if ((pos3 = strchr(pos2, '\'')) == NULL) { - printf("Line %d: invalid quotation '%s'\n", *ln, - pos); - errors++; - continue; - } - *pos3 = ','; - for (i = 0; i < len; i++) { - if ((pos3 = strchr(pos2, ',')) != NULL) { - *pos3 = '\0'; - *buf++ = (t_u8)a2hex_or_atoi(pos2); - pos2 = pos3 + 1; - } else - *buf++ = 0; - } - } else if (*pos2 == '{') { - t_u16 tlvlen = 0, tmp_tlvlen; - mlan_get_hostcmd_data(fp, ln, buf + len, &tlvlen); - tmp_tlvlen = tlvlen; - while (len--) { - *buf++ = (t_u8)(tmp_tlvlen & 0xff); - tmp_tlvlen >>= 8; - } - *size += tlvlen; - buf += tlvlen; - } else { - t_u32 value = a2hex_or_atoi(pos2); - while (len--) { - *buf++ = (t_u8)(value & 0xff); - value >>= 8; - } - } - } - return MLAN_STATUS_SUCCESS; -} - -/******************************************************** - Global Functions -********************************************************/ -/** - * @brief convert char to hex integer - * - * @param chr char to convert - * @return hex integer or 0 - */ -int -hexval(t_s32 chr) -{ - if (chr >= '0' && chr <= '9') - return chr - '0'; - if (chr >= 'A' && chr <= 'F') - return chr - 'A' + 10; - if (chr >= 'a' && chr <= 'f') - return chr - 'a' + 10; - - return 0; -} - -/** - * @brief Hump hex data - * - * @param prompt A pointer prompt buffer - * @param p A pointer to data buffer - * @param len the len of data buffer - * @param delim delim char - * @return hex integer - */ -t_void -hexdump(t_s8 *prompt, t_void *p, t_s32 len, t_s8 delim) -{ - t_s32 i; - t_u8 *s = p; - - if (prompt) { - printf("%s: len=%d\n", prompt, (int)len); - } - for (i = 0; i < len; i++) { - if (i != len - 1) - printf("%02x%c", *s++, delim); - else - printf("%02x\n", *s); - if ((i + 1) % 16 == 0) - printf("\n"); - } - printf("\n"); -} - -/** - * @brief convert char to hex integer - * - * @param chr char - * @return hex integer - */ -t_u8 -hexc2bin(t_s8 chr) -{ - if (chr >= '0' && chr <= '9') - chr -= '0'; - else if (chr >= 'A' && chr <= 'F') - chr -= ('A' - 10); - else if (chr >= 'a' && chr <= 'f') - chr -= ('a' - 10); - - return chr; -} - -/** - * @brief convert string to hex integer - * - * @param s A pointer string buffer - * @return hex integer - */ -t_u32 -a2hex(t_s8 *s) -{ - t_u32 val = 0; - - if (!strncasecmp("0x", s, 2)) { - s += 2; - } - - while (*s && isxdigit(*s)) { - val = (val << 4) + hexc2bin(*s++); - } - - return val; -} - -/* - * @brief convert String to integer - * - * @param value A pointer to string - * @return integer - */ -t_u32 -a2hex_or_atoi(t_s8 *value) -{ - if (value[0] == '0' && (value[1] == 'X' || value[1] == 'x')) { - return a2hex(value + 2); - } else if (isdigit(*value)) { - return atoi(value); - } else { - return *value; - } -} - -/** - * @brief convert string to hex - * - * @param ptr A pointer to data buffer - * @param chr A pointer to return integer - * @return A pointer to next data field - */ -t_s8 * -convert2hex(t_s8 *ptr, t_u8 *chr) -{ - t_u8 val; - - for (val = 0; *ptr && isxdigit(*ptr); ptr++) { - val = (val * 16) + hexval(*ptr); - } - - *chr = val; - - return ptr; -} - -/** - * @brief Check the Hex String - * @param s A pointer to the string - * @return MLAN_STATUS_SUCCESS --HexString, MLAN_STATUS_FAILURE --not HexString - */ -int -ishexstring(t_s8 *s) -{ - int ret = MLAN_STATUS_FAILURE; - t_s32 tmp; - - if (!strncasecmp("0x", s, 2)) { - s += 2; - } - while (*s) { - tmp = toupper(*s); - if (((tmp >= 'A') && (tmp <= 'F')) || - ((tmp >= '0') && (tmp <= '9'))) { - ret = MLAN_STATUS_SUCCESS; - } else { - ret = MLAN_STATUS_FAILURE; - break; - } - s++; - } - - return ret; -} - -/** - * @brief Convert String to Integer - * @param buf A pointer to the string - * @return Integer - */ -int -atoval(t_s8 *buf) -{ - if (!strncasecmp(buf, "0x", 2)) - return a2hex(buf + 2); - else if (!ishexstring(buf)) - return a2hex(buf); - else - return atoi(buf); -} - -/** - * @brief Prepare host-command buffer - * @param fp File handler - * @param cmd_name Command name - * @param buf A pointer to comand buffer - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -prepare_host_cmd_buffer(FILE * fp, char *cmd_name, t_u8 *buf) -{ - t_s8 line[256], cmdname[256], *pos, cmdcode[10]; - HostCmd_DS_GEN *hostcmd; - int ln = 0; - int cmdname_found = 0, cmdcode_found = 0; - - memset(buf, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - hostcmd = (HostCmd_DS_GEN *)buf; - hostcmd->command = 0xffff; - - snprintf(cmdname, sizeof(cmdname), "%s={", cmd_name); - cmdname_found = 0; - while ((pos = mlan_config_get_line(fp, line, sizeof(line), &ln))) { - if (strcmp(pos, cmdname) == 0) { - t_u16 len = 0; - cmdname_found = 1; - snprintf(cmdcode, sizeof(cmdcode), "CmdCode="); - cmdcode_found = 0; - while ((pos = - mlan_config_get_line(fp, line, sizeof(line), - &ln))) { - if (strncmp(pos, cmdcode, strlen(cmdcode)) == 0) { - cmdcode_found = 1; - hostcmd->command = - a2hex_or_atoi(pos + - strlen(cmdcode)); - hostcmd->size = S_DS_GEN; - mlan_get_hostcmd_data(fp, &ln, - buf + - hostcmd->size, - &len); - hostcmd->size += len; - break; - } - } - if (!cmdcode_found) { - fprintf(stderr, - "mlanconfig: CmdCode not found in conf file\n"); - return MLAN_STATUS_FAILURE; - } - break; - } - } - - if (!cmdname_found) { - fprintf(stderr, - "mlanconfig: cmdname '%s' is not found in conf file\n", - cmd_name); - return MLAN_STATUS_FAILURE; - } - - hostcmd->seq_num = 0; - hostcmd->result = 0; - hostcmd->command = cpu_to_le16(hostcmd->command); - hostcmd->size = cpu_to_le16(hostcmd->size); - return MLAN_STATUS_SUCCESS; -} - -/** Config data header length */ -#define CFG_DATA_HEADER_LEN 6 - -/** - * @brief Prepare cfg-data buffer - * @param argc number of arguments - * @param argv A pointer to arguments array - * @param fp File handler - * @param buf A pointer to comand buffer - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -prepare_cfg_data_buffer(int argc, char *argv[], FILE * fp, t_u8 *buf) -{ - int ln = 0, type; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_802_11_CFG_DATA *pcfg_data; - - memset(buf, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - hostcmd = (HostCmd_DS_GEN *)buf; - hostcmd->command = cpu_to_le16(HostCmd_CMD_CFG_DATA); - pcfg_data = (HostCmd_DS_802_11_CFG_DATA *)(buf + S_DS_GEN); - pcfg_data->action = - (argc == 4) ? HostCmd_ACT_GEN_GET : HostCmd_ACT_GEN_SET; - type = atoi(argv[3]); - if ((type < 1) || (type > 2)) { - fprintf(stderr, "mlanconfig: Invalid register type\n"); - return MLAN_STATUS_FAILURE; - } else { - pcfg_data->type = type; - } - if (argc == 5) { - ln = fparse_for_hex(fp, pcfg_data->data); - } - pcfg_data->data_len = ln; - hostcmd->size = - cpu_to_le16(pcfg_data->data_len + S_DS_GEN + - CFG_DATA_HEADER_LEN); - pcfg_data->data_len = cpu_to_le16(pcfg_data->data_len); - pcfg_data->type = cpu_to_le16(pcfg_data->type); - pcfg_data->action = cpu_to_le16(pcfg_data->action); - - hostcmd->seq_num = 0; - hostcmd->result = 0; - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process host_cmd response - * @param buf A pointer to the response buffer - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_host_cmd_resp(t_u8 *buf) -{ - HostCmd_DS_GEN *hostcmd = (HostCmd_DS_GEN *)buf; - int ret = MLAN_STATUS_SUCCESS; - - hostcmd->command = le16_to_cpu(hostcmd->command); - hostcmd->size = le16_to_cpu(hostcmd->size); - hostcmd->seq_num = le16_to_cpu(hostcmd->seq_num); - hostcmd->result = le16_to_cpu(hostcmd->result); - - hostcmd->command &= ~HostCmd_RET_BIT; - if (!hostcmd->result) { - switch (hostcmd->command) { - case HostCmd_CMD_CFG_DATA: - { - HostCmd_DS_802_11_CFG_DATA *pstcfgData = - (HostCmd_DS_802_11_CFG_DATA *)(buf + - S_DS_GEN); - pstcfgData->data_len = - le16_to_cpu(pstcfgData->data_len); - pstcfgData->action = - le16_to_cpu(pstcfgData->action); - - if (pstcfgData->action == HostCmd_ACT_GEN_GET) { - hexdump("cfgdata", pstcfgData->data, - pstcfgData->data_len, ' '); - } - break; - } - case HostCmd_CMD_802_11_TPC_ADAPT_REQ: - { - mlan_ioctl_11h_tpc_resp *tpcIoctlResp = - (mlan_ioctl_11h_tpc_resp *)(buf + - S_DS_GEN); - if (tpcIoctlResp->status_code == 0) { - printf("tpcrequest: txPower(%d), linkMargin(%d), rssi(%d)\n", tpcIoctlResp->tx_power, tpcIoctlResp->link_margin, tpcIoctlResp->rssi); - } else { - printf("tpcrequest: failure, status = %d\n", tpcIoctlResp->status_code); - } - break; - } - case HostCmd_CMD_802_11_CRYPTO: - { - t_u16 alg = - le16_to_cpu((t_u16) - *(buf + S_DS_GEN + - sizeof(t_u16))); - if (alg == CIPHER_TEST_AES_CCM || - alg == CIPHER_TEST_GCMP) { - HostCmd_DS_802_11_CRYPTO_AES_CCM - *cmd_aes_ccm = - (HostCmd_DS_802_11_CRYPTO_AES_CCM - *)(buf + S_DS_GEN); - - cmd_aes_ccm->encdec - = - le16_to_cpu(cmd_aes_ccm-> - encdec); - cmd_aes_ccm->algorithm = - le16_to_cpu(cmd_aes_ccm-> - algorithm); - cmd_aes_ccm->key_length = - le16_to_cpu(cmd_aes_ccm-> - key_length); - cmd_aes_ccm->nonce_length = - le16_to_cpu(cmd_aes_ccm-> - nonce_length); - cmd_aes_ccm->AAD_length = - le16_to_cpu(cmd_aes_ccm-> - AAD_length); - cmd_aes_ccm->data.header.type = - le16_to_cpu(cmd_aes_ccm->data. - header.type); - cmd_aes_ccm->data.header.len = - le16_to_cpu(cmd_aes_ccm->data. - header.len); - - printf("crypto_result: encdec=%d algorithm=%d, KeyLen=%d," " NonceLen=%d,AADLen=%d,dataLen=%d\n", cmd_aes_ccm->encdec, cmd_aes_ccm->algorithm, cmd_aes_ccm->key_length, cmd_aes_ccm->nonce_length, cmd_aes_ccm->AAD_length, cmd_aes_ccm->data.header.len); - - hexdump("Key", cmd_aes_ccm->key, - cmd_aes_ccm->key_length, ' '); - hexdump("Nonce", cmd_aes_ccm->nonce, - cmd_aes_ccm->nonce_length, ' '); - hexdump("AAD", cmd_aes_ccm->AAD, - cmd_aes_ccm->AAD_length, ' '); - hexdump("Data", cmd_aes_ccm->data.data, - cmd_aes_ccm->data.header.len, - ' '); - } else if (alg == CIPHER_TEST_WAPI) { - HostCmd_DS_802_11_CRYPTO_WAPI *cmd_wapi - = - (HostCmd_DS_802_11_CRYPTO_WAPI - *) (buf + S_DS_GEN); - - cmd_wapi->encdec - = le16_to_cpu(cmd_wapi->encdec); - cmd_wapi->algorithm - = - le16_to_cpu(cmd_wapi-> - algorithm); - cmd_wapi->key_length = - le16_to_cpu(cmd_wapi-> - key_length); - cmd_wapi->nonce_length = - le16_to_cpu(cmd_wapi-> - nonce_length); - cmd_wapi->AAD_length = - le16_to_cpu(cmd_wapi-> - AAD_length); - - printf("crypto_result: encdec=%d algorithm=%d, KeyLen=%d," " NonceLen=%d,AADLen=%d,dataLen=%d\n", cmd_wapi->encdec, cmd_wapi->algorithm, cmd_wapi->key_length, cmd_wapi->nonce_length, cmd_wapi->AAD_length, cmd_wapi->data_length); - - hexdump("Key", cmd_wapi->key, - cmd_wapi->key_length, ' '); - hexdump("Nonce", cmd_wapi->nonce, - cmd_wapi->nonce_length, ' '); - hexdump("AAD", cmd_wapi->AAD, - cmd_wapi->AAD_length, ' '); - } else { - HostCmd_DS_802_11_CRYPTO *cmd = - (HostCmd_DS_802_11_CRYPTO *)(buf - + - S_DS_GEN); - cmd->encdec = le16_to_cpu(cmd->encdec); - cmd->algorithm = - le16_to_cpu(cmd->algorithm); - cmd->key_IV_length = - le16_to_cpu(cmd->key_IV_length); - cmd->key_length = - le16_to_cpu(cmd->key_length); - cmd->data.header.type = - le16_to_cpu(cmd->data.header. - type); - cmd->data.header.len = - le16_to_cpu(cmd->data.header. - len); - - printf("crypto_result: encdec=%d algorithm=%d,KeyIVLen=%d," " KeyLen=%d,dataLen=%d\n", cmd->encdec, cmd->algorithm, cmd->key_IV_length, cmd->key_length, cmd->data.header.len); - hexdump("KeyIV", cmd->keyIV, - cmd->key_IV_length, ' '); - hexdump("Key", cmd->key, - cmd->key_length, ' '); - hexdump("Data", cmd->data.data, - cmd->data.header.len, ' '); - } - break; - } - case HostCmd_CMD_802_11_AUTO_TX: - { - HostCmd_DS_802_11_AUTO_TX *at = - (HostCmd_DS_802_11_AUTO_TX *)(buf + - S_DS_GEN); - - if (le16_to_cpu(at->action) == - HostCmd_ACT_GEN_GET) { - if (S_DS_GEN + sizeof(at->action) == - hostcmd->size) { - printf("auto_tx not configured\n"); - - } else { - MrvlIEtypesHeader_t *header = - &at->auto_tx.header; - - header->type = - le16_to_cpu(header-> - type); - header->len = - le16_to_cpu(header-> - len); - - if ((S_DS_GEN + - sizeof(at->action) - + - sizeof(MrvlIEtypesHeader_t) - + header->len == - hostcmd->size) && - (header->type == - TLV_TYPE_AUTO_TX)) { - - AutoTx_MacFrame_t *atmf - = - &at->auto_tx. - auto_tx_mac_frame; - - printf("Interval: %d second(s)\n", le16_to_cpu(atmf->interval)); - printf("Priority: %#x\n", atmf->priority); - printf("Frame Length: %d\n", le16_to_cpu(atmf->frame_len)); - printf("Dest Mac Address: " "%02x:%02x:%02x:%02x:%02x:%02x\n", atmf->dest_mac_addr[0], atmf->dest_mac_addr[1], atmf->dest_mac_addr[2], atmf->dest_mac_addr[3], atmf->dest_mac_addr[4], atmf->dest_mac_addr[5]); - printf("Src Mac Address: " "%02x:%02x:%02x:%02x:%02x:%02x\n", atmf->src_mac_addr[0], atmf->src_mac_addr[1], atmf->src_mac_addr[2], atmf->src_mac_addr[3], atmf->src_mac_addr[4], atmf->src_mac_addr[5]); - - hexdump("Frame Payload", - atmf->payload, - le16_to_cpu - (atmf-> - frame_len) - - - MLAN_MAC_ADDR_LENGTH - * 2, ' '); - } else { - printf("incorrect auto_tx command response\n"); - } - } - } - break; - } - case HostCmd_CMD_802_11_SUBSCRIBE_EVENT: - { - HostCmd_DS_802_11_SUBSCRIBE_EVENT *se = - (HostCmd_DS_802_11_SUBSCRIBE_EVENT - *)(buf + S_DS_GEN); - if (le16_to_cpu(se->action) == - HostCmd_ACT_GEN_GET) { - int len = - S_DS_GEN + - sizeof - (HostCmd_DS_802_11_SUBSCRIBE_EVENT); - printf("\nEvent\t\tValue\tFreq\tsubscribed\n\n"); - while (len < hostcmd->size) { - MrvlIEtypesHeader_t *header = - (MrvlIEtypesHeader_t - *)(buf + len); - switch (le16_to_cpu - (header->type)) { - case TLV_TYPE_RSSI_LOW: - { - MrvlIEtypes_RssiThreshold_t - *low_rssi - = - (MrvlIEtypes_RssiThreshold_t - *)(buf - + - len); - printf("Beacon Low RSSI\t%d\t%d\t%s\n", low_rssi->RSSI_value, low_rssi->RSSI_freq, (le16_to_cpu(se->events) & 0x0001) ? "yes" : "no"); - break; - } - case TLV_TYPE_SNR_LOW: - { - MrvlIEtypes_SnrThreshold_t - *low_snr - = - (MrvlIEtypes_SnrThreshold_t - *)(buf - + - len); - printf("Beacon Low SNR\t%d\t%d\t%s\n", low_snr->SNR_value, low_snr->SNR_freq, (le16_to_cpu(se->events) & 0x0002) ? "yes" : "no"); - break; - } - case TLV_TYPE_FAILCOUNT: - { - MrvlIEtypes_FailureCount_t - *failure_count - = - (MrvlIEtypes_FailureCount_t - *)(buf - + - len); - printf("Failure Count\t%d\t%d\t%s\n", failure_count->fail_value, failure_count->fail_freq, (le16_to_cpu(se->events) & 0x0004) ? "yes" : "no"); - break; - } - case TLV_TYPE_BCNMISS: - { - MrvlIEtypes_BeaconsMissed_t - *bcn_missed - = - (MrvlIEtypes_BeaconsMissed_t - *)(buf - + - len); - printf("Beacon Missed\t%d\tN/A\t%s\n", bcn_missed->beacon_missed, (le16_to_cpu(se->events) & 0x0008) ? "yes" : "no"); - break; - } - case TLV_TYPE_RSSI_HIGH: - { - MrvlIEtypes_RssiThreshold_t - *high_rssi - = - (MrvlIEtypes_RssiThreshold_t - *)(buf - + - len); - printf("Bcn High RSSI\t%d\t%d\t%s\n", high_rssi->RSSI_value, high_rssi->RSSI_freq, (le16_to_cpu(se->events) & 0x0010) ? "yes" : "no"); - break; - } - - case TLV_TYPE_SNR_HIGH: - { - MrvlIEtypes_SnrThreshold_t - *high_snr - = - (MrvlIEtypes_SnrThreshold_t - *)(buf - + - len); - printf("Beacon High SNR\t%d\t%d\t%s\n", high_snr->SNR_value, high_snr->SNR_freq, (le16_to_cpu(se->events) & 0x0020) ? "yes" : "no"); - break; - } - case TLV_TYPE_RSSI_LOW_DATA: - { - MrvlIEtypes_RssiThreshold_t - *low_rssi - = - (MrvlIEtypes_RssiThreshold_t - *)(buf - + - len); - printf("Data Low RSSI\t%d\t%d\t%s\n", low_rssi->RSSI_value, low_rssi->RSSI_freq, (le16_to_cpu(se->events) & 0x0040) ? "yes" : "no"); - break; - } - case TLV_TYPE_SNR_LOW_DATA: - { - MrvlIEtypes_SnrThreshold_t - *low_snr - = - (MrvlIEtypes_SnrThreshold_t - *)(buf - + - len); - printf("Data Low SNR\t%d\t%d\t%s\n", low_snr->SNR_value, low_snr->SNR_freq, (le16_to_cpu(se->events) & 0x0080) ? "yes" : "no"); - break; - } - case TLV_TYPE_RSSI_HIGH_DATA: - { - MrvlIEtypes_RssiThreshold_t - *high_rssi - = - (MrvlIEtypes_RssiThreshold_t - *)(buf - + - len); - printf("Data High RSSI\t%d\t%d\t%s\n", high_rssi->RSSI_value, high_rssi->RSSI_freq, (le16_to_cpu(se->events) & 0x0100) ? "yes" : "no"); - break; - } - case TLV_TYPE_SNR_HIGH_DATA: - { - MrvlIEtypes_SnrThreshold_t - *high_snr - = - (MrvlIEtypes_SnrThreshold_t - *)(buf - + - len); - printf("Data High SNR\t%d\t%d\t%s\n", high_snr->SNR_value, high_snr->SNR_freq, (le16_to_cpu(se->events) & 0x0200) ? "yes" : "no"); - break; - } - case TLV_TYPE_LINK_QUALITY: - { - MrvlIEtypes_LinkQuality_t - *link_qual - = - (MrvlIEtypes_LinkQuality_t - *)(buf - + - len); - printf("Link Quality Parameters:\n"); - printf("------------------------\n"); - printf("Link Quality Event Subscribed\t%s\n", (le16_to_cpu(se->events) & 0x0400) ? "yes" : "no"); - printf("Link SNR Threshold = %d\n", le16_to_cpu(link_qual->link_SNR_thrs)); - printf("Link SNR Frequency = %d\n", le16_to_cpu(link_qual->link_SNR_freq)); - printf("Min Rate Value = %d\n", le16_to_cpu(link_qual->min_rate_val)); - printf("Min Rate Frequency = %d\n", le16_to_cpu(link_qual->min_rate_freq)); - printf("Tx Latency Value = %d\n", le32_to_cpu(link_qual->tx_latency_val)); - printf("Tx Latency Threshold = %d\n", le32_to_cpu(link_qual->tx_latency_thrs)); - - break; - } - case TLV_TYPE_PRE_BEACON_LOST: - { - MrvlIEtypes_PreBeaconLost_t - *pre_bcn_lost - = - (MrvlIEtypes_PreBeaconLost_t - *)(buf - + - len); - printf("------------------------\n"); - printf("Pre-Beacon Lost Event Subscribed\t%s\n", (le16_to_cpu(se->events) & 0x0800) ? "yes" : "no"); - printf("Pre-Beacon Lost: %d\n", pre_bcn_lost->pre_beacon_lost); - break; - } - default: - printf("Unknown subscribed event TLV Type=%#x," " Len=%d\n", le16_to_cpu(header->type), le16_to_cpu(header->len)); - break; - } - - len += (sizeof - (MrvlIEtypesHeader_t) - + - le16_to_cpu(header-> - len)); - } - } - break; - } - case HostCmd_CMD_MAC_REG_ACCESS: - case HostCmd_CMD_BBP_REG_ACCESS: - case HostCmd_CMD_RF_REG_ACCESS: - case HostCmd_CMD_CAU_REG_ACCESS: - { - HostCmd_DS_REG *preg = - (HostCmd_DS_REG *)(buf + S_DS_GEN); - preg->action = le16_to_cpu(preg->action); - if (preg->action == HostCmd_ACT_GEN_GET) { - preg->value = le32_to_cpu(preg->value); - printf("value = 0x%08x\n", preg->value); - } - break; - } - case HostCmd_CMD_MEM_ACCESS: - { - HostCmd_DS_MEM *pmem = - (HostCmd_DS_MEM *)(buf + S_DS_GEN); - pmem->action = le16_to_cpu(pmem->action); - if (pmem->action == HostCmd_ACT_GEN_GET) { - pmem->value = le32_to_cpu(pmem->value); - printf("value = 0x%08x\n", pmem->value); - } - break; - } - default: - printf("HOSTCMD_RESP: CmdCode=%#04x, Size=%#04x," - " SeqNum=%#04x, Result=%#04x\n", - hostcmd->command, hostcmd->size, - hostcmd->seq_num, hostcmd->result); - hexdump("payload", - (t_void *)(buf + S_DS_GEN), - hostcmd->size - S_DS_GEN, ' '); - break; - } - } else { - printf("HOSTCMD failed: CmdCode=%#04x, Size=%#04x," - " SeqNum=%#04x, Result=%#04x\n", - hostcmd->command, hostcmd->size, - hostcmd->seq_num, hostcmd->result); - } - return ret; -} - -/** - * @brief Prepare the hostcmd for register access - * @param type Register type - * @param offset Register offset - * @param value Pointer to value (NULL for read) - * @param buf Pointer to hostcmd buffer - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -prepare_hostcmd_regrdwr(t_u32 type, t_u32 offset, t_u32 *value, t_u8 *buf) -{ - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_REG *preg; - - hostcmd = (HostCmd_DS_GEN *)buf; - switch (type) { - case 1: - hostcmd->command = cpu_to_le16(HostCmd_CMD_MAC_REG_ACCESS); - break; - case 2: - hostcmd->command = cpu_to_le16(HostCmd_CMD_BBP_REG_ACCESS); - break; - case 3: - hostcmd->command = cpu_to_le16(HostCmd_CMD_RF_REG_ACCESS); - break; - case 5: - hostcmd->command = cpu_to_le16(HostCmd_CMD_CAU_REG_ACCESS); - break; - default: - printf("Invalid register set specified\n"); - return -EINVAL; - } - preg = (HostCmd_DS_REG *)(buf + S_DS_GEN); - preg->action = (value) ? HostCmd_ACT_GEN_SET : HostCmd_ACT_GEN_GET; - preg->action = cpu_to_le16(preg->action); - preg->offset = cpu_to_le16((t_u16)offset); - if (value) - preg->value = cpu_to_le32(*value); - else - preg->value = 0; - hostcmd->size = cpu_to_le16(S_DS_GEN + sizeof(HostCmd_DS_REG)); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - return MLAN_STATUS_SUCCESS; -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/mlanhostcmd.h b/mxm_wifiex/wlan_src/mapp/mlanconfig/mlanhostcmd.h deleted file mode 100644 index 509f4b8..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/mlanhostcmd.h +++ /dev/null @@ -1,385 +0,0 @@ -/** @file mlanhostcmd.h - * - * @brief This file contains command structures for mlanconfig application - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 11/26/2008: initial version -************************************************************************/ -#ifndef _MLANHOSTCMD_H_ -#define _MLANHOSTCMD_H_ - -/** Find number of elements */ -#define NELEMENTS(x) (sizeof(x)/sizeof(x[0])) - -/** MLAN MAC Address Length */ -#define MLAN_MAC_ADDR_LENGTH (6) -/** Size of command buffer */ -#define MRVDRV_SIZE_OF_CMD_BUFFER (3 * 1024) - -/** Command RET code, MSB is set to 1 */ -#define HostCmd_RET_BIT 0x8000 -/** General purpose action : Get */ -#define HostCmd_ACT_GEN_GET 0x0000 -/** General purpose action : Set */ -#define HostCmd_ACT_GEN_SET 0x0001 -/** General purpose action : Clear */ -#define HostCmd_ACT_GEN_CLEAR 0x0004 -/** General purpose action : Remove */ -#define HostCmd_ACT_GEN_REMOVE 0x0004 - -/** Host Command ID : Memory access */ -#define HostCmd_CMD_MEM_ACCESS 0x0086 - -/** Pre-Authenticate - 11r only */ -#define HostCmd_CMD_802_11_AUTHENTICATE 0x0011 - -/** Read/Write Mac register */ -#define HostCmd_CMD_MAC_REG_ACCESS 0x0019 -/** Read/Write BBP register */ -#define HostCmd_CMD_BBP_REG_ACCESS 0x001a -/** Read/Write RF register */ -#define HostCmd_CMD_RF_REG_ACCESS 0x001b -/** Get TX Power data */ -#define HostCmd_CMD_802_11_RF_TX_POWER 0x001e -/** Get the current TSF */ -#define HostCmd_CMD_GET_TSF 0x0080 -/** Host Command ID : CAU register access */ -#define HostCmd_CMD_CAU_REG_ACCESS 0x00ed - -/** Host Command ID : 802.11 BG scan configuration */ -#define HostCmd_CMD_802_11_BG_SCAN_CONFIG 0x006b -/** Host Command ID : Configuration data */ -#define HostCmd_CMD_CFG_DATA 0x008f -/** Host Command ID : 802.11 TPC adapt req */ -#define HostCmd_CMD_802_11_TPC_ADAPT_REQ 0x0060 -/** Host Command ID : 802.11 crypto */ -#define HostCmd_CMD_802_11_CRYPTO 0x0078 -/** Host Command ID : 802.11 auto Tx */ -#define HostCmd_CMD_802_11_AUTO_TX 0x0082 - -/** Host Command ID : 802.11 subscribe event */ -#define HostCmd_CMD_802_11_SUBSCRIBE_EVENT 0x0075 - -#ifdef OPCHAN -/** Host Command ID : Operating channel config */ -#define HostCmd_CMD_OPCHAN_CONFIG 0x00f8 -/** Host Command ID : Opchan channel group config */ -#define HostCmd_CMD_OPCHAN_CHANGROUP_CONFIG 0x00f9 -#endif - -/** Host Command ID : Channel TRPC config */ -#define HostCmd_CMD_CHAN_TRPC_CONFIG 0x00fb - -/** TLV type ID definition */ -#define PROPRIETARY_TLV_BASE_ID 0x0100 -/** TLV type : Beacon RSSI low */ -#define TLV_TYPE_RSSI_LOW (PROPRIETARY_TLV_BASE_ID + 0x04) //0x0104 -/** TLV type : Beacon SNR low */ -#define TLV_TYPE_SNR_LOW (PROPRIETARY_TLV_BASE_ID + 0x05) //0x0105 -/** TLV type : Fail count */ -#define TLV_TYPE_FAILCOUNT (PROPRIETARY_TLV_BASE_ID + 0x06) //0x0106 -/** TLV type : BCN miss */ -#define TLV_TYPE_BCNMISS (PROPRIETARY_TLV_BASE_ID + 0x07) //0x0107 -/** TLV type : Beacon RSSI high */ -#define TLV_TYPE_RSSI_HIGH (PROPRIETARY_TLV_BASE_ID + 0x16) //0x0116 -/** TLV type : Beacon SNR high */ -#define TLV_TYPE_SNR_HIGH (PROPRIETARY_TLV_BASE_ID + 0x17) //0x0117 -/** TLV type : Auto Tx */ -#define TLV_TYPE_AUTO_TX (PROPRIETARY_TLV_BASE_ID + 0x18) //0x0118 -/** TLV type :Link Quality */ -#define TLV_TYPE_LINK_QUALITY (PROPRIETARY_TLV_BASE_ID + 0x24) //0x0124 -/** TLV type : Data RSSI low */ -#define TLV_TYPE_RSSI_LOW_DATA (PROPRIETARY_TLV_BASE_ID + 0x26) //0x0126 -/** TLV type : Data SNR low */ -#define TLV_TYPE_SNR_LOW_DATA (PROPRIETARY_TLV_BASE_ID + 0x27) //0x0127 -/** TLV type : Data RSSI high */ -#define TLV_TYPE_RSSI_HIGH_DATA (PROPRIETARY_TLV_BASE_ID + 0x28) //0x0128 -/** TLV type : Data SNR high */ -#define TLV_TYPE_SNR_HIGH_DATA (PROPRIETARY_TLV_BASE_ID + 0x29) //0x0129 -/** TLV type: Pre-Beacon Lost */ -#define TLV_TYPE_PRE_BEACON_LOST (PROPRIETARY_TLV_BASE_ID + 0x49) //0x0149 - -#ifdef OPCHAN -/** TLV type : Operating channel control description */ -#define TLV_TYPE_OPCHAN_CONTROL_DESC (PROPRIETARY_TLV_BASE_ID + 0x79) //0x0179 -/** TLV type : Operating channel group control */ -#define TLV_TYPE_OPCHAN_CHANGRP_CTRL (PROPRIETARY_TLV_BASE_ID + 0x7a) //0x017a -#endif - -/** TLV type : Channel TRPC */ -#define TLV_TYPE_CHAN_TRPC (PROPRIETARY_TLV_BASE_ID + 0x89) //0x0189 - -/* Define general hostcmd data structure */ -/** HostCmd_DS_GEN */ -typedef struct MAPP_HostCmd_DS_GEN { - /** Command */ - t_u16 command; - /** Size */ - t_u16 size; - /** Sequence number */ - t_u16 seq_num; - /** Result */ - t_u16 result; -} __ATTRIB_PACK__ HostCmd_DS_GEN; - -typedef struct _HostCmd_DS_MEF_CFG { - /** Criteria */ - t_u32 Criteria; - /** Number of entries */ - t_u16 NumEntries; -} __ATTRIB_PACK__ HostCmd_DS_MEF_CFG; - -typedef struct _MEF_CFG_DATA { - /** Size */ - t_u16 size; - /** Data */ - HostCmd_DS_MEF_CFG data; -} __ATTRIB_PACK__ MEF_CFG_DATA; - -/** Size of HostCmd_DS_GEN */ -#define S_DS_GEN sizeof(HostCmd_DS_GEN) - -/** HostCmd_DS_REG */ -typedef struct MAPP_HostCmd_DS_REG { - /** Read or write */ - t_u16 action; - /** Register offset */ - t_u16 offset; - /** Value */ - t_u32 value; -} __ATTRIB_PACK__ HostCmd_DS_REG; - -/** HostCmd_DS_MEM */ -typedef struct MAPP_HostCmd_DS_MEM { - /** Read or write */ - t_u16 action; - /** Reserved */ - t_u16 reserved; - /** Address */ - t_u32 addr; - /** Value */ - t_u32 value; -} __ATTRIB_PACK__ HostCmd_DS_MEM; - -/** HostCmd_DS_802_11_CFG_DATA */ -typedef struct MAPP_HostCmd_DS_802_11_CFG_DATA { - /** Action */ - t_u16 action; - /** Type */ - t_u16 type; - /** Data length */ - t_u16 data_len; - /** Data */ - t_u8 data[1]; -} __ATTRIB_PACK__ HostCmd_DS_802_11_CFG_DATA; - -/** mlan_ioctl_11h_tpc_resp */ -typedef struct { - int status_code; - /**< Firmware command result status code */ - int tx_power;/**< Reported TX Power from the TPC Report */ - int link_margin; - /**< Reported Link margin from the TPC Report */ - int rssi; /**< RSSI of the received TPC Report frame */ -} __ATTRIB_PACK__ mlan_ioctl_11h_tpc_resp; - -/** MrvlIEtypesHeader_t */ -typedef struct MrvlIEtypesHeader { - /** Header type */ - t_u16 type; - /** Header length */ - t_u16 len; -} __ATTRIB_PACK__ MrvlIEtypesHeader_t; - -/** MrvlIEtypes_Data_t */ -typedef struct MrvlIEtypes_Data_t { - /** Header */ - MrvlIEtypesHeader_t header; - /** Data */ - t_u8 data[1]; -} __ATTRIB_PACK__ MrvlIEtypes_Data_t; - -/** HostCmd_DS_802_11_CRYPTO */ -typedef struct MAPP_HostCmd_DS_802_11_CRYPTO { - t_u16 encdec; /**< Decrypt=0, Encrypt=1 */ - t_u16 algorithm; /**< RC4=1 AES=2 , AES_KEY_WRAP=3 */ - t_u16 key_IV_length;/**< Length of Key IV (bytes) */ - t_u8 keyIV[32]; /**< Key IV */ - t_u16 key_length; /**< Length of Key (bytes) */ - t_u8 key[32]; /**< Key */ - MrvlIEtypes_Data_t data; /**< Plain text if encdec=Encrypt, Ciphertext data if encdec=Decrypt*/ -} __ATTRIB_PACK__ HostCmd_DS_802_11_CRYPTO; - -/** HostCmd_DS_802_11_CRYPTO_AES_CCM */ -typedef struct MAPP_HostCmd_DS_802_11_CRYPTO_AES_CCM { - t_u16 encdec; /**< Decrypt=0, Encrypt=1 */ - t_u16 algorithm; /**< AES_CCM=4 */ - t_u16 key_length; /**< Length of Key (bytes) */ - t_u8 key[32]; /**< Key */ - t_u16 nonce_length;/**< Length of Nonce (bytes) */ - t_u8 nonce[14]; /**< Nonce */ - t_u16 AAD_length; /**< Length of AAD (bytes) */ - t_u8 AAD[32]; /**< AAD */ - MrvlIEtypes_Data_t data; /**< Plain text if encdec=Encrypt, Ciphertext data if encdec=Decrypt*/ -} __ATTRIB_PACK__ HostCmd_DS_802_11_CRYPTO_AES_CCM; - -/** HostCmd_DS_802_11_CRYPTO_WAPI */ -typedef struct MAPP_HostCmd_DS_802_11_CRYPTO_WAPI { - t_u16 encdec; /**< Decrypt=0, Encrypt=1 */ - t_u16 algorithm; /**< WAPI =5 */ - t_u16 key_length; /**< Length of Key (bytes) */ - t_u8 key[32]; /**< Key */ - t_u16 nonce_length;/**< Length of Nonce (bytes) */ - t_u8 nonce[16]; /**< Nonce */ - t_u16 AAD_length; /**< Length of AAD (bytes) */ - t_u8 AAD[48]; /**< AAD */ - t_u16 data_length; /**< Length of data (bytes) */ -} __ATTRIB_PACK__ HostCmd_DS_802_11_CRYPTO_WAPI; -/** WAPI cipher test */ -#define CIPHER_TEST_WAPI (5) -/** AES CCM cipher test */ -#define CIPHER_TEST_AES_CCM (4) -/** GCMP cipher test */ -#define CIPHER_TEST_GCMP (6) -/** AutoTx_MacFrame_t */ -typedef struct AutoTx_MacFrame { - t_u16 interval; /**< in seconds */ - t_u8 priority; /**< User Priority: 0~7, ignored if non-WMM */ - t_u8 reserved; /**< set to 0 */ - t_u16 frame_len; /**< Length of MAC frame payload */ - t_u8 dest_mac_addr[MLAN_MAC_ADDR_LENGTH]; /**< Destination MAC address */ - t_u8 src_mac_addr[MLAN_MAC_ADDR_LENGTH]; /**< Source MAC address */ - t_u8 payload[]; /**< Payload */ -} __ATTRIB_PACK__ AutoTx_MacFrame_t; - -/** MrvlIEtypes_AutoTx_t */ -typedef struct MrvlIEtypes_AutoTx { - MrvlIEtypesHeader_t header; /**< Header */ - AutoTx_MacFrame_t auto_tx_mac_frame; /**< Auto Tx MAC frame */ -} __ATTRIB_PACK__ MrvlIEtypes_AutoTx_t; - -/** HostCmd_DS_802_11_AUTO_TX */ -typedef struct MAPP_HostCmd_DS_802_11_AUTO_TX { - /** Action */ - t_u16 action; /* 0 = ACT_GET; 1 = ACT_SET; */ - MrvlIEtypes_AutoTx_t auto_tx; /**< Auto Tx */ -} __ATTRIB_PACK__ HostCmd_DS_802_11_AUTO_TX; - -/** HostCmd_DS_802_11_SUBSCRIBE_EVENT */ -typedef struct MAPP_HostCmd_DS_802_11_SUBSCRIBE_EVENT { - /** Action */ - t_u16 action; - /** Events */ - t_u16 events; -} __ATTRIB_PACK__ HostCmd_DS_802_11_SUBSCRIBE_EVENT; - -/** MrvlIEtypes_RssiParamSet_t */ -typedef struct MrvlIEtypes_RssiThreshold { - /** Header */ - MrvlIEtypesHeader_t header; - /** RSSI value */ - t_u8 RSSI_value; - /** RSSI frequency */ - t_u8 RSSI_freq; -} __ATTRIB_PACK__ MrvlIEtypes_RssiThreshold_t; - -/** MrvlIEtypes_SnrThreshold_t */ -typedef struct MrvlIEtypes_SnrThreshold { - /** Header */ - MrvlIEtypesHeader_t header; - /** SNR value */ - t_u8 SNR_value; - /** SNR frequency */ - t_u8 SNR_freq; -} __ATTRIB_PACK__ MrvlIEtypes_SnrThreshold_t; - -/** MrvlIEtypes_FailureCount_t */ -typedef struct MrvlIEtypes_FailureCount { - /** Header */ - MrvlIEtypesHeader_t header; - /** Failure value */ - t_u8 fail_value; - /** Failure frequency */ - t_u8 fail_freq; -} __ATTRIB_PACK__ MrvlIEtypes_FailureCount_t; - -/** MrvlIEtypes_BeaconsMissed_t */ -typedef struct MrvlIEtypes_BeaconsMissed { - /** Header */ - MrvlIEtypesHeader_t header; - /** Number of beacons missed */ - t_u8 beacon_missed; - /** Reserved */ - t_u8 reserved; -} __ATTRIB_PACK__ MrvlIEtypes_BeaconsMissed_t; - -/** MrvlIEtypes_LinkQuality_t */ -typedef struct MrvlIEtypes_LinkQuality { - /** Header */ - MrvlIEtypesHeader_t header; - /** Link SNR threshold */ - t_u16 link_SNR_thrs; - /** Link SNR frequency */ - t_u16 link_SNR_freq; - /** Minimum rate value */ - t_u16 min_rate_val; - /** Minimum rate frequency */ - t_u16 min_rate_freq; - /** Tx latency value */ - t_u32 tx_latency_val; - /** Tx latency threshold */ - t_u32 tx_latency_thrs; -} __ATTRIB_PACK__ MrvlIEtypes_LinkQuality_t; - -/** MrvlIEtypes_PreBeaconLost_t */ -typedef struct MrvlIEtypes_PreBeaconLost { - /** Header */ - MrvlIEtypesHeader_t header; - /** Pre-Beacon Lost */ - t_u8 pre_beacon_lost; - /** Reserved */ - t_u8 reserved; -} __ATTRIB_PACK__ MrvlIEtypes_PreBeaconLost_t; - -/* String helper functions */ -/** Convert char to hex integer */ -int hexval(t_s32 chr); -/** Convert char to hex integer */ -t_u8 hexc2bin(t_s8 chr); -/** Convert string to hex integer */ -t_u32 a2hex(t_s8 *s); -/** Check the Hex String */ -int ishexstring(t_s8 *s); -/** Convert String to integer */ -t_u32 a2hex_or_atoi(t_s8 *value); -/** Convert String to Integer */ -int atoval(t_s8 *buf); -/** Hump hex data */ -void hexdump(t_s8 *prompt, void *p, t_s32 len, t_s8 delim); -/** Convert String to Hex */ -t_s8 *convert2hex(t_s8 *ptr, t_u8 *chr); - -int process_host_cmd_resp(t_u8 *buf); -int prepare_host_cmd_buffer(FILE * fp, char *cmd_name, t_u8 *buf); -int prepare_cfg_data_buffer(int argc, char *argv[], FILE * fp, t_u8 *buf); -int prepare_hostcmd_regrdwr(t_u32 type, t_u32 offset, t_u32 *value, t_u8 *buf); - -#endif /* _MLANHOSTCMD_H_ */ diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/mlanmisc.c b/mxm_wifiex/wlan_src/mapp/mlanconfig/mlanmisc.c deleted file mode 100644 index 4c7b25a..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/mlanmisc.c +++ /dev/null @@ -1,1162 +0,0 @@ -/** @file mlanmisc.c - * - * @brief Program to prepare command buffer - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ - -/************************************************************************ -Change log: - 03/10/2009: initial version -************************************************************************/ - -#include "mlanconfig.h" -#include "mlanhostcmd.h" -#include "mlanmisc.h" - -/******************************************************** - Local Variables -********************************************************/ - -/******************************************************** - Global Variables -********************************************************/ - -/******************************************************** - Local Functions -********************************************************/ - -/** - * @brief Helper function for process_getscantable_idx - * - * @param pbuf A pointer to the buffer - * @param buf_len buffer length - * - * @return NA - * - */ -static void -dump_scan_elems(const t_u8 *pbuf, uint buf_len) -{ - uint idx; - uint marker = 2 + pbuf[1]; - - for (idx = 0; idx < buf_len; idx++) { - if (idx % 0x10 == 0) { - printf("\n%04x: ", idx); - } - - if (idx == marker) { - printf("|"); - marker = idx + pbuf[idx + 1] + 2; - } else { - printf(" "); - } - - printf("%02x ", pbuf[idx]); - } - - printf("\n"); -} - -/** - * @brief Helper function for process_getscantable_idx - * Find next element - * - * @param pp_ie_out pointer of a IEEEtypes_Generic_t structure pointer - * @param p_buf_left integer pointer, which contains the number of left p_buf - * - * @return MLAN_STATUS_SUCCESS on success, otherwise MLAN_STATUS_FAILURE - */ -static int -scantable_elem_next(IEEEtypes_Generic_t **pp_ie_out, int *p_buf_left) -{ - IEEEtypes_Generic_t *pie_gen; - t_u8 *p_next; - - if (*p_buf_left < 2) { - return MLAN_STATUS_FAILURE; - } - - pie_gen = *pp_ie_out; - - p_next = (t_u8 *)pie_gen + (pie_gen->ieee_hdr.len - + sizeof(pie_gen->ieee_hdr)); - *p_buf_left -= (p_next - (t_u8 *)pie_gen); - - *pp_ie_out = (IEEEtypes_Generic_t *)p_next; - - if (*p_buf_left <= 0) { - return MLAN_STATUS_FAILURE; - } - - return MLAN_STATUS_SUCCESS; -} - - /** - * @brief Helper function for process_getscantable_idx - * scantable find element - * - * @param ie_buf pointer of the IE buffer - * @param ie_buf_len IE buffer length - * @param ie_type IE type - * @param ppie_out pointer to the IEEEtypes_Generic_t structure pointer - * @return MLAN_STATUS_SUCCESS on success, otherwise MLAN_STATUS_FAILURE - */ -static int -scantable_find_elem(t_u8 *ie_buf, - unsigned int ie_buf_len, - IEEEtypes_ElementId_e ie_type, - IEEEtypes_Generic_t **ppie_out) -{ - int found; - unsigned int ie_buf_left; - - ie_buf_left = ie_buf_len; - - found = FALSE; - - *ppie_out = (IEEEtypes_Generic_t *)ie_buf; - - do { - found = ((*ppie_out)->ieee_hdr.element_id == ie_type); - - } while (!found && - (scantable_elem_next(ppie_out, (int *)&ie_buf_left) == 0)); - - if (!found) { - *ppie_out = NULL; - } - - return (found ? MLAN_STATUS_SUCCESS : MLAN_STATUS_FAILURE); -} - - /** - * @brief Helper function for process_getscantable_idx - * It gets SSID from IE - * - * @param ie_buf IE buffer - * @param ie_buf_len IE buffer length - * @param pssid SSID - * @param ssid_buf_max size of SSID - * @return MLAN_STATUS_SUCCESS on success, otherwise MLAN_STATUS_FAILURE - */ -static int -scantable_get_ssid_from_ie(t_u8 *ie_buf, - unsigned int ie_buf_len, - t_u8 *pssid, unsigned int ssid_buf_max) -{ - int retval; - IEEEtypes_Generic_t *pie_gen; - - retval = scantable_find_elem(ie_buf, ie_buf_len, SSID, &pie_gen); - if (retval == MLAN_STATUS_SUCCESS) - memcpy(pssid, pie_gen->data, - MIN(pie_gen->ieee_hdr.len, ssid_buf_max)); - - return retval; -} - -/** - * @brief Display detailed information for a specific scan table entry - * - * @param prsp_info_req Scan table entry request structure - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_getscantable_idx(wlan_ioctl_get_scan_table_info *prsp_info_req) -{ - int ioctl_val, subioctl_val; - struct iwreq iwr; - t_u8 *pcurrent; - int ret = 0; - char ssid[33]; - t_u16 tmp_cap; - t_u8 tsf[8]; - t_u16 beacon_interval; - t_u8 *scan_rsp_buf = NULL; - t_u16 cap_info; - wlan_ioctl_get_scan_table_info *prsp_info; - - wlan_get_scan_table_fixed fixed_fields; - t_u32 fixed_field_length; - t_u32 bss_info_length; - - scan_rsp_buf = (t_u8 *)malloc(SCAN_RESP_BUF_SIZE); - if (scan_rsp_buf == NULL) { - printf("Error: allocate memory for scan_rsp_buf failed\n"); - return -ENOMEM; - } - memset(ssid, 0x00, sizeof(ssid)); - - prsp_info = (wlan_ioctl_get_scan_table_info *)scan_rsp_buf; - - memcpy(prsp_info, prsp_info_req, - sizeof(wlan_ioctl_get_scan_table_info)); - - if (get_priv_ioctl("getscantable", - &ioctl_val, &subioctl_val) == MLAN_STATUS_FAILURE) { - ret = -EOPNOTSUPP; - goto done; - } - - /* - * Set up and execute the ioctl call - */ - strncpy(iwr.ifr_name, dev_name, IFNAMSIZ - 1); - iwr.u.data.pointer = (caddr_t) prsp_info; - iwr.u.data.length = SCAN_RESP_BUF_SIZE; - iwr.u.data.flags = subioctl_val; - - if (ioctl(sockfd, ioctl_val, &iwr) < 0) { - perror("mlanconfig: getscantable ioctl"); - ret = -EFAULT; - goto done; - } - - if (prsp_info->scan_number == 0) { - printf("mlanconfig: getscantable ioctl - index out of range\n"); - ret = -EINVAL; - goto done; - } - - pcurrent = prsp_info->scan_table_entry_buf; - - memcpy((t_u8 *)&fixed_field_length, - (t_u8 *)pcurrent, sizeof(fixed_field_length)); - pcurrent += sizeof(fixed_field_length); - - memcpy((t_u8 *)&bss_info_length, - (t_u8 *)pcurrent, sizeof(bss_info_length)); - pcurrent += sizeof(bss_info_length); - - memcpy((t_u8 *)&fixed_fields, (t_u8 *)pcurrent, sizeof(fixed_fields)); - pcurrent += fixed_field_length; - - /* time stamp is 8 byte long */ - memcpy(tsf, pcurrent, sizeof(tsf)); - pcurrent += sizeof(tsf); - bss_info_length -= sizeof(tsf); - - /* beacon interval is 2 byte long */ - memcpy(&beacon_interval, pcurrent, sizeof(beacon_interval)); - pcurrent += sizeof(beacon_interval); - bss_info_length -= sizeof(beacon_interval); - - /* capability information is 2 byte long */ - memcpy(&cap_info, pcurrent, sizeof(cap_info)); - pcurrent += sizeof(cap_info); - bss_info_length -= sizeof(cap_info); - - scantable_get_ssid_from_ie(pcurrent, - bss_info_length, (t_u8 *)ssid, sizeof(ssid)); - - printf("\n*** [%s], %02x:%02x:%02x:%02x:%02x:%2x\n", - ssid, - fixed_fields.bssid[0], - fixed_fields.bssid[1], - fixed_fields.bssid[2], - fixed_fields.bssid[3], - fixed_fields.bssid[4], fixed_fields.bssid[5]); - memcpy(&tmp_cap, &cap_info, sizeof(tmp_cap)); - printf("Channel = %d, SS = %d, CapInfo = 0x%04x, BcnIntvl = %d\n", - fixed_fields.channel, - 255 - fixed_fields.rssi, tmp_cap, beacon_interval); - - printf("TSF Values: AP(0x%02x%02x%02x%02x%02x%02x%02x%02x), ", - tsf[7], tsf[6], tsf[5], tsf[4], tsf[3], tsf[2], tsf[1], tsf[0]); - - printf("Network(0x%016llx)\n", fixed_fields.network_tsf); - printf("\n"); - printf("Element Data (%d bytes)\n", (int)bss_info_length); - printf("------------"); - dump_scan_elems(pcurrent, bss_info_length); - printf("\n"); - -done: - - if (scan_rsp_buf) - free(scan_rsp_buf); - - return ret; -} - -/******************************************************** - Global Functions -********************************************************/ -#ifdef SDIO -/** Maximum SDIO command-52 buffer length */ -#define CMD52_BUF_LEN 3 - -/** - * @brief SD comand52 read/write - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_sdcmd52rw(int argc, char *argv[]) -{ - struct iwreq iwr; - int ioctl_val, subioctl_val, buf[CMD52_BUF_LEN]; - - if (get_priv_ioctl("sdcmd52rw", - &ioctl_val, &subioctl_val) == MLAN_STATUS_FAILURE) { - return -EOPNOTSUPP; - } - - if (argc == 5) { - /* CMD52 read */ - iwr.u.data.length = CMD52_BUF_LEN - 1; - } else if (argc == 6) { - /* CMD52 write */ - buf[2] = atoval(argv[5]); /* data */ - iwr.u.data.length = CMD52_BUF_LEN; - } else { - fprintf(stderr, "Invalid number of parameters!\n"); - return MLAN_STATUS_FAILURE; - } - buf[0] = atoval(argv[3]); /* func */ - buf[1] = atoval(argv[4]); /* reg */ - strncpy(iwr.ifr_name, dev_name, IFNAMSIZ - 1); - iwr.u.data.flags = subioctl_val; - iwr.u.data.pointer = (caddr_t) buf; - - if (ioctl(sockfd, ioctl_val, &iwr)) { - perror("mlanconfig"); - fprintf(stderr, - "mlanconfig: CMD52 R/W not supported by " - "interface %s\n", dev_name); - return MLAN_STATUS_FAILURE; - } - printf("sdcmd52rw returns 0x%02X\n", buf[0]); - - return MLAN_STATUS_SUCCESS; -} - -/** Maximum SDIO command-53 buffer length */ -#define CMD53_BUF_LEN 2000 - -/** - * @brief SD comand53 read/write - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_sdcmd53rw(int argc, char *argv[]) -{ - struct iwreq iwr; - t_s8 *buf = NULL; - int addr, mode, blklen, blknum, i, rw; - int ioctl_val, subioctl_val; - - if (get_priv_ioctl("sdcmd53rw", - &ioctl_val, &subioctl_val) == MLAN_STATUS_FAILURE) { - return -EOPNOTSUPP; - } - - if (argc < 8) { - fprintf(stderr, "Invalid number of parameters!\n"); - return MLAN_STATUS_FAILURE; - } - - if (!(buf = malloc(CMD53_BUF_LEN))) - return -ENOMEM; - memset(buf, 0, CMD53_BUF_LEN); - - if (argc == 8) { - rw = buf[0] = 0; /* CMD53 read */ - } else { - rw = buf[0] = 1; /* CMD53 write */ - } - buf[1] = atoval(argv[3]); /* func */ - addr = atoval(argv[4]); /* address */ - buf[2] = addr & 0xff; - buf[3] = (addr >> 8) & 0xff; - buf[4] = (addr >> 16) & 0xff; - buf[5] = (addr >> 24) & 0xff; - mode = atoval(argv[5]); /* mode */ - buf[6] = (t_u8)mode; - blklen = atoval(argv[6]); /* block size */ - buf[7] = blklen & 0xff; - buf[8] = (blklen >> 8) & 0xff; - blknum = atoval(argv[7]); /* block number or byte number */ - buf[9] = blknum & 0xff; - buf[10] = (blknum >> 8) & 0xff; - iwr.u.data.length = 11; - if (buf[0]) { - for (i = 0; i < (argc - 8); i++) - buf[11 + i] = atoval(argv[8 + i]); - iwr.u.data.length += (argc - 8); - } - strncpy(iwr.ifr_name, dev_name, IFNAMSIZ - 1); - iwr.u.data.flags = subioctl_val; - iwr.u.data.pointer = (caddr_t) buf; - - if (ioctl(sockfd, ioctl_val, &iwr)) { - perror("mlanconfig"); - fprintf(stderr, - "mlanconfig: CMD53 R/W not supported by " - "interface %s\n", dev_name); - free(buf); - return MLAN_STATUS_FAILURE; - } - - if (mode) { - fprintf(stderr, "CMD53rw blklen = %d, blknum = %d\n", blklen, - blknum); - } else { - blklen = 1; - fprintf(stderr, "CMD53rw bytelen = %d\n", blknum); - } - if (!rw) - hexdump("data", buf, blklen * blknum, ' '); - - free(buf); - return MLAN_STATUS_SUCCESS; -} -#endif - -/** - * @brief Retrieve and display the contents of the driver scan table. - * - * The ioctl to retrieve the scan table contents will be invoked, and portions - * of the scan data will be displayed on stdout. The entire beacon or - * probe response is also retrieved (if available in the driver). This - * data would be needed in case the application was explicitly controlling - * the association (inserting IEs, TLVs, etc). - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_getscantable(int argc, char *argv[]) -{ - int ioctl_val, subioctl_val; - struct iwreq iwr; - t_u8 *scan_rsp_buf = NULL; - - struct wlan_ioctl_get_scan_list *scan_list_head = NULL; - struct wlan_ioctl_get_scan_list *scan_list_node = NULL; - struct wlan_ioctl_get_scan_list *curr = NULL, *prev = NULL, *next = - NULL; - - t_u32 total_scan_res = 0; - - unsigned int scan_start; - int idx, ret = 0; - - t_u8 *pcurrent; - t_u8 *pnext; - IEEEtypes_ElementId_e *pelement_id; - t_u8 *pelement_len; - int ssid_idx; - t_u8 *pbyte; - t_u16 new_ss; - t_u16 curr_ss; - - IEEEtypes_VendorSpecific_t *pwpa_ie; - const t_u8 wpa_oui[4] = { 0x00, 0x50, 0xf2, 0x01 }; - - IEEEtypes_WmmParameter_t *pwmm_ie; - const t_u8 wmm_oui[4] = { 0x00, 0x50, 0xf2, 0x02 }; - IEEEtypes_VendorSpecific_t *pwps_ie; - const t_u8 wps_oui[4] = { 0x00, 0x50, 0xf2, 0x04 }; - - int displayed_info; - - wlan_ioctl_get_scan_table_info rspInfoReq; - wlan_ioctl_get_scan_table_info *prsp_info; - - wlan_get_scan_table_fixed fixed_fields; - t_u32 fixed_field_length; - t_u32 bss_info_length; - wlan_ioctl_get_bss_info *bss_info; - - scan_rsp_buf = (t_u8 *)malloc(SCAN_RESP_BUF_SIZE); - if (scan_rsp_buf == NULL) { - printf("Error: allocate memory for scan_rsp_buf failed\n"); - return -ENOMEM; - } - prsp_info = (wlan_ioctl_get_scan_table_info *)scan_rsp_buf; - - if (get_priv_ioctl("getscantable", - &ioctl_val, &subioctl_val) == MLAN_STATUS_FAILURE) { - ret = -EOPNOTSUPP; - goto done; - } - - if (argc > 3 && (strcmp(argv[3], "tsf") != 0) - && (strcmp(argv[3], "help") != 0)) { - - idx = strtol(argv[3], NULL, 10); - - if (idx >= 0) { - if (scan_rsp_buf) { - free(scan_rsp_buf); - } - rspInfoReq.scan_number = idx; - return process_getscantable_idx(&rspInfoReq); - } - } - - displayed_info = FALSE; - scan_start = 1; - - do { - prsp_info->scan_number = scan_start; - - /* - * Set up and execute the ioctl call - */ - strncpy(iwr.ifr_name, dev_name, IFNAMSIZ - 1); - iwr.u.data.pointer = (caddr_t) prsp_info; - iwr.u.data.length = SCAN_RESP_BUF_SIZE; - iwr.u.data.flags = subioctl_val; - - if (ioctl(sockfd, ioctl_val, &iwr) < 0) { - perror("mlanconfig: getscantable ioctl"); - ret = -EFAULT; - goto done; - } - total_scan_res += prsp_info->scan_number; - - pcurrent = 0; - pnext = prsp_info->scan_table_entry_buf; - - for (idx = 0; (unsigned int)idx < prsp_info->scan_number; idx++) { - - /* Alloc memory for new node for next BSS */ - scan_list_node = (struct wlan_ioctl_get_scan_list *) - malloc(sizeof(struct wlan_ioctl_get_scan_list)); - if (scan_list_node == NULL) { - printf("Error: allocate memory for scan_list_head failed\n"); - return -ENOMEM; - } - memset(scan_list_node, 0, - sizeof(struct wlan_ioctl_get_scan_list)); - - /* - * Set pcurrent to pnext in case pad bytes are at the end - * of the last IE we processed. - */ - pcurrent = pnext; - - /* Start extracting each BSS to prepare a linked list */ - memcpy((t_u8 *)&fixed_field_length, - (t_u8 *)pcurrent, sizeof(fixed_field_length)); - pcurrent += sizeof(fixed_field_length); - - memcpy((t_u8 *)&bss_info_length, - (t_u8 *)pcurrent, sizeof(bss_info_length)); - pcurrent += sizeof(bss_info_length); - - memcpy((t_u8 *)&fixed_fields, - (t_u8 *)pcurrent, sizeof(fixed_fields)); - pcurrent += fixed_field_length; - - scan_list_node->fixed_buf.fixed_field_length = - fixed_field_length; - scan_list_node->fixed_buf.bss_info_length = - bss_info_length; - scan_list_node->fixed_buf.fixed_fields = fixed_fields; - - bss_info = &scan_list_node->bss_info_buf; - - /* Set next to be the start of the next scan entry */ - pnext = pcurrent + bss_info_length; - - if (bss_info_length >= - (sizeof(bss_info->tsf) + - sizeof(bss_info->beacon_interval) + - sizeof(bss_info->cap_info))) { - - /* time stamp is 8 byte long */ - memcpy(bss_info->tsf, pcurrent, - sizeof(bss_info->tsf)); - pcurrent += sizeof(bss_info->tsf); - bss_info_length -= sizeof(bss_info->tsf); - - /* beacon interval is 2 byte long */ - memcpy(&bss_info->beacon_interval, pcurrent, - sizeof(bss_info->beacon_interval)); - pcurrent += sizeof(bss_info->beacon_interval); - bss_info_length -= - sizeof(bss_info->beacon_interval); - - /* capability information is 2 byte long */ - memcpy(&bss_info->cap_info, pcurrent, - sizeof(bss_info->cap_info)); - pcurrent += sizeof(bss_info->cap_info); - bss_info_length -= sizeof(bss_info->cap_info); - } - - bss_info->wmm_cap = ' '; /* M (WMM), C (WMM-Call Admission Control) */ - bss_info->wps_cap = ' '; /* "S" */ - bss_info->dot11k_cap = ' '; /* "K" */ - bss_info->dot11r_cap = ' '; /* "R" */ - bss_info->ht_cap = ' '; /* "N" */ - - /* "P" for Privacy (WEP) since "W" is WPA, and "2" is RSN/WPA2 */ - bss_info->priv_cap = - bss_info->cap_info.privacy ? 'P' : ' '; - - memset(bss_info->ssid, 0, MRVDRV_MAX_SSID_LENGTH + 1); - bss_info->ssid_len = 0; - - while (bss_info_length >= 2) { - pelement_id = (IEEEtypes_ElementId_e *)pcurrent; - pelement_len = pcurrent + 1; - pcurrent += 2; - - switch (*pelement_id) { - - case SSID: - if (*pelement_len && - *pelement_len <= - MRVDRV_MAX_SSID_LENGTH) { - memcpy(bss_info->ssid, pcurrent, - *pelement_len); - bss_info->ssid_len = - *pelement_len; - } - break; - - case WPA_IE: - pwpa_ie = - (IEEEtypes_VendorSpecific_t *) - pelement_id; - if ((memcmp - (pwpa_ie->vend_hdr.oui, wpa_oui, - sizeof(pwpa_ie->vend_hdr.oui)) == - 0) - && (pwpa_ie->vend_hdr.oui_type == - wpa_oui[3])) { - /* WPA IE found, 'W' for WPA */ - bss_info->priv_cap = 'W'; - } else { - pwmm_ie = - (IEEEtypes_WmmParameter_t - *)pelement_id; - if ((memcmp - (pwmm_ie->vend_hdr.oui, - wmm_oui, - sizeof(pwmm_ie->vend_hdr. - oui)) == 0) - && (pwmm_ie->vend_hdr. - oui_type == - wmm_oui[3])) { - /* Check the subtype: 1 == parameter, 0 == info */ - if ((pwmm_ie->vend_hdr. - oui_subtype == 1) - && pwmm_ie-> - ac_params - [WMM_AC_VO]. - aci_aifsn.acm) { - /* Call admission on VO; 'C' for CAC */ - bss_info-> - wmm_cap - = 'C'; - } else { - /* No CAC; 'M' for uh, WMM */ - bss_info-> - wmm_cap - = 'M'; - } - } else { - pwps_ie = - (IEEEtypes_VendorSpecific_t - *)pelement_id; - if ((memcmp - (pwps_ie->vend_hdr. - oui, wps_oui, - sizeof(pwps_ie-> - vend_hdr. - oui)) == 0) - && (pwps_ie-> - vend_hdr. - oui_type == - wps_oui[3])) { - bss_info-> - wps_cap - = 'S'; - } - } - } - break; - - case RSN_IE: - /* RSN IE found; '2' for WPA2 (RSN) */ - bss_info->priv_cap = '2'; - break; - case HT_CAPABILITY: - bss_info->ht_cap = 'N'; - break; - case VHT_CAPABILITY: - bss_info->vht_cap[0] = 'A'; - bss_info->vht_cap[1] = 'C'; - break; - default: - break; - } - - pcurrent += *pelement_len; - bss_info_length -= (2 + *pelement_len); - } - - /* Create a sorted list of BSS using Insertion Sort. - Sort as per Signal Strength (descending order) */ - new_ss = 255 - fixed_fields.rssi; - - if (scan_list_head == NULL) { - // Node is the first element in the list. - scan_list_head = scan_list_node; - scan_list_node->next = NULL; - } else { - - curr_ss = - 255 - - scan_list_head->fixed_buf.fixed_fields. - rssi; - - if (new_ss > curr_ss) { - // Insert the node to head of the list - scan_list_node->next = scan_list_head; - scan_list_head = scan_list_node; - } else { - for (curr = scan_list_head; - curr != NULL; curr = curr->next) { - curr_ss = - 255 - - curr->fixed_buf. - fixed_fields.rssi; - if (prev && (new_ss > curr_ss)) { - // Insert the node to current position in list - scan_list_node->next = - curr; - prev->next = - scan_list_node; - break; - } - prev = curr; - } - if (prev && (curr == NULL)) { - // Insert the node to tail of the list - prev->next = scan_list_node; - scan_list_node->next = NULL; - } - } - } - } - - scan_start += prsp_info->scan_number; - } while (prsp_info->scan_number); - - // Display scan results - printf("---------------------------------------"); - printf("---------------------------------------\n"); - printf("# | ch | ss | bssid | cap | SSID \n"); - printf("---------------------------------------"); - printf("---------------------------------------\n"); - - for (curr = scan_list_head, idx = 0; - (curr != NULL) && ((unsigned int)idx < total_scan_res); - curr = curr->next, idx++) { - - fixed_fields = curr->fixed_buf.fixed_fields; - bss_info = &curr->bss_info_buf; - - printf("%02u| %03d | %03d | %02x:%02x:%02x:%02x:%02x:%02x |", - idx, - fixed_fields.channel, - 255 - fixed_fields.rssi, - fixed_fields.bssid[0], - fixed_fields.bssid[1], - fixed_fields.bssid[2], - fixed_fields.bssid[3], - fixed_fields.bssid[4], fixed_fields.bssid[5]); - - displayed_info = TRUE; - - /* "A" for Adhoc - * "I" for Infrastructure, - * "D" for DFS (Spectrum Mgmt) - */ - printf(" %c%c%c%c%c%c%c%c%c%c | ", bss_info->cap_info.ibss ? 'A' : 'I', bss_info->priv_cap, /* P (WEP), W (WPA), 2 (WPA2) */ - bss_info->cap_info.spectrum_mgmt ? 'D' : ' ', bss_info->wmm_cap, /* M (WMM), C (WMM-Call Admission Control) */ - bss_info->dot11k_cap, /* K */ - bss_info->dot11r_cap, /* R */ - bss_info->wps_cap, /* S */ - bss_info->ht_cap, /* N */ - bss_info->vht_cap[0], /* AC */ - bss_info->vht_cap[1]); - - /* Print out the ssid or the hex values if non-printable */ - for (ssid_idx = 0; ssid_idx < bss_info->ssid_len; ssid_idx++) { - if (isprint(bss_info->ssid[ssid_idx])) { - printf("%c", bss_info->ssid[ssid_idx]); - } else { - printf("\\%02x", bss_info->ssid[ssid_idx]); - } - } - - printf("\n"); - - if (argc > 3 && strcmp(argv[3], "tsf") == 0) { - /* TSF is a u64, some formatted printing libs have trouble - printing long longs, so cast and dump as bytes */ - pbyte = (t_u8 *)&fixed_fields.network_tsf; - printf(" TSF=%02x%02x%02x%02x%02x%02x%02x%02x\n", - pbyte[7], pbyte[6], pbyte[5], pbyte[4], - pbyte[3], pbyte[2], pbyte[1], pbyte[0]); - } - } - - if (displayed_info == TRUE) { - if (argc > 3 && strcmp(argv[3], "help") == 0) { - printf("\n\n" - "Capability Legend (Not all may be supported)\n" - "-----------------\n" - " I [ Infrastructure ]\n" - " A [ Ad-hoc ]\n" - " W [ WPA IE ]\n" - " 2 [ WPA2/RSN IE ]\n" - " M [ WMM IE ]\n" - " C [ Call Admission Control - WMM IE, VO ACM set ]\n" - " D [ Spectrum Management - DFS (11h) ]\n" - " K [ 11k ]\n" - " R [ 11r ]\n" - " S [ WPS ]\n" - " N [ HT (11n) ]\n" - " AC [VHT (11ac) ]\n" "\n\n"); - } - } else { - printf("< No Scan Results >\n"); - } - -done: - if (scan_rsp_buf) - free(scan_rsp_buf); - for (curr = scan_list_head; curr != NULL; curr = next) { - next = curr->next; - free(curr); - } - return ret; -} - -/** Maximum channel scratch */ -#define MAX_CHAN_SCRATCH 100 - -/** Maximum channel number for b/g band */ -#define MAX_CHAN_BG_BAND 14 - -/** Maximum number of probes to send on each channel */ -#define MAX_PROBES 5 - -/** Scan all the channels in specified band */ -#define BAND_SPECIFIED 0x80 -/** - * @brief Request a scan from the driver and display the scan table afterwards - * - * Command line interface for performing a specific immediate scan based - * on the following keyword parsing: - * - * chan=[chan#][band][mode] where band is [a,b,g,n] and mode is - * blank for active or 'p' for passive - * bssid=xx:xx:xx:xx:xx:xx specify a BSSID filter for the scan - * ssid="[SSID]" specify a SSID filter for the scan - * keep=[0 or 1] keep the previous scan results (1), discard (0) - * dur=[scan time] time to scan for each channel in milliseconds - * probes=[#] number of probe requests to send on each chan - * type=[1,2,3] BSS type: 1 (Infra), 2(Adhoc), 3(Any) - * - * Any combination of the above arguments can be supplied on the command line. - * If the chan token is absent, a full channel scan will be completed by - * the driver. If the dur or probes tokens are absent, the drivers default - * setting will be used. The bssid and ssid fields, if blank, - * will produce an unfiltered scan. The type field will default to 3 (Any) - * and the keep field will default to 0 (Discard). - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_setuserscan(int argc, char *argv[]) -{ - wlan_ioctl_user_scan_cfg scan_req; - int ioctl_val, subioctl_val; - struct iwreq iwr; - char *parg_tok; - char *pchan_tok; - char *parg_cookie; - char *pchan_cookie; - int arg_idx; - int chan_parse_idx; - int chan_cmd_idx; - char chan_scratch[MAX_CHAN_SCRATCH]; - char *pscratch; - int tmp_idx; - int scan_time; - int num_ssid; - int is_radio_set; - unsigned int mac[ETH_ALEN]; - - memset(&scan_req, 0x00, sizeof(scan_req)); - chan_cmd_idx = 0; - scan_time = 0; - num_ssid = 0; - - if (get_priv_ioctl("setuserscan", - &ioctl_val, &subioctl_val) == MLAN_STATUS_FAILURE) { - return -EOPNOTSUPP; - } - - for (arg_idx = 0; arg_idx < argc; arg_idx++) { - - if (strncmp(argv[arg_idx], "ssid=", strlen("ssid=")) == 0) { - /* - * "ssid" token string handler - */ - if (num_ssid < MRVDRV_MAX_SSID_LIST_LENGTH) { - strncpy(scan_req.ssid_list[num_ssid].ssid, - argv[arg_idx] + strlen("ssid="), - sizeof(scan_req.ssid_list[num_ssid]. - ssid)); - - scan_req.ssid_list[num_ssid].max_len = 0; - - num_ssid++; - } - } else if (strncmp(argv[arg_idx], "bssid=", strlen("bssid=")) == - 0) { - /* - * "bssid" token string handler - */ - sscanf(argv[arg_idx] + strlen("bssid="), - "%2x:%2x:%2x:%2x:%2x:%2x", mac + 0, mac + 1, - mac + 2, mac + 3, mac + 4, mac + 5); - - for (tmp_idx = 0; - (unsigned int)tmp_idx < NELEMENTS(mac); - tmp_idx++) { - scan_req.specific_bssid[tmp_idx] = - (t_u8)mac[tmp_idx]; - } - } else if (strncmp(argv[arg_idx], "chan=", strlen("chan=")) == - 0) { - /* - * "chan" token string handler - */ - parg_tok = argv[arg_idx] + strlen("chan="); - - if (strlen(parg_tok) > MAX_CHAN_SCRATCH) { - printf("Error: Specified channels exceeds max limit\n"); - return MLAN_STATUS_FAILURE; - } - is_radio_set = FALSE; - - while ((parg_tok = - strtok_r(parg_tok, ",", - &parg_cookie)) != NULL) { - - memset(chan_scratch, 0x00, - sizeof(chan_scratch)); - pscratch = chan_scratch; - - for (chan_parse_idx = 0; - (unsigned int)chan_parse_idx < - strlen(parg_tok); chan_parse_idx++) { - if (isalpha - (*(parg_tok + chan_parse_idx))) { - *pscratch++ = ' '; - } - - *pscratch++ = - *(parg_tok + chan_parse_idx); - } - *pscratch = 0; - parg_tok = NULL; - - pchan_tok = chan_scratch; - - while ((pchan_tok = strtok_r(pchan_tok, " ", - &pchan_cookie)) != - NULL) { - if (isdigit(*pchan_tok)) { - scan_req. - chan_list[chan_cmd_idx]. - chan_number = - atoi(pchan_tok); - if (scan_req. - chan_list[chan_cmd_idx]. - chan_number > - MAX_CHAN_BG_BAND) - scan_req. - chan_list - [chan_cmd_idx]. - radio_type = 1; - } else { - switch (toupper(*pchan_tok)) { - case 'A': - scan_req. - chan_list - [chan_cmd_idx]. - radio_type = 1; - is_radio_set = TRUE; - break; - case 'B': - case 'G': - scan_req. - chan_list - [chan_cmd_idx]. - radio_type = 0; - is_radio_set = TRUE; - break; - case 'N': - break; - case 'P': - scan_req. - chan_list - [chan_cmd_idx]. - scan_type = - MLAN_SCAN_TYPE_PASSIVE; - break; - default: - printf("Error: Band type not supported!\n"); - return -EOPNOTSUPP; - } - if (!chan_cmd_idx && - !scan_req. - chan_list[chan_cmd_idx]. - chan_number && is_radio_set) - scan_req. - chan_list - [chan_cmd_idx]. - radio_type |= - BAND_SPECIFIED; - } - pchan_tok = NULL; - } - chan_cmd_idx++; - } - } else if (strncmp(argv[arg_idx], "keep=", strlen("keep=")) == - 0) { - /* - * "keep" token string handler - */ - scan_req.keep_previous_scan = - atoi(argv[arg_idx] + strlen("keep=")); - } else if (strncmp(argv[arg_idx], "dur=", strlen("dur=")) == 0) { - /* - * "dur" token string handler - */ - scan_time = atoi(argv[arg_idx] + strlen("dur=")); - scan_req.chan_list[0].scan_time = scan_time; - - } else if (strncmp(argv[arg_idx], "wc=", strlen("wc=")) == 0) { - - if (num_ssid < MRVDRV_MAX_SSID_LIST_LENGTH) { - /* - * "wc" token string handler - */ - pscratch = strrchr(argv[arg_idx], ','); - - if (pscratch) { - *pscratch = 0; - pscratch++; - - if (isdigit(*pscratch)) { - scan_req.ssid_list[num_ssid]. - max_len = - atoi(pscratch); - } else { - scan_req.ssid_list[num_ssid]. - max_len = *pscratch; - } - } else { - /* Standard wildcard matching */ - scan_req.ssid_list[num_ssid].max_len = - 0xFF; - } - - strncpy(scan_req.ssid_list[num_ssid].ssid, - argv[arg_idx] + strlen("wc="), - sizeof(scan_req.ssid_list[num_ssid]. - ssid)); - - num_ssid++; - } - } else if (strncmp(argv[arg_idx], "probes=", strlen("probes=")) - == 0) { - /* - * "probes" token string handler - */ - scan_req.num_probes = - atoi(argv[arg_idx] + strlen("probes=")); - if (scan_req.num_probes > MAX_PROBES) { - fprintf(stderr, "Invalid probes (> %d)\n", - MAX_PROBES); - return -EOPNOTSUPP; - } - } else if (strncmp(argv[arg_idx], "type=", strlen("type=")) == - 0) { - /* - * "type" token string handler - */ - scan_req.bss_mode = - atoi(argv[arg_idx] + strlen("type=")); - switch (scan_req.bss_mode) { - case MLAN_SCAN_MODE_BSS: - case MLAN_SCAN_MODE_IBSS: - break; - case MLAN_SCAN_MODE_ANY: - default: - /* Set any unknown types to ANY */ - scan_req.bss_mode = MLAN_SCAN_MODE_ANY; - break; - } - } - } - - /* - * Update all the channels to have the same scan time - */ - for (tmp_idx = 1; tmp_idx < chan_cmd_idx; tmp_idx++) { - scan_req.chan_list[tmp_idx].scan_time = scan_time; - } - - strncpy(iwr.ifr_name, dev_name, IFNAMSIZ - 1); - iwr.u.data.pointer = (caddr_t) & scan_req; - iwr.u.data.length = sizeof(scan_req); - iwr.u.data.flags = subioctl_val; - - if (ioctl(sockfd, ioctl_val, &iwr) < 0) { - perror("mlanconfig: setuserscan ioctl"); - return -EFAULT; - } - - process_getscantable(0, 0); - - return MLAN_STATUS_SUCCESS; -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanconfig/mlanmisc.h b/mxm_wifiex/wlan_src/mapp/mlanconfig/mlanmisc.h deleted file mode 100644 index 2c92a18..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanconfig/mlanmisc.h +++ /dev/null @@ -1,705 +0,0 @@ -/** @file mlanmisc.h - * - * @brief This file contains command definitions for application - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 03/10/2009: initial version -************************************************************************/ - -#ifndef _MLANMISC_H_ -#define _MLANMISC_H_ - -/** Maximum size of IEEE Information Elements */ -#define IEEE_MAX_IE_SIZE 256 - -/** Maximum scan response buffer size */ -#define SCAN_RESP_BUF_SIZE 2000 - -#ifdef FALSE -#undef FALSE -#endif - -#ifdef TRUE -#undef TRUE -#endif - -#ifndef MIN -/** Find minimum value */ -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif /* MIN */ - -#ifndef MAX -/** Find maximum value */ -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#endif /* MAX */ - -/** Type enumeration of WMM AC_QUEUES */ -typedef enum _mlan_wmm_ac_e { - WMM_AC_BK, - WMM_AC_BE, - WMM_AC_VI, - WMM_AC_VO -} __ATTRIB_PACK__ mlan_wmm_ac_e; - -/** Maximum length of SSID */ -#define MRVDRV_MAX_SSID_LENGTH 32 - -/** Enumeration for scan mode */ -enum { - MLAN_SCAN_MODE_UNCHANGED = 0, - MLAN_SCAN_MODE_BSS, - MLAN_SCAN_MODE_IBSS, - MLAN_SCAN_MODE_ANY -}; - -/** Enumeration for scan type */ -enum { - MLAN_SCAN_TYPE_UNCHANGED = 0, - MLAN_SCAN_TYPE_ACTIVE, - MLAN_SCAN_TYPE_PASSIVE -}; - -/** Length of ethernet address */ -#ifndef ETH_ALEN -#define ETH_ALEN 6 -#endif -/** Maximum length of SSID list */ -#define MRVDRV_MAX_SSID_LIST_LENGTH 10 - -/** Maximum number of channels that can be sent in a setuserscan ioctl */ -#define WLAN_IOCTL_USER_SCAN_CHAN_MAX 50 - -/** IEEE Type definitions */ -typedef enum _IEEEtypes_ElementId_e { - SSID = 0, - SUPPORTED_RATES = 1, - FH_PARAM_SET = 2, - DS_PARAM_SET = 3, - CF_PARAM_SET = 4, - - IBSS_PARAM_SET = 6, - - COUNTRY_INFO = 7, - - POWER_CONSTRAINT = 32, - POWER_CAPABILITY = 33, - TPC_REQUEST = 34, - TPC_REPORT = 35, - SUPPORTED_CHANNELS = 36, - CHANNEL_SWITCH_ANN = 37, - QUIET = 40, - IBSS_DFS = 41, - HT_CAPABILITY = 45, - HT_OPERATION = 61, - BSSCO_2040 = 72, - OVERLAPBSSSCANPARAM = 74, - EXT_CAPABILITY = 127, - - VHT_CAPABILITY = 191, - VHT_OPERATION = 192, - EXT_BSS_LOAD = 193, - BW_CHANNEL_SWITCH = 194, - VHT_TX_POWER_ENV = 195, - EXT_POWER_CONSTR = 196, - AID_INFO = 197, - QUIET_CHAN = 198, - - ERP_INFO = 42, - EXTENDED_SUPPORTED_RATES = 50, - - VENDOR_SPECIFIC_221 = 221, - WMM_IE = VENDOR_SPECIFIC_221, - - WPS_IE = VENDOR_SPECIFIC_221, - - WPA_IE = VENDOR_SPECIFIC_221, - RSN_IE = 48, -} __ATTRIB_PACK__ IEEEtypes_ElementId_e; - -/** Capability Bit Map*/ -#ifdef BIG_ENDIAN_SUPPORT -typedef struct _IEEEtypes_CapInfo_t { - t_u8 rsrvd1:2; - t_u8 dsss_ofdm:1; - t_u8 rsvrd2:2; - t_u8 short_slot_time:1; - t_u8 rsrvd3:1; - t_u8 spectrum_mgmt:1; - t_u8 chan_agility:1; - t_u8 pbcc:1; - t_u8 short_preamble:1; - t_u8 privacy:1; - t_u8 cf_poll_rqst:1; - t_u8 cf_pollable:1; - t_u8 ibss:1; - t_u8 ess:1; -} __ATTRIB_PACK__ IEEEtypes_CapInfo_t, *pIEEEtypes_CapInfo_t; -#else -typedef struct _IEEEtypes_CapInfo_t { - /** Capability Bit Map : ESS */ - t_u8 ess:1; - /** Capability Bit Map : IBSS */ - t_u8 ibss:1; - /** Capability Bit Map : CF pollable */ - t_u8 cf_pollable:1; - /** Capability Bit Map : CF poll request */ - t_u8 cf_poll_rqst:1; - /** Capability Bit Map : privacy */ - t_u8 privacy:1; - /** Capability Bit Map : Short preamble */ - t_u8 short_preamble:1; - /** Capability Bit Map : PBCC */ - t_u8 pbcc:1; - /** Capability Bit Map : Channel agility */ - t_u8 chan_agility:1; - /** Capability Bit Map : Spectrum management */ - t_u8 spectrum_mgmt:1; - /** Capability Bit Map : Reserved */ - t_u8 rsrvd3:1; - /** Capability Bit Map : Short slot time */ - t_u8 short_slot_time:1; - /** Capability Bit Map : APSD */ - t_u8 apsd:1; - /** Capability Bit Map : Reserved */ - t_u8 rsvrd2:1; - /** Capability Bit Map : DSS OFDM */ - t_u8 dsss_ofdm:1; - /** Capability Bit Map : Reserved */ - t_u8 rsrvd1:2; -} __ATTRIB_PACK__ IEEEtypes_CapInfo_t, *pIEEEtypes_CapInfo_t; -#endif /* BIG_ENDIAN_SUPPORT */ - -/** IEEE IE header */ -typedef struct _IEEEtypes_Header_t { - /** Element ID */ - t_u8 element_id; - /** Length */ - t_u8 len; -} __ATTRIB_PACK__ IEEEtypes_Header_t, *pIEEEtypes_Header_t; - -/** IEEE IE header */ -#define IEEE_HEADER_LEN sizeof(IEEEtypes_Header_t) - -/** Vendor specific IE header */ -typedef struct _IEEEtypes_VendorHeader_t { - /** Element ID */ - t_u8 element_id; - /** Length */ - t_u8 len; - /** OUI */ - t_u8 oui[3]; - /** OUI type */ - t_u8 oui_type; - /** OUI subtype */ - t_u8 oui_subtype; - /** Version */ - t_u8 version; -} __ATTRIB_PACK__ IEEEtypes_VendorHeader_t, *pIEEEtypes_VendorHeader_t; - -/** Vendor specific IE */ -typedef struct _IEEEtypes_VendorSpecific_t { - /** Vendor specific IE header */ - IEEEtypes_VendorHeader_t vend_hdr; - /** IE Max - size of previous fields */ - t_u8 data[IEEE_MAX_IE_SIZE - sizeof(IEEEtypes_VendorHeader_t)]; -} __ATTRIB_PACK__ IEEEtypes_VendorSpecific_t, *pIEEEtypes_VendorSpecific_t; - -/** IEEE IE */ -typedef struct _IEEEtypes_Generic_t { - /** Generic IE header */ - IEEEtypes_Header_t ieee_hdr; - /** IE Max - size of previous fields */ - t_u8 data[IEEE_MAX_IE_SIZE - sizeof(IEEEtypes_Header_t)]; -} __ATTRIB_PACK__ IEEEtypes_Generic_t, *pIEEEtypes_Generic_t; - -/** Size of a TSPEC. Used to allocate necessary buffer space in commands */ -#define WMM_TSPEC_SIZE 63 - -/** Maximum number of AC QOS queues available in the driver/firmware */ -#define MAX_AC_QUEUES 4 - -/** Maximum number of User Priorities */ -#define MAX_USER_PRIORITIES 8 - -/** Extra IE bytes allocated in messages for appended IEs after a TSPEC */ -#define WMM_ADDTS_EXTRA_IE_BYTES 256 - -/** - * @brief Enumeration for the command result from an ADDTS or DELTS command - */ -typedef enum { - TSPEC_RESULT_SUCCESS = 0, - TSPEC_RESULT_EXEC_FAILURE = 1, - TSPEC_RESULT_TIMEOUT = 2, - TSPEC_RESULT_DATA_INVALID = 3, -} __ATTRIB_PACK__ mlan_wmm_tspec_result_e; - -/** - * @brief Enumeration for the action field in the Queue configure command - */ -typedef enum { - WMM_QUEUE_CONFIG_ACTION_GET = 0, - WMM_QUEUE_CONFIG_ACTION_SET = 1, - WMM_QUEUE_CONFIG_ACTION_DEFAULT = 2, - - WMM_QUEUE_CONFIG_ACTION_MAX -} __ATTRIB_PACK__ mlan_wmm_queue_config_action_e; - -/** - * @brief Enumeration for the action field in the queue stats command - */ -typedef enum { - WMM_STATS_ACTION_START = 0, - WMM_STATS_ACTION_STOP = 1, - WMM_STATS_ACTION_GET_CLR = 2, - WMM_STATS_ACTION_SET_CFG = 3, /* Not currently used */ - WMM_STATS_ACTION_GET_CFG = 4, /* Not currently used */ - - WMM_STATS_ACTION_MAX -} __ATTRIB_PACK__ mlan_wmm_stats_action_e; - -/** Data structure of WMM QoS information */ -typedef struct _IEEEtypes_WmmQosInfo_t { -#ifdef BIG_ENDIAN_SUPPORT - /** QoS UAPSD */ - t_u8 qos_uapsd:1; - /** Reserved */ - t_u8 reserved:3; - /** Parameter set count */ - t_u8 para_set_count:4; -#else - /** Parameter set count */ - t_u8 para_set_count:4; - /** Reserved */ - t_u8 reserved:3; - /** QoS UAPSD */ - t_u8 qos_uapsd:1; -#endif -} __ATTRIB_PACK__ IEEEtypes_WmmQosInfo_t, *pIEEEtypes_WmmQosInfo_t; - -/** Data structure of WMM Aci/Aifsn */ -typedef struct _IEEEtypes_WmmAciAifsn_t { -#ifdef BIG_ENDIAN_SUPPORT - /** Reserved */ - t_u8 reserved:1; - /** Aci */ - t_u8 aci:2; - /** Acm */ - t_u8 acm:1; - /** Aifsn */ - t_u8 aifsn:4; -#else - /** Aifsn */ - t_u8 aifsn:4; - /** Acm */ - t_u8 acm:1; - /** Aci */ - t_u8 aci:2; - /** Reserved */ - t_u8 reserved:1; -#endif -} __ATTRIB_PACK__ IEEEtypes_WmmAciAifsn_t, *pIEEEtypes_WmmAciAifsn_t; - -/** Data structure of WMM ECW */ -typedef struct _IEEEtypes_WmmEcw_t { -#ifdef BIG_ENDIAN_SUPPORT - /** Maximum Ecw */ - t_u8 ecw_max:4; - /** Minimum Ecw */ - t_u8 ecw_min:4; -#else - /** Minimum Ecw */ - t_u8 ecw_min:4; - /** Maximum Ecw */ - t_u8 ecw_max:4; -#endif -} __ATTRIB_PACK__ IEEEtypes_WmmEcw_t, *pIEEEtypes_WmmEcw_t; - -/** Data structure of WMM AC parameters */ -typedef struct _IEEEtypes_WmmAcParameters_t { - IEEEtypes_WmmAciAifsn_t aci_aifsn; /**< AciAifSn */ - IEEEtypes_WmmEcw_t ecw; /**< Ecw */ - t_u16 tx_op_limit; /**< Tx op limit */ -} __ATTRIB_PACK__ IEEEtypes_WmmAcParameters_t, *pIEEEtypes_WmmAcParameters_t; - -/** Data structure of WMM Info IE */ -typedef struct _IEEEtypes_WmmInfo_t { - - /** - * WMM Info IE - Vendor Specific Header: - * element_id [221/0xdd] - * Len [7] - * Oui [00:50:f2] - * OuiType [2] - * OuiSubType [0] - * Version [1] - */ - IEEEtypes_VendorHeader_t vend_hdr; - - /** QoS information */ - IEEEtypes_WmmQosInfo_t qos_info; - -} __ATTRIB_PACK__ IEEEtypes_WmmInfo_t, *pIEEEtypes_WmmInfo_t; - -/** Data structure of WMM parameter IE */ -typedef struct _IEEEtypes_WmmParameter_t { - /** - * WMM Parameter IE - Vendor Specific Header: - * element_id [221/0xdd] - * Len [24] - * Oui [00:50:f2] - * OuiType [2] - * OuiSubType [1] - * Version [1] - */ - IEEEtypes_VendorHeader_t vend_hdr; - - /** QoS information */ - IEEEtypes_WmmQosInfo_t qos_info; - /** Reserved */ - t_u8 reserved; - - /** AC Parameters Record WMM_AC_BE, WMM_AC_BK, WMM_AC_VI, WMM_AC_VO */ - IEEEtypes_WmmAcParameters_t ac_params[MAX_AC_QUEUES]; - -} __ATTRIB_PACK__ IEEEtypes_WmmParameter_t, *pIEEEtypes_WmmParameter_t; - -/** - * @brief IOCTL structure to send an ADDTS request and retrieve the response. - * - * IOCTL structure from the application layer relayed to firmware to - * instigate an ADDTS management frame with an appropriate TSPEC IE as well - * as any additional IEs appended in the ADDTS Action frame. - * - * @sa wlan_wmm_addts_req_ioctl - */ -typedef struct { - mlan_wmm_tspec_result_e commandResult; - /**< Firmware execution result */ - - t_u32 timeout_ms; /**< Timeout value in milliseconds */ - t_u8 ieeeStatusCode; /**< IEEE status code */ - - t_u32 ieDataLen; - t_u8 ieData[WMM_TSPEC_SIZE - /**< TSPEC to send in the ADDTS */ - + WMM_ADDTS_EXTRA_IE_BYTES]; - /**< ADDTS extra IE buf */ -} wlan_ioctl_wmm_addts_req_t; - -/** - * @brief IOCTL structure to send a DELTS request. - * - * IOCTL structure from the application layer relayed to firmware to - * instigate an DELTS management frame with an appropriate TSPEC IE. - * - * @sa wlan_wmm_delts_req_ioctl - */ -typedef struct { - mlan_wmm_tspec_result_e commandResult; - /**< Firmware execution result */ - t_u8 ieeeReasonCode; /**< IEEE reason code sent, unused for WMM */ - - t_u32 ieDataLen; - t_u8 ieData[WMM_TSPEC_SIZE]; - /**< TSPEC to send in the DELTS */ -} wlan_ioctl_wmm_delts_req_t; - -/** - * @brief IOCTL structure to configure a specific AC Queue's parameters - * - * IOCTL structure from the application layer relayed to firmware to - * get, set, or default the WMM AC queue parameters. - * - * - msduLifetimeExpiry is ignored if set to 0 on a set command - * - * @sa wlan_wmm_queue_config_ioctl - */ -typedef struct { - mlan_wmm_queue_config_action_e action; - /**< Set, Get, or Default */ - mlan_wmm_ac_e accessCategory; /**< WMM_AC_BK(0) to WMM_AC_VO(3) */ - t_u16 msduLifetimeExpiry; /**< lifetime expiry in TUs */ - t_u8 supportedRates[10]; /**< Not supported yet */ -} wlan_ioctl_wmm_queue_config_t; - -/** Number of bins in the histogram for the HostCmd_DS_WMM_QUEUE_STATS */ -#define WMM_STATS_PKTS_HIST_BINS 7 - -/** - * @brief IOCTL structure to start, stop, and get statistics for a WMM AC - * - * IOCTL structure from the application layer relayed to firmware to - * start or stop statistical collection for a given AC. Also used to - * retrieve and clear the collected stats on a given AC. - * - * @sa wlan_wmm_queue_stats_ioctl - */ -typedef struct { - mlan_wmm_stats_action_e action; - /**< Start, Stop, or Get */ - t_u8 userPriority; - /**< User Priority (0 to 7) */ - t_u16 pktCount; /**< Number of successful packets transmitted */ - t_u16 pktLoss; /**< Packets lost; not included in pktCount */ - t_u32 avgQueueDelay; - /**< Average Queue delay in microseconds */ - t_u32 avgTxDelay;/**< Average Transmission delay in microseconds */ - t_u16 usedTime; /**< Calculated used time - units of 32 microsec */ - t_u16 policedTime; - /**< Calculated policed time - units of 32 microsec */ - - /** @brief Queue Delay Histogram; number of packets per queue delay range - * - * [0] - 0ms <= delay < 5ms - * [1] - 5ms <= delay < 10ms - * [2] - 10ms <= delay < 20ms - * [3] - 20ms <= delay < 30ms - * [4] - 30ms <= delay < 40ms - * [5] - 40ms <= delay < 50ms - * [6] - 50ms <= delay < msduLifetime (TUs) - */ - t_u16 delayHistogram[WMM_STATS_PKTS_HIST_BINS]; -} wlan_ioctl_wmm_queue_stats_t; - -/** - * @brief IOCTL and command sub structure for a Traffic stream status. - */ -typedef struct { - t_u8 tid; /**< TSID: Range: 0->7 */ - t_u8 valid; /**< TSID specified is valid */ - t_u8 accessCategory;/**< AC TSID is active on */ - t_u8 userPriority; /**< UP specified for the TSID */ - - t_u8 psb; /**< Power save mode for TSID: 0 (legacy), 1 (UAPSD) */ - t_u8 flowDir; /**< Upstream (0), Downlink(1), Bidirectional(3) */ - t_u16 mediumTime; /**< Medium time granted for the TSID */ -} __ATTRIB_PACK__ HostCmd_DS_WMM_TS_STATUS, - wlan_ioctl_wmm_ts_status_t, wlan_cmd_wmm_ts_status_t; - -/** - * @brief IOCTL sub structure for a specific WMM AC Status - */ -typedef struct { - /** WMM Acm */ - t_u8 wmmAcm; - /** Flow required flag */ - t_u8 flowRequired; - /** Flow created flag */ - t_u8 flowCreated; - /** Disabled flag */ - t_u8 disabled; - /** delivery enabled */ - t_u8 deliveryEnabled; - /** trigger enabled */ - t_u8 triggerEnabled; -} wlan_ioctl_wmm_queue_status_ac_t; - -/** - * @brief IOCTL structure to retrieve the WMM AC Queue status - * - * IOCTL structure from the application layer to retrieve: - * - ACM bit setting for the AC - * - Firmware status (flow required, flow created, flow disabled) - * - * @sa wlan_wmm_queue_status_ioctl - */ -typedef struct { - /** WMM AC queue status */ - wlan_ioctl_wmm_queue_status_ac_t acStatus[MAX_AC_QUEUES]; -} wlan_ioctl_wmm_queue_status_t; - -typedef struct _wlan_get_scan_table_fixed { - /** BSSID of this network */ - t_u8 bssid[MLAN_MAC_ADDR_LENGTH]; - /** Channel this beacon/probe response was detected */ - t_u8 channel; - /** RSSI for the received packet */ - t_u8 rssi; - /** TSF value from the firmware at packet reception */ - t_u64 network_tsf; -} wlan_get_scan_table_fixed; - -/** - * Structure passed in the wlan_ioctl_get_scan_table_info for each - * BSS returned in the WLAN_GET_SCAN_RESP IOCTL - */ -typedef struct _wlan_ioctl_get_scan_table_entry { - /** - * Fixed field length included in the response. - * - * Length value is included so future fixed fields can be added to the - * response without breaking backwards compatibility. Use the length - * to find the offset for the bssInfoLength field, not a sizeof() calc. - */ - t_u32 fixed_field_length; - - /** - * Length of the BSS Information (probe resp or beacon) that - * follows after the fixed_field_length - */ - t_u32 bss_info_length; - - /** - * Always present, fixed length data fields for the BSS - */ - wlan_get_scan_table_fixed fixed_fields; - - /* - * Probe response or beacon scanned for the BSS. - * - * Field layout: - * - TSF 8 octets - * - Beacon Interval 2 octets - * - Capability Info 2 octets - * - * - IEEE Infomation Elements; variable number & length per 802.11 spec - */ - /* t_u8 bss_info_buffer[1]; */ -} wlan_ioctl_get_scan_table_entry; - -/** - * Structure to store BSS info (probe resp or beacon) & IEEE IE info for each - * BSS returned in WLAN_GET_SCAN_RESP IOCTL - */ -typedef struct _wlan_ioctl_get_bss_info { - /** - * Length of the BSS Information (probe resp or beacon) that - * follows after the fixed_field - */ - t_u32 bss_info_length; - - /** - * Probe response or beacon scanned for the BSS. - * - * Field layout: - */ - /** TSF 8 octets */ - t_u8 tsf[8]; - /** Beacon Interval 2 octets */ - t_u16 beacon_interval; - /** Capability Info 2 octets */ - IEEEtypes_CapInfo_t cap_info; - - /** - * IEEE Infomation Elements; variable number & length per 802.11 spec - */ - /** SSID */ - char ssid[MRVDRV_MAX_SSID_LENGTH + 1]; - /** SSID Length */ - t_u32 ssid_len; - /** WMM Capability */ - char wmm_cap; - /** WPS Capability */ - char wps_cap; - /** Privacy Capability - WEP/WPA/RSN */ - char priv_cap; - /** HT (11N) Capability */ - char ht_cap; - /** VHT (11AC) Capability */ - char vht_cap[2]; - /* 802.11k Capability */ - char dot11k_cap; - /** 802.11r Capability */ - char dot11r_cap; -} wlan_ioctl_get_bss_info; - -/** - * Structure to save of scan table info for each BSS returned - * in WLAN_GET_SCAN_RESP IOCTL - */ -struct wlan_ioctl_get_scan_list { - /** fixed info */ - wlan_ioctl_get_scan_table_entry fixed_buf; - /** variable info - BSS info (probe resp or beacon) & IEEE IE info */ - wlan_ioctl_get_bss_info bss_info_buf; - /** pointer to next node in list */ - struct wlan_ioctl_get_scan_list *next; -}; - -/** - * Sructure to retrieve the scan table - */ -typedef struct { - /** - * - Zero based scan entry to start retrieval in command request - * - Number of scans entries returned in command response - */ - t_u32 scan_number; - /** - * Buffer marker for multiple wlan_ioctl_get_scan_table_entry structures. - * Each struct is padded to the nearest 32 bit boundary. - */ - t_u8 scan_table_entry_buf[1]; - -} wlan_ioctl_get_scan_table_info; - -typedef struct { - t_u8 chan_number; - /**< Channel Number to scan */ - t_u8 radio_type; - /**< Radio type: 'B/G' Band = 0, 'A' Band = 1 */ - t_u8 scan_type;/**< Scan type: Active = 1, Passive = 2 */ - t_u8 reserved;/**< Reserved */ - t_u32 scan_time; - /**< Scan duration in milliseconds; if 0 default used */ -} __ATTRIB_PACK__ wlan_ioctl_user_scan_chan; - -typedef struct { - char ssid[MRVDRV_MAX_SSID_LENGTH + 1]; - /**< SSID */ - t_u8 max_len; /**< Maximum length of SSID */ -} __ATTRIB_PACK__ wlan_ioctl_user_scan_ssid; - -typedef struct { - - /** Flag set to keep the previous scan table intact */ - t_u8 keep_previous_scan; /* Do not erase the existing scan results */ - - /** BSS mode to be sent in the firmware command */ - t_u8 bss_mode; - - /** Configure the number of probe requests for active chan scans */ - t_u8 num_probes; - - /** Reserved */ - t_u8 reserved; - - /** BSSID filter sent in the firmware command to limit the results */ - t_u8 specific_bssid[ETH_ALEN]; - - /** SSID filter list used in the to limit the scan results */ - wlan_ioctl_user_scan_ssid ssid_list[MRVDRV_MAX_SSID_LIST_LENGTH]; - - /** Variable number (fixed maximum) of channels to scan up */ - wlan_ioctl_user_scan_chan chan_list[WLAN_IOCTL_USER_SCAN_CHAN_MAX]; - -} __ATTRIB_PACK__ wlan_ioctl_user_scan_cfg; - -#ifdef SDIO -int process_sdcmd52rw(int argc, char *argv[]); -int process_sdcmd53rw(int argc, char *argv[]); -#endif -int process_setuserscan(int argc, char *argv[]); -int process_getscantable(int argc, char *argv[]); -int process_getscantable_idx(wlan_ioctl_get_scan_table_info *prsp_info_req); - -#endif /* _MLANMISC_H_ */ diff --git a/mxm_wifiex/wlan_src/mapp/mlanutl/Makefile b/mxm_wifiex/wlan_src/mapp/mlanutl/Makefile index e2f9b24..1d5beaa 100644 --- a/mxm_wifiex/wlan_src/mapp/mlanutl/Makefile +++ b/mxm_wifiex/wlan_src/mapp/mlanutl/Makefile @@ -31,7 +31,6 @@ HEADERS = mlanutl.h - exectarget=mlanutl TARGET := $(exectarget) diff --git a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanhostcmd.c b/mxm_wifiex/wlan_src/mapp/mlanutl/mlanhostcmd.c deleted file mode 100644 index 0b4d707..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanhostcmd.c +++ /dev/null @@ -1,895 +0,0 @@ -/** @file mlanhostcmd.c - * - * @brief This file contains mlanutl helper functions - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 11/26/2008: initial version -************************************************************************/ - -#include "mlanhostcmd.h" - -#ifndef MIN -/** Find minimum value */ -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif /* MIN */ - -/******************************************************** - Local Variables -********************************************************/ - -/******************************************************** - Global Variables -********************************************************/ - -/******************************************************** - Local Functions -********************************************************/ -/** - * @brief get hostcmd data - * - * @param ln A pointer to line number - * @param buf A pointer to hostcmd data - * @param size A pointer to the return size of hostcmd buffer - * @return MLAN_STATUS_SUCCESS - */ -static int -mlan_get_hostcmd_data(FILE * fp, int *ln, t_u8 *buf, t_u16 *size) -{ - t_s32 errors = 0, i; - t_s8 line[512], *pos, *pos1, *pos2, *pos3; - t_u16 len; - - while ((pos = mlan_config_get_line(fp, line, sizeof(line), ln))) { - (*ln)++; - if (strcmp(pos, "}") == 0) { - break; - } - - pos1 = strchr(pos, ':'); - if (pos1 == NULL) { - printf("Line %d: Invalid hostcmd line '%s'\n", *ln, - pos); - errors++; - continue; - } - *pos1++ = '\0'; - - pos2 = strchr(pos1, '='); - if (pos2 == NULL) { - printf("Line %d: Invalid hostcmd line '%s'\n", *ln, - pos); - errors++; - continue; - } - *pos2++ = '\0'; - - len = a2hex_or_atoi(pos1); - if (len < 1 || len > MRVDRV_SIZE_OF_CMD_BUFFER) { - printf("Line %d: Invalid hostcmd line '%s'\n", *ln, - pos); - errors++; - continue; - } - - *size += len; - - if (*pos2 == '"') { - pos2++; - pos3 = strchr(pos2, '"'); - if (pos3 == NULL) { - printf("Line %d: invalid quotation '%s'\n", *ln, - pos); - errors++; - continue; - } - *pos3 = '\0'; - memset(buf, 0, len); - memmove(buf, pos2, MIN(strlen(pos2), len)); - buf += len; - } else if (*pos2 == '\'') { - pos2++; - pos3 = strchr(pos2, '\''); - if (pos3 == NULL) { - printf("Line %d: invalid quotation '%s'\n", *ln, - pos); - errors++; - continue; - } - *pos3 = ','; - for (i = 0; i < len; i++) { - pos3 = strchr(pos2, ','); - if (pos3 != NULL) { - *pos3 = '\0'; - *buf++ = (t_u8)a2hex_or_atoi(pos2); - pos2 = pos3 + 1; - } else - *buf++ = 0; - } - } else if (*pos2 == '{') { - t_u16 tlvlen = 0, tmp_tlvlen; - mlan_get_hostcmd_data(fp, ln, buf + len, &tlvlen); - tmp_tlvlen = tlvlen; - while (len--) { - *buf++ = (t_u8)(tmp_tlvlen & 0xff); - tmp_tlvlen >>= 8; - } - *size += tlvlen; - buf += tlvlen; - } else { - t_u32 value = a2hex_or_atoi(pos2); - while (len--) { - *buf++ = (t_u8)(value & 0xff); - value >>= 8; - } - } - } - return MLAN_STATUS_SUCCESS; -} - -/******************************************************** - Global Functions -********************************************************/ -/** - * @brief convert char to hex integer - * - * @param chr char to convert - * @return hex integer or 0 - */ -int -hexval(t_s32 chr) -{ - if (chr >= '0' && chr <= '9') - return chr - '0'; - if (chr >= 'A' && chr <= 'F') - return chr - 'A' + 10; - if (chr >= 'a' && chr <= 'f') - return chr - 'a' + 10; - - return 0; -} - -/** - * @brief Hump hex data - * - * @param prompt A pointer prompt buffer - * @param p A pointer to data buffer - * @param len the len of data buffer - * @param delim delim char - * @return hex integer - */ -t_void -hexdump(t_s8 *prompt, t_void *p, t_s32 len, t_s8 delim) -{ - t_s32 i; - t_u8 *s = p; - - if (prompt) { - printf("%s: len=%d\n", prompt, (int)len); - } - for (i = 0; i < len; i++) { - if (i != len - 1) - printf("%02x%c", *s++, delim); - else - printf("%02x\n", *s); - if ((i + 1) % 16 == 0) - printf("\n"); - } - printf("\n"); -} - -/** - * @brief convert char to hex integer - * - * @param chr char - * @return hex integer - */ -t_u8 -hexc2bin(t_s8 chr) -{ - if (chr >= '0' && chr <= '9') - chr -= '0'; - else if (chr >= 'A' && chr <= 'F') - chr -= ('A' - 10); - else if (chr >= 'a' && chr <= 'f') - chr -= ('a' - 10); - - return chr; -} - -/** - * @brief convert string to hex integer - * - * @param s A pointer string buffer - * @return hex integer - */ -t_u32 -a2hex(t_s8 *s) -{ - t_u32 val = 0; - - if (!strncasecmp("0x", s, 2)) { - s += 2; - } - - while (*s && isxdigit(*s)) { - val = (val << 4) + hexc2bin(*s++); - } - - return val; -} - -/* - * @brief convert String to integer - * - * @param value A pointer to string - * @return integer - */ -t_u32 -a2hex_or_atoi(t_s8 *value) -{ - if (value[0] == '0' && (value[1] == 'X' || value[1] == 'x')) { - return a2hex(value + 2); - } else if (isdigit(*value)) { - return atoi(value); - } else { - return *value; - } -} - -/** - * @brief convert string to hex - * - * @param ptr A pointer to data buffer - * @param chr A pointer to return integer - * @return A pointer to next data field - */ -t_s8 * -convert2hex(t_s8 *ptr, t_u8 *chr) -{ - t_u8 val; - - for (val = 0; *ptr && isxdigit(*ptr); ptr++) { - val = (val * 16) + hexval(*ptr); - } - - *chr = val; - - return ptr; -} - -/** - * @brief Check the Hex String - * @param s A pointer to the string - * @return MLAN_STATUS_SUCCESS --HexString, MLAN_STATUS_FAILURE --not HexString - */ -int -ishexstring(t_s8 *s) -{ - int ret = MLAN_STATUS_FAILURE; - t_s32 tmp; - - if (!strncasecmp("0x", s, 2)) { - s += 2; - } - while (*s) { - tmp = toupper(*s); - if (((tmp >= 'A') && (tmp <= 'F')) || - ((tmp >= '0') && (tmp <= '9'))) { - ret = MLAN_STATUS_SUCCESS; - } else { - ret = MLAN_STATUS_FAILURE; - break; - } - s++; - } - - return ret; -} - -/** - * @brief Convert String to Integer - * @param buf A pointer to the string - * @return Integer - */ -int -atoval(t_s8 *buf) -{ - if (!strncasecmp(buf, "0x", 2)) - return a2hex(buf + 2); - else if (!ishexstring(buf)) - return a2hex(buf); - else - return atoi(buf); -} - -/** - * @brief Prepare host-command buffer - * @param fp File handler - * @param cmd_name Command name - * @param buf A pointer to comand buffer - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -prepare_host_cmd_buffer(FILE * fp, char *cmd_name, t_u8 *buf) -{ - t_s8 line[256], cmdname[256], *pos, cmdcode[10]; - HostCmd_DS_GEN *hostcmd; - int ln = 0; - int cmdname_found = 0, cmdcode_found = 0; - - memset(buf, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - hostcmd = (HostCmd_DS_GEN *)buf; - hostcmd->command = 0xffff; - - snprintf(cmdname, sizeof(cmdname), "%s={", cmd_name); - cmdname_found = 0; - while ((pos = mlan_config_get_line(fp, line, sizeof(line), &ln))) { - if (strcmp(pos, cmdname) == 0) { - t_u16 len = 0; - cmdname_found = 1; - snprintf(cmdcode, sizeof(cmdcode), "CmdCode="); - cmdcode_found = 0; - while ((pos = - mlan_config_get_line(fp, line, sizeof(line), - &ln))) { - if (strncmp(pos, cmdcode, strlen(cmdcode)) == 0) { - cmdcode_found = 1; - hostcmd->command = - a2hex_or_atoi(pos + - strlen(cmdcode)); - hostcmd->size = S_DS_GEN; - mlan_get_hostcmd_data(fp, &ln, - buf + - hostcmd->size, - &len); - hostcmd->size += len; - break; - } - } - if (!cmdcode_found) { - fprintf(stderr, - "mlanutl: CmdCode not found in conf file\n"); - return MLAN_STATUS_FAILURE; - } - break; - } - } - - if (!cmdname_found) { - fprintf(stderr, - "mlanutl: cmdname '%s' is not found in conf file\n", - cmd_name); - return MLAN_STATUS_FAILURE; - } - - hostcmd->seq_num = 0; - hostcmd->result = 0; - hostcmd->command = cpu_to_le16(hostcmd->command); - hostcmd->size = cpu_to_le16(hostcmd->size); - return MLAN_STATUS_SUCCESS; -} - -/** Config data header length */ -#define CFG_DATA_HEADER_LEN 6 - -/** - * @brief Prepare cfg-data buffer - * @param argc number of arguments - * @param argv A pointer to arguments array - * @param fp File handler - * @param buf A pointer to comand buffer - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -prepare_cfg_data_buffer(int argc, char *argv[], FILE * fp, t_u8 *buf) -{ - int ln = 0, type; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_802_11_CFG_DATA *pcfg_data; - - memset(buf, 0, MRVDRV_SIZE_OF_CMD_BUFFER); - hostcmd = (HostCmd_DS_GEN *)buf; - hostcmd->command = cpu_to_le16(HostCmd_CMD_CFG_DATA); - pcfg_data = (HostCmd_DS_802_11_CFG_DATA *)(buf + S_DS_GEN); - pcfg_data->action = - (argc == 4) ? HostCmd_ACT_GEN_GET : HostCmd_ACT_GEN_SET; - type = atoi(argv[3]); - if ((type < 1) || (type > 2)) { - fprintf(stderr, "mlanutl: Invalid register type\n"); - return MLAN_STATUS_FAILURE; - } else { - pcfg_data->type = type; - } - if (argc == 5) { - ln = fparse_for_hex(fp, pcfg_data->data); - } - pcfg_data->data_len = ln; - hostcmd->size = - cpu_to_le16(pcfg_data->data_len + S_DS_GEN + - CFG_DATA_HEADER_LEN); - pcfg_data->data_len = cpu_to_le16(pcfg_data->data_len); - pcfg_data->type = cpu_to_le16(pcfg_data->type); - pcfg_data->action = cpu_to_le16(pcfg_data->action); - - hostcmd->seq_num = 0; - hostcmd->result = 0; - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process host_cmd response - * @param buf A pointer to the response buffer - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_host_cmd_resp(t_u8 *buf) -{ - HostCmd_DS_GEN *hostcmd = (HostCmd_DS_GEN *)buf; - int ret = MLAN_STATUS_SUCCESS; - - hostcmd->command = le16_to_cpu(hostcmd->command); - hostcmd->size = le16_to_cpu(hostcmd->size); - hostcmd->seq_num = le16_to_cpu(hostcmd->seq_num); - hostcmd->result = le16_to_cpu(hostcmd->result); - - hostcmd->command &= ~HostCmd_RET_BIT; - if (!hostcmd->result) { - switch (hostcmd->command) { - case HostCmd_CMD_CFG_DATA: - { - HostCmd_DS_802_11_CFG_DATA *pstcfgData = - (HostCmd_DS_802_11_CFG_DATA *)(buf + - S_DS_GEN); - pstcfgData->data_len = - le16_to_cpu(pstcfgData->data_len); - pstcfgData->action = - le16_to_cpu(pstcfgData->action); - - if (pstcfgData->action == HostCmd_ACT_GEN_GET) { - hexdump("cfgdata", pstcfgData->data, - pstcfgData->data_len, ' '); - } - break; - } - case HostCmd_CMD_802_11_TPC_ADAPT_REQ: - { - mlan_ioctl_11h_tpc_resp *tpcIoctlResp = - (mlan_ioctl_11h_tpc_resp *)(buf + - S_DS_GEN); - if (tpcIoctlResp->status_code == 0) { - printf("tpcrequest: txPower(%d), linkMargin(%d), rssi(%d)\n", tpcIoctlResp->tx_power, tpcIoctlResp->link_margin, tpcIoctlResp->rssi); - } else { - printf("tpcrequest: failure, status = %d\n", tpcIoctlResp->status_code); - } - break; - } - case HostCmd_CMD_802_11_CRYPTO: - { - t_u16 alg = - le16_to_cpu((t_u16) - *(buf + S_DS_GEN + - sizeof(t_u16))); - if (alg != CIPHER_TEST_AES_CCM && - alg != CIPHER_TEST_GCMP) { - HostCmd_DS_802_11_CRYPTO *cmd = - (HostCmd_DS_802_11_CRYPTO *)(buf - + - S_DS_GEN); - cmd->encdec = le16_to_cpu(cmd->encdec); - cmd->algorithm = - le16_to_cpu(cmd->algorithm); - cmd->key_IV_length = - le16_to_cpu(cmd->key_IV_length); - cmd->key_length = - le16_to_cpu(cmd->key_length); - cmd->data.header.type = - le16_to_cpu(cmd->data.header. - type); - cmd->data.header.len = - le16_to_cpu(cmd->data.header. - len); - - printf("crypto_result: encdec=%d algorithm=%d,KeyIVLen=%d," " KeyLen=%d,dataLen=%d\n", cmd->encdec, cmd->algorithm, cmd->key_IV_length, cmd->key_length, cmd->data.header.len); - hexdump("KeyIV", cmd->keyIV, - cmd->key_IV_length, ' '); - hexdump("Key", cmd->key, - cmd->key_length, ' '); - hexdump("Data", cmd->data.data, - cmd->data.header.len, ' '); - } else { - HostCmd_DS_802_11_CRYPTO_AES_CCM - *cmd_aes_ccm = - (HostCmd_DS_802_11_CRYPTO_AES_CCM - *)(buf + S_DS_GEN); - - cmd_aes_ccm->encdec - = - le16_to_cpu(cmd_aes_ccm-> - encdec); - cmd_aes_ccm->algorithm = - le16_to_cpu(cmd_aes_ccm-> - algorithm); - cmd_aes_ccm->key_length = - le16_to_cpu(cmd_aes_ccm-> - key_length); - cmd_aes_ccm->nonce_length = - le16_to_cpu(cmd_aes_ccm-> - nonce_length); - cmd_aes_ccm->AAD_length = - le16_to_cpu(cmd_aes_ccm-> - AAD_length); - cmd_aes_ccm->data.header.type = - le16_to_cpu(cmd_aes_ccm->data. - header.type); - cmd_aes_ccm->data.header.len = - le16_to_cpu(cmd_aes_ccm->data. - header.len); - - printf("crypto_result: encdec=%d algorithm=%d, KeyLen=%d," " NonceLen=%d,AADLen=%d,dataLen=%d\n", cmd_aes_ccm->encdec, cmd_aes_ccm->algorithm, cmd_aes_ccm->key_length, cmd_aes_ccm->nonce_length, cmd_aes_ccm->AAD_length, cmd_aes_ccm->data.header.len); - - hexdump("Key", cmd_aes_ccm->key, - cmd_aes_ccm->key_length, ' '); - hexdump("Nonce", cmd_aes_ccm->nonce, - cmd_aes_ccm->nonce_length, ' '); - hexdump("AAD", cmd_aes_ccm->AAD, - cmd_aes_ccm->AAD_length, ' '); - hexdump("Data", cmd_aes_ccm->data.data, - cmd_aes_ccm->data.header.len, - ' '); - } - break; - } - case HostCmd_CMD_802_11_AUTO_TX: - { - HostCmd_DS_802_11_AUTO_TX *at = - (HostCmd_DS_802_11_AUTO_TX *)(buf + - S_DS_GEN); - - if (le16_to_cpu(at->action) == - HostCmd_ACT_GEN_GET) { - if (S_DS_GEN + sizeof(at->action) == - hostcmd->size) { - printf("auto_tx not configured\n"); - - } else { - MrvlIEtypesHeader_t *header = - &at->auto_tx.header; - - header->type = - le16_to_cpu(header-> - type); - header->len = - le16_to_cpu(header-> - len); - - if ((S_DS_GEN + - sizeof(at->action) - + - sizeof(MrvlIEtypesHeader_t) - + header->len == - hostcmd->size) && - (header->type == - TLV_TYPE_AUTO_TX)) { - - AutoTx_MacFrame_t *atmf - = - &at->auto_tx. - auto_tx_mac_frame; - - printf("Interval: %d second(s)\n", le16_to_cpu(atmf->interval)); - printf("Priority: %#x\n", atmf->priority); - printf("Frame Length: %d\n", le16_to_cpu(atmf->frame_len)); - printf("Dest Mac Address: " "%02x:%02x:%02x:%02x:%02x:%02x\n", atmf->dest_mac_addr[0], atmf->dest_mac_addr[1], atmf->dest_mac_addr[2], atmf->dest_mac_addr[3], atmf->dest_mac_addr[4], atmf->dest_mac_addr[5]); - printf("Src Mac Address: " "%02x:%02x:%02x:%02x:%02x:%02x\n", atmf->src_mac_addr[0], atmf->src_mac_addr[1], atmf->src_mac_addr[2], atmf->src_mac_addr[3], atmf->src_mac_addr[4], atmf->src_mac_addr[5]); - - hexdump("Frame Payload", - atmf->payload, - le16_to_cpu - (atmf-> - frame_len) - - - MLAN_MAC_ADDR_LENGTH - * 2, ' '); - } else { - printf("incorrect auto_tx command response\n"); - } - } - } - break; - } - case HostCmd_CMD_802_11_SUBSCRIBE_EVENT: - { - HostCmd_DS_802_11_SUBSCRIBE_EVENT *se = - (HostCmd_DS_802_11_SUBSCRIBE_EVENT - *)(buf + S_DS_GEN); - if (le16_to_cpu(se->action) == - HostCmd_ACT_GEN_GET) { - int len = - S_DS_GEN + - sizeof - (HostCmd_DS_802_11_SUBSCRIBE_EVENT); - printf("\nEvent\t\tValue\tFreq\tsubscribed\n\n"); - while (len < hostcmd->size) { - MrvlIEtypesHeader_t *header = - (MrvlIEtypesHeader_t - *)(buf + len); - switch (le16_to_cpu - (header->type)) { - case TLV_TYPE_RSSI_LOW: - { - MrvlIEtypes_RssiThreshold_t - *low_rssi - = - (MrvlIEtypes_RssiThreshold_t - *)(buf - + - len); - printf("Beacon Low RSSI\t%d\t%d\t%s\n", low_rssi->RSSI_value, low_rssi->RSSI_freq, (le16_to_cpu(se->events) & 0x0001) ? "yes" : "no"); - break; - } - case TLV_TYPE_SNR_LOW: - { - MrvlIEtypes_SnrThreshold_t - *low_snr - = - (MrvlIEtypes_SnrThreshold_t - *)(buf - + - len); - printf("Beacon Low SNR\t%d\t%d\t%s\n", low_snr->SNR_value, low_snr->SNR_freq, (le16_to_cpu(se->events) & 0x0002) ? "yes" : "no"); - break; - } - case TLV_TYPE_FAILCOUNT: - { - MrvlIEtypes_FailureCount_t - *failure_count - = - (MrvlIEtypes_FailureCount_t - *)(buf - + - len); - printf("Failure Count\t%d\t%d\t%s\n", failure_count->fail_value, failure_count->fail_freq, (le16_to_cpu(se->events) & 0x0004) ? "yes" : "no"); - break; - } - case TLV_TYPE_BCNMISS: - { - MrvlIEtypes_BeaconsMissed_t - *bcn_missed - = - (MrvlIEtypes_BeaconsMissed_t - *)(buf - + - len); - printf("Beacon Missed\t%d\tN/A\t%s\n", bcn_missed->beacon_missed, (le16_to_cpu(se->events) & 0x0008) ? "yes" : "no"); - break; - } - case TLV_TYPE_RSSI_HIGH: - { - MrvlIEtypes_RssiThreshold_t - *high_rssi - = - (MrvlIEtypes_RssiThreshold_t - *)(buf - + - len); - printf("Bcn High RSSI\t%d\t%d\t%s\n", high_rssi->RSSI_value, high_rssi->RSSI_freq, (le16_to_cpu(se->events) & 0x0010) ? "yes" : "no"); - break; - } - - case TLV_TYPE_SNR_HIGH: - { - MrvlIEtypes_SnrThreshold_t - *high_snr - = - (MrvlIEtypes_SnrThreshold_t - *)(buf - + - len); - printf("Beacon High SNR\t%d\t%d\t%s\n", high_snr->SNR_value, high_snr->SNR_freq, (le16_to_cpu(se->events) & 0x0020) ? "yes" : "no"); - break; - } - case TLV_TYPE_RSSI_LOW_DATA: - { - MrvlIEtypes_RssiThreshold_t - *low_rssi - = - (MrvlIEtypes_RssiThreshold_t - *)(buf - + - len); - printf("Data Low RSSI\t%d\t%d\t%s\n", low_rssi->RSSI_value, low_rssi->RSSI_freq, (le16_to_cpu(se->events) & 0x0040) ? "yes" : "no"); - break; - } - case TLV_TYPE_SNR_LOW_DATA: - { - MrvlIEtypes_SnrThreshold_t - *low_snr - = - (MrvlIEtypes_SnrThreshold_t - *)(buf - + - len); - printf("Data Low SNR\t%d\t%d\t%s\n", low_snr->SNR_value, low_snr->SNR_freq, (le16_to_cpu(se->events) & 0x0080) ? "yes" : "no"); - break; - } - case TLV_TYPE_RSSI_HIGH_DATA: - { - MrvlIEtypes_RssiThreshold_t - *high_rssi - = - (MrvlIEtypes_RssiThreshold_t - *)(buf - + - len); - printf("Data High RSSI\t%d\t%d\t%s\n", high_rssi->RSSI_value, high_rssi->RSSI_freq, (le16_to_cpu(se->events) & 0x0100) ? "yes" : "no"); - break; - } - case TLV_TYPE_SNR_HIGH_DATA: - { - MrvlIEtypes_SnrThreshold_t - *high_snr - = - (MrvlIEtypes_SnrThreshold_t - *)(buf - + - len); - printf("Data High SNR\t%d\t%d\t%s\n", high_snr->SNR_value, high_snr->SNR_freq, (le16_to_cpu(se->events) & 0x0200) ? "yes" : "no"); - break; - } - case TLV_TYPE_LINK_QUALITY: - { - MrvlIEtypes_LinkQuality_t - *link_qual - = - (MrvlIEtypes_LinkQuality_t - *)(buf - + - len); - printf("Link Quality Parameters:\n"); - printf("------------------------\n"); - printf("Link Quality Event Subscribed\t%s\n", (le16_to_cpu(se->events) & 0x0400) ? "yes" : "no"); - printf("Link SNR Threshold = %d\n", le16_to_cpu(link_qual->link_SNR_thrs)); - printf("Link SNR Frequency = %d\n", le16_to_cpu(link_qual->link_SNR_freq)); - printf("Min Rate Value = %d\n", le16_to_cpu(link_qual->min_rate_val)); - printf("Min Rate Frequency = %d\n", le16_to_cpu(link_qual->min_rate_freq)); - printf("Tx Latency Value = %d\n", le32_to_cpu(link_qual->tx_latency_val)); - printf("Tx Latency Threshold = %d\n", le32_to_cpu(link_qual->tx_latency_thrs)); - - break; - } - case TLV_TYPE_PRE_BEACON_LOST: - { - MrvlIEtypes_PreBeaconLost_t - *pre_bcn_lost - = - (MrvlIEtypes_PreBeaconLost_t - *)(buf - + - len); - printf("------------------------\n"); - printf("Pre-Beacon Lost Event Subscribed\t%s\n", (le16_to_cpu(se->events) & 0x0800) ? "yes" : "no"); - printf("Pre-Beacon Lost: %d\n", pre_bcn_lost->pre_beacon_lost); - break; - } - default: - printf("Unknown subscribed event TLV Type=%#x," " Len=%d\n", le16_to_cpu(header->type), le16_to_cpu(header->len)); - break; - } - - len += (sizeof - (MrvlIEtypesHeader_t) - + - le16_to_cpu(header-> - len)); - } - } - break; - } - case HostCmd_CMD_MAC_REG_ACCESS: - case HostCmd_CMD_BBP_REG_ACCESS: - case HostCmd_CMD_RF_REG_ACCESS: - case HostCmd_CMD_CAU_REG_ACCESS: - { - HostCmd_DS_REG *preg = - (HostCmd_DS_REG *)(buf + S_DS_GEN); - preg->action = le16_to_cpu(preg->action); - if (preg->action == HostCmd_ACT_GEN_GET) { - preg->value = le32_to_cpu(preg->value); - printf("value = 0x%08x\n", preg->value); - } - break; - } - case HostCmd_CMD_MEM_ACCESS: - { - HostCmd_DS_MEM *pmem = - (HostCmd_DS_MEM *)(buf + S_DS_GEN); - pmem->action = le16_to_cpu(pmem->action); - if (pmem->action == HostCmd_ACT_GEN_GET) { - pmem->value = le32_to_cpu(pmem->value); - printf("value = 0x%08x\n", pmem->value); - } - break; - } - default: - printf("HOSTCMD_RESP: CmdCode=%#04x, Size=%#04x," - " SeqNum=%#04x, Result=%#04x\n", - hostcmd->command, hostcmd->size, - hostcmd->seq_num, hostcmd->result); - hexdump("payload", - (t_void *)(buf + S_DS_GEN), - hostcmd->size - S_DS_GEN, ' '); - break; - } - } else { - printf("HOSTCMD failed: CmdCode=%#04x, Size=%#04x," - " SeqNum=%#04x, Result=%#04x\n", - hostcmd->command, hostcmd->size, - hostcmd->seq_num, hostcmd->result); - } - return ret; -} - -/** - * @brief Prepare the hostcmd for register access - * @param type Register type - * @param offset Register offset - * @param value Pointer to value (NULL for read) - * @param buf Pointer to hostcmd buffer - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -prepare_hostcmd_regrdwr(t_u32 type, t_u32 offset, t_u32 *value, t_u8 *buf) -{ - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_REG *preg; - - hostcmd = (HostCmd_DS_GEN *)buf; - switch (type) { - case 1: - hostcmd->command = cpu_to_le16(HostCmd_CMD_MAC_REG_ACCESS); - break; - case 2: - hostcmd->command = cpu_to_le16(HostCmd_CMD_BBP_REG_ACCESS); - break; - case 3: - hostcmd->command = cpu_to_le16(HostCmd_CMD_RF_REG_ACCESS); - break; - case 5: - hostcmd->command = cpu_to_le16(HostCmd_CMD_CAU_REG_ACCESS); - break; - default: - printf("Invalid register set specified\n"); - return -EINVAL; - } - preg = (HostCmd_DS_REG *)(buf + S_DS_GEN); - preg->action = (value) ? HostCmd_ACT_GEN_SET : HostCmd_ACT_GEN_GET; - preg->action = cpu_to_le16(preg->action); - preg->offset = cpu_to_le16((t_u16)offset); - if (value) - preg->value = cpu_to_le32(*value); - else - preg->value = 0; - hostcmd->size = cpu_to_le16(S_DS_GEN + sizeof(HostCmd_DS_REG)); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - return MLAN_STATUS_SUCCESS; -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanhostcmd.h b/mxm_wifiex/wlan_src/mapp/mlanutl/mlanhostcmd.h deleted file mode 100644 index c482733..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanhostcmd.h +++ /dev/null @@ -1,134 +0,0 @@ -/** @file mlanhostcmd.h - * - * @brief This file contains command structures for mlanutl application - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 11/26/2008: initial version -************************************************************************/ -#ifndef _MLANHOSTCMD_H_ -#define _MLANHOSTCMD_H_ - -/** Find number of elements */ -#define NELEMENTS(x) (sizeof(x)/sizeof(x[0])) - -/** Size of command buffer */ -#define MRVDRV_SIZE_OF_CMD_BUFFER (3 * 1024) - -/** Host Command ID : Memory access */ -#define HostCmd_CMD_MEM_ACCESS 0x0086 - -/** Pre-Authenticate - 11r only */ -#define HostCmd_CMD_802_11_AUTHENTICATE 0x0011 - -/** Read/Write Mac register */ -#define HostCmd_CMD_MAC_REG_ACCESS 0x0019 -/** Read/Write BBP register */ -#define HostCmd_CMD_BBP_REG_ACCESS 0x001a -/** Read/Write RF register */ -#define HostCmd_CMD_RF_REG_ACCESS 0x001b -/** Get TX Power data */ -#define HostCmd_CMD_802_11_RF_TX_POWER 0x001e -/** Host Command ID : CAU register access */ -#define HostCmd_CMD_CAU_REG_ACCESS 0x00ed - -/** Host Command ID : 802.11 BG scan configuration */ -#define HostCmd_CMD_802_11_BG_SCAN_CONFIG 0x006b -/** Host Command ID : Configuration data */ -#define HostCmd_CMD_CFG_DATA 0x008f -/** Host Command ID : 802.11 TPC adapt req */ -#define HostCmd_CMD_802_11_TPC_ADAPT_REQ 0x0060 -/** Host Command ID : 802.11 crypto */ -#define HostCmd_CMD_802_11_CRYPTO 0x0078 -/** Host Command ID : 802.11 auto Tx */ -#define HostCmd_CMD_802_11_AUTO_TX 0x0082 - -/** Host Command ID : 802.11 subscribe event */ -#define HostCmd_CMD_802_11_SUBSCRIBE_EVENT 0x0075 - -#ifdef OPCHAN -/** Host Command ID : Operating channel config */ -#define HostCmd_CMD_OPCHAN_CONFIG 0x00f8 -/** Host Command ID : Opchan channel group config */ -#define HostCmd_CMD_OPCHAN_CHANGROUP_CONFIG 0x00f9 -#endif - -/** Host Command ID : Channel TRPC config */ -#define HostCmd_CMD_CHAN_TRPC_CONFIG 0x00fb - -/** TLV type ID definition */ -#define PROPRIETARY_TLV_BASE_ID 0x0100 -/** TLV type : Beacon RSSI low */ -#define TLV_TYPE_RSSI_LOW (PROPRIETARY_TLV_BASE_ID + 0x04) /* 0x0104 */ -/** TLV type : Beacon SNR low */ -#define TLV_TYPE_SNR_LOW (PROPRIETARY_TLV_BASE_ID + 0x05) /* 0x0105 */ -/** TLV type : Fail count */ -#define TLV_TYPE_FAILCOUNT (PROPRIETARY_TLV_BASE_ID + 0x06) /* 0x0106 */ -/** TLV type : BCN miss */ -#define TLV_TYPE_BCNMISS (PROPRIETARY_TLV_BASE_ID + 0x07) /* 0x0107 */ -/** TLV type : Beacon RSSI high */ -#define TLV_TYPE_RSSI_HIGH (PROPRIETARY_TLV_BASE_ID + 0x16) /* 0x0116 */ -/** TLV type : Beacon SNR high */ -#define TLV_TYPE_SNR_HIGH (PROPRIETARY_TLV_BASE_ID + 0x17) /* 0x0117 */ -/** TLV type : Auto Tx */ -#define TLV_TYPE_AUTO_TX (PROPRIETARY_TLV_BASE_ID + 0x18) /* 0x0118 */ -/** TLV type :Link Quality */ -#define TLV_TYPE_LINK_QUALITY (PROPRIETARY_TLV_BASE_ID + 0x24) /* 0x0124 */ -/** TLV type : Data RSSI low */ -#define TLV_TYPE_RSSI_LOW_DATA (PROPRIETARY_TLV_BASE_ID + 0x26) /* 0x0126 */ -/** TLV type : Data SNR low */ -#define TLV_TYPE_SNR_LOW_DATA (PROPRIETARY_TLV_BASE_ID + 0x27) /* 0x0127 */ -/** TLV type : Data RSSI high */ -#define TLV_TYPE_RSSI_HIGH_DATA (PROPRIETARY_TLV_BASE_ID + 0x28) /* 0x0128 */ -/** TLV type : Data SNR high */ -#define TLV_TYPE_SNR_HIGH_DATA (PROPRIETARY_TLV_BASE_ID + 0x29) /* 0x0129 */ -/** TLV type: Pre-Beacon Lost */ -#define TLV_TYPE_PRE_BEACON_LOST (PROPRIETARY_TLV_BASE_ID + 0x49) /* 0x0149 */ - -#ifdef OPCHAN -/** TLV type : Operating channel control description */ -#define TLV_TYPE_OPCHAN_CONTROL_DESC (PROPRIETARY_TLV_BASE_ID + 0x79) /* 0x0179 */ -/** TLV type : Operating channel group control */ -#define TLV_TYPE_OPCHAN_CHANGRP_CTRL (PROPRIETARY_TLV_BASE_ID + 0x7a) /* 0x017a */ -#endif - -/** TLV type : Channel TRPC */ -#define TLV_TYPE_CHAN_TRPC (PROPRIETARY_TLV_BASE_ID + 0x89) /* 0x0189 */ - -/** mlan_ioctl_11h_tpc_resp */ -typedef struct { - int status_code; - /**< Firmware command result status code */ - int tx_power;/**< Reported TX Power from the TPC Report */ - int link_margin; - /**< Reported Link margin from the TPC Report */ - int rssi; /**< RSSI of the received TPC Report frame */ -} __ATTRIB_PACK__ mlan_ioctl_11h_tpc_resp; - -/* Define general hostcmd data structure */ - -/** Convert String to integer */ -t_u32 a2hex_or_atoi(char *value); -char *mlan_config_get_line(FILE * fp, char *str, t_s32 size, int *lineno); - -int prepare_host_cmd_buffer(FILE * fp, char *cmd_name, t_u8 *buf); -int prepare_hostcmd_regrdwr(t_u32 type, t_u32 offset, t_u32 *value, t_u8 *buf); - -#endif /* _MLANHOSTCMD_H_ */ diff --git a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanoffload.c b/mxm_wifiex/wlan_src/mapp/mlanutl/mlanoffload.c deleted file mode 100644 index cb34b4e..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanoffload.c +++ /dev/null @@ -1,3051 +0,0 @@ -/** @file mlanoffload.c - * - * @brief This files contains mlanutl offload command handling. - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 08/11/2009: initial version -************************************************************************/ - -#include "mlanutl.h" -#include "mlanhostcmd.h" -#include "mlanoffload.h" - -/******************************************************** - Local Variables -********************************************************/ - -t_void hexdump(char *prompt, t_void *p, t_s32 len, t_s8 delim); - -/******************************************************** - Global Variables -********************************************************/ - -/******************************************************** - Local Functions -********************************************************/ - -/** - * @brief Remove unwanted spaces, tabs from a line - * - * @param data A pointer to the starting of the line - * @return NA - */ -static void -profile_param_polish(char *data) -{ - t_u8 i, j, len = 0; - char *ptr; - ptr = strrchr(data, '\r'); - if (ptr == NULL) { - ptr = strrchr(data, '\n'); - if (ptr == NULL) { - return; - } - } - len = ptr - data; - for (i = 0; i < len; i++) { - if ((*(data + i) == ' ') || (*(data + i) == '\t')) { - for (j = i; j < len; j++) { - data[j] = data[j + 1]; - } - i--; - len--; - } - } -} - -static int -ascii_value(char letter) -{ - if (letter >= '0' && letter <= '9') - return letter - '0'; - if (letter >= 'a' && letter <= 'f') - return letter - 'a' + 10; - if (letter >= 'A' && letter <= 'F') - return letter - 'A' + 10; - return -1; -} - -static int -twodigit_ascii(const char *nibble) -{ - int a, b; - a = ascii_value(*nibble++); - if (a < 0) - return -1; - b = ascii_value(*nibble++); - if (b < 0) - return -1; - return (a << 4) | b; -} - -/** - * @brief Read a network block from the profile configuration file - * - * @param fp file pointer of the configuration file - * @param p_head profile head - * @return MLAN_STATUS_SUCCESS - */ -static int -profile_read_block(FILE * fp, profile_entry_t *p_head) -{ - char line[0x100]; - char *ptr, *eptr; - t_u8 key_cnt = 0; - t_u8 i, wep_len; - int byte; - int tmpIdx; - unsigned int mac[ETH_ALEN]; - - while (fgets(line, sizeof(line), fp)) { - /* call function to remove spaces, tabs */ - profile_param_polish(line); - - if (strstr(line, "}") != NULL) { - ptr = strstr(line, "}"); - /* end of network */ - break; - - } else if (line[0] == '#') { - /* comments go ahead */ - continue; - - } else if (strstr(line, "bssid=") != NULL) { - ptr = strstr(line, "bssid="); - ptr = ptr + strlen("bssid="); - sscanf(ptr, "%2x:%2x:%2x:%2x:%2x:%2x", - mac + 0, mac + 1, mac + 2, mac + 3, mac + 4, - mac + 5); - for (tmpIdx = 0; (unsigned int)tmpIdx < NELEMENTS(mac); - tmpIdx++) { - p_head->bssid[tmpIdx] = (t_u8)mac[tmpIdx]; - } - - } else if (strstr(line, "ssid=") != NULL) { - - ptr = strstr(line, "ssid="); - ptr = ptr + strlen("ssid="); - eptr = strrchr(ptr + 1, '"'); - - if ((*ptr != '"') || (strrchr(ptr + 1, '"') == NULL)) { - - fprintf(stderr, "ssid not within quotes\n"); - break; - } - - p_head->ssid_len = - MIN(IW_ESSID_MAX_SIZE, eptr - ptr - 1); - strncpy((char *)p_head->ssid, ptr + 1, - p_head->ssid_len); - p_head->ssid[p_head->ssid_len] = '\0'; - - } else if (strstr(line, "psk=") != NULL) { - ptr = strstr(line, "psk="); - ptr = ptr + strlen("psk="); - if (*ptr != '"') { - p_head->psk_config = 1; - strncpy((char *)p_head->psk, ptr, KEY_LEN); - } else { - eptr = strrchr(ptr + 1, '"'); - if (eptr == NULL) { - fprintf(stderr, - "passphrase not within quotes.\n"); - break; - } - p_head->passphrase_len = - MIN(PHRASE_LEN, eptr - ptr - 1); - strncpy((char *)p_head->passphrase, ptr + 1, - p_head->passphrase_len); - } - } else if (strstr(line, "wep_key") != NULL) { - ptr = strstr(line, "wep_key"); - ptr = ptr + strlen("wep_key"); - key_cnt = atoi(ptr); - ptr++; - if (*ptr != '=') { - fprintf(stderr, - "invalid wep_key, missing =.\n"); - break; - } - eptr = strrchr(ptr + 1, '\r'); - if (eptr == NULL) { - eptr = strrchr(ptr + 1, '\n'); - if (eptr == NULL) { - fprintf(stderr, - "missing EOL from the wep_key config\n"); - break; - } - } - ptr++; - if (*ptr == '"') { - eptr = strrchr(ptr + 1, '"'); - if (eptr == NULL) { - fprintf(stderr, - "wep key does not end with quote.\n"); - break; - } - *eptr = '\0'; - p_head->wep_key_len[key_cnt] = eptr - ptr - 1; - strncpy((char *)p_head->wep_key[key_cnt], - ptr + 1, p_head->wep_key_len[key_cnt]); - } else { - while (*eptr == '\r' || *eptr == '\n') - eptr--; - *(eptr + 1) = '\0'; - wep_len = strlen(ptr); - if (wep_len & 0x01) { - fprintf(stderr, - "incorrect wep key %s.\n", ptr); - break; - } - p_head->wep_key_len[key_cnt] = wep_len / 2; - for (i = 0; i < wep_len / 2; i++) { - byte = twodigit_ascii(ptr); - if (byte == -1) { - fprintf(stderr, - "incorrect wep key %s.\n", - ptr); - break; - } - *(p_head->wep_key[key_cnt] + i) = - (t_u8)byte; - ptr += 2; - } - } - } else if (strstr(line, "key_mgmt=") != NULL) { - ptr = strstr(line, "key_mgmt="); - ptr = ptr + strlen("key_mgmt="); - eptr = strstr(ptr, "WPA-EAP"); - if (eptr != NULL) { - p_head->key_mgmt |= - PROFILE_DB_KEY_MGMT_IEEE8021X; - } - eptr = strstr(ptr, "WPA-PSK"); - if (eptr != NULL) { - p_head->key_mgmt |= PROFILE_DB_KEY_MGMT_PSK; - } - eptr = strstr(ptr, "FT-EAP"); - if (eptr != NULL) { - p_head->key_mgmt |= - PROFILE_DB_KEY_MGMT_FT_IEEE8021X; - } - eptr = strstr(ptr, "FT-PSK"); - if (eptr != NULL) { - p_head->key_mgmt |= PROFILE_DB_KEY_MGMT_FT_PSK; - } - eptr = strstr(ptr, "WPA-EAP-SHA256"); - if (eptr != NULL) { - p_head->key_mgmt |= - PROFILE_DB_KEY_MGMT_SHA256_IEEE8021X; - } - eptr = strstr(ptr, "WPA-PSK-SHA256"); - if (eptr != NULL) { - p_head->key_mgmt |= - PROFILE_DB_KEY_MGMT_SHA256_PSK; - } - eptr = strstr(ptr, "CCKM"); - if (eptr != NULL) { - p_head->key_mgmt |= PROFILE_DB_KEY_MGMT_CCKM; - } - eptr = strstr(ptr, "NONE"); - if (eptr != NULL) { - p_head->key_mgmt |= PROFILE_DB_KEY_MGMT_NONE; - } - } else if (strstr(line, "proto=") != NULL) { - ptr = strstr(line, "proto="); - ptr = ptr + strlen("proto="); - eptr = strstr(ptr, "WPA"); - if (eptr != NULL) { - p_head->protocol |= PROFILE_DB_PROTO_WPA; - } - - eptr = strstr(ptr, "RSN"); - if (eptr != NULL) { - p_head->protocol |= PROFILE_DB_PROTO_WPA2; - - } - } else if (strstr(line, "pairwise=") != NULL) { - ptr = strstr(line, "pairwise="); - ptr = ptr + strlen("pairwise="); - eptr = strstr(ptr, "CCMP"); - if (eptr != NULL) { - p_head->pairwise_cipher |= - PROFILE_DB_CIPHER_CCMP; - } - eptr = strstr(ptr, "TKIP"); - if (eptr != NULL) { - p_head->pairwise_cipher |= - PROFILE_DB_CIPHER_TKIP; - } - } else if (strstr(line, "groupwise=") != NULL) { - ptr = strstr(line, "groupwise="); - ptr = ptr + strlen("groupwise="); - eptr = strstr(ptr, "CCMP"); - if (eptr != NULL) { - p_head->groupwise_cipher |= - PROFILE_DB_CIPHER_CCMP; - } - eptr = strstr(ptr, "TKIP"); - if (eptr != NULL) { - p_head->groupwise_cipher |= - PROFILE_DB_CIPHER_TKIP; - } - } else if (strstr(line, "wep_tx_keyidx=") != NULL) { - ptr = strstr(line, "wep_tx_keyidx="); - ptr = ptr + strlen("wep_tx_keyidx="); - p_head->wep_key_idx = atoi(ptr); - } else if (strstr(line, "roaming=") != NULL) { - ptr = strstr(line, "roaming="); - ptr = ptr + strlen("roaming="); - p_head->roaming = atoi(ptr); - } else if (strstr(line, "ccx=") != NULL) { - ptr = strstr(line, "ccx="); - ptr = ptr + strlen("ccx="); - p_head->ccx = atoi(ptr); - } else if (strstr(line, "mode=") != NULL) { - ptr = strstr(line, "mode="); - ptr = ptr + strlen("mode="); - p_head->mode = atoi(ptr); - } - } - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Issue profile command to add new profile to FW - * - * @param filename Name of profile file - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -profile_read_download(char *filename) -{ - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - int i = 0; - t_u16 temp, tempc; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd = NULL; - profile_entry_t *p_head = NULL; - FILE *fp; - char line[0x100]; - - fp = fopen(filename, "r"); - if (fp == NULL) { - perror("fopen"); - fprintf(stderr, "Cannot open file %s\n", filename); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - pos = (t_u8 *)hostcmd; - while (fgets(line, sizeof(line), fp)) { - /* call function to remove spaces, tabs */ - profile_param_polish(line); - if ((strstr(line, "network={") == NULL) || (line[0] == '#')) { - continue; - } - /* - * Memory allocation of every network block - */ - p_head = (profile_entry_t *)malloc(sizeof(profile_entry_t)); - if (p_head == NULL) { - fprintf(stderr, "Memory error.\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(p_head, 0x00, sizeof(profile_entry_t)); - - ret = profile_read_block(fp, p_head); - if (ret || p_head->ssid_len == 0) { - free(p_head); - continue; - } - - /* - * Put all the ssid parameters in the buffer - */ - memset(pos, 0, - (BUFFER_LENGTH - cmd_header_len - sizeof(t_u32))); - - /* Cmd Header : Command */ - hostcmd->command = cpu_to_le16(HostCmd_CMD_PROFILE_DB); - cmd_len = sizeof(HostCmd_DS_GEN); - - /* set action as set */ - tempc = cpu_to_le16(HostCmd_ACT_GEN_SET); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - - /* ssid */ - tempc = cpu_to_le16(TLV_TYPE_SSID); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - temp = strlen((char *)p_head->ssid); - tempc = cpu_to_le16(temp); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - memcpy((void *)(pos + cmd_len), p_head->ssid, temp); - cmd_len += temp; - - if (memcmp(p_head->bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN)) { - /* bssid */ - tempc = cpu_to_le16(TLV_TYPE_BSSID); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - temp = ETH_ALEN; - tempc = cpu_to_le16(temp); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - memcpy((void *)(pos + cmd_len), p_head->bssid, temp); - cmd_len += temp; - } - - /* proto */ - if (p_head->protocol == 0) { - p_head->protocol = 0xFFFF; - } - - tempc = cpu_to_le16(TLV_TYPE_PROTO); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - temp = 2; - tempc = cpu_to_le16(temp); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - memcpy((pos + cmd_len), &(p_head->protocol), temp); - cmd_len += temp; - - /* key_mgmt */ - if (p_head->key_mgmt == 0) { - p_head->key_mgmt = 0xFFFF; - } - - tempc = cpu_to_le16(TLV_TYPE_AKMP); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - temp = 2; - tempc = cpu_to_le16(temp); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - memcpy((pos + cmd_len), &(p_head->key_mgmt), temp); - cmd_len += temp; - - /* pairwise */ - if (p_head->pairwise_cipher == 0) { - p_head->pairwise_cipher = 0xFF; - } - - /* groupwise */ - if (p_head->groupwise_cipher == 0) { - p_head->groupwise_cipher = 0xFF; - } - - tempc = cpu_to_le16(TLV_TYPE_CIPHER); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - temp = 2; - tempc = cpu_to_le16(temp); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - pos[cmd_len] = p_head->pairwise_cipher; - cmd_len += 1; - pos[cmd_len] = p_head->groupwise_cipher; - cmd_len += 1; - - if (p_head->passphrase_len) { - /* passphrase */ - tempc = cpu_to_le16(TLV_TYPE_PASSPHRASE); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - temp = p_head->passphrase_len; - tempc = cpu_to_le16(temp); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - memcpy((void *)(pos + cmd_len), p_head->passphrase, - temp); - cmd_len += temp; - } - - if (p_head->psk_config) { - /* psk method */ - tempc = cpu_to_le16(TLV_TYPE_PMK); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - temp = 32; - tempc = cpu_to_le16(temp); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - memcpy((void *)(pos + cmd_len), p_head->psk, temp); - cmd_len += temp; - } - - for (i = 0; i < WEP_KEY_CNT; i++) { - if (p_head->wep_key_len[i]) { - /* TAG_WEP_KEY */ - tempc = cpu_to_le16(TLV_TYPE_WEP_KEY); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - /* wep_key_len + sizeof(keyIndex) + sizeof(IsDefault) */ - tempc = cpu_to_le16(p_head->wep_key_len[i] + 1 + - 1); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - *(pos + cmd_len) = i; - cmd_len += 1; - *(pos + cmd_len) = (i == p_head->wep_key_idx); - cmd_len += 1; - temp = p_head->wep_key_len[i]; - memcpy((void *)(pos + cmd_len), - p_head->wep_key[i], temp); - cmd_len += temp; - } - } - - if (p_head->roaming | p_head->ccx) { - tempc = cpu_to_le16(TLV_TYPE_OFFLOAD_ENABLE); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - temp = 2; - tempc = cpu_to_le16(temp); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - tempc = 0; - if (p_head->roaming) - tempc |= PROFILE_DB_FEATURE_ROAMING; - if (p_head->ccx) - tempc |= PROFILE_DB_FEATURE_CCX; - tempc = cpu_to_le16(tempc); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += temp; - } - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - hostcmd->size = cpu_to_le16(cmd_len); - - fprintf(stdout, "Downloading profile: %s ... ", p_head->ssid); - fflush(stdout); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[profiledb ioctl]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } else { - hostcmd->result = le16_to_cpu(hostcmd->result); - if (hostcmd->result != 0) { - printf("hostcmd : profiledb ioctl failure, code %d\n", hostcmd->result); - ret = -EFAULT; - goto done; - } - } - - fprintf(stdout, "done.\n"); - - if (p_head) - free(p_head); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - if (fp) - fclose(fp); - return ret; -} - -/******************************************************** - Global Functions -********************************************************/ - -/** - * @brief Process sub command - * - * @param sub_cmd Sub command - * @param num_sub_cmds Number of subcommands - * @param argc Number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_sub_cmd(sub_cmd_exec_t *sub_cmd, int num_sub_cmds, - int argc, char *argv[]) -{ - int idx; - boolean invalid_cmd = TRUE; - int ret = MLAN_STATUS_FAILURE; - - if (argv[3]) { - for (idx = 0; idx < num_sub_cmds; idx++) { - if (strncmp(argv[3], - sub_cmd[idx].str, - sub_cmd[idx].match_len) == 0) { - invalid_cmd = FALSE; - ret = sub_cmd[idx].callback(argc - 4, argv + 4); - break; - } - } - } - - if (invalid_cmd) { - printf("\nUnknown %s command. Valid subcmds:\n", argv[2]); - for (idx = 0; idx < num_sub_cmds; idx++) { - if (sub_cmd[idx].display) { - printf(" - %s\n", sub_cmd[idx].str); - } - } - printf("\n"); - } - - return ret; -} - -/** - * @brief select the table's regclass - * - * @param table_str Reg channel table type - * @param pTable Pointer to the Reg channel table - * - * @return TRUE if success otherwise FALSE - */ -boolean -reg_class_table_select(char *table_str, reg_chan_table_e *pTable) -{ - boolean retval = TRUE; - - if (strcmp(table_str, "user") == 0) { - *pTable = REGTABLE_USER; - } else if ((strcmp(table_str, "md") == 0) || - (strncmp(table_str, "multidomain", 5) == 0)) { - *pTable = REGTABLE_MULTIDOMAIN; - } else if (strcmp(table_str, "ess") == 0) { - *pTable = REGTABLE_ESS; - } else if (strcmp(table_str, "default") == 0) { - *pTable = REGTABLE_DEFAULT; - } else { /* If no option/wrong option set to default */ - *pTable = REGTABLE_DEFAULT; - } - - return retval; -} - -/** - * @brief Issue a measurement timing command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_measurement(int argc, char *argv[]) -{ - int ret = 0; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd = NULL; - HostCmd_DS_MEASUREMENT_Timing *timing_cmd = NULL; - MrvlIETypes_MeasTiming_t *timing_tlv = NULL; - int idx, rsp_len; - t_u8 sel = 0; - t_u16 tlv_len = 0; - timing_sel_t sel_str[] = { {"disconnected", 1}, - {"adhoc", 1}, - {"fullpower", 1}, - {"ieeeps", 1}, - {"periodic", 1} - }; - - if ((argc < 4) || strncmp(argv[3], "timing", - MAX(strlen("timing"), strlen(argv[3])))) { - printf("\nUnknown %s command. Valid subcmd: timing \n", - argv[2]); - return MLAN_STATUS_FAILURE; - } - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - cmd_len = S_DS_GEN + sizeof(t_u16); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - return -ENOMEM; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return -ENOMEM; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - hostcmd->command = cpu_to_le16(HostCmd_CMD_MEASUREMENT_TIMING_CONFIG); - hostcmd->size = cmd_len; - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - timing_cmd = (HostCmd_DS_MEASUREMENT_Timing *)pos; - timing_cmd->action = cpu_to_le16(HostCmd_ACT_GEN_GET); - timing_tlv = (MrvlIETypes_MeasTiming_t *)timing_cmd->tlv_buffer; - - if (argc == 7) { - timing_cmd->action = cpu_to_le16(HostCmd_ACT_GEN_SET); - timing_tlv->header.type = - cpu_to_le16(TLV_TYPE_MEASUREMENT_TIMING); - timing_tlv->header.len = - cpu_to_le16(sizeof(MrvlIETypes_MeasTiming_t) - - sizeof(timing_tlv->header)); - - for (idx = 1; (unsigned int)idx < NELEMENTS(sel_str); idx++) { - if (strncmp - (argv[4], sel_str[idx].str, - sel_str[idx].match_len) == 0) { - sel = idx + 1; - break; - } - } - - if (idx == NELEMENTS(sel_str)) { - printf("Wrong argument for mode selected \"%s\"\n", - argv[4]); - ret = -EINVAL; - goto done; - } - - timing_tlv->mode = cpu_to_le32(sel); - timing_tlv->max_off_channel = cpu_to_le32(atoi(argv[5])); - timing_tlv->max_on_channel = cpu_to_le32(atoi(argv[6])); - cmd_len += sizeof(MrvlIETypes_MeasTiming_t); - } - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - hostcmd->size = cpu_to_le16(cmd_len); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[measurement timing ioctl]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - printf("--------------------------------------------------\n"); - printf("%44s\n", "Measurement Timing Profiles (in ms)"); - printf("--------------------------------------------------\n"); - printf(" Profile | MaxOffChannel | MaxOnChannel\n"); - printf("--------------------------------------------------\n"); - - /* Changed to TLV parsing */ - rsp_len = le16_to_cpu(hostcmd->size); - rsp_len -= (S_DS_GEN + sizeof(t_u16)); - pos = (t_u8 *)hostcmd + S_DS_GEN + sizeof(t_u16); - while ((unsigned int)rsp_len > sizeof(MrvlIEtypesHeader_t)) { - switch (le16_to_cpu(*(t_u16 *)(pos))) { - case TLV_TYPE_MEASUREMENT_TIMING: - timing_tlv = (MrvlIETypes_MeasTiming_t *)pos; - tlv_len = le16_to_cpu(timing_tlv->header.len); - printf("%15s | %14d | %13d\n", - sel_str[le32_to_cpu(timing_tlv->mode) - 1].str, - (int)le32_to_cpu(timing_tlv->max_off_channel), - (int)le32_to_cpu(timing_tlv->max_on_channel)); - break; - } - pos += tlv_len + sizeof(MrvlIEtypesHeader_t); - rsp_len -= tlv_len + sizeof(MrvlIEtypesHeader_t); - rsp_len = (rsp_len > 0) ? rsp_len : 0; - } - printf("\n"); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue a profile command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_profile_entry(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - unsigned int mac[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - int idx; - t_u16 temp, tempc; - char *ssid = NULL; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd = NULL; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - if (argc < 4) { - fprintf(stderr, "Invalid number of argument!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - if (!strncmp(argv[3], "delete", sizeof("delete"))) { - if (argc > 4) { - if (strncmp(argv[4], "bssid=", strlen("bssid=")) == 0) { - /* "bssid" token string handler */ - sscanf(argv[4] + strlen("bssid="), - "%2x:%2x:%2x:%2x:%2x:%2x", mac + 0, - mac + 1, mac + 2, mac + 3, mac + 4, - mac + 5); - } else if (strncmp(argv[4], "ssid=", strlen("ssid=")) == - 0) { - /* "ssid" token string handler */ - ssid = argv[4] + strlen("ssid="); - } else { - printf("Error: missing required option for command (ssid, bssid)\n"); - ret = -ENOMEM; - goto done; - } - printf("Driver profile delete request\n"); - } else { - printf("Error: missing required option for command (ssid, bssid)\n"); - ret = -ENOMEM; - goto done; - } - } else if (!strncmp(argv[3], "flush", sizeof("flush"))) { - printf("Driver profile flush request\n"); - } else { - ret = profile_read_download(argv[3]); - goto done; - } - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = -ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = -ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - hostcmd->command = cpu_to_le16(HostCmd_CMD_PROFILE_DB); - hostcmd->size = 0; - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Point after host command header */ - pos = (t_u8 *)hostcmd; - cmd_len = S_DS_GEN; - - /* set action as del */ - tempc = cpu_to_le16(HostCmd_ACT_GEN_REMOVE); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - - /* ssid */ - if (ssid) { - printf("For ssid %s\n", ssid); - tempc = cpu_to_le16(TLV_TYPE_SSID); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - temp = strlen((char *)ssid); - tempc = cpu_to_le16(temp); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - memcpy((void *)(pos + cmd_len), ssid, temp); - cmd_len += temp; - } else { - /* bssid */ - if (mac[0] != 0xFF) { - printf("For bssid %02x:%02x:%02x:%02x:%02x:%02x\n", - mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); - } - tempc = cpu_to_le16(TLV_TYPE_BSSID); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - temp = ETH_ALEN; - tempc = cpu_to_le16(temp); - memcpy((pos + cmd_len), &tempc, sizeof(t_u16)); - cmd_len += 2; - for (idx = 0; (unsigned int)idx < NELEMENTS(mac); idx++) { - pos[cmd_len + idx] = (t_u8)mac[idx]; - } - cmd_len += temp; - } - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - hostcmd->size = cpu_to_le16(cmd_len); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[profiledb ioctl]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } else { - hostcmd->result = le16_to_cpu(hostcmd->result); - if (hostcmd->result != 0) { - printf("hostcmd : profiledb ioctl failure, code %d\n", - hostcmd->result); - ret = -EFAULT; - goto done; - } - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue a chan report command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_chanrpt(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - int respLen; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - t_u8 *pByte; - t_u8 numBins; - t_u8 idx; - MrvlIEtypes_Data_t *pTlvHdr; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CHAN_RPT_RSP *pChanRptRsp; - HostCmd_DS_CHAN_RPT_REQ *pChanRptReq; - - MrvlIEtypes_ChanRptBcn_t *pBcnRpt; - MrvlIEtypes_ChanRptChanLoad_t *pLoadRpt; - MrvlIEtypes_ChanRptNoiseHist_t *pNoiseRpt; - MrvlIEtypes_ChanRpt11hBasic_t *pBasicRpt; - MrvlIEtypes_ChanRptFrame_t *pFrameRpt; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - cmd_len = S_DS_GEN + sizeof(HostCmd_DS_CHAN_RPT_REQ); - - hostcmd->command = cpu_to_le16(HostCmd_CMD_CHAN_REPORT_REQUEST); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - pChanRptReq = (HostCmd_DS_CHAN_RPT_REQ *)pos; - pChanRptRsp = (HostCmd_DS_CHAN_RPT_RSP *)pos; - - memset((void *)pChanRptReq, 0x00, sizeof(HostCmd_DS_CHAN_RPT_REQ)); - - if ((argc != 5) && (argc != 6)) { - printf("\nchanrpt syntax: chanrpt [sFreq]\n\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - pChanRptReq->chanDesc.chanNum = atoi(argv[3]); - pChanRptReq->millisecDwellTime = cpu_to_le32(atoi(argv[4])); - - if (argc == 6) { - pChanRptReq->chanDesc.startFreq = cpu_to_le16(atoi(argv[5])); - } - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[chanrpt hostcmd]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - /* TSF is a t_u64, some formatted printing libs have - * trouble printing long longs, so cast and dump as bytes - */ - pByte = (t_u8 *)&pChanRptRsp->startTsf; - - printf("\n"); - printf("[%03d] TSF: 0x%02x%02x%02x%02x%02x%02x%02x%02x\n", - atoi(argv[3]), - pByte[7], pByte[6], pByte[5], pByte[4], - pByte[3], pByte[2], pByte[1], pByte[0]); - printf("[%03d] Dwell: %u us\n", - atoi(argv[3]), (unsigned int)le32_to_cpu(pChanRptRsp->duration)); - - pByte = pChanRptRsp->tlvBuffer; - - respLen = le16_to_cpu(hostcmd->size) - sizeof(HostCmd_DS_GEN); - - respLen -= sizeof(pChanRptRsp->commandResult); - respLen -= sizeof(pChanRptRsp->startTsf); - respLen -= sizeof(pChanRptRsp->duration); - - pByte = pChanRptRsp->tlvBuffer; - - while ((unsigned int)respLen >= sizeof(pTlvHdr->header)) { - pTlvHdr = (MrvlIEtypes_Data_t *)pByte; - pTlvHdr->header.len = le16_to_cpu(pTlvHdr->header.len); - - switch (le16_to_cpu(pTlvHdr->header.type)) { - case TLV_TYPE_CHANRPT_BCN: - pBcnRpt = (MrvlIEtypes_ChanRptBcn_t *)pTlvHdr; - printf("[%03d] Beacon: scanReqId = %d\n", - atoi(argv[3]), pBcnRpt->scanReqId); - - break; - - case TLV_TYPE_CHANRPT_CHAN_LOAD: - pLoadRpt = (MrvlIEtypes_ChanRptChanLoad_t *)pTlvHdr; - printf("[%03d] ChanLoad: %d%%\n", - atoi(argv[3]), - (pLoadRpt->ccaBusyFraction * 100) / 255); - break; - - case TLV_TYPE_CHANRPT_NOISE_HIST: - pNoiseRpt = (MrvlIEtypes_ChanRptNoiseHist_t *)pTlvHdr; - numBins = - pNoiseRpt->header.len - sizeof(pNoiseRpt->anpi); - printf("[%03d] ANPI: %d dB\n", atoi(argv[3]), - le16_to_cpu(pNoiseRpt->anpi)); - printf("[%03d] NoiseHst:", atoi(argv[3])); - for (idx = 0; idx < numBins; idx++) { - printf(" %03d", pNoiseRpt->rpiDensities[idx]); - } - printf("\n"); - break; - - case TLV_TYPE_CHANRPT_11H_BASIC: - pBasicRpt = (MrvlIEtypes_ChanRpt11hBasic_t *)pTlvHdr; - printf("[%03d] 11hBasic: BSS(%d), OFDM(%d), UnId(%d), Radar(%d): " "[0x%02x]\n", atoi(argv[3]), pBasicRpt->map.BSS, pBasicRpt->map.OFDM_Preamble, pBasicRpt->map.Unidentified, pBasicRpt->map.Radar, *(t_u8 *)&pBasicRpt->map); - break; - - case TLV_TYPE_CHANRPT_FRAME: - pFrameRpt = (MrvlIEtypes_ChanRptFrame_t *)pTlvHdr; - printf("[%03d] Frame: %02x:%02x:%02x:%02x:%02x:%02x " "%02x:%02x:%02x:%02x:%02x:%02x %3d %02d\n", atoi(argv[3]), pFrameRpt->sourceAddr[0], pFrameRpt->sourceAddr[1], pFrameRpt->sourceAddr[2], pFrameRpt->sourceAddr[3], pFrameRpt->sourceAddr[4], pFrameRpt->sourceAddr[5], pFrameRpt->bssid[0], pFrameRpt->bssid[1], pFrameRpt->bssid[2], pFrameRpt->bssid[3], pFrameRpt->bssid[4], pFrameRpt->bssid[5], pFrameRpt->rssi, pFrameRpt->frameCnt); - break; - - default: - printf("[%03d] Other: Id=0x%x, Size = %d\n", - atoi(argv[3]), - pTlvHdr->header.type, pTlvHdr->header.len); - - break; - } - - pByte += (pTlvHdr->header.len + sizeof(pTlvHdr->header)); - respLen -= (pTlvHdr->header.len + sizeof(pTlvHdr->header)); - respLen = (respLen > 0) ? respLen : 0; - } - - printf("\n"); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue a assoc timing command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_assoc_timing(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_AssociationTiming_t *assoctiming; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - cmd_len = S_DS_GEN + sizeof(HostCmd_DS_AssociationTiming_t); - - hostcmd->command = cpu_to_le16(HostCmd_CMD_ASSOCIATION_TIMING); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - assoctiming = (HostCmd_DS_AssociationTiming_t *)pos; - assoctiming->Action = cpu_to_le16(HostCmd_ACT_GEN_GET); - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[hostcmd]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - if (argc > 3) { - assoctiming->Action = cpu_to_le16(HostCmd_ACT_GEN_SET); - switch (argc) { - case 9: - assoctiming->ReassocDiscMax = - cpu_to_le16(atoi(argv[8])); - /* No break, do everything below as well */ - case 8: - assoctiming->PriorApDeauthDelay = - cpu_to_le16(atoi(argv[7])); - /* No break, do everything below as well */ - case 7: - assoctiming->FrameExchangeTimeout = - cpu_to_le16(atoi(argv[6])); - /* No break, do everything below as well */ - case 6: - assoctiming->HandShakeTimeout = - cpu_to_le16(atoi(argv[5])); - /* No break, do everything below as well */ - case 5: - assoctiming->ReassocTimeout = - cpu_to_le16(atoi(argv[4])); - /* No break, do everything below as well */ - case 4: - assoctiming->AssocTimeout = cpu_to_le16(atoi(argv[3])); - break; - } - } - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[hostcmd]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - puts(""); - printf("------------------------------------------------\n"); - printf(" Association Timing Parameters\n"); - printf("------------------------------------------------\n"); - - printf("Association Timeout %5u ms\n" - "Reassociation Timeout %5u ms\n" - "Handshake Timeout %5u ms\n" - "Frame Exchange Timeout %5u ms\n" - "Prior AP Deauth Delay %5u ms\n" - "Reassoc Disconnect Max %5u ms\n", - le16_to_cpu(assoctiming->AssocTimeout), - le16_to_cpu(assoctiming->ReassocTimeout), - le16_to_cpu(assoctiming->HandShakeTimeout), - le16_to_cpu(assoctiming->FrameExchangeTimeout), - le16_to_cpu(assoctiming->PriorApDeauthDelay), - le16_to_cpu(assoctiming->ReassocDiscMax)); - puts(""); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Retrieve the association response from the driver - * - * Retrieve the buffered (re)association management frame from the driver. - * The response is identical to the one received from the AP and conforms - * to the IEEE specification. - * - * @return MLAN_STATUS_SUCCESS or ioctl error code - */ -int -process_get_assocrsp(int argc, char *argv[]) -{ - int ret = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - IEEEtypes_AssocRsp_t *pAssocRsp = NULL; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - pAssocRsp = (IEEEtypes_AssocRsp_t *)buffer; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), argv[2], strlen(argv[2])); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: version fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - if (cmd->used_len) { - printf("getassocrsp: Status[%d], Cap[0x%04x]:\n", - pAssocRsp->StatusCode, - le16_to_cpu(*(t_u16 *)&pAssocRsp->Capability)); - hexdump(NULL, buffer, cmd->used_len, ' '); - } else { - printf("getassocrsp: \n"); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -#ifdef OPCHAN -static void -dumpCc(MrvlIEtypes_ChanControlDesc_t *pCcTlv) -{ - printf(" %d.%-3d\t0x%04x\t\t%2d\t%2d\t%2d\t%2d\n", - le16_to_cpu(pCcTlv->chanDesc.startFreq), - pCcTlv->chanDesc.chanNum, - le16_to_cpu(pCcTlv->controlFlags), - pCcTlv->actPower, - pCcTlv->mdMinPower, pCcTlv->mdMaxPower, pCcTlv->mdPower); -} - -static void -dumpCg(MrvlIEtypes_ChanGroupControl_t *pCgTlv) -{ - int idx; - t_u16 lastFreq; - char buf[100]; - - lastFreq = 0; - *buf = 0; - - if (pCgTlv->numChan) { - for (idx = 0; idx < pCgTlv->numChan; idx++) { - if (lastFreq != - le16_to_cpu(pCgTlv->chanDesc[idx].startFreq)) { - lastFreq = - le16_to_cpu(pCgTlv->chanDesc[idx]. - startFreq); - - if (strlen(buf)) { - puts(buf); - *buf = 0; - } - - sprintf(buf, " 0x%08x 0x%02x %04d:%d", - (unsigned int)le32_to_cpu(pCgTlv-> - chanGroupBitmap), - *(t_u8 *)&pCgTlv->scanMode, - le16_to_cpu(pCgTlv->chanDesc[idx]. - startFreq), - pCgTlv->chanDesc[idx].chanNum); - } else { - sprintf(buf + strlen(buf), ",%d", - pCgTlv->chanDesc[idx].chanNum); - } - - if (strlen(buf) > 76) { - /* Cut the display off */ - lastFreq = 0; - puts(buf); - *buf = 0; - } - } - } - - if (strlen(buf)) { - puts(buf); - } -} - -static void -dumpCgBuf(t_u8 *tlv_buffer, int tlv_size) -{ - int tlvOffset = 0; - MrvlIEtypes_ChanGroupControl_t *pCgcTlv; - - while (tlvOffset < tlv_size) { - pCgcTlv = - (MrvlIEtypes_ChanGroupControl_t *)(tlv_buffer + - tlvOffset); - - dumpCg(pCgcTlv); - - tlvOffset += sizeof(pCgcTlv->header); - tlvOffset += le16_to_cpu(pCgcTlv->header.len); - } -} - -static void -execChanGroupCmd(struct eth_priv_cmd *cmd, int tlv_size, t_u8 displayResult) -{ - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd; - HostCmd_DS_OPCHAN_CHANGROUP_CONFIG *pChanGroup; - HostCmd_DS_GEN *hostcmd; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memcpy(&buffer, &cmd->buf, sizeof(buffer)); -#else - buffer = cmd->buf; -#endif - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - pChanGroup = (HostCmd_DS_OPCHAN_CHANGROUP_CONFIG *)pos; - cmd_len = S_DS_GEN + sizeof(pChanGroup->action) + tlv_size; - - hostcmd->command = cpu_to_le16(HostCmd_CMD_OPCHAN_CHANGROUP_CONFIG); - hostcmd->seq_num = 0; - hostcmd->result = 0; - hostcmd->size = cpu_to_le16(cmd_len); - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[changroup hostcmd]"); - printf("ERR:Command sending failed!\n"); - return; - } - - if (displayResult) { - dumpCgBuf(pChanGroup->tlv_buffer, (le16_to_cpu(hostcmd->size) - - sizeof(HostCmd_DS_GEN) - - - sizeof(pChanGroup->action))); - } -} - -/** - * @brief Issue a opchan command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_opchan(int argc, char *argv[]) -{ - char line[100]; - char section[80]; - int ln = 0; - t_u8 sectionFound = 0; - int totalTlvBytes = 0; - FILE *fp = NULL; - - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_OPCHAN_CONFIG *pOpChanConfig; - MrvlIEtypes_ChanControlDesc_t *pCcTlv; - - if ((argc < 3) || (argc > 5)) { - /* 3 arguments for a get, 4 for clear, 5 arguments for a set */ - printf("Invalid number of arguments\n"); - ret = -EOPNOTSUPP; - goto done; - } - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - cmd_len = S_DS_GEN + 2000; - - pOpChanConfig = (HostCmd_DS_OPCHAN_CONFIG *)pos; - - if ((argc == 4) && (strcmp(argv[3], "clear") != 0)) { - /* With 4 arguments cmd must be: mlanutl mlan0 opchan clear */ - printf("Invalid command arguments.\n"); - ret = -EOPNOTSUPP; - goto done; - } else if (argc == 5) { - pOpChanConfig->action = cpu_to_le16(HostCmd_ACT_GEN_SET); - - fp = fopen(argv[3], "r"); - if (fp == NULL) { - fprintf(stderr, "Cannot open file %s\n", argv[3]); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - sprintf(section, "[%s]", argv[4]); - - while (!sectionFound - && mlan_config_get_line(fp, line, sizeof(line), &ln)) { - if (strncmp(line, section, strlen(section)) == 0) { - sectionFound = 1; - break; - } - } - } - - while (sectionFound - && mlan_config_get_line(fp, line, sizeof(line), &ln)) { - - MrvlIEtypes_ChanControlDesc_t ccTlv; - int startFreq; - int chanNum; - int controlFlags; - int actPower; - int mdMinPower; - int mdMaxPower; - int mdPower; - - if (line[0] == '#') { - continue; - } - - if (line[0] == '[') { - break; - } - - sscanf(line, "%d.%d 0x%x %d %d %d %d", - &startFreq, &chanNum, - &controlFlags, - &actPower, &mdMinPower, &mdMaxPower, &mdPower); - - ccTlv.chanDesc.startFreq = cpu_to_le16(startFreq); - ccTlv.chanDesc.chanNum = chanNum; - ccTlv.controlFlags = cpu_to_le16(controlFlags); - ccTlv.actPower = actPower; - ccTlv.mdMinPower = mdMinPower; - ccTlv.mdMaxPower = mdMaxPower; - ccTlv.mdPower = mdPower; - - ccTlv.header.len = - cpu_to_le16(sizeof(ccTlv) - sizeof(ccTlv.header)); - ccTlv.header.type = cpu_to_le16(TLV_TYPE_OPCHAN_CONTROL_DESC); - - memcpy(pOpChanConfig->tlv_buffer + totalTlvBytes, - &ccTlv, sizeof(ccTlv)); - - totalTlvBytes += sizeof(ccTlv); - } - - if (argc == 3) { - pOpChanConfig->action = cpu_to_le16(HostCmd_ACT_GEN_GET); - } else if (argc == 4) { - /* Clears the multidomain learning table only. Does not change the - ** operating channels - */ - pOpChanConfig->action = cpu_to_le16(HostCmd_ACT_GEN_CLEAR); - } - - else if (!sectionFound) { - printf("Section \"%s\" not found\n", argv[4]); - ret = -EFAULT; - goto done; - } - - hostcmd->command = cpu_to_le16(HostCmd_CMD_OPCHAN_CONFIG); - hostcmd->seq_num = 0; - hostcmd->result = 0; - hostcmd->size = cpu_to_le16(sizeof(HostCmd_DS_GEN) - + sizeof(pOpChanConfig->action) - + totalTlvBytes); - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[changroup hostcmd]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - totalTlvBytes = (le16_to_cpu(hostcmd->size) - - sizeof(HostCmd_DS_GEN) - - sizeof(pOpChanConfig->action)); - - pCcTlv = (MrvlIEtypes_ChanControlDesc_t *)pOpChanConfig->tlv_buffer; - - while (totalTlvBytes) { - /* Switch to TLV parsing */ - dumpCc(pCcTlv); - pCcTlv++; - totalTlvBytes -= sizeof(MrvlIEtypes_ChanControlDesc_t); - } - -done: - if (fp) - fclose(fp); - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue a changroup command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_changroup(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - char line[100]; - char section[80]; - int ln = 0; - t_u8 sectionFound = 0; - int totalTlvBytes = 0; - FILE *fp = NULL; - - HostCmd_DS_OPCHAN_CHANGROUP_CONFIG *pChanGroup; - MrvlIEtypes_ChanGroupControl_t cgTlv; - - puts(""); - - if ((argc != 3) && (argc != 5)) { - /* 3 arguments for a get, 5 arguments for a set */ - ret = -EOPNOTSUPP; - goto done; - } - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - pos = (t_u8 *)buffer + cmd_header_len + sizeof(t_u32) + S_DS_GEN; - pChanGroup = (HostCmd_DS_OPCHAN_CHANGROUP_CONFIG *)pos; - - if (argc == 5) { - pChanGroup->action = cpu_to_le16(HostCmd_ACT_GEN_SET); - - fp = fopen(argv[3], "r"); - if (fp == NULL) { - fprintf(stderr, "Cannot open file %s\n", argv[3]); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - sprintf(section, "[%s]", argv[4]); - - while (!sectionFound - && mlan_config_get_line(fp, line, sizeof(line), &ln)) { - if (strncmp(line, section, strlen(section)) == 0) { - sectionFound = 1; - break; - } - } - - while (sectionFound - && mlan_config_get_line(fp, line, sizeof(line), &ln)) { - - int startFreq; - int chanNum; - int chanCount; - int chanGroupBitmap; - int scanMode; - int tlvBytes; - char *ptr; - char *ret; - - memset(&cgTlv, 0x00, sizeof(cgTlv)); - - if (line[0] == '#') { - continue; - } - - if (line[0] == '[') { - break; - } - - sscanf(strstr(line, "0"), - "0x%x 0x%x %d:", - &chanGroupBitmap, &scanMode, &startFreq); - - ptr = strtok_r(line, ":", &ret); - - if (ptr == NULL) { - break; - } - - chanCount = 0; - tlvBytes = sizeof(cgTlv.chanGroupBitmap); - tlvBytes += sizeof(cgTlv.scanMode); - tlvBytes += sizeof(cgTlv.numChan); - - while ((ptr = strtok_r(NULL, ",", &ret)) != NULL) { - sscanf(ptr, "%d", &chanNum); - - cgTlv.chanDesc[chanCount].startFreq = - cpu_to_le16(startFreq); - cgTlv.chanDesc[chanCount].chanNum = chanNum; - tlvBytes += sizeof(MrvlChannelDesc_t); - chanCount++; - } - - memcpy(&cgTlv.scanMode, &scanMode, - sizeof(cgTlv.scanMode)); - cgTlv.chanGroupBitmap = cpu_to_le32(chanGroupBitmap); - cgTlv.numChan = chanCount; - cgTlv.header.len = cpu_to_le16(tlvBytes); - cgTlv.header.type = - cpu_to_le16(TLV_TYPE_OPCHAN_CHANGRP_CTRL); - tlvBytes += sizeof(cgTlv.header); - - memcpy(pChanGroup->tlv_buffer + totalTlvBytes, - &cgTlv, sizeof(cgTlv.header) + tlvBytes); - - totalTlvBytes += tlvBytes; - } - - if (!sectionFound) { - printf("Section \"%s\" not found\n", argv[4]); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - execChanGroupCmd(cmd, totalTlvBytes, FALSE); - } - - if (argc == 3 || sectionFound) { - t_u8 loop; - - totalTlvBytes = sizeof(cgTlv.header); - totalTlvBytes += sizeof(cgTlv.chanGroupBitmap); - totalTlvBytes += sizeof(cgTlv.scanMode); - totalTlvBytes += sizeof(cgTlv.numChan); - - pChanGroup->action = cpu_to_le16(HostCmd_ACT_GEN_GET); - - memset(&cgTlv, 0x00, sizeof(cgTlv)); - cgTlv.header.len = cpu_to_le16(totalTlvBytes); - cgTlv.header.type = cpu_to_le16(TLV_TYPE_OPCHAN_CHANGRP_CTRL); - - for (loop = 0; loop < 4; loop++) { - /* Retrieve 8 channel groups at a time */ - cgTlv.chanGroupBitmap = cpu_to_le32(0xFF << 8 * loop); - - memcpy(pChanGroup->tlv_buffer, - &cgTlv, sizeof(cgTlv.header) + totalTlvBytes); - - execChanGroupCmd(cmd, totalTlvBytes, TRUE); - } - } - - puts(""); - -done: - if (fp) - fclose(fp); - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} -#endif - -/* -** Process mlanutl fcontrol command: -** -** mlanutl mlanX fcontrol %d [0xAA 0xBB... ] -** -** Sets and/or retrieves the feature control settings for a specific -** control set (argv[3] decimal argument). -** -*/ -int -process_fcontrol(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - t_u8 idx; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_OFFLOAD_FEATURE_CONTROL *pFcontrol; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - pFcontrol = (HostCmd_DS_OFFLOAD_FEATURE_CONTROL *)pos; - - if (argc < 4) { - printf("Wrong number of arguments\n"); - ret = -EINVAL; - goto done; - } - - pFcontrol->controlSelect = atoi(argv[3]); - cmd_len = S_DS_GEN + sizeof(pFcontrol->controlSelect); - - for (idx = 4; idx < argc; idx++) { - pFcontrol->controlBitmap[idx - 4] = a2hex_or_atoi(argv[idx]); - cmd_len++; - } - - hostcmd->command = cpu_to_le16(HostCmd_CMD_OFFLOAD_FEATURE_CONTROL); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[fcontrol hostcmd]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - cmd_len = (le16_to_cpu(hostcmd->size) - sizeof(HostCmd_DS_GEN)); - - printf("Control[%d]", pFcontrol->controlSelect); - cmd_len--; - - for (idx = 0; idx < cmd_len; idx++) { - printf("\t0x%02x", pFcontrol->controlBitmap[idx]); - } - - printf("\n"); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/* -** Process mlanutl iapp command: -** -** mlanutl mlanX iapp 0xAA 0xBB [0x... 0x.. ] -** -** 0xAA = IAPP type -** 0xBB = IAPP subtype -** 0x.. = Remaning bytes are iapp data -** -*/ -int -process_iapp(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - t_u8 idx; - t_u8 fixlen; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_IAPP_PROXY *pIappProxy; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - cmd_len = S_DS_GEN + sizeof(HostCmd_DS_IAPP_PROXY); - - pIappProxy = (HostCmd_DS_IAPP_PROXY *)pos; - - if (argc < 6) { - printf("Wrong number of arguments\n"); - ret = -EINVAL; - } - - memset(pIappProxy, 0x00, sizeof(HostCmd_DS_IAPP_PROXY)); - - pIappProxy->iappType = a2hex_or_atoi(argv[4]); - pIappProxy->iappSubType = a2hex_or_atoi(argv[5]); - - /* Fixed len portions of command */ - fixlen = (S_DS_GEN + sizeof(HostCmd_DS_IAPP_PROXY) - - sizeof(pIappProxy->iappData)); - - pIappProxy->timeout_ms = cpu_to_le32(a2hex_or_atoi(argv[3])); - - for (idx = 6; idx < argc; idx++) { - pIappProxy->iappData[idx - 6] = a2hex_or_atoi(argv[idx]); - pIappProxy->iappDataLen++; - } - - hostcmd->command = cpu_to_le16(HostCmd_CMD_IAPP_PROXY); - hostcmd->size = cpu_to_le16(fixlen + pIappProxy->iappDataLen); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - pIappProxy->iappDataLen = cpu_to_le32(pIappProxy->iappDataLen); - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[iapp hostcmd]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - printf("\nResult: %d\n", le32_to_cpu(pIappProxy->commandResult)); - printf("Type: 0x%02x\n", pIappProxy->iappType); - printf("SubType: 0x%02x\n", pIappProxy->iappSubType); - - printf("IappData: "); - hexdump(NULL, pIappProxy->iappData, - le32_to_cpu(pIappProxy->iappDataLen), ' '); - printf("\n\n"); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue a rf tx power command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_rf_tx_power(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_802_11_RF_TX_POWER *pRfTxPower; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - cmd_len = S_DS_GEN + sizeof(HostCmd_DS_802_11_RF_TX_POWER); - - pRfTxPower = (HostCmd_DS_802_11_RF_TX_POWER *)pos; - - memset(pRfTxPower, 0x00, sizeof(HostCmd_DS_802_11_RF_TX_POWER)); - - hostcmd->command = cpu_to_le16(HostCmd_CMD_802_11_RF_TX_POWER); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[hostcmd]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - printf("\n"); - printf(" MinPower: %2d\n", pRfTxPower->min_power); - printf(" MaxPower: %2d\n", pRfTxPower->max_power); - printf(" Current: %2d\n", le16_to_cpu(pRfTxPower->current_level)); - printf("\n"); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue a authenticate command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_authenticate(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_802_11_AUTHENTICATE *pAuth; - unsigned int mac[ETH_ALEN]; - int tmpIdx; - - if (argc != 4) { - printf("Wrong number of arguments\n"); - ret = -EINVAL; - goto done; - } - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - cmd_len = S_DS_GEN + sizeof(HostCmd_DS_802_11_AUTHENTICATE); - - pAuth = (HostCmd_DS_802_11_AUTHENTICATE *)pos; - - memset(pAuth, 0x00, sizeof(HostCmd_DS_802_11_AUTHENTICATE)); - - sscanf(argv[3], - "%2x:%2x:%2x:%2x:%2x:%2x", - mac + 0, mac + 1, mac + 2, mac + 3, mac + 4, mac + 5); - - for (tmpIdx = 0; (unsigned int)tmpIdx < NELEMENTS(mac); tmpIdx++) { - pAuth->MacAddr[tmpIdx] = (t_u8)mac[tmpIdx]; - } - - hostcmd->command = cpu_to_le16(HostCmd_CMD_802_11_AUTHENTICATE); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[hostcmd]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -static void -display_channel(void) -{ - FILE *tmpfile; - char result[200]; - char cmdStr[50]; - int ghz, mhz, chan; - - puts("\n"); - - sprintf(cmdStr, "iwlist %s chan", dev_name); - - tmpfile = popen(cmdStr, "r"); - - if (tmpfile == NULL) { - perror("mlanutl: iwlist failed to get current channel"); - } else { - while (fgets(result, sizeof(result), tmpfile)) { - if ((sscanf - (result, " Current Frequency=%d.%d ", &ghz, - &mhz) == 2) || - (sscanf - (result, " Current Frequency:%d.%d ", &ghz, - &mhz) == 2)) { - if (mhz < 10) { - mhz *= 100; - } else if (mhz < 100) { - mhz *= 10; - } - - chan = ghz * 1000 + mhz; - if (chan > 5000) { - chan -= 5000; - chan /= 5; - } else if (chan == 2484) { - chan = 14; - } else { - chan -= 2407; - chan /= 5; - } - printf(" Channel: %3d [%d.%d GHz]\n", chan, - ghz, mhz); - } - } - pclose(tmpfile); - } -} - -static char * -get_ratestr(int txRate) -{ - char *pStr; - - switch (txRate) { - case 0: - pStr = "1"; - break; - case 1: - pStr = "2"; - break; - case 2: - pStr = "5.5"; - break; - case 3: - pStr = "11"; - break; - case 4: - pStr = "6"; - break; - case 5: - pStr = "9"; - break; - case 6: - pStr = "12"; - break; - case 7: - pStr = "18"; - break; - case 8: - pStr = "24"; - break; - case 9: - pStr = "36"; - break; - case 10: - pStr = "48"; - break; - case 11: - pStr = "54"; - break; - case 12: - pStr = "MCS0"; - break; - case 13: - pStr = "MCS1"; - break; - case 14: - pStr = "MCS2"; - break; - case 15: - pStr = "MCS3"; - break; - case 16: - pStr = "MCS4"; - break; - case 17: - pStr = "MCS5"; - break; - case 18: - pStr = "MCS6"; - break; - case 19: - pStr = "MCS7"; - break; - - case 140: - pStr = "MCS0"; - break; - case 141: - pStr = "MCS1"; - break; - case 142: - pStr = "MCS2"; - break; - case 143: - pStr = "MCS3"; - break; - case 144: - pStr = "MCS4"; - break; - case 145: - pStr = "MCS5"; - break; - case 146: - pStr = "MCS6"; - break; - case 147: - pStr = "MCS7"; - break; - - default: - pStr = "Unkn"; - break; - } - - return pStr; -} - -typedef struct { - int rate; - int min; - int max; - -} RatePower_t; - -static int -get_txpwrcfg(RatePower_t ratePower[]) -{ - FILE *tmpfile; - char result[300]; - char cmdStr[50]; - int counter = 0; - char *pBuf; - int r1 = 0, r2 = 0, min = 0, max = 0, rate = 0; - int rateIdx = 0; - - sprintf(cmdStr, "iwpriv %s txpowercfg", dev_name); - - tmpfile = popen(cmdStr, "r"); - - if (tmpfile == NULL) { - perror("mlanutl: iwpriv failed to get txpowercfg"); - } else { - while (fgets(result, sizeof(result), tmpfile)) { - pBuf = strtok(result, ": "); - - while (pBuf != NULL) { - switch (counter % 5) { - case 0: - r1 = atoi(pBuf); - break; - - case 1: - r2 = atoi(pBuf); - break; - - case 2: - min = atoi(pBuf); - break; - - case 3: - max = atoi(pBuf); - break; - - case 4: - for (rate = r1; rate <= r2; rate++) { - ratePower[rateIdx].rate = rate; - ratePower[rateIdx].min = min; - ratePower[rateIdx].max = max; - rateIdx++; - } - break; - } - - if (isdigit(*pBuf)) { - counter++; - } - pBuf = strtok(NULL, ": "); - } - } - pclose(tmpfile); - } - - return rateIdx; -} - -static void -rateSort(RatePower_t rateList[], int numRates) -{ - int inc, i, j; - RatePower_t tmp; - - inc = 3; - - while (inc > 0) { - for (i = 0; i < numRates; i++) { - j = i; - memcpy(&tmp, &rateList[i], sizeof(RatePower_t)); - - while ((j >= inc) && - (rateList[j - inc].rate > tmp.rate)) { - memcpy(&rateList[j], &rateList[j - inc], - sizeof(RatePower_t)); - j -= inc; - } - - memcpy(&rateList[j], &tmp, sizeof(RatePower_t)); - } - - if (inc >> 1) { - inc >>= 1; - } else if (inc == 1) { - inc = 0; - } else { - inc = 1; - } - } -} - -typedef struct { - int rate; - int modGroup; - -} RateModPair_t; - -/* -** -** ModulationGroups -** 0: CCK (1,2,5.5,11 Mbps) -** 1: OFDM (6,9,12,18 Mbps) -** 2: OFDM (24,36 Mbps) -** 3: OFDM (48,54 Mbps) -** 4: HT20 (0,1,2) -** 5: HT20 (3,4) -** 6: HT20 (5,6,7) -** 7: HT40 (0,1,2) -** 8: HT40 (3,4) -** 9: HT40 (5,6,7) -*/ - -static RateModPair_t rateModPairs[] = { - {0, 0}, /* 1 */ - {1, 0}, /* 2 */ - {2, 0}, /* 5.5 */ - {3, 0}, /* 11 */ - {4, 1}, /* 6 */ - {5, 1}, /* 9 */ - {6, 1}, /* 12 */ - {7, 1}, /* 18 */ - {8, 2}, /* 24 */ - {9, 2}, /* 36 */ - {10, 3}, /* 48 */ - {11, 3}, /* 54 */ - {12, 4}, /* MCS0 */ - {13, 4}, /* MCS1 */ - {14, 4}, /* MCS2 */ - {15, 5}, /* MCS3 */ - {16, 5}, /* MCS4 */ - {17, 6}, /* MCS5 */ - {18, 6}, /* MCS6 */ - {19, 6}, /* MCS7 */ - - {140, 7}, /* MCS0 */ - {141, 7}, /* MCS1 */ - {142, 7}, /* MCS2 */ - {143, 8}, /* MCS3 */ - {144, 8}, /* MCS4 */ - {145, 9}, /* MCS5 */ - {146, 9}, /* MCS6 */ - {147, 9}, /* MCS7 */ -}; - -int -process_chantrpcdisp(int startRate, int endRate) -{ - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CHAN_TRPC_CONFIG *pChanTrpc; - MrvlIEtypes_ChanTrpcCfg_t *pChanTrpcTlv; - int totalTlvBytes = 0; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - pChanTrpc = (HostCmd_DS_CHAN_TRPC_CONFIG *)pos; - pChanTrpc->action = cpu_to_le16(HostCmd_ACT_GEN_GET); - - cmd_len = S_DS_GEN + sizeof(pChanTrpc->action); - hostcmd->command = cpu_to_le16(HostCmd_CMD_CHAN_TRPC_CONFIG); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[chantrpc hostcmd]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - totalTlvBytes = (le16_to_cpu(hostcmd->size) - - sizeof(HostCmd_DS_GEN) - - sizeof(pChanTrpc->action) - - sizeof(pChanTrpc->reserved)); - - pChanTrpcTlv = (MrvlIEtypes_ChanTrpcCfg_t *)pChanTrpc->tlv_buffer; - - while (totalTlvBytes) { - int tlvSize, numModGroups, idx, modIdx, numOut; - - /* Switch to TLV parsing */ - printf("%4d.%-3d ", - le16_to_cpu(pChanTrpcTlv->chanDesc.startFreq), - pChanTrpcTlv->chanDesc.chanNum); - - numOut = 0; - - tlvSize = (le16_to_cpu(pChanTrpcTlv->header.len) - + sizeof(pChanTrpcTlv->header)); - - numModGroups = (le16_to_cpu(pChanTrpcTlv->header.len) - - sizeof(pChanTrpcTlv->chanDesc)); - numModGroups /= sizeof(pChanTrpcTlv->chanTrpcEntry[0]); - - for (idx = 0; idx < NELEMENTS(rateModPairs); idx++) { - if ((rateModPairs[idx].rate >= startRate) && - (rateModPairs[idx].rate <= endRate)) { - for (modIdx = 0; modIdx < numModGroups; - modIdx++) { - if (rateModPairs[idx].modGroup == - pChanTrpcTlv->chanTrpcEntry[modIdx]. - modGroup) { - printf("%*d", - (numOut == 0) ? 3 : 6, - pChanTrpcTlv-> - chanTrpcEntry[modIdx]. - txPower); - numOut++; - } - } - - if (numOut == 0) { - printf(" -- "); - } - } - } - - puts(""); - - pChanTrpcTlv = - (MrvlIEtypes_ChanTrpcCfg_t *)((t_u8 *)pChanTrpcTlv + - tlvSize); - totalTlvBytes -= tlvSize; - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue a tx power display command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_txpowdisp(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - int rateIdx, rates; - int connected; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_802_11_RF_TX_POWER *pRfTxPower; - RatePower_t ratePower[50]; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - cmd_len = S_DS_GEN + sizeof(HostCmd_DS_802_11_RF_TX_POWER); - - pRfTxPower = (HostCmd_DS_802_11_RF_TX_POWER *)pos; - - memset(pRfTxPower, 0x00, sizeof(HostCmd_DS_802_11_RF_TX_POWER)); - - hostcmd->command = cpu_to_le16(HostCmd_CMD_802_11_RF_TX_POWER); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[hostcmd]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - connected = le16_to_cpu(pRfTxPower->current_level) ? TRUE : FALSE; - - if (connected) { - display_channel(); - - printf("\n"); - printf(" MinPower: %2d\n", pRfTxPower->min_power); - printf(" MaxPower: %2d\n", pRfTxPower->max_power); - printf(" Current: %2d\n", - le16_to_cpu(pRfTxPower->current_level)); - printf("\n"); - } - - rates = get_txpwrcfg(ratePower); - - puts(""); - - rateSort(ratePower, rates); - - printf("20MHz:"); - - for (rateIdx = 0; rateIdx < 12; rateIdx++) { - printf("%6s", get_ratestr(ratePower[rateIdx].rate)); - } - - printf("\n---------------------------------------" - "----------------------------------------\n%s", - connected ? "Active" : "Max "); - - for (rateIdx = 0; rateIdx < 12; rateIdx++) { - printf("%6d", ratePower[rateIdx].max); - } - - if (!connected) { - printf("\n---------------------------------------" - "----------------------------------------\n"); - - process_chantrpcdisp(ratePower[0].rate, ratePower[12 - 1].rate); - } - - puts("\n"); - - /* - ** MCS0 -> MCS7 - */ - - printf("20MHz:"); - - for (rateIdx = 12; rateIdx < 20; rateIdx++) { - printf("%6s", get_ratestr(ratePower[rateIdx].rate)); - } - - printf("\n---------------------------------------" - "----------------------------------------\n%s", - connected ? "Active" : "Max "); - - for (rateIdx = 12; rateIdx < 20; rateIdx++) { - printf("%6d", ratePower[rateIdx].max); - } - - if (!connected) { - printf("\n---------------------------------------" - "----------------------------------------\n"); - - process_chantrpcdisp(ratePower[12].rate, - ratePower[20 - 1].rate); - } - - puts("\n"); - - /* - ** MCS0 -> MCS7 @ 40MHz - */ - - printf("40MHz:"); - - for (rateIdx = 20; rateIdx < rates; rateIdx++) { - printf("%6s", get_ratestr(ratePower[rateIdx].rate)); - } - - printf("\n---------------------------------------" - "----------------------------------------\n%s", - connected ? "Active" : "Max "); - - for (rateIdx = 20; rateIdx < rates; rateIdx++) { - printf("%6d", ratePower[rateIdx].max); - } - - if (!connected) { - printf("\n---------------------------------------" - "----------------------------------------\n"); - - process_chantrpcdisp(ratePower[20].rate, - ratePower[rates - 1].rate); - } - - puts("\n"); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanoffload.h b/mxm_wifiex/wlan_src/mapp/mlanutl/mlanoffload.h deleted file mode 100644 index 39e6b5d..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanoffload.h +++ /dev/null @@ -1,514 +0,0 @@ -/** @file mlanoffload.h - * - * @brief This files contains mlanutl offload command handling. - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 08/11/2009: initial version -************************************************************************/ - -#ifndef _MLANOFFLOAD_H_ -#define _MLANOFFLOAD_H_ - -#ifndef MAX -/** Find maximum value */ -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#endif /* MAX */ - -/** Key length */ -#define KEY_LEN 32 -/** Phrase length */ -#define PHRASE_LEN 32 -/** WEP Key count */ -#define WEP_KEY_CNT 4 - -/* Bitmap for OFFLoad Enable - Feature*/ -#ifdef BIG_ENDIAN_SUPPORT -/** Roaming Feature */ -#define PROFILE_DB_FEATURE_ROAMING 0x8000 -/** CCX Feature */ -#define PROFILE_DB_FEATURE_CCX 0x4000 -/** UNUSED Feature */ -#define PROFILE_DB_FEATURE_UNUSED 0x2000 -/** adhoc/infra mode */ -#define PROFILE_DB_FEATURE_MODE 0x1000 -#else -/** Roaming Feature */ -#define PROFILE_DB_FEATURE_ROAMING 0x0001 -/** CCX Feature */ -#define PROFILE_DB_FEATURE_CCX 0x0002 -/** UNUSED Feature */ -#define PROFILE_DB_FEATURE_UNUSED 0x0004 -/** adhoc/infra mode */ -#define PROFILE_DB_FEATURE_MODE 0x0008 -#endif - -/* Bitmap for profile AKMP Support */ -#ifdef BIG_ENDIAN_SUPPORT -/** Key Management EAP */ -#define PROFILE_DB_KEY_MGMT_IEEE8021X 0x8000 -/** Key Management PSK */ -#define PROFILE_DB_KEY_MGMT_PSK 0x4000 -/** Key Management NONE */ -#define PROFILE_DB_KEY_MGMT_NONE 0x2000 -/** Key Management CCKM */ -#define PROFILE_DB_KEY_MGMT_CCKM 0x1000 -/** Key Management UNUSED */ -#define PROFILE_DB_KEY_MGMT_UNUSED 0x0800 -/** Key Management FT 802.1x */ -#define PROFILE_DB_KEY_MGMT_FT_IEEE8021X 0x0400 -/** Key Management FT PSK */ -#define PROFILE_DB_KEY_MGMT_FT_PSK 0x0200 -/** Key Management SHA256 802.1x */ -#define PROFILE_DB_KEY_MGMT_SHA256_IEEE8021X 0x0100 -/** Key Management SHA256 PSK*/ -#define PROFILE_DB_KEY_MGMT_SHA256_PSK 0x0080 -#else -/** Key Management EAP */ -#define PROFILE_DB_KEY_MGMT_IEEE8021X 0x0001 -/** Key Management PSK */ -#define PROFILE_DB_KEY_MGMT_PSK 0x0002 -/** Key Management NONE */ -#define PROFILE_DB_KEY_MGMT_NONE 0x0004 -/** Key Management CCKM */ -#define PROFILE_DB_KEY_MGMT_CCKM 0x0008 -/** Key Management UNUSED */ -#define PROFILE_DB_KEY_MGMT_UNUSED 0x0010 -/** Key Management FT 802.1x */ -#define PROFILE_DB_KEY_MGMT_FT_IEEE8021X 0x0020 -/** Key Management FT PSK */ -#define PROFILE_DB_KEY_MGMT_FT_PSK 0x0040 -/** Key Management SHA256 802.1x */ -#define PROFILE_DB_KEY_MGMT_SHA256_IEEE8021X 0x0080 -/** Key Management SHA256 PSK*/ -#define PROFILE_DB_KEY_MGMT_SHA256_PSK 0x0100 -#endif - -/* Bitmap for profile Encryption protocol support */ -#ifdef BIG_ENDIAN_SUPPORT -/** Encryption protocol noRsn */ -#define PROFILE_DB_PROTO_NO_RSN 0x8000 -/** Encryption protocol static wep */ -#define PROFILE_DB_PROTO_WEP_STATIC 0x4000 -/** Encryption protocol dynamic wep */ -#define PROFILE_DB_PROTO_WEP_DYNAMIC 0x2000 -/** Encryption protocol WPA */ -#define PROFILE_DB_PROTO_WPA 0x1000 -/** Encryption protocol WPA-none - * Ad-hoc Networks */ -#define PROFILE_DB_PROTO_WPA_NONE 0x0800 -/** Encryption protocol WPA2 */ -#define PROFILE_DB_PROTO_WPA2 0x0400 -/** Encryption protocol CCKM */ -#define PROFILE_DB_PROTO_CCKM 0x0200 -#else -/** Encryption protocol noRsn */ -#define PROFILE_DB_PROTO_NO_RSN 0x0001 -/** Encryption protocol static wep */ -#define PROFILE_DB_PROTO_WEP_STATIC 0x0002 -/** Encryption protocol dynamic wep */ -#define PROFILE_DB_PROTO_WEP_DYNAMIC 0x0004 -/** Encryption protocol WPA */ -#define PROFILE_DB_PROTO_WPA 0x0008 -/** Encryption protocol WPA-none - * Ad-hoc Networks */ -#define PROFILE_DB_PROTO_WPA_NONE 0x0010 -/** Encryption protocol WPA2 */ -#define PROFILE_DB_PROTO_WPA2 0x0020 -/** Encryption protocol CCKM */ -#define PROFILE_DB_PROTO_CCKM 0x0040 -#endif - -#ifdef BIG_ENDIAN_SUPPORT -/** Cipher wep40 */ -#define PROFILE_DB_CIPHER_WEP40 0x80 -/** Cipher wep104 */ -#define PROFILE_DB_CIPHER_WEP104 0x40 -/** Cipher tkip */ -#define PROFILE_DB_CIPHER_TKIP 0x20 -/** Cipher ccmp */ -#define PROFILE_DB_CIPHER_CCMP 0x10 -#else -/** Cipher wep40 */ -#define PROFILE_DB_CIPHER_WEP40 0x01 -/** Cipher wep104 */ -#define PROFILE_DB_CIPHER_WEP104 0x02 -/** Cipher tkip */ -#define PROFILE_DB_CIPHER_TKIP 0x04 -/** Cipher ccmp */ -#define PROFILE_DB_CIPHER_CCMP 0x08 -#endif - -typedef struct { - /** Header */ - MrvlIEtypesHeader_t header; - - t_u32 mode; /**< Mode */ - t_u32 max_off_channel; - /**< Maximum off-channel measurement duration (ms) */ - t_u32 max_on_channel; - /**< Maximum on-channel measurement duration (ms) */ - -} __ATTRIB_PACK__ MrvlIETypes_MeasTiming_t; - -typedef struct { - /** Action Set or get */ - t_u16 action; - - /** TLV buffer starts here */ - t_u8 tlv_buffer[1]; - - /* - * MrvlIETypes_MeasTiming_t - */ -} __ATTRIB_PACK__ HostCmd_DS_MEASUREMENT_Timing; - -/** helper structure for profile parsing */ -typedef struct { - /** SSID name string */ - t_u8 ssid[IW_ESSID_MAX_SIZE + 1]; - /** SSID len */ - t_u32 ssid_len; - /** BSSID network name */ - t_u8 bssid[ETH_ALEN]; - /** passphrase configured */ - t_s8 passphrase[PHRASE_LEN]; - /** passphrase length */ - t_u32 passphrase_len; - /** Pre-shared key config flag */ - int psk_config; - /** Pre-shared key */ - t_u8 psk[KEY_LEN]; - /** wep keys */ - t_u8 wep_key[WEP_KEY_CNT][KEY_LEN]; - /** wep keys lengths */ - t_u8 wep_key_len[WEP_KEY_CNT]; - /** wep key index */ - int wep_key_idx; - /** protocol fields */ - t_u16 protocol; - /** pairwise Cipher values */ - t_u8 pairwise_cipher; - /** Group Cipher values */ - t_u8 groupwise_cipher; - /** key management */ - t_u16 key_mgmt; - /** offload specific parameter(roaming) */ - t_u16 roaming; - /** offload specific parameter */ - t_u16 reserved; - /** offload specific parameter--ccx */ - t_u16 ccx; - /** offload specific parameter--mode */ - t_u16 mode; -} profile_entry_t; - -typedef struct { -#ifdef BIG_ENDIAN_SUPPORT - /** Reserved */ - t_u8 Reserved:3; - /** Channel not measured */ - t_u8 Unmeasured:1; - /** Radar detected */ - t_u8 Radar:1; - /** Unidentified signal received */ - t_u8 Unidentified:1; - /** OFDM Preamble received */ - t_u8 OFDM_Preamble:1; - /** BSS found */ - t_u8 BSS:1; -#else - /** BSS found */ - t_u8 BSS:1; - /** OFDM Preamble received */ - t_u8 OFDM_Preamble:1; - /** Unidentified signal received */ - t_u8 Unidentified:1; - /** Radar detected */ - t_u8 Radar:1; - /** Channel not measured */ - t_u8 Unmeasured:1; - /** Reserved */ - t_u8 Reserved:3; -#endif -} __ATTRIB_PACK__ IEEEtypes_DFS_Map_t; - -typedef struct { - MrvlIEtypesHeader_t Header; /**< Header */ - - t_u8 scanReqId; /**< Scan request id assigned in table */ -} __ATTRIB_PACK__ MrvlIEtypes_ChanRptBcn_t; - -typedef struct { - MrvlIEtypesHeader_t Header; /**< Header */ - - IEEEtypes_DFS_Map_t map; /**< IEEE 802.11h basic meas report */ -} __ATTRIB_PACK__ MrvlIEtypes_ChanRpt11hBasic_t; - -typedef struct { - MrvlIEtypesHeader_t Header; /**< Header */ - - t_u8 sourceAddr[ETH_ALEN]; /**< Source MAC */ - t_u8 bssid[ETH_ALEN]; /**< BSSID MAC */ - t_s16 rssi; /**< Avg RSSI of frames */ - t_u16 frameCnt; /**< # of frames */ -} __ATTRIB_PACK__ MrvlIEtypes_ChanRptFrame_t; - -#ifdef OPCHAN -typedef struct { - MrvlIEtypesHeader_t header; - /**< Header */ - - MrvlChannelDesc_t chanDesc; - - t_u16 controlFlags; - t_u16 reserved; - - t_u8 actPower; - t_u8 mdMinPower; - t_u8 mdMaxPower; - t_u8 mdPower; - -} __ATTRIB_PACK__ MrvlIEtypes_ChanControlDesc_t; - -typedef struct { -#ifdef BIG_ENDIAN - /** Reserved */ - t_u8 reserved_4_7:4; - /** Disble channel filtering flag */ - t_u8 disable_chan_filt:1; - /** Channel scan mode passive flag */ - t_u8 passive_scan:1; - /** Multidomain scan mode */ - t_u8 multidomain_scan:1; - /** Enable probe response timeout */ - t_u8 rsp_timeout_en:1; -#else - /** Enable probe response timeout */ - t_u8 rsp_timeout_en:1; - /** Multidomain scan mode */ - t_u8 multidomain_scan:1; - /** Channel scan mode passive flag */ - t_u8 passive_scan:1; - /** Disble channel filtering flag */ - t_u8 disable_chan_filt:1; - /** Reserved */ - t_u8 reserved_4_7:4; -#endif -} __ATTRIB_PACK__ ChanScanMode_t; - -typedef struct { - MrvlIEtypesHeader_t header; - /**< Header */ - - t_u32 chanGroupBitmap; - ChanScanMode_t scanMode; - t_u8 numChan; - - MrvlChannelDesc_t chanDesc[50]; - -} __ATTRIB_PACK__ MrvlIEtypes_ChanGroupControl_t; - -typedef struct { - t_u16 action; - /**< CMD Action Get/Set*/ - - t_u8 tlv_buffer[1]; - -} __ATTRIB_PACK__ HostCmd_DS_OPCHAN_CONFIG; - -typedef struct { - t_u16 action; - /**< CMD Action Get/Set*/ - - t_u8 tlv_buffer[1]; - -} __ATTRIB_PACK__ HostCmd_DS_OPCHAN_CHANGROUP_CONFIG; -#endif - -typedef struct { - t_u8 modGroup; - t_u8 txPower; - -} __ATTRIB_PACK__ MrvlChanTrpcEntry_t; - -typedef struct { - MrvlIEtypesHeader_t header; - /**< Header */ - - MrvlChannelDesc_t chanDesc; - MrvlChanTrpcEntry_t chanTrpcEntry[1]; - -} __ATTRIB_PACK__ MrvlIEtypes_ChanTrpcCfg_t; - -typedef struct { - t_u16 action; - /**< CMD Action Get/Set*/ - t_u16 reserved; - - t_u8 tlv_buffer[1];/** MrvlIEtypes_ChanTrpcCfg_t TLVs */ - -} __ATTRIB_PACK__ HostCmd_DS_CHAN_TRPC_CONFIG; - -typedef struct { - t_u8 controlSelect; - - t_u8 controlBitmap[1]; /* Variable length # of byte bitmaps */ - -} __ATTRIB_PACK__ HostCmd_DS_OFFLOAD_FEATURE_CONTROL; - -#define IAPP_DATA_MAX 1000 - -/** - * @brief Enumeration for the command result from an IAPP Proxy command - */ -typedef enum { - IAPP_PROXY_RESULT_SUCCESS = 0, - IAPP_PROXY_RESULT_EXEC_FAILURE = 1, - IAPP_PROXY_RESULT_TIMEOUT = 2, - IAPP_PROXY_RESULT_DATA_INVALID = 3, -} __ATTRIB_PACK__ mlan_iapp_proxy_result_e; - -typedef struct { - mlan_iapp_proxy_result_e commandResult; - /**< Firmware execution result */ - - t_u32 timeout_ms; /**< Timeout value in milliseconds */ - - t_u8 iappType; - t_u8 iappSubType; - - t_u32 iappDataLen; - t_u8 iappData[IAPP_DATA_MAX]; - -} __ATTRIB_PACK__ HostCmd_DS_IAPP_PROXY; - -typedef struct { - /** Action: GET/SET */ - t_u16 Action; - /** Reserved */ - t_u16 Reserved; - /** Association timeout */ - t_u32 AssocTimeout; - /** Reassociation timeout */ - t_u32 ReassocTimeout; - /** Hand shake timeout */ - t_u32 HandShakeTimeout; - /** Frame exchange timeout */ - t_u32 FrameExchangeTimeout; - /** Deauth of old AP in millisec; 0 to disable */ - t_u32 PriorApDeauthDelay; - /** Maximum time after a disconnect where a reassoc frame will be sent */ - t_u32 ReassocDiscMax; -} __ATTRIB_PACK__ HostCmd_DS_AssociationTiming_t; - -/** 16 bit unsigned integer */ -typedef t_u16 IEEEtypes_AId_t; -/** 16 bit unsigned integer */ -typedef t_u16 IEEEtypes_StatusCode_t; - -typedef struct { - /** Capability information */ - IEEEtypes_CapInfo_t Capability; - /** Association response status code */ - IEEEtypes_StatusCode_t StatusCode; - /** Association ID */ - IEEEtypes_AId_t AId; - /** IE data buffer */ - t_u8 IEBuffer[1]; -} __ATTRIB_PACK__ IEEEtypes_AssocRsp_t; - -/** Maximum number of AC QOS queues available in the driver/firmware */ -#define MAX_AC_QUEUES 4 - -/** timing select structure */ -typedef struct { - char *str; /**< Timing mode string */ - int match_len; /**< match length */ - t_u8 sel; /**< flag */ - -} timing_sel_t; - -/** ENUM definition: reg_chan_table */ -typedef enum { - REGTABLE_DEFAULT = 0, - REGTABLE_ESS = 1, - REGTABLE_USER = 2, - REGTABLE_MULTIDOMAIN = 3, - - REGTABLE_MAX = 0xFFFF, -} reg_chan_table_e; - -/** Sub-command callback */ -typedef int (*sub_cmd_callback_t) (int argc, char *argv[]); - -/** Sub-command execution data */ -typedef struct { - char *str; - /**< Command string */ - int match_len; - /**< Length */ - int display; - /**< display as valid cmd */ - sub_cmd_callback_t callback; - /**< Sub-command callback */ - -} sub_cmd_exec_t; - -/** HostCmd_CMD_802_11_RF_TX_POWER */ -typedef struct { - t_u16 action; - t_s16 current_level; - t_s8 max_power; - t_s8 min_power; - -} __ATTRIB_PACK__ HostCmd_DS_802_11_RF_TX_POWER; - -/** HostCmd_CMD_802_11_AUTHENTICATE */ -typedef struct { - /** MAC address */ - t_u8 MacAddr[ETH_ALEN]; - /** Authentication type */ - t_u8 AuthType; -} __ATTRIB_PACK__ HostCmd_DS_802_11_AUTHENTICATE; - -boolean reg_class_table_select(char *tableStr, reg_chan_table_e *pTable); -int process_sub_cmd(sub_cmd_exec_t *sub_cmd, int num_sub_cmds, - int argc, char *argv[]); -int process_regclass(int argc, char *argv[]); -int process_scanagent(int argc, char *argv[]); -int process_measurement(int argc, char *argv[]); -int process_profile_entry(int argc, char *argv[]); -int process_get_ra_config(int argc, char *argv[]); -int process_set_ra_config(int argc, char *argv[]); -int process_chanrpt(int argc, char *argv[]); -int process_assoc_timing(int argc, char *argv[]); -int process_get_assocrsp(int argc, char *argv[]); -int process_link_stats(int argc, char *argv[]); - -int process_opchan(int argc, char *argv[]); -int process_changroup(int argc, char *argv[]); -int process_fcontrol(int argc, char *argv[]); -int process_iapp(int argc, char *argv[]); -int process_rf_tx_power(int argc, char *argv[]); -int process_authenticate(int argc, char *argv[]); -int process_txpowdisp(int argc, char *argv[]); - -#endif /* _MLANOFFLOAD_H_ */ diff --git a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanregclass.c b/mxm_wifiex/wlan_src/mapp/mlanutl/mlanregclass.c deleted file mode 100644 index cadb35e..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanregclass.c +++ /dev/null @@ -1,540 +0,0 @@ -/** @file mlanregclass.c - * - * @brief This files contains mlanutl regclass command handling. - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 08/11/2009: initial version -************************************************************************/ - -#include "mlanutl.h" -#include "mlanhostcmd.h" -#include "mlanoffload.h" -#include "mlanregclass.h" - -/******************************************************** - Local Variables -********************************************************/ - -/******************************************************** - Global Variables -********************************************************/ - -/******************************************************** - Local Functions -********************************************************/ - -/** - * @brief Convert reg domain number to string - * - * @param reg_domain Reg Domain - * - * @return Reg Domain type - */ -static char * -reg_domain_to_str(reg_domain_e reg_domain) -{ - switch (reg_domain) { - case REGDOMAIN_FCC: - return "FCC"; - - case REGDOMAIN_ETSI: - return "ETSI"; - - case REGDOMAIN_MIC: - return "MIC"; - - case REGDOMAIN_OTHER: - return "MULTI"; - - default: - break; - } - - return "UNKN"; -} - -/** - * @brief Convert reg channel table number to string - * - * @param table_select Reg channel table - * - * @return Reg channel table type - */ -static char * -table_num_to_str(reg_chan_table_e table_select) -{ - switch (table_select) { - case REGTABLE_USER: - return "User"; - - case REGTABLE_MULTIDOMAIN: - return "MultiDomain"; - - case REGTABLE_ESS: - return "ESS"; - - case REGTABLE_DEFAULT: - return "Default"; - - default: - break; - } - - return "UNKN"; -} - -/** - * @brief Regclass dump channel table - * - * @param argc Number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -reg_class_dump_chan_table(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_REGCLASS_GET_CHAN_TABLE *get_table; - int idx; - t_u16 regLimits; - boolean invalid_cmd = FALSE; - - printf("ERR:Cannot allocate buffer for command!\n"); - if (argv[0] == NULL) { - invalid_cmd = TRUE; - } else { - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *) - malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, - strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = - (HostCmd_DS_GEN *)(buffer + cmd_header_len + - sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - cmd_len = S_DS_GEN + sizeof(HostCmd_DS_REGCLASS_GET_CHAN_TABLE); - hostcmd->command = cpu_to_le16(HostCmd_CMD_REGCLASS_CHAN_TABLE); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - get_table = (HostCmd_DS_REGCLASS_GET_CHAN_TABLE *)pos; - get_table->action = cpu_to_le16(HostCmd_ACT_GEN_GET); - - if (reg_class_table_select(argv[0], (reg_chan_table_e *) - &get_table->table_select) == FALSE) { - invalid_cmd = TRUE; - } - } - - if (invalid_cmd) { - printf("\nValid tables table; valid [user, md, ess, default]\n\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - get_table->table_select = cpu_to_le16((t_u16)(get_table->table_select)); - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[regClassIoctl]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - if (!le16_to_cpu(hostcmd->result)) { - printf("HOSTCMD_RESP: ReturnCode=%#04x, Result=%#04x\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } else { - printf("HOSTCMD failed: ReturnCode=%#04x, Result=%#04x\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } - - get_table->table_select = le16_to_cpu(get_table->table_select); - get_table->chan = le32_to_cpu(get_table->chan); - - printf("---------------------------------------"); - printf("---------------------------------------\n"); - printf("%35s: %s [%d]\n", "Channel Table", - table_num_to_str(get_table->table_select), (int)get_table->chan); - printf("---------------------------------------"); - printf("---------------------------------------\n"); - printf(" chn | freq | sfrq | sp | class | maxP | behavior limits\n"); - printf("---------------------------------------"); - printf("---------------------------------------\n"); - - for (idx = 0; (unsigned int)idx < get_table->chan; idx++) { - char regDisp[8]; - - sprintf(regDisp, "%4s-%02u", - reg_domain_to_str(get_table->chan_entry[idx]. - reg_domain), - get_table->chan_entry[idx].regulatory_class); - - printf(" %03u | %04u | %04u | %02u | %-8s | %02u |", - get_table->chan_entry[idx].chan_num, - (get_table->chan_entry[idx].start_freq + - (get_table->chan_entry[idx].chan_num * 5)), - le16_to_cpu(get_table->chan_entry[idx].start_freq), - le16_to_cpu(get_table->chan_entry[idx].chan_spacing), - regDisp, get_table->chan_entry[idx].max_tx_power); - - regLimits = le16_to_cpu(get_table->chan_entry[idx].reg_limits); - - if (regLimits & BLIMIT_NOMADIC) - printf(" nomadic"); - if (regLimits & BLIMIT_INDOOR_ONLY) - printf(" indoor"); - if (regLimits & BLIMIT_TPC) - printf(" tpc"); - if (regLimits & BLIMIT_DFS) - printf(" dfs"); - if (regLimits & BLIMIT_IBSS_PROHIBIT) - printf(" no_ibss"); - if (regLimits & BLIMIT_FOUR_MS_CS) - printf(" 4ms_cs"); - if (regLimits & BLIMIT_LIC_BASE_STA) - printf(" base_sta"); - if (regLimits & BLIMIT_MOBILE_STA) - printf(" mobile"); - if (regLimits & BLIMIT_PUBLIC_SAFETY) - printf(" safety"); - if (regLimits & BLIMIT_ISM_BANDS) - printf(" ism"); - - printf("\n"); - } - printf("---------------------------------------"); - printf("---------------------------------------\n"); - printf("\n"); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Regclass configure user table - * - * @param argc Number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -reg_class_config_user_table(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_REGCLASS_CONFIG_USER_TABLE *cfg_user_table; - - if (argv[0] == NULL) { - printf("\nCountry string not specified\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - cmd_len = S_DS_GEN + sizeof(HostCmd_DS_REGCLASS_CONFIG_USER_TABLE); - hostcmd->command = cpu_to_le16(HostCmd_CMD_REGCLASS_CONFIG_USER_TABLE); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - cfg_user_table = (HostCmd_DS_REGCLASS_CONFIG_USER_TABLE *)pos; - cfg_user_table->action = cpu_to_le16(HostCmd_ACT_GEN_SET); - memcpy(cfg_user_table->regulatory_str, - argv[0], - MIN(strlen(argv[0]), sizeof(cfg_user_table->regulatory_str))); - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[regClassIoctl]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - if (!le16_to_cpu(hostcmd->result)) { - printf("HOSTCMD_RESP: ReturnCode=%#04x, Result=%#04x\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } else { - printf("HOSTCMD failed: ReturnCode=%#04x, Result=%#04x\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue regclass multi-domain command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -reg_class_multidomain(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_REGCLASS_MULTIDOMAIN_CONTROL *multidomain_ctrl; - boolean invalid_cmd = FALSE; - - if (argv[0] == NULL) { - invalid_cmd = TRUE; - } else { - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *) - malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, - strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = - (HostCmd_DS_GEN *)(buffer + cmd_header_len + - sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - cmd_len = - S_DS_GEN + - sizeof(HostCmd_DS_REGCLASS_MULTIDOMAIN_CONTROL); - hostcmd->command = - cpu_to_le16(HostCmd_CMD_REGCLASS_MULTIDOMAIN_CONTROL); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - multidomain_ctrl = - (HostCmd_DS_REGCLASS_MULTIDOMAIN_CONTROL *)pos; - if (strcmp(argv[0], "on") == 0) { - multidomain_ctrl->multidomain_enable = 1; - } else if (strcmp(argv[0], "off") == 0) { - multidomain_ctrl->multidomain_enable = 0; - } else { - invalid_cmd = TRUE; - } - } - - if (invalid_cmd) { - printf("\nUnknown multiDomain command; valid [on, off]\n\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - multidomain_ctrl->multidomain_enable = - cpu_to_le32(multidomain_ctrl->multidomain_enable); - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[regClass]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } else { - printf("\nMultiDomain: %s\n", - le32_to_cpu(multidomain_ctrl->multidomain_enable) ? - "Enabled" : "Disabled"); - } - - if (!le16_to_cpu(hostcmd->result)) { - printf("HOSTCMD_RESP: ReturnCode=%#04x, Result=%#04x\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } else { - printf("HOSTCMD failed: ReturnCode=%#04x, Result=%#04x\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue a regclass command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_regclass(int argc, char *argv[]) -{ - sub_cmd_exec_t sub_cmd[] = { {"table", 1, 1, reg_class_dump_chan_table}, - {"multidomain", 1, 1, reg_class_multidomain}, - {"country", 1, 1, reg_class_config_user_table} - }; - - return process_sub_cmd(sub_cmd, NELEMENTS(sub_cmd), argc, argv); -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanregclass.h b/mxm_wifiex/wlan_src/mapp/mlanutl/mlanregclass.h deleted file mode 100644 index 67913c3..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanregclass.h +++ /dev/null @@ -1,100 +0,0 @@ -/** @file mlanregclass.h - * - * @brief This files contains mlanutl regclass command handling. - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 08/11/2009: initial version -************************************************************************/ - -#ifndef _MLANREGCLASS_H -#define _MLANREGCLASS_H - -/** Nomadic */ -#define BLIMIT_NOMADIC (1 << 0) -/** Indoor */ -#define BLIMIT_INDOOR_ONLY (1 << 1) -/** Tpc */ -#define BLIMIT_TPC (1 << 2) -/** Dfs */ -#define BLIMIT_DFS (1 << 3) -/** IBSS Prohibit */ -#define BLIMIT_IBSS_PROHIBIT (1 << 4) -/** Four MS CS */ -#define BLIMIT_FOUR_MS_CS (1 << 5) -/** LIC Base STA */ -#define BLIMIT_LIC_BASE_STA (1 << 6) -/** Mobile STA */ -#define BLIMIT_MOBILE_STA (1 << 7) -/** Public Safety */ -#define BLIMIT_PUBLIC_SAFETY (1 << 8) -/** ISM Bands */ -#define BLIMIT_ISM_BANDS (1 << 9) - -/** Enum Definitions: reg_domain */ -typedef enum { - REGDOMAIN_NULL = 0x00, - - REGDOMAIN_FCC = 0x01, - REGDOMAIN_ETSI = 0x02, - REGDOMAIN_MIC = 0x03, - - REGDOMAIN_OTHER = 0xFF, - -} reg_domain_e; - -typedef struct { - t_u8 reg_domain; /**< Domain */ - t_u8 regulatory_class; - /**< Regulatory class */ - t_u8 chan_num; /**< Channel Number */ - t_u8 reserved1; /**< Reserved */ - t_u16 start_freq; /**< Start frequency */ - t_u16 chan_spacing; /**< channel spacing */ - t_u8 max_tx_power; /**< Max. tx power */ - t_u8 coverage_class;/**< Coverage class */ - t_u16 reg_limits; /**< Limits */ -} __ATTRIB_PACK__ chan_entry_t; - -typedef struct { - /** Action: GET/SET */ - t_u16 action; - /** Reg channel table */ - t_u16 table_select; - /** Channel number */ - t_u32 chan; - /** Channel entry */ - chan_entry_t chan_entry[75]; -} __ATTRIB_PACK__ HostCmd_DS_REGCLASS_GET_CHAN_TABLE; - -typedef struct { - t_u16 action; - /**< Action: GET/SET */ - t_u16 reserved; - /**< Reserved */ - char regulatory_str[3];/**< Regulatory String */ -} __ATTRIB_PACK__ HostCmd_DS_REGCLASS_CONFIG_USER_TABLE; - -typedef struct { - t_u32 multidomain_enable; - /**< Multi domain enable */ -} __ATTRIB_PACK__ HostCmd_DS_REGCLASS_MULTIDOMAIN_CONTROL; - -#endif /* _MLANREGCLASS_H */ diff --git a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanroamagent.c b/mxm_wifiex/wlan_src/mapp/mlanutl/mlanroamagent.c deleted file mode 100644 index 95415fd..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanroamagent.c +++ /dev/null @@ -1,3670 +0,0 @@ -/** @file mlanroamagent.c - * - * @brief This files contains mlanutl roamagent command handling. - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 08/11/2009: initial version -************************************************************************/ - -#include "mlanutl.h" -#include "mlanhostcmd.h" -#include "mlanoffload.h" -#include "mlanroamagent.h" - -/******************************************************** - Local Variables -********************************************************/ - -/******************************************************** - Global Variables -********************************************************/ - -/******************************************************** - Local Functions -********************************************************/ - -/** - * @brief Issue getra failcnt command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamGetFailureCount(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - int failCount, failTimeThresh, state, i; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *statsthreshold; - MrvlIEtypes_FailureCount_t *pFailureCount; - MrvlIEtypesHeader_t *pTlvHdr; - t_u8 *tlvptr; - const char *states[] = - { "Stable", "Degrading", "Unacceptable", "Hardroam" }; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - statsthreshold = (HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *)pos; - cmd_len = - (S_DS_GEN + - sizeof(HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD) - - sizeof(statsthreshold->TlvBuffer)); - - /* Can be extended to all states later */ - for (state = STATE_HARDROAM - 1; state < STATE_HARDROAM; state++) { - statsthreshold->State = state + 1; - hostcmd->command = - cpu_to_le16(HostCmd_CMD_ROAMAGENT_STATISTICS_THRESHOLD); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - statsthreshold->action = cpu_to_le16(HostCmd_ACT_GEN_GET); - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[roamstatistics]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - i = le16_to_cpu(hostcmd->size); - i -= cmd_len; - tlvptr = statsthreshold->TlvBuffer; - - while (i > 2) { - pTlvHdr = (MrvlIEtypesHeader_t *)tlvptr; - - switch (le16_to_cpu(pTlvHdr->type)) { - case TLV_TYPE_FAILCOUNT: - pFailureCount = - (MrvlIEtypes_FailureCount_t *)pTlvHdr; - failCount = pFailureCount->fail_value; - failTimeThresh = - le16_to_cpu(pFailureCount-> - fail_min_thresh_time_millisecs); - break; - } - - tlvptr += (le16_to_cpu(pTlvHdr->len) - + sizeof(MrvlIEtypesHeader_t)); - i -= (le16_to_cpu(pTlvHdr->len) - + sizeof(MrvlIEtypesHeader_t)); - } - - printf("State: %-8s. FailCount = %d, FailTimeThresh(ms) = %d\n", - states[state], failCount, failTimeThresh); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue getra bcnmiss command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamGetPreBeaconMiss(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - int bcnmiss, state = STATE_HARDROAM, i; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *statsthreshold; - MrvlIEtypes_BeaconsMissed_t *pBeaconMissed; - MrvlIEtypesHeader_t *pTlvHdr; - t_u8 *tlvptr; - const char *states[] = - { "Stable", "Degrading", "Unacceptable", "Hardroam" }; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - statsthreshold = (HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *)pos; - cmd_len = - (S_DS_GEN + - sizeof(HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD) - - sizeof(statsthreshold->TlvBuffer)); - - /* Can be extended to all states later */ - for (state = STATE_HARDROAM - 1; state < STATE_HARDROAM; state++) { - statsthreshold->State = state + 1; - hostcmd->command = - cpu_to_le16(HostCmd_CMD_ROAMAGENT_STATISTICS_THRESHOLD); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - statsthreshold->action = cpu_to_le16(HostCmd_ACT_GEN_GET); - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[beacon miss]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - i = le16_to_cpu(hostcmd->size); - i -= cmd_len; - tlvptr = statsthreshold->TlvBuffer; - - while (i > 2) { - pTlvHdr = (MrvlIEtypesHeader_t *)tlvptr; - - switch (le16_to_cpu(pTlvHdr->type)) { - - case TLV_TYPE_PRE_BEACON_LOST: - pBeaconMissed = - (MrvlIEtypes_BeaconsMissed_t *)pTlvHdr; - bcnmiss = pBeaconMissed->beacon_missed; - } - - tlvptr += (le16_to_cpu(pTlvHdr->len) - + sizeof(MrvlIEtypesHeader_t)); - i -= (le16_to_cpu(pTlvHdr->len) - + sizeof(MrvlIEtypesHeader_t)); - } - - printf("State: %-8s. Pre Beacon missed threshold %d\n", - states[state], bcnmiss); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue getra rssi/snr command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * @param type RSSI/SNR threshold type - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamGetStatsThreshold(int argc, char *argv[], int type) -{ - int ret = MLAN_STATUS_SUCCESS; - int state = 0, i = 0, profile = 1; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *statsthreshold; - MrvlIEtypes_BeaconHighRssiThreshold_t *pHighRssiThreshold; - MrvlIEtypes_BeaconLowRssiThreshold_t *pLowRssiThreshold; - MrvlIEtypes_BeaconHighSnrThreshold_t *pHighSnrThreshold; - MrvlIEtypes_BeaconLowSnrThreshold_t *pLowSnrThreshold; - t_s8 high, low; - t_u8 *tlvptr; - t_u16 tlv; - const char *states[] = { "Stable", "Degrading", "Unacceptable" }; - - if (argc) { - if (strncmp(argv[0], "configured", strlen("config")) == 0) { - profile = 0; - } else if (strncmp(argv[0], "active", strlen("active"))) { - printf("\nIncorrect parameter %s for getra command\n\n", - argv[0]); - ret = MLAN_STATUS_FAILURE; - goto done; - } - } - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - statsthreshold = (HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *)pos; - cmd_len = - (S_DS_GEN + - sizeof(HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD) - - sizeof(statsthreshold->TlvBuffer)); - - printf("---------------------------------------------\n"); - if (type == RSSI_THRESHOLD) { - printf(" RSSI Thresholds\n"); - } else { - printf(" SNR Thresholds\n"); - } - printf("---------------------------------------------\n"); - - for (state = STATE_STABLE - 1; state < STATE_UNACCEPTABLE; state++) { - statsthreshold->State = state + 1; - statsthreshold->Profile = profile; - hostcmd->command = - cpu_to_le16(HostCmd_CMD_ROAMAGENT_STATISTICS_THRESHOLD); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - statsthreshold->action = cpu_to_le16(HostCmd_ACT_GEN_GET); - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[roamstatistics]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - if (le16_to_cpu(hostcmd->result)) { - printf("\nHostCmd Error: ReturnCode=%#04x, Result=%#04x\n\n", le16_to_cpu(hostcmd->command), le16_to_cpu(hostcmd->result)); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - i = le16_to_cpu(hostcmd->size); - i -= cmd_len; - tlvptr = statsthreshold->TlvBuffer; - while (i > 2) { - /* - * ENDIANNESS for Response - */ - tlv = le16_to_cpu(*((t_u16 *)(tlvptr))); - - switch (tlv) { - case TLV_TYPE_RSSI_HIGH: - high = *(t_s8 *)(tlvptr + sizeof(t_u16) + - sizeof(t_u16)); - pHighRssiThreshold = - (MrvlIEtypes_BeaconHighRssiThreshold_t - *)(tlvptr); - tlvptr += - (le16_to_cpu - (pHighRssiThreshold->Header.len) + - sizeof(MrvlIEtypesHeader_t)); - i -= (le16_to_cpu - (pHighRssiThreshold->Header.len) + - sizeof(MrvlIEtypesHeader_t)); - break; - - case TLV_TYPE_RSSI_LOW: - low = *(t_s8 *)(tlvptr + sizeof(t_u16) + - sizeof(t_u16)); - pLowRssiThreshold = - (MrvlIEtypes_BeaconLowRssiThreshold_t - *)(tlvptr); - tlvptr += - (le16_to_cpu - (pLowRssiThreshold->Header.len) + - sizeof(MrvlIEtypesHeader_t)); - i -= (le16_to_cpu(pLowRssiThreshold->Header.len) - + sizeof(MrvlIEtypesHeader_t)); - break; - - case TLV_TYPE_SNR_HIGH: - high = *(t_s8 *)(tlvptr + sizeof(t_u16) + - sizeof(t_u16)); - pHighSnrThreshold = - (MrvlIEtypes_BeaconHighSnrThreshold_t - *)(tlvptr); - tlvptr += - (le16_to_cpu - (pHighSnrThreshold->Header.len) + - sizeof(MrvlIEtypesHeader_t)); - i -= (le16_to_cpu(pHighSnrThreshold->Header.len) - + sizeof(MrvlIEtypesHeader_t)); - break; - - case TLV_TYPE_SNR_LOW: - low = *(t_s8 *)(tlvptr + sizeof(t_u16) + - sizeof(t_u16)); - pLowSnrThreshold = - (MrvlIEtypes_BeaconLowSnrThreshold_t - *)(tlvptr); - tlvptr += - (le16_to_cpu - (pLowSnrThreshold->Header.len) + - sizeof(MrvlIEtypesHeader_t)); - i -= (le16_to_cpu(pLowSnrThreshold->Header.len) - + sizeof(MrvlIEtypesHeader_t)); - break; - } - } - - printf("%-13s| High = %4d | Low = %4d |\n", - states[state], high, low); - } - puts(""); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue getra rssi/snr command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamGetRssiStatsThreshold(int argc, char *argv[]) -{ - return roamGetStatsThreshold(argc, argv, RSSI_THRESHOLD); -} - -/** - * @brief Coverts ms to exactTime - * - * @param ms number of milliseconds - * @param t converted into this structure - * - * @return none - */ -static void -ms2exactTime(t_u32 ms, ExactTime_t *t) -{ - memset(t, 0, sizeof(ExactTime_t)); - - t->msecs = ms % 1000; - if (ms >= 1000) { - ms = (ms - t->msecs) / 1000; - t->secs = ms % 60; - if (ms >= 60) { - ms = (ms - t->secs) / 60; - t->mins = ms % 60; - if (ms >= 60) { - ms = (ms - t->mins) / 60; - t->hrs = ms; - } - } - } - return; -} - -/** - * @brief Issue getra neighbor assessment command - * - * @pNborAssessment neighbour assessment struct - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -getNborAssessment(HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_ASSESSMENT - *pNborAssessmentParam) -{ - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_ASSESSMENT *pNborAssessment; - - /* - * NEIGHBOR_ASSESSMENT - */ - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - pNborAssessment = (HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_ASSESSMENT *)pos; - cmd_len = S_DS_GEN + sizeof(pNborAssessment->action); - pNborAssessment->action = cpu_to_le16(HostCmd_ACT_GEN_GET); - hostcmd->command = - cpu_to_le16(HostCmd_CMD_ROAMAGENT_NEIGHBOR_ASSESSMENT); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[GetNeibhorAssesinfo]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - /* - * ENDIANNESS for Response - */ - pNborAssessment->QualifyingNumNeighbor = - le16_to_cpu(pNborAssessment->QualifyingNumNeighbor); - pNborAssessment->ShortBlacklistPeriod = - le32_to_cpu(pNborAssessment->ShortBlacklistPeriod); - pNborAssessment->LongBlacklistPeriod = - le32_to_cpu(pNborAssessment->LongBlacklistPeriod); - pNborAssessment->StaleCount = le16_to_cpu(pNborAssessment->StaleCount); - pNborAssessment->StalePeriod = - le32_to_cpu(pNborAssessment->StalePeriod); - - memcpy((void *)pNborAssessmentParam, (void *)pNborAssessment, - sizeof(HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_ASSESSMENT)); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Display exactTime structure elements - * - * @param t ExactTime_t struct - * - * @return None - */ -static void -printExactTime2stdout(ExactTime_t *t) -{ - int flag = 0; - if (t->hrs) { - printf("%dh ", t->hrs); - flag = 1; - } - if (t->mins) { - printf("%dm ", t->mins); - flag = 1; - } - if (t->secs) { - printf("%ds ", t->secs); - flag = 1; - } - if (t->msecs) { - printf("%dms", t->msecs); - flag = 1; - } - if (!flag) { - printf(" 0"); - } -} - -static int -printNeighborAssessmentConfig(void) -{ - HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_ASSESSMENT nborAssessment; - int idx; - int threshDisp = FALSE; - - if (getNborAssessment(&nborAssessment) != MLAN_STATUS_SUCCESS) { - return MLAN_STATUS_FAILURE; - } - - printf("----------------------------------------------------------\n"); - printf(" Neighbor Threshold Parameters\n"); - printf("----------------------------------------------------------\n"); - printf(" Neighbors needed for tracking mode = %d\n", - nborAssessment.QualifyingNumNeighbor); - printf(" Config RSSI qualification offset = %d dB\n", - nborAssessment.ConfQualSignalStrength); - printf(" Active RSSI qualification offset = %d dB\n", - nborAssessment.ActiveQualSignalStrength); - printf(" Short black list period = %d ms\n", - (int)nborAssessment.ShortBlacklistPeriod); - printf(" Long black list period = %d ms\n", - (int)nborAssessment.LongBlacklistPeriod); - printf(" Stale count = %d\n", - (int)nborAssessment.StaleCount); - printf(" Stale period = %d ms\n", - (int)nborAssessment.StalePeriod); - printf(" Proactive Roaming Thresholds ="); - for (idx = 0; idx < NELEMENTS(nborAssessment.RoamThresh); idx++) { - if (nborAssessment.RoamThresh[idx].RssiNborDiff) { - if (threshDisp) { - printf(" "); - } - - threshDisp = TRUE; - printf("%3d to %4d [%d]\n", - nborAssessment.RoamThresh[idx].RssiHighLevel, - nborAssessment.RoamThresh[idx].RssiLowLevel, - nborAssessment.RoamThresh[idx].RssiNborDiff); - } - } - - if (!threshDisp) { - puts(" < None >"); - } - puts(""); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Issue getra neighbors command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamGetNborList(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - int cmdresplen, i; - struct ifreq ifr; - char neighflag[6]; - ExactTime_t t; - t_u16 tlv; - t_u8 *buffer = NULL, *pos = NULL, *tlvptr = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CMD_ROAMAGENT_NEIGHBORLIST *pNborList; - MrvlIEtypes_NeighborEntry_t *pNeighbor; - - /* - * NEIGHBOR_LIST - */ - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - pNborList = (HostCmd_DS_CMD_ROAMAGENT_NEIGHBORLIST *)pos; - cmd_len = S_DS_GEN + sizeof(pNborList->action); - pNborList->action = cpu_to_le16(HostCmd_ACT_GEN_GET); - hostcmd->command = cpu_to_le16(HostCmd_CMD_ROAMAGENT_NEIGHBORLIST); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[roamneighborlist]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - cmdresplen = le16_to_cpu(hostcmd->size); - cmdresplen -= cmd_len + sizeof(pNborList->Reserved); - tlvptr = pNborList->TlvBuffer; - - printf("----------------------------------------------------" - "--------------\n"); - printf(" BSSID | RSSI | Age | Qualified |" - " Blacklist Duration\n"); - printf("----------------------------------------------------" - "--------------\n"); - - i = 0; - - while (cmdresplen > 2) { - i++; - /* - * ENDIANNESS for Response - */ - tlv = le16_to_cpu(*((t_u16 *)(tlvptr))); - switch (tlv) { - case TLV_TYPE_NEIGHBOR_ENTRY: - pNeighbor = (MrvlIEtypes_NeighborEntry_t *)(tlvptr); - pNeighbor->SignalStrength = - le16_to_cpu(pNeighbor->SignalStrength); - pNeighbor->Age = le16_to_cpu(pNeighbor->Age); - pNeighbor->QualifiedNeighborBitmap = - le32_to_cpu(pNeighbor->QualifiedNeighborBitmap); - - pNeighbor->BlackListDuration = - le32_to_cpu(pNeighbor->BlackListDuration); - ms2exactTime(pNeighbor->BlackListDuration, &t); - neighflag[0] = '\0'; - - if ((pNeighbor->QualifiedNeighborBitmap - & (BIT_NEIGHFLAG_RSSI - | BIT_NEIGHFLAG_AGE - | BIT_NEIGHFLAG_BLACKLIST - | BIT_NEIGHFLAG_ADMISSION_CAP - | BIT_NEIGHFLAG_UPLINK_RSSI)) - == (BIT_NEIGHFLAG_RSSI - | BIT_NEIGHFLAG_AGE - | BIT_NEIGHFLAG_BLACKLIST - | BIT_NEIGHFLAG_ADMISSION_CAP - | BIT_NEIGHFLAG_UPLINK_RSSI)) { - strcat(neighflag, "Yes"); - } else { - strcat(neighflag, "No: "); - if (! - (pNeighbor-> - QualifiedNeighborBitmap & - BIT_NEIGHFLAG_RSSI)) { - strcat(neighflag, "R"); - } - if (! - (pNeighbor-> - QualifiedNeighborBitmap & - BIT_NEIGHFLAG_AGE)) { - strcat(neighflag, "S"); - } - if (!(pNeighbor->QualifiedNeighborBitmap - & BIT_NEIGHFLAG_BLACKLIST)) { - strcat(neighflag, "B"); - } - if (!(pNeighbor->QualifiedNeighborBitmap - & BIT_NEIGHFLAG_ADMISSION_CAP)) { - strcat(neighflag, "A"); - } - if (!(pNeighbor->QualifiedNeighborBitmap - & BIT_NEIGHFLAG_UPLINK_RSSI)) { - strcat(neighflag, "U"); - } - } - printf(" %02x:%02x:%02x:%02x:%02x:%02x | %3d | %5d | %9s | ", pNeighbor->Bssid[0], pNeighbor->Bssid[1], pNeighbor->Bssid[2], pNeighbor->Bssid[3], pNeighbor->Bssid[4], pNeighbor->Bssid[5], pNeighbor->SignalStrength, pNeighbor->Age, neighflag); - - if (pNeighbor->BlackListDuration) { - printExactTime2stdout(&t); - } else { - printf("Not Blacklisted"); - } - printf("\n"); - - tlvptr += (le16_to_cpu(pNeighbor->Header.len) + - sizeof(MrvlIEtypesHeader_t)); - cmdresplen -= (le16_to_cpu(pNeighbor->Header.len) + - sizeof(MrvlIEtypesHeader_t)); - break; - - default: - printf("\nIncorrect response.\n\n"); - break; - } - } - - if (i == 0) { - printf("< Empty >\n"); - } - - printf("\n"); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue getra neighbor params command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamGetNborParams(int argc, char *argv[]) -{ - printNeighborAssessmentConfig(); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Issue getra metrics command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamGetMetrics(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - int i; - t_u16 Metrics = 0; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CMD_ROAMAGENT_ADV_METRIC_THRESHOLD *metricscmd; - - const char *metricslist[] = { "beacon", "data", "per", "fer" }; - - if (argc != 0) { - puts("\nIncorrect number of arguments.\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - metricscmd = (HostCmd_DS_CMD_ROAMAGENT_ADV_METRIC_THRESHOLD *)pos; - cmd_len = S_DS_GEN + sizeof(metricscmd->action); - metricscmd->action = cpu_to_le16(HostCmd_ACT_GEN_GET); - hostcmd->command = - cpu_to_le16(HostCmd_CMD_ROAMAGENT_ADV_METRIC_THRESHOLD); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[roam set matrics]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - Metrics = le16_to_cpu(metricscmd->Metrics); - - if (le16_to_cpu(hostcmd->result) == MLAN_STATUS_SUCCESS) { - printf("\n Metrics Activated: "); - for (i = 0; (unsigned int)i < NELEMENTS(metricslist); i++) { - if (Metrics & BIT(i)) { - printf(" %s ", metricslist[i]); - } - } - printf("\n"); - - if (Metrics & BIT(3)) { - printf("FER Threshold : %u %% \n", - metricscmd->UcFerThresholdValue); - printf("FER Packet Threshold: %d \n", - le32_to_cpu(metricscmd->UiFerPktThreshold)); - printf("FER period. Stable : %d ms, Degrading : %d ms, " - "Unacceptable : %d ms\n", - le32_to_cpu(metricscmd->StableFERPeriod_ms), - le32_to_cpu(metricscmd->DegradingFERPeriod_ms), - le32_to_cpu(metricscmd-> - UnacceptableFERPeriod_ms)); - } - - if (Metrics & BIT(2)) { - printf("PER Threshold : %u %% \n", - metricscmd->UcPerThresholdValue); - printf("PER Packet Threshold: %d \n", - le32_to_cpu(metricscmd->UiPerPktThreshold)); - printf("PER period. Stable : %d ms, Degrading : %d ms, " - "Unacceptable : %d ms\n", - le32_to_cpu(metricscmd->StablePERPeriod_ms), - le32_to_cpu(metricscmd->DegradingPERPeriod_ms), - le32_to_cpu(metricscmd-> - UnacceptablePERPeriod_ms)); - } - - if (Metrics & BIT(1)) { - printf("Data Packet Threshold: %d \n", - le32_to_cpu(metricscmd->UiRxPktThreshold)); - } - - if ((Metrics & BIT(1)) || (Metrics & BIT(2)) || - (Metrics & BIT(3))) { - - printf("Inactivity Period: %d ms \n", - le32_to_cpu(metricscmd-> - InactivityPeriodThreshold_ms)); - } - } else { - printf("command response failure %d.\n", - le16_to_cpu(hostcmd->result)); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue getra scanperiod command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamGetScanPeriod(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - int state = 0, scanmode = 0, cmdresplen; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL, *tlvptr = NULL; - t_u16 tlv; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_SCANPERIOD_RSP *scanPeriodInfo; - MrvlIEtypes_NeighborScanPeriod_t *pscanperiod; - const char *states[] = { "Stable", "Degrading", "Unacceptable" }; - const char *scanmodes[] = { "Discovery", "Tracking" }; - /* scanperiodValues[state][scanmode] */ - t_u32 values[3][2]; - - /* - * NEIGHBOR_SCANPERIOD - */ - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - scanPeriodInfo = - (HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_SCANPERIOD_RSP *)pos; - cmd_len = S_DS_GEN + sizeof(scanPeriodInfo->action); - scanPeriodInfo->action = cpu_to_le16(HostCmd_ACT_GEN_GET); - hostcmd->command = - cpu_to_le16(HostCmd_CMD_ROAMAGENT_NEIGHBOR_SCAN_PERIOD); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[roamscanperiod]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - cmdresplen = le16_to_cpu(hostcmd->size); - cmdresplen -= cmd_len + sizeof(scanPeriodInfo->Reserved); - tlvptr = scanPeriodInfo->TlvBuffer; - while (cmdresplen > 2) { - /* - * ENDIANNESS for Response - */ - tlv = le16_to_cpu(*((t_u16 *)(tlvptr))); - switch (tlv) { - case TLV_TYPE_NEIGHBOR_SCANPERIOD: - pscanperiod = - (MrvlIEtypes_NeighborScanPeriod_t *)(tlvptr); - pscanperiod->SearchMode = - le16_to_cpu(pscanperiod->SearchMode); - pscanperiod->State = le16_to_cpu(pscanperiod->State); - pscanperiod->ScanPeriod = - le32_to_cpu(pscanperiod->ScanPeriod); - state = pscanperiod->State; - scanmode = pscanperiod->SearchMode; - if ((state < STATE_STABLE) || - (state > STATE_UNACCEPTABLE)) { - puts("\nIncorrect state in response.\n"); - } - if ((scanmode < DISCOVERY_MODE) || - (scanmode > TRACKING_MODE)) { - puts("\nIncorrect scanmode in response.\n"); - } - values[state - 1][scanmode - 1] = - pscanperiod->ScanPeriod; - tlvptr += - (le16_to_cpu(pscanperiod->Header.len) + - sizeof(MrvlIEtypesHeader_t)); - cmdresplen -= - (le16_to_cpu(pscanperiod->Header.len) + - sizeof(MrvlIEtypesHeader_t)); - break; - - default: - puts("\nIncorrect response.\n"); - break; - } - } - - for (state = STATE_STABLE - 1; state < STATE_UNACCEPTABLE; state++) { - printf("\nState: %-14s ", states[state]); - for (scanmode = DISCOVERY_MODE - 1; - scanmode < TRACKING_MODE; scanmode++) { - printf("%s = %6d ms\t", - scanmodes[scanmode], - (int)values[state][scanmode]); - } - } - printf("\n"); -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue getra command - * - * @param pcontrol control struct to return - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -getControl(HostCmd_DS_CMD_ROAMAGENT_CONTROL *pcontrol) -{ - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CMD_ROAMAGENT_CONTROL *roamcontrolcmd = NULL; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - cmd_len = S_DS_GEN + sizeof(roamcontrolcmd->action); - hostcmd->command = cpu_to_le16(HostCmd_CMD_ROAMAGENT_CONTROL); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - roamcontrolcmd = (HostCmd_DS_CMD_ROAMAGENT_CONTROL *)pos; - - roamcontrolcmd->action = cpu_to_le16(HostCmd_ACT_GEN_GET); - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[roamcontrol]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - memcpy((void *)pcontrol, - (void *)roamcontrolcmd, - sizeof(HostCmd_DS_CMD_ROAMAGENT_CONTROL)); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue getra command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * @param control roma control indicator value - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamGetEventBitmap(int argc, char *argv[]) -{ - t_u8 hostevent; - HostCmd_DS_CMD_ROAMAGENT_CONTROL roamcontrolcmd; - - if (getControl(&roamcontrolcmd) != MLAN_STATUS_SUCCESS) { - return MLAN_STATUS_FAILURE; - } - - hostevent = roamcontrolcmd.HostEvent; - if (!(hostevent | 0)) { - puts("\nHost events are disabled.\n"); - return MLAN_STATUS_SUCCESS; - } - printf("\nHost events enabled: "); - if (hostevent & HOST_EVENT_NBOR_ENABLE) - printf("neighbor "); - - if (hostevent & HOST_EVENT_ROAM_ENABLE) - printf("roam "); - - if (hostevent & HOST_EVENT_STATE_ENABLE) - printf("state"); - - printf("\n"); - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Issue getra command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * @param control roma control indicator value - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamGetControl(int argc, char *argv[]) -{ - t_u8 control; - HostCmd_DS_CMD_ROAMAGENT_CONTROL roamcontrolcmd; - - if (getControl(&roamcontrolcmd) != MLAN_STATUS_SUCCESS) { - return MLAN_STATUS_FAILURE; - } - - control = roamcontrolcmd.Control; - printf("\nGlobal roaming agent state: "); - if (control & ROAM_CONTROL_ENABLE) { - printf("enabled, "); - if (control & ROAM_CONTROL_SUSPEND) - printf("suspend.\n"); - else - printf("resume.\n"); - } else - printf("disabled.\n"); - - printf("Crossband: "); - if (control & CROSSBAND_ENABLE) - printf("enabled.\n"); - else - printf("disabled.\n"); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Internal funtion to issue getra backoff - * - * @param roambackoffcmd Backoff command structure - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -getBackOff(HostCmd_DS_CMD_ROAMAGENT_BACKOFF *roambackoffcmdParam) -{ - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CMD_ROAMAGENT_BACKOFF *roambackoffcmd; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - roambackoffcmd = (HostCmd_DS_CMD_ROAMAGENT_BACKOFF *)pos; - cmd_len = S_DS_GEN + sizeof(roambackoffcmd->action); - roambackoffcmd->action = cpu_to_le16(HostCmd_ACT_GEN_GET); - hostcmd->command = cpu_to_le16(HostCmd_CMD_ROAMAGENT_BACKOFF); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[roambackoff]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - /* - * ENDIANNESS for Response - */ - roambackoffcmd->Scans = le16_to_cpu(roambackoffcmd->Scans); - roambackoffcmd->Period = le32_to_cpu(roambackoffcmd->Period); - - memcpy((void *)roambackoffcmdParam, (void *)roambackoffcmd, - sizeof(HostCmd_DS_CMD_ROAMAGENT_BACKOFF)); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue getra backoff command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * @param control roma control indicator value - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamGetBackOff(int argc, char *argv[]) -{ - HostCmd_DS_CMD_ROAMAGENT_BACKOFF backoffcmd; - - if (getBackOff(&backoffcmd) != MLAN_STATUS_SUCCESS) { - return MLAN_STATUS_FAILURE; - } - - puts(""); - printf("----------------------------------------------------\n"); - printf(" Scanning Backoff Parameters \n"); - printf("----------------------------------------------------\n"); - printf(" Backoff period (max time in tracking) = %d ms\n", - backoffcmd.Period); - printf(" # of discovery scans before backoff = %d\n", - backoffcmd.Scans); - puts(""); - - if (backoffcmd.Scans) { - printf(" - Discovery backoff mode is enabled.\n" - " After %d discovery scans without a change in the number\n" - " of neighbors, the RA will only track the existing\n" - " neighbors until the backoff period expires.\n", - backoffcmd.Scans); - } else { - printf(" - Discovery backoff mode is disabled.\n" - " The RA will only move to tracking mode if a minimum\n" - " number of good neighbors have been found. See the\n" - " getra neighbor command for the current min setting.\n"); - } - puts(""); - - return MLAN_STATUS_SUCCESS; -} - -static int -printGetNeighborDeprecation(int argc, char *argv[]) -{ - printf("\nInfo: getra neighbor replaced with:\n" - " - getra nlist (display neighbor list)\n" - " - getra nparams (display neighbor assessment params)\n\n"); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Get the Roaming agent configuration parameters from FW. - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_get_ra_config(int argc, char *argv[]) -{ - if (argc == 3) { - return roamGetControl(argc, argv); - } - - sub_cmd_exec_t subCmds[] = { - {"rssi", 1, 1, roamGetRssiStatsThreshold}, - {"prebcnmiss", 1, 1, roamGetPreBeaconMiss}, - {"failcnt", 1, 1, roamGetFailureCount}, - {"backoff", 1, 1, roamGetBackOff}, - {"neighbor", 2, 0, printGetNeighborDeprecation}, - {"nlist", 2, 1, roamGetNborList}, - {"nparams", 2, 1, roamGetNborParams}, - {"scanperiod", 1, 1, roamGetScanPeriod}, - {"metrics", 1, 1, roamGetMetrics}, - {"event", 1, 1, roamGetEventBitmap} - }; - - return process_sub_cmd(subCmds, NELEMENTS(subCmds), argc, argv); -} - -/** - * @brief Issue setra bcnmiss command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamSetPreBeaconLoss(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - int bcnmiss; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *statsthreshold; - MrvlIEtypes_BeaconsMissed_t *beaconmiss; - - if (argc != 1) { - puts("\nIncorrect number of arguments.\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - bcnmiss = atoi(argv[0]); - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - statsthreshold = (HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *)pos; - cmd_len = sizeof(HostCmd_DS_GEN) + sizeof(statsthreshold->action) + - sizeof(statsthreshold->State) + - sizeof(statsthreshold->Profile) + - sizeof(MrvlIEtypes_BeaconsMissed_t); - - hostcmd->command = - cpu_to_le16(HostCmd_CMD_ROAMAGENT_STATISTICS_THRESHOLD); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - statsthreshold = (HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *)pos; - statsthreshold->action = cpu_to_le16(HostCmd_ACT_GEN_SET); - statsthreshold->State = STATE_HARDROAM; - - beaconmiss = (MrvlIEtypes_BeaconsMissed_t *)&statsthreshold->TlvBuffer; - beaconmiss->beacon_missed = bcnmiss; - beaconmiss->header.type = cpu_to_le16(TLV_TYPE_PRE_BEACON_LOST); - beaconmiss->header.len = - cpu_to_le16(sizeof(MrvlIEtypes_BeaconsMissed_t) - - sizeof(MrvlIEtypesHeader_t)); - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[setra]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - if (le16_to_cpu(hostcmd->result)) { - printf("\nHostCmd Error: ReturnCode=%#04x, Result=%#04x\n\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } else { - roamGetPreBeaconMiss(argc, argv); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue setra failurecnt command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamSetFailureCount(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - int failCount, failTimeThresh; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *statsthreshold; - MrvlIEtypes_FailureCount_t *failcnt; - - if (argc != 2) { - puts("\n2 arguments required: FailCnt, FailTimeThresh(ms)\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - failCount = atoi(argv[0]); - failTimeThresh = atoi(argv[1]); - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - statsthreshold = (HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *)pos; - - cmd_len = (S_DS_GEN + - sizeof(statsthreshold->action) + - sizeof(statsthreshold->State) + - sizeof(statsthreshold->Profile) + - sizeof(MrvlIEtypes_FailureCount_t)); - - hostcmd->command = - cpu_to_le16(HostCmd_CMD_ROAMAGENT_STATISTICS_THRESHOLD); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - statsthreshold->action = cpu_to_le16(HostCmd_ACT_GEN_SET); - statsthreshold->State = STATE_HARDROAM; - - failcnt = (MrvlIEtypes_FailureCount_t *)&statsthreshold->TlvBuffer; - failcnt->fail_value = failCount; - failcnt->fail_min_thresh_time_millisecs = cpu_to_le16(failTimeThresh); - failcnt->header.type = cpu_to_le16(TLV_TYPE_FAILCOUNT); - failcnt->header.len = cpu_to_le16(sizeof(MrvlIEtypes_FailureCount_t) - - sizeof(MrvlIEtypesHeader_t)); - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[setra]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - if (le16_to_cpu(hostcmd->result)) { - printf("\nHostCmd Error: ReturnCode=%#04x, Result=%#04x\n\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } else { - roamGetFailureCount(argc, argv); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue setra rssi/snr command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * @param type RSSI/SNR threshold type - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamSetStatsThreshold(int argc, char *argv[], int type) -{ - int ret = MLAN_STATUS_SUCCESS; - int i, state = 0, low = 0, high = 0, lowval, highval; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *statsthreshold; - MrvlIEtypes_BeaconHighRssiThreshold_t *bcnhighrssi; - MrvlIEtypes_BeaconLowRssiThreshold_t *bcnlowrssi; - MrvlIEtypes_BeaconHighSnrThreshold_t *bcnhighsnr; - MrvlIEtypes_BeaconLowSnrThreshold_t *bcnlowsnr; - - if (argv[0] == NULL) { - puts("\nInsufficient arguments.. \n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - if (argv[0] && strncmp(argv[0], "stable", strlen("stable")) == 0) { - state = STATE_STABLE; - /* degrad[ing] */ - } else if (argv[0] && strncmp(argv[0], "degrad", strlen("degrad")) == 0) { - state = STATE_DEGRADING; - /* unaccep[table] */ - } else if (argv[0] - && strncmp(argv[0], "unaccep", strlen("unaccep")) == 0) { - state = STATE_UNACCEPTABLE; - } else { - puts("\nUnknown state. Use stable/degrading/unacceptable\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - if (argc != 3 && argc != 5) { - puts("\nIncorrect number of arguments.\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - if (argv[1] && strncmp(argv[1], "low", strlen("low")) == 0) { - low = 1; - lowval = atoi(argv[2]); - /* TODO validation check on lowval */ - } - if (argv[1 + (2 * low)] - && strncmp(argv[1 + (2 * low)], "high", strlen("high")) == 0) { - high = 1; - highval = atoi(argv[2 + (2 * low)]); - /* TODO validation check on highval */ - } - /* check if low is specified after high */ - if ((low == 0) && (argc == 5)) { - if (argv[1 + (2 * high)] - && strncmp(argv[1 + (2 * high)], "low", strlen("low")) == 0) { - low = 1; - lowval = atoi(argv[2 + 2 * (high)]); - /* TODO validation check on lowval */ - } - } - - if (!low && !high) { - puts("\nIncorrect argument. Use low /high \n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - statsthreshold = (HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *)pos; - cmd_len = - (S_DS_GEN + - sizeof(HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD) - - sizeof(statsthreshold->TlvBuffer)); - if (type == RSSI_THRESHOLD) { - if (high) { - cmd_len += - sizeof(MrvlIEtypes_BeaconHighRssiThreshold_t); - } - if (low) { - cmd_len += sizeof(MrvlIEtypes_BeaconLowRssiThreshold_t); - } - } else { - if (high) { - cmd_len += sizeof(MrvlIEtypes_BeaconHighSnrThreshold_t); - } - if (low) { - cmd_len += sizeof(MrvlIEtypes_BeaconLowSnrThreshold_t); - } - } - - hostcmd->command = - cpu_to_le16(HostCmd_CMD_ROAMAGENT_STATISTICS_THRESHOLD); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - statsthreshold->action = cpu_to_le16(HostCmd_ACT_GEN_SET); - statsthreshold->State = state; - - /* - * TLV buffer start pointer initialization - */ - i = 0; - if (type == RSSI_THRESHOLD) { - if (high) { - bcnhighrssi = (MrvlIEtypes_BeaconHighRssiThreshold_t *) - (((t_u8 *)&statsthreshold->TlvBuffer) + i); - bcnhighrssi->Header.type = TLV_TYPE_RSSI_HIGH; - bcnhighrssi->Header.len = - (sizeof(MrvlIEtypes_BeaconHighRssiThreshold_t) - - sizeof(MrvlIEtypesHeader_t)); - bcnhighrssi->Value = highval; - i += sizeof(MrvlIEtypes_BeaconHighRssiThreshold_t); - /* - * ENDIANNESS - */ - bcnhighrssi->Header.type = - cpu_to_le16(bcnhighrssi->Header.type); - bcnhighrssi->Header.len = - cpu_to_le16(bcnhighrssi->Header.len); - } - - if (low) { - bcnlowrssi = (MrvlIEtypes_BeaconLowRssiThreshold_t *) - (((t_u8 *)&statsthreshold->TlvBuffer) + i); - bcnlowrssi->Header.type = TLV_TYPE_RSSI_LOW; - bcnlowrssi->Header.len = - (sizeof(MrvlIEtypes_BeaconLowRssiThreshold_t) - - sizeof(MrvlIEtypesHeader_t)); - bcnlowrssi->Value = lowval; - i += sizeof(MrvlIEtypes_BeaconLowRssiThreshold_t); - /* - * ENDIANNESS - */ - bcnlowrssi->Header.type = - cpu_to_le16(bcnlowrssi->Header.type); - bcnlowrssi->Header.len = - cpu_to_le16(bcnlowrssi->Header.len); - } - } else { - if (high) { - bcnhighsnr = (MrvlIEtypes_BeaconHighSnrThreshold_t *) - (((t_u8 *)&statsthreshold->TlvBuffer) + i); - bcnhighsnr->Header.type = TLV_TYPE_SNR_HIGH; - bcnhighsnr->Header.len = - (sizeof(MrvlIEtypes_BeaconHighSnrThreshold_t) - - sizeof(MrvlIEtypesHeader_t)); - bcnhighsnr->Value = highval; - i += sizeof(MrvlIEtypes_BeaconHighSnrThreshold_t); - /* - * ENDIANNESS - */ - bcnhighsnr->Header.type = - cpu_to_le16(bcnhighsnr->Header.type); - bcnhighsnr->Header.len = - cpu_to_le16(bcnhighsnr->Header.len); - } - if (low) { - bcnlowsnr = (MrvlIEtypes_BeaconLowSnrThreshold_t *) - (((t_u8 *)&statsthreshold->TlvBuffer) + i); - bcnlowsnr->Header.type = TLV_TYPE_SNR_LOW; - bcnlowsnr->Header.len = - (sizeof(MrvlIEtypes_BeaconLowSnrThreshold_t) - - sizeof(MrvlIEtypesHeader_t)); - bcnlowsnr->Value = lowval; - i += sizeof(MrvlIEtypes_BeaconLowSnrThreshold_t); - /* - * ENDIANNESS - */ - bcnlowsnr->Header.type = - cpu_to_le16(bcnlowsnr->Header.type); - bcnlowsnr->Header.len = - cpu_to_le16(bcnlowsnr->Header.len); - } - } - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[setra]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - if (le16_to_cpu(hostcmd->result)) { - printf("\nHostCmd Error: ReturnCode=%#04x, Result=%#04x\n\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } else { - printf("\nHostCmd Success: ReturnCode=%#04x, Result=%#04x\n\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue setra rssi command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamSetRssiStatsThreshold(int argc, char *argv[]) -{ - if (roamSetStatsThreshold(argc, argv, RSSI_THRESHOLD) - == MLAN_STATUS_SUCCESS) { - roamGetStatsThreshold(0, argv, RSSI_THRESHOLD); - } - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Issue setra scanperiod command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamSetScanPeriod(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - int scanmode = 0, period = 0, state = 0; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_SCANPERIOD *scanPeriodInfo; - - if (argv[0] == NULL) { - puts("\nInsufficient arguments.. \n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* scanperiod */ - if (argc != 3) { - puts("\nIncorrect number of arguments.\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - if (argv[0] && strncmp(argv[0], "stable", strlen("stable")) == 0) { - state = STATE_STABLE; - /* degrad[ing] */ - } else if (argv[0] && strncmp(argv[0], "degrad", strlen("degrad")) == 0) { - state = STATE_DEGRADING; - /* unaccep[table] */ - } else if (argv[0] - && strncmp(argv[0], "unaccep", strlen("unaccep")) == 0) { - state = STATE_UNACCEPTABLE; - } else { - puts("\nUnknown state. Use stable/degrading/unacceptable\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - if (argv[1] && strncmp(argv[1], "disc", strlen("disc")) == 0) { - scanmode = DISCOVERY_MODE; - /* track[ing] */ - } else if (argv[1] && strncmp(argv[1], "track", strlen("track")) == 0) { - scanmode = TRACKING_MODE; - } else { - puts("\nUnknown scamode. Use discovery/ tracking\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - period = atoi(argv[2]); - /* TODO validation check on period */ - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - scanPeriodInfo = (HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_SCANPERIOD *)pos; - cmd_len = - S_DS_GEN + sizeof(HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_SCANPERIOD); - hostcmd->command = - cpu_to_le16(HostCmd_CMD_ROAMAGENT_NEIGHBOR_SCAN_PERIOD); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - scanPeriodInfo->action = HostCmd_ACT_GEN_SET; - scanPeriodInfo->scanPeriod.Header.type = TLV_TYPE_NEIGHBOR_SCANPERIOD; - scanPeriodInfo->scanPeriod.Header.len = - sizeof(MrvlIEtypes_NeighborScanPeriod_t) - - sizeof(MrvlIEtypesHeader_t); - scanPeriodInfo->scanPeriod.SearchMode = scanmode; - scanPeriodInfo->scanPeriod.State = state; - scanPeriodInfo->scanPeriod.ScanPeriod = period; - - /* - * ENDIANNESS - */ - scanPeriodInfo->action = cpu_to_le16(scanPeriodInfo->action); - scanPeriodInfo->scanPeriod.Header.type = cpu_to_le16 - (scanPeriodInfo->scanPeriod.Header.type); - scanPeriodInfo->scanPeriod.Header.len = cpu_to_le16 - (scanPeriodInfo->scanPeriod.Header.len); - scanPeriodInfo->scanPeriod.SearchMode = cpu_to_le16 - (scanPeriodInfo->scanPeriod.SearchMode); - scanPeriodInfo->scanPeriod.State = cpu_to_le16 - (scanPeriodInfo->scanPeriod.State); - scanPeriodInfo->scanPeriod.ScanPeriod = cpu_to_le32 - (scanPeriodInfo->scanPeriod.ScanPeriod); - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[neighborlist maintain]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - if (le16_to_cpu(hostcmd->result)) { - printf("\nHostCmd Error: ReturnCode=%#04x, Result=%#04x\n\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } else { - printf("\nHostCmd Success: ReturnCode=%#04x, Result=%#04x\n\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Check it string contains digits - * @param str string to check for digits - * @return same as isdigit(char) - */ -static inline int -isdigitstr(char *str) -{ - unsigned int i = 0; - for (i = 0; i < strlen(str); i++) { - if (!isdigit((str)[i])) - return 0; - } - return 1; -} - -/** - * @brief Process sub command - * - * @param valid_cmds valid commands array - * @param count number of valid commands - * @param argc number of arguments - * @param argv A pointer to arguments array - * @param param argc parameter counter - * @param value values to update back - * - * @return command index--success, otherwise--fail - */ -static int -process_subcmd(char *valid_cmds[], int count, int argc, char *argv[], - int *param, int *value) -{ - int ret = 0; - int j = *param; - int k; - while (1) { - for (k = 0; k < count; k++) - if (argv[j] && - !strncmp(valid_cmds[k], argv[j], - strlen(valid_cmds[k]))) - break; - if (k >= count) { - break; - } else { - /* special case */ - if (!strncmp - (valid_cmds[k], "perperiod", strlen("perperiod")) || - !strncmp(valid_cmds[k], "ferperiod", - strlen("ferperiod"))) { - *param = j; - return ret | 1 << k; - } - if (!argv[j + 1] || !isdigitstr(argv[j + 1])) - return -1; - value[k] = atoi(argv[j + 1]); - j = j + 2; - ret |= (1 << k); - } - - if (j >= argc) { - break; - } - } - - if (*param == j) { - return -1; - } - - *param = j; - return ret; -} - -static int -printSetNeighborDeprecation(int argc, char *argv[]) -{ - printf("\nInfo: setra neighbor replaced with:\n" - " - setra nparams (config neighbor assessment params)\n\n"); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Issue setra neighbor command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamSetNborParams(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - int trackcount = 0, i = 0, j = 0; - int blist[2] = { 0, 0 }; /* blacklist short and long: 0-short 1-long */ - int qualoffset[1] = { 0 }; /* rssi */ - int stalecount = ~0; - int staleperiod = ~0; - signed char temp; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - char *valid_cmds[] = { "trackcount", "qualoffset", "blacklistdur", - "stalecount", "staleperiod", "roamthresh" - }; - - /** blacklistdur sub commands */ - char *valid_blcmds[] = { "short", "long" }; - - /** qualoffset sub commands */ - char *valid_bfcmds[] = { "rssi" }; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_ASSESSMENT *pNborAssessment; - - if (argv[0] == NULL) { - puts("\nUnknown setra nparams subcmd. Valid subcmds:"); - for (i = 0; i < NELEMENTS(valid_cmds); i++) { - printf(" - %s\n", valid_cmds[i]); - } - printf("\n"); - - ret = MLAN_STATUS_FAILURE; - goto done; - } - - if (argc < 2 || argc > 18) { - puts("\nIncorrect number of arguments.\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - pNborAssessment = (HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_ASSESSMENT *)pos; - cmd_len = - S_DS_GEN + sizeof(HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_ASSESSMENT); - - hostcmd->command = - cpu_to_le16(HostCmd_CMD_ROAMAGENT_NEIGHBOR_ASSESSMENT); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Get parameters unspecified on command line */ - if (getNborAssessment(pNborAssessment) != MLAN_STATUS_SUCCESS) { - ret = MLAN_STATUS_FAILURE; - goto done; - } - - while (argc - j) { - for (i = 0; (unsigned int)i < NELEMENTS(valid_cmds); i++) { - if (!strncmp - (valid_cmds[i], argv[j], strlen(valid_cmds[i]))) - break; - } - - if ((unsigned int)i >= NELEMENTS(valid_cmds)) { - printf("\nInvalid argument to \"%s\"\n\n", argv[0]); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - switch (i) { - - case 0: - /** trackcount */ - trackcount = atoi(argv[j + 1]); - pNborAssessment->QualifyingNumNeighbor = trackcount; - j = j + 2; - break; - - case 1: - /** qualoffset */ - j++; - ret = process_subcmd(valid_bfcmds, - NELEMENTS(valid_bfcmds), argc, - argv, &j, qualoffset); - if (ret == -1) { - printf("\nInvalid argument to \"%s\"\n\n", - argv[j - 1]); - ret = ret; - goto done; - } - pNborAssessment->ConfQualSignalStrength = qualoffset[0]; - break; - - case 2: - /** blacklistdur */ - j++; - ret = process_subcmd(valid_blcmds, - NELEMENTS(valid_blcmds), argc, - argv, &j, blist); - if (ret == -1) { - printf("\nInvalid argument to \"%s\"\n\n", - argv[j - 1]); - ret = ret; - goto done; - } else { - if (ret & 0x01) { - pNborAssessment->ShortBlacklistPeriod = - blist[0]; - } - if (ret & 0x02) { - pNborAssessment->LongBlacklistPeriod = - blist[1]; - } - } - break; - - case 3: - /** stalecount */ - stalecount = atoi(argv[j + 1]); - pNborAssessment->StaleCount = stalecount; - j = j + 2; - break; - - case 4: - /** staleperiod */ - staleperiod = atoi(argv[j + 1]); - pNborAssessment->StalePeriod = staleperiod; - j = j + 2; - break; - - case 5: - /** roamthresh */ - j++; - temp = 0; - for (i = 0; j + i < argc; i++) { - if (isdigit(*argv[j + i]) || - (*argv[j + i] == '-')) { - temp++; - } else { - break; - } - } - - if ((temp % 3 != 0) || (temp > 12)) { - puts(""); - printf("Error: %d numeric arguments detected for roamthresh.\n" " Roam threhold values must be specified in\n" " multiples of 3 (low, high, diff triplets) up\n" " to a maximum of 4 sets (12 numbers max).\n", temp); - puts(""); - - ret = MLAN_STATUS_FAILURE; - goto done; - } - - for (i = 0; (i < 12); i++) { - if ((j >= argc) || - (!isdigit(*argv[j]) && *argv[j] != '-')) { - temp = 0; - } else { - temp = atoi(argv[j]); - j++; - } - - switch (i % 3) { - case 0: - pNborAssessment->RoamThresh[i / - 3]. - RssiHighLevel = temp; - break; - - case 1: - pNborAssessment->RoamThresh[i / - 3]. - RssiLowLevel = temp; - break; - - case 2: - pNborAssessment->RoamThresh[i / - 3]. - RssiNborDiff = temp; - break; - } - } - break; - } - } - - pNborAssessment->action = cpu_to_le16(HostCmd_ACT_GEN_SET); - - /* Both stalecount, staleperiod can not be zero */ - if ((pNborAssessment->StaleCount == 0) && - (pNborAssessment->StalePeriod == 0)) { - - puts("\nstalecount and staleperiod both can not be zero\n"); - ret = (MLAN_STATUS_FAILURE); - goto done; - } - - /* - * ENDIANNESS - */ - pNborAssessment->QualifyingNumNeighbor = - cpu_to_le16(pNborAssessment->QualifyingNumNeighbor); - pNborAssessment->ShortBlacklistPeriod = - cpu_to_le32(pNborAssessment->ShortBlacklistPeriod); - pNborAssessment->LongBlacklistPeriod = - cpu_to_le32(pNborAssessment->LongBlacklistPeriod); - pNborAssessment->StaleCount = cpu_to_le16(pNborAssessment->StaleCount); - pNborAssessment->StalePeriod = - cpu_to_le16(pNborAssessment->StalePeriod); - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[roam neighbor assessment]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - if (le16_to_cpu(hostcmd->result)) { - printf("\nHostCmd Error: ReturnCode=%#04x, Result=%#04x\n\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } else { - printNeighborAssessmentConfig(); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue setra metrics command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamSetMetrics(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CMD_ROAMAGENT_ADV_METRIC_THRESHOLD *metricscmd; - - int perlist[3] = { 0, 0, 0 }; /* 0=inactivity, - 1=perthreshold, - 2=packetthreshold */ - int ferlist[3] = { 0, 0, 0 }; /* 0=inactivity, - 1=ferthreshold, - 2=framethreshold */ - int perstate[3] = { 0, 0, 0 }; /* 0=stable, 1=degrading, 2=unacceptable */ - int ferstate[3] = { 0, 0, 0 }; /* 0=stable, 1=degrading, 2=unacceptable */ - int datalist[2] = { 0, 0 }; /* 0=inactivity, 1=datathreshold */ - char *valid_cmds[] = { "Beacon", "Data", "PER", "FER" }; - - /** PER sub commands */ - char *valid_percmds[] = { "inactivity", "perthreshold", - "packetthreshold", "perperiod" - }; - - char *valid_fercmds[] = { "inactivity", "ferthreshold", - "framethreshold", "ferperiod" - }; - - /** PER period states */ - char *per_states[] = { "stable", "degrading", "unacceptable" }; - - /** Data sub commands */ - char *valid_datacmds[] = { "inactivity", "datathreshold" }; - - int i = 0, j = 0; - - if (argv[0] == NULL) { - puts("\nInsufficient arguments.. \n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - if (argc < 1 || argc > 38) { - puts("\nIncorrect number of arguments.\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - cmd_len = - S_DS_GEN + - sizeof(HostCmd_DS_CMD_ROAMAGENT_ADV_METRIC_THRESHOLD); - - hostcmd->command = - cpu_to_le16(HostCmd_CMD_ROAMAGENT_ADV_METRIC_THRESHOLD); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - metricscmd = (HostCmd_DS_CMD_ROAMAGENT_ADV_METRIC_THRESHOLD *)pos; - metricscmd->action = cpu_to_le16(HostCmd_ACT_GEN_SET); - - /* clear [ Beacon/Data/PER ] */ - if (!strncmp("clear", argv[j], strlen("clear"))) { - if (argc == 1) { - puts("\nInvalid number of argument"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - while (1) { - j++; - for (i = 0; (unsigned int)i < NELEMENTS(valid_cmds); - i++) { - if (!strncmp - (valid_cmds[i], argv[j], - strlen(valid_cmds[i]))) - break; - } - if ((unsigned int)i >= NELEMENTS(valid_cmds)) { - printf("\nInvalid argument \"%s\"\n\n", - argv[j]); - ret = MLAN_STATUS_FAILURE; - goto done; - } else { - metricscmd->Metrics |= BIT(i); - } - - if (j >= (argc - 1)) { - break; - } - } - metricscmd->action = HostCmd_ACT_GEN_REMOVE; - } else { /* set [ Beacon/Data/PER ] */ - - while (argc - j) { - for (i = 0; (unsigned int)i < NELEMENTS(valid_cmds); - i++) { - if (!strncmp - (valid_cmds[i], argv[j], - strlen(valid_cmds[i]))) - break; - } - if ((unsigned int)i >= NELEMENTS(valid_cmds)) { - printf("\nInvalid argument to \"%s\"\n\n", - argv[j]); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - switch (i) { - case 0: - /** Beacon */ - j++; - metricscmd->Metrics |= 0x01; - break; - - case 1: - /** Data*/ - j++; - ret = process_subcmd(valid_datacmds, - NELEMENTS(valid_datacmds), - argc, argv, &j, datalist); - if (ret > 0) { - if (ret & 0x01) { - metricscmd-> - InactivityPeriodThreshold_ms - = datalist[0]; - } - if (ret & 0x02) { - metricscmd->UiRxPktThreshold = - datalist[1]; - } - } - metricscmd->Metrics |= 0x02; - break; - - case 2: - /** PER */ - j++; - ret = process_subcmd(valid_percmds, - NELEMENTS(valid_percmds), - argc, argv, &j, perlist); - if (ret > 0) { - if (ret & 0x01) { - metricscmd-> - InactivityPeriodThreshold_ms - = perlist[0]; - } - if (ret & 0x02) { - metricscmd-> - UcPerThresholdValue = - perlist[1]; - } - if (ret & 0x04) { - metricscmd->UiPerPktThreshold = - perlist[2]; - } - if (ret & 0x08) { - j++; - ret = process_subcmd(per_states, - NELEMENTS - (per_states), - argc, argv, - &j, - perstate); - if (ret & 0x01) { - metricscmd-> - StablePERPeriod_ms - = perstate[0]; - } - if (ret & 0x02) { - metricscmd-> - DegradingPERPeriod_ms - = perstate[1]; - } - if (ret & 0x04) { - metricscmd-> - UnacceptablePERPeriod_ms - = perstate[2]; - } - if (j < argc) { - ret = process_subcmd - (valid_percmds, - NELEMENTS - (valid_percmds), - argc, argv, &j, - perlist); - if (ret > 0) { - if (ret & 0x01) { - metricscmd-> - InactivityPeriodThreshold_ms - = - perlist - [0]; - } - if (ret & 0x02) { - metricscmd-> - UcPerThresholdValue - = - perlist - [1]; - } - if (ret & 0x04) { - metricscmd-> - UiPerPktThreshold - = - perlist - [2]; - } - } - } - } - } - metricscmd->Metrics |= 0x04; - break; - - case 3: - /** FER */ - j++; - ret = process_subcmd(valid_fercmds, - NELEMENTS(valid_fercmds), - argc, argv, &j, ferlist); - if (ret > 0) { - if (ret & 0x01) { - metricscmd-> - InactivityPeriodThreshold_ms - = ferlist[0]; - } - if (ret & 0x02) { - metricscmd-> - UcFerThresholdValue = - ferlist[1]; - } - if (ret & 0x04) { - metricscmd->UiFerPktThreshold = - ferlist[2]; - } - if (ret & 0x08) { - j++; - ret = process_subcmd(per_states, - NELEMENTS - (per_states), - argc, argv, - &j, - ferstate); - if (ret & 0x01) { - metricscmd-> - StableFERPeriod_ms - = ferstate[0]; - } - if (ret & 0x02) { - metricscmd-> - DegradingFERPeriod_ms - = ferstate[1]; - } - if (ret & 0x04) { - metricscmd-> - UnacceptableFERPeriod_ms - = ferstate[2]; - } - if (j < argc) { - ret = process_subcmd - (valid_fercmds, - NELEMENTS - (valid_fercmds), - argc, argv, &j, - ferlist); - if (ret > 0) { - if (ret & 0x01) { - metricscmd-> - InactivityPeriodThreshold_ms - = - ferlist - [0]; - } - if (ret & 0x02) { - metricscmd-> - UcFerThresholdValue - = - ferlist - [1]; - } - if (ret & 0x04) { - metricscmd-> - UiFerPktThreshold - = - ferlist - [2]; - } - } - } - } - } - metricscmd->Metrics |= 0x08; - break; - } - metricscmd->action = HostCmd_ACT_GEN_SET; - } - } - - /* - * ENDIANNESS - */ - metricscmd->action = cpu_to_le16(metricscmd->action); - metricscmd->Metrics = cpu_to_le16(metricscmd->Metrics); - metricscmd->UiPerPktThreshold = - cpu_to_le32(metricscmd->UiPerPktThreshold); - metricscmd->StablePERPeriod_ms = - cpu_to_le32(metricscmd->StablePERPeriod_ms); - metricscmd->DegradingPERPeriod_ms = - cpu_to_le32(metricscmd->DegradingPERPeriod_ms); - metricscmd->UnacceptablePERPeriod_ms = - cpu_to_le32(metricscmd->UnacceptablePERPeriod_ms); - metricscmd->InactivityPeriodThreshold_ms = - cpu_to_le32(metricscmd->InactivityPeriodThreshold_ms); - metricscmd->UiRxPktThreshold = - cpu_to_le32(metricscmd->UiRxPktThreshold); - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[neighborlist maintain]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - if (le16_to_cpu(hostcmd->result)) { - printf("\nHostCmd Error: ReturnCode=%#04x, Result=%#04x\n\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } else { - printf("\nHostCmd Success: ReturnCode=%#04x, Result=%#04x\n\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Process maintenance of Neighbor list - * - * @param argc # arguments - * @param argv A pointer to arguments array - * - */ -static int -roamSetNborMaintenance(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - char *valid_cmds[] = { "blacklist", "clear" }; - int i = 0, j = 0, k = 0; - unsigned int mac[ETH_ALEN]; - - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CMD_ROAMAGENT_NEIGHBORLIST_MAINTENANCE *pNborMaintainance; - - if (argv[0] == NULL) { - puts("\nInsufficient arguments.. \n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - if (argc != 2) { - puts("\nIncorrect number of arguments.\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - for (i = 0; (unsigned int)i < NELEMENTS(valid_cmds); i++) - if (!strncmp(valid_cmds[i], argv[j], strlen(valid_cmds[i]))) - break; - if ((unsigned int)i >= NELEMENTS(valid_cmds)) { - printf("\nInvalid argument \"%s\"\n\n", argv[0]); - ret = MLAN_STATUS_FAILURE; - goto done; - } - switch (i) { - case 0: - /** blacklist */ - j++; - sscanf(argv[j], "%2x:%2x:%2x:%2x:%2x:%2x", - mac, mac + 1, mac + 2, mac + 3, mac + 4, mac + 5); - for (k = 0; k < ETH_ALEN; k++) { - if (*(mac + k) != 0xFF) { - break; - } - } - - if (k == ETH_ALEN) { - puts("\nBlacklisting a Broadcast address is not allowed"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - break; - - case 1: - /** clear */ - j++; - if (!strncmp("all", argv[j], strlen("all"))) { - for (k = 0; k < ETH_ALEN; k++) { - *(mac + k) = 0xFF; - } - } else { - sscanf(argv[j], "%2x:%2x:%2x:%2x:%2x:%2x", - mac, mac + 1, mac + 2, mac + 3, mac + 4, - mac + 5); - } - break; - } - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - pNborMaintainance - = (HostCmd_DS_CMD_ROAMAGENT_NEIGHBORLIST_MAINTENANCE *)pos; - - cmd_len = S_DS_GEN + - sizeof(HostCmd_DS_CMD_ROAMAGENT_NEIGHBORLIST_MAINTENANCE); - - hostcmd->command - = cpu_to_le16(HostCmd_CMD_ROAMAGENT_NEIGHBORLIST_MAINTENANCE); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - pNborMaintainance->action = ((i == 0) ? HostCmd_ACT_ADD_TO_BLACKLIST : - HostCmd_ACT_REMOVE_FROM_BLACKLIST); - pNborMaintainance->action = cpu_to_le16(pNborMaintainance->action); - for (k = 0; k < ETH_ALEN; k++) { - pNborMaintainance->BSSID[k] = *(mac + k); - } - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[neighborlist maintain]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - if (le16_to_cpu(hostcmd->result)) { - printf("\nHostCmd Error: ReturnCode=%#04x, Result=%#04x\n\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } else { - printf("\nHostCmd Success: ReturnCode=%#04x, Result=%#04x\n\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue setra backoff command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamSetBackOff(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - int spflag[2] = { 0, 0 }; /*scan,priod */ - t_u16 minscan; - t_u32 bperiod; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CMD_ROAMAGENT_BACKOFF *roambackoffcmd; - int i; - - if (argv[0] == NULL) { - puts("\nInsufficient arguments.. \n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - /* BackOff */ - if ((argc != 2) && (argc != 4)) { - puts("\nIncorrect number of arguments.\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - for (i = 0; i < 4; i++) { - if (argv[i + 0] && - strncmp(argv[i + 0], "scans", strlen("scans")) == 0) { - minscan = atoi(argv[i + 1]); - i++; - spflag[0] = 1; - /* TODO validation check on minscan */ - } - if (argv[i + 0] && - strncmp(argv[i + 0], "period", strlen("period")) == 0) { - bperiod = atoi(argv[i + 1]); - i++; - spflag[1] = 1; - /* TODO validation check on bperiod */ - } - } - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - roambackoffcmd = (HostCmd_DS_CMD_ROAMAGENT_BACKOFF *)pos; - cmd_len = S_DS_GEN + sizeof(HostCmd_DS_CMD_ROAMAGENT_BACKOFF); - hostcmd->command = cpu_to_le16(HostCmd_CMD_ROAMAGENT_BACKOFF); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - switch (spflag[0] + spflag[1]) { - case 0: - /* error */ - puts("\nIncorrect arguments for setra backoff command.\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - - case 1: - /* get missing parameter */ - if (getBackOff(roambackoffcmd) != MLAN_STATUS_SUCCESS) { - ret = MLAN_STATUS_FAILURE; - goto done; - } - if (spflag[0] == 0) { - minscan = roambackoffcmd->Scans; - } else { - bperiod = roambackoffcmd->Period; - } - break; - - case 2: - default: - break; - } - - roambackoffcmd->action = cpu_to_le16(HostCmd_ACT_GEN_SET); - roambackoffcmd->Scans = cpu_to_le16(minscan); - roambackoffcmd->Period = cpu_to_le16(bperiod); - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[roambackoff]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - if (le16_to_cpu(hostcmd->result)) { - printf("\nHostCmd Error: ReturnCode=%#04x, Result=%#04x\n\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } else { - printf("\nHostCmd Success: ReturnCode=%#04x, Result=%#04x\n\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue setra enable/disable/resume/suspend command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * @param set/reset set/reset flag - * @param value roam control/ host event bitmap value - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamSetControl(int argc, char *argv[], int setreset, t_u8 value) -{ - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CMD_ROAMAGENT_CONTROL *roamcontrolcmd; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - cmd_len = S_DS_GEN + sizeof(HostCmd_DS_CMD_ROAMAGENT_CONTROL); - - hostcmd->command = cpu_to_le16(HostCmd_CMD_ROAMAGENT_CONTROL); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - roamcontrolcmd = (HostCmd_DS_CMD_ROAMAGENT_CONTROL *)pos; - - /* get current value */ - if (getControl(roamcontrolcmd) != MLAN_STATUS_SUCCESS) { - ret = MLAN_STATUS_FAILURE; - goto done; - } - - roamcontrolcmd->action = cpu_to_le16(HostCmd_ACT_GEN_SET); - switch (setreset) { - case 0: - roamcontrolcmd->Control &= value; - break; - case 1: - roamcontrolcmd->Control |= value; - break; - case 2: - roamcontrolcmd->HostEvent &= value; - break; - case 3: - roamcontrolcmd->HostEvent |= value; - break; - } - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[roamcontrol]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - if (le16_to_cpu(hostcmd->result)) { - printf("\nHostCmd Error: ReturnCode=%#04x, Result=%#04x\n\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } else { - printf("\nHostCmd Success: ReturnCode=%#04x, Result=%#04x\n\n", - le16_to_cpu(hostcmd->command), - le16_to_cpu(hostcmd->result)); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue setra enable command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamSetEnableControl(int argc, char *argv[]) -{ - return roamSetControl(argc, argv, 1, ROAM_CONTROL_ENABLE); -} - -/** - * @brief Issue setra disable command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamSetDisableControl(int argc, char *argv[]) -{ - return roamSetControl(argc, argv, 0, ROAM_CONTROL_DISABLE); -} - -/** - * @brief Issue setra suspend command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamSetSuspendControl(int argc, char *argv[]) -{ - return roamSetControl(argc, argv, 1, ROAM_CONTROL_SUSPEND); -} - -/** - * @brief Issue setra resume command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamSetResumeControl(int argc, char *argv[]) -{ - return roamSetControl(argc, argv, 0, ROAM_CONTROL_RESUME); -} - -/** - * @brief Issue setra crossband command - * - * @param argc number of arguments - * @param argv A pointer to argument array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamSetCrossband(int argc, char *argv[]) -{ - if (argc != 1) { - printf("Invalid Usage \n"); - return MLAN_STATUS_FAILURE; - } - if (strncmp(argv[0], "enable", strlen("enable")) == 0) { - return roamSetControl(argc, argv, 1, CROSSBAND_ENABLE); - } else if (strncmp(argv[0], "disable", strlen("disable")) == 0) { - return roamSetControl(argc, argv, 0, CROSSBAND_DISABLE); - } - - printf("Invalid Usage \n"); - return MLAN_STATUS_FAILURE; -} - -/** - * @brief Issue setra event command - * - * @param argc number of arguments - * @param argv A pointer to argument array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -roamSetEventBitmap(int argc, char *argv[]) -{ - int i, enableFlag, found = 0; - t_u8 value; - if (argc > 4 || argc < 2) { - printf("Invalid Usage \n"); - return MLAN_STATUS_FAILURE; - } - if (strncmp(argv[0], "enable", strlen("enable")) == 0) { - enableFlag = 3; - value = HOST_EVENT_NBOR_DISABLE & HOST_EVENT_ROAM_DISABLE - & HOST_EVENT_STATE_DISABLE; - } else if (strncmp(argv[0], "disable", strlen("disable")) == 0) { - enableFlag = 2; - value = HOST_EVENT_NBOR_ENABLE | HOST_EVENT_ROAM_ENABLE - | HOST_EVENT_STATE_ENABLE; - } else { - printf("Invalid parameter %s \n", argv[0]); - return MLAN_STATUS_FAILURE; - } - - for (i = 1; i < argc; i++) { - found = 0; - if (strncmp(argv[i], "neighbor", strlen("neighbor")) == 0) { - found = 1; - if (enableFlag == 3) { - value |= HOST_EVENT_NBOR_ENABLE; - } else { - value &= HOST_EVENT_NBOR_DISABLE; - } - } - if (strncmp(argv[i], "roam", strlen("roam")) == 0) { - found = 1; - if (enableFlag == 3) { - value |= HOST_EVENT_ROAM_ENABLE; - } else { - value &= HOST_EVENT_ROAM_DISABLE; - } - } - if (strncmp(argv[i], "state", strlen("state")) == 0) { - found = 1; - if (enableFlag == 3) { - value |= HOST_EVENT_STATE_ENABLE; - } else { - value &= HOST_EVENT_STATE_DISABLE; - } - } - if (found == 0) { - printf("Invalid parameter %s \n", argv[i]); - return MLAN_STATUS_FAILURE; - } - } - - return roamSetControl(argc, argv, enableFlag, value); -} - -/** - * @brief Set the Roaming agent configuration parameters to FW. - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_set_ra_config(int argc, char *argv[]) -{ - sub_cmd_exec_t subCmds[] = { - {"rssi", 2, 1, roamSetRssiStatsThreshold}, - {"prebcnmiss", 2, 1, roamSetPreBeaconLoss}, - {"failcnt", 2, 1, roamSetFailureCount}, - {"neighbor", 2, 0, printSetNeighborDeprecation}, - {"nparams", 2, 1, roamSetNborParams}, - {"maintain", 2, 1, roamSetNborMaintenance}, - {"scanperiod", 2, 1, roamSetScanPeriod}, - {"backoff", 2, 1, roamSetBackOff}, - {"enable", 2, 1, roamSetEnableControl}, - {"disable", 2, 1, roamSetDisableControl}, - {"suspend", 2, 1, roamSetSuspendControl}, - {"resume", 2, 1, roamSetResumeControl}, - {"metrics", 2, 1, roamSetMetrics}, - {"crossband", 2, 1, roamSetCrossband}, - {"event", 2, 1, roamSetEventBitmap} - }; - - return process_sub_cmd(subCmds, NELEMENTS(subCmds), argc, argv); -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanroamagent.h b/mxm_wifiex/wlan_src/mapp/mlanutl/mlanroamagent.h deleted file mode 100644 index e4ad39b..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanroamagent.h +++ /dev/null @@ -1,315 +0,0 @@ -/** @file mlanroamagent.h - * - * @brief This files contains mlanutl roamagent command handling. - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 08/11/2009: initial version -************************************************************************/ - -#ifndef _MLANROAMAGENT_H_ -#define _MLANROAMAGENT_H_ - -/** Bit definitions */ -#ifndef BIT -#define BIT(x) (1UL << (x)) -#endif - -/* Define actionsd for HostCmd_DS_CMD_ROAMAGENT_NEIGHBORLIST_MAINTENANCE */ -/** Blacklist */ -#define HostCmd_ACT_ADD_TO_BLACKLIST 0x0001 -/** Flushing blacklisted entry */ -#define HostCmd_ACT_REMOVE_FROM_BLACKLIST 0x0002 - -/** Roaming scanmode: discovery */ -#define DISCOVERY_MODE 1 -/** Roaming scanmode: tracking */ -#define TRACKING_MODE 2 - -/** Threshold configuration: RSSI */ -#define RSSI_THRESHOLD 1 -/** Threshold configuration: SNR */ -#define SNR_THRESHOLD 2 - -#ifdef BIG_ENDIAN_SUPPORT -/** Bit values for Qualified Neighbor RSSI Entry */ -#define BIT_NEIGHFLAG_RSSI 0x80000000 -/** Bit values for Qualified Neighbor AGE Entry */ -#define BIT_NEIGHFLAG_AGE 0x40000000 -/** Bit values for Qualified Neighbor Blacklist Entry */ -#define BIT_NEIGHFLAG_BLACKLIST 0x20000000 -/** Bit values for Qualified Neighbor Admission Capacity */ -#define BIT_NEIGHFLAG_ADMISSION_CAP 0x10000000 -/** Bit values for Qualified Neighbor Uplink RSSI */ -#define BIT_NEIGHFLAG_UPLINK_RSSI 0x08000000 -#else -/** Bit values for Qualified Neighbor RSSI Entry */ -#define BIT_NEIGHFLAG_RSSI 0x01 -/** Bit values for Qualified Neighbor AGE Entry */ -#define BIT_NEIGHFLAG_AGE 0x02 -/** Bit values for Qualified Neighbor Blacklist Entry */ -#define BIT_NEIGHFLAG_BLACKLIST 0x04 -/** Bit values for Qualified Neighbor Admission Capacity */ -#define BIT_NEIGHFLAG_ADMISSION_CAP 0x08 -/** Bit values for Qualified Neighbor Uplink RSSI */ -#define BIT_NEIGHFLAG_UPLINK_RSSI 0x10 -#endif - -/** milliseconds time conversion data */ -typedef struct exactTime { - t_u16 hrs; /**< Number of hours */ - t_u16 mins; /**< Number of minutes */ - t_u16 secs; /**< Number of seconds */ - t_u16 msecs; /**< Number of milliseconds left */ -} ExactTime_t; - -/** ROAMAGENT HostEvent bitmasks */ -typedef enum { - HOST_EVENT_NBOR_DISABLE = 6, /* reset bit 0 */ - HOST_EVENT_NBOR_ENABLE = 1, /* set bit 0 */ - HOST_EVENT_ROAM_DISABLE = 5, /* reset bit 1 */ - HOST_EVENT_ROAM_ENABLE = 2, /* set bit 1 */ - HOST_EVENT_STATE_DISABLE = 3, /* reset bit 2 */ - HOST_EVENT_STATE_ENABLE = 4, /* reset bit 2 */ -} __ATTRIB_PACK__ HostEvent_e; - -/** ROAMAGENT_CONTROL command identifiers */ -typedef enum { - ROAM_CONTROL_DISABLE = 6, /* reset bit 0 */ - ROAM_CONTROL_ENABLE = 1, /* set bit 0 */ - ROAM_CONTROL_RESUME = 5, /* reset bit 1 */ - ROAM_CONTROL_SUSPEND = 2, /* set bit 1 */ - CROSSBAND_DISABLE = 3, /* reset bit 2 */ - CROSSBAND_ENABLE = 4 /* set bit 2 */ -} __ATTRIB_PACK__ RoamControl_e; - -/* - * Definitions of roaming state and other constants - */ -/** Enum Definitations: Roaming agent state */ -typedef enum { - STATE_DISCONNECTED, - STATE_STABLE, - STATE_DEGRADING, - STATE_UNACCEPTABLE, - STATE_HARDROAM, - STATE_LINKLOSS, - STATE_SOFTROAM, - STATE_SUSPEND, - STATE_CMD_SUSPEND, - STATE_ASYNCASSOC_SUSPEND -} RoamingAgentState; - -/** statistics threshold High RSSI */ -typedef struct { - /** Header */ - MrvlIEtypesHeader_t Header; - /** RSSI threshold (dBm) */ - t_u8 Value; - /** reporting frequency */ - t_u8 Frequency; -} __ATTRIB_PACK__ MrvlIEtypes_BeaconHighRssiThreshold_t, - MrvlIEtypes_BeaconLowRssiThreshold_t, - MrvlIEtypes_BeaconHighSnrThreshold_t, - MrvlIEtypes_BeaconLowSnrThreshold_t; - -/** HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD */ -typedef struct { - /** Action */ - t_u16 action; - /** roaming state */ - t_u8 State; - /** active/configured user */ - t_u8 Profile; - /** TLV buffer */ - t_u8 TlvBuffer[1]; - /* MrvlIEtypes_BeaconHighRssiThreshold_t BeaconHighRssiThreshold; - * MrvlIEtypes_BeaconLowRssiThreshold_t BeaconLowRssiThreshold; - * MrvlIEtypes_BeaconHighSnrThreshold_t BeaconHighSnrThreshold; - * MrvlIEtypes_BeaconLowSnrThreshold_t BeaconLowSnrThreshold; - * MrvlIEtypes_BeaconsMissed_t PreBeaconMissed; - * MrvlIEtypes_FailureCount_t FailureCnt; - */ -} __ATTRIB_PACK__ HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD; - -typedef struct { - /** */ - signed char RssiHighLevel; - /** */ - signed char RssiLowLevel; - /** */ - signed char RssiNborDiff; - -} __ATTRIB_PACK__ HostCmd_DS_CMD_ROAMAGENT_ROAM_THRESHOLD; - -#define ROAM_THRESH_MAX 4 - -/** HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_ASSESSMENT */ -typedef struct { - /** Action */ - t_u16 action; - /** configured qualifying snr */ - signed char ConfQualSignalStrength; - /** active qualifying snr */ - signed char ActiveQualSignalStrength; - /** qualifying neighbor count */ - t_u16 QualifyingNumNeighbor; - /** inactivity in # scans */ - t_u16 StaleCount; - /** inactivity in time (ms) */ - t_u32 StalePeriod; - /** blacklist duration in ms due to minor failures */ - t_u32 ShortBlacklistPeriod; - /** blacklist duration in ms due to severe failures */ - t_u32 LongBlacklistPeriod; - - HostCmd_DS_CMD_ROAMAGENT_ROAM_THRESHOLD RoamThresh[ROAM_THRESH_MAX]; - -} __ATTRIB_PACK__ HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_ASSESSMENT; - -/** HostCmd_DS_CMD_ROAMAGENT_NEIGHBORLIST */ -typedef struct { - /** Action */ - t_u16 action; - /** Reserved */ - t_u16 Reserved; - /** TLV buffer */ - t_u8 TlvBuffer[1]; - /* MrvlIEtypes_NeighborEntry_t Neighbors[MRVL_ROAM_MAX_NEIGHBORS]; - * MRVL_ROAM_MAX_NEIGHBORS = 5 - */ -} __ATTRIB_PACK__ HostCmd_DS_CMD_ROAMAGENT_NEIGHBORLIST; - -/** neighbor entry details roaming agent */ -typedef struct { - /** Header */ - MrvlIEtypesHeader_t Header; - /** bssid of neighbor */ - t_u8 Bssid[ETH_ALEN]; - /** Reserved */ - t_u16 Reserved; - /** neighbor snr */ - t_s16 SignalStrength; - /** neighbor age */ - t_u16 Age; - /** bit map for qualified neighbor */ - t_u32 QualifiedNeighborBitmap; - /** blacklist duration in ms */ - t_u32 BlackListDuration; -} __ATTRIB_PACK__ MrvlIEtypes_NeighborEntry_t; - -/** HostCmd_DS_ROAMAGENT_ADV_METRIC_THRESHOLD */ -typedef struct { - /** Action */ - t_u16 action; - /** Beacon RSSI Metrics,Data RSSI Metrics or PER Metrics */ - t_u16 Metrics; - /** Percentage FER Threshold value to exceed for making a roam decision */ - t_u8 UcFerThresholdValue; - /** Percentage PER Threshold value to exceed for making a roam decision */ - t_u8 UcPerThresholdValue; - /** Reserved for later use */ - t_u8 Reserved[2]; - /** Time (ms) for which FER should prevail in stable state */ - t_u32 StableFERPeriod_ms; - /** Time (ms) for which FER should prevail in degrading state */ - t_u32 DegradingFERPeriod_ms; - /** Time (ms) for which FER should prevail in unacceptable state */ - t_u32 UnacceptableFERPeriod_ms; - /** Time (ms) for which FER should prevail in stable state */ - t_u32 StablePERPeriod_ms; - /** Time (ms) for which PER should prevail in degrading state */ - t_u32 DegradingPERPeriod_ms; - /** Time (ms) for which PER should prevail in unacceptable state */ - t_u32 UnacceptablePERPeriod_ms; - /** Number of TX packets to exceed in period_ms ms for the FER for Roam */ - t_u32 UiFerPktThreshold; - /** Number of TX packets to exceed in period_ms ms for the PER for Roam */ - t_u32 UiPerPktThreshold; - /** Time in ms for which inactivity should prevail for state transition */ - t_u32 InactivityPeriodThreshold_ms; - /** With Data RSSI Metrics, Roam only when RX packets in period_ms ms exceeds this */ - t_u32 UiRxPktThreshold; -} __ATTRIB_PACK__ HostCmd_DS_CMD_ROAMAGENT_ADV_METRIC_THRESHOLD; - -/** scan period for each search mode and state for roaming agent */ -typedef struct { - /** Header */ - MrvlIEtypesHeader_t Header; - /** search mode */ - t_u16 SearchMode; - /** roaming state */ - t_u16 State; - /** scan period value */ - t_u32 ScanPeriod; -} __ATTRIB_PACK__ MrvlIEtypes_NeighborScanPeriod_t; - -/** HostCmd_DS_CMD_ROAMAGENT_CONTROL */ -typedef struct { - /** Action */ - t_u16 action; - /** enable control */ - t_u8 Control; - /** host event control */ - t_u8 HostEvent; -} __ATTRIB_PACK__ HostCmd_DS_CMD_ROAMAGENT_CONTROL; - -/** HostCmd_DS_CMD_ROAMAGENT_BACKOFF */ -typedef struct { - /** Action */ - t_u16 action; - /** minimum scans */ - t_u16 Scans; - /** backoff period */ - t_u32 Period; -} __ATTRIB_PACK__ HostCmd_DS_CMD_ROAMAGENT_BACKOFF; - -/** HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_SCANPERIOD */ -typedef struct { - /** Action */ - t_u16 action; - /** Reserved */ - t_u16 Reserved; - /** scanPeriod TLV */ - MrvlIEtypes_NeighborScanPeriod_t scanPeriod; -} __ATTRIB_PACK__ HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_SCANPERIOD; - -/** HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_SCANPERIOD_RSP */ -typedef struct { - /** Action */ - t_u16 action; - /** Reserved */ - t_u16 Reserved; - /** TLV buffer */ - t_u8 TlvBuffer[1]; - /* MrvlIEtypes_NeighborScanPeriod_t scanPeriod[MRVL_ROAM_SCAN_PERIODS]; - * MRVL_ROAM_SCAN_PERIODS = 6 - */ -} __ATTRIB_PACK__ HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_SCANPERIOD_RSP; - -/** HostCmd_DS_CMD_ROAMAGENT_NEIGHBORLIST_MAINTENANCE */ -typedef struct { - /** Action */ - t_u16 action; - /** BSSID */ - t_u8 BSSID[ETH_ALEN]; -} __ATTRIB_PACK__ HostCmd_DS_CMD_ROAMAGENT_NEIGHBORLIST_MAINTENANCE; - -#endif /* _MLANROAMAGENT_H_ */ diff --git a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanscanagent.c b/mxm_wifiex/wlan_src/mapp/mlanutl/mlanscanagent.c deleted file mode 100644 index 443f428..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanscanagent.c +++ /dev/null @@ -1,841 +0,0 @@ -/** @file mlanscanagent.c - * - * @brief This files contains mlanutl scanagent command handling. - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 08/11/2009: initial version -************************************************************************/ - -#include "mlanutl.h" -#include "mlanhostcmd.h" -#include "mlanoffload.h" -#include "mlanscanagent.h" - -/******************************************************** - Local Variables -********************************************************/ - -/******************************************************** - Global Variables -********************************************************/ - -/******************************************************** - Local Functions -********************************************************/ - -/** - * @brief scanagent configure scan table - * - * @param age_limit age limit - * @param hold_limit hold limit - * - * @return MLAN_STATUS_SUCCESS on success, otherwise error code - */ -static int -scanagent_cfg_scan_table_limits(t_u32 age_limit, t_u32 hold_limit) -{ - int ret = 0; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd = NULL; - HostCmd_DS_SCANAGENT_SCAN_TABLE_LIMITS *scan_table_limits = NULL; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - cmd_len = S_DS_GEN + sizeof(HostCmd_DS_SCANAGENT_SCAN_TABLE_LIMITS); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - return -ENOMEM; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return -ENOMEM; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - hostcmd->command = cpu_to_le16(HostCmd_CMD_SCANAGENT_SCAN_TABLE_LIMITS); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - scan_table_limits = (HostCmd_DS_SCANAGENT_SCAN_TABLE_LIMITS *)pos; - scan_table_limits->table_age_limit = cpu_to_le16(age_limit); - scan_table_limits->table_hold_limit = cpu_to_le16(hold_limit); - - /* 0 set values are ignored by firmware */ - scan_table_limits->action = cpu_to_le16(HostCmd_ACT_GEN_SET); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[scanAgentIoctl]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - printf("\nAge limit = %7d seconds\n", - le16_to_cpu(scan_table_limits->table_age_limit)); - printf("Hold limit = %7d seconds\n\n", - le16_to_cpu(scan_table_limits->table_hold_limit)); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Set scanagent age limit - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS on success, otherwise error code - */ -static int -scanagent_age_limit(int argc, char *argv[]) -{ - t_u32 age_limit = 0; - - if (argc) { - age_limit = atoi(argv[0]); - } - - return scanagent_cfg_scan_table_limits(age_limit, 0); -} - -/** - * @brief Set scanagent hold limit - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS on success, otherwise error code - */ -static int -scanagent_hold_limit(int argc, char *argv[]) -{ - t_u32 hold_limit = 0; - - if (argc) { - hold_limit = atoi(argv[0]); - } - - return scanagent_cfg_scan_table_limits(0, hold_limit); -} - -/** - * @brief Set scanagent scan timing - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS on success, otherwise error code - */ -static int -scanagent_timing(int argc, char *argv[]) -{ - int ret = 0; - struct ifreq ifr; - int idx; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len = 0, sel = 0; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd = NULL; - HostCmd_DS_SCANAGENT_CONFIG_TIMING *cfg_timing_cmd = NULL; - MrvlIEtypes_ConfigScanTiming_t *cfg_timing_tlv = NULL; - timing_sel_t sel_str[] = { {"disconnected", 1}, - {"adhoc", 1}, - {"fullpower", 1}, - {"ieeeps", 1}, - {"periodic", 1} - }; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - cmd_len = S_DS_GEN + sizeof(t_u16); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - return -ENOMEM; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return -ENOMEM; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - hostcmd->command = cpu_to_le16(HostCmd_CMD_SCANAGENT_SCAN_TIMING); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - cfg_timing_cmd = (HostCmd_DS_SCANAGENT_CONFIG_TIMING *)pos; - cfg_timing_cmd->action = cpu_to_le16(HostCmd_ACT_GEN_GET); - - cfg_timing_tlv - = (MrvlIEtypes_ConfigScanTiming_t *)cfg_timing_cmd->tlv_buffer; - - if (argc == 5) { - cfg_timing_cmd->action = cpu_to_le16(HostCmd_ACT_GEN_SET); - cfg_timing_tlv->header.type = cpu_to_le16(TLV_TYPE_SCAN_TIMING); - cfg_timing_tlv->header.len = - cpu_to_le16(sizeof(MrvlIEtypes_ConfigScanTiming_t) - - sizeof(cfg_timing_tlv->header)); - - for (idx = 0; (unsigned int)idx < NELEMENTS(sel_str); idx++) { - if (strncmp(argv[0], - sel_str[idx].str, - sel_str[idx].match_len) == 0) { - sel = idx + 1; - break; - } - } - - if (idx == NELEMENTS(sel_str)) { - printf("Wrong argument for mode selected \"%s\"\n", - argv[0]); - ret = -EINVAL; - goto done; - } - - /* - * HostCmd_DS_ScanagentTimingMode_e; - * TIMING_MODE_INVALID = 0, - * TIMING_MODE_DISCONNECTED = 1, - * TIMING_MODE_ADHOC = 2, - * TIMING_MODE_FULL_POWER = 3, - * TIMING_MODE_IEEE_PS = 4, - * TIMING_MODE_PERIODIC_PS = 5, - */ - cfg_timing_tlv->mode = cpu_to_le32(sel); - cfg_timing_tlv->dwell = cpu_to_le32(atoi(argv[1])); - cfg_timing_tlv->max_off = cpu_to_le32(atoi(argv[2])); - cfg_timing_tlv->min_link = cpu_to_le32(atoi(argv[3])); - cfg_timing_tlv->rsp_timeout = cpu_to_le32(atoi(argv[4])); - - cmd_len += sizeof(MrvlIEtypes_ConfigScanTiming_t); - } - - hostcmd->size = cpu_to_le16(cmd_len); - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[scanAgentIoctl]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - ret = process_host_cmd_resp(HOSTCMD, buffer); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Set scanagent profile scan period - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS on success, otherwise error code - */ -static int -scanagent_profile_period(int argc, char *argv[]) -{ - int ret = 0; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len = 0; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd = NULL; - HostCmd_DS_SCANAGENT_CONFIG_PROFILE_SCAN *cfg_profile_scan = NULL; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - cmd_len = S_DS_GEN + sizeof(HostCmd_DS_SCANAGENT_CONFIG_PROFILE_SCAN); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - return -ENOMEM; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return -ENOMEM; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - hostcmd->command = - cpu_to_le16(HostCmd_CMD_SCANAGENT_CONFIG_PROFILE_SCAN); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - cfg_profile_scan = (HostCmd_DS_SCANAGENT_CONFIG_PROFILE_SCAN *)pos; - if (argc == 1) { - cfg_profile_scan->action = cpu_to_le16(HostCmd_ACT_GEN_SET); - cfg_profile_scan->scan_interval = cpu_to_le16(atoi(argv[0])); - } else { - cfg_profile_scan->action = cpu_to_le16(HostCmd_ACT_GEN_GET); - } - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[scanAgentIoctl]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - cfg_profile_scan->scan_interval = - le16_to_cpu(cfg_profile_scan->scan_interval); - if ((int)cfg_profile_scan->scan_interval == 0) - printf("\nProfile Scan interval: \n\n"); - else - printf("\nProfile Scan interval: %d seconds\n\n", - (int)cfg_profile_scan->scan_interval); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief scanagent parse entry selection - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * @param psel A pointer to scanagent entry selection - * - * @return None - */ -static void -scanAgentParseEntrySel(int argc, char *argv[], - HostCmd_DS_SCANAGENT_TABLE_MAINTENANCE *psel, - int *cmd_len) -{ - int arg_idx, tmp_idx; - t_u8 *tlv_pos; - MrvlIEtypes_SsIdParamSet_t *ssid; - MrvlIEtypes_Bssid_List_t *bssid; - unsigned int mac[ETH_ALEN]; - - tlv_pos = (t_u8 *)psel->tlv_buffer; - - for (arg_idx = 0; arg_idx < argc; arg_idx++) { - if (strncmp(argv[arg_idx], "ssid=", strlen("ssid=")) == 0) { - ssid = (MrvlIEtypes_SsIdParamSet_t *)tlv_pos; - ssid->header.type = cpu_to_le16(TLV_TYPE_SSID); - ssid->header.len = - strlen(argv[arg_idx]) - strlen("ssid="); - strncpy((char *)ssid->ssid, - (argv[arg_idx] + strlen("ssid=")), - ssid->header.len); - tlv_pos += - ssid->header.len + sizeof(MrvlIEtypesHeader_t); - ssid->header.len = cpu_to_le16(ssid->header.len); - - } else if (strncmp(argv[arg_idx], "bssid=", strlen("bssid=")) == - 0) { - bssid = (MrvlIEtypes_Bssid_List_t *)tlv_pos; - bssid->header.type = cpu_to_le16(TLV_TYPE_BSSID); - bssid->header.len = ETH_ALEN; - /* - * "bssid" token string handler - */ - sscanf(argv[arg_idx] + strlen("bssid="), - "%2x:%2x:%2x:%2x:%2x:%2x", mac + 0, mac + 1, - mac + 2, mac + 3, mac + 4, mac + 5); - for (tmp_idx = 0; - (unsigned int)tmp_idx < NELEMENTS(mac); - tmp_idx++) { - bssid->bssid[tmp_idx] = (t_u8)mac[tmp_idx]; - } - tlv_pos += - bssid->header.len + sizeof(MrvlIEtypesHeader_t); - bssid->header.len = cpu_to_le16(bssid->header.len); - - } else if (strncmp(argv[arg_idx], "age=", strlen("age=")) == 0) { - psel->age = - cpu_to_le32(atoi - (argv[arg_idx] + strlen("age="))); - - } else if (strncmp(argv[arg_idx], "id=", strlen("id=")) == 0) { - psel->scan_request_id = - cpu_to_le32(atoi - (argv[arg_idx] + strlen("id="))); - } - } - - *cmd_len += (tlv_pos - psel->tlv_buffer); -} - -/** - * @brief scanagent execute scan - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS on success, otherwise error code - */ -static int -scanagent_exec_scan(int argc, char *argv[]) -{ - int ret = 0; - struct ifreq ifr; - int arg_idx, tmp_idx; - t_u32 cmd_len = 0, cmd_header_len = 0; - t_u8 *buffer = NULL, *pos = NULL, *tlv_pos = NULL; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd = NULL; - HostCmd_DS_SCANAGENT_SCAN_EXEC *scan_exec = NULL; - MrvlIEtypes_SsIdParamSet_t *ssid = NULL; - MrvlIEtypes_Bssid_List_t *bssid = NULL; - MrvlIEtypes_ConfigScanTiming_t *cfg_timing_tlv = NULL; - unsigned int mac[ETH_ALEN]; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - cmd_len = (S_DS_GEN + sizeof(HostCmd_DS_SCANAGENT_SCAN_EXEC) - - sizeof(scan_exec->tlv_buffer)); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - return -ENOMEM; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return -ENOMEM; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - hostcmd->command = cpu_to_le16(HostCmd_CMD_SCANAGENT_SCAN_EXEC); - hostcmd->size = 0; - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - scan_exec = (HostCmd_DS_SCANAGENT_SCAN_EXEC *)pos; - tlv_pos = scan_exec->tlv_buffer; - - for (arg_idx = 0; arg_idx < argc; arg_idx++) { - if (strncmp(argv[arg_idx], "ssid=", strlen("ssid=")) == 0) { - /* - * "ssid" token string handler - */ - ssid = (MrvlIEtypes_SsIdParamSet_t *)tlv_pos; - ssid->header.type = cpu_to_le16(TLV_TYPE_SSID); - ssid->header.len = - strlen(argv[arg_idx]) - strlen("ssid="); - strncpy((char *)ssid->ssid, - argv[arg_idx] + strlen("ssid="), - ssid->header.len); - tlv_pos += - ssid->header.len + sizeof(MrvlIEtypesHeader_t); - ssid->header.len = cpu_to_le16(ssid->header.len); - } else if (strncmp(argv[arg_idx], "bssid=", strlen("bssid=")) == - 0) { - bssid = (MrvlIEtypes_Bssid_List_t *)tlv_pos; - bssid->header.type = cpu_to_le16(TLV_TYPE_BSSID); - bssid->header.len = ETH_ALEN; - /* - * "bssid" token string handler - */ - sscanf(argv[arg_idx] + strlen("bssid="), - "%2x:%2x:%2x:%2x:%2x:%2x", mac + 0, mac + 1, - mac + 2, mac + 3, mac + 4, mac + 5); - for (tmp_idx = 0; - (unsigned int)tmp_idx < NELEMENTS(mac); - tmp_idx++) { - bssid->bssid[tmp_idx] = (t_u8)mac[tmp_idx]; - } - tlv_pos += - bssid->header.len + sizeof(MrvlIEtypesHeader_t); - bssid->header.len = cpu_to_le16(bssid->header.len); - } else if (strncmp(argv[arg_idx], "type=", strlen("type=")) == - 0) { - /* - if (strcmp(argv[arg_idx] + strlen("type="), "prof") == 0) { - scan_exec->scan_type = CONFIG_PROFILE; - } else { - scan_exec->scan_type = CONFIG_SITE_SURVEY; - } - */ - scan_exec->scan_type = CONFIG_SITE_SURVEY; - scan_exec->scan_type = - cpu_to_le16(scan_exec->scan_type); - } else if (strncmp(argv[arg_idx], "group=", strlen("group=")) == - 0) { - sscanf(argv[arg_idx] + strlen("group="), "0x%x", - &tmp_idx); - scan_exec->chan_group = cpu_to_le32(tmp_idx); - } else if (strncmp(argv[arg_idx], "delay=", strlen("delay=")) == - 0) { - /* - * "delay" token string handler - */ - sscanf(argv[arg_idx] + strlen("delay="), - "%d", (int *)&scan_exec->delay); - scan_exec->delay = cpu_to_le32(scan_exec->delay); - } else if (strncmp(argv[arg_idx], "timing=", strlen("timing=")) - == 0) { - cfg_timing_tlv = - (MrvlIEtypes_ConfigScanTiming_t *)tlv_pos; - cfg_timing_tlv->header.type = - cpu_to_le16(TLV_TYPE_SCAN_TIMING); - cfg_timing_tlv->header.len = ((sizeof(cfg_timing_tlv) - - - sizeof(cfg_timing_tlv-> - header))); - /* - * "timing" token string handler - */ - sscanf(argv[arg_idx] + strlen("timing="), "%d,%d,%d,%d", - (int *)&cfg_timing_tlv->dwell, - (int *)&cfg_timing_tlv->max_off, - (int *)&cfg_timing_tlv->min_link, - (int *)&cfg_timing_tlv->rsp_timeout); - - cfg_timing_tlv->mode = 0; - cfg_timing_tlv->dwell = - cpu_to_le32(cfg_timing_tlv->dwell); - cfg_timing_tlv->max_off = - cpu_to_le32(cfg_timing_tlv->max_off); - cfg_timing_tlv->min_link = - cpu_to_le32(cfg_timing_tlv->min_link); - cfg_timing_tlv->rsp_timeout = - cpu_to_le32(cfg_timing_tlv->rsp_timeout); - - tlv_pos += sizeof(MrvlIEtypesHeader_t); - tlv_pos += cfg_timing_tlv->header.len; - cfg_timing_tlv->header.len = - cpu_to_le16(cfg_timing_tlv->header.len); - } - } - - cmd_len += (tlv_pos - scan_exec->tlv_buffer); - hostcmd->size = cpu_to_le16(cmd_len); - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[scanAgentIoctl]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } else { - printf("\nScan Scheduled, ID = %d\n\n", - (int)le32_to_cpu(scan_exec->scan_req_id_out)); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue a scanagent cmd_type subcommand - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * @param cmd_type command type - * - * @return MLAN_STATUS_SUCCESS on success, otherwise error code - */ -static int -scanagent_table_entry_sub_cmd(int argc, char *argv[], - HostCmd_DS_ScanagentTableMaintenance_e cmd_type) -{ - int ret = 0; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len = 0; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd = NULL; - HostCmd_DS_SCANAGENT_TABLE_MAINTENANCE *table_maintenance = NULL; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - cmd_len = (S_DS_GEN + sizeof(HostCmd_DS_SCANAGENT_TABLE_MAINTENANCE) - - sizeof(table_maintenance->tlv_buffer)); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - return -ENOMEM; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return -ENOMEM; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - hostcmd->command = cpu_to_le16(HostCmd_CMD_SCANAGENT_TABLE_MAINTENANCE); - hostcmd->size = 0; - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - table_maintenance = (HostCmd_DS_SCANAGENT_TABLE_MAINTENANCE *)pos; - table_maintenance->action = cpu_to_le16((t_u16)cmd_type); - - scanAgentParseEntrySel(argc, argv, table_maintenance, (int *)&cmd_len); - - hostcmd->size = cpu_to_le16(cmd_len); - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[scanAgentIoctl]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Issue a scanagent table lock subcommand - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS on success, otherwise error code - */ -static int -scanagent_table_lock(int argc, char *argv[]) -{ - return scanagent_table_entry_sub_cmd(argc, argv, SCAN_TABLE_OP_LOCK); -} - -/** - * @brief Issue a scanagent table unlock subcommand - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS on success, otherwise error code - */ -static int -scanagent_table_unlock(int argc, char *argv[]) -{ - return scanagent_table_entry_sub_cmd(argc, argv, SCAN_TABLE_OP_UNLOCK); -} - -/** - * @brief Issue a scanagent table purge subcommand - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS on success, otherwise error code - */ -static int -scanagent_table_purge(int argc, char *argv[]) -{ - return scanagent_table_entry_sub_cmd(argc, argv, SCAN_TABLE_OP_PURGE); -} - -/** - * @brief Issue a scanagent command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_scanagent(int argc, char *argv[]) -{ - sub_cmd_exec_t sub_cmd[] = { - {"timing", 2, 1, scanagent_timing}, - {"scan", 2, 1, scanagent_exec_scan}, - {"lock", 2, 1, scanagent_table_lock}, - {"unlock", 2, 1, scanagent_table_unlock}, - {"purge", 2, 1, scanagent_table_purge}, - {"profile", 2, 1, scanagent_profile_period}, - {"holdlimit", 2, 1, scanagent_hold_limit}, - {"agelimit", 2, 1, scanagent_age_limit} - }; - - return process_sub_cmd(sub_cmd, NELEMENTS(sub_cmd), argc, argv); -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanscanagent.h b/mxm_wifiex/wlan_src/mapp/mlanutl/mlanscanagent.h deleted file mode 100644 index 0453794..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanscanagent.h +++ /dev/null @@ -1,150 +0,0 @@ -/** @file mlanscanagent.h - * - * @brief This files contains mlanutl scanagent command handling. - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ -/************************************************************************ -Change log: - 08/11/2009: initial version -************************************************************************/ - -#ifndef _MLAN_SCANAGENT_H_ -#define _MLAN_SCANAGENT_H_ - -typedef struct { - /** Action GET or SET */ - t_u16 action; - /** scan interval */ - t_u16 scan_interval; -} __ATTRIB_PACK__ HostCmd_DS_SCANAGENT_CONFIG_PROFILE_SCAN; - -typedef struct { - t_u32 scan_req_id_out; - /**< Scan request id */ - t_u32 delay; /**< Delay */ - t_u32 chan_group; /**< Channel Group */ - t_u16 scan_type; /**< Scan type */ - t_u16 reserved; /**< Reserved */ - - t_u8 tlv_buffer[1]; /**< Rest is TLV buffer */ - - /* MrvlIEtypes_SsIdParamSet_t - * MrvlIEtypes_Bssid_List_t - * MrvlIEtypes_ConfigScanTiming_t - */ -} __ATTRIB_PACK__ HostCmd_DS_SCANAGENT_SCAN_EXEC; - -typedef struct { - /** Action Set or get */ - t_u16 action; - /** Reserved */ - t_u16 reserved; - /** Table age limit */ - t_u16 table_age_limit; - /** Table hold limit */ - t_u16 table_hold_limit; -} __ATTRIB_PACK__ HostCmd_DS_SCANAGENT_SCAN_TABLE_LIMITS; - -typedef struct { - /** Action Set or get */ - t_u16 action; - /** TLV buffer starts here */ - t_u8 tlv_buffer[1]; - /* MrvlIEtypes_ConfigScanTiming_t */ -} __ATTRIB_PACK__ HostCmd_DS_SCANAGENT_CONFIG_TIMING; - -typedef struct { - /** HostCmd_DS_ScanagentTableMaintenance_e action */ - t_u16 action; - /** Reserved */ - t_u16 reserved; - /** Request Id, 0 to disable */ - t_u32 scan_request_id; - /** Age, 0 to disable */ - t_u32 age; - /** TLV Buffer follows */ - t_u8 tlv_buffer[1]; - - /* MrvlIEtypes_SsIdParamSet_t - * MrvlIEtypes_Bssid_List_t - */ -} __ATTRIB_PACK__ HostCmd_DS_SCANAGENT_TABLE_MAINTENANCE; - -/** ENUM definition: Scanagent Table Maintenance */ -typedef enum { - SCAN_TABLE_OP_INVALID = 0, - - SCAN_TABLE_OP_LOCK = 1, - SCAN_TABLE_OP_UNLOCK = 2, - SCAN_TABLE_OP_PURGE = 3, - -} __ATTRIB_PACK__ HostCmd_DS_ScanagentTableMaintenance_e; - -/** MrvlIEtypes_SsIdParamSet_t */ -typedef struct _MrvlIEtypes_SsIdParamSet_t { - /** Header */ - MrvlIEtypesHeader_t header; - /** SSID */ - t_u8 ssid[1]; -} __ATTRIB_PACK__ MrvlIEtypes_SsIdParamSet_t; - -/** _MrvlIEtypes_Bssid_List_t */ -typedef struct _MrvlIEtypes_Bssid_List_t { - /** Header */ - MrvlIEtypesHeader_t header; - /** BSSID */ - t_u8 bssid[ETH_ALEN]; -} __ATTRIB_PACK__ MrvlIEtypes_Bssid_List_t; - -typedef struct { - /** Header */ - MrvlIEtypesHeader_t header; - - t_u32 mode; /**< Mode */ - t_u32 dwell; /**< Dwell */ - t_u32 max_off; /**< Max. off */ - t_u32 min_link;/**< Minimum Link */ - t_u32 rsp_timeout; - /**< Rsp Timeout */ - -} __ATTRIB_PACK__ MrvlIEtypes_ConfigScanTiming_t; - -/** ENUM definition: ScanAgentScanType */ -typedef enum { - CONFIG_SITE_SURVEY = 0, - CONFIG_NEIGHBOR = 1, - CONFIG_PROFILE = 2, - CONFIG_ARBITRARY_CHANNEL = 3, - -} __ATTRIB_PACK__ HostCmd_DS_ScanagentScanType_e; - -/** ENUM definition: ScanAgentScanTimingMode */ -typedef enum { - TIMING_MODE_INVALID = 0, - - TIMING_MODE_DISCONNECTED = 1, - TIMING_MODE_ADHOC = 2, - TIMING_MODE_FULL_POWER = 3, - TIMING_MODE_IEEE_PS = 4, - TIMING_MODE_PERIODIC_PS = 5, - -} __ATTRIB_PACK__HostCmd_DS_ScanagentTimingMode_e; - -int process_host_cmd_resp(char *cmd_name, t_u8 *buf); -#endif /* _MLAN_SCANAGENT_H_ */ diff --git a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.c b/mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.c index 900370e..5843da5 100644 --- a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.c +++ b/mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.c @@ -1,24 +1,24 @@ /** @file mlanutl.c - * - * @brief Program to control parameters in the mlandriver - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ + * + * @brief Program to control parameters in the mlandriver + * + * + * Copyright 2014-2020 NXP + * + * This software file (the File) is distributed by NXP + * under the terms of the GNU General Public License Version 2, June 1991 + * (the License). You may use, redistribute and/or modify the File in + * accordance with the terms and conditions of the License, a copy of which + * is available by writing to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the + * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. + * + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about + * this warranty disclaimer. + * + */ /************************************************************************ Change log: 11/04/2011: initial version @@ -40,492 +40,100 @@ Change log: #include #include -#include "mlanutl.h" +#include "mlanutl.h" /** Supported stream modes */ -#define HT_STREAM_MODE_1X1 0x11 -#define HT_STREAM_MODE_2X2 0x22 +#define HT_STREAM_MODE_1X1 0x11 +#define HT_STREAM_MODE_2X2 0x22 /** mlanutl version number */ -#define MLANUTL_VER "M1.3" +#define MLANUTL_VER "M1.3.01" /** Initial number of total private ioctl calls */ -#define IW_INIT_PRIV_NUM 128 +#define IW_INIT_PRIV_NUM 128 /** Maximum number of total private ioctl calls supported */ -#define IW_MAX_PRIV_NUM 1024 +#define IW_MAX_PRIV_NUM 1024 /** Termination flag */ int terminate_flag = 0; typedef struct { - t_u8 chanNum; /**< Channel Number */ - t_u8 chanLoad; /**< Channel Load fraction */ - t_s16 anpi; /**< Channel ANPI */ + t_u8 chanNum; /**< Channel Number */ + t_u8 chanLoad; /**< Channel Load fraction */ + t_s16 anpi; /**< Channel ANPI */ } ChanRptInfo_t; /******************************************************** Local Variables ********************************************************/ -#define BAND_B (1U << 0) -#define BAND_G (1U << 1) -#define BAND_A (1U << 2) -#define BAND_GN (1U << 3) -#define BAND_AN (1U << 4) -#define BAND_GAC (1U << 5) -#define BAND_AAC (1U << 6) -#define BAND_GAX (1U << 8) -#define BAND_AAX (1U << 9) -static char *band[] = { - "B", - "G", - "A", - "GN", - "AN", - "GAC", - "AAC", - "11P", - "GAX", - "AAX", -}; +#define BAND_B (1U << 0) +#define BAND_G (1U << 1) +#define BAND_A (1U << 2) +#define BAND_GN (1U << 3) +#define BAND_AN (1U << 4) +#define BAND_GAC (1U << 5) +#define BAND_AAC (1U << 6) +#define BAND_GAX (1U << 8) +#define BAND_AAX (1U << 9) /** Stringification of rateId enumeration */ -const char *rateIdStr[] = { "1", "2", "5.5", "11", "--", - "6", "9", "12", "18", "24", "36", "48", "54", "--", - "M0", "M1", "M2", "M3", "M4", "M5", "M6", "M7", - "H0", "H1", "H2", "H3", "H4", "H5", "H6", "H7" -}; +const char *rateIdStr[] = {"1", "2", "5.5", "11", "--", "6", "9", "12", + "18", "24", "36", "48", "54", "--", "M0", "M1", + "M2", "M3", "M4", "M5", "M6", "M7", "H0", "H1", + "H2", "H3", "H4", "H5", "H6", "H7"}; #ifdef DEBUG_LEVEL1 -#define MMSG MBIT(0) -#define MFATAL MBIT(1) -#define MERROR MBIT(2) -#define MDATA MBIT(3) -#define MCMND MBIT(4) -#define MEVENT MBIT(5) -#define MINTR MBIT(6) -#define MIOCTL MBIT(7) +#define MMSG MBIT(0) +#define MFATAL MBIT(1) +#define MERROR MBIT(2) +#define MDATA MBIT(3) +#define MCMND MBIT(4) +#define MEVENT MBIT(5) +#define MINTR MBIT(6) +#define MIOCTL MBIT(7) -#define MREG_D MBIT(9) +#define MREG_D MBIT(9) -#define MMPA_D MBIT(15) -#define MDAT_D MBIT(16) -#define MCMD_D MBIT(17) -#define MEVT_D MBIT(18) -#define MFW_D MBIT(19) -#define MIF_D MBIT(20) +#define MMPA_D MBIT(15) +#define MDAT_D MBIT(16) +#define MCMD_D MBIT(17) +#define MEVT_D MBIT(18) +#define MFW_D MBIT(19) +#define MIF_D MBIT(20) -#define MENTRY MBIT(28) -#define MWARN MBIT(29) -#define MINFO MBIT(30) -#define MHEX_DUMP MBIT(31) -#endif -static int process_dot11_txrx(int argc, char *argv[]); -#ifdef RX_PACKET_COALESCE -static int process_rx_pkt_coalesce_cfg(int argc, char *argv[]); -static void print_rx_packet_coalesc_help(void); +#define MENTRY MBIT(28) +#define MWARN MBIT(29) +#define MINFO MBIT(30) +#define MHEX_DUMP MBIT(31) #endif + static int process_version(int argc, char *argv[]); -static int process_bandcfg(int argc, char *argv[]); +static int process_verext(int argc, char *argv[]); static int process_hostcmd(int argc, char *argv[]); -static int process_httxcfg(int argc, char *argv[]); -static int process_htcapinfo(int argc, char *argv[]); -static int process_addbapara(int argc, char *argv[]); -static int process_aggrpriotbl(int argc, char *argv[]); -static int process_addbareject(int argc, char *argv[]); -static int process_delba(int argc, char *argv[]); -static int process_rejectaddbareq(int argc, char *argv[]); -static int process_vhtcfg(int argc, char *argv[]); -static int process_opermodecfg(int argc, char *argv[]); -static int process_datarate(int argc, char *argv[]); -static int process_txratecfg(int argc, char *argv[]); -static int process_getlog(int argc, char *argv[]); -static int process_getcfgchanlist(int argc, char *argv[]); -static int process_esuppmode(int argc, char *argv[]); -static int process_passphrase(int argc, char *argv[]); -static int process_deauth(int argc, char *argv[]); -#ifdef UAP_SUPPORT -static int process_getstalist(int argc, char *argv[]); -#endif -#ifdef WIFI_DIRECT_SUPPORT -#if defined(STA_SUPPORT) && defined(UAP_SUPPORT) -static int process_bssrole(int argc, char *argv[]); -#endif -#endif -#ifdef STA_SUPPORT -static int process_setuserscan(int argc, char *argv[]); -static int wlan_process_getscantable(int argc, char *argv[], - wlan_ioctl_user_scan_cfg *scan_req); -static int wlan_process_getchanstats(int argc, char *argv[]); -static int process_getchanstats(int argc, char *argv[]); -static int process_getscantable(int argc, char *argv[]); -static int process_extcapcfg(int argc, char *argv[]); -static int process_cancelscan(int argc, char *argv[]); -#endif -static int process_deepsleep(int argc, char *argv[]); -static int process_ipaddr(int argc, char *argv[]); -static int process_otpuserdata(int argc, char *argv[]); -static int process_countrycode(int argc, char *argv[]); -static int process_tcpackenh(int argc, char *argv[]); -#ifdef REASSOCIATION -static int process_assocessid(int argc, char *argv[]); -#endif -#ifdef STA_SUPPORT -static int process_listeninterval(int argc, char *argv[]); -static int process_psmode(int argc, char *argv[]); -#endif #ifdef DEBUG_LEVEL1 static int process_drvdbg(int argc, char *argv[]); #endif -static int process_hscfg(int argc, char *argv[]); -static int process_hssetpara(int argc, char *argv[]); -static int process_wakeupresaon(int argc, char *argv[]); -static int process_mgmtfilter(int argc, char *argv[]); -static int process_scancfg(int argc, char *argv[]); -static int process_aggrctrl(int argc, char *argv[]); -static int process_usbaggrctrl(int argc, char *argv[]); -static int process_warmreset(int argc, char *argv[]); -static int process_txpowercfg(int argc, char *argv[]); -static int process_pscfg(int argc, char *argv[]); -static int process_bcntimeoutcfg(int argc, char *argv[]); -static int process_sleeppd(int argc, char *argv[]); -static int process_txcontrol(int argc, char *argv[]); -static int process_dfs_offload_enable(int argc, char *argv[]); -static int process_customie(int argc, char *argv[]); -static int process_regrdwr(int argc, char *argv[]); -static int process_rdeeprom(int argc, char *argv[]); -static int process_memrdwr(int argc, char *argv[]); -#ifdef SDIO -static int process_sdcmd52rw(int argc, char *argv[]); -#endif -static int process_mefcfg(int argc, char *argv[]); -static int process_cfgdata(int argc, char *argv[]); -static int process_mgmtframetx(int argc, char *argv[]); -static int process_mgmt_frame_passthrough(int argc, char *argv[]); -static int process_hotspot_config(int argc, char *argv[]); -static int process_qconfig(int argc, char *argv[]); -static int process_addts(int argc, char *argv[]); -static int process_delts(int argc, char *argv[]); -static int process_wmm_qstatus(int argc, char *argv[]); -static int process_wmm_ts_status(int argc, char *argv[]); -static int process_qos_config(int argc, char *argv[]); -static int process_macctrl(int argc, char *argv[]); -static int process_fwmacaddr(int argc, char *argv[]); -static int process_regioncode(int argc, char *argv[]); -static int process_cfpinfo(int argc, char *argv[]); -static int process_offchannel(int argc, char *argv[]); -static int process_linkstats(int argc, char *argv[]); -#if defined(STA_SUPPORT) -static int process_pmfcfg(int argc, char *argv[]); -#endif -static int process_verext(int argc, char *argv[]); -static int process_usb_suspend(int argc, char *argv[]); -static int process_usb_resume(int argc, char *argv[]); -#if defined(STA_SUPPORT) && defined(STA_WEXT) -static int process_radio_ctrl(int argc, char *argv[]); -#endif -static int process_wmm_cfg(int argc, char *argv[]); -static int process_wmm_param_config(int argc, char *argv[]); -static int process_min_ba_threshold_cfg(int argc, char *argv[]); -#if defined(STA_SUPPORT) -static int process_11d_cfg(int argc, char *argv[]); -static int process_11d_clr_tbl(int argc, char *argv[]); -#endif -#ifndef OPCHAN -static int process_wws_cfg(int argc, char *argv[]); -#endif -#if defined(REASSOCIATION) -static int process_set_get_reassoc(int argc, char *argv[]); -#endif -static int process_txbuf_cfg(int argc, char *argv[]); -#ifdef STA_SUPPORT -static int process_set_get_auth_type(int argc, char *argv[]); -#endif -static int process_11h_local_pwr_constraint(int argc, char *argv[]); -static int process_ht_stream_cfg(int argc, char *argv[]); -static int process_mimo_switch(int argc, char *argv[]); -static int process_thermal(int argc, char *argv[]); -static int process_beacon_interval(int argc, char *argv[]); -static int process_cwmode(int argc, char *argv[]); +static int process_datarate(int argc, char *argv[]); +static int process_getlog(int argc, char *argv[]); #ifdef STA_SUPPORT static int process_get_signal(int argc, char *argv[]); -static int process_get_signal_ext(int argc, char *argv[]); -static int process_signalext_cfg(int argc, char *argv[]); #endif -static int process_inactivity_timeout_ext(int argc, char *argv[]); -static int process_11n_amsdu_aggr_ctrl(int argc, char *argv[]); -static int process_tx_bf_cap_ioctl(int argc, char *argv[]); -#ifdef SDIO -static int process_sdio_clock_ioctl(int argc, char *argv[]); -#endif -#ifdef SDIO -static int process_sdio_mpa_ctrl(int argc, char *argv[]); -#endif -static int process_sleep_params(int argc, char *argv[]); -static int process_dfs_testing(int argc, char *argv[]); -static int process_cfp_code(int argc, char *argv[]); -static int process_set_get_tx_rx_ant(int argc, char *argv[]); static int process_get_txpwrlimit(int argc, char *argv[]); -static int process_get_chnrgpwr(int argc, char *argv[]); -static int process_compare_rgpwr(int argc, char *argv[]); -static int process_comparetrpc(int argc, char *argv[]); -static int process_sysclock(int argc, char *argv[]); -static int process_get_key(int argc, char *argv[]); -static int process_associate_ssid_bssid(int argc, char *argv[]); -static int process_tx_bf_cfg(int argc, char *argv[]); -static int process_wps_cfg(int argc, char *argv[]); -static int process_port_ctrl(int argc, char *argv[]); -static int process_bypassed_packet(int argc, char *argv[]); -/* #ifdef FW_WAKEUP_METHOD */ -static int process_fw_wakeup_method(int argc, char *argv[]); -/* #endif */ -#ifdef SDIO -static int process_sdcmd53rw(int argc, char *argv[]); -#endif -#ifdef WIFI_DIRECT_SUPPORT -static int process_cfg_noa_opp_ps(int argc, char *argv[]); -#endif -static int process_dscpmap(int argc, char *argv[]); -#ifdef WIFI_DIRECT_SUPPORT -static int process_miracastcfg(int argc, char *argv[]); -#endif -static int process_coex_rx_winsize(int argc, char *argv[]); -static int process_dfs_repeater(int argc, char *argv[]); -#ifdef PCIE -static int process_pcie_reg_rw(int argc, char *argv[]); -static int process_pcie_bar0_reg_rw(int argc, char *argv[]); -#endif -static int process_get_sensor_temp(int argc, char *argv[]); -static int process_chan_graph(int argc, char *argv[]); -static int process_extend_channel_switch(int argc, char *argv[]); -static int process_auto_arp(int argc, char *argv[]); -static int process_txrxhistogram(int argc, char *argv[]); -static int process_per_pkt_cfg(int argc, char *argv[]); -static int process_ind_rst_cfg(int argc, char *argv[]); -static int process_cloud_keep_alive(int argc, char *argv[]); -int process_tsf(int argc, char *argv[]); -static int process_dyn_bw(int argc, char *argv[]); -static int process_robustcoex(int argc, char *argv[]); -static int process_dmcs(int argc, char *argv[]); -#if defined(PCIE) -static int process_ssu_cmd(int argc, char *argv[]); -#endif -static int process_ctrldeauth(int argc, char *argv[]); -static int process_bootsleep(int argc, char *argv[]); -static int process_11axcfg(int argc, char *argv[]); -static int process_11axcmdcfg(int argc, char *argv[]); -static int process_twt_setup(int argc, char *argv[]); -static int process_twt_teardown(int argc, char *argv[]); - -static int process_rx_abort_cfg(int argc, char *argv[]); -static int process_rx_abort_cfg_ext(int argc, char *argv[]); -static int process_tx_ampdu_prot_mode(int argc, char *argv[]); -static int process_rate_adapt_cfg(int argc, char *argv[]); -static int process_cck_desense_cfg(int argc, char *argv[]); -static int process_lpm(int argc, char *argv[]); struct command_node command_list[] = { {"version", process_version}, - {"bandcfg", process_bandcfg}, + {"verext", process_verext}, {"hostcmd", process_hostcmd}, - {"httxcfg", process_httxcfg}, - {"htcapinfo", process_htcapinfo}, - {"addbapara", process_addbapara}, - {"aggrpriotbl", process_aggrpriotbl}, - {"addbareject", process_addbareject}, - {"delba", process_delba}, - {"rejectaddbareq", process_rejectaddbareq}, - {"vhtcfg", process_vhtcfg}, - {"opermodecfg", process_opermodecfg}, - {"getdatarate", process_datarate}, - {"txratecfg", process_txratecfg}, - {"getlog", process_getlog}, - {"esuppmode", process_esuppmode}, - {"passphrase", process_passphrase}, - {"deauth", process_deauth}, -#ifdef UAP_SUPPORT - {"getstalist", process_getstalist}, -#endif -#ifdef WIFI_DIRECT_SUPPORT -#if defined(STA_SUPPORT) && defined(UAP_SUPPORT) - {"bssrole", process_bssrole}, -#endif -#endif -#ifdef STA_SUPPORT - {"setuserscan", process_setuserscan}, - {"getscantable", process_getscantable}, - {"getchanstats", process_getchanstats}, - {"extcapcfg", process_extcapcfg}, - {"cancelscan", process_cancelscan}, -#endif - {"deepsleep", process_deepsleep}, - {"ipaddr", process_ipaddr}, - {"otpuserdata", process_otpuserdata}, - {"countrycode", process_countrycode}, - {"tcpackenh", process_tcpackenh}, -#ifdef REASSOCIATION - {"assocessid", process_assocessid}, - {"assocessid_bssid", process_assocessid}, -#endif -#ifdef STA_SUPPORT - {"listeninterval", process_listeninterval}, - {"psmode", process_psmode}, -#endif #ifdef DEBUG_LEVEL1 {"drvdbg", process_drvdbg}, #endif - {"hscfg", process_hscfg}, - {"hssetpara", process_hssetpara}, - {"wakeupreason", process_wakeupresaon}, - {"mgmtfilter", process_mgmtfilter}, - {"scancfg", process_scancfg}, - {"aggrctrl", process_aggrctrl}, - {"usbaggrctrl", process_usbaggrctrl}, - {"warmreset", process_warmreset}, - {"txpowercfg", process_txpowercfg}, - {"pscfg", process_pscfg}, - {"bcntimeoutcfg", process_bcntimeoutcfg}, - {"sleeppd", process_sleeppd}, - {"txcontrol", process_txcontrol}, - {"dfs_offload", process_dfs_offload_enable}, - {"customie", process_customie}, - {"regrdwr", process_regrdwr}, - {"rdeeprom", process_rdeeprom}, - {"memrdwr", process_memrdwr}, -#ifdef SDIO - {"sdcmd52rw", process_sdcmd52rw}, -#endif - {"mefcfg", process_mefcfg}, - {"cfgdata", process_cfgdata}, - {"mgmtframetx", process_mgmtframetx}, - {"mgmtframectrl", process_mgmt_frame_passthrough}, - {"hotspotcfg", process_hotspot_config}, - {"qconfig", process_qconfig}, - {"addts", process_addts}, - {"delts", process_delts}, - {"ts_status", process_wmm_ts_status}, - {"qstatus", process_wmm_qstatus}, - {"qoscfg", process_qos_config}, - {"macctrl", process_macctrl}, - {"fwmacaddr", process_fwmacaddr}, - {"regioncode", process_regioncode}, - {"cfpinfo", process_cfpinfo}, - {"offchannel", process_offchannel}, - {"linkstats", process_linkstats}, -#if defined(STA_SUPPORT) - {"pmfcfg", process_pmfcfg}, -#endif - {"verext", process_verext}, - {"usbsuspend", process_usb_suspend}, - {"usbresume", process_usb_resume}, -#if defined(STA_SUPPORT) && defined(STA_WEXT) - {"radioctrl", process_radio_ctrl}, -#endif - {"wmmcfg", process_wmm_cfg}, - {"wmmparamcfg", process_wmm_param_config}, - {"min_ba_threshold", process_min_ba_threshold_cfg}, -#if defined(STA_SUPPORT) - {"11dcfg", process_11d_cfg}, - {"11dclrtbl", process_11d_clr_tbl}, -#endif -#ifndef OPCHAN - {"wwscfg", process_wws_cfg}, -#endif -#if defined(REASSOCIATION) - {"reassoctrl", process_set_get_reassoc}, -#endif - {"txbufcfg", process_txbuf_cfg}, -#ifdef STA_SUPPORT - {"authtype", process_set_get_auth_type}, -#endif - {"powercons", process_11h_local_pwr_constraint}, - {"htstreamcfg", process_ht_stream_cfg}, - {"mimoswitch", process_mimo_switch}, - {"thermal", process_thermal}, - {"bcninterval", process_beacon_interval}, - {"cwmode", process_cwmode}, + {"getdatarate", process_datarate}, + {"getlog", process_getlog}, #ifdef STA_SUPPORT {"getsignal", process_get_signal}, - {"getsignalext", process_get_signal_ext}, - {"getsignalextv2", process_get_signal_ext}, - {"signalextcfg", process_signalext_cfg}, #endif - {"inactivityto", process_inactivity_timeout_ext}, - {"amsduaggrctrl", process_11n_amsdu_aggr_ctrl}, - {"httxbfcap", process_tx_bf_cap_ioctl}, -#ifdef SDIO - {"sdioclock", process_sdio_clock_ioctl}, -#endif -#ifdef SDIO - {"mpactrl", process_sdio_mpa_ctrl}, -#endif - {"sleepparams", process_sleep_params}, - {"dfstesting", process_dfs_testing}, - {"cfpcode", process_cfp_code}, - {"antcfg", process_set_get_tx_rx_ant}, - {"get_chnrgpwr", process_get_chnrgpwr}, - {"comparergpwr", process_compare_rgpwr}, {"get_txpwrlimit", process_get_txpwrlimit}, - {"getcfgchanlist", process_getcfgchanlist}, - {"comparetrpc", process_comparetrpc}, - {"dscpmap", process_dscpmap}, - {"changraph", process_chan_graph}, - {"getkey", process_get_key}, - {"associate", process_associate_ssid_bssid}, - {"httxbfcfg", process_tx_bf_cfg}, - {"wpssession", process_wps_cfg}, - {"port_ctrl", process_port_ctrl}, - {"pb_bypass", process_bypassed_packet}, -/* #ifdef FW_WAKEUP_METHOD */ - {"fwwakeupmethod", process_fw_wakeup_method}, -/* #endif */ - {"sysclock", process_sysclock}, -#ifdef SDIO - {"sdcmd53rw", process_sdcmd53rw}, -#endif -#ifdef RX_PACKET_COALESCE - {"rxpktcoal_cfg", process_rx_pkt_coalesce_cfg}, -#endif -#ifdef WIFI_DIRECT_SUPPORT - {"cfg_noa", process_cfg_noa_opp_ps}, - {"cfg_opp_ps", process_cfg_noa_opp_ps}, -#endif -#ifdef WIFI_DIRECT_SUPPORT - {"miracastcfg", process_miracastcfg}, -#endif - {"coex_rx_winsize", process_coex_rx_winsize}, - {"dfs_repeater", process_dfs_repeater}, -#ifdef PCIE - {"pcieregrw", process_pcie_reg_rw}, - {"pciebar0regrw", process_pcie_bar0_reg_rw}, -#endif - {"get_sensor_temp", process_get_sensor_temp}, - {"channel_switch", process_extend_channel_switch}, - {"auto_arp", process_auto_arp}, - {"txrxhistogram", process_txrxhistogram}, - {"indrstcfg", process_ind_rst_cfg}, - {"cloud_keep_alive", process_cloud_keep_alive}, - {"tsf", process_tsf}, - {"dot11_txrx", process_dot11_txrx}, - {"per_pkt_cfg", process_per_pkt_cfg}, - {"dyn_bw", process_dyn_bw}, - {"robustcoex", process_robustcoex}, -#if defined(PCIE) - {"ssu", process_ssu_cmd}, -#endif - {"ctrldeauth", process_ctrldeauth}, - {"bootsleep", process_bootsleep}, - {"dmcs", process_dmcs}, - {"11axcfg", process_11axcfg}, - {"11axcmd", process_11axcmdcfg}, - {"twt_setup", process_twt_setup}, - {"twt_teardown", process_twt_teardown}, - {"rx_abort_cfg", process_rx_abort_cfg}, - {"rx_abort_cfg_ext", process_rx_abort_cfg_ext}, - {"tx_ampdu_prot_mode", process_tx_ampdu_prot_mode}, - {"rate_adapt_cfg", process_rate_adapt_cfg}, - {"cck_desense_cfg", process_cck_desense_cfg}, - {"lpm", process_lpm}, }; static char *usage[] = { @@ -535,198 +143,18 @@ static char *usage[] = { " where", " ifname : wireless network interface name, such as mlanX or uapX", " cmd :", - " 11dcfg", - " 11dclrtbl", - " addbapara", - " addbareject", - " addts", - " aggrpriotbl", - " amsduaggrctrl", - " antcfg", -#ifdef REASSOCIATION - " assocessid", - " assocessid_bssid", -#endif - " associate", - " authtype", - " bandcfg", - " bcninterval", -#ifdef WIFI_DIRECT_SUPPORT -#if defined(STA_SUPPORT) && defined(UAP_SUPPORT) - " bssrole", -#endif -#endif - " cfgdata", - " cfpcode", - " changraph", - " coex_rx_winsize", - " countrycode", - " customie", - " deauth", - " deepsleep", - " delba", - " delts", - " dfstesting", - " dfs_repeater", + " version", + " verext", + " hostcmd", #ifdef DEBUG_LEVEL1 " drvdbg", #endif - " dscpmap", - " esuppmode", -#ifdef STA_SUPPORT - " extcapcfg", - " cancelscan", -#endif - " fwmacaddr", -/* #ifdef FW_WAKEUP_METHOD */ - " fwwakeupmethod", -/* #endif */ " getdatarate", - " getkey", " getlog", #ifdef STA_SUPPORT - " getscantable", -#endif " getsignal", -#ifdef UAP_SUPPORT - " getstalist", #endif - " hostcmd", - " hotspotcfg", - " hscfg", - " hssetpara", - " mgmtfilter", - " htcapinfo", - " htstreamcfg", - " mimoswitch", -#ifdef STA_SUPPORT - " signalextcfg", - " getsignalext", - " getsignalextv2", -#endif - " httxbfcap", - " httxbfcfg", - " httxcfg", - " inactivityto", - " ipaddr", - " linkstats", -#ifdef STA_SUPPORT - " listeninterval", -#endif - " macctrl", - " mefcfg", - " memrdwr", -#ifdef WIFI_DIRECT_SUPPORT - " miracastcfg", -#endif - " mgmtframectrl", - " mgmtframetx", -#ifdef SDIO - " mpactrl", -#endif -#ifdef WIFI_DIRECT_SUPPORT - " cfg_noa", - " cfg_opp_ps", -#endif - " offchannel", - " otpuserdata", - " passphrase", - " pb_bypass", -#ifdef PCIE - " pcieregrw", -#endif -#if defined(STA_SUPPORT) - " pmfcfg", -#endif - " port_ctrl", - " powercons", - " pscfg", -#ifdef STA_SUPPORT - " psmode", -#endif - " qconfig", - " qoscfg", - " qstatus", -#ifdef STA_WEXT - " radioctrl", -#endif - " rdeeprom", -#if defined(REASSOCIATION) - " reassoctrl", -#endif - " regioncode", - " cfpinfo", - " regrdwr", - " rejectaddbareq", - " scancfg", -#ifdef SDIO - " sdcmd52rw", - " sdcmd53rw", - " sdioclock", -#endif -#ifdef STA_SUPPORT - " setuserscan", -#endif - " sleepparams", - " sleeppd", - " sysclock", - " tcpackenh", - " thermal", - " ts_status", - " tsf", - " txbufcfg", - " txcontrol", - " txpowercfg", - " txratecfg", - " aggrctrl", - " usbaggrctrl", - " usbresume", - " usbsuspend", - " verext", - " version", - " vhtcfg", - " opermodecfg", - " wakeupreason", - " warmreset", - " wmmcfg", - " wmmparamcfg", - " min_ba_threshold", - " wpssession", -#ifndef OPCHAN - " wwscfg", -#endif -#ifdef RX_PACKET_COALESCE - " rxpktcoal_cfg", -#endif - " get_sensor_temp", - " channel_switch", - " indrstcfg", - " cloud_keep_alive", - " dfs_offload", - - " cwmode", - " dyn_bw", - " txrxhistogram", - " per_pkt_cfg", - " dot11_txrx", - " robustcoex", - " ctrldeauth", - " dmcs", - " 11axcfg", - " 11axcmd", - " twt_setup", - " twt_teardown", - " rx_abort_cfg", - " rx_abort_cfg_ext", - " tx_ampdu_prot_mode", - " rate_adapt_cfg", - " cck_desense_cfg", - " get_chnrgpwr", - " comparergpwr", " get_txpwrlimit", - " comparetrpc", - " getcfgchanlist", - " lpm", }; /** Socket */ @@ -735,9 +163,8 @@ t_s32 sockfd; char dev_name[IFNAMSIZ + 1]; #define HOSTCMD "hostcmd" -static char *config_get_line(char *s, int size, FILE * stream, int *line, +static char *config_get_line(char *s, int size, FILE *stream, int *line, char **_pos); -static int parse_line(char *line, char *args[], t_u16 args_count); #define BSSID_FILTER 1 #define SSID_FILTER 2 /******************************************************** @@ -750,38 +177,13 @@ int num_ssid_filter = 0; Local Functions ********************************************************/ -/** - * @brief isdigit for String. - * - * @param x Char string - * @return MLAN_STATUS_FAILURE for non-digit. - * MLAN_STATUS_SUCCESS for digit - */ -static int -ISDIGIT(char *x) -{ - unsigned int i; - for (i = 0; i < strlen(x); i++) - if (isdigit(x[i]) == 0) - return MLAN_STATUS_FAILURE; - return MLAN_STATUS_SUCCESS; -} - -/** - * Check of decimal or hex string - * @param num string - */ -#define IS_HEX_OR_DIGIT(num) \ - (strncasecmp("0x", (num), 2)?ISDIGIT((num)):ishexstring((num))) - /** * @brief Convert char to hex integer * * @param chr Char to convert * @return Hex integer or 0 */ -int -hexval(t_s32 chr) +int hexval(t_s32 chr) { if (chr >= '0' && chr <= '9') return chr - '0'; @@ -802,8 +204,7 @@ hexval(t_s32 chr) * @param delim Delim char * @return Hex integer */ -t_void -hexdump(char *prompt, t_void *p, t_s32 len, char delim) +t_void hexdump(char *prompt, t_void *p, t_s32 len, char delim) { t_s32 i; t_u8 *s = p; @@ -828,8 +229,7 @@ hexdump(char *prompt, t_void *p, t_s32 len, char delim) * @param chr Char * @return Hex integer */ -t_u8 -hexc2bin(char chr) +t_u8 hexc2bin(char chr) { if (chr >= '0' && chr <= '9') chr -= '0'; @@ -847,8 +247,7 @@ hexc2bin(char chr) * @param s A pointer string buffer * @return Hex integer */ -t_u32 -a2hex(char *s) +t_u32 a2hex(char *s) { t_u32 val = 0; @@ -869,8 +268,7 @@ a2hex(char *s) * @param value A pointer to string * @return Integer */ -t_u32 -a2hex_or_atoi(char *value) +t_u32 a2hex_or_atoi(char *value) { if (value[0] == '0' && (value[1] == 'X' || value[1] == 'x')) { return a2hex(value + 2); @@ -886,8 +284,7 @@ a2hex_or_atoi(char *value) * @param chr A pointer to return integer * @return A pointer to next data field */ -char * -convert2hex(char *ptr, t_u8 *chr) +char *convert2hex(char *ptr, t_u8 *chr) { t_u8 val; @@ -903,10 +300,10 @@ convert2hex(char *ptr, t_u8 *chr) /** * @brief Check the Hex String * @param s A pointer to the string - * @return MLAN_STATUS_SUCCESS --HexString, MLAN_STATUS_FAILURE --not HexString + * @return MLAN_STATUS_SUCCESS --HexString, MLAN_STATUS_FAILURE --not + * HexString */ -int -ishexstring(char *s) +int ishexstring(char *s) { int ret = MLAN_STATUS_FAILURE; t_s32 tmp; @@ -934,8 +331,7 @@ ishexstring(char *s) * @param buf A pointer to the string * @return Integer */ -int -atoval(char *buf) +int atoval(char *buf) { if (!strncasecmp(buf, "0x", 2)) return a2hex(buf + 2); @@ -950,8 +346,7 @@ atoval(char *buf) * * @return NA */ -static t_void -display_usage(t_void) +static t_void display_usage(t_void) { t_u32 i; for (i = 0; i < NELEMENTS(usage); i++) @@ -965,8 +360,7 @@ display_usage(t_void) * @param argv A pointer to arguments array * @return MLAN_STATUS_SUCCESS for success, otherwise failure */ -static int -process_command(int argc, char *argv[]) +static int process_command(int argc, char *argv[]) { int i = 0, ret = MLAN_STATUS_NOTFOUND; struct command_node *node = NULL; @@ -989,8 +383,7 @@ process_command(int argc, char *argv[]) * @param raw A pointer to the raw data buffer * @return Number of bytes read **/ -int -string2raw(char *str, unsigned char *raw) +int string2raw(char *str, unsigned char *raw) { int len = (strlen(str) + 1) / 2; @@ -1018,8 +411,7 @@ string2raw(char *str, unsigned char *raw) * @param args Arguments list * @return MLAN_STATUS_SUCCESS */ -static int -prepare_buffer(t_u8 *buffer, char *cmd, t_u32 num, char *args[]) +static int prepare_buffer(t_u8 *buffer, char *cmd, t_u32 num, char *args[]) { t_u8 *pos = NULL; unsigned int i = 0; @@ -1048,154 +440,6 @@ prepare_buffer(t_u8 *buffer, char *cmd, t_u32 num, char *args[]) return MLAN_STATUS_SUCCESS; } -/** - * @brief Determine the netlink number - * - * @param i socket number - * - * @return Netlink number to use - */ -static int -get_netlink_num(int i) -{ - FILE *fp; - int netlink_num = NETLINK_NXP; - char str[64]; - char *srch = "netlink_num"; - char filename[64]; - - /* Try to open old driver proc: /proc/mwlan/configX first */ - if (i == 0) - strcpy(filename, "/proc/mwlan/config"); - else if (i > 0) - sprintf(filename, "/proc/mwlan/config%d", i); - fp = fopen(filename, "r"); - if (!fp) { - /* Try to open multi-adapter driver proc: /proc/mwlan/adapterX/config if old proc access fail */ - snprintf(filename, sizeof(filename), - "/proc/mwlan/adapter%d/config", i); - fp = fopen(filename, "r"); - } - - if (fp) { - while (!feof(fp)) { - fgets(str, sizeof(str), fp); - if (strncmp(str, srch, strlen(srch)) == 0) { - netlink_num = atoi(str + strlen(srch) + 1); - break; - } - } - fclose(fp); - } else { - return -1; - } - return netlink_num; -} - -/** - * @brief Read event data from netlink socket - * - * @param sk_fd Netlink socket handler - * @param buffer Pointer to the data buffer - * @param nlh Pointer to netlink message header - * @param msg Pointer to message header - * - * @return Number of bytes read or MLAN_EVENT_FAILURE - */ -int -read_event_netlink_socket(int sk_fd, unsigned char *buffer, - struct nlmsghdr *nlh, struct msghdr *msg) -{ - int count = -1; - count = recvmsg(sk_fd, msg, 0); -#if DEBUG - printf("DBG:Waiting for message from NETLINK.\n"); -#endif - if (count < 0) { - printf("ERR:NETLINK read failed!\n"); - terminate_flag++; - return MLAN_EVENT_FAILURE; - } -#if DEBUG - printf("DBG:Received message payload (%d)\n", count); -#endif - if (count > NLMSG_SPACE(NL_MAX_PAYLOAD)) { - printf("ERR:Buffer overflow!\n"); - return MLAN_EVENT_FAILURE; - } - memset(buffer, 0, NL_MAX_PAYLOAD); - memcpy(buffer, NLMSG_DATA(nlh), count - NLMSG_HDRLEN); -#if DEBUG - hexdump(buffer, count - NLMSG_HDRLEN, ' '); -#endif - return count - NLMSG_HDRLEN; -} - -/** - * @brief Configure and read event data from netlink socket - * - * @param sk_fd Array of netlink sockets - * @param no_of_sk Number of netlink sockets opened - * @param recv_buf Pointer to the array of evt_buf structures - * @param timeout Socket listen timeout value - * @param nlh Pointer to netlink message header - * @param msg Pointer to message header - * - * @return Number of bytes read or MLAN_EVENT_FAILURE - */ -int -read_event(int *sk_fd, int no_of_sk, evt_buf *recv_buf, int timeout, - struct nlmsghdr *nlh, struct msghdr *msg) -{ - struct timeval tv; - fd_set rfds; - int i = 0, max_sk_fd = sk_fd[0]; - int ret = MLAN_EVENT_FAILURE; - - /* Setup read fds */ - FD_ZERO(&rfds); - for (i = 0; i < no_of_sk; i++) { - if (sk_fd[i] > max_sk_fd) - max_sk_fd = sk_fd[i]; - - if (sk_fd[i] > 0) - FD_SET(sk_fd[i], &rfds); - } - - /* Initialize timeout value */ - if (timeout != 0) - tv.tv_sec = timeout; - else - tv.tv_sec = UAP_RECV_WAIT_DEFAULT; - tv.tv_usec = 0; - - /* Wait for reply */ - ret = select(max_sk_fd + 1, &rfds, NULL, NULL, &tv); - if (ret == -1) { - /* Error */ - terminate_flag++; - return MLAN_EVENT_FAILURE; - } else if (!ret) { - /* Timeout. Try again */ - return MLAN_EVENT_FAILURE; - } - for (i = 0; i < no_of_sk; i++) { - if (sk_fd[i] > 0) { - if (FD_ISSET(sk_fd[i], &rfds)) { - /* Success */ - recv_buf[i].flag = 1; - recv_buf[i].length = - read_event_netlink_socket(sk_fd[i], - recv_buf[i]. - buffer, nlh, - msg); - ret += recv_buf[i].length; - } - } - } - return ret; -} - /** * @brief Signal handler * @@ -1203,737 +447,40 @@ read_event(int *sk_fd, int no_of_sk, evt_buf *recv_buf, int timeout, * * @return N/A */ -void -sig_handler(int sig) +void sig_handler(int sig) { printf("Stopping application.\n"); terminate_flag = 1; } /** - * @brief Wait event specified by event ID, and return back the pointer. - * - * @param eventID Event ID - * @param pEvent Pointer to the Event buffer - * @param pEventLen Pointer to the Event Length - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE + * @brief Trims leading and traling spaces only + * @param str A pointer to argument string + * @return pointer to trimmed string */ -static int -wait_event(t_u32 eventID, t_u8 *pEvent, int *pEventLen) +char *trim_spaces(char *str) { - int nl_sk[MAX_NO_OF_DEVICES]; - struct nlmsghdr *nlh = NULL; - struct sockaddr_nl src_addr, dest_addr; - struct msghdr msg; - struct iovec iov; - evt_buf evt_recv_buf[MAX_NO_OF_DEVICES]; - int num_events = 0; - event_header *event = NULL; - int ret = MLAN_EVENT_FAILURE; - int netlink_num[MAX_NO_OF_DEVICES]; - char if_name[IFNAMSIZ + 1]; - t_u32 event_id = 0; - int i = 0, no_of_sk = 0; - int buf_len = 0; + char *str_end = NULL; - if (!pEvent || !pEventLen) { - printf("ERR:Input paramater(s) 'pEvent' or 'pEventLen' is NULL"); - goto done; - } - - buf_len = *pEventLen; - *pEventLen = 0; - - /* Currently, we support maximum 4 devices */ - /* TODO: determine no_of_sk at run time */ - no_of_sk = MAX_NO_OF_DEVICES; - - for (i = 0; i < no_of_sk; i++) { - /* Initialise */ - nl_sk[i] = -1; - netlink_num[i] = get_netlink_num(i); - if (netlink_num[i] >= 0) { - /* Open netlink socket */ - nl_sk[i] = socket(PF_NETLINK, SOCK_RAW, netlink_num[i]); - if (nl_sk[i] < 0) { - printf("ERR:Could not open netlink socket.\n"); - ret = MLAN_EVENT_FAILURE; - goto done; - } - - /* Set source address */ - memset(&src_addr, 0, sizeof(src_addr)); - src_addr.nl_family = AF_NETLINK; - src_addr.nl_pid = getpid(); /* Our PID */ - src_addr.nl_groups = NL_MULTICAST_GROUP; - - /* Bind socket with source address */ - if (bind - (nl_sk[i], (struct sockaddr *)&src_addr, - sizeof(src_addr)) < 0) { - printf("ERR:Could not bind socket!\n"); - ret = MLAN_EVENT_FAILURE; - goto done; - } - - /* Set destination address */ - memset(&dest_addr, 0, sizeof(dest_addr)); - dest_addr.nl_family = AF_NETLINK; - dest_addr.nl_pid = 0; /* Kernel */ - dest_addr.nl_groups = NL_MULTICAST_GROUP; - - /* Initialize netlink header */ - nlh = (struct nlmsghdr *) - malloc(NLMSG_SPACE(NL_MAX_PAYLOAD)); - if (!nlh) { - printf("ERR: Could not alloc buffer\n"); - ret = MLAN_EVENT_FAILURE; - goto done; - } - memset(nlh, 0, NLMSG_SPACE(NL_MAX_PAYLOAD)); - - /* Initialize I/O vector */ - iov.iov_base = (void *)nlh; - iov.iov_len = NLMSG_SPACE(NL_MAX_PAYLOAD); - - /* Initialize message header */ - memset(&msg, 0, sizeof(struct msghdr)); - msg.msg_name = (void *)&dest_addr; - msg.msg_namelen = sizeof(dest_addr); - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - - memset(&evt_recv_buf[i], 0, sizeof(evt_buf)); - } - } - - signal(SIGTERM, sig_handler); - signal(SIGINT, sig_handler); - signal(SIGALRM, sig_handler); - while (1) { - if (terminate_flag) { - printf("Stopping!\n"); - break; - } - ret = read_event(nl_sk, no_of_sk, evt_recv_buf, 0, nlh, &msg); - - /* No result. Loop again */ - if (ret == MLAN_EVENT_FAILURE) { - continue; - } - if (ret == 0) { - /* Zero bytes received */ - printf("ERR:Received zero bytes!\n"); - continue; - } - for (i = 0; i < no_of_sk; i++) { - if (evt_recv_buf[i].flag == 1) { - num_events++; - - memcpy(&event_id, evt_recv_buf[i].buffer, - sizeof(event_id)); - if (((event_id & 0xFF000000) == 0x80000000) || - ((event_id & 0xFF000000) == 0)) { - event = (event_header - *)(evt_recv_buf[i].buffer); - } else { - memset(if_name, 0, IFNAMSIZ + 1); - memcpy(if_name, evt_recv_buf[i].buffer, - IFNAMSIZ); - event = (event_header - *)((t_u8 *)(evt_recv_buf[i]. - buffer) + - IFNAMSIZ); - ret -= IFNAMSIZ; - evt_recv_buf[i].length -= IFNAMSIZ; - } - if (event->event_id == eventID) { - if (buf_len > evt_recv_buf[i].length) { - *pEventLen = - evt_recv_buf[i].length; - memcpy(pEvent, (t_u8 *)event, - evt_recv_buf[i].length); - } else { - printf("ERR:Buffer length exceeded \n"); - } - goto done; - } - /* Reset event flag after reading */ - evt_recv_buf[i].flag = 0; - } - } - fflush(stdout); - } - -done: - for (i = 0; i < no_of_sk; i++) { - if (nl_sk[i] > 0) - close(nl_sk[i]); - } - if (nlh) - free(nlh); - return 0; - -} - -/** - * @brief Set Robustcoex gpiocfg - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_robustcoex(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd; - struct ifreq ifr; - - if (argc <= 4) { - printf("Err: Invalid number of arguments\n"); - printf("Usage: ./mlanutl robustcoex [gpiocfg] [value]\n"); - return MLAN_STATUS_FAILURE; - } - if (strcmp(argv[3], "gpiocfg") == 0) { - if (argc != 7 && argc != 5) { - printf("ERR: Invalid number of arguments\n"); - printf("Usage: ./mlanutl robustcoex gpiocfg [Enable][Gpionum][Gpiopolarity]\n"); - printf("Usage: ./mlanutl robustcoex gpiocfg [Disable]\n"); - return MLAN_STATUS_FAILURE; - } - } else { - printf("ERR: Invalid arguments\n"); - printf("Usage: ./mlanutl robustcoex [gpiocfg][value]\n"); - return MLAN_STATUS_FAILURE; - } - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: robustcoex fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Set/get DMCS config - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_dmcs(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd; - struct ifreq ifr; - struct eth_priv_dmcs_status *status; - int i = 0, j = 0; - - if (argc <= 3 || argc > 5) { - printf("Err: Invalid number of arguments\n"); - printf("Usage: ./mlanutl dmcs [subcmd] [value]\n"); - return MLAN_STATUS_FAILURE; - } - if ((*argv[3] != '0') && (*argv[3] != '1')) { - printf("Err: Invalid input argument of [subcmd]!\n"); - printf("Currently, we only support 0 and 1 for [subcmd]\n"); - return MLAN_STATUS_FAILURE; - } - if (*argv[3] == '0') { - if (argc != 5) { - printf("Err: Invalid number of arguments for disable/enable DMCS\n"); - printf("Usage: ./mlanutl dmcs [subcmd] [value]\n"); - return MLAN_STATUS_FAILURE; - } - } - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: dmcs fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - /* Process get status response */ - if (*argv[3] == '1') { - status = (struct eth_priv_dmcs_status *)buffer; - printf("mapping policy: %d\n", status->mapping_policy); - for (i = 0; i < MAX_NUM_MAC; i++) { - printf("radio_status[%d]:\n", i); - printf("\tradio id: %d\n", - status->radio_status[i].radio_id); - printf("\trunning mode: %d\n", - status->radio_status[i].running_mode); - for (j = 0; j < 2; j++) { - printf("\tchan_status[%d]:\n", j); - printf("\t\tchannel: %d\n", - status->radio_status[i].chan_status[j]. - channel); - printf("\t\tap count: %d\n", - status->radio_status[i].chan_status[j]. - ap_count); - printf("\t\tsta count: %d\n", - status->radio_status[i].chan_status[j]. - sta_count); - } - } - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return MLAN_STATUS_SUCCESS; -} - -#if defined(PCIE) -/** - * @brief Enable SSU support - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_ssu_cmd(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - char *args[30], *pos = NULL; - int li = 0, cmd_found = 0; - char *line = NULL; - FILE *fp = NULL; - ssu_params_cfg *ssu_params = NULL; - int ret = 0; - int ssu_mode = 0; - int used_len = 0; - - if ((argc != 3) && (argc != 4)) { - printf("Err: Invalid number of arguments\n"); - printf("Usage: ./mlanutl ssu\n"); - printf("Usage: ./mlanutl ssu config/ssu.conf\n"); - printf("Usage: ./mlanutl ssu 2\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - if (argc == 4) { - ssu_mode = (t_u8)a2hex_or_atoi(argv[3]); - used_len = - strlen(CMD_NXP) + strlen(argv[2]) + - sizeof(ssu_params_cfg); - } else { - used_len = strlen(CMD_NXP) + strlen(argv[2]); - } - prepare_buffer(buffer, argv[2], 0, NULL); - if (argc == 4 && (ssu_mode != 2)) { - line = (char *)malloc(MAX_CONFIG_LINE); - if (!line) { - printf("ERR:Cannot allocate memory for line\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(line, 0, MAX_CONFIG_LINE); - ssu_params = - (ssu_params_cfg *) (buffer + strlen(CMD_NXP) + - strlen(argv[2])); - ssu_params->ssu_mode = 0; - fp = fopen(argv[3], "r"); - if (fp == NULL) { - fprintf(stderr, "Cannot open file %s\n", argv[3]); - ret = MLAN_STATUS_FAILURE; - goto done; - } - /* Parse file and process */ - while (config_get_line(line, MAX_CONFIG_LINE, fp, &li, &pos)) { - parse_line(line, args, 30); - if (!cmd_found && - strncmp(args[0], "ssu_params_cfg", strlen(args[0]))) - continue; - cmd_found = 1; - if (strcmp(args[0], "nskip") == 0) - ssu_params->nskip = - (t_u32)a2hex_or_atoi(args[1]); - else if (strcmp(args[0], "nsel") == 0) - ssu_params->nsel = - (t_u32)a2hex_or_atoi(args[1]); - else if (strcmp(args[0], "adcdownsample") == 0) - ssu_params->adcdownsample = - (t_u32)a2hex_or_atoi(args[1]); - else if (strcmp(args[0], "mask_adc_pkt") == 0) - ssu_params->mask_adc_pkt = - (t_u32)a2hex_or_atoi(args[1]); - else if (strcmp(args[0], "out_16bits") == 0) - ssu_params->out_16bits = - (t_u32)a2hex_or_atoi(args[1]); - else if (strcmp(args[0], "spec_pwr_enable") == 0) - ssu_params->spec_pwr_enable = - (t_u32)a2hex_or_atoi(args[1]); - else if (strcmp(args[0], "rate_reduction") == 0) - ssu_params->rate_deduction = - (t_u32)a2hex_or_atoi(args[1]); - else if (strcmp(args[0], "n_pkt_avg") == 0) - ssu_params->n_pkt_avg = - (t_u32)a2hex_or_atoi(args[1]); - } - } else if (ssu_mode == 2) { - ssu_params = - (ssu_params_cfg *) (buffer + strlen(CMD_NXP) + - strlen(argv[2])); - ssu_params->ssu_mode = 2; - } - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - - } - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = used_len; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: ssu command fail\n"); - ret = MLAN_STATUS_FAILURE; - } -done: - if (line) - free(line); - if (fp) - fclose(fp); - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} -#endif - -/** - * @brief Get one line from the File - * - * @param fp File handler - * @param str Storage location for data. - * @param size Maximum number of characters to read. - * @param lineno A pointer to return current line number - * @return returns string or NULL - */ -char * -mlan_config_get_line(FILE * fp, char *str, t_s32 size, int *lineno) -{ - char *start, *end; - int out, next_line; - - if (!fp || !str) + if (!str) return NULL; - do { -read_line: - if (!fgets(str, size, fp)) - break; - start = str; - start[size - 1] = '\0'; - end = start + strlen(str); - (*lineno)++; + /* Trim leading spaces */ + while (!*str && isspace(*str)) + str++; - out = 1; - while (out && (start < end)) { - next_line = 0; - /* Remove empty lines and lines starting with # */ - switch (start[0]) { - case ' ': /* White space */ - case '\t': /* Tab */ - start++; - break; - case '#': - case '\n': - case '\0': - next_line = 1; - break; - case '\r': - if (start[1] == '\n') - next_line = 1; - else - start++; - break; - default: - out = 0; - break; - } - if (next_line) - goto read_line; - } + if (*str == 0) /* All spaces? */ + return str; - /* Remove # comments unless they are within a double quoted - * string. Remove trailing white space. */ - end = strstr(start, "\""); - if (end) { - end = strstr(end + 1, "\""); - if (!end) - end = start; - } else - end = start; + /* Trim trailing spaces */ + str_end = str + strlen(str) - 1; + while (str_end > str && isspace(*str_end)) + str_end--; - end = strstr(end + 1, "#"); - if (end) - *end-- = '\0'; - else - end = start + strlen(start) - 1; + /* null terminate the string */ + *(str_end + 1) = '\0'; - out = 1; - while (out && (start < end)) { - switch (*end) { - case ' ': /* White space */ - case '\t': /* Tab */ - case '\n': - case '\r': - *end = '\0'; - end--; - break; - default: - out = 0; - break; - } - } - - if (*start == '\0') - continue; - - return start; - } while (1); - - return NULL; -} - -/** - * @brief Parse function for a configuration line - * - * @param s Storage buffer for data - * @param size Maximum size of data - * @param stream File stream pointer - * @param line Pointer to current line within the file - * @param _pos Output string or NULL - * @return String or NULL - */ -static char * -config_get_line(char *s, int size, FILE * stream, int *line, char **_pos) -{ - *_pos = mlan_config_get_line(stream, s, size, line); - return *_pos; -} - -/** - * @brief Converts colon separated MAC address to hex value - * - * @param mac A pointer to the colon separated MAC string - * @param raw A pointer to the hex data buffer - * @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE - * MAC_BROADCAST - if broadcast mac - * MAC_MULTICAST - if multicast mac - */ -static int -mac2raw(char *mac, t_u8 *raw) -{ - unsigned int temp_raw[ETH_ALEN]; - int num_tokens = 0; - int i; - - if (strlen(mac) != ((2 * ETH_ALEN) + (ETH_ALEN - 1))) { - return MLAN_STATUS_FAILURE; - } - num_tokens = sscanf(mac, "%2x:%2x:%2x:%2x:%2x:%2x", - temp_raw + 0, temp_raw + 1, temp_raw + 2, - temp_raw + 3, temp_raw + 4, temp_raw + 5); - if (num_tokens != ETH_ALEN) { - return MLAN_STATUS_FAILURE; - } - for (i = 0; i < num_tokens; i++) - raw[i] = (t_u8)temp_raw[i]; - - if (memcmp(raw, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) == 0) { - return MAC_BROADCAST; - } else if (raw[0] & 0x01) { - return MAC_MULTICAST; - } - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Parses a command line - * - * @param line The line to parse - * @param args Pointer to the argument buffer to be filled in - * @param args_count Max number of elements which can be filled in buffer 'args' - * @return Number of arguments in the line or EOF - */ -static int -parse_line(char *line, char *args[], t_u16 args_count) -{ - int arg_num = 0; - int is_start = 0; - int is_quote = 0; - int length = 0; - int i = 0; - - arg_num = 0; - length = strlen(line); - /* Process line */ - - /* Find number of arguments */ - is_start = 0; - is_quote = 0; - for (i = 0; (i < length) && (arg_num < args_count); i++) { - /* Ignore leading spaces */ - if (is_start == 0) { - if (line[i] == ' ') { - continue; - } else if (line[i] == '\t') { - continue; - } else if (line[i] == '\n') { - break; - } else { - is_start = 1; - args[arg_num] = &line[i]; - arg_num++; - } - } - if (is_start == 1) { - /* Ignore comments */ - if (line[i] == '#') { - if (is_quote == 0) { - line[i] = '\0'; - arg_num--; - } - break; - } - /* Separate by '=' */ - if (line[i] == '=') { - line[i] = '\0'; - is_start = 0; - continue; - } - /* Separate by ',' */ - if (line[i] == ',') { - line[i] = '\0'; - is_start = 0; - continue; - } - /* Change ',' to ' ', but not inside quotes */ - if ((line[i] == ',') && (is_quote == 0)) { - line[i] = ' '; - continue; - } - } - /* Remove newlines */ - if (line[i] == '\n') { - line[i] = '\0'; - } - /* Check for quotes */ - if (line[i] == '"') { - is_quote = (is_quote == 1) ? 0 : 1; - continue; - } - if (((line[i] == ' ') || (line[i] == '\t')) && (is_quote == 0)) { - line[i] = '\0'; - is_start = 0; - continue; - } - } - return arg_num; + return str; } /** @@ -1942,8 +489,7 @@ parse_line(char *line, char *args[], t_u16 args_count) * @param argv A pointer to arguments array * @return MLAN_STATUS_SUCCESS--success, otherwise--fail */ -static int -process_version(int argc, char *argv[]) +static int process_version(int argc, char *argv[]) { t_u8 *buffer = NULL; struct eth_priv_cmd *cmd = NULL; @@ -2000,27 +546,34 @@ process_version(int argc, char *argv[]) return MLAN_STATUS_SUCCESS; } - /** - * @brief Process band configuration + * @brief Process extended version * @param argc Number of arguments * @param argv A pointer to arguments array * @return MLAN_STATUS_SUCCESS--success, otherwise--fail */ -static int -process_bandcfg(int argc, char *argv[]) +static int process_verext(int argc, char *argv[]) { + int ret = 0; t_u8 *buffer = NULL; - int i; struct eth_priv_cmd *cmd = NULL; - struct eth_priv_bandcfg *bandcfg = NULL; struct ifreq ifr; /* Initialize buffer */ buffer = (t_u8 *)malloc(BUFFER_LENGTH); if (!buffer) { printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; + ret = MLAN_STATUS_FAILURE; + goto done; + } + memset(buffer, 0, BUFFER_LENGTH); + + /* Sanity tests */ + if (argc < 3 || argc > 4) { + printf("Error: invalid no of arguments\n"); + printf("mlanutl mlanX verext [#]\n"); + ret = MLAN_STATUS_FAILURE; + goto done; } prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); @@ -2028,8 +581,8 @@ process_bandcfg(int argc, char *argv[]) cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); if (!cmd) { printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; + ret = MLAN_STATUS_FAILURE; + goto done; } /* Fill up buffer */ @@ -2049,42 +602,134 @@ process_bandcfg(int argc, char *argv[]) if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { perror("mlanutl"); - fprintf(stderr, "mlanutl: bandcfg fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; + fprintf(stderr, "mlanutl: verext fail\n"); + ret = MLAN_STATUS_FAILURE; + goto done; } /* Process result */ - bandcfg = (struct eth_priv_bandcfg *)buffer; - if (argc == 3) { - /* GET operation */ - printf("Band Configuration:\n"); - printf(" Infra Band: 0x%x (", (int)bandcfg->config_bands); - for (i = 0; i < 10; i++) { - if ((bandcfg->config_bands >> i) & 0x1) - printf(" %s", band[i]); - } - printf(" )\n"); - printf(" Adhoc Start Band: 0x%x (", - (int)bandcfg->adhoc_start_band); - for (i = 0; i < 10; i++) { - if ((bandcfg->adhoc_start_band >> i) & 0x1) - printf(" %s", band[i]); - } - printf(" )\n"); - printf(" Adhoc Start Channel: %d\n", - (int)bandcfg->adhoc_channel); - } + if (cmd->used_len) + printf("Extended Version string received: %s\n", buffer); +done: if (buffer) free(buffer); if (cmd) free(cmd); - return MLAN_STATUS_SUCCESS; + return ret; +} + +/** + * @brief Get one line from the File + * + * @param fp File handler + * @param str Storage location for data. + * @param size Maximum number of characters to read. + * @param lineno A pointer to return current line number + * @return returns string or NULL + */ +char *mlan_config_get_line(FILE *fp, char *str, t_s32 size, int *lineno) +{ + char *start, *end; + int out, next_line; + + if (!fp || !str) + return NULL; + + do { + read_line: + if (!fgets(str, size, fp)) + break; + start = str; + start[size - 1] = '\0'; + end = start + strlen(str); + (*lineno)++; + + out = 1; + while (out && (start < end)) { + next_line = 0; + /* Remove empty lines and lines starting with # */ + switch (start[0]) { + case ' ': /* White space */ + case '\t': /* Tab */ + start++; + break; + case '#': + case '\n': + case '\0': + next_line = 1; + break; + case '\r': + if (start[1] == '\n') + next_line = 1; + else + start++; + break; + default: + out = 0; + break; + } + if (next_line) + goto read_line; + } + + /* Remove # comments unless they are within a double quoted + * string. Remove trailing white space. */ + end = strstr(start, "\""); + if (end) { + end = strstr(end + 1, "\""); + if (!end) + end = start; + } else + end = start; + + end = strstr(end + 1, "#"); + if (end) + *end-- = '\0'; + else + end = start + strlen(start) - 1; + + out = 1; + while (out && (start < end)) { + switch (*end) { + case ' ': /* White space */ + case '\t': /* Tab */ + case '\n': + case '\r': + *end = '\0'; + end--; + break; + default: + out = 0; + break; + } + } + + if (*start == '\0') + continue; + + return start; + } while (1); + + return NULL; +} + +/** + * @brief Parse function for a configuration line + * + * @param s Storage buffer for data + * @param size Maximum size of data + * @param stream File stream pointer + * @param line Pointer to current line within the file + * @param _pos Output string or NULL + * @return String or NULL + */ +static char *config_get_line(char *s, int size, FILE *stream, int *line, + char **_pos) +{ + *_pos = mlan_config_get_line(stream, s, size, line); + return *_pos; } /** @@ -2095,8 +740,7 @@ process_bandcfg(int argc, char *argv[]) * @param size A pointer to the return size of hostcmd buffer * @return MLAN_STATUS_SUCCESS */ -static int -mlan_get_hostcmd_data(FILE * fp, int *ln, t_u8 *buf, t_u16 *size) +static int mlan_get_hostcmd_data(FILE *fp, int *ln, t_u8 *buf, t_u16 *size) { t_s32 errors = 0, i; char line[512], *pos, *pos1, *pos2, *pos3; @@ -2196,8 +840,7 @@ mlan_get_hostcmd_data(FILE * fp, int *ln, t_u8 *buf, t_u16 *size) * @param buf A pointer to comand buffer * @return MLAN_STATUS_SUCCESS--success, otherwise--fail */ -int -prepare_host_cmd_buffer(FILE * fp, char *cmd_name, t_u8 *buf) +int prepare_host_cmd_buffer(FILE *fp, char *cmd_name, t_u8 *buf) { char line[256], cmdname[256], *pos, cmdcode[10]; HostCmd_DS_GEN *hostcmd; @@ -2215,21 +858,20 @@ prepare_host_cmd_buffer(FILE * fp, char *cmd_name, t_u8 *buf) cmdname_found = 1; snprintf(cmdcode, sizeof(cmdcode), "CmdCode="); cmdcode_found = 0; - while ((pos = - mlan_config_get_line(fp, line, sizeof(line), - &ln))) { - if (strncmp(pos, cmdcode, strlen(cmdcode)) == 0) { + while ((pos = mlan_config_get_line( + fp, line, sizeof(line), &ln))) { + if (strncmp(pos, cmdcode, strlen(cmdcode)) == + 0) { t_u16 len = 0; cmdcode_found = 1; - hostcmd->command = - a2hex_or_atoi(pos + - strlen(cmdcode)); + hostcmd->command = a2hex_or_atoi( + pos + strlen(cmdcode)); hostcmd->size = S_DS_GEN; - mlan_get_hostcmd_data(fp, &ln, - buf + - sizeof(t_u32) + - hostcmd->size, - &len); + mlan_get_hostcmd_data( + fp, &ln, + buf + sizeof(t_u32) + + hostcmd->size, + &len); hostcmd->size += len; break; } @@ -2261,589 +903,16 @@ prepare_host_cmd_buffer(FILE * fp, char *cmd_name, t_u8 *buf) return MLAN_STATUS_SUCCESS; } -/** - * @brief Prints a MAC address in colon separated form from raw data - * - * @param raw A pointer to the hex data buffer - * @return N/A - */ -void -print_mac(t_u8 *raw) -{ - printf("%02x:%02x:%02x:%02x:%02x:%02x", (unsigned int)raw[0], - (unsigned int)raw[1], (unsigned int)raw[2], (unsigned int)raw[3], - (unsigned int)raw[4], (unsigned int)raw[5]); - return; -} - -/** - * @brief Process host_cmd response - * @param cmd_name Command name - * @param buf A pointer to the response buffer - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_host_cmd_resp(char *cmd_name, t_u8 *buf) -{ - t_u32 hostcmd_size = 0; - HostCmd_DS_GEN *hostcmd = NULL; - int ret = MLAN_STATUS_SUCCESS; - - buf += strlen(CMD_NXP) + strlen(cmd_name); - memcpy((t_u8 *)&hostcmd_size, buf, sizeof(t_u32)); - buf += sizeof(t_u32); - - hostcmd = (HostCmd_DS_GEN *)buf; - hostcmd->command = le16_to_cpu(hostcmd->command); - hostcmd->size = le16_to_cpu(hostcmd->size); - hostcmd->seq_num = le16_to_cpu(hostcmd->seq_num); - hostcmd->result = le16_to_cpu(hostcmd->result); - - hostcmd->command &= ~HostCmd_RET_BIT; - if (!hostcmd->result) { - switch (hostcmd->command) { - case HostCmd_CMD_CFG_DATA: - { - HostCmd_DS_802_11_CFG_DATA *pstcfgData = - (HostCmd_DS_802_11_CFG_DATA *)(buf + - S_DS_GEN); - pstcfgData->data_len = - le16_to_cpu(pstcfgData->data_len); - pstcfgData->action = - le16_to_cpu(pstcfgData->action); - - if (pstcfgData->action == HostCmd_ACT_GEN_GET) { - hexdump("cfgdata", pstcfgData->data, - pstcfgData->data_len, ' '); - } - break; - } - case HostCmd_CMD_802_11_TPC_ADAPT_REQ: - { - mlan_ioctl_11h_tpc_resp *tpcIoctlResp = - (mlan_ioctl_11h_tpc_resp *)(buf + - S_DS_GEN); - if (tpcIoctlResp->status_code == 0) { - printf("tpcrequest: txPower(%d), linkMargin(%d), rssi(%d)\n", tpcIoctlResp->tx_power, tpcIoctlResp->link_margin, tpcIoctlResp->rssi); - } else { - printf("tpcrequest: failure, status = %d\n", tpcIoctlResp->status_code); - } - break; - } - case HostCmd_CMD_802_11_CRYPTO: - { - t_u16 alg = - le16_to_cpu((t_u16) - *(buf + S_DS_GEN + - sizeof(t_u16))); - if (alg == CIPHER_TEST_AES_CCM || - alg == CIPHER_TEST_GCMP) { - HostCmd_DS_802_11_CRYPTO_AES_CCM - *cmd_aes_ccm = - (HostCmd_DS_802_11_CRYPTO_AES_CCM - *)(buf + S_DS_GEN); - - cmd_aes_ccm->encdec - = - le16_to_cpu(cmd_aes_ccm-> - encdec); - cmd_aes_ccm->algorithm = - le16_to_cpu(cmd_aes_ccm-> - algorithm); - cmd_aes_ccm->key_length = - le16_to_cpu(cmd_aes_ccm-> - key_length); - cmd_aes_ccm->nonce_length = - le16_to_cpu(cmd_aes_ccm-> - nonce_length); - cmd_aes_ccm->AAD_length = - le16_to_cpu(cmd_aes_ccm-> - AAD_length); - cmd_aes_ccm->data.header.type = - le16_to_cpu(cmd_aes_ccm->data. - header.type); - cmd_aes_ccm->data.header.len = - le16_to_cpu(cmd_aes_ccm->data. - header.len); - - printf("crypto_result: encdec=%d algorithm=%d, KeyLen=%d," " NonceLen=%d,AADLen=%d,dataLen=%d\n", cmd_aes_ccm->encdec, cmd_aes_ccm->algorithm, cmd_aes_ccm->key_length, cmd_aes_ccm->nonce_length, cmd_aes_ccm->AAD_length, cmd_aes_ccm->data.header.len); - - hexdump("Key", cmd_aes_ccm->key, - cmd_aes_ccm->key_length, ' '); - hexdump("Nonce", cmd_aes_ccm->nonce, - cmd_aes_ccm->nonce_length, ' '); - hexdump("AAD", cmd_aes_ccm->AAD, - cmd_aes_ccm->AAD_length, ' '); - hexdump("Data", cmd_aes_ccm->data.data, - cmd_aes_ccm->data.header.len, - ' '); - } else if (alg == CIPHER_TEST_WAPI) { - HostCmd_DS_802_11_CRYPTO_WAPI *cmd_wapi - = - (HostCmd_DS_802_11_CRYPTO_WAPI - *) (buf + S_DS_GEN); - - cmd_wapi->encdec - = le16_to_cpu(cmd_wapi->encdec); - cmd_wapi->algorithm - = - le16_to_cpu(cmd_wapi-> - algorithm); - cmd_wapi->key_length = - le16_to_cpu(cmd_wapi-> - key_length); - cmd_wapi->nonce_length = - le16_to_cpu(cmd_wapi-> - nonce_length); - cmd_wapi->AAD_length = - le16_to_cpu(cmd_wapi-> - AAD_length); - - printf("crypto_result: encdec=%d algorithm=%d, KeyLen=%d," " NonceLen=%d,AADLen=%d,dataLen=%d\n", cmd_wapi->encdec, cmd_wapi->algorithm, cmd_wapi->key_length, cmd_wapi->nonce_length, cmd_wapi->AAD_length, cmd_wapi->data_length); - - hexdump("Key", cmd_wapi->key, - cmd_wapi->key_length, ' '); - hexdump("Nonce", cmd_wapi->nonce, - cmd_wapi->nonce_length, ' '); - hexdump("AAD", cmd_wapi->AAD, - cmd_wapi->AAD_length, ' '); - } else { - HostCmd_DS_802_11_CRYPTO *cmd = - (HostCmd_DS_802_11_CRYPTO *)(buf - + - S_DS_GEN); - cmd->encdec = le16_to_cpu(cmd->encdec); - cmd->algorithm = - le16_to_cpu(cmd->algorithm); - cmd->key_IV_length = - le16_to_cpu(cmd->key_IV_length); - cmd->key_length = - le16_to_cpu(cmd->key_length); - cmd->data.header.type = - le16_to_cpu(cmd->data.header. - type); - cmd->data.header.len = - le16_to_cpu(cmd->data.header. - len); - - printf("crypto_result: encdec=%d algorithm=%d,KeyIVLen=%d," " KeyLen=%d,dataLen=%d\n", cmd->encdec, cmd->algorithm, cmd->key_IV_length, cmd->key_length, cmd->data.header.len); - hexdump("KeyIV", cmd->keyIV, - cmd->key_IV_length, ' '); - hexdump("Key", cmd->key, - cmd->key_length, ' '); - hexdump("Data", cmd->data.data, - cmd->data.header.len, ' '); - } - break; - } - case HostCmd_CMD_802_11_AUTO_TX: - { - HostCmd_DS_802_11_AUTO_TX *at = - (HostCmd_DS_802_11_AUTO_TX *)(buf + - S_DS_GEN); - - if (le16_to_cpu(at->action) == - HostCmd_ACT_GEN_GET) { - if (S_DS_GEN + sizeof(at->action) == - hostcmd->size) { - printf("auto_tx not configured\n"); - - } else { - MrvlIEtypesHeader_t *header = - &at->auto_tx.header; - - header->type = - le16_to_cpu(header-> - type); - header->len = - le16_to_cpu(header-> - len); - - if ((S_DS_GEN + - sizeof(at->action) - + - sizeof(MrvlIEtypesHeader_t) - + header->len == - hostcmd->size) && - (header->type == - TLV_TYPE_AUTO_TX)) { - - AutoTx_MacFrame_t *atmf - = - &at->auto_tx. - auto_tx_mac_frame; - - printf("Interval: %d second(s)\n", le16_to_cpu(atmf->interval)); - printf("Priority: %#x\n", atmf->priority); - printf("Frame Length: %d\n", le16_to_cpu(atmf->frame_len)); - printf("Dest Mac Address: " "%02x:%02x:%02x:%02x:%02x:%02x\n", atmf->dest_mac_addr[0], atmf->dest_mac_addr[1], atmf->dest_mac_addr[2], atmf->dest_mac_addr[3], atmf->dest_mac_addr[4], atmf->dest_mac_addr[5]); - printf("Src Mac Address: " "%02x:%02x:%02x:%02x:%02x:%02x\n", atmf->src_mac_addr[0], atmf->src_mac_addr[1], atmf->src_mac_addr[2], atmf->src_mac_addr[3], atmf->src_mac_addr[4], atmf->src_mac_addr[5]); - - hexdump("Frame Payload", - atmf->payload, - le16_to_cpu - (atmf-> - frame_len) - - - MLAN_MAC_ADDR_LENGTH - * 2, ' '); - } else { - printf("incorrect auto_tx command response\n"); - } - } - } - break; - } - case HostCmd_CMD_802_11_SUBSCRIBE_EVENT: - { - HostCmd_DS_802_11_SUBSCRIBE_EVENT *se = - (HostCmd_DS_802_11_SUBSCRIBE_EVENT - *)(buf + S_DS_GEN); - if (le16_to_cpu(se->action) == - HostCmd_ACT_GEN_GET) { - int len = - S_DS_GEN + - sizeof - (HostCmd_DS_802_11_SUBSCRIBE_EVENT); - printf("\nEvent\t\tValue\tFreq\tsubscribed\n\n"); - while (len < hostcmd->size) { - MrvlIEtypesHeader_t *header = - (MrvlIEtypesHeader_t - *)(buf + len); - switch (le16_to_cpu - (header->type)) { - case TLV_TYPE_RSSI_LOW: - { - MrvlIEtypes_RssiThreshold_t - *low_rssi - = - (MrvlIEtypes_RssiThreshold_t - *)(buf - + - len); - printf("Beacon Low RSSI\t%d\t%d\t%s\n", low_rssi->RSSI_value, low_rssi->RSSI_freq, (le16_to_cpu(se->events) & 0x0001) ? "yes" : "no"); - break; - } - case TLV_TYPE_SNR_LOW: - { - MrvlIEtypes_SnrThreshold_t - *low_snr - = - (MrvlIEtypes_SnrThreshold_t - *)(buf - + - len); - printf("Beacon Low SNR\t%d\t%d\t%s\n", low_snr->SNR_value, low_snr->SNR_freq, (le16_to_cpu(se->events) & 0x0002) ? "yes" : "no"); - break; - } - case TLV_TYPE_FAILCOUNT: - { - MrvlIEtypes_FailureCount_t - *failure_count - = - (MrvlIEtypes_FailureCount_t - *)(buf - + - len); - printf("Failure Count\t%d\t%d\t%s\n", failure_count->fail_value, failure_count->fail_freq, (le16_to_cpu(se->events) & 0x0004) ? "yes" : "no"); - break; - } - case TLV_TYPE_BCNMISS: - { - MrvlIEtypes_BeaconsMissed_t - *bcn_missed - = - (MrvlIEtypes_BeaconsMissed_t - *)(buf - + - len); - printf("Beacon Missed\t%d\tN/A\t%s\n", bcn_missed->beacon_missed, (le16_to_cpu(se->events) & 0x0008) ? "yes" : "no"); - break; - } - case TLV_TYPE_RSSI_HIGH: - { - MrvlIEtypes_RssiThreshold_t - *high_rssi - = - (MrvlIEtypes_RssiThreshold_t - *)(buf - + - len); - printf("Bcn High RSSI\t%d\t%d\t%s\n", high_rssi->RSSI_value, high_rssi->RSSI_freq, (le16_to_cpu(se->events) & 0x0010) ? "yes" : "no"); - break; - } - - case TLV_TYPE_SNR_HIGH: - { - MrvlIEtypes_SnrThreshold_t - *high_snr - = - (MrvlIEtypes_SnrThreshold_t - *)(buf - + - len); - printf("Beacon High SNR\t%d\t%d\t%s\n", high_snr->SNR_value, high_snr->SNR_freq, (le16_to_cpu(se->events) & 0x0020) ? "yes" : "no"); - break; - } - case TLV_TYPE_RSSI_LOW_DATA: - { - MrvlIEtypes_RssiThreshold_t - *low_rssi - = - (MrvlIEtypes_RssiThreshold_t - *)(buf - + - len); - printf("Data Low RSSI\t%d\t%d\t%s\n", low_rssi->RSSI_value, low_rssi->RSSI_freq, (le16_to_cpu(se->events) & 0x0040) ? "yes" : "no"); - break; - } - case TLV_TYPE_SNR_LOW_DATA: - { - MrvlIEtypes_SnrThreshold_t - *low_snr - = - (MrvlIEtypes_SnrThreshold_t - *)(buf - + - len); - printf("Data Low SNR\t%d\t%d\t%s\n", low_snr->SNR_value, low_snr->SNR_freq, (le16_to_cpu(se->events) & 0x0080) ? "yes" : "no"); - break; - } - case TLV_TYPE_RSSI_HIGH_DATA: - { - MrvlIEtypes_RssiThreshold_t - *high_rssi - = - (MrvlIEtypes_RssiThreshold_t - *)(buf - + - len); - printf("Data High RSSI\t%d\t%d\t%s\n", high_rssi->RSSI_value, high_rssi->RSSI_freq, (le16_to_cpu(se->events) & 0x0100) ? "yes" : "no"); - break; - } - case TLV_TYPE_SNR_HIGH_DATA: - { - MrvlIEtypes_SnrThreshold_t - *high_snr - = - (MrvlIEtypes_SnrThreshold_t - *)(buf - + - len); - printf("Data High SNR\t%d\t%d\t%s\n", high_snr->SNR_value, high_snr->SNR_freq, (le16_to_cpu(se->events) & 0x0200) ? "yes" : "no"); - break; - } - case TLV_TYPE_LINK_QUALITY: - { - MrvlIEtypes_LinkQuality_t - *link_qual - = - (MrvlIEtypes_LinkQuality_t - *)(buf - + - len); - printf("Link Quality Parameters:\n"); - printf("------------------------\n"); - printf("Link Quality Event Subscribed\t%s\n", (le16_to_cpu(se->events) & 0x0400) ? "yes" : "no"); - printf("Link SNR Threshold = %d\n", le16_to_cpu(link_qual->link_SNR_thrs)); - printf("Link SNR Frequency = %d\n", le16_to_cpu(link_qual->link_SNR_freq)); - printf("Min Rate Value = %d\n", le16_to_cpu(link_qual->min_rate_val)); - printf("Min Rate Frequency = %d\n", le16_to_cpu(link_qual->min_rate_freq)); - printf("Tx Latency Value = %d\n", le32_to_cpu(link_qual->tx_latency_val)); - printf("Tx Latency Threshold = %d\n", le32_to_cpu(link_qual->tx_latency_thrs)); - - break; - } - case TLV_TYPE_PRE_BEACON_LOST: - { - MrvlIEtypes_PreBeaconLost_t - *pre_bcn_lost - = - (MrvlIEtypes_PreBeaconLost_t - *)(buf - + - len); - printf("------------------------\n"); - printf("Pre-Beacon Lost Event Subscribed\t%s\n", (le16_to_cpu(se->events) & 0x0800) ? "yes" : "no"); - printf("Pre-Beacon Lost: %d\n", pre_bcn_lost->pre_beacon_lost); - break; - } - default: - printf("Unknown subscribed event TLV Type=%#x," " Len=%d\n", le16_to_cpu(header->type), le16_to_cpu(header->len)); - break; - } - - len += (sizeof - (MrvlIEtypesHeader_t) - + - le16_to_cpu(header-> - len)); - } - } - break; - } - case HostCmd_CMD_MAC_REG_ACCESS: - case HostCmd_CMD_BBP_REG_ACCESS: - case HostCmd_CMD_RF_REG_ACCESS: - case HostCmd_CMD_CAU_REG_ACCESS: - { - HostCmd_DS_REG *preg = - (HostCmd_DS_REG *)(buf + S_DS_GEN); - preg->action = le16_to_cpu(preg->action); - if (preg->action == HostCmd_ACT_GEN_GET) { - preg->value = le32_to_cpu(preg->value); - printf("value = 0x%08x\n", preg->value); - } - break; - } - case HostCmd_CMD_MEM_ACCESS: - { - HostCmd_DS_MEM *pmem = - (HostCmd_DS_MEM *)(buf + S_DS_GEN); - pmem->action = le16_to_cpu(pmem->action); - if (pmem->action == HostCmd_ACT_GEN_GET) { - pmem->value = le32_to_cpu(pmem->value); - printf("value = 0x%08x\n", pmem->value); - } - break; - } - case HostCmd_CMD_LINK_STATS_SUMMARY: - { - HostCmd_DS_LINK_STATS_SUMMARY *linkstats = - (HostCmd_DS_LINK_STATS_SUMMARY *)(buf + - S_DS_GEN); - /* GET operation */ - printf("Link Statistics: \n"); - /* format */ - printf("Duration: %u\n", - (int)le32_to_cpu(linkstats-> - timeSinceLastQuery_ms)); - - printf("Beacon count: %u\n", - le16_to_cpu(linkstats->bcnCnt)); - printf("Beacon missing: %u\n", - le16_to_cpu(linkstats->bcnMiss)); - printf("Beacon RSSI avg: %d\n", - le16_to_cpu(linkstats->bcnRssiAvg)); - printf("Beacon SNR avg: %d\n", - le16_to_cpu(linkstats->bcnSnrAvg)); - - printf("Rx packets: %u\n", - (int)le32_to_cpu(linkstats->rxPkts)); - printf("Rx RSSI avg: %d\n", - le16_to_cpu(linkstats->rxRssiAvg)); - printf("Rx SNR avg: %d\n", - le16_to_cpu(linkstats->rxSnrAvg)); - - printf("Tx packets: %u\n", - (int)le32_to_cpu(linkstats->txPkts)); - printf("Tx Attempts: %u\n", - (int)le32_to_cpu(linkstats->txAttempts)); - printf("Tx Failures: %u\n", - (int)le32_to_cpu(linkstats->txFailures)); - printf("Tx Initial Rate: %s\n", - rateIdStr[linkstats->txInitRate]); - - printf("Tx AC VO: %u [ %u ]\n", - le16_to_cpu(linkstats-> - txQueuePktCnt[WMM_AC_VO]), - (int)le32_to_cpu(linkstats-> - txQueueDelay[WMM_AC_VO]) - / 1000); - printf("Tx AC VI: %u [ %u ]\n", - le16_to_cpu(linkstats-> - txQueuePktCnt[WMM_AC_VI]), - (int)le32_to_cpu(linkstats-> - txQueueDelay[WMM_AC_VI]) - / 1000); - printf("Tx AC BE: %u [ %u ]\n", - le16_to_cpu(linkstats-> - txQueuePktCnt[WMM_AC_BE]), - (int)le32_to_cpu(linkstats-> - txQueueDelay[WMM_AC_BE]) - / 1000); - printf("Tx AC BK: %u [ %u ]\n", - le16_to_cpu(linkstats-> - txQueuePktCnt[WMM_AC_BK]), - (int)le32_to_cpu(linkstats-> - txQueueDelay[WMM_AC_BK]) - / 1000); - break; - } - case HostCmd_CMD_WMM_PARAM_CONFIG: - { - HostCmd_DS_WMM_PARAM_CONFIG *wmm_param = - (HostCmd_DS_WMM_PARAM_CONFIG *) (buf + - S_DS_GEN); - printf("WMM Params: \n"); - printf("\tBE: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", wmm_param->ac_params[AC_BE].aci_aifsn.aifsn, wmm_param->ac_params[AC_BE].ecw.ecw_max, wmm_param->ac_params[AC_BE].ecw.ecw_min, le16_to_cpu(wmm_param->ac_params[AC_BE].tx_op_limit)); - printf("\tBK: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", wmm_param->ac_params[AC_BK].aci_aifsn.aifsn, wmm_param->ac_params[AC_BK].ecw.ecw_max, wmm_param->ac_params[AC_BK].ecw.ecw_min, le16_to_cpu(wmm_param->ac_params[AC_BK].tx_op_limit)); - printf("\tVI: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", wmm_param->ac_params[AC_VI].aci_aifsn.aifsn, wmm_param->ac_params[AC_VI].ecw.ecw_max, wmm_param->ac_params[AC_VI].ecw.ecw_min, le16_to_cpu(wmm_param->ac_params[AC_VI].tx_op_limit)); - printf("\tVO: AIFSN=%d, CW_MAX=%d CW_MIN=%d, TXOP=%d\n", wmm_param->ac_params[AC_VO].aci_aifsn.aifsn, wmm_param->ac_params[AC_VO].ecw.ecw_max, wmm_param->ac_params[AC_VO].ecw.ecw_min, le16_to_cpu(wmm_param->ac_params[AC_VO].tx_op_limit)); - break; - } - default: - printf("HOSTCMD_RESP: CmdCode=%#04x, Size=%#04x," - " SeqNum=%#04x, Result=%#04x\n", - hostcmd->command, hostcmd->size, - hostcmd->seq_num, hostcmd->result); - hexdump("payload", - (t_void *)(buf + S_DS_GEN), - hostcmd->size - S_DS_GEN, ' '); - break; - } - } else { - printf("HOSTCMD failed: CmdCode=%#04x, Size=%#04x," - " SeqNum=%#04x, Result=%#04x\n", - hostcmd->command, hostcmd->size, - hostcmd->seq_num, hostcmd->result); - } - return ret; -} - -/** - * @brief Trims leading and traling spaces only - * @param str A pointer to argument string - * @return pointer to trimmed string - */ -char * -trim_spaces(char *str) -{ - char *str_end = NULL; - - if (!str) - return NULL; - - /* Trim leading spaces */ - while (!*str && isspace(*str)) - str++; - - if (*str == 0) /* All spaces? */ - return str; - - /* Trim trailing spaces */ - str_end = str + strlen(str) - 1; - while (str_end > str && isspace(*str_end)) - str_end--; - - /* null terminate the string */ - *(str_end + 1) = '\0'; - - return str; -} - /** * @brief Process hostcmd command * @param argc Number of arguments * @param argv A pointer to arguments array * @return MLAN_STATUS_SUCCESS--success, otherwise--fail */ -static int -process_hostcmd(int argc, char *argv[]) +static int process_hostcmd(int argc, char *argv[]) { t_u8 *buffer = NULL, *raw_buf = NULL; struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; FILE *fp = NULL; FILE *fp_raw = NULL; FILE *fp_dtsi = NULL; @@ -2862,7 +931,7 @@ process_hostcmd(int argc, char *argv[]) if (argc < 5) { printf("Error: invalid no of arguments\n"); - printf("Syntax: ./mlanutl mlanX hostcmd \n"); + printf("Syntax: ./mlanutl mlanX hostcmd generate_raw \n"); ret = MLAN_STATUS_FAILURE; goto done; } @@ -2873,9 +942,15 @@ process_hostcmd(int argc, char *argv[]) call_ioctl = FALSE; } + if (call_ioctl) { + printf("Error: invalid no of arguments\n"); + printf("Syntax: ./mlanutl mlanX hostcmd generate_raw \n"); + ret = MLAN_STATUS_FAILURE; + goto done; + } if (!call_ioctl && argc != 6) { printf("Error: invalid no of arguments\n"); - printf("Syntax: ./mlanutl mlanX hostcmd %s \n", cmdname); + printf("Syntax: ./mlanutl mlanX hostcmd generate_raw \n"); ret = MLAN_STATUS_FAILURE; goto done; } @@ -2897,19 +972,7 @@ process_hostcmd(int argc, char *argv[]) } memset(buffer, 0, BUFFER_LENGTH); - if (call_ioctl) { - /* Prepare the hostcmd buffer */ - prepare_buffer(buffer, argv[2], 0, NULL); - if (MLAN_STATUS_FAILURE == - prepare_host_cmd_buffer(fp, cmdname, - buffer + strlen(CMD_NXP) + - strlen(argv[2]))) { - fclose(fp); - ret = MLAN_STATUS_FAILURE; - goto done; - } - fclose(fp); - } else { + { line = (char *)malloc(MAX_CONFIG_LINE); if (!line) { printf("ERR:Cannot allocate memory for line\n"); @@ -2923,9 +986,8 @@ process_hostcmd(int argc, char *argv[]) line = trim_spaces(line); if (line[strlen(line) - 1] == '{') { if (ob == 0) { - new_node = - (struct cmd_node *) - malloc(sizeof(struct cmd_node)); + new_node = (struct cmd_node *)malloc( + sizeof(struct cmd_node)); if (!new_node) { printf("ERR:Cannot allocate memory for cmd_node\n"); fclose(fp); @@ -2945,25 +1007,27 @@ process_hostcmd(int argc, char *argv[]) strncpy(command->cmd_string, line, (strchr(line, '=') - line)); memmove(command->cmd_string, - trim_spaces(command-> - cmd_string), - strlen(trim_spaces - (command->cmd_string)) + - 1); + trim_spaces( + command->cmd_string), + strlen(trim_spaces( + command->cmd_string)) + + 1); } ob++; - continue; /* goto while() */ + continue; /* goto while() */ } if (line[strlen(line) - 1] == '}') { ob--; if (ob == 0) blk_count++; - continue; /* goto while() */ + continue; /* goto while() */ } } - rewind(fp); /* Set the source file pointer to the beginning again */ - command = header; /* Set 'command' at the beginning of the command list */ + rewind(fp); /* Set the source file pointer to the beginning + again */ + command = header; /* Set 'command' at the beginning of the + command list */ fp_raw = fopen(argv[5], "w"); if (fp_raw == NULL) { @@ -2995,7 +1059,11 @@ process_hostcmd(int argc, char *argv[]) memcpy(&buf_len, buffer, sizeof(t_u32)); if (buf_len) { - raw_buf = buffer + sizeof(t_u32); /* raw_buf points to start of actual */ + raw_buf = buffer + sizeof(t_u32); /* raw_buf + points to + start of + actual */ printf("buf_len = %d\n", (int)buf_len); if (k > 0) fprintf(fp_raw, "\n\n"); @@ -3034,42 +1102,6 @@ process_hostcmd(int argc, char *argv[]) fclose(fp_raw); fclose(fp); } - - if (call_ioctl) { - cmd = (struct eth_priv_cmd *) - malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: hostcmd fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Process result */ - process_host_cmd_resp(argv[2], buffer); - } - done: while (header) { command = header; @@ -3085,3756 +1117,6 @@ done: return ret; } -/** - * @brief Process HT Tx configuration - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_httxcfg(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - t_u32 *data = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: httxcfg fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - if (argc == 3) { - /* Get result */ - data = (t_u32 *)buffer; - printf("HT Tx cfg: \n"); - printf(" BG band: 0x%08x\n", data[0]); - printf(" A band: 0x%08x\n", data[1]); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process HT capability configuration - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_htcapinfo(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct eth_priv_htcapinfo *ht_cap = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: htcapinfo fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - if (argc == 3) { - ht_cap = (struct eth_priv_htcapinfo *)buffer; - printf("HT cap info: \n"); - printf(" BG band: 0x%08x\n", ht_cap->ht_cap_info_bg); - printf(" A band: 0x%08x\n", ht_cap->ht_cap_info_a); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process HT Add BA parameters - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_addbapara(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - struct eth_priv_addba *addba = NULL; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: addbapara fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - if (argc == 3) { - /* Get */ - addba = (struct eth_priv_addba *)buffer; - printf("Add BA configuration: \n"); - printf(" Time out : %d\n", addba->time_out); - printf(" TX window: %d\n", addba->tx_win_size); - printf(" RX window: %d\n", addba->rx_win_size); - printf(" TX AMSDU : %d\n", addba->tx_amsdu); - printf(" RX AMSDU : %d\n", addba->rx_amsdu); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process Aggregation priority table parameters - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_aggrpriotbl(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - int i; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: aggrpriotbl fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - if (argc == 3) { - /* Get */ - printf("Aggregation priority table cfg: \n"); - printf(" TID AMPDU AMSDU \n"); - for (i = 0; i < MAX_NUM_TID; i++) { - printf(" %d %3d %3d \n", - i, buffer[2 * i], buffer[2 * i + 1]); - } - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process HT Add BA reject configurations - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_addbareject(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - int i; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: addbareject fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - if (argc == 3) { - /* Get */ - printf("Add BA reject configuration: \n"); - printf(" TID Reject \n"); - for (i = 0; i < MAX_NUM_TID; i++) { - printf(" %d %d\n", i, buffer[i]); - } - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process HT Del BA command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_delba(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: delba fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process reject addba req command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_rejectaddbareq(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: rejectaddbareq fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - printf("Reject addba req command response: %s\n", buffer); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Implement Minimum BA Threshold command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_min_ba_threshold_cfg(int argc, char *argv[]) -{ - int ret = 0; - t_u8 min_ba_thres = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc < 3 || argc > 4) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX min_ba_threshold [#]\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: min_ba_threshold fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Process result */ - if (argc == 3) { - memcpy(&min_ba_thres, buffer, sizeof(min_ba_thres)); - printf("Min Tx BA Threshold: %d\n", min_ba_thres); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -/** - * @brief Process VHT configuration - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_vhtcfg(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct eth_priv_vhtcfg vhtcfg; - struct ifreq ifr; - t_u8 i, num = 0; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - /* Sanity tests */ - if (argc < 5) { - printf("Insufficient parameters\n"); - printf("For STA interface: mlanutl mlanX vhtcfg [bwcfg] [vhtcap]\n"); - printf("For uAP interface: mlanutl uapX vhtcfg [bwcfg] [vhtcap] [vht_tx_mcs] [vht_rx_mcs]\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: vhtcfg fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - /* the first attribute is the number of vhtcfg entries */ - num = *buffer; - if (argc == 5) { - /* GET operation */ - printf("11AC VHT Configuration: \n"); - for (i = 0; i < num; i++) { - memcpy(&vhtcfg, buffer + 1 + i * sizeof(vhtcfg), - sizeof(vhtcfg)); - /* Band */ - if (vhtcfg.band == 1) - printf("Band: 2.4G\n"); - else - printf("Band: 5G\n"); - /* BW confi9 */ - - if (vhtcfg.bwcfg == 0) - printf(" BW config: Follow BW in the 11N config\n"); - else - printf(" BW config: Follow BW in VHT Capabilities\n"); - - /* Tx/Rx */ - if (vhtcfg.txrx & 0x1) - printf(" VHT operation for Tx: 0x%08x\n", - vhtcfg.vht_cap_info); - if (vhtcfg.txrx & 0x2) - /* VHT capabilities */ - printf(" VHT Capabilities Info: 0x%08x\n", - vhtcfg.vht_cap_info); - /* MCS */ - if (vhtcfg.txrx & 0x2) { - printf(" Tx MCS set: 0x%04x\n", - vhtcfg.vht_tx_mcs); - printf(" Rx MCS set: 0x%04x\n", - vhtcfg.vht_rx_mcs); - } - } - } else { - /* SET operation */ - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process Operating Mode Notification configuration - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_opermodecfg(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct eth_priv_opermodecfg *cfg = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: opermodecfg fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - cfg = (struct eth_priv_opermodecfg *)(buffer); - printf("11AC Operating Mode Notification Configuration: \n"); - printf(" bw: %d\n", cfg->bw); - printf(" nss: %d\n", cfg->nss); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -static char *rate_format[4] = { "LG", "HT", "VHT", "HE" }; - -static char *lg_rate[] = { "1 Mbps", "2 Mbps", "5.5 Mbps", "11 Mbps", - "6 Mbps", "9 Mbps", "12 Mbps", "18 Mbps", - "24 Mbps", "36 Mbps", "48 Mbps", "54 Mbps" -}; - -/** - * @brief Process Get data rate - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_datarate(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct eth_priv_data_rate *datarate = NULL; - struct ifreq ifr; - char *bw[] = { "20 MHz", "40 MHz", "80 MHz", "160 MHz" }; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], 0, NULL); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: getdatarate fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - datarate = (struct eth_priv_data_rate *)buffer; - printf("Data Rate:\n"); - printf(" TX: \n"); - if (datarate->tx_rate_format <= 3) { - printf(" Type: %s\n", rate_format[datarate->tx_rate_format]); - if ((datarate->tx_rate_format == 0) && - datarate->tx_data_rate <= 11) - /* LG */ - printf(" Rate: %s\n", - lg_rate[datarate->tx_data_rate]); - else { - /* HT and VHT */ - if (datarate->tx_bw <= 3) - printf(" BW: %s\n", bw[datarate->tx_bw]); - if (datarate->tx_rate_format < 3) { - if (datarate->tx_gi == 0) - printf(" GI: Long\n"); - else - printf(" GI: Short\n"); - } else if (datarate->tx_rate_format == 3) { - switch (datarate->tx_gi) { - case 0: - printf(" GI: 1xHELTF + GI 0.8us \n"); - break; - case 1: - printf(" GI: 2xHELTF + GI 0.8us \n"); - break; - case 2: - printf(" GI: 2xHELTF + GI 1.6us \n"); - break; - case 3: - printf(" GI: 4xHELTF + GI 0.8us DCM=0 and STBC=0 or\n" " 4xHELTF + GI 3.2us Otherwise \n"); - break; - } - } - if (datarate->tx_rate_format >= 2) - printf(" NSS: %d\n", datarate->tx_nss + 1); - if (datarate->tx_mcs_index != 0xFF) - printf(" MCS: MCS %d\n", - (int)datarate->tx_mcs_index); - else - printf(" MCS: Auto\n"); - if (datarate->tx_rate_format < 3) - printf(" Rate: %f Mbps\n", - (float)datarate->tx_data_rate / 2); - } - } - - printf(" RX: \n"); - if (datarate->rx_rate_format <= 3) { - printf(" Type: %s\n", rate_format[datarate->rx_rate_format]); - if ((datarate->rx_rate_format == 0) && - datarate->rx_data_rate <= 11) - /* LG */ - printf(" Rate: %s\n", - lg_rate[datarate->rx_data_rate]); - else { - /* HT and VHT */ - if (datarate->rx_bw <= 3) - printf(" BW: %s\n", bw[datarate->rx_bw]); - if (datarate->rx_rate_format < 3) { - if (datarate->rx_gi == 0) - printf(" GI: Long\n"); - else - printf(" GI: Short\n"); - } else if (datarate->rx_rate_format == 3) { - switch (datarate->rx_gi) { - case 0: - printf(" GI: 1xHELTF + GI 0.8us \n"); - break; - case 1: - printf(" GI: 2xHELTF + GI 0.8us \n"); - break; - case 2: - printf(" GI: 2xHELTF + GI 1.6us \n"); - break; - case 3: - printf(" GI: 4xHELTF + GI 0.8us DCM=0 and STBC=0 or\n" " 4xHELTF + GI 3.2us Otherwise \n"); - break; - } - } - if (datarate->rx_rate_format >= 2) - printf(" NSS: %d\n", datarate->rx_nss + 1); - if (datarate->rx_mcs_index != 0xFF) - printf(" MCS: MCS %d\n", - (int)datarate->rx_mcs_index); - else - printf(" MCS: Auto\n"); - if (datarate->rx_rate_format < 3) - printf(" Rate: %f Mbps\n", - (float)datarate->rx_data_rate / 2); - } - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process tx rate configuration - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_txratecfg(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct eth_priv_tx_rate_cfg *txratecfg = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: txratecfg fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - txratecfg = (struct eth_priv_tx_rate_cfg *)buffer; - if (argc == 3) { - /* GET operation */ - printf("Tx Rate Configuration: \n"); - /* format */ - if (txratecfg->rate_format == 0xFF) { - printf(" Type: 0xFF (Auto)\n"); - } else if (txratecfg->rate_format <= 3) { - printf(" Type: %d (%s)\n", - txratecfg->rate_format, - rate_format[txratecfg->rate_format]); - if (txratecfg->rate_format == 0) - printf(" Rate Index: %d (%s)\n", - txratecfg->rate_index, - lg_rate[txratecfg->rate_index]); - else if (txratecfg->rate_format >= 1) - printf(" MCS Index: %d\n", - (int)txratecfg->rate_index); - if (txratecfg->rate_format == 2 || - txratecfg->rate_format == 3) - printf(" NSS: %d\n", - (int)txratecfg->nss); - if (txratecfg->rate_setting == 0xffff) - printf("Rate setting :Preamble type/BW/GI/STBC/.. : auto \n"); - else { - printf("Preamble type: %x\n", - (txratecfg->rate_setting & 0x0003)); - printf("BW: %x\n", - (txratecfg->rate_setting & 0x001C) >> 2); - printf("LTF + GI size %x\n", - (txratecfg->rate_setting & 0x0060) >> 5); - printf("STBC %x\n", - (txratecfg->rate_setting & 0x0080) >> 7); - printf("DCM %x\n", - (txratecfg->rate_setting & 0x0100) >> 8); - printf("Coding %x\n", - (txratecfg->rate_setting & 0x0200) >> 9); - printf("maxPE %x\n", - (txratecfg-> - rate_setting & 0x3000) >> 12); - } - } else { - printf(" Unknown rate format.\n"); - } - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process get channel list used by cfg80211 - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_getcfgchanlist(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - int i = 0; - wlan_ieee80211_chan_list *chan_list = NULL; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: getcfgchanlist\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - /* Process results */ - chan_list = (wlan_ieee80211_chan_list *) buffer; - printf("Channel Flags:\n"); - printf(" IEEE80211_CHAN_DISABLED = 1<<0\n"); - printf(" IEEE80211_CHAN_NO_IR = 1<<1\n"); - printf(" IEEE80211_CHAN_RADAR = 1<<3\n"); - printf(" IEEE80211_CHAN_NO_HT40PLUS = 1<<4\n"); - printf(" IEEE80211_CHAN_NO_HT40MINUS = 1<<5\n"); - printf(" IEEE80211_CHAN_NO_OFDM = 1<<6\n"); - printf(" IEEE80211_CHAN_NO_80MHZ = 1<<7\n"); - printf(" IEEE80211_CHAN_NO_160MHZ = 1<<8\n"); - printf(" IEEE80211_CHAN_INDOOR_ONLY = 1<<9\n"); - printf(" IEEE80211_CHAN_IR_CONCURRENT = 1<<10\n"); - printf(" IEEE80211_CHAN_NO_20MHZ = 1<<11\n"); - printf(" IEEE80211_CHAN_NO_10MHZ = 1<<12\n"); - printf("--------------------------------------------"); - printf("--------------------------------------------\n"); - printf("# | chan | freq | disable | NO_IR | RADAR |NO_OFDM|NO_HT40+|NO_HT40-|NO_80| dfs_state\n"); - printf("--------------------------------------------"); - printf("--------------------------------------------\n"); - for (i = 0; i < chan_list->num_chan; i++) { - if (!(chan_list->chan_list[i].flags & IEEE80211_CHAN_RADAR)) { - printf(" [%03d] %04d %c %c %c %c %c %c %c %c\n", chan_list->chan_list[i].hw_value, chan_list->chan_list[i].center_freq, (chan_list->chan_list[i].flags & IEEE80211_CHAN_DISABLED) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_IR) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_RADAR) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_OFDM) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_HT40PLUS) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_HT40MINUS) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_80MHZ) ? 'Y' : '-', '-'); - } else if (chan_list->chan_list[i].dfs_state == DFS_USEABLE) { - printf(" [%03d] %04d %c %c %c %c %c %c %c %c\n", chan_list->chan_list[i].hw_value, chan_list->chan_list[i].center_freq, (chan_list->chan_list[i].flags & IEEE80211_CHAN_DISABLED) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_IR) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_RADAR) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_OFDM) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_HT40PLUS) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_HT40MINUS) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_80MHZ) ? 'Y' : '-', 'U'); - } else if (chan_list->chan_list[i].dfs_state == DFS_UNAVAILABLE) { - printf(" [%03d] %04d %c %c %c %c %c %c %c %c\n", chan_list->chan_list[i].hw_value, chan_list->chan_list[i].center_freq, (chan_list->chan_list[i].flags & IEEE80211_CHAN_DISABLED) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_IR) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_RADAR) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_OFDM) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_HT40PLUS) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_HT40MINUS) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_80MHZ) ? 'Y' : '-', 'N'); - } else if (chan_list->chan_list[i].dfs_state == DFS_AVAILABLE) { - printf(" [%03d] %04d %c %c %c %c %c %c %c %c\n", chan_list->chan_list[i].hw_value, chan_list->chan_list[i].center_freq, (chan_list->chan_list[i].flags & IEEE80211_CHAN_DISABLED) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_IR) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_RADAR) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_OFDM) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_HT40PLUS) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_HT40MINUS) ? 'Y' : '-', (chan_list->chan_list[i].flags & IEEE80211_CHAN_NO_80MHZ) ? 'Y' : '-', 'A'); - } - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; - -} - -/** - * @brief Process get wireless stats - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_getlog(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct eth_priv_get_log *stats = NULL; - struct ifreq ifr; - struct timeval tv; - int i = 0; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: getlog fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - gettimeofday(&tv, NULL); - - /* Process results */ - stats = (struct eth_priv_get_log *)buffer; - printf("Get log: timestamp %d.%06d sec\n", (int)tv.tv_sec, - (int)tv.tv_usec); - printf("dot11GroupTransmittedFrameCount %u\n" - "dot11FailedCount %u\n" - "dot11RetryCount %u\n" - "dot11MultipleRetryCount %u\n" - "dot11FrameDuplicateCount %u\n" - "dot11RTSSuccessCount %u\n" - "dot11RTSFailureCount %u\n" - "dot11ACKFailureCount %u\n" - "dot11ReceivedFragmentCount %u\n" - "dot11GroupReceivedFrameCount %u\n" - "dot11FCSErrorCount %u\n" - "dot11TransmittedFrameCount %u\n" - "wepicverrcnt-1 %u\n" - "wepicverrcnt-2 %u\n" - "wepicverrcnt-3 %u\n" - "wepicverrcnt-4 %u\n" - "beaconReceivedCount %u\n" - "beaconMissedCount %u\n", stats->mcast_tx_frame, - stats->failed, stats->retry, stats->multi_retry, - stats->frame_dup, stats->rts_success, stats->rts_failure, - stats->ack_failure, stats->rx_frag, stats->mcast_rx_frame, - stats->fcs_error, stats->tx_frame, stats->wep_icv_error[0], - stats->wep_icv_error[1], stats->wep_icv_error[2], - stats->wep_icv_error[3], stats->bcn_rcv_cnt, - stats->bcn_miss_cnt); - if (cmd->used_len == sizeof(struct eth_priv_get_log)) { - printf("dot11TransmittedFragmentCount %u\n", - stats->tx_frag_cnt); - printf("dot11QosTransmittedFragmentCount "); - for (i = 0; i < 8; i++) { - printf("%u ", stats->qos_tx_frag_cnt[i]); - } - printf("\ndot11QosFailedCount "); - for (i = 0; i < 8; i++) { - printf("%u ", stats->qos_failed_cnt[i]); - } - printf("\ndot11QosRetryCount "); - for (i = 0; i < 8; i++) { - printf("%u ", stats->qos_retry_cnt[i]); - } - printf("\ndot11QosMultipleRetryCount "); - for (i = 0; i < 8; i++) { - printf("%u ", stats->qos_multi_retry_cnt[i]); - } - printf("\ndot11QosFrameDuplicateCount "); - for (i = 0; i < 8; i++) { - printf("%u ", stats->qos_frm_dup_cnt[i]); - } - printf("\ndot11QosRTSSuccessCount "); - for (i = 0; i < 8; i++) { - printf("%u ", stats->qos_rts_suc_cnt[i]); - } - printf("\ndot11QosRTSFailureCount "); - for (i = 0; i < 8; i++) { - printf("%u ", stats->qos_rts_failure_cnt[i]); - } - printf("\ndot11QosACKFailureCount "); - for (i = 0; i < 8; i++) { - printf("%u ", stats->qos_ack_failure_cnt[i]); - } - printf("\ndot11QosReceivedFragmentCount "); - for (i = 0; i < 8; i++) { - printf("%u ", stats->qos_rx_frag_cnt[i]); - } - printf("\ndot11QosTransmittedFrameCount "); - for (i = 0; i < 8; i++) { - printf("%u ", stats->qos_tx_frm_cnt[i]); - } - printf("\ndot11QosDiscardedFrameCount "); - for (i = 0; i < 8; i++) { - printf("%u ", stats->qos_discarded_frm_cnt[i]); - } - printf("\ndot11QosMPDUsReceivedCount "); - for (i = 0; i < 8; i++) { - printf("%u ", stats->qos_mpdus_rx_cnt[i]); - } - printf("\ndot11QosRetriesReceivedCount "); - for (i = 0; i < 8; i++) { - printf("%u ", stats->qos_retries_rx_cnt[i]); - } - printf("\ndot11RSNAStatsCMACICVErrors %u\n" - "dot11RSNAStatsCMACReplays %u\n" - "dot11RSNAStatsRobustMgmtCCMPReplays %u\n" - "dot11RSNAStatsTKIPICVErrors %u\n" - "dot11RSNAStatsTKIPReplays %u\n" - "dot11RSNAStatsCCMPDecryptErrors %u\n" - "dot11RSNAstatsCCMPReplays %u\n" - "dot11TransmittedAMSDUCount %u\n" - "dot11FailedAMSDUCount %u\n" - "dot11RetryAMSDUCount %u\n" - "dot11MultipleRetryAMSDUCount %u\n" - "dot11TransmittedOctetsInAMSDUCount %llu\n" - "dot11AMSDUAckFailureCount %u\n" - "dot11ReceivedAMSDUCount %u\n" - "dot11ReceivedOctetsInAMSDUCount %llu\n" - "dot11TransmittedAMPDUCount %u\n" - "dot11TransmittedMPDUsInAMPDUCount %u\n" - "dot11TransmittedOctetsInAMPDUCount %llu\n" - "dot11AMPDUReceivedCount %u\n" - "dot11MPDUInReceivedAMPDUCount %u\n" - "dot11ReceivedOctetsInAMPDUCount %llu\n" - "dot11AMPDUDelimiterCRCErrorCount %u\n", - stats->cmacicv_errors, - stats->cmac_replays, - stats->mgmt_ccmp_replays, - stats->tkipicv_errors, - stats->tkip_replays, - stats->ccmp_decrypt_errors, - stats->ccmp_replays, - stats->tx_amsdu_cnt, - stats->failed_amsdu_cnt, - stats->retry_amsdu_cnt, - stats->multi_retry_amsdu_cnt, - stats->tx_octets_in_amsdu_cnt, - stats->amsdu_ack_failure_cnt, - stats->rx_amsdu_cnt, - stats->rx_octets_in_amsdu_cnt, - stats->tx_ampdu_cnt, - stats->tx_mpdus_in_ampdu_cnt, - stats->tx_octets_in_ampdu_cnt, - stats->ampdu_rx_cnt, - stats->mpdu_in_rx_ampdu_cnt, - stats->rx_octets_in_ampdu_cnt, - stats->ampdu_delimiter_crc_error_cnt); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process esuppmode command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_esuppmode(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct eth_priv_esuppmode_cfg *esuppmodecfg = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: esuppmode fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - esuppmodecfg = (struct eth_priv_esuppmode_cfg *)buffer; - if (argc == 3) { - /* GET operation */ - printf("Esupplicant Mode Configuration: \n"); - /* RSN mode */ - printf(" RSN mode: 0x%x ( ", esuppmodecfg->rsn_mode); - if (esuppmodecfg->rsn_mode & MBIT(0)) - printf("No-RSN "); - if (esuppmodecfg->rsn_mode & MBIT(3)) - printf("WPA "); - if (esuppmodecfg->rsn_mode & MBIT(4)) - printf("WPA-None "); - if (esuppmodecfg->rsn_mode & MBIT(5)) - printf("WPA2 "); - printf(")\n"); - /* Pairwise cipher */ - printf(" Pairwise cipher: 0x%x ( ", - esuppmodecfg->pairwise_cipher); - if (esuppmodecfg->pairwise_cipher & MBIT(2)) - printf("TKIP "); - if (esuppmodecfg->pairwise_cipher & MBIT(3)) - printf("AES "); - printf(")\n"); - /* Group cipher */ - printf(" Group cipher: 0x%x ( ", - esuppmodecfg->group_cipher); - if (esuppmodecfg->group_cipher & MBIT(2)) - printf("TKIP "); - if (esuppmodecfg->group_cipher & MBIT(3)) - printf("AES "); - printf(")\n"); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process passphrase command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_passphrase(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - /* The argument being a string, this requires special handling */ - prepare_buffer(buffer, argv[2], 0, NULL); - if (argc >= 4) { - strcpy((char *)(buffer + strlen(CMD_NXP) + strlen(argv[2])), - argv[3]); - } - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: passphrase fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - printf("Passphrase Configuration: %s\n", (char *)buffer); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process deauth command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_deauth(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - /* The argument being a string, this requires special handling */ - prepare_buffer(buffer, argv[2], 0, NULL); - if (argc >= 4) { - strcpy((char *)(buffer + strlen(CMD_NXP) + strlen(argv[2])), - argv[3]); - } - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: deauth fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -#ifdef UAP_SUPPORT -/** - * @brief Process getstalist command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_getstalist(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - struct eth_priv_getstalist *list = NULL; - int i = 0, rssi = 0; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - /* The argument being a string, this requires special handling */ - prepare_buffer(buffer, argv[2], 0, NULL); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: getstalist fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - list = (struct eth_priv_getstalist *)(buffer + strlen(CMD_NXP) + - strlen(argv[2])); - - printf("Number of STA = %d\n\n", list->sta_count); - - for (i = 0; i < list->sta_count; i++) { - printf("STA %d information:\n", i + 1); - printf("=====================\n"); - printf("MAC Address: "); - print_mac(list->client_info[i].mac_address); - printf("\nPower mgmt status: %s\n", - (list->client_info[i].power_mgmt_status == - 0) ? "active" : "power save"); - - /** On some platform, s8 is same as unsigned char*/ - rssi = (int)list->client_info[i].rssi; - if (rssi > 0x7f) - rssi = -(256 - rssi); - printf("Rssi : %d dBm\n\n", rssi); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} -#endif - -#ifdef WIFI_DIRECT_SUPPORT -#if defined(STA_SUPPORT) && defined(UAP_SUPPORT) -/** - * @brief Process BSS role command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_bssrole(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: bssrole fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - if (argc == 3) { - /* GET operation */ - printf("BSS role: %d\n", buffer[0]); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} -#endif -#endif - -#ifdef STA_SUPPORT -/** - * @brief Helper function for process_getscantable_idx - * - * @param pbuf A pointer to the buffer - * @param buf_len Buffer length - * - * @return NA - * - */ -static void -dump_scan_elems(const t_u8 *pbuf, uint buf_len) -{ - uint idx; - uint marker = 2 + pbuf[1]; - - for (idx = 0; idx < buf_len; idx++) { - if (idx % 0x10 == 0) { - printf("\n%04x: ", idx); - } - - if (idx == marker) { - printf("|"); - marker = idx + pbuf[idx + 1] + 2; - } else { - printf(" "); - } - - printf("%02x ", pbuf[idx]); - } - - printf("\n"); -} - -/** - * @brief Helper function for process_getscantable_idx - * Find next element - * - * @param pp_ie_out Pointer of a IEEEtypes_Generic_t structure pointer - * @param p_buf_left Integer pointer, which contains the number of left p_buf - * - * @return MLAN_STATUS_SUCCESS on success, otherwise MLAN_STATUS_FAILURE - */ -static int -scantable_elem_next(IEEEtypes_Generic_t **pp_ie_out, int *p_buf_left) -{ - IEEEtypes_Generic_t *pie_gen; - t_u8 *p_next; - - if (*p_buf_left < 2) { - return MLAN_STATUS_FAILURE; - } - - pie_gen = *pp_ie_out; - - p_next = (t_u8 *)pie_gen + (pie_gen->ieee_hdr.len - + sizeof(pie_gen->ieee_hdr)); - *p_buf_left -= (p_next - (t_u8 *)pie_gen); - - *pp_ie_out = (IEEEtypes_Generic_t *)p_next; - - if (*p_buf_left <= 0) { - return MLAN_STATUS_FAILURE; - } - - return MLAN_STATUS_SUCCESS; -} - - /** - * @brief Helper function for process_getscantable_idx - * scantable find element - * - * @param ie_buf Pointer of the IE buffer - * @param ie_buf_len IE buffer length - * @param ie_type IE type - * @param ppie_out Pointer to the IEEEtypes_Generic_t structure pointer - * @return MLAN_STATUS_SUCCESS on success, otherwise MLAN_STATUS_FAILURE - */ -static int -scantable_find_elem(t_u8 *ie_buf, - unsigned int ie_buf_len, - IEEEtypes_ElementId_e ie_type, - IEEEtypes_Generic_t **ppie_out) -{ - int found; - unsigned int ie_buf_left; - - ie_buf_left = ie_buf_len; - - found = FALSE; - - *ppie_out = (IEEEtypes_Generic_t *)ie_buf; - - do { - found = ((*ppie_out)->ieee_hdr.element_id == ie_type); - - } while (!found && - (scantable_elem_next(ppie_out, (int *)&ie_buf_left) == 0)); - - if (!found) { - *ppie_out = NULL; - } - - return found ? MLAN_STATUS_SUCCESS : MLAN_STATUS_FAILURE; -} - - /** - * @brief Helper function for process_getscantable_idx - * It gets SSID from IE - * - * @param ie_buf IE buffer - * @param ie_buf_len IE buffer length - * @param pssid SSID - * @param ssid_buf_max Size of SSID - * @return MLAN_STATUS_SUCCESS on success, otherwise MLAN_STATUS_FAILURE - */ -static int -scantable_get_ssid_from_ie(t_u8 *ie_buf, - unsigned int ie_buf_len, - t_u8 *pssid, unsigned int ssid_buf_max) -{ - int retval; - IEEEtypes_Generic_t *pie_gen; - - retval = scantable_find_elem(ie_buf, ie_buf_len, SSID, &pie_gen); - if (retval == MLAN_STATUS_SUCCESS) - memcpy(pssid, pie_gen->data, - MIN(pie_gen->ieee_hdr.len, ssid_buf_max)); - else - return MLAN_STATUS_FAILURE; - - return retval; -} - -/** - * @brief Display detailed information for a specific scan table entry - * - * @param cmd_name Command name - * @param prsp_info_req Scan table entry request structure - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_getscantable_idx(char *cmd_name, - wlan_ioctl_get_scan_table_info *prsp_info_req) -{ - int ret = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - t_u8 *pcurrent; - char ssid[33]; - t_u16 tmp_cap; - t_u8 tsf[8]; - t_u16 beacon_interval; - t_u16 cap_info; - wlan_ioctl_get_scan_table_info *prsp_info; - - wlan_get_scan_table_fixed fixed_fields; - t_u32 fixed_field_length; - t_u32 bss_info_length; - - memset(ssid, 0x00, sizeof(ssid)); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, cmd_name, 0, NULL); - - prsp_info = - (wlan_ioctl_get_scan_table_info *)(buffer + strlen(CMD_NXP) + - strlen(cmd_name)); - - memcpy(prsp_info, prsp_info_req, - sizeof(wlan_ioctl_get_scan_table_info)); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* - * Set up and execute the ioctl call - */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - if (errno == EAGAIN) { - ret = -EAGAIN; - } else { - perror("mlanutl"); - fprintf(stderr, "mlanutl: getscantable fail\n"); - ret = MLAN_STATUS_FAILURE; - } - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return ret; - } - - prsp_info = (wlan_ioctl_get_scan_table_info *)buffer; - if (prsp_info->scan_number == 0) { - printf("mlanutl: getscantable ioctl - index out of range\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return -EINVAL; - } - - pcurrent = prsp_info->scan_table_entry_buf; - - memcpy((t_u8 *)&fixed_field_length, - (t_u8 *)pcurrent, sizeof(fixed_field_length)); - pcurrent += sizeof(fixed_field_length); - - memcpy((t_u8 *)&bss_info_length, - (t_u8 *)pcurrent, sizeof(bss_info_length)); - pcurrent += sizeof(bss_info_length); - - memcpy((t_u8 *)&fixed_fields, (t_u8 *)pcurrent, sizeof(fixed_fields)); - pcurrent += fixed_field_length; - - /* Time stamp is 8 byte long */ - memcpy(tsf, pcurrent, sizeof(tsf)); - pcurrent += sizeof(tsf); - bss_info_length -= sizeof(tsf); - - /* Beacon interval is 2 byte long */ - memcpy(&beacon_interval, pcurrent, sizeof(beacon_interval)); - pcurrent += sizeof(beacon_interval); - bss_info_length -= sizeof(beacon_interval); - - /* Capability information is 2 byte long */ - memcpy(&cap_info, pcurrent, sizeof(cap_info)); - pcurrent += sizeof(cap_info); - bss_info_length -= sizeof(cap_info); - - scantable_get_ssid_from_ie(pcurrent, - bss_info_length, (t_u8 *)ssid, sizeof(ssid)); - - printf("\n*** [%s], %02x:%02x:%02x:%02x:%02x:%2x\n", - ssid, - fixed_fields.bssid[0], - fixed_fields.bssid[1], - fixed_fields.bssid[2], - fixed_fields.bssid[3], - fixed_fields.bssid[4], fixed_fields.bssid[5]); - memcpy(&tmp_cap, &cap_info, sizeof(tmp_cap)); - printf("Channel = %d, SS = %d, ChanLoad = %d%% CapInfo = 0x%04x, BcnIntvl = %d\n", fixed_fields.channel, 255 - fixed_fields.rssi, fixed_fields.chan_load, tmp_cap, beacon_interval); - - printf("TSF Values: AP(0x%02x%02x%02x%02x%02x%02x%02x%02x), ", - tsf[7], tsf[6], tsf[5], tsf[4], tsf[3], tsf[2], tsf[1], tsf[0]); - - printf("Network(0x%016llx)\n", fixed_fields.network_tsf); - printf("\n"); - printf("Element Data (%d bytes)\n", (int)bss_info_length); - printf("------------"); - dump_scan_elems(pcurrent, bss_info_length); - printf("\n"); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief channel validation. - * @param scan_req A pointer to wlan_ioctl_user_scan_cfg structure - * @param chan_num channel number - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -wlan_is_channel_valid(wlan_ioctl_user_scan_cfg *scan_req, t_u8 chan_number) -{ - int ret = -1; - int i; - if (scan_req && scan_req->chan_list[0].chan_number) { - for (i = 0; - i < WLAN_IOCTL_USER_SCAN_CHAN_MAX && - scan_req->chan_list[i].chan_number; i++) { - if (scan_req->chan_list[i].chan_number == chan_number) { - ret = 0; - break; - } - } - } else { - ret = 0; - } - return ret; -} - -/** - * @brief filter_ssid_result - * @param scan_req A pointer to wlan_ioctl_user_scan_cfg structure - * @param num_ssid_rqst Number of SSIDs which are filterted - * @param bss_info A pointer to current bss information structure - * @return 0--success, otherwise--fail - */ - -int -filter_ssid_result(wlan_ioctl_user_scan_cfg *scan_req, int num_ssid_rqst, - wlan_ioctl_get_bss_info *bss_info) -{ - int i, ret = 1; - - for (i = 0; i < num_ssid_rqst; i++) { - if ((memcmp(scan_req->ssid_list[i].ssid, bss_info->ssid, - (int)bss_info->ssid_len)) == 0) { - return 0; - } - } - return ret; -} - -/** - * @brief Process getchanstats - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -wlan_process_getchanstats(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - int ret = 0; - int idx = 0; - int i = 0; - chan_stats *stats = NULL; - t_u16 chan_load = 0; - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - prepare_buffer(buffer, argv[2], 0, NULL); - - /* Set up and execute the ioctl call */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: getchload fail\n"); - ret = MLAN_STATUS_FAILURE; - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return ret; - } - - stats = (chan_stats *) buffer; - /* Display scan results */ - printf("----------------------------------------------------------- \n"); - printf("# | Channel | BSS | minrss | maxrss | NF | CH load \n"); - printf("----------------------------------------------------------- \n"); - - for (i = 0; i < stats->num_in_chan_stats; i++) { - if (stats->stats[i].cca_scan_duration) { - chan_load = - stats->stats[i].cca_busy_duration * 100 / - stats->stats[i].cca_scan_duration; - printf("%02u| %03d | %03d | %02d | %02d | %02d | %02d\n", idx, stats->stats[i].chan_num, stats->stats[i].total_networks, stats->stats[i].min_rss, stats->stats[i].max_rss, stats->stats[i].noise, chan_load); - idx++; - } - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process getscantable command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @param scan_req A pointer to wlan_ioctl_user_scan_cfg structure - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -wlan_process_getscantable(int argc, char *argv[], - wlan_ioctl_user_scan_cfg *scan_req) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - struct wlan_ioctl_get_scan_list *scan_list_head = NULL; - struct wlan_ioctl_get_scan_list *scan_list_node = NULL; - struct wlan_ioctl_get_scan_list *curr = NULL, *next = NULL; - - t_u32 total_scan_res = 0; - - unsigned int scan_start; - int idx, ret = 0; - int i = 0; - t_u8 *pcurrent; - t_u8 *pnext; - IEEEtypes_ElementId_e *pelement_id; - t_u8 *pelement_len; - int ssid_idx; - int insert = 0; - int sort_by_channel = 0; - t_u8 *pbyte; - t_u16 new_ss = 0; - t_u16 curr_ss = 0; - t_u8 new_ch = 0; - t_u8 curr_ch = 0; - - IEEEtypes_VendorSpecific_t *pwpa_ie; - const t_u8 wpa_oui[4] = { 0x00, 0x50, 0xf2, 0x01 }; - - IEEEtypes_WmmParameter_t *pwmm_ie; - const t_u8 wmm_oui[4] = { 0x00, 0x50, 0xf2, 0x02 }; - IEEEtypes_VendorSpecific_t *pwps_ie; - const t_u8 wps_oui[4] = { 0x00, 0x50, 0xf2, 0x04 }; - - int displayed_info; - - wlan_ioctl_get_scan_table_info rsp_info_req; - wlan_ioctl_get_scan_table_info *prsp_info; - - wlan_get_scan_table_fixed fixed_fields; - t_u32 fixed_field_length; - t_u32 bss_info_length; - wlan_ioctl_get_bss_info *bss_info; - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - if (argc > 3 && (strcmp(argv[3], "tsf") != 0) - && (strcmp(argv[3], "help") != 0) - && (strcmp(argv[3], "ch") != 0)) { - - idx = strtol(argv[3], NULL, 10); - - if (idx >= 0) { - rsp_info_req.scan_number = idx; - ret = process_getscantable_idx(argv[2], &rsp_info_req); - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; - } - } - - displayed_info = FALSE; - scan_start = 1; - - do { - prepare_buffer(buffer, argv[2], 0, NULL); - prsp_info = - (wlan_ioctl_get_scan_table_info *)(buffer + - strlen(CMD_NXP) + - strlen(argv[2])); - - prsp_info->scan_number = scan_start; - - /* - * Set up and execute the ioctl call - */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - if (errno == EAGAIN) { - ret = -EAGAIN; - } else { - perror("mlanutl"); - fprintf(stderr, "mlanutl: getscantable fail\n"); - ret = MLAN_STATUS_FAILURE; - } - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return ret; - } - - prsp_info = (wlan_ioctl_get_scan_table_info *)buffer; - pcurrent = 0; - pnext = prsp_info->scan_table_entry_buf; - total_scan_res += prsp_info->scan_number; - - for (idx = 0; (unsigned int)idx < prsp_info->scan_number; idx++) { - /* Alloc memory for new node for next BSS */ - scan_list_node = (struct wlan_ioctl_get_scan_list *) - malloc(sizeof(struct wlan_ioctl_get_scan_list)); - if (scan_list_node == NULL) { - printf("Error: allocate memory for scan_list_head failed\n"); - return -ENOMEM; - } - memset(scan_list_node, 0, - sizeof(struct wlan_ioctl_get_scan_list)); - - /* - * Set pcurrent to pnext in case pad bytes are at the end - * of the last IE we processed. - */ - pcurrent = pnext; - - /* Start extracting each BSS to prepare a linked list */ - memcpy((t_u8 *)&fixed_field_length, - (t_u8 *)pcurrent, sizeof(fixed_field_length)); - pcurrent += sizeof(fixed_field_length); - - memcpy((t_u8 *)&bss_info_length, - (t_u8 *)pcurrent, sizeof(bss_info_length)); - pcurrent += sizeof(bss_info_length); - - memcpy((t_u8 *)&fixed_fields, - (t_u8 *)pcurrent, sizeof(fixed_fields)); - pcurrent += fixed_field_length; - - scan_list_node->fixed_buf.fixed_field_length = - fixed_field_length; - scan_list_node->fixed_buf.bss_info_length = - bss_info_length; - scan_list_node->fixed_buf.fixed_fields = fixed_fields; - - bss_info = &scan_list_node->bss_info_buf; - - /* Set next to be the start of the next scan entry */ - pnext = pcurrent + bss_info_length; - - if (bss_info_length >= - (sizeof(bss_info->tsf) + - sizeof(bss_info->beacon_interval) + - sizeof(bss_info->cap_info))) { - - /* time stamp is 8 byte long */ - memcpy(bss_info->tsf, pcurrent, - sizeof(bss_info->tsf)); - pcurrent += sizeof(bss_info->tsf); - bss_info_length -= sizeof(bss_info->tsf); - - /* beacon interval is 2 byte long */ - memcpy(&bss_info->beacon_interval, pcurrent, - sizeof(bss_info->beacon_interval)); - pcurrent += sizeof(bss_info->beacon_interval); - bss_info_length -= - sizeof(bss_info->beacon_interval); - /* capability information is 2 byte long */ - memcpy(&bss_info->cap_info, pcurrent, - sizeof(bss_info->cap_info)); - pcurrent += sizeof(bss_info->cap_info); - bss_info_length -= sizeof(bss_info->cap_info); - } - - bss_info->wmm_cap = ' '; /* M (WMM), C (WMM-Call Admission Control) */ - bss_info->wps_cap = ' '; /* "S" */ - bss_info->dot11k_cap = ' '; /* "K" */ - bss_info->dot11r_cap = ' '; /* "R" */ - bss_info->ht_cap = ' '; /* "N" */ - bss_info->vht_cap[0] = ' '; - bss_info->vht_cap[1] = ' '; - /* "P" for Privacy (WEP) since "W" is WPA, and "2" is RSN/WPA2 */ - bss_info->priv_cap = - bss_info->cap_info.privacy ? 'P' : ' '; - - memset(bss_info->ssid, 0, MRVDRV_MAX_SSID_LENGTH + 1); - bss_info->ssid_len = 0; - - while (bss_info_length >= 2) { - pelement_id = (IEEEtypes_ElementId_e *)pcurrent; - pelement_len = pcurrent + 1; - pcurrent += 2; - - if ((bss_info_length - 2) < *pelement_len) { - printf("Error when processing bss info, bss_info_length < element length\n"); - bss_info_length = 0; - continue; - } - - switch (*pelement_id) { - case SSID: - if (*pelement_len && - *pelement_len <= - MRVDRV_MAX_SSID_LENGTH) { - memcpy(bss_info->ssid, pcurrent, - *pelement_len); - bss_info->ssid_len = - *pelement_len; - } - break; - - case WPA_IE: - pwpa_ie = - (IEEEtypes_VendorSpecific_t *) - pelement_id; - if ((memcmp - (pwpa_ie->vend_hdr.oui, wpa_oui, - sizeof(pwpa_ie->vend_hdr.oui)) == - 0) - && (pwpa_ie->vend_hdr.oui_type == - wpa_oui[3])) { - /* WPA IE found, 'W' for WPA */ - bss_info->priv_cap = 'W'; - } else { - pwmm_ie = - (IEEEtypes_WmmParameter_t - *)pelement_id; - if ((memcmp - (pwmm_ie->vend_hdr.oui, - wmm_oui, - sizeof(pwmm_ie->vend_hdr. - oui)) == 0) - && (pwmm_ie->vend_hdr. - oui_type == - wmm_oui[3])) { - /* Check the subtype: 1 == parameter, 0 == info */ - if ((pwmm_ie->vend_hdr. - oui_subtype == 1) - && pwmm_ie-> - ac_params - [WMM_AC_VO]. - aci_aifsn.acm) { - /* Call admission on VO; 'C' for CAC */ - bss_info-> - wmm_cap - = 'C'; - } else { - /* No CAC; 'M' for uh, WMM */ - bss_info-> - wmm_cap - = 'M'; - } - } else { - pwps_ie = - (IEEEtypes_VendorSpecific_t - *)pelement_id; - if ((memcmp - (pwps_ie->vend_hdr. - oui, wps_oui, - sizeof(pwps_ie-> - vend_hdr. - oui)) == 0) - && (pwps_ie-> - vend_hdr. - oui_type == - wps_oui[3])) { - bss_info-> - wps_cap - = 'S'; - } - } - } - break; - - case RSN_IE: - /* RSN IE found; '2' for WPA2 (RSN) */ - bss_info->priv_cap = '2'; - break; - case HT_CAPABILITY: - bss_info->ht_cap = 'N'; - break; - case VHT_CAPABILITY: - bss_info->vht_cap[0] = 'A'; - bss_info->vht_cap[1] = 'C'; - break; - default: - break; - } - - pcurrent += *pelement_len; - bss_info_length -= (2 + *pelement_len); - } - - /* Create a sorted list of BSS using Insertion Sort. */ - if ((argc > 3) && !strcmp(argv[3], "ch")) { - /* Sort by channel number (ascending order) */ - new_ch = fixed_fields.channel; - sort_by_channel = 1; - } else { - /* Sort as per Signal Strength (descending order) (Default case) */ - new_ss = 255 - fixed_fields.rssi; - } - if (scan_list_head == NULL) { - /* Node is the first element in the list. */ - scan_list_head = scan_list_node; - scan_list_node->next = NULL; - scan_list_node->prev = NULL; - } else { - curr = scan_list_head; - insert = 0; - do { - if (sort_by_channel) { - curr_ch = - curr->fixed_buf. - fixed_fields.channel; - if (new_ch < curr_ch) - insert = 1; - } else { - curr_ss = - 255 - - curr->fixed_buf. - fixed_fields.rssi; - if (new_ss > curr_ss) { - insert = 1; - } - } - if (insert) { - if (curr == scan_list_head) { - /* Insert the node to head of the list */ - scan_list_node->next = - scan_list_head; - scan_list_head->prev = - scan_list_node; - scan_list_head = - scan_list_node; - } else { - /* Insert the node to current position in list */ - scan_list_node->prev = - curr->prev; - scan_list_node->next = - curr; - (curr->prev)->next = - scan_list_node; - curr->prev = - scan_list_node; - } - break; - } - if (curr->next == NULL) { - /* Insert the node to tail of the list */ - curr->next = scan_list_node; - scan_list_node->prev = curr; - scan_list_node->next = NULL; - break; - } - curr = curr->next; - } while (curr != NULL); - } - } - scan_start += prsp_info->scan_number; - } while (prsp_info->scan_number); - - /* Display scan results */ - printf("---------------------------------------"); - printf("---------------------------------------\n"); - printf("# | ch | ss | ld | bssid | cap | SSID \n"); - printf("---------------------------------------"); - printf("---------------------------------------\n"); - - for (curr = scan_list_head, idx = 0; - (curr != NULL) && ((unsigned int)idx < total_scan_res); - curr = curr->next, idx++) { - fixed_fields = curr->fixed_buf.fixed_fields; - bss_info = &curr->bss_info_buf; - if (wlan_is_channel_valid(scan_req, fixed_fields.channel)) - continue; - - if (setuserscan_filter == BSSID_FILTER) { - if (scan_req->bssid_num) { - for (i = 0; i < scan_req->bssid_num; i++) { - if (memcmp - (scan_req->bssid_list[i].bssid, - fixed_fields.bssid, ETH_ALEN)) - continue; - } - } else if (memcmp - (scan_req->specific_bssid, - fixed_fields.bssid, ETH_ALEN)) - continue; - } - if (setuserscan_filter == SSID_FILTER) { - if (filter_ssid_result - (scan_req, num_ssid_filter, bss_info)) - continue; - } - printf("%02u| %03d | %03d | %03d | %02x:%02x:%02x:%02x:%02x:%02x |", idx, fixed_fields.channel, -fixed_fields.rssi, fixed_fields.chan_load, fixed_fields.bssid[0], fixed_fields.bssid[1], fixed_fields.bssid[2], fixed_fields.bssid[3], fixed_fields.bssid[4], fixed_fields.bssid[5]); - displayed_info = TRUE; - - /* "A" for Adhoc - * "I" for Infrastructure, - * "D" for DFS (Spectrum Mgmt) - */ - printf(" %c%c%c%c%c%c%c%c%c%c | ", bss_info->cap_info.ibss ? 'A' : 'I', bss_info->priv_cap, /* P (WEP), W (WPA), 2 (WPA2) */ - bss_info->cap_info.spectrum_mgmt ? 'D' : ' ', bss_info->wmm_cap, /* M (WMM), C (WMM-Call Admission Control) */ - bss_info->dot11k_cap, /* K */ - bss_info->dot11r_cap, /* R */ - bss_info->wps_cap, /* S */ - bss_info->ht_cap, /* N */ - bss_info->vht_cap[0], /* AC */ - bss_info->vht_cap[1]); - - /* Print out the ssid or the hex values if non-printable */ - for (ssid_idx = 0; ssid_idx < (int)bss_info->ssid_len; - ssid_idx++) { - if (isprint(bss_info->ssid[ssid_idx])) { - printf("%c", bss_info->ssid[ssid_idx]); - } else { - printf("\\%02x", bss_info->ssid[ssid_idx]); - } - } - - printf("\n"); - - if (argc > 3 && strcmp(argv[3], "tsf") == 0) { - /* TSF is a u64, some formatted printing libs have trouble - printing long longs, so cast and dump as bytes */ - pbyte = (t_u8 *)&fixed_fields.network_tsf; - printf(" TSF=%02x%02x%02x%02x%02x%02x%02x%02x\n", - pbyte[7], pbyte[6], pbyte[5], pbyte[4], - pbyte[3], pbyte[2], pbyte[1], pbyte[0]); - } - } - - if (displayed_info == TRUE) { - if (argc > 3 && strcmp(argv[3], "help") == 0) { - printf("\n\n" - "Capability Legend (Not all may be supported)\n" - "-----------------\n" - " I [ Infrastructure ]\n" - " A [ Ad-hoc ]\n" - " W [ WPA IE ]\n" - " 2 [ WPA2/RSN IE ]\n" - " M [ WMM IE ]\n" - " C [ Call Admission Control - WMM IE, VO ACM set ]\n" - " D [ Spectrum Management - DFS (11h) ]\n" - " K [ 11k ]\n" - " R [ 11r ]\n" - " S [ WPS ]\n" - " N [ HT (11n) ]\n" - " AC [VHT (11ac) ]\n" "\n\n"); - } - } else { - printf("< No Scan Results >\n"); - } - - for (curr = scan_list_head; curr != NULL; curr = next) { - next = curr->next; - free(curr); - } - argv[2] = "getchanstats"; - process_getchanstats(argc, argv); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process getschstats command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_getchanstats(int argc, char *argv[]) -{ - return wlan_process_getchanstats(argc, argv); -} - -/** - * @brief Process getscantable command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @param scan_req A pointer to wlan_ioctl_user_scan_cfg structure - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_getscantable(int argc, char *argv[]) -{ - return wlan_process_getscantable(argc, argv, NULL); -} - -/** - * @brief Prepare setuserscan command buffer - * @param scan_req pointer to wlan_ioctl_user_scan_cfg structure - * @param num Number of arguments - * @param args Arguments list - * @return MLAN_STATUS_SUCCESS - */ -static int -prepare_setuserscan_buffer(wlan_ioctl_user_scan_cfg *scan_req, t_u32 num, - char *args[]) -{ - int arg_idx = 0; - int num_ssid = 0; - int num_bssid = 0; - char *parg_tok = NULL; - char *pchan_tok = NULL; - char *parg_cookie = NULL; - char *pchan_cookie = NULL; - int chan_parse_idx = 0; - int chan_cmd_idx = 0; - char chan_scratch[MAX_CHAN_SCRATCH]; - char *pscratch = NULL; - int tmp_idx = 0; - int scan_time = 0; - int is_radio_set = 0; - unsigned int mac[ETH_ALEN]; - - for (arg_idx = 0; arg_idx < (int)num; arg_idx++) { - if (strncmp(args[arg_idx], "ssid=", strlen("ssid=")) == 0) { - /* "ssid" token string handler */ - if (num_ssid < MRVDRV_MAX_SSID_LIST_LENGTH) { - strncpy(scan_req->ssid_list[num_ssid].ssid, - args[arg_idx] + strlen("ssid="), - sizeof(scan_req->ssid_list[num_ssid]. - ssid)); - - scan_req->ssid_list[num_ssid].max_len = 0; - setuserscan_filter = SSID_FILTER; - num_ssid++; - num_ssid_filter++; - } - } else if (strncmp(args[arg_idx], "bssid=", strlen("bssid=")) == - 0) { - /* "bssid" token string handler */ - if (num_bssid < MAX_BSSID_FILTER_LIST) { - sscanf(args[arg_idx] + strlen("bssid="), - "%2x:%2x:%2x:%2x:%2x:%2x", mac + 0, - mac + 1, mac + 2, mac + 3, mac + 4, - mac + 5); - setuserscan_filter = BSSID_FILTER; - for (tmp_idx = 0; - (unsigned int)tmp_idx < NELEMENTS(mac); - tmp_idx++) { - scan_req->bssid_list[num_bssid]. - bssid[tmp_idx] = - (t_u8)mac[tmp_idx]; - } - /* Update BSSID into specific_bssid field */ - if (scan_req->bssid_num == 0) { - for (tmp_idx = 0; - (unsigned int)tmp_idx < - NELEMENTS(mac); tmp_idx++) { - scan_req-> - specific_bssid[tmp_idx] - = (t_u8)mac[tmp_idx]; - } - } - num_bssid++; - scan_req->bssid_num = num_bssid; - } - - } else if (strncmp(args[arg_idx], "chan=", strlen("chan=")) == - 0) { - /* "chan" token string handler */ - parg_tok = args[arg_idx] + strlen("chan="); - - if (strlen(parg_tok) > MAX_CHAN_SCRATCH) { - printf("Error: Specified channels exceeds max limit\n"); - return MLAN_STATUS_FAILURE; - } - is_radio_set = FALSE; - - while ((parg_tok = - strtok_r(parg_tok, ",", - &parg_cookie)) != NULL) { - - memset(chan_scratch, 0x00, - sizeof(chan_scratch)); - pscratch = chan_scratch; - - for (chan_parse_idx = 0; - (unsigned int)chan_parse_idx < - strlen(parg_tok); chan_parse_idx++) { - if (isalpha - (*(parg_tok + chan_parse_idx))) { - *pscratch++ = ' '; - } - - *pscratch++ = - *(parg_tok + chan_parse_idx); - } - *pscratch = 0; - parg_tok = NULL; - - pchan_tok = chan_scratch; - - while ((pchan_tok = strtok_r(pchan_tok, " ", - &pchan_cookie)) != - NULL) { - if (isdigit(*pchan_tok)) { - scan_req-> - chan_list[chan_cmd_idx]. - chan_number = - atoi(pchan_tok); - if (scan_req-> - chan_list[chan_cmd_idx]. - chan_number > - MAX_CHAN_BG_BAND) - scan_req-> - chan_list - [chan_cmd_idx]. - radio_type = 1; - } else { - switch (toupper(*pchan_tok)) { - case 'A': - scan_req-> - chan_list - [chan_cmd_idx]. - radio_type = 1; - is_radio_set = TRUE; - break; - case 'B': - case 'G': - scan_req-> - chan_list - [chan_cmd_idx]. - radio_type = 0; - is_radio_set = TRUE; - break; - case 'N': - break; - case 'C': - scan_req-> - chan_list - [chan_cmd_idx]. - scan_type = - MLAN_SCAN_TYPE_ACTIVE; - break; - case 'P': - scan_req-> - chan_list - [chan_cmd_idx]. - scan_type = - MLAN_SCAN_TYPE_PASSIVE; - break; - default: - printf("Error: Band type not supported!\n"); - return -EOPNOTSUPP; - } - if (!chan_cmd_idx && - !scan_req-> - chan_list[chan_cmd_idx]. - chan_number && is_radio_set) - scan_req-> - chan_list - [chan_cmd_idx]. - radio_type |= - BAND_SPECIFIED; - } - pchan_tok = NULL; - } - if (((scan_req->chan_list[chan_cmd_idx]. - chan_number > MAX_CHAN_BG_BAND) - && !scan_req->chan_list[chan_cmd_idx]. - radio_type) || - ((scan_req->chan_list[chan_cmd_idx]. - chan_number < MAX_CHAN_BG_BAND) - && (scan_req->chan_list[chan_cmd_idx]. - radio_type == 1))) { - printf("Error: Invalid Radio type: chan=%d radio_type=%d\n", scan_req->chan_list[chan_cmd_idx].chan_number, scan_req->chan_list[chan_cmd_idx].radio_type); - return MLAN_STATUS_FAILURE; - } - chan_cmd_idx++; - } - } else if (strncmp(args[arg_idx], "gap=", strlen("gap=")) == 0) { - scan_req->scan_chan_gap = - atoi(args[arg_idx] + strlen("gap=")); - } else if (strncmp(args[arg_idx], "keep=", strlen("keep=")) == - 0) { - /* "keep" token string handler */ - scan_req->keep_previous_scan = - atoi(args[arg_idx] + strlen("keep=")); - } else if (strncmp(args[arg_idx], "dur=", strlen("dur=")) == 0) { - /* "dur" token string handler */ - scan_time = atoi(args[arg_idx] + strlen("dur=")); - scan_req->chan_list[0].scan_time = scan_time; - - } else if (strncmp(args[arg_idx], "wc=", strlen("wc=")) == 0) { - - if (num_ssid < MRVDRV_MAX_SSID_LIST_LENGTH) { - /* "wc" token string handler */ - pscratch = strrchr(args[arg_idx], ','); - - if (pscratch) { - *pscratch = 0; - pscratch++; - - if (isdigit(*pscratch)) { - scan_req->ssid_list[num_ssid]. - max_len = - atoi(pscratch); - } else { - scan_req->ssid_list[num_ssid]. - max_len = *pscratch; - } - } else { - /* Standard wildcard matching */ - scan_req->ssid_list[num_ssid].max_len = - 0xFF; - } - - strncpy(scan_req->ssid_list[num_ssid].ssid, - args[arg_idx] + strlen("wc="), - sizeof(scan_req->ssid_list[num_ssid]. - ssid)); - - num_ssid++; - } - } else if (strncmp(args[arg_idx], "probes=", strlen("probes=")) - == 0) { - /* "probes" token string handler */ - scan_req->num_probes = - atoi(args[arg_idx] + strlen("probes=")); - if (scan_req->num_probes > MAX_PROBES) { - fprintf(stderr, "Invalid probes (> %d)\n", - MAX_PROBES); - return -EOPNOTSUPP; - } - } else if (strncmp - (args[arg_idx], "bss_type=", - strlen("bss_type=")) == 0) { - /* "bss_type" token string handler */ - scan_req->bss_mode = - atoi(args[arg_idx] + strlen("bss_type=")); - switch (scan_req->bss_mode) { - case MLAN_SCAN_MODE_BSS: - case MLAN_SCAN_MODE_IBSS: - break; - case MLAN_SCAN_MODE_ANY: - default: - /* Set any unknown types to ANY */ - scan_req->bss_mode = MLAN_SCAN_MODE_ANY; - break; - } - } else if (strncmp - (args[arg_idx], "scan_type=", - strlen("scan_type=")) == 0) { - /* "scan_type" token string handler */ - scan_req->ext_scan_type = - atoi(args[arg_idx] + strlen("scan_type=")); - } - } - - /* Update all the channels to have the same scan time */ - for (tmp_idx = 1; tmp_idx < chan_cmd_idx; tmp_idx++) { - scan_req->chan_list[tmp_idx].scan_time = scan_time; - } - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process setuserscan command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_setuserscan(int argc, char *argv[]) -{ - wlan_ioctl_user_scan_cfg *scan_req = NULL; - t_u8 *pos = NULL; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - int status = 0; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - memset(buffer, 0, BUFFER_LENGTH); - - /* Flag it for our use */ - pos = buffer; - strncpy((char *)pos, CMD_NXP, strlen(CMD_NXP)); - pos += (strlen(CMD_NXP)); - - /* Insert command */ - strncpy((char *)pos, (char *)argv[2], strlen(argv[2])); - pos += (strlen(argv[2])); - - /* Insert arguments */ - scan_req = (wlan_ioctl_user_scan_cfg *)pos; - - if (prepare_setuserscan_buffer(scan_req, (argc - 3), &argv[3])) { - printf("ERR:Invalid parameter\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: setuserscan fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - if (argc > 3) { - if (!strcmp(argv[3], "sort_by_ch")) { - argv[3] = "ch"; - } else { - argc = 0; - } - } - do { - argv[2] = "getscantable"; - status = wlan_process_getscantable(argc, argv, scan_req); - } while (status == -EAGAIN); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process extended capabilities configuration - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_extcapcfg(int argc, char *argv[]) -{ - t_u8 *buffer = NULL, ext_cap[9]; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - IEEEtypes_Header_t ie; - - if (argc > 4) { - printf("ERR:Incorrect number of arguments.\n"); - printf("Syntax: ./mlanutl mlanX extcapcfg \n"); - return MLAN_STATUS_FAILURE; - } - - if (argc == 4 && MLAN_STATUS_FAILURE == ishexstring(argv[3])) { - printf("ERR:Only hex digits are allowed.\n"); - printf("Syntax: ./mlanutl mlanX extcapcfg \n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - /* Only insert command */ - prepare_buffer(buffer, argv[2], 0, NULL); - - if (argc == 4) { - if (!strncasecmp("0x", argv[3], 2)) - argv[3] += 2; - - if (strlen(argv[3]) > 2 * sizeof(ext_cap)) { - printf("ERR:Incorrect length of arguments.\n"); - printf("Syntax: ./mlanutl mlanX extcapcfg \n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - memset(ext_cap, 0, sizeof(ext_cap)); - ie.element_id = TLV_TYPE_EXTCAP; - ie.len = sizeof(ext_cap); - - string2raw(argv[3], ext_cap); - memcpy(buffer + strlen(CMD_NXP) + strlen(argv[2]), &ie, - sizeof(ie)); - memcpy(buffer + strlen(CMD_NXP) + strlen(argv[2]) + sizeof(ie), - ext_cap, sizeof(ext_cap)); - } - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, - "mlanutl: extended capabilities configure fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - hexdump("Extended capabilities", buffer + sizeof(IEEEtypes_Header_t), - ((IEEEtypes_Header_t *)buffer)->len, ' '); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Cancel ongoing scan - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_cancelscan(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - if (argc != 3) { - printf("ERR:Incorrect number of arguments.\n"); - printf("Syntax: ./mlanutl mlanX cancelscan\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - /* Only insert command */ - prepare_buffer(buffer, argv[2], 0, NULL); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: cancel scan fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} -#endif /* STA_SUPPORT */ - -/** - * @brief Process deep sleep configuration - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_deepsleep(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: deepsleep fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - printf("Deepsleep command response: %s\n", buffer); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process ipaddr command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_ipaddr(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - /* The argument being a string, this requires special handling */ - prepare_buffer(buffer, argv[2], 0, NULL); - if (argc >= 4) { - strcpy((char *)(buffer + strlen(CMD_NXP) + strlen(argv[2])), - argv[3]); - } - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: ipaddr fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - printf("IP address Configuration: %s\n", (char *)buffer); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process otpuserdata command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_otpuserdata(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - if (argc < 4) { - printf("ERR:No argument\n"); - return MLAN_STATUS_FAILURE; - } - - if (a2hex_or_atoi(argv[3]) > BUFFER_LENGTH) { - printf("ERR: user_data_length too big\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: otpuserdata fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - hexdump("OTP user data: ", buffer, - MIN(cmd->used_len, a2hex_or_atoi(argv[3])), ' '); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process countrycode setting - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_countrycode(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct eth_priv_countrycode *countrycode = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - /* The argument being a string, this requires special handling */ - prepare_buffer(buffer, argv[2], 0, NULL); - if (argc >= 4) { - strcpy((char *)(buffer + strlen(CMD_NXP) + strlen(argv[2])), - argv[3]); - } - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: countrycode fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - countrycode = (struct eth_priv_countrycode *)buffer; - if (argc == 3) { - /* GET operation */ - printf("Country code: %s\n", countrycode->country_code); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process TCP ACK enhancement configuration - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_tcpackenh(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: tcpackenh fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - printf("TCP Ack enhancement: "); - if (buffer[0]) - printf("enabled.\n"); - else - printf("disabled.\n"); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -#ifdef REASSOCIATION -/** - * @brief Process asynced essid setting - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_assocessid(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - /* The argument being a string, this requires special handling */ - prepare_buffer(buffer, argv[2], 0, NULL); - if (argc >= 4) { - strcpy((char *)(buffer + strlen(CMD_NXP) + strlen(argv[2])), - argv[3]); - } - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: assocessid fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - printf("Set Asynced ESSID: %s\n", (char *)buffer); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; - -} -#endif - -#ifdef STA_SUPPORT -/** - * @brief Process listen interval configuration - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_listeninterval(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: listen interval fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - if (argc == 3) - printf("Listen interval command response: %s\n", buffer); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process power save mode setting - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_psmode(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - int psmode = 0; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: psmode fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - psmode = *(int *)buffer; - printf("PS mode: %d\n", psmode); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} -#endif - #ifdef DEBUG_LEVEL1 /** * @brief Process driver debug configuration @@ -6842,8 +1124,7 @@ process_psmode(int argc, char *argv[]) * @param argv A pointer to arguments array * @return MLAN_STATUS_SUCCESS--success, otherwise--fail */ -static int -process_drvdbg(int argc, char *argv[]) +static int process_drvdbg(int argc, char *argv[]) { t_u8 *buffer = NULL; struct eth_priv_cmd *cmd = NULL; @@ -6932,7 +1213,6 @@ process_drvdbg(int argc, char *argv[]) printf("MFATAL (%08x) %s\n", MFATAL, (drvdbg & MFATAL) ? "X" : ""); printf("MMSG (%08x) %s\n", MMSG, (drvdbg & MMSG) ? "X" : ""); - } if (buffer) @@ -6944,19 +1224,24 @@ process_drvdbg(int argc, char *argv[]) } #endif +static char *rate_format[4] = {"LG", "HT", "VHT", "HE"}; +static char *lg_rate[] = {"1 Mbps", "2 Mbps", "5.5 Mbps", "11 Mbps", + "6 Mbps", "9 Mbps", "12 Mbps", "18 Mbps", + "24 Mbps", "36 Mbps", "48 Mbps", "54 Mbps"}; + /** - * @brief Process hscfg configuration + * @brief Process Get data rate * @param argc Number of arguments * @param argv A pointer to arguments array * @return MLAN_STATUS_SUCCESS--success, otherwise--fail */ -static int -process_hscfg(int argc, char *argv[]) +static int process_datarate(int argc, char *argv[]) { t_u8 *buffer = NULL; struct eth_priv_cmd *cmd = NULL; + struct eth_priv_data_rate *datarate = NULL; struct ifreq ifr; - struct eth_priv_hs_cfg *hscfg; + char *bw[] = {"20 MHz", "40 MHz", "80 MHz", "160 MHz"}; /* Initialize buffer */ buffer = (t_u8 *)malloc(BUFFER_LENGTH); @@ -6965,686 +1250,6 @@ process_hscfg(int argc, char *argv[]) return MLAN_STATUS_FAILURE; } - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: hscfg fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - hscfg = (struct eth_priv_hs_cfg *)buffer; - if (argc == 3) { - /* GET operation */ - printf("HS Configuration:\n"); - printf(" Conditions: %d\n", (int)hscfg->conditions); - printf(" GPIO: %d\n", (int)hscfg->gpio); - printf(" GAP: %d\n", (int)hscfg->gap); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process hssetpara configuration - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_hssetpara(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: hssetpara fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process wakeup reason - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_wakeupresaon(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: get wakeup reason fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - printf("Get wakeup reason response: %s\n", buffer); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process hscfg management frame config - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_mgmtfilter(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - FILE *fp = NULL; - int ret = MLAN_STATUS_SUCCESS; - char line[256], cmdname[256], *pos = NULL, *filter = NULL; - int cmdname_found = 0, name_found = 0; - int ln = 0, i = 0, numEntries = 0, len = 0; - eth_priv_mgmt_frame_wakeup hs_mgmt_filter[2]; - - if (argc < 4) { - printf("Error: invalid no of arguments\n"); - printf("Syntax: ./mlanutl mlanX mgmtfilter \n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - memset(&hs_mgmt_filter, 0, sizeof(hs_mgmt_filter)); - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - pos = (char *)buffer; - strncpy((char *)pos, CMD_NXP, strlen(CMD_NXP)); - pos += (strlen(CMD_NXP)); - len += (strlen(CMD_NXP)); - - /* Insert command */ - strncpy((char *)pos, argv[2], strlen(argv[2])); - pos += (strlen(argv[2])); - len += (strlen(argv[2])); - - filter = pos; - - cmdname_found = 0; - snprintf(cmdname, sizeof(cmdname), "%s={", argv[2]); - - fp = fopen(argv[3], "r"); - if (fp == NULL) { - fprintf(stderr, "Cannot open file %s\n", argv[3]); - ret = MLAN_STATUS_FAILURE; - if (buffer) - free(buffer); - goto done; - } - - while ((pos = mlan_config_get_line(fp, line, sizeof(line), &ln))) { - if (strcmp(pos, cmdname) == 0) { - cmdname_found = 1; - snprintf(cmdname, sizeof(cmdname), "entry_num="); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, sizeof(line), - &ln))) { - if (strncmp(pos, cmdname, strlen(cmdname)) == 0) { - name_found = 1; - numEntries = - a2hex_or_atoi(pos + - strlen(cmdname)); - if (numEntries > 2) { - printf("mlanutl: NumEntries exceed max number.\ - We support two entries in currently\n"); - free(buffer); - if (fp) - fclose(fp); - return MLAN_STATUS_FAILURE; - } - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanutl: NumEntries not found in file '%s'\n", - argv[3]); - break; - } - for (i = 0; i < numEntries; i++) { - snprintf(cmdname, sizeof(cmdname), "entry_%d={", - i); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, - sizeof(line), - &ln))) { - if (strncmp - (pos, cmdname, - strlen(cmdname)) == 0) { - name_found = 1; - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanutl: %s not found in file '%s'\n", - cmdname, argv[3]); - break; - } - snprintf(cmdname, sizeof(cmdname), "action="); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, - sizeof(line), - &ln))) { - if (strncmp - (pos, cmdname, - strlen(cmdname)) == 0) { - name_found = 1; - hs_mgmt_filter[i].action = - a2hex_or_atoi(pos + - strlen - (cmdname)); - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanutl: %s not found in file '%s'\n", - cmdname, argv[3]); - break; - } - snprintf(cmdname, sizeof(cmdname), "type="); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, - sizeof(line), - &ln))) { - if (strncmp - (pos, cmdname, - strlen(cmdname)) == 0) { - name_found = 1; - hs_mgmt_filter[i].type = - a2hex_or_atoi(pos + - strlen - (cmdname)); - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanutl: %s not found in file '%s'\n", - cmdname, argv[3]); - break; - } - snprintf(cmdname, sizeof(cmdname), - "frame_mask="); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, - sizeof(line), - &ln))) { - if (strncmp - (pos, cmdname, - strlen(cmdname)) == 0) { - name_found = 1; - hs_mgmt_filter[i].frame_mask = - a2hex_or_atoi(pos + - strlen - (cmdname)); - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanutl: %s not found in file '%s'\n", - cmdname, argv[3]); - break; - } - } - break; - } - } - fclose(fp); - if (!cmdname_found) { - fprintf(stderr, "mlanutl: ipPkt data not found in file '%s'\n", - argv[3]); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - memcpy(filter, (t_u8 *)hs_mgmt_filter, - sizeof(eth_priv_mgmt_frame_wakeup) * numEntries); - len += sizeof(eth_priv_mgmt_frame_wakeup) * numEntries; - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = len; - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: cloud keep alive fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - -done: - return ret; -} - -/** - * @brief Process scancfg configuration - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_scancfg(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - struct eth_priv_scan_cfg *scancfg; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: scancfg fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - scancfg = (struct eth_priv_scan_cfg *)buffer; - /* Show scan configure */ - printf("Scan Configuration:\n"); - printf(" Scan Type: %d (%s)\n", scancfg->scan_type, - (scancfg->scan_type == 1) ? "Active" : (scancfg->scan_type == - 2) ? "Passive" : ""); - printf(" Scan Mode: %d (%s)\n", scancfg->scan_mode, - (scancfg->scan_mode == 1) ? "BSS" : (scancfg->scan_mode == - 2) ? "IBSS" : (scancfg-> - scan_mode == - 3) ? "Any" : - ""); - printf(" Scan Probes: %d (%s)\n", scancfg->scan_probe, - "per channel"); - printf(" Specific Scan Time: %d ms\n", - scancfg->scan_time.specific_scan_time); - printf(" Active Scan Time: %d ms\n", - scancfg->scan_time.active_scan_time); - printf(" Passive Scan Time: %d ms\n", - scancfg->scan_time.passive_scan_time); - printf(" Passive to Active Scan: %d (%s)\n", - scancfg->passive_to_active_scan, - (scancfg->passive_to_active_scan == - MLAN_PASS_TO_ACT_SCAN_EN) ? "Enable" : (scancfg-> - passive_to_active_scan - == - MLAN_PASS_TO_ACT_SCAN_DIS) - ? "Disable" : ""); - printf(" Extended Scan Support: %d (%s)\n", scancfg->ext_scan, - (scancfg->ext_scan == 1) ? "No" : (scancfg->ext_scan == - 2) ? "Yes" : (scancfg-> - ext_scan == - 3) ? "Enhanced" - : ""); - printf(" Scan channel Gap: %d ms\n", scancfg->scan_chan_gap); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process packet aggregation configuration - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_aggrctrl(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - aggr_ctrl_params *param = NULL; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: usbaggrctrl failed.\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - if (argc == 3) { - /* GET operation */ - param = (aggr_ctrl_params *) buffer; - printf("TX Aggr Ctrl:\n"); - printf(" %s, Max = %d bytes, Max Pkt Num = %d, Align=%d Timeout = %d us\n", param->tx.enable ? "Enabled" : "Disabled", param->tx.aggr_max_size, param->tx.aggr_max_num, param->tx.aggr_align, param->tx.aggr_tmo); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process USB packet aggregation configuration - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_usbaggrctrl(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - aggr_params *param = NULL; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: usbaggrctrl failed.\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - if (argc == 3) { - /* GET operation */ - param = (aggr_params *)buffer; - printf("Tx aggregation:\n"); - printf(" %s, Max = %d %s, Alignment = %d bytes, Timeout = %d us\n", param->tx_aggr_ctrl.enable ? "Enabled" : "Disabled", param->tx_aggr_ctrl.aggr_max, (param->tx_aggr_ctrl.aggr_max < 512) ? "packets" : "bytes", param->tx_aggr_ctrl.aggr_align, param->tx_aggr_ctrl.aggr_tmo); - printf("Rx aggregation:\n"); - printf(" %s, Max = %d %s, Alignment = %d bytes, Timeout = %d us\n", param->rx_deaggr_ctrl.enable ? "Enabled" : "Disabled", param->rx_deaggr_ctrl.aggr_max, (param->rx_deaggr_ctrl.aggr_max < 512) ? "packets" : "bytes", param->rx_deaggr_ctrl.aggr_align, param->rx_deaggr_ctrl.aggr_tmo); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process warmreset command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_warmreset(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - /* The argument being a string, this requires special handling */ prepare_buffer(buffer, argv[2], 0, NULL); cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); @@ -7671,74 +1276,7 @@ process_warmreset(int argc, char *argv[]) if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { perror("mlanutl"); - fprintf(stderr, "mlanutl: warmreset fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -static char *bandwidth[4] = { "20 MHz", "40 MHz", "80 MHz", "160 MHz" }; - -/** - * @brief Process txpowercfg command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_txpowercfg(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - struct eth_priv_power_cfg_ext *power_ext = NULL; - struct eth_priv_power_group *power_group = NULL; - int i = 0; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(2 * BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = 2 * BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: txpowercfg fail\n"); + fprintf(stderr, "mlanutl: getdatarate fail\n"); if (cmd) free(cmd); if (buffer) @@ -7747,3656 +1285,100 @@ process_txpowercfg(int argc, char *argv[]) } /* Process result */ - power_ext = (struct eth_priv_power_cfg_ext *)buffer; - if (argc == 3) { - /* GET operation */ - printf("Tx Power Configurations:\n"); - for (i = 0; i < power_ext->num_pwr_grp; i++) { - power_group = &power_ext->power_group[i]; - if (power_group->rate_format == MLAN_RATE_FORMAT_HT) { - if (power_group->bandwidth == MLAN_HT_BW20) { - power_group->first_rate_ind += 12; - power_group->last_rate_ind += 12; - } else if (power_group->bandwidth == - MLAN_HT_BW40) { - power_group->first_rate_ind += 140; - power_group->last_rate_ind += 140; - } - } - printf(" Power Group %d: \n", i); - printf(" Bandwidth: %3s %s\n", - rate_format[power_group->rate_format], - bandwidth[power_group->bandwidth]); - if (power_group->rate_format == 2) - /** NSS */ - printf(" NSS: %3d\n", - power_group->nss); - printf(" first rate index: %3d\n", - power_group->first_rate_ind); - printf(" last rate index: %3d\n", - power_group->last_rate_ind); - printf(" minimum power: %3d dBm\n", - power_group->power_min); - printf(" maximum power: %3d dBm\n", - power_group->power_max); - printf(" power step: %3d\n", - power_group->power_step); - printf("\n"); - power_group++; - } - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process pscfg command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_pscfg(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - struct eth_priv_ds_ps_cfg *ps_cfg = NULL; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: pscfg fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - ps_cfg = (struct eth_priv_ds_ps_cfg *)buffer; - if (argc == 3) { - /* GET operation */ - printf("PS Configurations:\n"); - printf("%d", (int)ps_cfg->ps_null_interval); - printf(" %d", (int)ps_cfg->multiple_dtim_interval); - printf(" %d", (int)ps_cfg->listen_interval); - printf(" %d", (int)ps_cfg->bcn_miss_timeout); - printf(" %d", (int)ps_cfg->delay_to_ps); - printf(" %d", (int)ps_cfg->ps_mode); - printf("\n"); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process bcntimeoutcfg command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_bcntimeoutcfg(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - if (argc != 7) { - printf("ERR:Incorrect number of arguments.\n"); - printf("Syntax: ./mlanutl mlanX bcntimeoutcfg [l] [m] [o] [p]\n"); - return -EINVAL; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return -ENOMEM; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return -ENOMEM; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: bcntimeoutcfg fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return -EFAULT; - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return 0; -} - -/** - * @brief Process sleeppd configuration - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_sleeppd(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - int sleeppd = 0; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: sleeppd fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - sleeppd = *(int *)buffer; - if (argc == 3) { - /* GET operation */ - printf("Sleep Period: %d ms\n", sleeppd); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process tx control configuration - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_txcontrol(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - t_u32 txcontrol = 0; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: txcontrol fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - txcontrol = *(t_u32 *)buffer; - if (argc == 3) { - /* GET operation */ - printf("Tx control: 0x%x\n", txcontrol); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** custom IE, auto mask value */ -#define CUSTOM_IE_AUTO_MASK 0xffff - -/** - * @brief Show usage information for the customie - * command - * - * $return N/A - **/ -void -print_custom_ie_usage(void) -{ - printf("\nUsage : customie [INDEX] [MASK] [IEBuffer]"); - printf("\n empty - Get all IE settings\n"); - printf("\n INDEX: 0 - Get/Set IE index 0 setting"); - printf("\n 1 - Get/Set IE index 1 setting"); - printf("\n 2 - Get/Set IE index 2 setting"); - printf("\n 3 - Get/Set IE index 3 setting"); - printf("\n . "); - printf("\n . "); - printf("\n . "); - printf("\n -1 - Append/Delete IE automatically"); - printf("\n Delete will delete the IE from the matching IE buffer"); - printf("\n Append will append the IE to the buffer with the same mask"); - printf("\n MASK : Management subtype mask value as per bit defintions"); - printf("\n : Bit 0 - Association request."); - printf("\n : Bit 1 - Association response."); - printf("\n : Bit 2 - Reassociation request."); - printf("\n : Bit 3 - Reassociation response."); - printf("\n : Bit 4 - Probe request."); - printf("\n : Bit 5 - Probe response."); - printf("\n : Bit 8 - Beacon."); - printf("\n MASK : MASK = 0 to clear the mask and the IE buffer"); - printf("\n IEBuffer : IE Buffer in hex (max 256 bytes)\n\n"); - return; -} - -/** - * @brief Creates a hostcmd request for custom IE settings - * and sends to the driver - * - * Usage: "customie [INDEX] [MASK] [IEBuffer]" - * - * Options: INDEX : 0 - Get/Delete IE index 0 setting - * 1 - Get/Delete IE index 1 setting - * 2 - Get/Delete IE index 2 setting - * 3 - Get/Delete IE index 3 setting - * . - * . - * . - * -1 - Append IE at the IE buffer with same MASK - * MASK : Management subtype mask value - * IEBuffer: IE Buffer in hex - * empty - Get all IE settings - * - * @param argc Number of arguments - * @param argv Pointer to the arguments - * @return N/A - **/ -static int -process_customie(int argc, char *argv[]) -{ - eth_priv_ds_misc_custom_ie *tlv = NULL; - tlvbuf_max_mgmt_ie *max_mgmt_ie_tlv = NULL; - t_u16 mgmt_subtype_mask = 0; - custom_ie *ie_ptr = NULL; - int ie_buf_len = 0, ie_len = 0, i = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - int ret = MLAN_STATUS_SUCCESS; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - prepare_buffer(buffer, argv[2], 0, NULL); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* mlanutl mlan0 customie idx flag buf */ - if (argc > 6) { - printf("ERR:Too many arguments.\n"); - print_custom_ie_usage(); - ret = MLAN_STATUS_FAILURE; - goto done; - } - /* Error checks and initialize the command length */ - if (argc > 3) { - if (((IS_HEX_OR_DIGIT(argv[3]) == MLAN_STATUS_FAILURE) && - (atoi(argv[3]) != -1)) || (atoi(argv[3]) < -1)) { - printf("ERR:Illegal index %s\n", argv[3]); - print_custom_ie_usage(); - ret = MLAN_STATUS_FAILURE; - goto done; - } - } - switch (argc) { - case 3: - break; - case 4: - if (atoi(argv[3]) < 0) { - printf("ERR:Illegal index %s. Must be either greater than or equal to 0 for Get Operation \n", argv[3]); - print_custom_ie_usage(); - ret = MLAN_STATUS_FAILURE; - goto done; - } - break; - case 5: - if (MLAN_STATUS_FAILURE == ishexstring(argv[4]) || - A2HEXDECIMAL(argv[4]) != 0) { - printf("ERR: Mask value should be 0 to clear IEBuffers.\n"); - print_custom_ie_usage(); - ret = MLAN_STATUS_FAILURE; - goto done; - } - if (atoi(argv[3]) == -1) { - printf("ERR: You must provide buffer for automatic deletion.\n"); - print_custom_ie_usage(); - ret = MLAN_STATUS_FAILURE; - goto done; - } - break; - case 6: - /* This is to check negative numbers and special symbols */ - if (MLAN_STATUS_FAILURE == IS_HEX_OR_DIGIT(argv[4])) { - printf("ERR:Mask value must be 0 or hex digits\n"); - print_custom_ie_usage(); - ret = MLAN_STATUS_FAILURE; - goto done; - } - /* If above check is passed and mask is not hex, then it must be 0 */ - if ((ISDIGIT(argv[4]) == MLAN_STATUS_SUCCESS) && atoi(argv[4])) { - printf("ERR:Mask value must be 0 or hex digits\n "); - print_custom_ie_usage(); - ret = MLAN_STATUS_FAILURE; - goto done; - } - if (MLAN_STATUS_FAILURE == ishexstring(argv[5])) { - printf("ERR:Only hex digits are allowed\n"); - print_custom_ie_usage(); - ret = MLAN_STATUS_FAILURE; - goto done; - } - ie_buf_len = strlen(argv[5]); - if (!strncasecmp("0x", argv[5], 2)) { - ie_len = (ie_buf_len - 2 + 1) / 2; - argv[5] += 2; - } else - ie_len = (ie_buf_len + 1) / 2; - if (ie_len > MAX_IE_BUFFER_LEN) { - printf("ERR:Incorrect IE length %d\n", ie_buf_len); - print_custom_ie_usage(); - ret = MLAN_STATUS_FAILURE; - goto done; - } - mgmt_subtype_mask = (t_u16)A2HEXDECIMAL(argv[4]); - break; - } - /* Initialize the command buffer */ - tlv = (eth_priv_ds_misc_custom_ie *)(buffer + strlen(CMD_NXP) + - strlen(argv[2])); - - if (tlv == NULL) { - ret = MLAN_STATUS_FAILURE; - goto done; - } - - tlv->type = MRVL_MGMT_IE_LIST_TLV_ID; - if (argc == 3 || argc == 4) { - if (argc == 3) - tlv->len = 0; + datarate = (struct eth_priv_data_rate *)buffer; + printf("Data Rate:\n"); + printf(" TX: \n"); + if (datarate->tx_rate_format <= 3) { + printf(" Type: %s\n", rate_format[datarate->tx_rate_format]); + if ((datarate->tx_rate_format == 0) && + datarate->tx_data_rate <= 11) + /* LG */ + printf(" Rate: %s\n", + lg_rate[datarate->tx_data_rate]); else { - tlv->len = sizeof(t_u16); - ie_ptr = (custom_ie *)(tlv->ie_data); - ie_ptr->ie_index = (t_u16)(atoi(argv[3])); - } - } else { - /* Locate headers */ - ie_ptr = (custom_ie *)(tlv->ie_data); - /* Set TLV fields */ - tlv->len = sizeof(custom_ie) + ie_len; - ie_ptr->ie_index = atoi(argv[3]); - ie_ptr->mgmt_subtype_mask = mgmt_subtype_mask; - ie_ptr->ie_length = ie_len; - if (argc == 6) - string2raw(argv[5], ie_ptr->ie_buffer); - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[CUSTOM_IE_CFG]"); - printf("ERR:Command sending failed!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - /* Print response */ - if (argc > 4) { - printf("Custom IE setting successful\n"); - } else { - printf("Querying custom IE successful\n"); - ie_len = tlv->len; - ie_ptr = (custom_ie *)(tlv->ie_data); - while (ie_len >= (int)sizeof(custom_ie)) { - printf("Index [%d]\n", ie_ptr->ie_index); - if (ie_ptr->ie_length) - printf("Management Subtype Mask = 0x%02x\n", - (ie_ptr->mgmt_subtype_mask) == 0 ? - CUSTOM_IE_AUTO_MASK : - (ie_ptr->mgmt_subtype_mask)); - else - printf("Management Subtype Mask = 0x%02x\n", - (ie_ptr->mgmt_subtype_mask)); - hexdump("IE Buffer", (void *)ie_ptr->ie_buffer, - ie_ptr->ie_length, ' '); - ie_len -= sizeof(custom_ie) + ie_ptr->ie_length; - ie_ptr = (custom_ie *)((t_u8 *)ie_ptr + - sizeof(custom_ie) + - ie_ptr->ie_length); - } - } - max_mgmt_ie_tlv = (tlvbuf_max_mgmt_ie *)((t_u8 *)tlv + - sizeof - (eth_priv_ds_misc_custom_ie) + - tlv->len); - if (max_mgmt_ie_tlv) { - if (max_mgmt_ie_tlv->type == MRVL_MAX_MGMT_IE_TLV_ID) { - for (i = 0; i < max_mgmt_ie_tlv->count; i++) { - printf("buf%d_size = %d\n", i, - max_mgmt_ie_tlv->info[i].buf_size); - printf("number of buffers = %d\n", - max_mgmt_ie_tlv->info[i].buf_count); - printf("\n"); - } - } - } - - ret = MLAN_STATUS_SUCCESS; - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Process regrdwr command - * - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_regrdwr(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - struct eth_priv_ds_reg_rw *reg = NULL; - - if (argc < 5 || argc > 6) { - printf("Error: invalid no of arguments\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: regrdwr fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - reg = (struct eth_priv_ds_reg_rw *)buffer; - if (argc == 5) { - /* GET operation */ - printf("Value = 0x%x\n", reg->value); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process rdeeprom command - * - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_rdeeprom(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - struct eth_priv_ds_read_eeprom *eeprom = NULL; - int i = 0; - - if (argc != 5) { - printf("Error: invalid no of arguments\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: rdeeprom fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - eeprom = (struct eth_priv_ds_read_eeprom *)buffer; - if (argc == 5) { - /* GET operation */ - printf("Value:\n"); - for (i = 0; i < MIN(MAX_EEPROM_DATA, eeprom->byte_count); i++) - printf(" %02x", eeprom->value[i]); - printf("\n"); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process memrdwr command - * - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_memrdwr(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - struct eth_priv_ds_mem_rw *mem = NULL; - - if (argc < 4 || argc > 5) { - printf("Error: invalid no of arguments\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: memrdwr fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - mem = (struct eth_priv_ds_mem_rw *)buffer; - if (argc == 4) { - /* GET operation */ - printf("Value = 0x%x\n", mem->value); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -#ifdef SDIO -/** - * @brief Process sdcmd52rw command - * - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_sdcmd52rw(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - if (argc < 5 || argc > 6) { - printf("Error: invalid no of arguments\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: sdcmd52rw fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - if (argc == 5) { - /* GET operation */ - printf("Value = 0x%x\n", (int)(*buffer)); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} -#endif /* SDIO */ - -#define STACK_NBYTES 100 /**< Number of bytes in stack */ -#define MAX_BYTESEQ 6 /**< Maximum byte sequence */ -#define TYPE_DNUM 1 /**< decimal number */ -#define TYPE_BYTESEQ 2 /**< byte sequence */ -#define MAX_OPERAND 0x40 /**< Maximum operands */ -#define TYPE_EQ (MAX_OPERAND+1) /**< byte comparison: == operator */ -#define TYPE_EQ_DNUM (MAX_OPERAND+2) /**< decimal comparison: =d operator */ -#define TYPE_EQ_BIT (MAX_OPERAND+3) /**< bit comparison: =b operator */ -#define TYPE_AND (MAX_OPERAND+4) /**< && operator */ -#define TYPE_OR (MAX_OPERAND+5) /**< || operator */ - -typedef struct { - t_u16 sp; /**< Stack pointer */ - t_u8 byte[STACK_NBYTES]; /**< Stack */ -} mstack_t; - -typedef struct { - t_u8 type; /**< Type */ - t_u8 reserve[3]; /**< so 4-byte align val array */ - /* byte sequence is the largest among all the operands and operators. */ - /* byte sequence format: 1 byte of num of bytes, then variable num bytes */ - t_u8 val[MAX_BYTESEQ + 1];/**< Value */ -} op_t; - -/** - * @brief push data to stack - * - * @param s a pointer to mstack_t structure - * - * @param nbytes number of byte to push to stack - * - * @param val a pointer to data buffer - * - * @return TRUE-- sucess , FALSE -- fail - * - */ -static int -push_n(mstack_t * s, t_u8 nbytes, t_u8 *val) -{ - if ((s->sp + nbytes) < STACK_NBYTES) { - memcpy((void *)(s->byte + s->sp), (const void *)val, - (size_t) nbytes); - s->sp += nbytes; - /* printf("push: n %d sp %d\n", nbytes, s->sp); */ - return TRUE; - } else /* stack full */ - return FALSE; -} - -/** - * @brief push data to stack - * - * @param s a pointer to mstack_t structure - * - * @param op a pointer to op_t structure - * - * @return TRUE-- sucess , FALSE -- fail - * - */ -static int -push(mstack_t * s, op_t * op) -{ - t_u8 nbytes; - switch (op->type) { - case TYPE_DNUM: - if (push_n(s, 4, op->val)) - return push_n(s, 1, &op->type); - return FALSE; - case TYPE_BYTESEQ: - nbytes = op->val[0]; - if (push_n(s, nbytes, op->val + 1) && - push_n(s, 1, op->val) && push_n(s, 1, &op->type)) - return TRUE; - return FALSE; - default: - return push_n(s, 1, &op->type); - } -} - -/** - * @brief parse RPN string - * - * @param s a pointer to Null-terminated string to scan. - * - * @param first_time a pointer to return first_time - * - * @return A pointer to the last token found in string. - * NULL is returned when there are no more tokens to be found. - * - */ -static char * -getop(char *s, int *first_time) -{ - const char delim[] = " \t\n"; - char *p; - if (*first_time) { - p = strtok(s, delim); - *first_time = FALSE; - } else { - p = strtok(NULL, delim); - } - return p; -} - -/** - * @brief Verify hex digit. - * - * @param c input ascii char - * @param h a pointer to return integer value of the digit char. - * @return TURE -- c is hex digit, FALSE -- c is not hex digit. - */ -static int -ishexdigit(char c, t_u8 *h) -{ - if (c >= '0' && c <= '9') { - *h = c - '0'; - return TRUE; - } else if (c >= 'a' && c <= 'f') { - *h = c - 'a' + 10; - return TRUE; - } else if (c >= 'A' && c <= 'F') { - *h = c - 'A' + 10; - return TRUE; - } - return FALSE; -} - -/** - * @brief convert hex string to integer. - * - * @param s A pointer to hex string, string length up to 2 digits. - * @return integer value. - */ -static t_u8 -hex_atoi(char *s) -{ - int i; - t_u8 digit; /* digital value */ - t_u8 t = 0; /* total value */ - - for (i = 0, t = 0; ishexdigit(s[i], &digit) && i < 2; i++) - t = 16 * t + digit; - return t; -} - -/** - * @brief Parse byte sequence in hex format string to a byte sequence. - * - * @param opstr A pointer to byte sequence in hex format string, with ':' as delimiter between two byte. - * @param val A pointer to return byte sequence string - * @return NA - */ -static void -parse_hex(char *opstr, t_u8 *val) -{ - char delim = ':'; - char *p; - char *q; - t_u8 i; - - /* +1 is for skipping over the preceding h character. */ - p = opstr + 1; - - /* First byte */ - val[1] = hex_atoi(p++); - - /* Parse subsequent bytes. */ - /* Each byte is preceded by the : character. */ - for (i = 1; *p; i++) { - q = strchr(p, delim); - if (!q) - break; - p = q + 1; - val[i + 1] = hex_atoi(p); - } - /* Set num of bytes */ - val[0] = i; -} - -/** - * @brief str2bin, convert RPN string to binary format - * - * @param str A pointer to rpn string - * @param stack A pointer to mstack_t structure - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -str2bin(char *str, mstack_t * stack) -{ - int first_time; - char *opstr; - op_t op; /* operator/operand */ - int dnum; - int ret = MLAN_STATUS_SUCCESS; - - memset(stack, 0, sizeof(mstack_t)); - first_time = TRUE; - while ((opstr = getop(str, &first_time)) != NULL) { - if (isdigit(*opstr)) { - op.type = TYPE_DNUM; - dnum = cpu_to_le32(atoi(opstr)); - memcpy((t_u8 *)op.val, &dnum, sizeof(dnum)); - if (!push(stack, &op)) { - printf("push decimal number failed\n"); - ret = MLAN_STATUS_FAILURE; - break; - } - } else if (*opstr == 'h') { - op.type = TYPE_BYTESEQ; - parse_hex(opstr, op.val); - if (!push(stack, &op)) { - printf("push byte sequence failed\n"); - ret = MLAN_STATUS_FAILURE; - break; - } - } else if (!strcmp(opstr, "==")) { - op.type = TYPE_EQ; - if (!push(stack, &op)) { - printf("push byte cmp operator failed\n"); - ret = MLAN_STATUS_FAILURE; - break; - } - } else if (!strcmp(opstr, "=d")) { - op.type = TYPE_EQ_DNUM; - if (!push(stack, &op)) { - printf("push decimal cmp operator failed\n"); - ret = MLAN_STATUS_FAILURE; - break; - } - } else if (!strcmp(opstr, "=b")) { - op.type = TYPE_EQ_BIT; - if (!push(stack, &op)) { - printf("push bit cmp operator failed\n"); - ret = MLAN_STATUS_FAILURE; - break; - } - } else if (!strcmp(opstr, "&&")) { - op.type = TYPE_AND; - if (!push(stack, &op)) { - printf("push AND operator failed\n"); - ret = MLAN_STATUS_FAILURE; - break; - } - } else if (!strcmp(opstr, "||")) { - op.type = TYPE_OR; - if (!push(stack, &op)) { - printf("push OR operator failed\n"); - ret = MLAN_STATUS_FAILURE; - break; - } - } else { - printf("Unknown operand\n"); - ret = MLAN_STATUS_FAILURE; - break; - } - } - return ret; -} - -#define FILTER_BYTESEQ TYPE_EQ /**< byte sequence */ -#define FILTER_DNUM TYPE_EQ_DNUM /**< decimal number */ -#define FILTER_BITSEQ TYPE_EQ_BIT /**< bit sequence */ -#define FILTER_TEST (FILTER_BITSEQ+1) /**< test */ - -#define NAME_TYPE 1 /**< Field name 'type' */ -#define NAME_PATTERN 2 /**< Field name 'pattern' */ -#define NAME_OFFSET 3 /**< Field name 'offset' */ -#define NAME_NUMBYTE 4 /**< Field name 'numbyte' */ -#define NAME_REPEAT 5 /**< Field name 'repeat' */ -#define NAME_BYTE 6 /**< Field name 'byte' */ -#define NAME_MASK 7 /**< Field name 'mask' */ -#define NAME_DEST 8 /**< Field name 'dest' */ - -static struct mef_fields { - char *name; - /**< Name */ - t_s8 nameid; - /**< Name Id. */ -} mef_fields[] = { - { - "type", NAME_TYPE}, { - "pattern", NAME_PATTERN}, { - "offset", NAME_OFFSET}, { - "numbyte", NAME_NUMBYTE}, { - "repeat", NAME_REPEAT}, { - "byte", NAME_BYTE}, { - "mask", NAME_MASK}, { - "dest", NAME_DEST} -}; - -/** - * @brief get filter data - * - * @param fp A pointer to file stream - * @param ln A pointer to line number - * @param buf A pointer to hostcmd data - * @param size A pointer to the return size of hostcmd buffer - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -mlan_get_filter_data(FILE * fp, int *ln, t_u8 *buf, t_u16 *size) -{ - t_s32 errors = 0, i; - char line[256], *pos = NULL, *pos1 = NULL; - t_u16 type = 0; - t_u32 pattern = 0; - t_u16 repeat = 0; - t_u16 offset = 0; - char byte_seq[50]; - char mask_seq[50]; - t_u16 numbyte = 0; - t_s8 type_find = 0; - t_s8 pattern_find = 0; - t_s8 offset_find = 0; - t_s8 numbyte_find = 0; - t_s8 repeat_find = 0; - t_s8 byte_find = 0; - t_s8 mask_find = 0; - t_s8 dest_find = 0; - char dest_seq[50]; - - *size = 0; - while ((pos = mlan_config_get_line(fp, line, sizeof(line), ln))) { - if (strcmp(pos, "}") == 0) { - break; - } - pos1 = strchr(pos, '='); - if (pos1 == NULL) { - printf("Line %d: Invalid mef_filter line '%s'\n", *ln, - pos); - errors++; - continue; - } - *pos1++ = '\0'; - for (i = 0; (t_u32)i < NELEMENTS(mef_fields); i++) { - if (strncmp - (pos, mef_fields[i].name, - strlen(mef_fields[i].name)) == 0) { - switch (mef_fields[i].nameid) { - case NAME_TYPE: - type = a2hex_or_atoi(pos1); - if ((type != FILTER_DNUM) && - (type != FILTER_BYTESEQ) - && (type != FILTER_BITSEQ) && - (type != FILTER_TEST)) { - printf("Invalid filter type:%d\n", type); - return MLAN_STATUS_FAILURE; - } - type_find = 1; - break; - case NAME_PATTERN: - pattern = a2hex_or_atoi(pos1); - pattern_find = 1; - break; - case NAME_OFFSET: - offset = a2hex_or_atoi(pos1); - offset_find = 1; - break; - case NAME_NUMBYTE: - numbyte = a2hex_or_atoi(pos1); - numbyte_find = 1; - break; - case NAME_REPEAT: - repeat = a2hex_or_atoi(pos1); - repeat_find = 1; - break; - case NAME_BYTE: - memset(byte_seq, 0, sizeof(byte_seq)); - strncpy(byte_seq, pos1, - (sizeof(byte_seq) - 1)); - byte_find = 1; - break; - case NAME_MASK: - memset(mask_seq, 0, sizeof(mask_seq)); - strncpy(mask_seq, pos1, - (sizeof(mask_seq) - 1)); - mask_find = 1; - break; - case NAME_DEST: - memset(dest_seq, 0, sizeof(dest_seq)); - strncpy(dest_seq, pos1, - (sizeof(dest_seq) - 1)); - dest_find = 1; - break; - } - break; - } - } - if (i == NELEMENTS(mef_fields)) { - printf("Line %d: unknown mef field '%s'.\n", - *line, pos); - errors++; - } - } - if (type_find == 0) { - printf("Can not find filter type\n"); - return MLAN_STATUS_FAILURE; - } - switch (type) { - case FILTER_DNUM: - if (!pattern_find || !offset_find || !numbyte_find) { - printf("Missing field for FILTER_DNUM: pattern=%d,offset=%d,numbyte=%d\n", pattern_find, offset_find, numbyte_find); - return MLAN_STATUS_FAILURE; - } - memset(line, 0, sizeof(line)); - snprintf(line, sizeof(line), "%d %d %d =d ", pattern, offset, - numbyte); - break; - case FILTER_BYTESEQ: - if (!byte_find || !offset_find || !repeat_find) { - printf("Missing field for FILTER_BYTESEQ: byte=%d,offset=%d,repeat=%d\n", byte_find, offset_find, repeat_find); - return MLAN_STATUS_FAILURE; - } - memset(line, 0, sizeof(line)); - snprintf(line, sizeof(line), "%d h%s %d == ", repeat, byte_seq, - offset); - break; - case FILTER_BITSEQ: - if (!byte_find || !offset_find || !mask_find) { - printf("Missing field for FILTER_BITSEQ: byte=%d,offset=%d,mask_find=%d\n", byte_find, offset_find, mask_find); - return MLAN_STATUS_FAILURE; - } - if (strlen(byte_seq) != strlen(mask_seq)) { - printf("byte string's length is different with mask's length!\n"); - return MLAN_STATUS_FAILURE; - } - memset(line, 0, sizeof(line)); - snprintf(line, sizeof(line), "h%s %d h%s =b ", byte_seq, offset, - mask_seq); - break; - case FILTER_TEST: - if (!byte_find || !offset_find || !repeat_find || !dest_find) { - printf("Missing field for FILTER_TEST: byte=%d,offset=%d,repeat=%d,dest=%d\n", byte_find, offset_find, repeat_find, dest_find); - return MLAN_STATUS_FAILURE; - } - memset(line, 0, sizeof(line)); - snprintf(line, sizeof(line), "h%s %d h%s %d ", dest_seq, repeat, - byte_seq, offset); - break; - } - memcpy(buf, line, strlen(line)); - *size = strlen(line); - return MLAN_STATUS_SUCCESS; -} - -#define NAME_MODE 1 /**< Field name 'mode' */ -#define NAME_ACTION 2 /**< Field name 'action' */ -#define NAME_FILTER_NUM 3 /**< Field name 'filter_num' */ -#define NAME_RPN 4 /**< Field name 'RPN' */ -static struct mef_entry_fields { - char *name; - /**< Name */ - t_s8 nameid; - /**< Name id */ -} mef_entry_fields[] = { - { - "mode", NAME_MODE}, { - "action", NAME_ACTION}, { - "filter_num", NAME_FILTER_NUM}, { -"RPN", NAME_RPN},}; - -typedef struct _MEF_ENTRY { - /** Mode */ - t_u8 Mode; - /** Size */ - t_u8 Action; - /** Size of expression */ - t_u16 ExprSize; -} MEF_ENTRY; - -/** - * @brief get mef_entry data - * - * @param fp A pointer to file stream - * @param ln A pointer to line number - * @param buf A pointer to hostcmd data - * @param size A pointer to the return size of hostcmd buffer - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -mlan_get_mef_entry_data(FILE * fp, int *ln, t_u8 *buf, t_u16 *size) -{ - char line[256], *pos = NULL, *pos1 = NULL; - t_u8 mode, action, filter_num = 0; - char rpn[256]; - t_s8 mode_find = 0; - t_s8 action_find = 0; - t_s8 filter_num_find = 0; - t_s8 rpn_find = 0; - char rpn_str[256]; - int rpn_len = 0; - char filter_name[50]; - t_s8 name_found = 0; - t_u16 len = 0; - int i; - int first_time = TRUE; - char *opstr = NULL; - char filter_action[10]; - t_s32 errors = 0; - MEF_ENTRY *pMefEntry = (MEF_ENTRY *) buf; - mstack_t stack; - while ((pos = mlan_config_get_line(fp, line, sizeof(line), ln))) { - if (strcmp(pos, "}") == 0) { - break; - } - pos1 = strchr(pos, '='); - if (pos1 == NULL) { - printf("Line %d: Invalid mef_entry line '%s'\n", *ln, - pos); - errors++; - continue; - } - *pos1++ = '\0'; - if (!mode_find || !action_find || !filter_num_find || !rpn_find) { - for (i = 0; - (unsigned int)i < NELEMENTS(mef_entry_fields); - i++) { - if (strncmp - (pos, mef_entry_fields[i].name, - strlen(mef_entry_fields[i].name)) == 0) { - switch (mef_entry_fields[i].nameid) { - case NAME_MODE: - mode = a2hex_or_atoi(pos1); - if (mode & ~0x7) { - printf("invalid mode=%d\n", mode); - return MLAN_STATUS_FAILURE; - } - pMefEntry->Mode = mode; - mode_find = 1; - break; - case NAME_ACTION: - action = a2hex_or_atoi(pos1); - if (action & ~0xff) { - printf("invalid action=%d\n", action); - return MLAN_STATUS_FAILURE; - } - pMefEntry->Action = action; - action_find = 1; - break; - case NAME_FILTER_NUM: - filter_num = - a2hex_or_atoi(pos1); - filter_num_find = 1; - break; - case NAME_RPN: - memset(rpn, 0, sizeof(rpn)); - strncpy(rpn, pos1, - (sizeof(rpn) - 1)); - rpn_find = 1; - break; - } - break; - } - } - if (i == NELEMENTS(mef_fields)) { - printf("Line %d: unknown mef_entry field '%s'.\n", *line, pos); - return MLAN_STATUS_FAILURE; - } - } - if (mode_find && action_find && filter_num_find && rpn_find) { - for (i = 0; i < filter_num; i++) { - opstr = getop(rpn, &first_time); - if (opstr == NULL) - break; - snprintf(filter_name, sizeof(filter_name), - "%s={", opstr); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, - sizeof(line), - ln))) { - if (strncmp - (pos, filter_name, - strlen(filter_name)) == 0) { - name_found = 1; - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanutl: %s not found in file\n", - filter_name); - return MLAN_STATUS_FAILURE; - } - if (MLAN_STATUS_FAILURE == - mlan_get_filter_data(fp, ln, - (t_u8 *)(rpn_str + - rpn_len), - &len)) - break; - rpn_len += len; - if (i > 0) { - memcpy(rpn_str + rpn_len, filter_action, - strlen(filter_action)); - rpn_len += strlen(filter_action); - } - opstr = getop(rpn, &first_time); - if (opstr == NULL) - break; - memset(filter_action, 0, sizeof(filter_action)); - snprintf(filter_action, sizeof(filter_action), - "%s ", opstr); - } - /* Remove the last space */ - if (rpn_len > 0) { - rpn_len--; - rpn_str[rpn_len] = 0; - } - if (MLAN_STATUS_FAILURE == str2bin(rpn_str, &stack)) { - printf("Fail on str2bin!\n"); - return MLAN_STATUS_FAILURE; - } - *size = sizeof(MEF_ENTRY); - pMefEntry->ExprSize = cpu_to_le16(stack.sp); - memmove(buf + sizeof(MEF_ENTRY), stack.byte, stack.sp); - *size += stack.sp; - break; - } else if (mode_find && action_find && filter_num_find && - (filter_num == 0)) { - pMefEntry->ExprSize = 0; - *size = sizeof(MEF_ENTRY); - break; - } - } - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process cloud keep alive command - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_cloud_keep_alive(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - FILE *fp = NULL; - int ret = MLAN_STATUS_SUCCESS; - char line[256], cmdname[256], *pos = NULL; - int cmdname_found = 0, name_found = 0, arg_num = 0; - int ln = 0, i = 0; - char *args[256]; - cloud_keep_alive *keep_alive = NULL; - - if (argc < 5) { - printf("Error: invalid no of arguments\n"); - printf("Syntax: ./mlanutl mlanX cloud_keep_alive \n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Insert command */ - strncpy((char *)buffer, argv[2], strlen(argv[2])); - - keep_alive = (cloud_keep_alive *) (buffer + strlen(argv[2])); - - cmdname_found = 0; - snprintf(cmdname, sizeof(cmdname), "%s={", argv[4]); - - fp = fopen(argv[3], "r"); - if (fp == NULL) { - fprintf(stderr, "Cannot open file %s\n", argv[3]); - ret = MLAN_STATUS_FAILURE; - if (buffer) - free(buffer); - goto done; - } - - while ((pos = mlan_config_get_line(fp, line, sizeof(line), &ln))) { - if (strcmp(pos, cmdname) == 0) { - cmdname_found = 1; - snprintf(cmdname, sizeof(cmdname), "mkeep_alive_id="); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, sizeof(line), - &ln))) { - if (strncmp(pos, cmdname, strlen(cmdname)) == 0) { - name_found = 1; - keep_alive->mkeep_alive_id = - a2hex_or_atoi(pos + - strlen(cmdname)); - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanutl: keep alive id not found in file '%s'\n", - argv[3]); - break; - } - snprintf(cmdname, sizeof(cmdname), "enable="); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, sizeof(line), - &ln))) { - if (strncmp(pos, cmdname, strlen(cmdname)) == 0) { - name_found = 1; - keep_alive->enable = - a2hex_or_atoi(pos + - strlen(cmdname)); - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanutl: enable not found in file '%s'\n", - argv[3]); - break; - } - if (strcmp(argv[4], "reset") == 0) { - snprintf(cmdname, sizeof(cmdname), "reset="); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, - sizeof(line), - &ln))) { - if (strncmp - (pos, cmdname, - strlen(cmdname)) == 0) { - name_found = 1; - keep_alive->reset = - a2hex_or_atoi(pos + - strlen - (cmdname)); - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanutl: reset not found in file '%s'\n", - argv[3]); - break; - } - } - if (strcmp(argv[4], "start") == 0) { - snprintf(cmdname, sizeof(cmdname), - "sendInterval="); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, - sizeof(line), - &ln))) { - if (strncmp - (pos, cmdname, - strlen(cmdname)) == 0) { - name_found = 1; - keep_alive->sendInterval = - a2hex_or_atoi(pos + - strlen - (cmdname)); - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanutl: sendInterval not found in file '%s'\n", - argv[3]); - break; - } - snprintf(cmdname, sizeof(cmdname), - "retryInterval="); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, - sizeof(line), - &ln))) { - if (strncmp - (pos, cmdname, - strlen(cmdname)) == 0) { - name_found = 1; - keep_alive->retryInterval = - a2hex_or_atoi(pos + - strlen - (cmdname)); - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanutl: retryInterval not found in file '%s'\n", - argv[3]); - break; - } - snprintf(cmdname, sizeof(cmdname), - "retryCount="); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, - sizeof(line), - &ln))) { - if (strncmp - (pos, cmdname, - strlen(cmdname)) == 0) { - name_found = 1; - keep_alive->retryCount = - a2hex_or_atoi(pos + - strlen - (cmdname)); - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanutl: retryCount not found in file '%s'\n", - argv[3]); - break; - } - snprintf(cmdname, sizeof(cmdname), - "destMacAddr="); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, - sizeof(line), - &ln))) { - if (strncmp - (pos, cmdname, - strlen(cmdname)) == 0) { - name_found = 1; - mac2raw(pos + strlen(cmdname), - keep_alive->dst_mac); - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanutl: destination MAC address not found in file '%s'\n", - argv[3]); - break; - } - snprintf(cmdname, sizeof(cmdname), - "srcMacAddr="); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, - sizeof(line), - &ln))) { - if (strncmp - (pos, cmdname, - strlen(cmdname)) == 0) { - name_found = 1; - mac2raw(pos + strlen(cmdname), - keep_alive->src_mac); - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanutl: source MAC address not found in file '%s'\n", - argv[3]); - break; - } - snprintf(cmdname, sizeof(cmdname), "pktLen="); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, - sizeof(line), - &ln))) { - if (strncmp - (pos, cmdname, - strlen(cmdname)) == 0) { - name_found = 1; - keep_alive->pkt_len = - a2hex_or_atoi(pos + - strlen - (cmdname)); - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanutl: ip packet length not found in file '%s'\n", - argv[3]); - break; - } - snprintf(cmdname, sizeof(cmdname), "ipPkt="); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, - sizeof(line), - &ln))) { - if (strncmp - (pos, cmdname, - strlen(cmdname)) == 0) { - name_found = 1; - arg_num = - parse_line(line, args, - 256); - if (arg_num < - keep_alive->pkt_len) { - fprintf(stderr, - "Invalid ipPkt or pkt_len in '%s'\n", - argv[3]); - break; - } - for (i = 0; - i < keep_alive->pkt_len; - i++) - keep_alive->pkt[i] = - (t_u8) - atoval(args - [i + 1]); - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanutl: ipPkt data not found in file '%s'\n", - argv[3]); - break; - } - } - } - } - if (!cmdname_found) { - fprintf(stderr, "mlanutl: ipPkt data not found in file '%s'\n", - argv[3]); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: cloud keep alive fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - /* Process result */ - keep_alive = (cloud_keep_alive *) (buffer + strlen(argv[2])); - if (strcmp(argv[4], "start") != 0) { - hexdump("Last cloud keep alive packet info", keep_alive->pkt, - keep_alive->pkt_len, ' '); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - -done: - return ret; -} - -/** - * @brief Process enable/disable DFS offload - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_dfs_offload_enable(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Check arguments */ - if (argc < 3 || argc > 4) { - printf("ERR:Incorrect number of arguments!\n"); - printf("Syntax: ./mlanutl mlanX dfs_offload <0/1>\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: dfs offload enable/disable fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -#define MEFCFG_CMDCODE 0x009a - -/** - * @brief Process mefcfg command - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_mefcfg(int argc, char *argv[]) -{ - char line[256], cmdname[256], *pos = NULL; - int cmdname_found = 0, name_found = 0; - int ln = 0; - int ret = MLAN_STATUS_SUCCESS; - int i; - t_u8 *buffer = NULL; - t_u16 len = 0; - HostCmd_DS_MEF_CFG *mefcmd = NULL; - HostCmd_DS_GEN *hostcmd = NULL; - FILE *fp = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - if (argc < 4) { - printf("Error: invalid no of arguments\n"); - printf("Syntax: ./mlanutl mlan0 mefcfg \n"); - exit(1); - } - - cmd_header_len = strlen(CMD_NXP) + strlen("HOSTCMD"); - cmd_len = sizeof(HostCmd_DS_GEN) + sizeof(HostCmd_DS_MEF_CFG); - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - exit(1); - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - /* buf = MRVL_CMD */ - prepare_buffer(buffer, HOSTCMD, 0, NULL); - - /* buf = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - hostcmd->command = cpu_to_le16(MEFCFG_CMDCODE); - hostcmd->seq_num = 0; - hostcmd->result = 0; - /* buf = MRVL_CMD */ - mefcmd = (HostCmd_DS_MEF_CFG *)(buffer + cmd_header_len + - sizeof(t_u32) + S_DS_GEN); - -/* Host Command Population */ - snprintf(cmdname, sizeof(cmdname), "%s={", argv[2]); - cmdname_found = 0; - fp = fopen(argv[3], "r"); - if (fp == NULL) { - fprintf(stderr, "Cannot open file %s\n", argv[4]); - exit(1); - } - - while ((pos = mlan_config_get_line(fp, line, sizeof(line), &ln))) { - if (strcmp(pos, cmdname) == 0) { - cmdname_found = 1; - snprintf(cmdname, sizeof(cmdname), "Criteria="); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, sizeof(line), - &ln))) { - if (strncmp(pos, cmdname, strlen(cmdname)) == 0) { - name_found = 1; - mefcmd->Criteria = - a2hex_or_atoi(pos + - strlen(cmdname)); - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanutl: criteria not found in file '%s'\n", - argv[3]); - break; - } - snprintf(cmdname, sizeof(cmdname), "NumEntries="); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, sizeof(line), - &ln))) { - if (strncmp(pos, cmdname, strlen(cmdname)) == 0) { - name_found = 1; - mefcmd->NumEntries = - a2hex_or_atoi(pos + - strlen(cmdname)); - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanutl: NumEntries not found in file '%s'\n", - argv[3]); - break; - } - for (i = 0; i < mefcmd->NumEntries; i++) { - snprintf(cmdname, sizeof(cmdname), - "mef_entry_%d={", i); - name_found = 0; - while ((pos = - mlan_config_get_line(fp, line, - sizeof(line), - &ln))) { - if (strncmp - (pos, cmdname, - strlen(cmdname)) == 0) { - name_found = 1; - break; - } - } - if (!name_found) { - fprintf(stderr, - "mlanutl: %s not found in file '%s'\n", - cmdname, argv[3]); - break; - } - if (MLAN_STATUS_FAILURE == - mlan_get_mef_entry_data(fp, &ln, - (t_u8 *)hostcmd + - cmd_len, &len)) { - ret = MLAN_STATUS_FAILURE; - break; - } - cmd_len += len; - } - break; - } - } - fclose(fp); - /* buf = MRVL_CMD */ - memcpy(buffer + cmd_header_len, (t_u8 *)&cmd_len, sizeof(t_u32)); - - if (!cmdname_found) - fprintf(stderr, - "mlanutl: cmdname '%s' not found in file '%s'\n", - argv[4], argv[3]); - - if (!cmdname_found || !name_found) { - ret = MLAN_STATUS_FAILURE; - goto mef_exit; - } - hostcmd->size = cpu_to_le16(cmd_len); - mefcmd->Criteria = cpu_to_le32(mefcmd->Criteria); - mefcmd->NumEntries = cpu_to_le16(mefcmd->NumEntries); - hexdump("mefcfg", buffer + cmd_header_len, cmd_len, ' '); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[MEF_CFG]"); - printf("ERR:Command sending failed!\n"); - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return MLAN_STATUS_FAILURE; - } - - ret = process_host_cmd_resp(HOSTCMD, buffer); - -mef_exit: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; - -} - -/** - * @brief parse hex data - * @param fp File handler - * @param dst A pointer to receive hex data - * @return length of hex data - */ -int -fparse_for_hex(FILE * fp, t_u8 *dst) -{ - char *ptr = NULL; - t_u8 *dptr = NULL; - char buf[256]; - - dptr = dst; - while (fgets(buf, sizeof(buf), fp)) { - ptr = buf; - - while (*ptr) { - /* skip leading spaces */ - while (*ptr && (isspace(*ptr) || *ptr == '\t')) - ptr++; - - /* skip blank lines and lines beginning with '#' */ - if (*ptr == '\0' || *ptr == '#') - break; - - if (isxdigit(*ptr)) { - ptr = convert2hex(ptr, dptr++); - } else { - /* Invalid character on data line */ - ptr++; - } - } - } - - return dptr - dst; -} - -/** Config data header length */ -#define CFG_DATA_HEADER_LEN 6 - -/** - * @brief Prepare cfg-data buffer - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @param fp File handler - * @param buf A pointer to comand buffer - * @param cmd_header_len Length of the command header - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -prepare_cfg_data_buffer(int argc, char *argv[], FILE * fp, t_u8 *buf, - int cmd_header_len) -{ - int ln = 0, type; - HostCmd_DS_GEN *hostcmd = NULL; - HostCmd_DS_802_11_CFG_DATA *pcfg_data = NULL; - - memset(buf, 0, BUFFER_LENGTH - cmd_header_len - sizeof(t_u32)); - hostcmd = (HostCmd_DS_GEN *)buf; - hostcmd->command = cpu_to_le16(HostCmd_CMD_CFG_DATA); - pcfg_data = (HostCmd_DS_802_11_CFG_DATA *)(buf + S_DS_GEN); - pcfg_data->action = - (argc == 4) ? HostCmd_ACT_GEN_GET : HostCmd_ACT_GEN_SET; - type = atoi(argv[3]); - if ((type < 1) || (type > 2)) { - fprintf(stderr, "mlanutl: Invalid register type\n"); - return MLAN_STATUS_FAILURE; - } else { - pcfg_data->type = type; - } - if (argc == 5) { - ln = fparse_for_hex(fp, pcfg_data->data); - } - pcfg_data->data_len = ln; - hostcmd->size = - cpu_to_le16(pcfg_data->data_len + S_DS_GEN + - CFG_DATA_HEADER_LEN); - pcfg_data->data_len = cpu_to_le16(pcfg_data->data_len); - pcfg_data->type = cpu_to_le16(pcfg_data->type); - pcfg_data->action = cpu_to_le16(pcfg_data->action); - - hostcmd->seq_num = 0; - hostcmd->result = 0; - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process cfgdata - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_cfgdata(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - HostCmd_DS_GEN *hostcmd = NULL; - int ret = MLAN_STATUS_SUCCESS; - FILE *fp = NULL; - int cmd_header_len = 0; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - if (argc < 4 || argc > 5) { - printf("Error: invalid no of arguments\n"); - printf("Syntax: ./mlanutl mlanX cfgdata \n"); - exit(1); - } - - if (argc == 5) { - fp = fopen(argv[4], "r"); - if (fp == NULL) { - fprintf(stderr, "Cannot open file %s\n", argv[3]); - exit(1); - } - } - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - printf("Error: allocate memory for hostcmd failed\n"); - if (argc == 5) - fclose(fp); - return -ENOMEM; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - if (fp) { - fclose(fp); - } - return MLAN_STATUS_FAILURE; - } - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - /* buf = MRVL_CMD */ - prepare_buffer(buffer, HOSTCMD, 0, NULL); - - /* buf = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - ret = prepare_cfg_data_buffer(argc, argv, fp, (t_u8 *)hostcmd, - cmd_header_len); - if (argc == 5) - fclose(fp); - - if (ret == MLAN_STATUS_FAILURE) - goto _exit_; - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[CFG_DATA]"); - printf("ERR:Command sending failed!\n"); - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return MLAN_STATUS_FAILURE; - } - ret = process_host_cmd_resp(HOSTCMD, buffer); - -_exit_: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -/** - * @brief Process transmission of mgmt frames - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_mgmtframetx(int argc, char *argv[]) -{ - struct ifreq ifr; - char *line = NULL; - FILE *config_file = NULL; - int li = 0, arg_num = 0, ret = 0, i = 0; - char *args[100], *pos = NULL, mac_addr[20]; - t_u8 peer_mac[ETH_ALEN]; - t_u16 data_len = 0, type = 0, subtype = 0; - t_u16 seq_num = 0, frag_num = 0, from_ds = 0, to_ds = 0; - eth_priv_mgmt_frame_tx *pmgmt_frame = NULL; - t_u8 *buffer = NULL; - pkt_header *hdr = NULL; - - /* Check arguments */ - if (argc != 4) { - printf("ERR:Incorrect number of arguments.\n"); - printf("Syntax: ./mlanutl mlanX mgmtframetx \n"); - exit(1); - } - - data_len = sizeof(eth_priv_mgmt_frame_tx); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - hdr = (pkt_header *)buffer; - pmgmt_frame = (eth_priv_mgmt_frame_tx *)(buffer + sizeof(pkt_header)); - - /* Check if file exists */ - config_file = fopen(argv[3], "r"); - if (config_file == NULL) { - printf("\nERR:Config file can not open.\n"); - goto done; - } - line = (char *)malloc(MAX_CONFIG_LINE); - if (!line) { - printf("ERR:Cannot allocate memory for line\n"); - goto done; - } - memset(line, 0, MAX_CONFIG_LINE); - - /* Parse file and process */ - while (config_get_line(line, MAX_CONFIG_LINE, config_file, &li, &pos)) { - arg_num = parse_line(line, args, 100); - if (strcmp(args[0], "PktType") == 0) { - type = (t_u16)A2HEXDECIMAL(args[1]); - pmgmt_frame->frm_ctl = (type & 0x3) << 2; - } else if (strcmp(args[0], "PktSubType") == 0) { - subtype = (t_u16)A2HEXDECIMAL(args[1]); - pmgmt_frame->frm_ctl |= subtype << 4; - } else if (strncmp(args[0], "Addr", 4) == 0) { - strncpy(mac_addr, args[1], 20); - ret = mac2raw(mac_addr, peer_mac); - if (ret != MLAN_STATUS_SUCCESS) { - printf("%s Address \n", - ret == - MLAN_STATUS_FAILURE ? "Invalid MAC" : ret - == - MAC_BROADCAST ? "Broadcast" : - "Multicast"); - if (ret == MLAN_STATUS_FAILURE) - goto done; - } - i = atoi(args[0] + 4); - switch (i) { - case 1: - memcpy(pmgmt_frame->addr1, peer_mac, ETH_ALEN); - break; - case 2: - memcpy(pmgmt_frame->addr2, peer_mac, ETH_ALEN); - break; - case 3: - memcpy(pmgmt_frame->addr3, peer_mac, ETH_ALEN); - break; - case 4: - memcpy(pmgmt_frame->addr4, peer_mac, ETH_ALEN); - break; - } - } else if (strcmp(args[0], "Data") == 0) { - for (i = 0; i < arg_num - 1; i++) - pmgmt_frame->payload[i] = - (t_u8)A2HEXDECIMAL(args[i + 1]); - data_len += arg_num - 1; - } else if (strcmp(args[0], "SeqNum") == 0) { - seq_num = (t_u16)A2HEXDECIMAL(args[1]); - pmgmt_frame->seq_ctl = seq_num << 4; - } else if (strcmp(args[0], "FragNum") == 0) { - frag_num = (t_u16)A2HEXDECIMAL(args[1]); - pmgmt_frame->seq_ctl |= frag_num; - } else if (strcmp(args[0], "FromDS") == 0) { - from_ds = (t_u16)A2HEXDECIMAL(args[1]); - pmgmt_frame->frm_ctl |= (from_ds & 0x1) << 9; - } else if (strcmp(args[0], "ToDS") == 0) { - to_ds = (t_u16)A2HEXDECIMAL(args[1]); - pmgmt_frame->frm_ctl |= (to_ds & 0x1) << 8; - } - } - pmgmt_frame->frm_len = data_len - sizeof(pmgmt_frame->frm_len); -#define MRVL_PKT_TYPE_MGMT_FRAME 0xE5 - hdr->pkt_len = data_len; - hdr->TxPktType = MRVL_PKT_TYPE_MGMT_FRAME; - hdr->TxControl = 0; - hexdump("Frame Tx", buffer, data_len + sizeof(pkt_header), ' '); - /* Send collective command */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)buffer; - - /* Perform ioctl */ - if (ioctl(sockfd, FRAME_TX_IOCTL, &ifr)) { - perror(""); - printf("ERR:Could not send management frame.\n"); - } else { - printf("Mgmt Frame sucessfully sent.\n"); - } - -done: - if (config_file) - fclose(config_file); - if (buffer) - free(buffer); - if (line) - free(line); - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief set/get management frame passthrough - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_mgmt_frame_passthrough(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - t_u32 mask = 0; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: htcapinfo fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - mask = *(t_u32 *)buffer; - if (argc == 3) - printf("Registed Management Frame Mask: 0x%x\n", mask); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief set/get hotspot enable/disable config - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_hotspot_config(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - t_u32 hotspotcfg = 0; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: htcapinfo fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - hotspotcfg = *(t_u32 *)buffer; - if (argc == 3) - printf("HotSpot 2.0 Status: 0x%x\n", hotspotcfg); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief read current command - * @param ptr A pointer to data - * @param curCmd A pointer to the buf which will hold current command - * @return NULL or the pointer to the left command buf - */ -static t_s8 * -readCurCmd(t_s8 *ptr, t_s8 *curCmd) -{ - t_s32 i = 0; -#define MAX_CMD_SIZE 64 /**< Max command size */ - - while (*ptr != ']' && i < (MAX_CMD_SIZE - 1)) - curCmd[i++] = *(++ptr); - - if (*ptr != ']') - return NULL; - - curCmd[i - 1] = '\0'; - - return ++ptr; -} - -/** - * @brief parse command and hex data - * @param fp A pointer to FILE stream - * @param dst A pointer to the dest buf - * @param cmd A pointer to command buf for search - * @return Length of hex data or MLAN_STATUS_FAILURE - */ -static int -fparse_for_cmd_and_hex(FILE * fp, t_u8 *dst, t_u8 *cmd) -{ - t_s8 *ptr; - t_u8 *dptr; - t_s8 buf[256], curCmd[64]; - t_s32 isCurCmd = 0; - - dptr = dst; - while (fgets((char *)buf, sizeof(buf), fp)) { - ptr = buf; - - while (*ptr) { - /* skip leading spaces */ - while (*ptr && isspace(*ptr)) - ptr++; - - /* skip blank lines and lines beginning with '#' */ - if (*ptr == '\0' || *ptr == '#') - break; - - if (*ptr == '[' && *(ptr + 1) != '/') { - ptr = readCurCmd(ptr, curCmd); - if (!ptr) - return MLAN_STATUS_FAILURE; - - if (strcasecmp((char *)curCmd, (char *)cmd)) /* Not equal */ - isCurCmd = 0; + /* HT and VHT*/ + if (datarate->tx_bw <= 3) + printf(" BW: %s\n", bw[datarate->tx_bw]); + if (datarate->tx_rate_format < 3) { + if (datarate->tx_gi == 0) + printf(" GI: Long\n"); else - isCurCmd = 1; - } - - /* Ignore the rest if it is not correct cmd */ - if (!isCurCmd) - break; - - if (*ptr == '[' && *(ptr + 1) == '/') - return dptr - dst; - - if (isxdigit(*ptr)) { - ptr = (t_s8 *)convert2hex((char *)ptr, dptr++); - } else { - /* Invalid character on data line */ - ptr++; - } - } - } - - return MLAN_STATUS_FAILURE; -} - -/** - * @brief 11ax HE capability and operation configure - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ - -static int -process_11axcfg(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd; - struct ifreq ifr; - int id_len = 0; - FILE *fp = NULL; - int ret = 0, cmd_header_len = 0; - char config_id[20]; - char filename[256]; - - if (argc != 3 && argc != 4) { - printf("Err: Invalid number of arguments\n"); - printf("Usage: ./mlanutl 11axcfg [11axcfg.conf]\n"); - return MLAN_STATUS_FAILURE; - } - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - cmd_header_len = strlen(CMD_NXP) + strlen(argv[2]); - prepare_buffer(buffer, argv[2], 0, NULL); - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = cmd_header_len; - cmd->total_len = BUFFER_LENGTH; - - if (argc == 4) { - memset(filename, 0, sizeof(filename)); - strncpy(filename, argv[3], sizeof(filename) - 1); - - fp = fopen(filename, "r"); - if (fp == NULL) { - perror("fopen"); - fprintf(stderr, "Cannot open file %s\n", argv[3]); - ret = -EFAULT;; - goto done; - } - - snprintf(config_id, sizeof(config_id), "Band"); - id_len = fparse_for_cmd_and_hex(fp, buffer + cmd_header_len, - (t_u8 *)config_id); - - snprintf(config_id, sizeof(config_id), "HECap"); - fparse_for_cmd_and_hex(fp, buffer + cmd_header_len + id_len, - (t_u8 *)config_id); - hexdump("Set 11axcfg", buffer + cmd_header_len, - sizeof(mlan_ds_11ax_he_cfg), ' '); - cmd->used_len = cmd_header_len + sizeof(mlan_ds_11ax_he_cfg); - } - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl: 11axcfg"); - ret = -EFAULT; - goto done; - } - hexdump("11axcfg", buffer + cmd_header_len, sizeof(mlan_ds_11ax_he_cfg), - ' '); -done: - if (fp) - fclose(fp); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Process 11ax command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_11axcmdcfg(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - mlan_ds_11ax_cmd_cfg *axcmd = NULL; - t_u32 action = 0; - t_u32 prefix_len = 0; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - if (strcmp(argv[3], "obss_pd_offset") == 0) { - sprintf(argv[3], "%d", MLAN_11AXCMD_CFG_ID_SR_OBSS_PD_OFFSET); - } else if (strcmp(argv[3], "enable_sr") == 0) { - sprintf(argv[3], "%d", MLAN_11AXCMD_CFG_ID_SR_ENABLE); - } else if (strcmp(argv[3], "beam_change") == 0) { - sprintf(argv[3], "%d", MLAN_11AXCMD_CFG_ID_BEAM_CHANGE); - } else if (strcmp(argv[3], "enable_htc") == 0) { - sprintf(argv[3], "%d", MLAN_11AXCMD_CFG_ID_HTC_ENABLE); - } else { - printf("ERR:unknown command %s!\n", argv[3]); - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = strlen((char *)buffer); - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: 11axcmd fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - prefix_len += strlen(CMD_NXP) + strlen(argv[2]); - action = *(t_u32 *)(buffer + prefix_len); - if (action == MLAN_ACT_GET) { - axcmd = (mlan_ds_11ax_cmd_cfg *) (buffer + prefix_len + - sizeof(t_u32)); - switch (axcmd->sub_id) { - case MLAN_11AXCMD_SR_SUBID: - if (axcmd->param.sr_cfg.type == - MRVL_DOT11AX_OBSS_PD_OFFSET_TLV_ID) { - printf("HE SR = %d,%d\n", axcmd->param.sr_cfg.param.obss_pd_offset.offset[0], axcmd->param.sr_cfg.param.obss_pd_offset.offset[1]); - } else if (axcmd->param.sr_cfg.type == - MRVL_DOT11AX_ENABLE_SR_TLV_ID) { - printf("HE SR Spatial Reuse is %s(%d)\n", - axcmd->param.sr_cfg.param.sr_control. - control == 1 ? "enabled" : "disabled", - axcmd->param.sr_cfg.param.sr_control. - control); - } else { - printf("Unknown SR type 0x%x\n", - axcmd->param.sr_cfg.type); - } - break; - case MLAN_11AXCMD_BEAM_SUBID: - printf("HE Beam change %s(%d)\n", - axcmd->param.beam_cfg.value == - 1 ? "disabled" : "enabled", - axcmd->param.beam_cfg.value); - break; - case MLAN_11AXCMD_HTC_SUBID: - printf("HTC transmission %s(%d)\n", - axcmd->param.htc_cfg.value == - 1 ? "enabled" : "disabled", - axcmd->param.htc_cfg.value); - break; - default: - printf("Unknown sub_command 0x%x\n", axcmd->sub_id); - break; - } - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; - -} - -/** - * @brief Send a WMM AC Queue configuration command to get/set/default params - * - * Configure or get the parameters of a WMM AC queue. The command takes - * an optional Queue Id as a last parameter. Without the queue id, all - * queues will be acted upon. - * - * mlanutl mlanX qconfig set msdu [Queue Id: 0-3] - * mlanutl mlanX qconfig get [Queue Id: 0-3] - * mlanutl mlanX qconfig def [Queue Id: 0-3] - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_qconfig(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - wlan_ioctl_wmm_queue_config_t queue_config_cmd; - mlan_wmm_ac_e ac_idx; - mlan_wmm_ac_e ac_idx_start; - mlan_wmm_ac_e ac_idx_stop; - int cmd_header_len = 0; - int ret = 0; - - const char *ac_str_tbl[] = { "BK", "BE", "VI", "VO" }; - - if (argc < 4) { - fprintf(stderr, "Invalid number of parameters!\n"); - return -EINVAL; - } - - cmd_header_len = strlen(CMD_NXP) + strlen(argv[2]); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - printf("Error: allocate memory for qconfig failed\n"); - return -ENOMEM; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - /* buf = MRVL_CMD */ - prepare_buffer(buffer, argv[2], 0, NULL); - - memset(&queue_config_cmd, 0x00, sizeof(wlan_ioctl_wmm_queue_config_t)); - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (strcmp(argv[3], "get") == 0) { - /* 3 4 5 */ - /* qconfig get [qid] */ - if (argc == 4) { - ac_idx_start = WMM_AC_BK; - ac_idx_stop = WMM_AC_VO; - } else if (argc == 5) { - if (atoi(argv[4]) < WMM_AC_BK || - atoi(argv[4]) > WMM_AC_VO) { - fprintf(stderr, "ERROR: Invalid Queue ID!\n"); - ret = -EINVAL; - goto done; - } - ac_idx_start = atoi(argv[4]); - ac_idx_stop = ac_idx_start; - } else { - fprintf(stderr, "Invalid number of parameters!\n"); - ret = -EINVAL; - goto done; - } - queue_config_cmd.action = WMM_QUEUE_CONFIG_ACTION_GET; - - for (ac_idx = ac_idx_start; ac_idx <= ac_idx_stop; ac_idx++) { - queue_config_cmd.accessCategory = ac_idx; - memcpy(buffer + cmd_header_len, - (t_u8 *)&queue_config_cmd, - sizeof(queue_config_cmd)); - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("qconfig ioctl"); - } else { - memcpy((t_u8 *)&queue_config_cmd, - buffer + cmd_header_len, - sizeof(queue_config_cmd)); - printf("qconfig %s(%d): MSDU Lifetime GET = 0x%04x (%d)\n", ac_str_tbl[ac_idx], ac_idx, queue_config_cmd.msduLifetimeExpiry, queue_config_cmd.msduLifetimeExpiry); - } - } - } else if (strcmp(argv[3], "set") == 0) { - if ((argc >= 5) && strcmp(argv[4], "msdu") == 0) { - /* 3 4 5 6 7 */ - /* qconfig set msdu [qid] */ - if (argc == 6) { - ac_idx_start = WMM_AC_BK; - ac_idx_stop = WMM_AC_VO; - } else if (argc == 7) { - if (atoi(argv[6]) < WMM_AC_BK || - atoi(argv[6]) > WMM_AC_VO) { - fprintf(stderr, - "ERROR: Invalid Queue ID!\n"); - ret = -EINVAL; - goto done; - } - ac_idx_start = atoi(argv[6]); - ac_idx_stop = ac_idx_start; - } else { - fprintf(stderr, - "Invalid number of parameters!\n"); - ret = -EINVAL; - goto done; - } - queue_config_cmd.action = WMM_QUEUE_CONFIG_ACTION_SET; - queue_config_cmd.msduLifetimeExpiry = atoi(argv[5]); - - for (ac_idx = ac_idx_start; ac_idx <= ac_idx_stop; - ac_idx++) { - queue_config_cmd.accessCategory = ac_idx; - memcpy(buffer + cmd_header_len, - (t_u8 *)&queue_config_cmd, - sizeof(queue_config_cmd)); - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("qconfig ioctl"); - } else { - memcpy((t_u8 *)&queue_config_cmd, - buffer + cmd_header_len, - sizeof(queue_config_cmd)); - printf("qconfig %s(%d): MSDU Lifetime SET = 0x%04x (%d)\n", ac_str_tbl[ac_idx], ac_idx, queue_config_cmd.msduLifetimeExpiry, queue_config_cmd.msduLifetimeExpiry); + printf(" GI: Short\n"); + } else if (datarate->tx_rate_format == 3) { + switch (datarate->tx_gi) { + case 0: + printf(" GI: 1xHELTF + GI 0.8us \n"); + break; + case 1: + printf(" GI: 2xHELTF + GI 0.8us \n"); + break; + case 2: + printf(" GI: 2xHELTF + GI 1.6us \n"); + break; + case 3: + printf(" GI: 4xHELTF + GI 0.8us DCM=0 and STBC=0 or\n" + " 4xHELTF + GI 3.2us Otherwise \n"); + break; } } - } else { - /* Only MSDU Lifetime provisioning accepted for now */ - fprintf(stderr, "Invalid set parameter: s/b [msdu]\n"); - ret = -EINVAL; - goto done; + if (datarate->tx_rate_format >= 2) + printf(" NSS: %d\n", datarate->tx_nss + 1); + if (datarate->tx_mcs_index != 0xFF) + printf(" MCS: MCS %d\n", + (int)datarate->tx_mcs_index); + else + printf(" MCS: Auto\n"); + if (datarate->tx_rate_format < 3) + printf(" Rate: %f Mbps\n", + (float)datarate->tx_data_rate / 2); } - } else if (strncmp(argv[3], "def", strlen("def")) == 0) { - /* 3 4 5 */ - /* qconfig def [qid] */ - if (argc == 4) { - ac_idx_start = WMM_AC_BK; - ac_idx_stop = WMM_AC_VO; - } else if (argc == 5) { - if (atoi(argv[4]) < WMM_AC_BK || - atoi(argv[4]) > WMM_AC_VO) { - fprintf(stderr, "ERROR: Invalid Queue ID!\n"); - ret = -EINVAL; - goto done; + } + + printf(" RX: \n"); + if (datarate->rx_rate_format <= 3) { + printf(" Type: %s\n", rate_format[datarate->rx_rate_format]); + if ((datarate->rx_rate_format == 0) && + datarate->rx_data_rate <= 11) + /* LG */ + printf(" Rate: %s\n", + lg_rate[datarate->rx_data_rate]); + else { + /* HT and VHT*/ + if (datarate->rx_bw <= 3) + printf(" BW: %s\n", bw[datarate->rx_bw]); + if (datarate->rx_rate_format < 3) { + if (datarate->rx_gi == 0) + printf(" GI: Long\n"); + else + printf(" GI: Short\n"); + } else if (datarate->rx_rate_format == 3) { + switch (datarate->rx_gi) { + case 0: + printf(" GI: 1xHELTF + GI 0.8us \n"); + break; + case 1: + printf(" GI: 2xHELTF + GI 0.8us \n"); + break; + case 2: + printf(" GI: 2xHELTF + GI 1.6us \n"); + break; + case 3: + printf(" GI: 4xHELTF + GI 0.8us DCM=0 and STBC=0 or\n" + " 4xHELTF + GI 3.2us Otherwise \n"); + break; + } } - ac_idx_start = atoi(argv[4]); - ac_idx_stop = ac_idx_start; - } else { - fprintf(stderr, "Invalid number of parameters!\n"); - ret = -EINVAL; - goto done; + if (datarate->rx_rate_format >= 2) + printf(" NSS: %d\n", datarate->rx_nss + 1); + if (datarate->rx_mcs_index != 0xFF) + printf(" MCS: MCS %d\n", + (int)datarate->rx_mcs_index); + else + printf(" MCS: Auto\n"); + if (datarate->rx_rate_format < 3) + printf(" Rate: %f Mbps\n", + (float)datarate->rx_data_rate / 2); } - queue_config_cmd.action = WMM_QUEUE_CONFIG_ACTION_DEFAULT; - - for (ac_idx = ac_idx_start; ac_idx <= ac_idx_stop; ac_idx++) { - queue_config_cmd.accessCategory = ac_idx; - memcpy(buffer + cmd_header_len, - (t_u8 *)&queue_config_cmd, - sizeof(queue_config_cmd)); - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("qconfig ioctl"); - } else { - memcpy((t_u8 *)&queue_config_cmd, - buffer + cmd_header_len, - sizeof(queue_config_cmd)); - printf("qconfig %s(%d): MSDU Lifetime DEFAULT = 0x%04x (%d)\n", ac_str_tbl[ac_idx], ac_idx, queue_config_cmd.msduLifetimeExpiry, queue_config_cmd.msduLifetimeExpiry); - } - } - } else { - fprintf(stderr, - "Invalid qconfig command; s/b [set, get, default]\n"); - ret = -EINVAL; - goto done; - } - - ret = MLAN_STATUS_SUCCESS; -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Send an ADDTS command to the associated AP - * - * Process a given conf file for a specific TSPEC data block. Send the - * TSPEC along with any other IEs to the driver/firmware for transmission - * in an ADDTS request to the associated AP. - * - * Return the execution status of the command as well as the ADDTS response - * from the AP if any. - * - * mlanutl mlanX addts - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_addts(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - wlan_ioctl_wmm_addts_req_t addtsReq; - FILE *fp = NULL; - char filename[48]; - char config_id[20]; - int cmd_header_len = 0, ret = 0, copy_len = 0; - - memset(&addtsReq, 0x00, sizeof(addtsReq)); - memset(filename, 0x00, sizeof(filename)); - - if (argc != 6) { - fprintf(stderr, "Invalid number of parameters!\n"); - ret = -EINVAL; - goto done; - } - - cmd_header_len = strlen(CMD_NXP) + strlen(argv[2]); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - printf("Error: allocate memory for buffer failed\n"); - ret = -ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - /* buf = MRVL_CMD */ - prepare_buffer(buffer, argv[2], 0, NULL); - - strncpy(filename, argv[3], sizeof(filename) - 1); - - fp = fopen(filename, "r"); - if (fp == NULL) { - perror("fopen"); - fprintf(stderr, "Cannot open file %s\n", argv[3]); - ret = -EFAULT; - goto done; - } - - snprintf(config_id, sizeof(config_id), "tspec%d", atoi(argv[4])); - - addtsReq.ieDataLen = fparse_for_cmd_and_hex(fp, - addtsReq.ieData, - (t_u8 *)config_id); - - if (addtsReq.ieDataLen > 0) { - printf("Found %d bytes in the %s section of conf file %s\n", - (int)addtsReq.ieDataLen, config_id, filename); - } else { - fprintf(stderr, "section %s not found in %s\n", - config_id, filename); - ret = -EFAULT; - goto done; - } - - addtsReq.timeout_ms = atoi(argv[5]); - - printf("Cmd Input:\n"); - hexdump(config_id, addtsReq.ieData, addtsReq.ieDataLen, ' '); - copy_len = sizeof(addtsReq); - memcpy(buffer + cmd_header_len, (t_u8 *)&addtsReq, copy_len); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl: addts ioctl"); - ret = -EFAULT; - goto done; - } - - memcpy(&addtsReq, buffer, strlen((const char *)buffer)); - printf("Cmd Output:\n"); - printf("ADDTS Command Result = %d\n", addtsReq.commandResult); - printf("ADDTS IEEE Status = %d\n", addtsReq.ieeeStatusCode); - hexdump(config_id, addtsReq.ieData, addtsReq.ieDataLen, ' '); - -done: - if (fp) - fclose(fp); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Send a DELTS command to the associated AP - * - * Process a given conf file for a specific TSPEC data block. Send the - * TSPEC along with any other IEs to the driver/firmware for transmission - * in a DELTS request to the associated AP. - * - * Return the execution status of the command. There is no response to a - * DELTS from the AP. - * - * mlanutl mlanX delts - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_delts(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - wlan_ioctl_wmm_delts_req_t deltsReq; - FILE *fp = NULL; - char filename[48]; - char config_id[20]; - int cmd_header_len = 0, ret = 0, copy_len = 0; - - memset(&deltsReq, 0x00, sizeof(deltsReq)); - memset(filename, 0x00, sizeof(filename)); - - if (argc != 5) { - fprintf(stderr, "Invalid number of parameters!\n"); - ret = -EINVAL; - goto done; - } - - cmd_header_len = strlen(CMD_NXP) + strlen(argv[2]); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - printf("Error: allocate memory for buffer failed\n"); - ret = -ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - /* buf = MRVL_CMD */ - prepare_buffer(buffer, argv[2], 0, NULL); - - strncpy(filename, argv[3], sizeof(filename) - 1); - fp = fopen(filename, "r"); - if (fp == NULL) { - perror("fopen"); - fprintf(stderr, "Cannot open file %s\n", argv[3]); - ret = -EFAULT;; - goto done; - } - - snprintf(config_id, sizeof(config_id), "tspec%d", atoi(argv[4])); - - deltsReq.ieDataLen = fparse_for_cmd_and_hex(fp, - deltsReq.ieData, - (t_u8 *)config_id); - - if (deltsReq.ieDataLen > 0) { - printf("Found %d bytes in the %s section of conf file %s\n", - (int)deltsReq.ieDataLen, config_id, filename); - } else { - fprintf(stderr, "section %s not found in %s\n", - config_id, filename); - ret = -EFAULT; - goto done; - } - - printf("Cmd Input:\n"); - hexdump(config_id, deltsReq.ieData, deltsReq.ieDataLen, ' '); - - copy_len = - sizeof(deltsReq) - sizeof(deltsReq.ieData) + deltsReq.ieDataLen; - memcpy(buffer + cmd_header_len, (t_u8 *)&deltsReq, copy_len); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("delts ioctl"); - ret = -EFAULT; - goto done; - } - - memcpy(&deltsReq, buffer, strlen((const char *)buffer)); - printf("Cmd Output:\n"); - printf("DELTS Command Result = %d\n", deltsReq.commandResult); - -done: - if (fp) - fclose(fp); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Get the current status of the WMM Queues - * - * Command: mlanutl mlanX qstatus - * - * Retrieve the following information for each AC if wmm is enabled: - * - WMM IE ACM Required - * - Firmware Flow Required - * - Firmware Flow Established - * - Firmware Queue Enabled - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_wmm_qstatus(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - wlan_ioctl_wmm_queue_status_t qstatus; - int ret = 0; - mlan_wmm_ac_e acVal; - - if (argc != 3) { - fprintf(stderr, "Invalid number of parameters!\n"); - ret = -EINVAL; - goto done; - } - - memset(&qstatus, 0x00, sizeof(qstatus)); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - printf("Error: allocate memory for qconfig failed\n"); - ret = -ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - /* buf = MRVL_CMD */ - prepare_buffer(buffer, argv[2], 0, NULL); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("qstatus ioctl"); - ret = -EFAULT; - goto done; - } - - memcpy(&qstatus, buffer, strlen((const char *)buffer)); - for (acVal = WMM_AC_BK; acVal <= WMM_AC_VO; acVal++) { - switch (acVal) { - case WMM_AC_BK: - printf("BK: "); - break; - case WMM_AC_BE: - printf("BE: "); - break; - case WMM_AC_VI: - printf("VI: "); - break; - case WMM_AC_VO: - printf("VO: "); - break; - default: - printf("??: "); - } - - printf("ACM[%c], FlowReq[%c], FlowCreated[%c], Enabled[%c]," - " DE[%c], TE[%c]\n", - (qstatus.acStatus[acVal].wmmAcm ? 'X' : ' '), - (qstatus.acStatus[acVal].flowRequired ? 'X' : ' '), - (qstatus.acStatus[acVal].flowCreated ? 'X' : ' '), - (qstatus.acStatus[acVal].disabled ? ' ' : 'X'), - (qstatus.acStatus[acVal].deliveryEnabled ? 'X' : ' '), - (qstatus.acStatus[acVal].triggerEnabled ? 'X' : ' ')); - } - -done: - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Get the current status of the WMM Traffic Streams - * - * Command: mlanutl mlanX ts_status - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_wmm_ts_status(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - wlan_ioctl_wmm_ts_status_t ts_status; - int tid; - int cmd_header_len = 0, ret = 0; - - const char *ac_str_tbl[] = { "BK", "BE", "VI", "VO" }; - - if (argc != 3) { - fprintf(stderr, "Invalid number of parameters!\n"); - ret = -EINVAL; - goto done; - } - - cmd_header_len = strlen(CMD_NXP) + strlen(argv[2]); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - printf("Error: allocate memory for qconfig failed\n"); - ret = -ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - /* buf = MRVL_CMD */ - - printf("\nTID Valid AC UP PSB FlowDir MediumTime\n"); - printf("---------------------------------------------------\n"); - - for (tid = 0; tid <= 7; tid++) { - memset(buffer, 0, BUFFER_LENGTH); - prepare_buffer(buffer, argv[2], 0, NULL); - memset(&ts_status, 0x00, sizeof(ts_status)); - ts_status.tid = tid; - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - memcpy(buffer + cmd_header_len, (t_u8 *)&ts_status, - sizeof(ts_status)); - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ts_status ioctl"); - ret = -EFAULT; - goto done; - } - - memcpy(&ts_status, buffer, strlen((const char *)buffer)); - printf(" %02d %3s %2s %u %c ", - ts_status.tid, - (ts_status.valid ? "Yes" : "No"), - (ts_status. - valid ? ac_str_tbl[ts_status.accessCategory] : "--"), - ts_status.userPriority, (ts_status.psb ? 'U' : 'L')); - - if ((ts_status.flowDir & 0x03) == 0) { - printf("%s", " ---- "); - } else { - printf("%2s%4s", - (ts_status.flowDir & 0x01 ? "Up" : ""), - (ts_status.flowDir & 0x02 ? "Down" : "")); - } - - printf("%12u\n", ts_status.mediumTime); - } - printf("\n"); - -done: - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Set/get WMM IE QoS info parameter - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_qos_config(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - /* Sanity tests */ - if (argc < 3 || argc > 4) { - printf("Insufficient parameters\n"); - printf("mlanutl mlanX qoscfg [QoS]\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: qoscfg fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - if (argc == 3) { - /* GET operation */ - printf("WMM QoS Info: %#x\n", *buffer); } if (buffer) @@ -11408,1282 +1390,19 @@ process_qos_config(int argc, char *argv[]) } /** - * @brief Set/get MAC control configuration - * + * @brief Process get wireless stats * @param argc Number of arguments * @param argv A pointer to arguments array * @return MLAN_STATUS_SUCCESS--success, otherwise--fail */ - -static int -process_macctrl(int argc, char *argv[]) +static int process_getlog(int argc, char *argv[]) { t_u8 *buffer = NULL; struct eth_priv_cmd *cmd = NULL; + struct eth_priv_get_log *stats = NULL; struct ifreq ifr; - t_u32 mac_ctrl = 0; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - /* Sanity tests */ - if (argc < 3 || argc > 4) { - printf("Insufficient parameters\n"); - printf("mlanutl mlanX macctrl [macctrl]\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: macctrl fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - mac_ctrl = *(t_u32 *)buffer; - if (argc == 3) { - /* GET operation */ - printf("MAC Control: 0x%08x\n", mac_ctrl); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process generic commands - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_generic(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], 0, NULL); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if ((ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) < 0) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: %s fail\n", argv[2]); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - if (argc == 3) { - /* GET operation */ - printf("%s command response received: %s\n", argv[2], buffer); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Set/Get mlanX FW side MAC address - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_fwmacaddr(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - /* Sanity tests */ - if (argc < 3 || argc > 4) { - printf("Insufficient parameters\n"); - printf("mlanutl mlanX fwmacaddr [fwmacaddr]\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: fwmacaddr fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - if (argc == 3) { - /* GET operation */ - printf("FW MAC address = "); - print_mac(buffer); - printf("\n"); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -#ifdef RX_PACKET_COALESCE -static void -print_rx_packet_coalesc_help() -{ - printf("\nUSAGE: rxpktcoal_cfg [PKT-THRESHOLD] [TIMEOUT]\n\n"); - printf("OPTIONS:"); - printf("PKT-THRESHOLD: count after which packets would be sent to host. Valid values 1-7\n"); - printf("\tTIMEOUT: Time after which packets would be sent to host Valid values 1-4\n"); - printf("\tCoalescing is disabled if both or either of PKT-THRESHOLD or TIMEOUT is zero\n\n"); - printf("\tEmpty - Get current packet coalescing settings\n"); -} - -static int -process_rx_pkt_coalesce_cfg(int argc, char *argv[]) -{ - - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - tlvbuf_rx_pkt_coal_t *rx_pkt_info; - int ret = MLAN_STATUS_SUCCESS; - - if ((argc != 3) && (argc != 5)) { - printf("ERR:Invalid no. of arguments\n"); - print_rx_packet_coalesc_help(); - return MLAN_STATUS_FAILURE; - } - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if ((ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) < 0) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: %s fail\n", argv[2]); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - if (argc == 3) { /* GET operation */ - rx_pkt_info = (tlvbuf_rx_pkt_coal_t *)(buffer); - printf("RX packet coalesce configuraion:\n"); - printf("Packet threshold=%d\n", rx_pkt_info->rx_pkt_count); - printf("Timeout=%dms\n", rx_pkt_info->delay); - } else { - printf("RX packet coalesce configuration set successfully.\n"); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; - -} -#endif - -/** - * @brief Process regioncode configuration - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_regioncode(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - t_u32 regioncode; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: regioncode config fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - if (argc == 3) { - memcpy(®ioncode, buffer, sizeof(regioncode)); - printf("regioncode: %d\n", regioncode); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process cfpinfo get command - * @param argc Number of arguments - * @param argv Pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_cfpinfo(int argc, char *argv[]) -{ - t_u8 *data, *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - t_u32 i, size = 0; - t_u32 j; - t_u32 rows, cols; - struct chan_freq_power { - t_u16 channel; - t_u32 freq; - t_u16 max_tx_power; - t_u8 passive_scan_or_radar_detect; - t_u16 flags; - t_u8 blacklist; - } *cfp; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: cfpinfo cmd failed\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - data = buffer; - size = *(t_u32 *)data; - if (!size) - goto out; - - /* Region code is stored in first 2 bytes, country code in next 3 bytes - * and environment, if available, in the following byte - */ - data += sizeof(size); - printf("Region Code : 0x%x\n", *(t_u16 *)data); - data += 2; - printf("Country Code : %c%c\n", *data, *(data + 1)); - data += 3; - if (size == 6) { - printf("Environment : 0x%x\n", *data); - data++; - } - /* Print cfp tables */ - size = *(t_u32 *)data; - if (!size) - goto out; - - data += sizeof(size); - printf("\n2.4GHz Channels:\n"); - printf("%8s%10s%6s%11s%16s%16s%17s\n", "Channel", "isPassive", - "isDFS", - "isDisabled", "is40MHzDisabled", - "is80MHzDisabled", "is160MHzDisabled"); - i = 0; - while (i < size) { - if (!(*data)) - goto out; - cfp = (struct chan_freq_power *)data; - printf("%8u%10u%6u%11u%16u%16c%17c\n", - cfp->channel, - (cfp->flags & NXP_CHANNEL_PASSIVE) ? 1 : 0, - cfp->passive_scan_or_radar_detect, - (cfp->flags & NXP_CHANNEL_DISABLED) ? 1 : 0, - (cfp->flags & NXP_CHANNEL_NOHT40) ? 1 : 0, '-', '-'); - data += sizeof(struct chan_freq_power); - i += sizeof(struct chan_freq_power); - } - size = *(t_u32 *)data; - if (!size) - goto out; - - data += sizeof(size); - - printf("\n5GHz Channels:\n"); - printf("%8s%10s%6s%11s%16s%16s%17s\n", "Channel", "isPassive", - "isDFS", - "isDisabled", "is40MHzDisabled", - "is80MHzDisabled", "is160MHzDisabled"); - i = 0; - while (i < size) { - if (!(*data)) - goto out; - cfp = (struct chan_freq_power *)data; - printf("%8u%10u%6u%11u%16u%16u%17c\n", - cfp->channel, - (cfp->flags & NXP_CHANNEL_PASSIVE) ? 1 : 0, - cfp->passive_scan_or_radar_detect, - (cfp->flags & NXP_CHANNEL_DISABLED) ? 1 : 0, - (cfp->flags & NXP_CHANNEL_NOHT40) ? 1 : 0, - (cfp->flags & NXP_CHANNEL_NOHT80) ? 1 : 0, '-'); - data += sizeof(struct chan_freq_power); - i += sizeof(struct chan_freq_power); - } - - /* Print power tables */ - size = *(t_u32 *)data; - if (!size) - goto out; - - data += sizeof(size); - rows = *(t_u32 *)data; - data += sizeof(size); - cols = *(t_u32 *)data; - data += sizeof(size); - if (!rows || !cols) - goto out; - - printf("\n2.4GHz Power Table:\n"); - printf("%8s ", "Channel"); - for (i = 0; i < cols - 1; i++) - printf(" m%02d", i); - - for (i = 0; i < rows; i++) { - printf("\n%8u ", *data++); - for (j = 1; j < cols; j++) - printf("%3u ", *data++); - } - printf("\n"); - size = *(t_u32 *)data; - if (!size) - goto out; - - data += sizeof(size); - rows = *(t_u32 *)data; - data += sizeof(size); - cols = *(t_u32 *)data; - data += sizeof(size); - if (!rows || !cols) - goto out; - - printf("\n5GHz Power Table:\n"); - printf("%8s ", "Channel"); - for (i = 0; i < cols - 1; i++) - printf(" m%02d", i); - - for (i = 0; i < rows; i++) { - printf("\n%8u ", *data++); - for (j = 1; j < cols; j++) - printf("%3u ", *data++); - } - /* Print Modulation Conversion Information */ - printf("\n\nModulation Conversions:\n"); - j = 0; - for (i = 0; i < 10; i++) - printf("m%02d: %s\n", j++, mod_conv_bg_1x1[i]); - for (i = 0; i < 6; i++) - printf("m%02d: %s\n", j++, mod_conv_bg_2x2[i]); - if (j >= cols - 1) - goto out; - for (i = 0; i < 6; i++) - printf("m%02d: %s\n", j++, mod_conv_a_1x1[i]); - for (i = 0; i < 6; i++) - printf("m%02d: %s\n", j++, mod_conv_a_2x2[i]); -out: - printf("\n"); - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process offchannel configuration - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_offchannel(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - /* Sanity tests */ - if (argc < 3 || argc > 7) { - printf("Incorrect number of parameters\n"); - printf("mlanutl mlanX offchannel [ ]\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: offchannel config fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - printf("%s\n", buffer); - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process link statistics - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_linkstats(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - t_u8 *buffer = NULL; - t_u8 *data = NULL; - HostCmd_DS_GEN *hostcmd = NULL; - t_u32 cmd_len = 0; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - /* prepare the host cmd */ - data = buffer; - prepare_buffer(buffer, HOSTCMD, 0, NULL); - data += strlen(CMD_NXP) + strlen(HOSTCMD); - /* add buffer size field */ - cmd_len = - sizeof(HostCmd_DS_GEN) + sizeof(HostCmd_DS_LINK_STATS_SUMMARY); - cmd_len = cpu_to_le32(cmd_len); - memcpy(data, &cmd_len, sizeof(t_u32)); - data += sizeof(t_u32); - /* add cmd header */ - hostcmd = (HostCmd_DS_GEN *)data; - hostcmd->command = cpu_to_le16(HostCmd_CMD_LINK_STATS_SUMMARY); - hostcmd->size = cpu_to_le16(sizeof(HostCmd_DS_GEN)); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: linkstats fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - ret = process_host_cmd_resp(HOSTCMD, buffer); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -#if defined(STA_SUPPORT) -/** - * @brief Configure PMF parameters - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_pmfcfg(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd; - struct eth_priv_pmfcfg pmfcfg; - struct ifreq ifr; - - /* Check if arguments are valid */ - if ((argc > 5) || (argc == 4) || - ((argc == 5) && ((!atoi(argv[3])) && atoi(argv[4])))) { - printf("ERR: Invalid arguments\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: pmfcfg fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* GET operation */ - if (argc == 3) { - memcpy(&pmfcfg, buffer, sizeof(struct eth_priv_pmfcfg)); - printf("Management Frame Protection Capability: %s\n", - (pmfcfg.mfpc ? "Yes" : "No")); - if (pmfcfg.mfpc) - printf("Management Frame Protection: %s\n", - (pmfcfg.mfpr ? "Required" : "Optional")); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} -#endif - -/** - * @brief Process extended version - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_verext(int argc, char *argv[]) -{ - int ret = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc < 3 || argc > 4) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX verext [#]\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: verext fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Process result */ - if (cmd->used_len) - printf("Extended Version string received: %s\n", buffer); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -/** - * @brief Makes USB device to suspend - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_usb_suspend(int argc, char *argv[]) -{ - int ret = 0, status = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc != 3) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX usbsuspend\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], 0, NULL); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: usbsuspend fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memcpy(&status, buffer, sizeof(status)); - if (status == -EFAULT) - printf("USB Device is already suspended\n"); - else if (status == 0) - printf("USB Device has been suspended\n"); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Process extended version - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_usb_resume(int argc, char *argv[]) -{ - int ret = 0, status = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc != 3) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX usbresume\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], 0, NULL); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: usbresume fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memcpy(&status, buffer, sizeof(status)); - if (status == -EFAULT) - printf("USB Device is already resumed\n"); - else if (status == 0) - printf("USB Device has been resumed\n"); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -#if defined(STA_SUPPORT) && defined(STA_WEXT) -/** - * @brief Set/Get radio - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_radio_ctrl(int argc, char *argv[]) -{ - int ret = 0, radio = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc < 3 || argc > 4) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX radioctrl [#]\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: radioctrl fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Process result */ - if (argc == 3) { - memcpy(&radio, buffer, sizeof(radio)); - if (radio == 0) { - printf("Radio is Disabled\n"); - } else if (radio == 1) { - printf("Radio is Enabled\n"); - } - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} -#endif - -/** - * @brief Implement WMM enable command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_wmm_cfg(int argc, char *argv[]) -{ - int ret = 0, status = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc < 3 || argc > 4) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX wmmcfg [#]\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: wmmcfg fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Process result */ - if (argc == 3) { - memcpy(&status, buffer, sizeof(status)); - if (status == 0) { - printf("WMM is Disabled\n"); - } else if (status == 1) { - printf("WMM is Enabled\n"); - } - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -static int -process_wmm_param_config(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - t_u8 *buffer = NULL; - t_u8 *data = NULL; - HostCmd_DS_GEN *hostcmd = NULL; - t_u32 cmd_len = 0; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; + struct timeval tv; int i = 0; - t_u32 wmm_param[MAX_AC_QUEUES][5]; - t_u8 aci = 0; - t_u8 aifsn = 0; - t_u8 ecwmax = 0; - t_u8 ecwmin = 0; - t_u16 txop = 0; - HostCmd_DS_WMM_PARAM_CONFIG *cmd_data = NULL; - - /* Sanity tests */ - if ((argc < 3) || (argc > (3 + 5 * MAX_AC_QUEUES)) || - (((argc - 3) % 5) != 0)) { - printf("Incorrect number of parameters\n"); - printf("Format reference: mlanutl mlanX wmm_param_config \n"); - printf("\t[AC_BE AIFSN ECW_MAX ECW_MIN TX_OP]\n"); - printf("\t[AC_BK AIFSN ECW_MAX ECW_MIN TX_OP]\n"); - printf("\t[AC_VI AIFSN ECW_MAX ECW_MIN TX_OP]\n"); - printf("\t[AC_VO AIFSN ECW_MAX ECW_MIN TX_OP]\n"); - return MLAN_STATUS_FAILURE; - } - - for (i = 3; i < argc; i++) { - if (IS_HEX_OR_DIGIT(argv[i]) == MLAN_STATUS_FAILURE) { - printf("ERR: Only Number values are allowed\n"); - return MLAN_STATUS_FAILURE; - } - } - - i = 3; - memset(wmm_param, 0x00, sizeof(wmm_param)); - while (i < argc) { - aci = A2HEXDECIMAL(argv[i]); - aifsn = A2HEXDECIMAL(argv[i + 1]); - ecwmax = A2HEXDECIMAL(argv[i + 2]); - ecwmin = A2HEXDECIMAL(argv[i + 3]); - txop = A2HEXDECIMAL(argv[i + 4]); - if ((aci <= 3) && !wmm_param[aci][0]) { - if (((aifsn >= 2) && (aifsn <= 15)) - && (ecwmax <= 15) - && (ecwmin <= 15) - && (txop <= 0xFFFF)) { - wmm_param[aci][0] = TRUE; - wmm_param[aci][1] = aifsn; - wmm_param[aci][2] = ecwmax; - wmm_param[aci][3] = ecwmin; - wmm_param[aci][4] = txop; - } else { - printf("wmm parmams invalid\n"); - return MLAN_STATUS_FAILURE; - } - } else { - printf("aci out of range or repeated \n"); - return MLAN_STATUS_FAILURE; - } - i = i + 5; - } /* Initialize buffer */ buffer = (t_u8 *)malloc(BUFFER_LENGTH); @@ -12691,45 +1410,8 @@ process_wmm_param_config(int argc, char *argv[]) printf("ERR:Cannot allocate buffer for command!\n"); return MLAN_STATUS_FAILURE; } - memset(buffer, 0x00, BUFFER_LENGTH); - /* prepare the host cmd */ - data = buffer; - prepare_buffer(buffer, HOSTCMD, 0, NULL); - data += strlen(CMD_NXP) + strlen(HOSTCMD); - /* add buffer size field */ - cmd_len = sizeof(HostCmd_DS_GEN) + sizeof(HostCmd_DS_WMM_PARAM_CONFIG); - cmd_len = cpu_to_le32(cmd_len); - memcpy(data, &cmd_len, sizeof(t_u32)); - data += sizeof(t_u32); - /* add cmd header */ - hostcmd = (HostCmd_DS_GEN *)data; - hostcmd->command = cpu_to_le16(HostCmd_CMD_WMM_PARAM_CONFIG); - hostcmd->size = - cpu_to_le16(sizeof(HostCmd_DS_GEN) + - sizeof(HostCmd_DS_WMM_PARAM_CONFIG)); - hostcmd->seq_num = 0; - hostcmd->result = 0; - data += sizeof(HostCmd_DS_GEN); - cmd_data = (HostCmd_DS_WMM_PARAM_CONFIG *) data; - if (argc > 3) { - cmd_data->action = ACTION_SET; - for (i = 0; i < MAX_AC_QUEUES; i++) { - if (wmm_param[i][0] == TRUE) { - cmd_data->ac_params[i].aci_aifsn.acm = 1; - cmd_data->ac_params[i].aci_aifsn.aci = (t_u8)i; - cmd_data->ac_params[i].aci_aifsn.aifsn = - (t_u8)(wmm_param[i][1]); - cmd_data->ac_params[i].ecw.ecw_max = - (t_u8)(wmm_param[i][2]); - cmd_data->ac_params[i].ecw.ecw_min = - (t_u8)(wmm_param[i][3]); - cmd_data->ac_params[i].tx_op_limit = - cpu_to_le16((t_u16)(wmm_param[i][4])); - } - } - } else - cmd_data->action = ACTION_GET; + prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); if (!cmd) { @@ -12755,7 +1437,7 @@ process_wmm_param_config(int argc, char *argv[]) if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { perror("mlanutl"); - fprintf(stderr, "mlanutl: linkstats fail\n"); + fprintf(stderr, "mlanutl: getlog fail\n"); if (cmd) free(cmd); if (buffer) @@ -12763,812 +1445,136 @@ process_wmm_param_config(int argc, char *argv[]) return MLAN_STATUS_FAILURE; } - /* Process result */ - ret = process_host_cmd_resp(HOSTCMD, buffer); + gettimeofday(&tv, NULL); - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -#if defined(STA_SUPPORT) -/** - * @brief Implement 802.11D enable command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_11d_cfg(int argc, char *argv[]) -{ - int ret = 0, status = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc < 3 || argc > 4) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX 11dcfg [#]\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: 11dcfg fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Process result */ - if (argc == 3) { - memcpy(&status, buffer, sizeof(status)); - if (status == 0) { - printf("802.11D is Disabled\n"); - } else if (status == 1) { - printf("802.11D is Enabled\n"); + /* Process results */ + stats = (struct eth_priv_get_log *)buffer; + printf("Get log: timestamp %d.%06d sec\n", (int)tv.tv_sec, + (int)tv.tv_usec); + printf("dot11GroupTransmittedFrameCount %u\n" + "dot11FailedCount %u\n" + "dot11RetryCount %u\n" + "dot11MultipleRetryCount %u\n" + "dot11FrameDuplicateCount %u\n" + "dot11RTSSuccessCount %u\n" + "dot11RTSFailureCount %u\n" + "dot11ACKFailureCount %u\n" + "dot11ReceivedFragmentCount %u\n" + "dot11GroupReceivedFrameCount %u\n" + "dot11FCSErrorCount %u\n" + "dot11TransmittedFrameCount %u\n" + "wepicverrcnt-1 %u\n" + "wepicverrcnt-2 %u\n" + "wepicverrcnt-3 %u\n" + "wepicverrcnt-4 %u\n" + "beaconReceivedCount %u\n" + "beaconMissedCount %u\n", + stats->mcast_tx_frame, stats->failed, stats->retry, + stats->multi_retry, stats->frame_dup, stats->rts_success, + stats->rts_failure, stats->ack_failure, stats->rx_frag, + stats->mcast_rx_frame, stats->fcs_error, stats->tx_frame, + stats->wep_icv_error[0], stats->wep_icv_error[1], + stats->wep_icv_error[2], stats->wep_icv_error[3], + stats->bcn_rcv_cnt, stats->bcn_miss_cnt); + if (cmd->used_len == sizeof(struct eth_priv_get_log)) { + printf("dot11TransmittedFragmentCount %u\n", + stats->tx_frag_cnt); + printf("dot11QosTransmittedFragmentCount "); + for (i = 0; i < 8; i++) { + printf("%u ", stats->qos_tx_frag_cnt[i]); } - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -/** - * @brief Implement 802.11D clear chan table command - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_11d_clr_tbl(int argc, char *argv[]) -{ - int ret = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc != 3) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX 11dclrtbl\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], 0, NULL); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: 11dclrtbl fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} -#endif - -#ifndef OPCHAN -/** - * @brief Set/Get WWS configuration - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_wws_cfg(int argc, char *argv[]) -{ - int ret = 0, status = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc < 3 || argc > 4) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX wwscfg [#]\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: wwscfg fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Process result */ - if (argc == 3) { - memcpy(&status, buffer, sizeof(status)); - if (status == 1) { - printf("WWS is Enabled\n"); - } else if (status == 0) { - printf("WWS is Disabled\n"); + printf("\ndot11QosFailedCount "); + for (i = 0; i < 8; i++) { + printf("%u ", stats->qos_failed_cnt[i]); } - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} -#endif - -#if defined(REASSOCIATION) -/** - * @brief Set/Get reassociation settings - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_set_get_reassoc(int argc, char *argv[]) -{ - int ret = 0, status = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc < 3 || argc > 4) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX reassoctrl [#]\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: reassoctrl fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Process result */ - if (argc == 3) { - memcpy(&status, buffer, sizeof(status)); - if (status == 1) { - printf("Re-association is Enabled\n"); - } else if (status == 0) { - printf("Re-association is Disabled\n"); + printf("\ndot11QosRetryCount "); + for (i = 0; i < 8; i++) { + printf("%u ", stats->qos_retry_cnt[i]); } - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} -#endif - -/** - * @brief Get Transmit buffer size - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_txbuf_cfg(int argc, char *argv[]) -{ - int ret = 0, buf_size = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc != 3) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX txbufcfg\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], 0, NULL); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: txbufcfg fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memcpy(&buf_size, buffer, sizeof(buf_size)); - printf("Transmit buffer size is %d\n", buf_size); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -#ifdef STA_SUPPORT -/** - * @brief Set/Get auth type - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_set_get_auth_type(int argc, char *argv[]) -{ - int ret = 0, auth_type = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc < 3 || argc > 4) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX authtype [#]\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: authtype fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Process result */ - if (argc == 3) { - memcpy(&auth_type, buffer, sizeof(auth_type)); - if (auth_type == 1) { - printf("802.11 shared key authentication\n"); - } else if (auth_type == 0) { - printf("802.11 open system authentication\n"); - } else if (auth_type == 3) { - printf("802.11 WPA3 SAE authentication\n"); - } else if (auth_type == 255) { - printf("Allow open system or shared key authentication\n"); + printf("\ndot11QosMultipleRetryCount "); + for (i = 0; i < 8; i++) { + printf("%u ", stats->qos_multi_retry_cnt[i]); } + printf("\ndot11QosFrameDuplicateCount "); + for (i = 0; i < 8; i++) { + printf("%u ", stats->qos_frm_dup_cnt[i]); + } + printf("\ndot11QosRTSSuccessCount "); + for (i = 0; i < 8; i++) { + printf("%u ", stats->qos_rts_suc_cnt[i]); + } + printf("\ndot11QosRTSFailureCount "); + for (i = 0; i < 8; i++) { + printf("%u ", stats->qos_rts_failure_cnt[i]); + } + printf("\ndot11QosACKFailureCount "); + for (i = 0; i < 8; i++) { + printf("%u ", stats->qos_ack_failure_cnt[i]); + } + printf("\ndot11QosReceivedFragmentCount "); + for (i = 0; i < 8; i++) { + printf("%u ", stats->qos_rx_frag_cnt[i]); + } + printf("\ndot11QosTransmittedFrameCount "); + for (i = 0; i < 8; i++) { + printf("%u ", stats->qos_tx_frm_cnt[i]); + } + printf("\ndot11QosDiscardedFrameCount "); + for (i = 0; i < 8; i++) { + printf("%u ", stats->qos_discarded_frm_cnt[i]); + } + printf("\ndot11QosMPDUsReceivedCount "); + for (i = 0; i < 8; i++) { + printf("%u ", stats->qos_mpdus_rx_cnt[i]); + } + printf("\ndot11QosRetriesReceivedCount "); + for (i = 0; i < 8; i++) { + printf("%u ", stats->qos_retries_rx_cnt[i]); + } + printf("\ndot11RSNAStatsCMACICVErrors %u\n" + "dot11RSNAStatsCMACReplays %u\n" + "dot11RSNAStatsRobustMgmtCCMPReplays %u\n" + "dot11RSNAStatsTKIPICVErrors %u\n" + "dot11RSNAStatsTKIPReplays %u\n" + "dot11RSNAStatsCCMPDecryptErrors %u\n" + "dot11RSNAstatsCCMPReplays %u\n" + "dot11TransmittedAMSDUCount %u\n" + "dot11FailedAMSDUCount %u\n" + "dot11RetryAMSDUCount %u\n" + "dot11MultipleRetryAMSDUCount %u\n" + "dot11TransmittedOctetsInAMSDUCount %llu\n" + "dot11AMSDUAckFailureCount %u\n" + "dot11ReceivedAMSDUCount %u\n" + "dot11ReceivedOctetsInAMSDUCount %llu\n" + "dot11TransmittedAMPDUCount %u\n" + "dot11TransmittedMPDUsInAMPDUCount %u\n" + "dot11TransmittedOctetsInAMPDUCount %llu\n" + "dot11AMPDUReceivedCount %u\n" + "dot11MPDUInReceivedAMPDUCount %u\n" + "dot11ReceivedOctetsInAMPDUCount %llu\n" + "dot11AMPDUDelimiterCRCErrorCount %u\n", + stats->cmacicv_errors, stats->cmac_replays, + stats->mgmt_ccmp_replays, stats->tkipicv_errors, + stats->tkip_replays, stats->ccmp_decrypt_errors, + stats->ccmp_replays, stats->tx_amsdu_cnt, + stats->failed_amsdu_cnt, stats->retry_amsdu_cnt, + stats->multi_retry_amsdu_cnt, + stats->tx_octets_in_amsdu_cnt, + stats->amsdu_ack_failure_cnt, stats->rx_amsdu_cnt, + stats->rx_octets_in_amsdu_cnt, stats->tx_ampdu_cnt, + stats->tx_mpdus_in_ampdu_cnt, + stats->tx_octets_in_ampdu_cnt, stats->ampdu_rx_cnt, + stats->mpdu_in_rx_ampdu_cnt, + stats->rx_octets_in_ampdu_cnt, + stats->ampdu_delimiter_crc_error_cnt); } -done: if (buffer) free(buffer); if (cmd) free(cmd); - return ret; -} -#endif - -/** - * @brief Set/get user provisioned local power constraint - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_11h_local_pwr_constraint(int argc, char *argv[]) -{ - int ret = 0, power_cons = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc < 3 || argc > 4) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX powercons [#]\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: powercons fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - if (argc == 3) { - /* Process result */ - memcpy(&power_cons, buffer, sizeof(power_cons)); - printf("Local power constraint is %d dbm\n", power_cons); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -/** - * @brief Set/get HT stream configurations - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_ht_stream_cfg(int argc, char *argv[]) -{ - int ret = 0, mode = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc < 3 || argc > 4) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX htstreamcfg [#]\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: htstreamcfg fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Process result */ - memcpy(&mode, buffer, sizeof(mode)); - if (mode == HT_STREAM_MODE_1X1) - printf("HT stream is in 1x1 mode\n"); - else if (mode == HT_STREAM_MODE_2X2) - printf("HT stream is in 2x2 mode\n"); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -/** - * @brief Set mimo switch configurations - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_mimo_switch(int argc, char *argv[]) -{ - int ret = 0; - t_u8 *buffer = NULL; - t_u8 tx_antmode = 0, rx_antmode = 0; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc != 5) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX/uapX mimoswitch [txpath_antmode] [rxpath_antmode]\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - tx_antmode = (t_u8)a2hex_or_atoi(argv[3]); - rx_antmode = (t_u8)a2hex_or_atoi(argv[4]); - if (! - ((tx_antmode == 1 && rx_antmode == 1) || - (tx_antmode == 2 && rx_antmode == 2) || (rx_antmode == 3 && - (tx_antmode == 1 || - tx_antmode == 3)))) { - printf("Error: invalid arguments\n"); - printf("The valid values of txpath_antmode and rxpath_antmode are 1/1 2/2 3/3 1/3 \n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: mimoswitch fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Process result */ - printf("Successfully set Tx path antenna mode: %d, Rx path antenna mode: %d\n", tx_antmode, rx_antmode); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -/** - * @brief Get thermal reading - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_thermal(int argc, char *argv[]) -{ - int ret = 0, thermal = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc != 3) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX thermal\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: thermal fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Process result */ - memcpy(&thermal, buffer, sizeof(thermal)); - printf("Thermal reading is %d\n", thermal); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; + return MLAN_STATUS_SUCCESS; } #ifdef STA_SUPPORT @@ -13578,10 +1584,9 @@ done: * @param argv A pointer to arguments array * @return MLAN_STATUS_SUCCESS--success, otherwise--fail */ -static int -process_get_signal(int argc, char *argv[]) +static int process_get_signal(int argc, char *argv[]) { -#define DATA_SIZE 12 +#define DATA_SIZE 12 int ret = 0, data[DATA_SIZE], i = 0, copy_size = 0; t_u8 *buffer = NULL; struct eth_priv_cmd *cmd = NULL; @@ -13644,176 +1649,6 @@ process_get_signal(int argc, char *argv[]) printf("%d\t", data[i]); printf("\n"); -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -/** - * @brief Set signalext cfg - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_signalext_cfg(int argc, char *argv[]) -{ - int ret = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc != 4) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX signalextcfg [#]\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: signalext cfg fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -/** - * @brief Get signal - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_get_signal_ext(int argc, char *argv[]) -{ -#define MAX_NUM_PATH 3 -#define PATH_SIZE 13 -#define PATH_A 1 -#define PATH_B 2 -#define PATH_AB 3 - int ret = 0, data[PATH_SIZE * MAX_NUM_PATH] = { 0 }; - int i = 0, copy_size = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - t_u8 num_path = 0; - - memset(data, 0, sizeof(data)); - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc != 3 && argc != 4) { - printf("Error: invalid no of arguments\n"); - if (strncmp(argv[2], "getsignalextv2", strlen("getsignalextv2")) - == 0) - printf("mlanutl mlanX getsignalextv2 [m]\n"); - else if (strncmp - (argv[2], "getsignalext", strlen("getsignalext")) == 0) - printf("mlanutl mlanX getsignalext [m]\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: getsignal fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Process result */ - copy_size = cmd->used_len; - memcpy(&data, (int *)buffer, copy_size); - - num_path = copy_size / sizeof(int) / PATH_SIZE; - for (i = 0; i < num_path; i++) { - if (data[i * PATH_SIZE] == PATH_A) - printf("PATH A: %d %d %d %d %d %d %d %d %d %d %d %d\n", data[i * PATH_SIZE + 1], data[i * PATH_SIZE + 2], data[i * PATH_SIZE + 3], data[i * PATH_SIZE + 4], data[i * PATH_SIZE + 5], data[i * PATH_SIZE + 6], data[i * PATH_SIZE + 7], data[i * PATH_SIZE + 8], data[i * PATH_SIZE + 9], data[i * PATH_SIZE + 10], data[i * PATH_SIZE + 11], data[i * PATH_SIZE + 12]); - else if (data[i * PATH_SIZE] == PATH_B) - printf("PATH B: %d %d %d %d %d %d %d %d %d %d %d %d\n", data[i * PATH_SIZE + 1], data[i * PATH_SIZE + 2], data[i * PATH_SIZE + 3], data[i * PATH_SIZE + 4], data[i * PATH_SIZE + 5], data[i * PATH_SIZE + 6], data[i * PATH_SIZE + 7], data[i * PATH_SIZE + 8], data[i * PATH_SIZE + 9], data[i * PATH_SIZE + 10], data[i * PATH_SIZE + 11], data[i * PATH_SIZE + 12]); - else if (data[i * PATH_SIZE] == PATH_AB) - printf("PATH A+B: %d %d %d %d %d %d %d %d %d %d %d %d\n", data[i * PATH_SIZE + 1], data[i * PATH_SIZE + 2], data[i * PATH_SIZE + 3], data[i * PATH_SIZE + 4], data[i * PATH_SIZE + 5], data[i * PATH_SIZE + 6], data[i * PATH_SIZE + 7], data[i * PATH_SIZE + 8], data[i * PATH_SIZE + 9], data[i * PATH_SIZE + 10], data[i * PATH_SIZE + 11], data[i * PATH_SIZE + 12]); - } - printf("\n"); - done: if (buffer) free(buffer); @@ -13823,283 +1658,6 @@ done: return ret; } #endif /* #ifdef STA_SUPPORT */ - -/** - * @brief Set/Get beacon interval - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_beacon_interval(int argc, char *argv[]) -{ - int ret = 0, bcninterval = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc < 3 || argc > 4) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX bcninterval [#]\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: bcninterval fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Process result */ - memcpy(&bcninterval, buffer, sizeof(bcninterval)); - printf("Beacon interval is %d\n", bcninterval); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -/** - * @brief Get/Set inactivity timeout extend - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_inactivity_timeout_ext(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd; - int data[4]; - struct ifreq ifr; - - /* Check if arguments are valid */ - if ((argc != 3) && (argc != 6) && (argc != 7)) { - printf("ERR: Invalid arguments\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: inactivityto fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* GET operation */ - if (argc == 3) { - memset(data, 0, sizeof(data)); - memcpy(data, buffer, sizeof(data)); - printf("Timeout unit is %d us\n" - "Inactivity timeout for unicast data is %d ms\n" - "Inactivity timeout for multicast data is %d ms\n" - "Inactivity timeout for new Rx traffic is %d ms\n", - data[0], data[1], data[2], data[3]); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Get chnrgpwr - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -get_chnrgpwr(FILE * fp_raw, char *argv[], t_u8 *buffer, t_u16 len, - struct eth_priv_cmd *cmd) -{ - struct ifreq ifr; - mlan_ds_misc_chnrgpwr_cfg *chnrgpwr_cfg = NULL; - int i = 0; - int j = 0; - - memset(buffer, 0, len); - /* Insert command */ - strncpy((char *)buffer, argv[2], strlen(argv[2])); - chnrgpwr_cfg = (mlan_ds_misc_chnrgpwr_cfg *) (buffer + strlen(argv[2])); - if (cmd) { - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = len; - } - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: get_chnrgpwr fail\n"); - return MLAN_STATUS_FAILURE; - } - /* Process result */ - printf("Get region channel power table: len=%d\n", - chnrgpwr_cfg->length); - if (fp_raw) { - i = j = 0; - while (i < chnrgpwr_cfg->length) { - for (j = 0; j < 16; j++) { - fprintf(fp_raw, "%02x ", - chnrgpwr_cfg->chnrgpwr_buf[i]); - if (++i >= chnrgpwr_cfg->length) - break; - } - fputc('\n', fp_raw); - } - } - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process Get region code channel power - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_get_chnrgpwr(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - int ret = MLAN_STATUS_SUCCESS; - FILE *fp_raw = NULL; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(sizeof(mlan_ds_misc_chnrgpwr_cfg) + - strlen(argv[2])); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, sizeof(mlan_ds_misc_chnrgpwr_cfg) + strlen(argv[2])); - /* Sanity tests */ - if (argc < 4) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX/uapX get_chnrgpwr logfile_name\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - fp_raw = fopen(argv[3], "w"); - if (fp_raw == NULL) { - fprintf(stderr, - "Cannot open the destination raw_data file %s\n", - argv[4]); - ret = MLAN_STATUS_FAILURE; - goto done; - } - ret = get_chnrgpwr(fp_raw, argv, buffer, - sizeof(mlan_ds_misc_chnrgpwr_cfg) + strlen(argv[2]), - cmd); -done: - if (fp_raw) - fclose(fp_raw); - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - /** * @brief Get txpwrlimit * @@ -14108,9 +1666,8 @@ done: * * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE */ -static int -get_txpwrlimit(FILE * fp_raw, char *argv[], t_u16 sub_band, t_u8 *buffer, - t_u16 len, struct eth_priv_cmd *cmd) +static int get_txpwrlimit(FILE *fp_raw, char *argv[], t_u16 sub_band, + t_u8 *buffer, t_u16 len, struct eth_priv_cmd *cmd) { struct ifreq ifr; mlan_ds_misc_chan_trpc_cfg *trcp_cfg = NULL; @@ -14125,7 +1682,7 @@ get_txpwrlimit(FILE * fp_raw, char *argv[], t_u16 sub_band, t_u8 *buffer, memset(buffer, 0, len); /* Insert command */ strncpy((char *)buffer, argv[2], strlen(argv[2])); - trcp_cfg = (mlan_ds_misc_chan_trpc_cfg *) (buffer + strlen(argv[2])); + trcp_cfg = (mlan_ds_misc_chan_trpc_cfg *)(buffer + strlen(argv[2])); trcp_cfg->sub_band = sub_band; if (cmd) { /* Fill up buffer */ @@ -14146,10 +1703,6 @@ get_txpwrlimit(FILE * fp_raw, char *argv[], t_u16 sub_band, t_u8 *buffer, if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { perror("mlanutl"); fprintf(stderr, "mlanutl: get_txpwrlimit fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); return MLAN_STATUS_FAILURE; } /* Process result */ @@ -14164,13 +1717,12 @@ get_txpwrlimit(FILE * fp_raw, char *argv[], t_u16 sub_band, t_u8 *buffer, switch (le16_to_cpu(pTlvHdr->header.type)) { case TLV_TYPE_CHAN_TRPC_CONFIG: - trpc_tlv = (MrvlIETypes_ChanTRPCConfig_t *) pTlvHdr; + trpc_tlv = (MrvlIETypes_ChanTRPCConfig_t *)pTlvHdr; printf("StartFreq: %d\n", trpc_tlv->start_freq); printf("ChanWidth: %d\n", trpc_tlv->width); printf("ChanNum: %d\n", trpc_tlv->chan_num); - mod_num = - (pTlvHdr->header.len - - 4) / sizeof(mod_group_setting); + mod_num = (pTlvHdr->header.len - 4) / + sizeof(mod_group_setting); printf("Pwr:"); for (i = 0; i < mod_num; i++) { if (i == (mod_num - 1)) @@ -14229,8 +1781,7 @@ get_txpwrlimit(FILE * fp_raw, char *argv[], t_u16 sub_band, t_u8 *buffer, * * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE */ -static int -process_get_txpwrlimit(int argc, char *argv[]) +static int process_get_txpwrlimit(int argc, char *argv[]) { t_u8 *buffer = NULL; struct eth_priv_cmd *cmd = NULL; @@ -14278,32 +1829,50 @@ process_get_txpwrlimit(int argc, char *argv[]) case 0x12: ret = get_txpwrlimit(fp_raw, argv, sub_band, buffer, sizeof(mlan_ds_misc_chan_trpc_cfg) + - strlen(argv[2]), cmd); + strlen(argv[2]), + cmd); break; case 0x1f: ret = get_txpwrlimit(fp_raw, argv, 0x10, buffer, sizeof(mlan_ds_misc_chan_trpc_cfg) + - strlen(argv[2]), cmd); + strlen(argv[2]), + cmd); + if (ret) + break; ret = get_txpwrlimit(fp_raw, argv, 0x11, buffer, sizeof(mlan_ds_misc_chan_trpc_cfg) + - strlen(argv[2]), cmd); + strlen(argv[2]), + cmd); + if (ret) + break; ret = get_txpwrlimit(fp_raw, argv, 0x12, buffer, sizeof(mlan_ds_misc_chan_trpc_cfg) + - strlen(argv[2]), cmd); + strlen(argv[2]), + cmd); break; case 0xff: ret = get_txpwrlimit(fp_raw, argv, 0, buffer, sizeof(mlan_ds_misc_chan_trpc_cfg) + - strlen(argv[2]), cmd); + strlen(argv[2]), + cmd); + if (ret) + break; ret = get_txpwrlimit(fp_raw, argv, 0x10, buffer, sizeof(mlan_ds_misc_chan_trpc_cfg) + - strlen(argv[2]), cmd); + strlen(argv[2]), + cmd); + if (ret) + break; ret = get_txpwrlimit(fp_raw, argv, 0x11, buffer, sizeof(mlan_ds_misc_chan_trpc_cfg) + - strlen(argv[2]), cmd); + strlen(argv[2]), + cmd); + if (ret) + break; ret = get_txpwrlimit(fp_raw, argv, 0x12, buffer, sizeof(mlan_ds_misc_chan_trpc_cfg) + - strlen(argv[2]), cmd); + strlen(argv[2]), + cmd); break; default: printf("Error: invalid arguments\n"); @@ -14320,6056 +1889,6 @@ done: return ret; } -/** - * @brief get hostcmd data - * - * @param ln A pointer to line number - * @param buf A pointer to hostcmd data - * @param size A pointer to the return size of hostcmd buffer - * @return MLAN_STATUS_SUCCESS - */ -static int -get_hostcmd_raw_data(FILE * fp, int *ln, t_u8 *buf, t_u16 *size) -{ - char line[512], *pos; - char *ptr = NULL; - t_u8 *dptr = NULL; - - dptr = buf; - while ((pos = mlan_config_get_line(fp, line, sizeof(line), ln))) { - (*ln)++; - if (strcmp(pos, "}") == 0) { - break; - } - ptr = line; - while (*ptr) { - /* skip leading spaces */ - while (*ptr && (isspace(*ptr) || *ptr == '\t')) - ptr++; - - /* skip blank lines and lines beginning with '#' */ - if (*ptr == '\0' || *ptr == '#') - break; - - if (isxdigit(*ptr)) { - ptr = convert2hex(ptr, dptr++); - } else { - /* Invalid character on data line */ - ptr++; - } - } - } - *size = dptr - buf; - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief parse the trpc command raw data and fill in trpc table. - * - * @param trpc_raw_data trpc hostcmd raw data - * @param length total length of trcp raw data - * @param trcp_buf trpc table buffer - * @param max_chan max channel number support in trpc table - * @param chan_idx index in trcp table - * @param cmd_no buffer pointer to return cmd_no - * @param cmd_act buffer pointer to return cmd_action. - * @return next index in trpc table - */ -int -parse_trpc_raw_data(t_u8 *trpc_raw_data, t_u16 length, t_u8 *trpc_buf, - t_u8 max_chan, int *chan_idx, t_u16 *cmd_no, t_u16 *cmd_act) -{ - MrvlIETypes_ChanTRPCConfig_t *trpc_tlv = NULL; - MrvlIEtypes_Data_t *pTlvHdr; - int left_len; - t_u8 *pByte = NULL; - int idx = *chan_idx; - ChanTRPCConfig_t *pchan_trpc = - (ChanTRPCConfig_t *) ((t_u8 *)trpc_buf + - idx * sizeof(ChanTRPCConfig_t)); - *cmd_no = le16_to_cpu(*(t_u16 *)trpc_raw_data); - *cmd_act = le16_to_cpu(*(t_u16 *)(trpc_raw_data + S_DS_GEN)); - - pByte = trpc_raw_data + S_DS_GEN + 4; - left_len = length - S_DS_GEN - 4; - while (left_len >= sizeof(pTlvHdr->header)) { - if (idx >= max_chan) { - printf("trpc buf too small, idx=%d\n", idx); - break; - } - pTlvHdr = (MrvlIEtypes_Data_t *)pByte; - pTlvHdr->header.len = le16_to_cpu(pTlvHdr->header.len); - - switch (le16_to_cpu(pTlvHdr->header.type)) { - case TLV_TYPE_CHAN_TRPC_CONFIG: - trpc_tlv = (MrvlIETypes_ChanTRPCConfig_t *) pTlvHdr; - memset(pchan_trpc->mod_group, 0xff, - sizeof(pchan_trpc->mod_group)); - memcpy(&pchan_trpc->start_freq, &trpc_tlv->start_freq, - pTlvHdr->header.len); - idx++; - pchan_trpc++; - break; - default: - break; - } - left_len -= (pTlvHdr->header.len + sizeof(pTlvHdr->header)); - pByte += pTlvHdr->header.len + sizeof(pTlvHdr->header); - } - *chan_idx = idx; - return idx; -} - -/** - * @brief get trpc data from file and fill in trpc table. - * - * @param fp file handle for trpc file - * @param trpc_buf trpc table buffer - * @param max_chan max channel supported in trpc table - * @param get_flag only allow action get in the raw data - * @return num_of channel filled in trpc table - */ -int -get_trpc_data(FILE * fp, t_u8 *trpc_buf, t_u8 max_chan, t_u8 get_flag) -{ - char line[256], *pos; - int ln = 0; - t_u8 *buffer = NULL; - t_u16 size = BUFFER_LENGTH; - int chan_idx = 0; - t_u16 cmd_act = 0; - t_u16 cmd_no = 0; - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - goto done; - } - while ((pos = mlan_config_get_line(fp, line, sizeof(line), &ln))) { - if (strstr(pos, "={")) { - get_hostcmd_raw_data(fp, &ln, buffer, &size); - parse_trpc_raw_data(buffer, size, trpc_buf, max_chan, - &chan_idx, &cmd_no, &cmd_act); - if (cmd_no != HostCmd_CHANNEL_TRPC_CONFIG) { - chan_idx = 0; - printf("Invalid cmd_no 0x%x cmd act=%d in file\n", cmd_no, (int)cmd_act); - break; - } - } - } -done: - if (buffer) - free(buffer); - return chan_idx; -} - -/** - * @brief find the same chanTrpc on another table - * - * @param trpc_buf trpc table buffer - * @param nun_chan num of chan in trpc table buffer - * @param chan channel number - * @return NULL or find chan_trpc entry in the table - */ -ChanTRPCConfig_t * -get_trpc_entry(t_u8 *trpc_buf, t_u8 num_chan, t_u8 chan) -{ - int i = 0; - int find = 0; - ChanTRPCConfig_t *pentry; - pentry = (ChanTRPCConfig_t *) trpc_buf; - for (i = 0; i < num_chan; i++) { - if (pentry->chan_num == chan) { - find = 1; - break; - } - pentry++; - } - if (find) - return pentry; - else - return NULL; -} - -/** - * @brief get max mod_group in trpbc table - * - * @param trpc_buf trpc table buffer - * @param nun_chan num of chan in trpc table buffer - * @return max mod_group number - */ -t_u8 -get_max_mod_group(t_u8 *trpc_buf, t_u8 num_chan) -{ - t_u8 max_mod_group = 0; - int i, j; - ChanTRPCConfig_t *pentry; - pentry = (ChanTRPCConfig_t *) trpc_buf; - for (i = 0; i < num_chan; i++) { - for (j = 0; j < MAX_MOD_GROUP; j++) { - if (pentry->mod_group[j].mod_group == 0xff) - break; - if (pentry->mod_group[j].mod_group > max_mod_group) - max_mod_group = pentry->mod_group[j].mod_group; - } - pentry++; - } - return max_mod_group; -} - -/** - * @brief get mod_group setting for specifc mod_group - * - * @param pchan_trpc a pointer to channel trpc setting - * @param pmod_group a point to mod_group setting. - * @return NULL or the pointer to specfic mod_group setting. - */ -mod_group_setting * -get_chan_mod_group(ChanTRPCConfig_t * pchan_trpc, - mod_group_setting * pmod_group) -{ - int i; - for (i = 0; i < MAX_MOD_GROUP; i++) { - if (pchan_trpc->mod_group[i].mod_group == 0xff) - break; - if (pmod_group->mod_group == pchan_trpc->mod_group[i].mod_group) { - return &pchan_trpc->mod_group[i]; - } - } - return NULL; -} - -/** - * @brief get the power for specifc mod_group - * - * @param pchan_trpc a pointer to channel trpc setting - * @param pmod_group mod group value - * @return the power of specific mod group. - */ -t_u8 -get_mod_power(ChanTRPCConfig_t * pchan_trpc, t_u8 mod_group) -{ - int i; - for (i = 0; i < MAX_MOD_GROUP; i++) { - if (pchan_trpc->mod_group[i].mod_group == 0xff) - break; - if (pchan_trpc->mod_group[i].mod_group == mod_group) { - return pchan_trpc->mod_group[i].power; - } - } - return 0xff; -} - -/** - * @brief compare to chan_trpc entry - * - * @param psrc_entry pointer to chan_trpc entry in src file - * @param ptarget_entry pointer to the target chan_trpc entry to compare - * @return 0 - match or 1 - */ -int -check_chan_trpc_error(ChanTRPCConfig_t * psrc_entry, - ChanTRPCConfig_t * ptarget_entry, t_u8 min_mod_group, - t_u8 max_mod_group) -{ - int diff = 0; - int i = 0; - mod_group_setting *pmod_group = NULL; - if (psrc_entry->start_freq != ptarget_entry->start_freq) - diff++; - if (psrc_entry->width != ptarget_entry->width) - diff++; - for (i = min_mod_group; i <= max_mod_group; i++) { - if (psrc_entry->mod_group[i].mod_group == 0xff) - break; - pmod_group = - get_chan_mod_group(ptarget_entry, - &psrc_entry->mod_group[i]); - if (!pmod_group) - diff++; - else if (pmod_group->power != psrc_entry->mod_group[i].power) - diff++; - } - if (diff) - return 1; - else - return 0; -} - -/** - * @brief display and compare to chan_trpc entry - * - * @param psrc_entry pointer to chan_trpc entry in src file - * @param ptarget_entry pointer to the target chan_trpc entry to compare - * @return 0 - match or 1 - */ -int -compare_and_display_chan_trpc(ChanTRPCConfig_t * psrc_entry, - ChanTRPCConfig_t * ptarget_entry) -{ - int diff = 0; - int i = 0; - mod_group_setting *pmod_group = NULL; - if (psrc_entry && ptarget_entry) { - if (psrc_entry->start_freq != ptarget_entry->start_freq) - diff++; - if (psrc_entry->width != ptarget_entry->width) - diff++; - for (i = 0; i < MAX_MOD_GROUP; i++) { - if (psrc_entry->mod_group[i].mod_group == 0xff) - break; - pmod_group = - get_chan_mod_group(ptarget_entry, - &psrc_entry->mod_group[i]); - if (pmod_group && - (pmod_group->power == - psrc_entry->mod_group[i].power)) { - printf("ch:%03d startfreq:%04d width:%02d mod:%02d power:%02d %02d PASS\n", (int)psrc_entry->chan_num, (int)psrc_entry->start_freq, (int)psrc_entry->width, (int)psrc_entry->mod_group[i].mod_group, (int)pmod_group->power, (int)psrc_entry->mod_group[i].power); - } else if (pmod_group) { - printf("ch:%03d startfreq:%04d width:%02d mod:%02d power:%02d %02d FAIL\n", (int)psrc_entry->chan_num, (int)psrc_entry->start_freq, (int)psrc_entry->width, (int)psrc_entry->mod_group[i].mod_group, (int)pmod_group->power, (int)psrc_entry->mod_group[i].power); - diff++; - } else { - printf("ch:%03d startfreq:%04d width:%02d mod:%02d power:%02d NOT FOUND\n", (int)psrc_entry->chan_num, (int)psrc_entry->start_freq, (int)psrc_entry->width, (int)psrc_entry->mod_group[i].mod_group, (int)psrc_entry->mod_group[i].power); - diff++; - } - } - } else if (psrc_entry) { - printf("-------------------------------------------------------------------------------------------\n"); - printf("Missing expected channel %d TRPC setting in target file\n", psrc_entry->chan_num); - printf("ch:%03d startfreq:%04d width:%02d Pwr:", - (int)psrc_entry->chan_num, (int)psrc_entry->start_freq, - (int)psrc_entry->width); - for (i = 0; i < MAX_MOD_GROUP; i++) { - if (psrc_entry->mod_group[i].mod_group == 0xff) - break; - if (i == 0) - printf("%d,%d", - psrc_entry->mod_group[i].mod_group, - psrc_entry->mod_group[i].power); - else - printf(",%d,%d", - psrc_entry->mod_group[i].mod_group, - psrc_entry->mod_group[i].power); - } - printf("\n"); - printf("-------------------------------------------------------------------------------------------\n"); - diff++; - } - if (diff) - return 1; - else - return 0; -} - -/** - * @brief get channel list in 2 trpc table - * - * @param target_trpc_buf trpc buf from target file - * @param target_chan_num num of channe in target file - * @param src_trpc_buf trpc buf from src file - * @param src_chan_num num of channel in src file - * @param chan_flag 0- all channel 1--5g only - * @return num of total channel in src trpc buf and target trpc buf -*/ -int -get_trpc_channel_list(t_u8 *target_trpc_buf, t_u8 target_chan_num, - t_u8 *src_trpc_buf, t_u8 src_chan_num, t_u8 *pchan, - t_u8 chan_size, t_u8 chan_flag) -{ - ChanTRPCConfig_t *ptarget_entry = NULL; - ChanTRPCConfig_t *psrc_entry = NULL; - int target_chan_left = target_chan_num; - int src_chan_left = src_chan_num; - int total_chan = 0; - int i = 0; - - memset(pchan, 0, chan_size); - ptarget_entry = (ChanTRPCConfig_t *) target_trpc_buf; - psrc_entry = (ChanTRPCConfig_t *) src_trpc_buf; - - if (chan_flag) { - for (i = 0; i < target_chan_num; i++) { - if (ptarget_entry->chan_num > MAX_BG_CHANNEL) - break; - ptarget_entry++; - target_chan_left--; - } - for (i = 0; i < src_chan_num; i++) { - if (psrc_entry->chan_num > MAX_BG_CHANNEL) - break; - psrc_entry++; - src_chan_left--; - } - if (src_chan_left <= 0) - psrc_entry = NULL; - if (target_chan_left <= 0) - ptarget_entry = NULL; - } - while (1) { - if (!target_chan_left && !src_chan_left) - break; - if (ptarget_entry && psrc_entry) { - if (ptarget_entry->chan_num == psrc_entry->chan_num) { - *pchan = ptarget_entry->chan_num; - pchan++; - total_chan++; - ptarget_entry++; - psrc_entry++; - target_chan_left--; - src_chan_left--; - } else if (ptarget_entry->chan_num < - psrc_entry->chan_num) { - *pchan = ptarget_entry->chan_num; - pchan++; - total_chan++; - ptarget_entry++; - target_chan_left--; - } else { - *pchan = psrc_entry->chan_num; - pchan++; - total_chan++; - psrc_entry++; - src_chan_left--; - } - } else if (ptarget_entry) { - *pchan = ptarget_entry->chan_num; - pchan++; - total_chan++; - ptarget_entry++; - target_chan_left--; - } else if (psrc_entry) { - *pchan = psrc_entry->chan_num; - pchan++; - total_chan++; - psrc_entry++; - src_chan_left--; - } - if (src_chan_left <= 0) - psrc_entry = NULL; - if (target_chan_left <= 0) - ptarget_entry = NULL; - } - return total_chan; -} - -/** - * @brief compare two trpc table's data - * - * @param target_trpc_buf trpc buf from target file - * @param target_chan_num num of channe in target file - * @param src_trpc_buf trpc buf from src file - * @param src_chan_num num of channel in src file - * @param dispaly mode 1: text mode, 2 table mode. - * @return N/A - */ -void -process_trpc_data(t_u8 *target_trpc_buf, t_u8 target_chan_num, - t_u8 *src_trpc_buf, t_u8 src_chan_num, t_u8 display_mode) -{ - int i, j; - t_u32 diff = 0; - t_u16 total_diff = 0; - t_u8 power_target; - t_u8 power_src; - t_u8 max_mod_group_target = 0; - t_u8 max_mod_group_src = 0; - t_u8 total_chan = 0; - t_u8 chan_list[WLAN_IOCTL_USER_SCAN_CHAN_MAX]; - ChanTRPCConfig_t *ptarget_entry = NULL; - ChanTRPCConfig_t *psrc_entry = NULL; - - printf("ModulationGroup:\n"); - printf(" 0: CCK (1,2,5.5,11 Mbps) 1: OFDM (6,9,12,18 Mbps)\n"); - printf(" 2: OFDM (24,36 Mbps) 3: OFDM (48,54 Mbps)\n"); - printf(" 4: HT20 (MCS0,1,2) 5: HT20 (MCS3,4)\n"); - printf(" 6: HT20 (MCS5,6,7) 7: HT40 (MCS0,1,2)\n"); - printf(" 8: HT40 (MCS3,4) 9: HT40 (MCS5,6,7)\n"); - printf("10: HT2_20 (MCS8,9,10) 11: HT2_20 (MCS11,12)\n"); - printf("12: HT2_20 (MCS13,14,15) 13: HT2_40 (MCS8,9,10)\n"); - printf("14: HT2_40 (MCS11,12) 15: HT2_40 (MCS13,14,15)\n"); - printf("16: VHT_QAM256 (MCS8) 17: VHT_40_QAM256 (MCS8,9)\n"); - printf("18: VHT_80_PSK (MCS0,1,2) 19: VHT_80_QAM16 (MCS3,4)\n"); - printf("20: VHT_80_QAM64 (MCS5,6,7) 21: VHT_80_QAM256 (MCS8,9)\n"); - printf("22: VHT2_20_QAM256 (MCS8) 23: VHT2_40_QAM256 (MCS8,9)\n"); - printf("24: VHT2_80_PSK (MCS0,1,2) 25: VHT2_80_QAM16 (MCS3,4)\n"); - printf("26: VHT2_80_QAM64 (MCS5,6,7) 27: VHT2_80_QAM256 (MCS8,9)\n"); - printf("28: HE_20_QAM256 (MCS8,9) 29: HE_20_QAM1024 (MCS10,11)\n"); - printf("30: HE_40_QAM1024 (MCS10,11) 31: HE_80_QAM1024 (MCS10,11)\n"); - printf("32: HE2_20_QAM256 (MCS8,9) 33: HE2_20_QAM1024 (MCS10,11)\n"); - printf("34: HE2_40_QAM1024 (MCS10,11) 35: HE2_80_QAM1024 (MCS10,11)\n"); - printf("\n"); - if (display_mode == 1) { - psrc_entry = (ChanTRPCConfig_t *) src_trpc_buf; - for (i = 0; i < src_chan_num; i++) { - ptarget_entry = - get_trpc_entry(target_trpc_buf, target_chan_num, - psrc_entry->chan_num); - if (ptarget_entry) { - diff += compare_and_display_chan_trpc - (psrc_entry, ptarget_entry); - } else { - diff += compare_and_display_chan_trpc - (psrc_entry, NULL); - } - psrc_entry++; - } - if (diff) - printf("Number of different channel trpc setting:%d in target file\n", diff); - else - printf("PASS\n"); - } else { - printf("Column=ModGroup, Row=Channel, Value=Target,Source\n"); - printf(" CH 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15\n"); - ptarget_entry = (ChanTRPCConfig_t *) target_trpc_buf; - total_chan = - get_trpc_channel_list(target_trpc_buf, target_chan_num, - src_trpc_buf, src_chan_num, - chan_list, - WLAN_IOCTL_USER_SCAN_CHAN_MAX, 0); - for (i = 0; i < total_chan; i++) { - ptarget_entry = - get_trpc_entry(target_trpc_buf, target_chan_num, - chan_list[i]); - psrc_entry = - get_trpc_entry(src_trpc_buf, src_chan_num, - chan_list[i]); - diff = 0; - if (psrc_entry && ptarget_entry) - diff = check_chan_trpc_error(psrc_entry, - ptarget_entry, 0, - 15); - else if (psrc_entry) - diff++; - if (diff) - printf("*%03d ", (int)chan_list[i]); - else - printf(" %03d ", (int)chan_list[i]); - for (j = 0; j <= 15; j++) { - if (ptarget_entry) - power_target = - get_mod_power(ptarget_entry, j); - else - power_target = 0xff; - if (psrc_entry) - power_src = - get_mod_power(psrc_entry, j); - else - power_src = 0xff; - if (power_target != 0xff) - printf("%02d", power_target); - else - printf("--"); - if (power_src != 0xff) - printf(",%02d ", power_src); - else - printf(",-- "); - } - if (diff) - total_diff++; - printf("\n"); - } - max_mod_group_target = - get_max_mod_group(target_trpc_buf, target_chan_num); - max_mod_group_src = - get_max_mod_group(src_trpc_buf, src_chan_num); - if (max_mod_group_target > 15 || max_mod_group_src > 15) { - printf(" CH 16 17 18 19 20 21 22 23 24 25 26 27\n"); - ptarget_entry = (ChanTRPCConfig_t *) target_trpc_buf; - total_chan = - get_trpc_channel_list(target_trpc_buf, - target_chan_num, - src_trpc_buf, - src_chan_num, chan_list, - WLAN_IOCTL_USER_SCAN_CHAN_MAX, - 1); - for (i = 0; i < total_chan; i++) { - diff = 0; - ptarget_entry = - get_trpc_entry(target_trpc_buf, - target_chan_num, - chan_list[i]); - psrc_entry = - get_trpc_entry(src_trpc_buf, - src_chan_num, - chan_list[i]); - if (psrc_entry && ptarget_entry) - diff = check_chan_trpc_error(psrc_entry, - ptarget_entry, - 16, 27); - else if (psrc_entry) - diff++; - if (diff) - printf("*%03d ", (int)chan_list[i]); - else - printf(" %03d ", (int)chan_list[i]); - - for (j = 16; j <= 27; j++) { - if (ptarget_entry) - power_target = - get_mod_power - (ptarget_entry, j); - else - power_target = 0xff; - if (psrc_entry) - power_src = - get_mod_power - (psrc_entry, j); - else - power_src = 0xff; - if (power_target != 0xff) - printf("%02d", power_target); - else - printf("--"); - if (power_src != 0xff) - printf(",%02d ", power_src); - else - printf(",-- "); - } - if (diff) - total_diff++; - printf("\n"); - } - } - max_mod_group_target = - get_max_mod_group(target_trpc_buf, target_chan_num); - max_mod_group_src = - get_max_mod_group(src_trpc_buf, src_chan_num); - if (max_mod_group_target > 27 || max_mod_group_src > 27) { - printf(" CH 28 29 30 31 32 33 34 35\n"); - ptarget_entry = (ChanTRPCConfig_t *) target_trpc_buf; - total_chan = - get_trpc_channel_list(target_trpc_buf, - target_chan_num, - src_trpc_buf, - src_chan_num, chan_list, - WLAN_IOCTL_USER_SCAN_CHAN_MAX, - 1); - for (i = 0; i < total_chan; i++) { - diff = 0; - ptarget_entry = - get_trpc_entry(target_trpc_buf, - target_chan_num, - chan_list[i]); - psrc_entry = - get_trpc_entry(src_trpc_buf, - src_chan_num, - chan_list[i]); - if (psrc_entry && ptarget_entry) - diff = check_chan_trpc_error(psrc_entry, - ptarget_entry, - 16, 27); - else if (psrc_entry) - diff++; - if (diff) - printf("*%03d ", (int)chan_list[i]); - else - printf(" %03d ", (int)chan_list[i]); - - for (j = 28; j <= 35; j++) { - if (ptarget_entry) - power_target = - get_mod_power - (ptarget_entry, j); - else - power_target = 0xff; - if (psrc_entry) - power_src = - get_mod_power - (psrc_entry, j); - else - power_src = 0xff; - if (power_target != 0xff) - printf("%02d", power_target); - else - printf("--"); - if (power_src != 0xff) - printf(",%02d ", power_src); - else - printf(",-- "); - } - if (diff) - total_diff++; - printf("\n"); - } - } - if (total_diff) - printf("Number of different channel trpc setting:%d in target file\n", total_diff); - else - printf("PASS\n"); - } - - return; -} - -/** - * @brief Process compare the trpc from 2 bin file - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_comparetrpc(int argc, char *argv[]) -{ - FILE *target_fp = NULL; - FILE *src_fp = NULL; - int ret = MLAN_STATUS_SUCCESS; - t_u8 *target_trpc_buf = NULL; - t_u8 *src_trpc_buf = NULL; - t_u8 target_chan_num = WLAN_IOCTL_USER_SCAN_CHAN_MAX; - t_u8 src_chan_num = WLAN_IOCTL_USER_SCAN_CHAN_MAX; - int display_mode = 1; - - if (argc < 5) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX/uapX comparetrpc target_file src_file 1/2\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - if (argc == 6) { - display_mode = a2hex_or_atoi(argv[5]); - if (display_mode != 1 && display_mode != 2) { - printf("Error: invalid display mode\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - } - target_fp = fopen(argv[3], "r"); - if (target_fp == NULL) { - perror("target file fopen failed"); - goto done; - } - target_trpc_buf = - (t_u8 *)malloc(sizeof(ChanTRPCConfig_t) * - WLAN_IOCTL_USER_SCAN_CHAN_MAX); - if (!target_trpc_buf) { - printf("ERR:Cannot allocate buffer for target trpc buf!\n"); - goto done; - } - memset(target_trpc_buf, 0, - sizeof(ChanTRPCConfig_t) * WLAN_IOCTL_USER_SCAN_CHAN_MAX); - target_chan_num = - get_trpc_data(target_fp, target_trpc_buf, - WLAN_IOCTL_USER_SCAN_CHAN_MAX, 1); - if (!target_chan_num) { - printf("Invalid target file %s: it should be the raw data file save from get_txpwrlimit command\n", argv[3]); - goto done; - } - src_fp = fopen(argv[4], "r"); - if (src_fp == NULL) { - perror("src file fopen failed"); - goto done; - } - src_trpc_buf = - (t_u8 *)malloc(sizeof(ChanTRPCConfig_t) * - WLAN_IOCTL_USER_SCAN_CHAN_MAX); - if (!src_trpc_buf) { - printf("ERR:Cannot allocate buffer for src trpc buf!\n"); - goto done; - } - memset(src_trpc_buf, 0, - sizeof(ChanTRPCConfig_t) * WLAN_IOCTL_USER_SCAN_CHAN_MAX); - src_chan_num = - get_trpc_data(src_fp, src_trpc_buf, - WLAN_IOCTL_USER_SCAN_CHAN_MAX, 0); - if (!src_chan_num) { - printf("Invalid source file %s: it should be raw data file download to FW during driver init\n", argv[4]); - goto done; - } - printf("Comparing %s to %s\n", argv[3], argv[4]); - process_trpc_data(target_trpc_buf, target_chan_num, src_trpc_buf, - src_chan_num, display_mode); -done: - if (target_fp) - fclose(target_fp); - if (target_trpc_buf) - free(target_trpc_buf); - if (src_fp) - fclose(src_fp); - if (src_trpc_buf) - free(src_trpc_buf); - return ret; -} - -/** - * @brief get source region power data and fill in region power table. - * - * @param fp file handle for region power file - * @param file_size file size; - * @param src_rgpwr_buf power table buffer - - * @return 0 -- success else failure - */ -int -get_src_rgpwr_data(FILE * src_fp, int file_size, - region_chan_pwr_tbl * rgchnpwr_tbl) -{ - t_u8 *tmp_buf = NULL; - int ret = 0; - t_u8 *pdata = NULL; - int left_size = file_size; - mfg_rghdr_t *rghdr = NULL; - mfg_rgdatahdr_t *rgdatahdr = NULL; - int max_chan_bg = 14; - int max_chan_a = 0; - int max_power_bg = 0; - int max_power_a = 0; - int i = 0; - - tmp_buf = (t_u8 *)malloc(file_size); - if (!tmp_buf) { - printf("fail to alloc temp buf, size=%d\n", file_size); - return -EFAULT; - } - if (fread(tmp_buf, sizeof(t_u8), file_size, src_fp) == 0) { - printf("ERR:read source image failed!\n"); - ret = -EFAULT; - goto done; - } - //hexdump("Uncompressed data", tmp_buf, file_size, ' '); - pdata = tmp_buf; - rghdr = (mfg_rghdr_t *) pdata; - if (rghdr->identifier != OTP_IDENTIFIER) { - ret = -EFAULT; - printf("ERR: Invalid identifier in uncompressed file 0x%x\n", - rghdr->identifier); - goto done; - } - rgchnpwr_tbl->ptbaseversion = rghdr->ptbaseversion; - left_size -= sizeof(mfg_rghdr_t); - pdata += sizeof(mfg_rghdr_t); - rgdatahdr = (mfg_rgdatahdr_t *) pdata; - memcpy(&rgchnpwr_tbl->countrycode, &rgdatahdr->countrycode, - sizeof(rgchnpwr_tbl->countrycode)); - rgchnpwr_tbl->environment = rgdatahdr->environment; - rgchnpwr_tbl->regioncode = rgdatahdr->regioncode; - left_size -= sizeof(mfg_rgdatahdr_t); - pdata += sizeof(mfg_rgdatahdr_t); - switch (rghdr->ptbaseversion) { - case PTVER_2X2_AC: - max_chan_a = 39; - max_power_a = 28; - max_power_bg = 16; - break; - case PTVER_1X1_AC: - max_chan_a = 39; - max_power_a = 16; - max_power_bg = 10; - break; - case PTVER_2X2_N: - max_chan_a = 39; - max_power_a = 16; - max_power_bg = 16; - break; - case PTVER_1X1_N: - max_chan_a = 39; - max_power_a = 10; - max_power_bg = 10; - break; - case PTVER_1X1_AC_11P: - max_chan_a = 40; - max_power_a = 16; - max_power_bg = 10; - break; - case PTVER_2X2_AC_2GVHT: - max_chan_a = 39; - max_power_a = 28; - max_power_bg = 24; - break; - case PTVER_1X1_AC_2GVHT: - max_chan_a = 39; - max_power_a = 16; - max_power_bg = 12; - break; - case PTVER_1X1_AC_2GVHT_11P: - max_chan_a = 40; - max_power_a = 16; - max_power_bg = 12; - break; - } - rgchnpwr_tbl->max_chan_bg = max_chan_bg; - rgchnpwr_tbl->max_chan_a = max_chan_a; - rgchnpwr_tbl->max_power_a = max_power_a; - rgchnpwr_tbl->max_power_bg = max_power_bg; - if (left_size < ((max_power_bg + 1) * max_chan_bg)) { - printf("ERR: left size not enough for 2g\n"); - goto done; - } - for (i = 0; i < max_chan_bg; i++) { - rgchnpwr_tbl->bg_pwr_tbl[i].chan_no = *pdata; - pdata++; - memset(rgchnpwr_tbl->bg_pwr_tbl[i].pwr, 0xff, - MAX_MCS_POWER_INDEX); - memcpy(rgchnpwr_tbl->bg_pwr_tbl[i].pwr, pdata, max_power_bg); - pdata += max_power_bg; - } - left_size -= (max_power_bg + 1) * max_chan_bg; - if (left_size < ((max_power_a + 1) * max_chan_a)) { - printf("ERR: left size not enough for 5g\n"); - goto done; - } - for (i = 0; i < max_chan_a; i++) { - rgchnpwr_tbl->a_pwr_tbl[i].chan_no = *pdata; - pdata++; - memset(rgchnpwr_tbl->a_pwr_tbl[i].pwr, 0xff, - MAX_MCS_POWER_INDEX); - memcpy(rgchnpwr_tbl->a_pwr_tbl[i].pwr, pdata, max_power_a); - pdata += max_power_a; - } - left_size -= (max_power_a + 1) * max_chan_a; - if (left_size < max_chan_bg + max_chan_a) { - printf("ERR: left size not enough for chan attr\n"); - goto done; - } - for (i = 0; i < max_chan_bg; i++) { - rgchnpwr_tbl->bg_pwr_tbl[i].chan_attr = *pdata; - pdata++; - } - for (i = 0; i < max_chan_a; i++) { - rgchnpwr_tbl->a_pwr_tbl[i].chan_attr = *pdata; - pdata++; - } - left_size -= max_chan_bg + max_chan_a; - if (left_size) - printf("ERR: left_size=%d\n", left_size); -done: - if (tmp_buf) - free(tmp_buf); - return ret; -} - -/** - * @brief get FW region power table - * - * @param fp file handle for region power file - * @param rgchnpwr_tbl a pointer to regchnpwr tbl - * - * @return 0 -- success else failure - */ -int -get_fw_rgpwr_data(FILE * fp, region_chan_pwr_tbl * rgchnpwr_tbl) -{ - int ln = 0; - int i; - t_u8 *buffer = NULL; - t_u8 *tlv_buf = NULL; - t_u16 size = BUFFER_LENGTH; - int ret = 0; - HostCmd_DS_GEN *hostcmd = NULL; - t_u16 tlv_buf_left = 0; - t_u16 tlv_type, tlv_len; - MrvlIEtypesHeader_t *tlv; - MrvlIEtypes_otp_region_info_t *rginfo_tlv; - MrvlIEtypes_power_table_attr_t *pwr_tbl_attr_tlv; - MrvlIEtypes_chan_attr_t *chan_attr_tlv; - MrvlIEtypes_power_table_t *power_tlv; - t_u8 *pdata = NULL; - chan_power_t *power = NULL; - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - goto done; - } - get_hostcmd_raw_data(fp, &ln, buffer, &size); - //hexdump("cmdresp", buffer,size, ' '); - hostcmd = (HostCmd_DS_GEN *)buffer; - hostcmd->command = le16_to_cpu(hostcmd->command); - hostcmd->size = le16_to_cpu(hostcmd->size); - if (hostcmd->command != HostCmd_CMD_CHAN_REGION_CFG) { - printf("ERR: target file don't have the hostcmd id 0x242\n"); - ret = -EFAULT; - goto done; - } - tlv_buf_left = hostcmd->size - S_DS_GEN - sizeof(t_u16); - tlv_buf = buffer + S_DS_GEN + sizeof(t_u16); - while (tlv_buf_left >= sizeof(MrvlIEtypesHeader_t)) { - tlv = (MrvlIEtypesHeader_t *)tlv_buf; - tlv_type = le16_to_cpu(tlv->type); - tlv_len = le16_to_cpu(tlv->len); - switch (tlv_type) { - case TLV_TYPE_POWER_TABLE_ATTR: - pwr_tbl_attr_tlv = - (MrvlIEtypes_power_table_attr_t *) tlv_buf; - rgchnpwr_tbl->max_chan_bg = pwr_tbl_attr_tlv->rows_bg; - rgchnpwr_tbl->max_power_bg = - pwr_tbl_attr_tlv->cols_bg - 1; - rgchnpwr_tbl->max_chan_a = pwr_tbl_attr_tlv->rows_a; - rgchnpwr_tbl->max_power_a = - pwr_tbl_attr_tlv->cols_a - 1; - break; - case TLV_TYPE_REGION_INFO: - rginfo_tlv = (MrvlIEtypes_otp_region_info_t *) tlv_buf; - memcpy(&rgchnpwr_tbl->countrycode, - &rginfo_tlv->countrycode, - sizeof(rgchnpwr_tbl->countrycode)); - rgchnpwr_tbl->regioncode = rginfo_tlv->regioncode; - rgchnpwr_tbl->environment = rginfo_tlv->environment; - break; - case TLV_TYPE_CHAN_ATTR_CFG: - chan_attr_tlv = (MrvlIEtypes_chan_attr_t *) tlv_buf; - if (tlv_len < - ((rgchnpwr_tbl->max_chan_a + - rgchnpwr_tbl->max_chan_bg) * - sizeof(chan_attr_t))) { - printf("ERR: Invalid chan attr tlv\n"); - hexdump("chan attrib tlv", tlv_buf, - tlv_len + sizeof(MrvlIEtypesHeader_t), - ' '); - ret = -EFAULT; - goto done; - } - for (i = 0; i < rgchnpwr_tbl->max_chan_bg; i++) { - if (!chan_attr_tlv->chan_attr[i].chan_no) { - printf("ERR:Invalid chan attr tlv\n"); - hexdump("chan attrib tlv", tlv_buf, - tlv_len + - sizeof(MrvlIEtypesHeader_t), - ' '); - ret = -EFAULT; - goto done; - } - rgchnpwr_tbl->bg_pwr_tbl[i].chan_attr = - chan_attr_tlv->chan_attr[i].chan_attr; - rgchnpwr_tbl->bg_pwr_tbl[i].chan_no = - chan_attr_tlv->chan_attr[i].chan_no; - } - for (i = 0; i < rgchnpwr_tbl->max_chan_a; i++) { - rgchnpwr_tbl->a_pwr_tbl[i].chan_attr = - chan_attr_tlv->chan_attr[i + - rgchnpwr_tbl-> - max_chan_bg]. - chan_attr; - rgchnpwr_tbl->a_pwr_tbl[i].chan_no = - chan_attr_tlv->chan_attr[i + - rgchnpwr_tbl-> - max_chan_bg]. - chan_no; - } - break; - case TLV_TYPE_POWER_TABLE: - power_tlv = (MrvlIEtypes_power_table_t *) tlv_buf; - if (tlv_len < - (rgchnpwr_tbl->max_chan_bg * - (rgchnpwr_tbl->max_power_bg + 1) - + - rgchnpwr_tbl->max_chan_a * - (rgchnpwr_tbl->max_power_a + 1))) { - printf("ERR: Invalid power table tlv\n"); - hexdump("power table tlv", tlv_buf, - tlv_len + sizeof(MrvlIEtypesHeader_t), - ' '); - ret = -EFAULT; - goto done; - } - pdata = (t_u8 *)&power_tlv->chan_power; - for (i = 0; i < rgchnpwr_tbl->max_chan_bg; i++) { - power = (chan_power_t *) pdata; - if (!power->chan_no || - (rgchnpwr_tbl->bg_pwr_tbl[i].chan_no != - power->chan_no)) { - printf("ERR: Invalid power table tlv, channel miss match\n"); - hexdump("power table tlv", tlv_buf, - tlv_len + - sizeof(MrvlIEtypesHeader_t), - ' '); - ret = -EFAULT; - goto done; - } - memset(rgchnpwr_tbl->bg_pwr_tbl[i].pwr, 0xff, - sizeof(rgchnpwr_tbl->bg_pwr_tbl[i].pwr)); - memcpy(rgchnpwr_tbl->bg_pwr_tbl[i].pwr, - power->power, - rgchnpwr_tbl->max_power_bg); - pdata += rgchnpwr_tbl->max_power_bg + 1; - } - for (i = 0; i < rgchnpwr_tbl->max_chan_a; i++) { - power = (chan_power_t *) pdata; - if (rgchnpwr_tbl->a_pwr_tbl[i].chan_no != - power->chan_no) { - printf("ERR: Invalid power table tlv, channel miss match\n"); - hexdump("power table tlv", tlv_buf, - tlv_len + - sizeof(MrvlIEtypesHeader_t), - ' '); - ret = -EFAULT; - goto done; - } - memset(rgchnpwr_tbl->a_pwr_tbl[i].pwr, 0xff, - sizeof(rgchnpwr_tbl->a_pwr_tbl[i].pwr)); - memcpy(rgchnpwr_tbl->a_pwr_tbl[i].pwr, - power->power, rgchnpwr_tbl->max_power_a); - pdata += rgchnpwr_tbl->max_power_a + 1; - } - break; - } - tlv_buf += sizeof(MrvlIEtypesHeader_t) + tlv_len; - tlv_buf_left -= sizeof(MrvlIEtypesHeader_t) + tlv_len; - } -done: - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief display region_chan_pwr_table header - * - * @param tbl pointer to table - * @return void - */ -void -display_tbl_hdr(region_chan_pwr_tbl * tbl) -{ - printf("====================2G_Power_Index_Map=========================================\n"); - printf("Pwr index mapping Pwr index mapping \n"); - printf("===============================================================================\n"); - switch (tbl->ptbaseversion) { - case PTVER_1X1_AC: - case PTVER_1X1_N: - case PTVER_1X1_AC_11P: - printf(" 1 11b (11M - 1M) 2 11g (18M - 6M)\n"); - printf(" 3 11g (36M - 24M) 4 11g (54M - 48M)\n"); - printf(" 5 11n 20 (MCS2 - MCS0, 1x1) 6 11n 20 (MCS4 - MCS3, 1x1)\n"); - printf(" 7 11n 20 (MCS7 - MCS5, 1x1) 8 11n 40 (MCS2 - MCS0, 1x1)\n"); - printf(" 9 11n 40 (MCS4 - MCS3, 1x1) 10 11n 40 (MCS7 - MCS5, 1x1)\n"); - break; - case PTVER_2X2_N: - case PTVER_2X2_AC: - printf(" 1 11b (11M - 1M) 2 11g (18M - 6M)\n"); - printf(" 3 11g (36M - 24M) 4 11g (54M - 48M)\n"); - printf(" 5 11n 20 (MCS2 - MCS0, 1x1) 6 11n 20 (MCS4 - MCS3, 1x1)\n"); - printf(" 7 11n 20 (MCS7 - MCS5, 1x1) 8 11n 20 (MCS10 - MCS8, 2x2)\n"); - printf(" 9 11n 20 (MCS12 - MCS11, 2x2) 10 11n 20 (MCS15 - MCS13, 2x2)\n"); - printf("11 11n 40 (MCS2 - MCS0, 1x1) 12 11n 40 (MCS4 - MCS3, 1x1)\n"); - printf("13 11n 40 (MCS7 - MCS5, 1x1) 14 11n 40 (MCS10 - MCS8, 2x2)\n"); - printf("15 11n 40 (MCS12 - MCS11, 2x2) 16 11n 40 (MCS15 - MCS13, 2x2)\n"); - break; - case PTVER_1X1_AC_2GVHT: - case PTVER_1X1_AC_2GVHT_11P: - printf(" 1 11b (11M - 1M) 2 11g (18M - 6M)\n"); - printf(" 3 11g (36M - 24M) 4 11g (54M - 48M)\n"); - printf(" 5 11n 20 (MCS2 - MCS0, 1x1) 6 11n 20 (MCS4 - MCS3, 1x1)\n"); - printf(" 7 11n 20 (MCS7 - MCS5, 1x1) 8 11n 20 (MCS10 - MCS8, 2x2)\n"); - printf(" 9 11n 20 (MCS12 - MCS11, 2x2) 10 11n 40 (MCS2 - MCS0, 1x1)\n"); - printf(" 11 11n 40 (MCS4 - MCS3, 1x1) 12 11n 40 (MCS7 - MCS5, 1x1)\n"); - break; - case PTVER_2X2_AC_2GVHT: - printf(" 1 11b (11M - 1M) 2 11g (18M - 6M)\n"); - printf(" 3 11g (36M - 24M) 4 11g (54M - 48M)\n"); - printf(" 5 11n 20 (MCS2 - MCS0, 1x1) 6 11n 20 (MCS4 - MCS3, 1x1)\n"); - printf(" 7 11n 20 (MCS7 - MCS5, 1x1) 8 11n 20 (MCS10 - MCS8, 2x2)\n"); - printf(" 9 11n 20 (MCS12 - MCS11, 2x2) 10 11n 20 (MCS15 - MCS13, 2x2)\n"); - printf("11 11ac 20 (mcs8, 1x1) 12 11ac 20 (mcs9-mcs8, 2x2)\n"); - printf("13 11n 40 (MCS2 - MCS0, 1x1) 14 11n 40 (MCS4 - MCS3, 1x1)\n"); - printf("15 11n 40 (MCS7 - MCS5, 1x1) 16 11n 40 (MCS10 - MCS8, 2x2)\n"); - printf("17 11n 40 (MCS12 - MCS11, 2x2) 18 11ac 40 (mcs9-mcs8, 1x1)\n"); - printf("19 11ac 40 (mcs9-mcs8, 2x2) 20 11n 40 (MCS15 - MCS13, 2x2)\n"); - printf("21 11ac 80 (mcs2-mcs0, 1x1) 22 11ac 80 (mcs4 - mcs3, 1x1)\n"); - printf("23 11ac 80 (mcs7 - mcs5, 1x1) 24 11ac 80 (mcs9-8, 1x1)\n"); - break; - } - printf("====================5G_Power_Index_Map=========================================\n"); - printf("Pwr index mapping Pwr index mapping \n"); - printf("===============================================================================\n"); - switch (tbl->ptbaseversion) { - case PTVER_1X1_AC: - case PTVER_1X1_AC_11P: - case PTVER_1X1_AC_2GVHT: - case PTVER_1X1_AC_2GVHT_11P: - printf(" 1 11b (11M - 1M) 2 11a (18M - 6M)\n"); - printf(" 3 11a (36M - 24M) 4 11a (54M - 48M)\n"); - printf(" 5 11n 20 (MCS2 - MCS0, 1x1) 6 11n 20 (MCS4 - MCS3, 1x1)\n"); - printf(" 7 11n 20 (MCS7 - MCS5, 1x1) 8 11ac 20 (mcs8, 1x1)\n"); - printf(" 9 11n 40 (mcs2 - mcs0, 1x1) 10 11n 40 (mcs4 - mcs3, 1x1)\n"); - printf("11 11n 40 (mcs7 - mcs5, 1x1) 12 11ac 40 (mcs9-mcs8, 1x1)\n"); - printf("13 11ac 80 (mcs2-mcs0, 1x1) 14 11ac 80 (mcs4 - mcs3, 1x1)\n"); - printf("15 11ac 80 (mcs7 - mcs5, 1x1) 16 11ac 80 (mcs9-8, 1x1)\n"); - break; - case PTVER_1X1_N: - printf(" 1 11b (11M - 1M) 2 11a (18M - 6M)\n"); - printf(" 3 11a (36M - 24M) 4 11a (54M - 48M)\n"); - printf(" 5 11n 20 (MCS2 - MCS0, 1x1) 6 11n 20 (MCS4 - MCS3, 1x1)\n"); - printf(" 7 11n 20 (MCS7 - MCS5, 1x1) 8 11n 40 (mcs2 - mcs0, 1x1)\n"); - printf(" 9 11n 40 (mcs4 - mcs3, 1x1) 10 11n 40 (mcs7 - mcs5, 1x1)\n"); - break; - case PTVER_2X2_AC_2GVHT: - case PTVER_2X2_AC: - printf(" 1 11b (11M - 1M) 2 11a (18M - 6M)\n"); - printf(" 3 11a (36M - 24M) 4 11a (54M - 48M)\n"); - printf(" 5 11n 20 (MCS2 - MCS0, 1x1) 6 11n 20 (MCS4 - MCS3, 1x1)\n"); - printf(" 7 11n 20 (MCS7 - MCS5, 1x1) 8 11n 20 (mcs10 - mcs8, 2x2)\n"); - printf(" 9 11n 20 (mcs12 - mcs11, 2x2) 10 11n 20 (mcs15 - mcs13, 2x2)\n"); - printf("11 11ac 20 (mcs8, 1x1) 12 11ac 20 (mcs9-mcs8, 2x2)\n"); - printf("13 11n 40 (mcs2 - mcs0, 1x1) 14 11n 40 (mcs4 - mcs3, 1x1)\n"); - printf("15 11n 40 (mcs7 - mcs5, 1x1) 16 11n 40 (mcs10 - mcs8, 2x2)\n"); - printf("17 11n 40 (mcs12 - mcs11, 2x2) 18 11ac 40 (mcs9-mcs8, 1x1) \n"); - printf("19 11ac 40 (mcs9-mcs8, 2x2) 20 11n 40 (mcs15 - mcs13, 2x2)\n"); - printf("21 11ac 80 (mcs2-mcs0, 1x1) 22 11ac 80 (mcs4 - mcs3, 1x1)\n"); - printf("23 11ac 80 (mcs7 - mcs5, 1x1) 24 11ac 80 (mcs9-8, 1x1)\n"); - printf("25 11ac 80 (mcs2-mcs0, 2x2) 26 11ac 80 (mcs4 - mcs3, 2x2)\n"); - printf("27 11ac 80 (mcs7 - mcs5, 2x2) 28 11ac 80 (mcs9-8, 2x2)\n"); - break; - case PTVER_2X2_N: - printf(" 1 11b (11M - 1M) 2 11a (18M - 6M)\n"); - printf(" 3 11a (36M - 24M) 4 11a (54M - 48M)\n"); - printf(" 5 11n 20 (MCS2 - MCS0, 1x1) 6 11n 20 (MCS4 - MCS3, 1x1)\n"); - printf(" 7 11n 20 (MCS7 - MCS5, 1x1) 8 11n 20 (mcs10 - mcs8, 2x2)\n"); - printf(" 9 11n 20 (mcs12 - mcs11, 2x2) 10 11n 20 (mcs15 - mcs13, 2x2)\n"); - printf("11 11n 40 (mcs2 - mcs0, 1x1) 12 11n 40 (mcs4 - mcs3, 1x1)\n"); - printf("13 11n 40 (mcs7 - mcs5, 1x1) 14 11n 40 (mcs10 - mcs8, 2x2)\n"); - printf("15 11n 40 (mcs12 - mcs11, 2x2) 16 11n 40 (mcs15 - mcs13, 2x2) \n"); - break; - } - printf("\n\n"); - return; -} - -/** - * @brief display and compare the channel power table - * - * @param tbl pointer to table - * @param target_tbl pointer to target table - * @return void - */ -void -display_regpwr_tbl(region_chan_pwr_tbl * tbl, region_chan_pwr_tbl * comp_tbl) -{ - int i, j; - if (!comp_tbl) - display_tbl_hdr(tbl); - if (comp_tbl && (tbl->environment != comp_tbl->environment || - tbl->regioncode != comp_tbl->regioncode || - tbl->countrycode[0] != comp_tbl->countrycode[0] || - tbl->countrycode[1] != comp_tbl->countrycode[1])) - printf("* country code is ( %c%c ) region code is ( %d ) environment code is ( %d )\n", tbl->countrycode[0], tbl->countrycode[1], tbl->regioncode, tbl->environment); - else - printf(" country code is ( %c%c ) region code is ( %d ) environment code is ( %d )\n", tbl->countrycode[0], tbl->countrycode[1], tbl->regioncode, tbl->environment); - switch (tbl->max_power_bg) { - case 10: - printf("=========================2G_POWER_TABLE=========================================\n"); - printf("chan_no(Attr), Pindx(dBm) 1 2 3 4 5 6 7 8 9 10 \n"); - printf("================================================================================\n"); - break; - case 12: - printf("=========================2G_POWER_TABLE===================================================\n"); - printf("chan_no(Attr), Pindx(dBm) 1 2 3 4 5 6 7 8 9 10 11 12 \n"); - printf("==========================================================================================\n"); - break; - case 16: - printf("=========================2G_POWER_TABLE=======================================================================\n"); - printf("chan_no(Attr), Pindx(dBm) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 \n"); - printf("==============================================================================================================\n"); - break; - case 24: - printf("=========================5G_POWER_TABLE=========================================================================================================\n"); - printf("chan_no(Attr), Pindx(dBm) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 \n"); - printf("================================================================================================================================================\n"); - break; - } - for (i = 0; i < 14; i++) { - if (comp_tbl && - memcmp(&tbl->bg_pwr_tbl[i], &comp_tbl->bg_pwr_tbl[i], - sizeof(rgchan_pwr_t))) - printf(" *%3d (%02x) ", - tbl->bg_pwr_tbl[i].chan_no, - tbl->bg_pwr_tbl[i].chan_attr); - else - printf(" %3d (%02x) ", - tbl->bg_pwr_tbl[i].chan_no, - tbl->bg_pwr_tbl[i].chan_attr); - for (j = 0; j < tbl->max_power_bg; j++) { - printf("%2d ", tbl->bg_pwr_tbl[i].pwr[j]); - } - printf("\n"); - } - printf(" \n"); - switch (tbl->max_power_a) { - case 10: - printf("=========================5G_POWER_TABLE=========================================\n"); - printf("chan_no(Attr), Pindx(dBm) 1 2 3 4 5 6 7 8 9 10 \n"); - printf("================================================================================\n"); - break; - case 16: - printf("=========================5G_POWER_TABLE=================================================================================\n"); - printf("chan_no(Attr), Pindx(dBm) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 \n"); - printf("========================================================================================================================\n"); - break; - case 28: - printf("=========================5G_POWER_TABLE=============================================================================================================================\n"); - printf("chan_no(Attr), Pindx(dBm) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 \n"); - printf("====================================================================================================================================================================\n"); - break; - } - for (i = 0; i < tbl->max_chan_a; i++) { - if (comp_tbl && - memcmp(&tbl->a_pwr_tbl[i], &comp_tbl->a_pwr_tbl[i], - sizeof(rgchan_pwr_t))) - printf(" *%3d (%02x) ", - tbl->a_pwr_tbl[i].chan_no, - tbl->a_pwr_tbl[i].chan_attr); - else - printf(" %3d (%02x) ", - tbl->a_pwr_tbl[i].chan_no, - tbl->a_pwr_tbl[i].chan_attr); - for (j = 0; j < tbl->max_power_a; j++) { - printf("%2d ", tbl->a_pwr_tbl[i].pwr[j]); - } - printf("\n"); - } - return; -} - -/** - * @brief Process compare the regionpowertable - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_compare_rgpwr(int argc, char *argv[]) -{ - - FILE *src_fp = NULL; - FILE *target_fp = NULL; - int ret = MLAN_STATUS_SUCCESS; - struct stat st; - t_u8 *src_rgpwr_buf = NULL; - t_u8 *target_rgpwr_buf = NULL; - - if (argc < 4) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX/uapX comparergpwr uncompressed_file target_file\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - if (argc == 5) { - target_fp = fopen(argv[4], "r"); - if (target_fp == NULL) { - ret = -EFAULT; - perror("target file fopen failed"); - goto done; - } - target_rgpwr_buf = (t_u8 *)malloc(sizeof(region_chan_pwr_tbl)); - if (!target_rgpwr_buf) { - ret = -EFAULT; - printf("ERR:Cannot allocate buffer target_rgpwr_buf!\n"); - goto done; - } - memset(target_rgpwr_buf, 0, sizeof(region_chan_pwr_tbl)); - if (get_fw_rgpwr_data - (target_fp, (region_chan_pwr_tbl *) target_rgpwr_buf)) { - ret = -EFAULT; - printf("ERR:Fail to parse target file\n"); - goto done; - } - } - if (stat(argv[3], &st)) { - printf("cannot stat %s\n", argv[3]); - ret = -EFAULT; - goto done; - } - - src_fp = fopen(argv[3], "r"); - if (src_fp == NULL) { - perror("src file fopen failed"); - goto done; - } - src_rgpwr_buf = (t_u8 *)malloc(sizeof(region_chan_pwr_tbl)); - if (!src_rgpwr_buf) { - ret = -EFAULT; - printf("ERR:Cannot allocate buffer for src_rgpwr_buf!\n"); - goto done; - } - memset(src_rgpwr_buf, 0, sizeof(region_chan_pwr_tbl)); - if (get_src_rgpwr_data - (src_fp, (int)st.st_size, (region_chan_pwr_tbl *) src_rgpwr_buf)) { - printf("ERR: Fail to parse source file!\n"); - goto done; - } - if (src_rgpwr_buf && target_rgpwr_buf) { - if (!memcmp - (src_rgpwr_buf, target_rgpwr_buf, - sizeof(region_chan_pwr_tbl) - 1)) { - printf("PASS\n"); - display_regpwr_tbl((region_chan_pwr_tbl *) - src_rgpwr_buf, NULL); - } else { - printf("FAIL\n"); - printf("SRC Region Channel Power Table:\n"); - display_regpwr_tbl((region_chan_pwr_tbl *) - src_rgpwr_buf, NULL); - printf("==============================================================================\n"); - printf("FW Region Channel Power Table:\n"); - display_regpwr_tbl((region_chan_pwr_tbl *) - target_rgpwr_buf, - (region_chan_pwr_tbl *) - src_rgpwr_buf); - } - } else if (src_rgpwr_buf) { - printf("SRC Region Channel Power Table:\n"); - display_regpwr_tbl((region_chan_pwr_tbl *) src_rgpwr_buf, NULL); - } -done: - if (target_fp) - fclose(target_fp); - if (target_rgpwr_buf) - free(target_rgpwr_buf); - if (src_fp) - fclose(src_fp); - if (src_rgpwr_buf) - free(src_rgpwr_buf); - return ret; -} - -/** - * @brief Enable/Disable amsdu_aggr_ctrl - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_11n_amsdu_aggr_ctrl(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - int ret = 0, data[2]; - struct ifreq ifr; - - /* Check if arguments are valid */ - if ((argc != 3) && (argc != 4)) { - printf("ERR: Invalid arguments\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: amsduaggrctrl fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - memset(data, 0, sizeof(data)); - memcpy(data, buffer, sizeof(data)); - if (data[0] == 1) - printf("Feature is enabled\n"); - if (data[0] == 0) - printf("Feature is disabled\n"); - printf("Current AMSDU buffer size is %d\n", data[1]); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -/** - * @brief Set/Get Transmit beamforming capabilities - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_tx_bf_cap_ioctl(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - int ret = 0, bf_cap; - struct ifreq ifr; - - /* Check if arguments are valid */ - if ((argc != 3) && (argc != 4)) { - printf("ERR: Invalid arguments\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: httxbfcap fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - memcpy(&bf_cap, buffer, sizeof(int)); - printf("Current TX beamforming capability is 0x%x\n", bf_cap); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -#ifdef SDIO -/** - * @brief Turn on/off the sdio clock - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_sdio_clock_ioctl(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - int ret = 0, clock_state = 0; - struct ifreq ifr; - - /* Check if arguments are valid */ - if ((argc != 3) && (argc != 4)) { - printf("ERR: Invalid arguments\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: sdioclock fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - if (argc == 3) { - memcpy(&clock_state, buffer, sizeof(clock_state)); - printf("Current SDIO clock state is %d\n", clock_state); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} -#endif - -#ifdef SDIO -/** - * @brief Set SDIO Multi-point aggregation control parameters - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_sdio_mpa_ctrl(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - int ret = 0, data[6]; - struct ifreq ifr; - - /* Check if arguments are valid */ - if ((argc < 3) && (argc > 9)) { - printf("ERR: Invalid arguments\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: diaglooptest fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - if (argc == 3) { - memset(data, 0, sizeof(data)); - memcpy(data, buffer, sizeof(data)); - printf("Enable MP aggregation for Tx is %d\n", data[0]); - printf("Enable MP aggregation for Rx is %d\n", data[1]); - printf("Tx buffer size is %d\n", data[2]); - printf("Rx buffer size is %d\n", data[3]); - printf("maximum Tx port is %d\n", data[4]); - printf("maximum Rx port is %d\n", data[5]); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} -#endif - -/** - * @brief Configure sleep parameters - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_sleep_params(int argc, char *argv[]) -{ - int ret = 0, data[6]; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Check if arguments are valid */ - if ((argc != 3) && (argc != 9)) { - printf("ERR: Invalid arguments\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); -/* prepare_buffer(buffer, argv[2], 0, NULL); */ - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: sleepparams fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(data, 0, sizeof(data)); - memcpy(data, buffer, sizeof(data)); - printf("Sleep clock error in ppm is %d\n", data[0]); - printf("Wakeup offset in usec is %d\n", data[1]); - printf("Clock stabilization time in usec is %d\n", data[2]); - printf("Control periodic calibration is %d\n", data[3]); - printf("Control the use of external sleep clock is %d\n", data[4]); - printf("Debug is %d\n", data[5]); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -/** - * @brief Set/Get cw mode - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_cwmode(int argc, char *argv[]) -{ - t_u8 *buffer = NULL, *pos = NULL, *action; - char *data = NULL, *args[100]; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - cw_mode_ctrl *cwmode = NULL; - FILE *config_file = NULL; - char *line = NULL; - int li = 0; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - memset(buffer, 0, BUFFER_LENGTH); - pos = buffer; - strncpy((char *)pos, CMD_NXP, strlen(CMD_NXP)); - pos += (strlen(CMD_NXP)); - strcpy((char *)pos, argv[2]); - pos += (strlen(argv[2])); - action = pos; - pos++; - - if (argc > 3) { - *action = 1; - config_file = fopen(argv[3], "r"); - if (config_file == NULL) { - perror("CONFIG"); - exit(1); - } - - line = (char *)malloc(MAX_CONFIG_LINE); - if (!line) { - printf("ERR:Cannot allocate memory for line\n"); - exit(1); - } - memset(line, 0, MAX_CONFIG_LINE); - /* Parse file and process */ - while (config_get_line - (line, MAX_CONFIG_LINE, config_file, &li, &data)) { - parse_line(line, args, 100); - - if (strcmp(args[0], "CW_MODE") == 0) - cwmode = (cw_mode_ctrl *) pos; - else { - if (cwmode) { - if (strcmp(args[0], "Mode") == 0) - cwmode->mode = - a2hex_or_atoi(args[1]); - else if (strcmp(args[0], "Channel") == - 0) - cwmode->channel = - a2hex_or_atoi(args[1]); - else if (strcmp(args[0], "Chaninfo") == - 0) - cwmode->chanInfo = - a2hex_or_atoi(args[1]); - else if (strcmp(args[0], "TxPower") == - 0) - cwmode->txPower = - a2hex_or_atoi(args[1]); - else if (strcmp(args[0], "PktLength") == - 0) - cwmode->pktLength = - a2hex_or_atoi(args[1]); - else if (strcmp(args[0], "RateInfo") == - 0) - cwmode->rateInfo = - a2hex_or_atoi(args[1]); - } else { - printf("invalid config file\n"); - printf("Specify the parameters in CW_MODE header as shown below:\n"); - printf("CW_MODE = {\n"); - printf("//\n"); - printf("// specify parameters between CW_MODE header only\n"); - printf("//\n"); - printf("}\n"); - exit(1); - } - } - } - } - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ - cmd->buf = buffer; - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: cwmode fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - cwmode = (cw_mode_ctrl *) buffer; - printf("CW Mode:\nMode = %d\nChannel = %d\nChanInfo = 0x%x\n" - "TxPower=%d\nRateInfo=0x%x\nPacket Length=%d\n", - cwmode->mode, cwmode->channel, cwmode->chanInfo, - cwmode->txPower, cwmode->rateInfo, cwmode->pktLength); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Set/Get DFS Testing settings - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_dfs_testing(int argc, char *argv[]) -{ - int ret = 0, data[4]; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Check if arguments are valid */ - if ((argc != 3) && (argc != 7)) { - printf("ERR: Invalid arguments\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: dfstesting fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - if (argc == 3) { - memset(data, 0, sizeof(data)); - memcpy(data, buffer, sizeof(data)); - printf("User-configured Channel Availability Check in msec is %d\n", data[0]); - printf("User-configured Non-Occupancy Period in sec is %d\n", - data[1]); - printf("No channel change on radar enabled is %d\n", data[2]); - printf("User-configured channel to change to on radar is %d\n", - data[3]); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -/** - * @brief Set/Get CFP table codes - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_cfp_code(int argc, char *argv[]) -{ - int ret = 0, data[2]; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Check if arguments are valid */ - if ((argc != 3) && (argc != 4) && (argc != 5)) { - printf("ERR: Invalid arguments\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: cfpcode fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - if (argc == 3) { - memset(data, 0, sizeof(data)); - memcpy(data, buffer, sizeof(data)); - printf("Code of the CFP table for 2.4GHz is %d\n", data[0]); - printf("Code of the CFP table for 5GHz is %d\n", data[1]); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -/** - * @brief Set/Get Tx/Rx antenna - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_set_get_tx_rx_ant(int argc, char *argv[]) -{ - int ret = 0; - int data[3] = { 0 }; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Check if arguments are valid */ - if ((argc != 3) && (argc != 4) - && (argc != 5) - ) { - printf("ERR: Invalid arguments\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: antcfg fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - if (argc == 3) { - if (cmd->used_len < sizeof(data)) { - memcpy(data, buffer, cmd->used_len); - printf("Mode of Tx path is 0x%x\n", data[0]); - if (cmd->used_len == (sizeof(int) * 2)) - printf("Mode of Rx path is 0x%x\n", data[1]); - } else { - memcpy(data, buffer, sizeof(data)); - printf("Mode of Tx/Rx path is 0x%x\n", data[0]); - /* Evaluate time is valid only when SAD is enabled */ - if (data[0] == 0xffff) { - printf("Evaluate time = %d\n", data[1]); - /* Current antenna value should be 1,2,3. 0 is invalid value */ - if (data[2] > 0) - printf("Current antenna is %d\n", - data[2]); - } - } - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -/** - * @brief Get/Set system clock - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_sysclock(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd; - int data[65], i = 0; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: sysclock fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* GET operation */ - if (argc == 3) { - memset(data, 0, sizeof(data)); - memcpy(data, buffer, sizeof(data)); - printf("sysclock = "); - for (i = 1; i <= data[0]; i++) { - printf("%d ", data[i]); - } - printf("\n"); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Get GTK/PTK - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_get_key(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd; - struct ifreq ifr; - - if (argc != 3) { - printf("ERR: Invalid arguments\n"); - return MLAN_STATUS_FAILURE; - } - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], 0, NULL); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: getkey fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - if (cmd->used_len) - printf("Key is %s\n", buffer); - else - printf("Key is not set\n"); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Associate to a specific indexed entry in the ScanTable - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_associate_ssid_bssid(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd; - struct ifreq ifr; - - if (argc == 3) { - printf("ERR: Invalid number of arguments\n"); - return MLAN_STATUS_FAILURE; - } - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: associate fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Set/Get Transmit beamforming configuration - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_tx_bf_cfg(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - char *param = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - t_u32 param_cnt = 0; - int status = MLAN_STATUS_SUCCESS; - int bf_action; - bf_global_cfg *bf_cfg = NULL; - - if (argc == 3) { - printf("ERR: Invalid number of arguments\n"); - return MLAN_STATUS_FAILURE; - } - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - status = MLAN_STATUS_FAILURE; - goto exit; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: httxbfcfg fail\n"); - status = MLAN_STATUS_FAILURE; - goto exit; - } - - param = argv[3]; - param_cnt = strlen(param); - if (param_cnt == 1) { - /* The first byte represents the beamforming action */ - bf_action = atoi(argv[3]); - switch (bf_action) { - case BF_GLOBAL_CONFIGURATION: - bf_cfg = (bf_global_cfg *) buffer; - printf("Action: BF Configuration (%d) \n", bf_action); - printf("Enable: %d\n", bf_cfg->bf_enbl); - printf("Sounding Enable: %d\n", - bf_cfg->sounding_enbl); - printf("Feedback Type: %d\n", bf_cfg->fb_type); - printf("SNR Threshold: %d\n", - bf_cfg->snr_threshold); - printf("Sounding Interval: %d\n", - bf_cfg->sounding_interval); - printf("BF Mode: %d\n", bf_cfg->bf_mode); - break; - default: - break; - } - } - -exit: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return status; -} - -/** - * @brief Control WPS Session Enable/Disable - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_wps_cfg(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd; - struct ifreq ifr; - - if (argc < 3 && argc > 4) { - printf("ERR: Invalid number of arguments\n"); - return MLAN_STATUS_FAILURE; - } - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: wpssession fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - printf("%s\n", buffer); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Set/Get Port Control mode - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_port_ctrl(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd; - struct ifreq ifr; - int port_ctrl = 0; - - if (argc < 3 && argc > 4) { - printf("ERR: Invalid number of arguments\n"); - return MLAN_STATUS_FAILURE; - } - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: port_ctrl fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - if (argc == 3) { - port_ctrl = (int)*buffer; - if (port_ctrl == 1) - printf("port_ctrl is Enabled\n"); - else - printf("port_ctrl is Disabled\n"); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Private IOCTL entry to get the By-passed TX packet from upper layer - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_bypassed_packet(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: pb_bypass fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/* #ifdef FW_WAKEUP_METHOD */ -/** - * @brief Set/Get module configuration - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_fw_wakeup_method(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd; - struct ifreq ifr; - int fw_wakeup_method = 0; - int gpio_pin = 0; - - if (argc < 3 || argc > 5) { - printf("ERR: Invalid number of arguments\n"); - return MLAN_STATUS_FAILURE; - } - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: fwwakeupmethod fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - if (argc == 3) { - fw_wakeup_method = (int)*buffer; - gpio_pin = (int)*(buffer + 4); - if (fw_wakeup_method == 1) - printf("FW wakeup method is interface\n"); - else if (fw_wakeup_method == 2) - printf("FW wakeup method is gpio, GPIO Pin is %d\n", - gpio_pin); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/* #endif */ - -#ifdef SDIO -/** - * @brief SD comand53 read/write - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_sdcmd53rw(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - int cmd_header_len = 0; - struct eth_priv_cmd *cmd; - struct ifreq ifr; - t_u8 *buffer = NULL; - t_u8 *pos = NULL; - int addr, mode, blklen, blknum, i = 0, rw; - t_u16 cmd_len = 0; - - if (argc < 8) { - fprintf(stderr, "Invalid number of parameters!\n"); - return MLAN_STATUS_FAILURE; - } - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - prepare_buffer(buffer, argv[2], 0, NULL); - - cmd_header_len = strlen(CMD_NXP) + strlen(argv[2]); - - pos = buffer + cmd_header_len + sizeof(cmd_len); - - if (argc == 8) { - rw = pos[0] = 0; /* CMD53 read */ - } else { - rw = pos[0] = 1; /* CMD53 write */ - } - pos[1] = atoval(argv[3]); /* func (0/1/2) */ - addr = atoval(argv[4]); /* address */ - pos[2] = addr & 0xff; - pos[3] = (addr >> 8) & 0xff; - pos[4] = (addr >> 16) & 0xff; - pos[5] = (addr >> 24) & 0xff; - mode = atoval(argv[5]); /* byte mode/block mode (0/1) */ - pos[6] = (t_u8)mode; - blklen = atoval(argv[6]); /* block size */ - pos[7] = blklen & 0xff; - pos[8] = (blklen >> 8) & 0xff; - blknum = atoval(argv[7]); /* block number or byte number */ - pos[9] = blknum & 0xff; - pos[10] = (blknum >> 8) & 0xff; - if (pos[0]) { - for (i = 0; i < (argc - 8); i++) - pos[11 + i] = atoval(argv[8 + i]); - } - cmd_len = 11 + i; - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(cmd_len)); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: sdcmd53rw fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - if (mode) { - fprintf(stderr, "CMD53rw blklen = %d, blknum = %d\n", blklen, - blknum); - } else { - blklen = 1; - fprintf(stderr, "CMD53rw bytelen = %d\n", blknum); - } - if (!rw) - hexdump("CMD53 data", buffer, blklen * blknum, ' '); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} -#endif - -#ifdef WIFI_DIRECT_SUPPORT -/** - * @brief Set/Get P2P NoA (Notice of Absence) Or OPP-PS parameters - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_cfg_noa_opp_ps(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd; - struct ifreq ifr; - mlan_ds_wifi_direct_config *cfg; - - if (argc < 3 || argc > 8) { - printf("ERR: Invalid number of arguments\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: noa_cfg fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - if (argc == 3) { - cfg = (mlan_ds_wifi_direct_config *)buffer; - if (!cfg) { - printf("Err : Could not get P2P noa configuration\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - if (cfg->flags & WIFI_DIRECT_NOA) { - printf("noa_enable : %d\n", cfg->noa_enable); - printf("index : %d\n", cfg->index); - printf("noa_count : %d\n", cfg->noa_count); - printf("noa_duration : %d\n", cfg->noa_duration); - printf("noa_interval : %d\n", cfg->noa_interval); - } - if (cfg->flags & WIFI_DIRECT_OPP_PS) { - printf("opp_ps_enable : %d\n", cfg->opp_ps_enable); - printf("ct_window : %d\n", cfg->ct_window); - } - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} -#endif - -/** - * @brief Issue a dscp map command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_dscpmap(int argc, char *argv[]) -{ - int ret = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - unsigned int dscp, tid, idx; - t_u8 dscp_map[64]; - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), argv[2], strlen(argv[2])); - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[dscpmap]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - memcpy(dscp_map, buffer, sizeof(dscp_map)); - - if ((argc == 4) && (strcmp(argv[3], "reset") == 0)) { - memset(dscp_map, 0xff, sizeof(dscp_map)); - } else if (argc == (3 + sizeof(dscp_map))) { - /* Update the entire dscp table */ - for (idx = 3; idx < (3 + sizeof(dscp_map)); idx++) { - tid = a2hex_or_atoi(argv[idx]); - - if (tid < 8) { - dscp_map[idx - 3] = tid; - } - } - } else if (argc > 3 && argc <= (3 + sizeof(dscp_map))) { - /* Update any dscp entries provided on the command line */ - for (idx = 3; idx < argc; idx++) { - if ((sscanf(argv[idx], "%x=%x", &dscp, &tid) == 2) - && (dscp < sizeof(dscp_map)) - && (tid < 8)) { - dscp_map[dscp] = tid; - } - } - } else if (argc != 3) { - printf("Invalid number of arguments\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - memset(buffer, 0, BUFFER_LENGTH); - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), argv[2], strlen(argv[2])); - if (argc > 3) - memcpy(buffer + strlen(CMD_NXP) + strlen(argv[2]), - dscp_map, sizeof(dscp_map)); -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[dscpmap]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - /* Display the active dscp -> TID mapping table */ - if (cmd->used_len) { - printf("DscpMap:\n"); - hexdump(NULL, buffer, cmd->used_len, ' '); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Set/Get DF repeater mode parameters - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_dfs_repeater(int argc, char *argv[]) -{ - int ret = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - dfs_repeater *dfs_rptr = NULL; - - if (argc < 3 && argc > 4) { - printf("ERR: Invalid number of arguments\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: %s fail\n", __func__); - ret = MLAN_STATUS_FAILURE; - goto done; - } - if (argc == 3) { - dfs_rptr = (dfs_repeater *) buffer; - printf("DFS repeater mode: %s\n", - (dfs_rptr->mode) ? "On" : "Off"); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -#ifdef WIFI_DIRECT_SUPPORT -/** - * @brief Set/Get miracast configuration parameters - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_miracastcfg(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - int data[3]; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - if (argc < 3 && argc > 6) { - fprintf(stderr, "mlanutl: Invalid number of arguments\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - fprintf(stderr, "mlanutl: Cannot allocate memory\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - fprintf(stderr, - "mlanutl: Cannot allocate buffer for command\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: miracastcfg fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - memset(data, 0, sizeof(data)); - /* Process result */ - memcpy(data, buffer, sizeof(data)); - if (argc == 3) { - /* GET operation */ - printf("Miracast Configuration:\n"); - printf(" Mode: %d\n", data[0]); - printf(" Scan time: %d\n", data[1]); - printf(" Scan channel gap: %d\n", data[2]); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} -#endif /* WIFI_DIRECT_SUPPORT */ - -/** - * @brief Set/get control to coex RX window size - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_coex_rx_winsize(int argc, char *argv[]) -{ - int ret = 0; - int coex_rx_winsize = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Check if arguments are valid */ - if ((argc != 3) && (argc != 4)) { - printf("ERR: Invalid arguments\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR: Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR: Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: coex_rx_winsize fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - if (argc == 3) { - memcpy(&coex_rx_winsize, buffer, sizeof(coex_rx_winsize)); - printf("COEX RX winsize is %s\n", - coex_rx_winsize ? "enabled" : "disabled"); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -#ifdef PCIE -/** - * @brief Read/Write PCIE register - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_pcie_reg_rw(int argc, char *argv[]) -{ - int ret = 0, data[2]; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Check if arguments are valid */ - if ((argc != 4) && (argc != 5)) { - printf("ERR: Invalid arguments\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: pcieregrw fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - if (argc == 4) { - memset(data, 0, sizeof(data)); - memcpy(data, buffer, sizeof(data)); - printf("Offset of PCIE register is %#x\n", data[0]); - printf("Value at the register is %#x\n", data[1]); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -/** - * @brief Read/Write PCIE register/memory from BAR0 - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_pcie_bar0_reg_rw(int argc, char *argv[]) -{ - int ret = 0, data[2]; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Check if arguments are valid */ - if ((argc != 4) && (argc != 5)) { - printf("ERR: Invalid arguments\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: pcieregrw fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - if (argc == 4) { - memset(data, 0, sizeof(data)); - memcpy(data, buffer, sizeof(data)); - printf("Offset of PCIE register is %#x\n", data[0]); - printf("Value at the register is %#x\n", data[1]); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} -#endif - -/** - * @brief get SOC sensor temperature. - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_get_sensor_temp(int argc, char *argv[]) -{ - int ret = 0; - t_u32 temp = 0; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc != 3) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX get_sensor_temp\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], 0, NULL); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: temp_sensor fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Process result */ - memcpy(&temp, buffer, sizeof(t_u32)); - printf("SOC temperature is %u C \n", temp); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -/** - * @brief Get channel report values - * - * @param chanNum Number of channels - * @param startFreq Start Frequency - * @param duration Duration - * @param pAnpi Pointer to the anpi value - * @param pLoadPercent Pointer to the LoadPercent value - * @param chanWidth Channel width - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -chanrpt_getValues(t_u8 chanNum, t_u16 startFreq, - t_u32 duration, t_s16 *pAnpi, t_u8 *pLoadPercent, - t_u8 chanWidth) -{ - int ret = MLAN_STATUS_SUCCESS; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - t_u8 *pByte; - int eventLen = 0; - MrvlIEtypes_Data_t *pTlvHdr; - HostCmd_DS_GEN *hostcmd; - HostCmd_DS_CHAN_RPT_RSP *pChanRptRsp = NULL; - HostCmd_DS_CHAN_RPT_REQ *pChanRptReq = NULL; - t_u8 *pChanRptEvent = NULL; - MrvlIEtypes_ChanRptChanLoad_t *pLoadRpt = NULL; - MrvlIEtypes_ChanRptNoiseHist_t *pNoiseRpt = NULL; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - cmd_len = S_DS_GEN + sizeof(HostCmd_DS_CHAN_RPT_REQ); - - hostcmd->command = cpu_to_le16(HostCmd_CMD_CHAN_REPORT_REQUEST); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - pChanRptReq = (HostCmd_DS_CHAN_RPT_REQ *)pos; - - memset((void *)pChanRptReq, 0x00, sizeof(HostCmd_DS_CHAN_RPT_REQ)); - - pChanRptReq->chanDesc.chanNum = chanNum; - pChanRptReq->chanDesc.startFreq = cpu_to_le16(startFreq); - pChanRptReq->chanDesc.chanWidth = chanWidth; - pChanRptReq->millisecDwellTime = duration; - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[chanrpt hostcmd]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - eventLen = NL_MAX_PAYLOAD; - pChanRptEvent = (t_u8 *)malloc(NL_MAX_PAYLOAD); - - if (!pChanRptEvent) { - printf("ERR:Could not allocate buffer!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - ret = wait_event(EVENT_CHANNEL_REPORT_RDY, pChanRptEvent, &eventLen); - - if (ret || !pChanRptEvent || !eventLen) { - printf("ERR: wait_event failed!\n"); - ret = -EFAULT; - goto done; - } - - pChanRptRsp = (HostCmd_DS_CHAN_RPT_RSP *)(pChanRptEvent + EVENT_ID_LEN); - eventLen -= EVENT_ID_LEN; - - /* TSF is a t_u64, some formatted printing libs have - * trouble printing long longs, so cast and dump as bytes - */ - pByte = (t_u8 *)&pChanRptRsp->startTsf; - - pByte = pChanRptRsp->tlvBuffer; - - eventLen -= sizeof(pChanRptRsp->commandResult); - eventLen -= sizeof(pChanRptRsp->startTsf); - eventLen -= sizeof(pChanRptRsp->duration); - - pByte = pChanRptRsp->tlvBuffer; - - while ((unsigned int)eventLen >= sizeof(pTlvHdr->header)) { - pTlvHdr = (MrvlIEtypes_Data_t *)pByte; - pTlvHdr->header.len = le16_to_cpu(pTlvHdr->header.len); - - switch (le16_to_cpu(pTlvHdr->header.type)) { - case TLV_TYPE_CHANRPT_CHAN_LOAD: - pLoadRpt = (MrvlIEtypes_ChanRptChanLoad_t *)pTlvHdr; - *pLoadPercent = (pLoadRpt->ccaBusyFraction * 100) / 255; - break; - - case TLV_TYPE_CHANRPT_NOISE_HIST: - pNoiseRpt = (MrvlIEtypes_ChanRptNoiseHist_t *)pTlvHdr; - *pAnpi = pNoiseRpt->anpi; - break; - - default: - break; - } - - pByte += (pTlvHdr->header.len + sizeof(pTlvHdr->header)); - eventLen -= (pTlvHdr->header.len + sizeof(pTlvHdr->header)); - eventLen = (eventLen > 0) ? eventLen : 0; - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - if (pChanRptEvent) - free(pChanRptEvent); - return ret; -} - -/** - * @brief Print x Axis - * - * @param pChanRpt Pointer to the chan report - * @param numChans Number of channels - * - * @return void - */ -static void -chanrpt_print_xAxis(ChanRptInfo_t * pChanRpt, int numChans) -{ - int idx; - - printf(" `-"); - - for (idx = 0; idx < numChans; idx++) { - printf("----"); - } - - printf("\n "); - - for (idx = 0; idx < numChans; idx++) { - printf("%03d ", (pChanRpt + idx)->chanNum); - } - - printf("\n"); -} - -/** - * @brief Print anpi - * - * @param pChanRpt Pointer to the chan report - * @param numChans Number of channels - * - * @return void - */ -static void -chanrpt_print_anpi(ChanRptInfo_t * pChanRpt, int numChans) -{ - int dumpIdx; - int yAxis; - int yPrint; - - printf("\n"); - printf(" Average Noise Power Indicator\n"); - printf(" -----------------------------\n"); - - yPrint = 0; - for (yAxis = -55; yAxis >= -95; yAxis -= 2) { - if (yPrint % 2 == 1) { - printf("%2d| ", yAxis); - } else { - printf(" | "); - } - - yPrint++; - - for (dumpIdx = 0; dumpIdx < numChans; dumpIdx++) { - if ((pChanRpt + dumpIdx)->anpi >= yAxis) { - printf("### "); - } else if ((pChanRpt + dumpIdx)->anpi >= yAxis - 2) { - printf("%3d ", (pChanRpt + dumpIdx)->anpi); - } else { - printf(" "); - } - } - - printf("\n"); - } - - chanrpt_print_xAxis(pChanRpt, numChans); -} - -/** - * @brief Print chan load - * - * @param pChanRpt Pointer to the chan report - * @param numChans Number of channels - * - * @return void - */ -static void -chanrpt_print_chanLoad(ChanRptInfo_t * pChanRpt, int numChans) -{ - int dumpIdx; - int yAxis; - int yPrint; - - printf("\n"); - printf(" Channel Load\n"); - printf(" ------------\n"); - - yPrint = 0; - for (yAxis = 100; yAxis >= 0; yAxis -= 5) { - if (yPrint % 2 == 1) { - printf("%2d%%| ", yAxis); - } else { - printf(" | "); - } - - yPrint++; - - for (dumpIdx = 0; dumpIdx < numChans; dumpIdx++) { - if ((pChanRpt + dumpIdx)->chanLoad >= yAxis) { - printf("### "); - } else if ((pChanRpt + dumpIdx)->chanLoad >= yAxis - 5) { - printf("%2d%% ", - (pChanRpt + dumpIdx)->chanLoad); - } else { - printf(" "); - } - } - - printf("\n"); - } - chanrpt_print_xAxis(pChanRpt, numChans); -} - -/** - * @brief Get chanrpt values and print graph - * - * @param void - * - * @return void - */ -static void -chanrpt_graph(void) -{ - int idx; - ChanRptInfo_t chanRpt[14]; - - memset(chanRpt, 0x00, sizeof(chanRpt)); - for (idx = 0; (unsigned int)idx < NELEMENTS(chanRpt); idx++) { - chanRpt[idx].chanNum = idx + 1; - chanrpt_getValues(idx + 1, - 0, - 100, - &chanRpt[idx].anpi, &chanRpt[idx].chanLoad, - 0); - } - - chanrpt_print_anpi(chanRpt, NELEMENTS(chanRpt)); - chanrpt_print_chanLoad(chanRpt, NELEMENTS(chanRpt)); -} - -/** - * @brief Loops to get chanrpt values and print graph, at end print 1 average graph - * - * @param loopOnLoad Print Load graph loop on - * @param loopOnAnpi Print anpi graph loop on - * @param loops Loops - * - * @return void - */ -static void -chanrpt_graph_loop(boolean loopOnLoad, boolean loopOnAnpi, int loops) -{ - int idx; - int loopsLeft; - ChanRptInfo_t chanRpt[14]; - ChanRptInfo_t chanRptAvg[14]; - - memset(chanRpt, 0x00, sizeof(chanRpt)); - memset(chanRptAvg, 0x00, sizeof(chanRptAvg)); - for (idx = 0; (unsigned int)idx < NELEMENTS(chanRpt); idx++) { - chanRpt[idx].chanNum = idx + 1; - chanrpt_getValues(idx + 1, - 0, - 100, - &chanRpt[idx].anpi, &chanRpt[idx].chanLoad, - 0); - } - - idx = 0; - loopsLeft = loops; - - while (loopsLeft) { - chanRpt[idx].chanNum = idx + 1; - chanrpt_getValues(idx + 1, - 0, - 75, - &chanRpt[idx].anpi, &chanRpt[idx].chanLoad, - 0); - - chanRptAvg[idx].chanNum = idx + 1; - chanRptAvg[idx].anpi - = (chanRptAvg[idx].anpi * (loops - loopsLeft) - + chanRpt[idx].anpi) / (loops - loopsLeft + 1); - - chanRptAvg[idx].chanLoad - = (chanRptAvg[idx].chanLoad * (loops - loopsLeft) - + chanRpt[idx].chanLoad) / (loops - loopsLeft + 1); - - idx = (idx + 1) % NELEMENTS(chanRpt); - - if (idx == 0) { - if (loopOnAnpi) { - chanrpt_print_anpi(chanRpt, NELEMENTS(chanRpt)); - } - - if (loopOnLoad) { - chanrpt_print_chanLoad(chanRpt, - NELEMENTS(chanRpt)); - } - - loopsLeft--; - } - } - - if (loopOnAnpi) { - chanrpt_print_anpi(chanRptAvg, NELEMENTS(chanRptAvg)); - } - - if (loopOnLoad) { - chanrpt_print_chanLoad(chanRptAvg, NELEMENTS(chanRptAvg)); - } -} - -/** - * @brief Issue a changraph command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_chan_graph(int argc, char *argv[]) -{ - if (argc == 3) { - chanrpt_graph(); - } else if (argc == 5) { - t_u8 input = atoi(argv[4]); - - if (input <= 100) { - if (strcmp(argv[3], "load") == 0) { - chanrpt_graph_loop(TRUE, FALSE, input); - } else if (strcmp(argv[3], "anpi") == 0) { - chanrpt_graph_loop(FALSE, TRUE, input); - } else if (strcmp(argv[3], "anpiload") == 0) { - chanrpt_graph_loop(TRUE, TRUE, input); - } else { - printf("\nchangraph syntax:" - " changraph \n The value of should be <= 100\n"); - } - } else { - printf("\nchangraph syntax:" - " changraph \n The value of should be <= 100\n"); - } - } - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process extended channel switch(ECSA) - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_extend_channel_switch(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: extended channel switch fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Get/Set per packet Txctl and Rxinfo configuration - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_per_pkt_cfg(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS, i, j; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - MrvlIEtypes_per_pkt_cfg_t *per_pkt_cfg = NULL; - struct ifreq ifr; - t_u8 *pos = NULL; - - /* Sanity tests */ - if (argc != 3 && argc != 4 && argc < 6) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX perpktcfg [tx_rx_control] [type_num] [ether_type1 ...] [tx_rx_control] [type_num] [ether_type1 ...]\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - memset(buffer, 0, BUFFER_LENGTH); - - /* Flag it for our use */ - pos = buffer; - strncpy((char *)pos, CMD_NXP, strlen(CMD_NXP)); - pos += (strlen(CMD_NXP)); - /* Insert command */ - strncpy((char *)pos, argv[2], strlen(argv[2])); - pos += (strlen(argv[2])); - - if (argc == 3) { - *pos = ACTION_GET; - } else { - *pos = ACTION_SET; - pos++; - i = 3; - while (i < argc) { - per_pkt_cfg = (MrvlIEtypes_per_pkt_cfg_t *) pos; - per_pkt_cfg->header.type = TLV_TYPE_PER_PKT_CFG; - if (a2hex_or_atoi(argv[i]) <= MAX_TXRX_CTRL) { - per_pkt_cfg->tx_rx_control = - (t_u8)a2hex_or_atoi(argv[i++]); - per_pkt_cfg->header.len += sizeof(t_u8); - if (per_pkt_cfg->tx_rx_control == 0) - break; - else if (i >= argc) { - printf("Error: invalid arguments, type_num is needed when tx_rx_control != 0.\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - } else { - printf("Error: invalid arguments, tx_rx_control <=3\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - if (a2hex_or_atoi(argv[i]) <= MAX_NUM_ETHER_TYPE && - a2hex_or_atoi(argv[i]) > 0) - per_pkt_cfg->proto_type_num = - a2hex_or_atoi(argv[i++]); - else { - printf("Error: invalid arguments, type_num <=8\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - for (j = 0; j < per_pkt_cfg->proto_type_num; j++) { - if (i < argc) - per_pkt_cfg->ether_type[j] = - (t_u16)a2hex_or_atoi(argv[i++]); - else { - printf("Error: invalid arguments, number of ether type less than type_num \n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - } - per_pkt_cfg->header.len = - sizeof(MrvlIEtypes_per_pkt_cfg_t) + - per_pkt_cfg->proto_type_num * sizeof(t_u16) - - sizeof(MrvlIEtypesHeader_t); - pos += per_pkt_cfg->header.len + - sizeof(MrvlIEtypesHeader_t); - } - } - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: perpktcfg fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Process Get result */ - pos = buffer + (strlen(CMD_NXP)) + strlen(argv[2]); - if (*pos == ACTION_GET) { - per_pkt_cfg = (MrvlIEtypes_per_pkt_cfg_t *)++ pos; - while (per_pkt_cfg->header.type == TLV_TYPE_PER_PKT_CFG) { - if (per_pkt_cfg->tx_rx_control & TX_PKT_CTRL) { - printf("The ethernet type of per packet Txctrl:\n"); - for (j = 0; j < per_pkt_cfg->proto_type_num; - j++) { - printf("0x%04x ", - per_pkt_cfg->ether_type[j]); - } - printf("\n"); - } else if (per_pkt_cfg->tx_rx_control & RX_PKT_INFO) { - printf("The ethernet type of per packet Rxinfo:\n"); - for (j = 0; j < per_pkt_cfg->proto_type_num; - j++) { - printf("0x%04x ", - per_pkt_cfg->ether_type[j]); - } - printf("\n"); - } - pos += per_pkt_cfg->header.len + - sizeof(MrvlIEtypesHeader_t); - per_pkt_cfg = (MrvlIEtypes_per_pkt_cfg_t *) pos; - } - } else if (argc == 4) { - printf("Disable per packet control!\n"); - } else { - printf("Successfully do the TXctl/Rxinfo per packet configuration!\n"); - } -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief enable auto_arp 1->enable 0->disable - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_auto_arp(int argc, char *argv[]) -{ - int ret = 0, status; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc != 3 && argc != 4) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX auto_arp [0/1]\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], argc - 3, &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: auto_arp fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Process Get result */ - if (argc == 3) { - memcpy(&status, buffer, sizeof(status)); - if (status == 0) { - printf("Auto ARP is Disabled\n"); - } else if (status == 1) { - printf("Auto ARP is Enabled\n"); - } - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Creates a tx/rx histogram statistic request and send to driver - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_txrxhistogram(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - int ret = MLAN_STATUS_SUCCESS, i; - struct ifreq ifr; - tx_rx_histogram *tx_rx_info; - tx_pkt_ht_rate_info *tx_ht_info; - tx_pkt_vht_rate_info *tx_vht_info; - tx_pkt_he_rate_info *tx_he_info; - tx_pkt_rate_info *tx_info; - rx_pkt_ht_rate_info *rx_ht_info; - rx_pkt_vht_rate_info *rx_vht_info; - rx_pkt_he_rate_info *rx_he_info; - rx_pkt_rate_info *rx_info; - t_u16 size = 0; - t_u8 *pos = NULL; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - /* Sanity tests */ - if (argc != 5 && argc != 4) { - printf("Error: invalid no of arguments\n"); - printf("mlanutl mlanX/uapX txrxhistogram [action: 0/1/2] [tx_rx_statics: 1/2/3]\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Insert command */ - strncpy((char *)buffer, argv[2], strlen(argv[2])); - tx_rx_info = (tx_rx_histogram *) (buffer + strlen(argv[2])); - tx_rx_info->enable = (t_u8)a2hex_or_atoi(argv[3]); - if (argc == 5 && tx_rx_info->enable == GET_TX_RX_HISTOGRAM) - tx_rx_info->action = (t_u8)a2hex_or_atoi(argv[4]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: get tx/rx histogram fail\n");; - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Process result */ - pos = buffer + strlen(argv[2]) + 2 * sizeof(t_u8); - memcpy(&size, pos, sizeof(size)); - pos += sizeof(size); - if (tx_rx_info->enable & GET_TX_RX_HISTOGRAM) { - if (tx_rx_info->action & FLAG_TX_HISTOGRAM) { - printf("The TX histogram statistic:\n"); - printf("============================================\n"); - tx_ht_info = (tx_pkt_ht_rate_info *) pos; - for (i = 0; i < 16; i++) { - printf("htmcs_txcnt[%d] = %u\n", i, - tx_ht_info->htmcs_txcnt[i]); - printf("htsgi_txcnt[%d] = %u\n", i, - tx_ht_info->htsgi_txcnt[i]); - printf("htstbcrate_txcnt[%d] = %u\n", i, - tx_ht_info->htstbcrate_txcnt[i]); - } - pos += sizeof(tx_pkt_ht_rate_info); - tx_vht_info = (tx_pkt_vht_rate_info *) pos; - for (i = 0; i < 10; i++) { - printf("vhtmcs_txcnt[%d] = %u\n", i, - tx_vht_info->vhtmcs_txcnt[i]); - printf("vhtsgi_txcnt[%d] = %u\n", i, - tx_vht_info->vhtsgi_txcnt[i]); - printf("vhtstbcrate_txcnt[%d] = %u\n", i, - tx_vht_info->vhtstbcrate_txcnt[i]); - } - pos += sizeof(tx_pkt_vht_rate_info); - if (size == - (sizeof(tx_pkt_ht_rate_info) + - sizeof(tx_pkt_vht_rate_info) + - sizeof(tx_pkt_he_rate_info) + - sizeof(tx_pkt_rate_info)) - || size == - (sizeof(tx_pkt_ht_rate_info) + - sizeof(tx_pkt_vht_rate_info) + - sizeof(tx_pkt_he_rate_info) + - sizeof(tx_pkt_rate_info) - + sizeof(rx_pkt_ht_rate_info) + - sizeof(rx_pkt_vht_rate_info) + - sizeof(rx_pkt_he_rate_info) + - sizeof(rx_pkt_rate_info))) { - tx_he_info = (tx_pkt_he_rate_info *) pos; - for (i = 0; i < 12; i++) { - printf("hemcs_txcnt[%d] = %u\n", i, - tx_he_info->hemcs_txcnt[i]); - printf("hestbcrate_txcnt[%d] = %u\n", i, - tx_he_info->hestbcrate_txcnt[i]); - } - pos += sizeof(tx_pkt_he_rate_info); - } - tx_info = (tx_pkt_rate_info *) pos; - for (i = 0; i < 2; i++) - printf("nss_txcnt[%d] = %u\n", i, - tx_info->nss_txcnt[i]); - for (i = 0; i < 3; i++) - printf("bandwidth_txcnt[%d] = %u\n", i, - tx_info->bandwidth_txcnt[i]); - for (i = 0; i < 4; i++) - printf("preamble_txcnt[%d] = %u\n", i, - tx_info->preamble_txcnt[i]); - printf("ldpc_txcnt = %u\n", - tx_info->ldpc_txcnt); - printf("rts_txcnt = %u\n", - tx_info->rts_txcnt); - printf("ack_RSSI = %d\n\n", - tx_info->ack_RSSI); - pos += sizeof(tx_pkt_rate_info); - } - - if (tx_rx_info->action & FLAG_RX_HISTOGRAM) { - printf("The RX histogram statistic:\n"); - printf("============================================\n"); - rx_ht_info = (rx_pkt_ht_rate_info *) pos; - for (i = 0; i < 16; i++) { - printf("htmcs_rxcnt[%d] = %u\n", i, - rx_ht_info->htmcs_rxcnt[i]); - printf("htsgi_rxcnt[%d] = %u\n", i, - rx_ht_info->htsgi_rxcnt[i]); - printf("htstbcrate_rxcnt[%d] = %u\n", i, - rx_ht_info->htstbcrate_rxcnt[i]); - } - pos += sizeof(rx_pkt_ht_rate_info); - rx_vht_info = (rx_pkt_vht_rate_info *) pos; - for (i = 0; i < 10; i++) { - printf("vhtmcs_rxcnt[%d] = %u\n", i, - rx_vht_info->vhtmcs_rxcnt[i]); - printf("vhtsgi_rxcnt[%d] = %u\n", i, - rx_vht_info->vhtsgi_rxcnt[i]); - printf("vhtstbcrate_rxcnt[%d] = %u\n", i, - rx_vht_info->vhtstbcrate_rxcnt[i]); - } - pos += sizeof(rx_pkt_vht_rate_info); - if (size == - (sizeof(rx_pkt_ht_rate_info) + - sizeof(rx_pkt_vht_rate_info) + - sizeof(rx_pkt_he_rate_info) + - sizeof(rx_pkt_rate_info)) - || size == - (sizeof(tx_pkt_ht_rate_info) + - sizeof(tx_pkt_vht_rate_info) + - sizeof(tx_pkt_he_rate_info) + - sizeof(tx_pkt_rate_info) - + sizeof(rx_pkt_ht_rate_info) + - sizeof(rx_pkt_vht_rate_info) + - sizeof(rx_pkt_he_rate_info) + - sizeof(rx_pkt_rate_info))) { - rx_he_info = (rx_pkt_he_rate_info *) pos; - for (i = 0; i < 12; i++) { - printf("hemcs_txcnt[%d] = %u\n", i, - rx_he_info->hemcs_rxcnt[i]); - printf("hestbcrate_txcnt[%d] = %u\n", i, - rx_he_info->hestbcrate_rxcnt[i]); - } - pos += sizeof(rx_pkt_he_rate_info); - } - rx_info = (rx_pkt_rate_info *) pos; - for (i = 0; i < 2; i++) - printf("nss_rxcnt[%d] = %u\n", i, - rx_info->nss_rxcnt[i]); - printf("nsts_rxcnt = %u\n", - rx_info->nsts_rxcnt); - for (i = 0; i < 3; i++) - printf("bandwidth_rxcnt[%d] = %u\n", i, - rx_info->bandwidth_rxcnt[i]); - for (i = 0; i < 6; i++) - printf("preamble_rxcnt[%d] = %u\n", i, - rx_info->preamble_rxcnt[i]); - for (i = 0; i < 2; i++) - printf("ldpc_txbfcnt[%d] = %u\n", i, - rx_info->ldpc_txbfcnt[i]); - for (i = 0; i < 2; i++) - printf("rssi_value[%d] = %d\n", i, - rx_info->rssi_value[i]); - for (i = 0; i < 4; i++) - printf("rssi_chain0[%d] = %d\n", i, - rx_info->rssi_chain0[i]); - for (i = 0; i < 4; i++) - printf("rssi_chain1[%d] = %d\n", i, - rx_info->rssi_chain1[i]); - printf("\n"); - } - } else if (tx_rx_info->enable & ENABLE_TX_RX_HISTOGRAM) - printf("Enable the TX and RX histogram statistic\n"); - else - printf("Disable the TX and RX histogram statistic\n"); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -/** - * @brief Set/Get out band independent reset - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - */ -static int -process_ind_rst_cfg(int argc, char *argv[]) -{ - int ret = 0; - int data[3] = { 0 }; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Check if arguments are valid */ - if ((argc < 3) || (argc > 5)) { - printf("ERR: Invalid arguments\n"); - printf("usage: mlanutl indrstcfg [gpio_pin]\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - if (((argc == 4) || (argc == 5)) && - ((atoi(argv[3]) < 0) || (atoi(argv[3]) > 2))) { - printf("ERR: Mode must be 0, 1 or 2\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: indrstcfg fail\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - if (argc == 3) { - memcpy(data, buffer, sizeof(data)); - /* Display the result */ - printf("Independent Reset Mode = %s\n", - (data[0] == - 0) ? "disabled" : ((data[0] == - 1) ? "Out Band" : "In Band")); - if (data[0] == 1) - printf("GPIO Pin = %d\n", data[1]); - } - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return ret; -} - -static void -send_dot11_packet(char *ifName, char *file_name) -{ - t_u8 sendbuf[BUF_SIZ], buff[BUF_SIZ]; - char *args[100], *pos, mac_addr[20]; - struct ether_header *eh = (struct ether_header *)sendbuf; - int data_len = 0, tx_len = 0; - dot11_txcontrol *txc; - struct sockaddr_ll socket_address; - wsmp_header *header; - t_u8 mac[ETH_ALEN]; - FILE *config_file = NULL; - char *line = NULL; - int li = 0, arg_num = 0, ret = 0, i = 0; - int protocol = 0; - int sockfd; - struct ifreq if_idx; - struct ifreq if_mac; - - memset(buff, 0, sizeof(buff)); - memset(mac, 0, sizeof(mac)); - memset(mac_addr, 0, sizeof(mac_addr)); - - /* Construct the Ethernet header */ - memset(sendbuf, 0, BUF_SIZ); - txc = (dot11_txcontrol *) (sendbuf + sizeof(struct ether_header)); - config_file = fopen(file_name, "r"); - if (config_file == NULL) { - perror("CONFIG"); - exit(1); - } - - line = (char *)malloc(MAX_CONFIG_LINE); - if (!line) { - printf("ERR:Cannot allocate memory for line\n"); - exit(1); - } - memset(line, 0, MAX_CONFIG_LINE); - - /* Parse file and process */ - while (config_get_line(line, MAX_CONFIG_LINE, config_file, &li, &pos)) { - arg_num = parse_line(line, args, 100); - - if (strcmp(args[0], "Datarate") == 0) { - txc->tx_datarate = ((t_u16)A2HEXDECIMAL(args[1])); - printf("datarate(in 0.5Mbps) = %d\n", txc->tx_datarate); - } else if (strcmp(args[0], "Channel") == 0) { - txc->tx_channel = atoi(args[1]); - printf("channel = %d\n", txc->tx_channel); - } else if (strcmp(args[0], "Bandwidth") == 0) { - txc->tx_Bw = (t_u8)A2HEXDECIMAL(args[1]); - printf("Bandwidth = %d\n", txc->tx_Bw); - } else if (strcmp(args[0], "Power") == 0) { - txc->tx_power = (t_u8)A2HEXDECIMAL(args[1]); - printf("powerlevel = %d\n", txc->tx_power); - } else if (strcmp(args[0], "Priority") == 0) { - txc->pkt_priority = atoi(args[1]); - printf("Pkt_priority = %d\n", txc->pkt_priority); - } else if (strcmp(args[0], "Retry_limit") == 0) { - txc->retry_limit = atoi(args[1]); - printf("Retry_limit = %d\n", txc->retry_limit); - } else if (strncmp(args[0], "Addr", 4) == 0) { - - strncpy(mac_addr, args[1], sizeof(mac_addr) - 1); - ret = mac2raw(mac_addr, mac); - printf("destination MAC : %s\n", mac_addr); - if (ret != MLAN_STATUS_SUCCESS) { - printf("%s Address \n", - ret == - MLAN_STATUS_FAILURE ? "Invalid MAC" : ret - == - MAC_BROADCAST ? "Broadcast" : - "Multicast"); - } - } else if (strcmp(args[0], "Data") == 0) { - for (i = 0; i < arg_num - 1; i++) { - buff[i] = (t_u8)A2HEXDECIMAL(args[i + 1]); - } - } else if (strcmp(args[0], "Protocol") == 0) { - protocol = A2HEXDECIMAL(args[1]); - printf("protocol = %x\n", protocol); - } - data_len = arg_num - 1; - } - - /* Open RAW socket to send/recv on */ - if ((sockfd = socket(AF_PACKET, SOCK_RAW, htons(protocol))) == -1) { - perror("socket"); - } - - /* Get the index of the interface to send on */ - memset(&if_idx, 0, sizeof(struct ifreq)); - strncpy(if_idx.ifr_name, ifName, IFNAMSIZ - 1); - if (ioctl(sockfd, SIOCGIFINDEX, &if_idx) < 0) - perror("SIOCGIFINDEX"); - - /*get mac address of the interface */ - memset(&if_mac, 0, sizeof(struct ifreq)); - strncpy(if_mac.ifr_name, ifName, IFNAMSIZ - 1); - if (ioctl(sockfd, SIOCGIFHWADDR, &if_mac) < 0) - perror("SIOCGIFHWADDR"); - - memcpy(eh->ether_shost, (u_int8_t *) & if_mac.ifr_hwaddr.sa_data, - MLAN_MAC_ADDR_LENGTH); - - /* destination mac address */ - for (i = 0; i < MLAN_MAC_ADDR_LENGTH; i++) { - eh->ether_dhost[i] = (uint8_t) mac[i]; - } - /* Ethertype field */ - eh->ether_type = htons(protocol); - tx_len += sizeof(struct ether_header); - /*Add the length of tx header */ - tx_len += sizeof(dot11_txcontrol); - - if (protocol == ETH_P_WSMP) { - header = (wsmp_header *) (sendbuf + tx_len); - header->version = 2; - header->sec_type = 5; - header->chan = txc->tx_channel; - header->rate = txc->tx_datarate / 2; - header->tx_pow = txc->tx_power; - header->app_class = 14; - header->acm_len = 0; - header->len = data_len; - tx_len += sizeof(wsmp_header); - } - memcpy(sendbuf + tx_len, buff, data_len); - - tx_len += data_len; - - /* Index of the network device */ - socket_address.sll_ifindex = if_idx.ifr_ifindex; - /* Address length */ - socket_address.sll_halen = ETH_ALEN; - memcpy(&socket_address.sll_addr, (uint8_t *) mac, MLAN_MAC_ADDR_LENGTH); - if (sendto(sockfd, sendbuf, tx_len, 0, - (struct sockaddr *)&socket_address, - sizeof(struct sockaddr_ll)) < 0) - perror("Send failed\n"); - else - printf("packet sent\n"); - - close(sockfd); - fclose(config_file); -} - -static void -receive_dot11_packet(char *ifName, int protocol, int verbose) -{ - int sockopt = 0, i, j, prev_channel = 0; - t_u8 buf[BUF_SIZ]; - ssize_t numbytes; - struct ether_header *eh = (struct ether_header *)buf; - dot11_rxcontrol *rxctrl; - int sockfd = 0; - struct ifreq if_idx; - struct ifreq if_mac; - - /* Open RAW socket to recv on */ - if ((sockfd = socket(AF_PACKET, SOCK_RAW, htons(protocol))) == -1) { - perror("socket"); - } - /* Get the index of the interface to send on */ - memset(&if_idx, 0, sizeof(struct ifreq)); - strncpy(if_idx.ifr_name, ifName, IFNAMSIZ - 1); - if (ioctl(sockfd, SIOCGIFINDEX, &if_idx) < 0) - perror("SIOCGIFINDEX"); - - /*get mac address of the interface */ - memset(&if_mac, 0, sizeof(struct ifreq)); - strncpy(if_mac.ifr_name, ifName, IFNAMSIZ - 1); - if (ioctl(sockfd, SIOCGIFHWADDR, &if_mac) < 0) - perror("SIOCGIFHWADDR"); - - /* Allow the socket to be reused - incase connection is closed prematurely */ - if (setsockopt - (sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, - sizeof sockopt) == -1) { - perror("setsockopt"); - close(sockfd); - exit(EXIT_FAILURE); - } - - /* Bind to device */ - if (setsockopt - (sockfd, SOL_SOCKET, SO_BINDTODEVICE, ifName, IFNAMSIZ - 1) == -1) { - perror("SO_BINDTODEVICE"); - close(sockfd); - exit(EXIT_FAILURE); - } - - printf("protocol type : %x\n", protocol); - printf("waiting to receive data...\n"); - rxctrl = (dot11_rxcontrol *) (buf + sizeof(struct ether_header)); - while (1) { - numbytes = recvfrom(sockfd, buf, BUF_SIZ, 0, NULL, NULL); - if (verbose == 1) { - printf("\nReceived data from peer - "); - for (i = 0; i < MLAN_MAC_ADDR_LENGTH; i++) { - printf("%02x", eh->ether_shost[i]); - if (i < (MLAN_MAC_ADDR_LENGTH - 1)) - printf(":"); - } - printf("\n"); - printf("\nchannel = %d\ndata rate = %d\n" - "antenna = %d\nRSSI = %d\n", - rxctrl->rx_channel, - rxctrl->rx_datarate, - rxctrl->rx_antenna, rxctrl->rx_RSSI); - - i = sizeof(struct ether_header) + - sizeof(dot11_rxcontrol); - - if (protocol == ETH_P_WSMP) { - j = i; - printf("WSMP header : \n"); - for (; i < j + sizeof(wsmp_header); i++) - printf("%02x ", buf[i]); - printf("\n"); - } - printf("Data:\n"); - - for (; i < numbytes; i++) - printf("%02x ", buf[i]); - printf("\n"); - } else { - if (rxctrl->rx_channel != prev_channel) { - printf("channel %d : ", rxctrl->rx_channel); - for (i = 0; i < MLAN_MAC_ADDR_LENGTH; i++) - printf("%x ", eh->ether_shost[i]); - printf("\n"); - prev_channel = rxctrl->rx_channel; - } else - printf("*"); - fflush(stdout); - } - } -} - -/** - * @brief process request to send/recv WSMP packets - * - * @param argc Number of arguments - * @param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - * */ -static int -process_dot11_txrx(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - char ifName[IFNAMSIZ], file_name[100]; - int receive_protocol, verbose = 0; - - memset(ifName, 0, sizeof(ifName)); - memset(file_name, 0, sizeof(file_name)); - if (argc != 5 && argc != 6) { - fprintf(stderr, "Invalid no. of arguments\n"); - fprintf(stderr, - "Usage : ./mlanutil dot11_txrx \n" - "./mlanutil dot11_txrx send \n" - "./mlanutil dot11_txrx recv [v]\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /*copy interface name */ - strncpy(ifName, argv[1], sizeof(ifName) - 1); - - if (!strcmp(argv[3], "send")) { - strncpy(file_name, argv[4], sizeof(file_name) - 1); - if (argc == 5) - send_dot11_packet(ifName, file_name); - else { - fprintf(stderr, "Usage: " - "./mlanutil dot11_txrx send \n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - } else if (!strcmp(argv[3], "recv")) { - receive_protocol = A2HEXDECIMAL(argv[4]); - if (argc == 6 && strcmp(argv[5], "v") == 0) - verbose = 1; - receive_dot11_packet(ifName, receive_protocol, verbose); - } else { - fprintf(stderr, "Invalid option after dot11_txrx\n"); - fprintf(stderr, - "Usage : ./mlanutil dot11_txrx [options]\n" - "./mlanutil dot11_txrx send " - "./mlanutil dot11_txrx recv [v]\n"); - } - -done: - return ret; -} - -/** - * @brief Issue a tsf command - * - * @param argc number of arguments - * @param argv A pointer to arguments array - * - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -int -process_tsf(int argc, char *argv[]) -{ - int ret = MLAN_STATUS_SUCCESS; - int x; - struct ifreq ifr; - t_u8 *buffer = NULL, *pos = NULL; - t_u32 cmd_len = 0, cmd_header_len; - struct eth_priv_cmd *cmd = NULL; - HostCmd_DS_GEN *hostcmd; - - cmd_header_len = strlen(CMD_NXP) + strlen(HOSTCMD); - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (buffer == NULL) { - fprintf(stderr, "Cannot alloc memory\n"); - ret = ENOMEM; - goto done; - } - memset(buffer, 0, BUFFER_LENGTH); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - ret = ENOMEM; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* buffer = MRVL_CMD */ - strncpy((char *)buffer, CMD_NXP, strlen(CMD_NXP)); - strncpy((char *)buffer + strlen(CMD_NXP), HOSTCMD, strlen(HOSTCMD)); - - /* buffer = MRVL_CMD */ - hostcmd = (HostCmd_DS_GEN *)(buffer + cmd_header_len + sizeof(t_u32)); - - /* Point after host command header */ - pos = (t_u8 *)hostcmd + S_DS_GEN; - - cmd_len = S_DS_GEN + sizeof(t_u64); - - hostcmd->command = cpu_to_le16(HostCmd_CMD_GET_TSF); - hostcmd->size = cpu_to_le16(cmd_len); - hostcmd->seq_num = 0; - hostcmd->result = 0; - - /* Put buffer length */ - memcpy(buffer + cmd_header_len, &cmd_len, sizeof(t_u32)); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - /* Perform ioctl */ - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("ioctl[hostcmd]"); - printf("ERR:Command sending failed!\n"); - ret = -EFAULT; - goto done; - } - - printf("TSF="); - - for (x = 7; x >= 0; x--) { - printf("%02x", pos[x]); - } - - puts("\n"); - -done: - if (buffer) - free(buffer); - if (cmd) - free(cmd); - return ret; -} - -/** - * @brief Process dynamic bandwidth set/get - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_dyn_bw(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - int dyn_bw = 0; - - /* Check arguments */ - if (argc < 3 || argc > 4) { - printf("ERR:Incorrect number of arguments!\n"); - printf("Syntax: ./mlanutl mlanX dyn_bw \n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: dyn_bw fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - dyn_bw = *(int *)buffer; - printf("Dynamic bandwidth: 0x%02x\n", dyn_bw); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process set/get deauth control when uap move to another channel - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_ctrldeauth(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: deauthctrl fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - printf("Deauth control: "); - if (buffer[0]) - printf("enabled.\n"); - else - printf("disabled.\n"); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process boot sleep configure command - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_bootsleep(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Check arguments */ - if (argc != 3 && argc != 4) { - printf("ERR:Incorrect number of arguments!\n"); - printf("Syntax: ./mlanutl mlanX bootsleep <1/0>\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - -/* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: bootsleep fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process Get result */ - if (argc == 3) { - printf("boot sleep status: %u\n", *(t_u16 *)buffer); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process static rx abort config set/get - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_rx_abort_cfg(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - rx_abort_cfg_para data; - int rssi = 0; - - /* Check arguments */ - if (argc < 3 || (argc > 5)) { - printf("ERR:Incorrect number of arguments!\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: rx_abort_cfg fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - memset((void *)&data, 0, sizeof(data)); - memcpy((void *)&data, buffer, sizeof(data)); - - printf("Static Rx Abort %s\n", - (data.enable == 1) ? "enabled" : "disabled"); - - if (data.enable) { - /* on some platforms, t_s8 is same as unsigned char */ - rssi = (int)(data.rssi_threshold); - if (rssi > 0x7f) - rssi = -(256 - rssi); - printf("RSSI Threshold : %s%ddBm\n", ((rssi > 0) ? "-" : ""), - rssi); - } - printf("\n"); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process dynamic rx abort config set/get - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_rx_abort_cfg_ext(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - rx_abort_cfg_ext_para data; - int rssi; - - /* Check arguments */ - if (argc < 3 || (argc > 6)) { - printf("ERR:Incorrect number of arguments!\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: rx_abort_cfg_ext fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - memset((void *)&data, 0, sizeof(data)); - memcpy((void *)&data, buffer, sizeof(data)); - - printf("Dynamic Rx Abort %s\n", - (data.enable == 1) ? "enabled" : "disabled"); - - if (data.enable) { - /* on some platforms, t_s8 is same as unsigned char */ - rssi = (int)(data.rssi_margin); - if (rssi > 0x7f) - rssi = -(256 - rssi); - printf("RSSI Margin : %s%ddBm\n", ((rssi > 0) ? "-" : ""), - rssi); - - rssi = (int)(data.ceil_rssi_threshold); - if (rssi > 0x7f) - rssi = -(256 - rssi); - printf("Ceil RSSI Threshold : %s%ddBm\n", - ((rssi > 0) ? "-" : ""), rssi); - } - printf("\n"); - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process tx ampdu protection mode set/get - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_tx_ampdu_prot_mode(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - tx_ampdu_prot_mode_para data; - - /* Check arguments */ - if (argc < 3 || (argc > 4)) { - printf("ERR:Incorrect number of arguments!\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: tx_ampdu_prot_mode fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - memset((void *)&data, 0, sizeof(data)); - memcpy((void *)&data, buffer, sizeof(data)); - - printf("Tx AMPDU protection mode: "); - if (data.mode == TX_AMPDU_RTS_CTS) - printf("RTS/CTS\n"); - else if (data.mode == TX_AMPDU_CTS_2_SELF) - printf("CTS-2-SELF\n"); - else if (data.mode == TX_AMPDU_DYNAMIC_RTS_CTS) - printf("DYNAMIC RTS/CTS\n"); - else - printf("Disabled\n"); - printf("\n"); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process rate adapt config set/get - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_rate_adapt_cfg(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - rate_adapt_cfg_para data; - - /* Check arguments */ - if ((argc < 3) || (argc > 4 && argc != 7)) { - printf("ERR:Incorrect number of arguments!\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: rate_adapt_cfg fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - memset((void *)&data, 0, sizeof(data)); - memcpy((void *)&data, buffer, sizeof(data)); - - printf("Rate Adapt Cfg:\n"); - - if (data.sr_rateadapt == 0) - printf(" Legacy RateAdapt Enabled\n"); - else { - printf(" SR RateAdapt Enabled\n"); - if ((data.ra_low_thresh & data.ra_high_thresh) == 0xff) - printf("Dynamic rate adaptation mode based on noise level active\n"); - else { - printf("Aggregated data Tx success rate static thresholds:\n"); - printf(" Low : %u\n", data.ra_low_thresh); - printf(" High : %u\n", data.ra_high_thresh); - } - printf("Eval Timer interval : %u i.e. %ums\n", - data.ra_interval, 10 * data.ra_interval); - printf("(in multiples of 10)\n\n"); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process cck desense config set/get - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_cck_desense_cfg(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - cck_desense_cfg_para data; - int rssi; - - /* Check arguments */ - if (argc < 3 || argc > 8) { - printf("ERR:Incorrect number of arguments!\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: cck_desense_cfg fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Process result */ - memset((void *)&data, 0, sizeof(data)); - memcpy((void *)&data, buffer, sizeof(data)); - - printf("CCK Desense %s\n", (data.mode) ? "enabled" : "disabled"); - - if (data.mode != CCK_DESENSE_MODE_DISABLED) { - printf("Mode: %s\n", - (data.mode == CCK_DESENSE_MODE_DYNAMIC) ? - "Dynamic" : "Dynamic Enhanced"); - /* on some platforms, t_s8 is same as unsigned char */ - rssi = (int)(data.margin); - if (rssi > 0x7f) - rssi = -(256 - rssi); - printf("Margin : %s%ddBm\n", ((rssi > 0) ? "-" : ""), rssi); - - rssi = (int)(data.ceil_thresh); - if (rssi > 0x7f) - rssi = -(256 - rssi); - printf("Ceil RSSI Threshold : %s%ddBm\n", - ((rssi > 0) ? "-" : ""), rssi); - } - if (data.mode == CCK_DESENSE_MODE_DYN_ENH) { - printf("Num ON intervals : %d\n", data.num_on_intervals); - printf("Num OFF intervals : %d\n", data.num_off_intervals); - } - printf("\n"); - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process low power mode config set/get - * @param argc Number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_lpm(int argc, char *argv[]) -{ - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd; - struct ifreq ifr; - t_u16 lpm = 0; - - /* Check arguments */ - if (argc < 3 || argc > 4) { - printf("ERR:Incorrect number of arguments!\n"); - return MLAN_STATUS_FAILURE; - } - - /* Initialize buffer */ - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate buffer for command!\n"); - return MLAN_STATUS_FAILURE; - } - - prepare_buffer(buffer, argv[2], (argc - 3), &argv[3]); - - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR:Cannot allocate buffer for command!\n"); - free(buffer); - return MLAN_STATUS_FAILURE; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = 0; - cmd->total_len = BUFFER_LENGTH; - - /* Perform IOCTL */ - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl"); - fprintf(stderr, "mlanutl: lpm fail\n"); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return MLAN_STATUS_FAILURE; - } - - if (argc == 3) { - /* GET operation */ - lpm = *(t_u16 *)buffer; - printf("low power mode is %d\n", lpm); - } - - if (buffer) - free(buffer); - if (cmd) - free(cmd); - - return MLAN_STATUS_SUCCESS; -} - -/** - * @brief Process twt_setup - * @param argc number of arguments - * @param argv a pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_twt_setup(int argc, char *argv[]) -{ - twt_setup *param_buf = NULL; - char *line = NULL; - FILE *config_file = NULL; - int li = 0, ret = MLAN_STATUS_SUCCESS, cmd_found = 0, cmd_header_len = - 0; - char *args[30], *pos = NULL; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Check arguments */ - if (argc != 4) { - printf("ERR:Incorrect number of arguments.\n"); - printf("Syntax: ./mlanutl mlanX twt_setup \n"); - return MLAN_STATUS_FAILURE; - } - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - cmd_header_len = strlen(CMD_NXP) + strlen(argv[2]); - prepare_buffer(buffer, argv[2], 0, NULL); - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR: Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = cmd_header_len; - cmd->total_len = BUFFER_LENGTH; - - param_buf = (twt_setup *) ((t_u8 *)buffer + cmd_header_len); - - /* Check if file exists */ - config_file = fopen(argv[3], "r"); - if (config_file == NULL) { - printf("\nERR:Could not open Config file.\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - line = (char *)malloc(MAX_CONFIG_LINE); - if (!line) { - printf("ERR:Cannot allocate memory for line\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(line, 0, MAX_CONFIG_LINE); - - /* Parse file and process */ - while (config_get_line(line, MAX_CONFIG_LINE, config_file, &li, &pos)) { - parse_line(line, args, 30); - if (!cmd_found && strncmp(args[0], argv[2], strlen(args[0]))) - continue; - - cmd_found = 1; - - if (strcmp(args[0], "Implicit") == 0) { - param_buf->implicit = (t_u8)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "Announced") == 0) { - param_buf->announced = (t_u8)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "TriggerEnabled") == 0) { - param_buf->triggerEn = (t_u8)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "TWTInformationDisabled") == 0) { - param_buf->twtInfoDisabled = - (t_u8)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "NegotiationType") == 0) { - param_buf->negotiationType = - (t_u8)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "TWTWakeupDuration") == 0) { - param_buf->twtWakeupDuration = - (t_u8)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "FlowIdentifier") == 0) { - param_buf->flowIdentifier = (t_u8)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "HardConstraint") == 0) { - param_buf->hardConstraint = (t_u8)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "TWTExponent") == 0) { - param_buf->twtExponent = (t_u8)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "TWTMantissa") == 0) { - param_buf->twtMantissa = (t_u16)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "}") == 0 && cmd_found) { - break; - } - } - - if (!cmd_found) { - printf("Command %s not found in the config file!\n" - "Syntax: ./mlanutl mlanX twt_setup \n", - (char *)argv[2]); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - cmd->used_len = cmd_header_len + sizeof(twt_setup); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl: twt_setup"); - fprintf(stderr, "mlanutl:twt_setup failed\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - -done: - if (line) - free(line); - if (config_file) - fclose(config_file); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return ret; -} - -/** - * @brief Process twt_teardown - * @param argc number of arguments - * @param argv A pointer to arguments array - * @return MLAN_STATUS_SUCCESS--success, otherwise--fail - */ -static int -process_twt_teardown(int argc, char *argv[]) -{ - twt_teardown *param_buf = NULL; - char *line = NULL; - FILE *config_file = NULL; - int li = 0, ret = MLAN_STATUS_SUCCESS, cmd_found = 0, cmd_header_len = - 0; - char *args[30], *pos = NULL; - t_u8 *buffer = NULL; - struct eth_priv_cmd *cmd = NULL; - struct ifreq ifr; - - /* Check arguments */ - if (argc != 4) { - printf("ERR:Incorrect number of arguments.\n"); - printf("Syntax: ./mlanutl mlanX twt_teardown \n"); - return MLAN_STATUS_FAILURE; - } - - buffer = (t_u8 *)malloc(BUFFER_LENGTH); - if (!buffer) { - printf("ERR:Cannot allocate memory!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - cmd_header_len = strlen(CMD_NXP) + strlen(argv[2]); - prepare_buffer(buffer, argv[2], 0, NULL); - cmd = (struct eth_priv_cmd *)malloc(sizeof(struct eth_priv_cmd)); - if (!cmd) { - printf("ERR: Cannot allocate buffer for command!\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - /* Fill up buffer */ -#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT - memset(cmd, 0, sizeof(struct eth_priv_cmd)); - memcpy(&cmd->buf, &buffer, sizeof(buffer)); -#else - cmd->buf = buffer; -#endif - cmd->used_len = cmd_header_len; - cmd->total_len = BUFFER_LENGTH; - - param_buf = (twt_teardown *) ((t_u8 *)buffer + cmd_header_len); - - /* Check if file exists */ - config_file = fopen(argv[3], "r"); - if (config_file == NULL) { - printf("\nERR:Could not open Config file.\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - line = (char *)malloc(MAX_CONFIG_LINE); - if (!line) { - printf("ERR:Cannot allocate memory for line\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - memset(line, 0, MAX_CONFIG_LINE); - - /* Parse file and process */ - while (config_get_line(line, MAX_CONFIG_LINE, config_file, &li, &pos)) { - parse_line(line, args, 30); - if (!cmd_found && strncmp(args[0], argv[2], strlen(args[0]))) - continue; - - cmd_found = 1; - - if (strcmp(args[0], "FlowIdentifier") == 0) { - param_buf->flowIdentifier = (t_u8)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "NegotiationType") == 0) { - param_buf->negotiationType = - (t_u8)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "TearDownAllTWT") == 0) { - param_buf->teardownAllTWT = (t_u8)A2HEXDECIMAL(args[1]); - } else if (strcmp(args[0], "}") == 0 && cmd_found) { - break; - } - } - - if (!cmd_found) { - printf("Command %s not found in the config file!\n" - "Syntax: ./mlanutl mlanX twt_teardown \n", - (char *)argv[2]); - ret = MLAN_STATUS_FAILURE; - goto done; - } - - cmd->used_len = cmd_header_len + sizeof(twt_teardown); - - /* Initialize the ifr structure */ - memset(&ifr, 0, sizeof(ifr)); - - strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name)); - ifr.ifr_ifru.ifru_data = (void *)cmd; - - if (ioctl(sockfd, MLAN_ETH_PRIV, &ifr)) { - perror("mlanutl: twt_teardown"); - fprintf(stderr, "mlanutl:twt_teardown failed\n"); - ret = MLAN_STATUS_FAILURE; - goto done; - } - -done: - if (line) - free(line); - if (config_file) - fclose(config_file); - if (cmd) - free(cmd); - if (buffer) - free(buffer); - return ret; -} - /******************************************************** Global Functions ********************************************************/ @@ -20380,8 +1899,7 @@ done: * @param argv A pointer to arguments array * @return MLAN_STATUS_SUCCESS--success, otherwise--fail */ -int -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int ret = MLAN_STATUS_SUCCESS; @@ -20409,8 +1927,6 @@ main(int argc, char *argv[]) ret = process_command(argc, argv); if (ret == MLAN_STATUS_NOTFOUND) { - ret = process_generic(argc, argv); - if (ret) { fprintf(stderr, "Invalid command specified!\n"); display_usage(); diff --git a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.h b/mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.h index 5426bb1..300446b 100644 --- a/mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.h +++ b/mxm_wifiex/wlan_src/mapp/mlanutl/mlanutl.h @@ -1,24 +1,24 @@ /** @file mlanutl.h - * - * @brief This file contains definitions for application - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ + * + * @brief This file contains definitions for application + * + * + * Copyright 2014-2020 NXP + * + * This software file (the File) is distributed by NXP + * under the terms of the GNU General Public License Version 2, June 1991 + * (the License). You may use, redistribute and/or modify the File in + * accordance with the terms and conditions of the License, a copy of which + * is available by writing to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the + * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. + * + * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE + * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE + * ARE EXPRESSLY DISCLAIMED. The License provides additional details about + * this warranty disclaimer. + * + */ /************************************************************************ Change log: 11/26/2008: initial version @@ -27,19 +27,19 @@ Change log: #define _MLANUTL_H_ /** Include header files */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -48,46 +48,45 @@ Change log: typedef enum { FALSE, TRUE } boolean; /** 16 bits byte swap */ -#define swap_byte_16(x) \ -((t_u16)((((t_u16)(x) & 0x00ffU) << 8) | \ - (((t_u16)(x) & 0xff00U) >> 8))) +#define swap_byte_16(x) \ + ((t_u16)((((t_u16)(x)&0x00ffU) << 8) | (((t_u16)(x)&0xff00U) >> 8))) /** 32 bits byte swap */ -#define swap_byte_32(x) \ -((t_u32)((((t_u32)(x) & 0x000000ffUL) << 24) | \ - (((t_u32)(x) & 0x0000ff00UL) << 8) | \ - (((t_u32)(x) & 0x00ff0000UL) >> 8) | \ - (((t_u32)(x) & 0xff000000UL) >> 24))) +#define swap_byte_32(x) \ + ((t_u32)((((t_u32)(x)&0x000000ffUL) << 24) | \ + (((t_u32)(x)&0x0000ff00UL) << 8) | \ + (((t_u32)(x)&0x00ff0000UL) >> 8) | \ + (((t_u32)(x)&0xff000000UL) >> 24))) /** Convert to correct endian format */ #ifdef BIG_ENDIAN_SUPPORT /** CPU to little-endian convert for 16-bit */ -#define cpu_to_le16(x) swap_byte_16(x) +#define cpu_to_le16(x) swap_byte_16(x) /** CPU to little-endian convert for 32-bit */ -#define cpu_to_le32(x) swap_byte_32(x) +#define cpu_to_le32(x) swap_byte_32(x) /** Little-endian to CPU convert for 16-bit */ -#define le16_to_cpu(x) swap_byte_16(x) +#define le16_to_cpu(x) swap_byte_16(x) /** Little-endian to CPU convert for 32-bit */ -#define le32_to_cpu(x) swap_byte_32(x) +#define le32_to_cpu(x) swap_byte_32(x) #else /** Do nothing */ -#define cpu_to_le16(x) (x) +#define cpu_to_le16(x) (x) /** Do nothing */ -#define cpu_to_le32(x) (x) +#define cpu_to_le32(x) (x) /** Do nothing */ -#define le16_to_cpu(x) (x) +#define le16_to_cpu(x) (x) /** Do nothing */ -#define le32_to_cpu(x) (x) +#define le32_to_cpu(x) (x) #endif /** TLV header */ -#define TLVHEADER /** Tag */ \ - t_u16 tag; \ - /** Length */ \ - t_u16 length +#define TLVHEADER /** Tag */ \ + t_u16 tag; \ + /** Length */ \ + t_u16 length /** Length of TLV header */ -#define TLVHEADER_LEN 4 +#define TLVHEADER_LEN 4 /** Character, 1 byte */ typedef signed char t_s8; @@ -112,29 +111,38 @@ typedef unsigned long long t_u64; /** Void pointer (4-bytes) */ typedef void t_void; +enum _mlan_act_ioctl { + MLAN_ACT_SET = 1, + MLAN_ACT_GET, + MLAN_ACT_CANCEL, + MLAN_ACT_CLEAR, + MLAN_ACT_RESET, + MLAN_ACT_DEFAULT +}; + /** The attribute pack used for structure packing */ #ifndef __ATTRIB_PACK__ -#define __ATTRIB_PACK__ __attribute__((packed)) +#define __ATTRIB_PACK__ __attribute__((packed)) #endif /** Success */ -#define MLAN_STATUS_SUCCESS (0) +#define MLAN_STATUS_SUCCESS (0) /** Failure */ -#define MLAN_STATUS_FAILURE (-1) +#define MLAN_STATUS_FAILURE (-1) /** Not found */ -#define MLAN_STATUS_NOTFOUND (1) +#define MLAN_STATUS_NOTFOUND (1) /** IOCTL number */ -#define MLAN_ETH_PRIV (SIOCDEVPRIVATE + 14) +#define MLAN_ETH_PRIV (SIOCDEVPRIVATE + 14) /** Command buffer max length */ -#define BUFFER_LENGTH (3 * 1024) +#define BUFFER_LENGTH (3 * 1024) /** Find number of elements */ -#define NELEMENTS(x) (sizeof(x)/sizeof(x[0])) +#define NELEMENTS(x) (sizeof(x) / sizeof(x[0])) /** BIT value */ -#define MBIT(x) (((t_u32)1) << (x)) +#define MBIT(x) (((t_u32)1) << (x)) #ifndef MIN /** Find minimum value */ @@ -143,577 +151,193 @@ typedef void t_void; /** Length of ethernet address */ #ifndef ETH_ALEN -#define ETH_ALEN 6 +#define ETH_ALEN 6 #endif /** Action field value : get */ -#define ACTION_GET 0 +#define ACTION_GET 0 /** Action field value : set */ -#define ACTION_SET 1 - -/** Channel usability flags */ -#define NXP_CHANNEL_DISABLED MBIT(7) -#define NXP_CHANNEL_NOHT160 MBIT(4) -#define NXP_CHANNEL_NOHT80 MBIT(3) -#define NXP_CHANNEL_NOHT40 MBIT(2) -#define NXP_CHANNEL_DFS MBIT(1) -#define NXP_CHANNEL_PASSIVE MBIT(0) - -char mod_conv_bg_1x1[10][35] = { "CCK (1,2,5.5,11 Mbps)", - "OFDM_PSK (6,9,12,18 Mbps)", - "OFDM_QAM16 (24,36 Mbps)", - "OFDM_QAM64 (48,54 Mbps)", - "HT_20_PSK (MCS 0,1,2)", - "HT_20_QAM16 (MCS 3,4)", - "HT_20_QAM64 (MCS 5,6,7)", - "HT_40_PSK (MCS 0,1,2)", - "HT_40_QAM16 (MCS 3,4)", - "HT_40_QAM64 (MCS 5,6,7)" -}; - -char mod_conv_a_1x1[6][35] = { "VHT_20_QAM256 (MCS 8)", - "VHT_40_QAM256 (MCS 8,9)", - "VHT_80_PSK (MCS 0,1,2)", - "VHT_80_QAM16 (MCS 3,4)", - "VHT_80_QAM64 (MCS 5,6,7)", - "VHT_80_QAM256 (MCS 8,9)" -}; - -char mod_conv_bg_2x2[6][35] = { "HT2_20_PSK (MCS 8,9,10)", - "HT2_20_QAM16 (MCS 11,12)", - "HT2_20_QAM64 (MCS 13,14,15)", - "HT2_40_PSK (MCS 8,9,10)", - "HT2_40_QAM16 (MCS 11,12)", - "HT2_40_QAM64 (MCS 13,14,15)" -}; - -char mod_conv_a_2x2[6][35] = { "VHT2_20_QAM256 (MCS 8)", - "VHT2_40_QAM256 (MCS 8,9)", - "VHT2_80_PSK (MCS 0,1,2)", - "VHT2_80_QAM16 (MCS 3,4)", - "VHT2_80_QAM64 (MCS 5,6,7)", - "VHT2_80_QAM256 (MCS 8,9)" -}; - -/** Socket */ -extern t_s32 sockfd; +#define ACTION_SET 1 /** Device name */ extern char dev_name[IFNAMSIZ + 1]; -#define HOSTCMD "hostcmd" +#define HOSTCMD "hostcmd" /** NXP private command identifier */ -#define CMD_NXP "MRVL_CMD" +#define CMD_NXP "MRVL_CMD" struct command_node { char *name; - int (*handler) (int, char **); + int (*handler)(int, char **); }; /** Private command structure */ #ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT struct eth_priv_cmd { - /** Command buffer pointer */ + /** Command buffer pointer */ t_u64 buf; - /** buffer updated by driver */ + /** buffer updated by driver */ int used_len; - /** buffer sent by application */ + /** buffer sent by application */ int total_len; } __ATTRIB_PACK__; #else struct eth_priv_cmd { - /** Command buffer */ + /** Command buffer */ t_u8 *buf; - /** Used length */ + /** Used length */ int used_len; - /** Total length */ + /** Total length */ int total_len; }; #endif -#if defined(STA_SUPPORT) -struct eth_priv_pmfcfg { - /* Management Frame Protection Capability */ - t_u8 mfpc; - /* Management Frame Protection Required */ - t_u8 mfpr; -}; -#endif - struct eth_priv_htcapinfo { t_u32 ht_cap_info_bg; t_u32 ht_cap_info_a; }; -#define MAX_NUM_MAC 2 - -struct dmcsChanStatus_t { - /** Channel number */ - t_u8 channel; - /** Number of ap on this channel */ - t_u8 ap_count; - /** Number of station on this channel */ - t_u8 sta_count; -}; - -struct dmcsStatus_t { - /** Radio ID */ - t_u8 radio_id; - /** Running mode */ - t_u8 running_mode; - /** Current channel status */ - struct dmcsChanStatus_t chan_status[2]; -}; - -/** data structure for cmd dmcs */ -struct eth_priv_dmcs_status { - /** Current mapping policy */ - t_u8 mapping_policy; - /** radio status of DMCS */ - struct dmcsStatus_t radio_status[MAX_NUM_MAC]; -}; - -struct eth_priv_addba { - t_u32 time_out; - t_u32 tx_win_size; - t_u32 rx_win_size; - t_u32 tx_amsdu; - t_u32 rx_amsdu; -}; - -/** data_structure for cmd vhtcfg */ -struct eth_priv_vhtcfg { - /** Band (1: 2.4G, 2: 5 G, 3: both 2.4G and 5G) */ - t_u32 band; - /** TxRx (1: Tx, 2: Rx, 3: both Tx and Rx) */ - t_u32 txrx; - /** BW CFG (0: 11N CFG, 1: vhtcap) */ - t_u32 bwcfg; - /** VHT capabilities. */ - t_u32 vht_cap_info; - /** VHT Tx mcs */ - t_u32 vht_tx_mcs; - /** VHT Rx mcs */ - t_u32 vht_rx_mcs; - /** VHT rx max rate */ - t_u16 vht_rx_max_rate; - /** VHT max tx rate */ - t_u16 vht_tx_max_rate; -}; - -/** data_structure for cmd opermodecfg */ -struct eth_priv_opermodecfg { - /** channel width: 1-20MHz, 2-40MHz, 3-80MHz, 4-160MHz or 80+80MHz */ - t_u8 bw; - /** Rx NSS */ - t_u8 nss; -}; - /** data structure for cmd getdatarate */ struct eth_priv_data_rate { - /** Tx data rate */ + /** Tx data rate */ t_u32 tx_data_rate; - /** Rx data rate */ + /** Rx data rate */ t_u32 rx_data_rate; - /** Tx channel bandwidth */ + /** Tx channel bandwidth */ t_u32 tx_bw; - /** Tx guard interval */ + /** Tx guard interval */ t_u32 tx_gi; - /** Rx channel bandwidth */ + /** Rx channel bandwidth */ t_u32 rx_bw; - /** Rx guard interval */ + /** Rx guard interval */ t_u32 rx_gi; - /** MCS index */ + /** MCS index */ t_u32 tx_mcs_index; t_u32 rx_mcs_index; - /** NSS */ + /** NSS */ t_u32 tx_nss; t_u32 rx_nss; /* LG rate: 0, HT rate: 1, VHT rate: 2 */ t_u32 tx_rate_format; t_u32 rx_rate_format; }; - -/** data structure for cmd bandcfg */ -struct eth_priv_bandcfg { - /** Infra band */ - t_u32 config_bands; - /** Ad-hoc start band */ - t_u32 adhoc_start_band; - /** Ad-hoc start channel */ - t_u32 adhoc_channel; - /** fw supported band */ - t_u32 fw_bands; -}; - -/** data structure for cmd txratecfg */ -struct eth_priv_tx_rate_cfg { - /* LG rate: 0, HT rate: 1, VHT rate: 2 */ - t_u32 rate_format; - /** Rate/MCS index (0xFF: auto) */ - t_u32 rate_index; - /** Rate rate */ - t_u32 rate; - /** NSS */ - t_u32 nss; - /** Rate Setting */ - t_u16 rate_setting; -}; - /** data structure for cmd getlog */ struct eth_priv_get_log { - /** Multicast transmitted frame count */ + /** Multicast transmitted frame count */ t_u32 mcast_tx_frame; - /** Failure count */ + /** Failure count */ t_u32 failed; - /** Retry count */ + /** Retry count */ t_u32 retry; - /** Multi entry count */ + /** Multi entry count */ t_u32 multi_retry; - /** Duplicate frame count */ + /** Duplicate frame count */ t_u32 frame_dup; - /** RTS success count */ + /** RTS success count */ t_u32 rts_success; - /** RTS failure count */ + /** RTS failure count */ t_u32 rts_failure; - /** Ack failure count */ + /** Ack failure count */ t_u32 ack_failure; - /** Rx fragmentation count */ + /** Rx fragmentation count */ t_u32 rx_frag; - /** Multicast Tx frame count */ + /** Multicast Tx frame count */ t_u32 mcast_rx_frame; - /** FCS error count */ + /** FCS error count */ t_u32 fcs_error; - /** Tx frame count */ + /** Tx frame count */ t_u32 tx_frame; - /** WEP ICV error count */ + /** WEP ICV error count */ t_u32 wep_icv_error[4]; - /** beacon recv count */ + /** beacon recv count */ t_u32 bcn_rcv_cnt; - /** beacon miss count */ + /** beacon miss count */ t_u32 bcn_miss_cnt; - /** Tx frag count */ + /** Tx frag count */ t_u32 tx_frag_cnt; - /** Qos Tx frag count */ + /** Qos Tx frag count */ t_u32 qos_tx_frag_cnt[8]; - /** Qos failed count */ + /** Qos failed count */ t_u32 qos_failed_cnt[8]; - /** Qos retry count */ + /** Qos retry count */ t_u32 qos_retry_cnt[8]; - /** Qos multi retry count */ + /** Qos multi retry count */ t_u32 qos_multi_retry_cnt[8]; - /** Qos frame dup count */ + /** Qos frame dup count */ t_u32 qos_frm_dup_cnt[8]; - /** Qos rts success count */ + /** Qos rts success count */ t_u32 qos_rts_suc_cnt[8]; - /** Qos rts failure count */ + /** Qos rts failure count */ t_u32 qos_rts_failure_cnt[8]; - /** Qos ack failure count */ + /** Qos ack failure count */ t_u32 qos_ack_failure_cnt[8]; - /** Qos Rx frag count */ + /** Qos Rx frag count */ t_u32 qos_rx_frag_cnt[8]; - /** Qos Tx frame count */ + /** Qos Tx frame count */ t_u32 qos_tx_frm_cnt[8]; - /** Qos discarded frame count */ + /** Qos discarded frame count */ t_u32 qos_discarded_frm_cnt[8]; - /** Qos mpdus Rx count */ + /** Qos mpdus Rx count */ t_u32 qos_mpdus_rx_cnt[8]; - /** Qos retry rx count */ + /** Qos retry rx count */ t_u32 qos_retries_rx_cnt[8]; - /** CMACICV errors count */ + /** CMACICV errors count */ t_u32 cmacicv_errors; - /** CMAC replays count */ + /** CMAC replays count */ t_u32 cmac_replays; - /** mgmt CCMP replays count */ + /** mgmt CCMP replays count */ t_u32 mgmt_ccmp_replays; - /** TKIP ICV errors count */ + /** TKIP ICV errors count */ t_u32 tkipicv_errors; - /** TKIP replays count */ + /** TKIP replays count */ t_u32 tkip_replays; - /** CCMP decrypt errors count */ + /** CCMP decrypt errors count */ t_u32 ccmp_decrypt_errors; - /** CCMP replays count */ + /** CCMP replays count */ t_u32 ccmp_replays; - /** Tx amsdu count */ + /** Tx amsdu count */ t_u32 tx_amsdu_cnt; - /** failed amsdu count */ + /** failed amsdu count */ t_u32 failed_amsdu_cnt; - /** retry amsdu count */ + /** retry amsdu count */ t_u32 retry_amsdu_cnt; - /** multi-retry amsdu count */ + /** multi-retry amsdu count */ t_u32 multi_retry_amsdu_cnt; - /** Tx octets in amsdu count */ + /** Tx octets in amsdu count */ t_u64 tx_octets_in_amsdu_cnt; - /** amsdu ack failure count */ + /** amsdu ack failure count */ t_u32 amsdu_ack_failure_cnt; - /** Rx amsdu count */ + /** Rx amsdu count */ t_u32 rx_amsdu_cnt; - /** Rx octets in amsdu count */ + /** Rx octets in amsdu count */ t_u64 rx_octets_in_amsdu_cnt; - /** Tx ampdu count */ + /** Tx ampdu count */ t_u32 tx_ampdu_cnt; - /** tx mpdus in ampdu count */ + /** tx mpdus in ampdu count */ t_u32 tx_mpdus_in_ampdu_cnt; - /** tx octets in ampdu count */ + /** tx octets in ampdu count */ t_u64 tx_octets_in_ampdu_cnt; - /** ampdu Rx count */ + /** ampdu Rx count */ t_u32 ampdu_rx_cnt; - /** mpdu in Rx ampdu count */ + /** mpdu in Rx ampdu count */ t_u32 mpdu_in_rx_ampdu_cnt; - /** Rx octets ampdu count */ + /** Rx octets ampdu count */ t_u64 rx_octets_in_ampdu_cnt; - /** ampdu delimiter CRC error count */ + /** ampdu delimiter CRC error count */ t_u32 ampdu_delimiter_crc_error_cnt; }; -struct eth_priv_esuppmode_cfg { - /* RSN mode */ - t_u16 rsn_mode; - /* Pairwise cipher */ - t_u8 pairwise_cipher; - /* Group cipher */ - t_u8 group_cipher; -}; - /** MLAN MAC Address Length */ -#define MLAN_MAC_ADDR_LENGTH 6 -#ifdef UAP_SUPPORT -/** Max clients supported by AP */ -#define MAX_AP_CLIENTS 64 -/** associated station info */ -struct ap_client_info { - /** STA MAC address */ - t_u8 mac_address[MLAN_MAC_ADDR_LENGTH]; - /** Power Mgmt status */ - t_u8 power_mgmt_status; - /** RSSI */ - t_s8 rssi; -}; - -/** Type definition of eth_priv_getstalist */ -struct eth_priv_getstalist { - /** station count */ - t_u16 sta_count; - /** station list */ - struct ap_client_info client_info[MAX_AP_CLIENTS]; -}; -#endif - -#define COUNTRY_CODE_LEN 3 +#define MLAN_MAC_ADDR_LENGTH 6 +#define COUNTRY_CODE_LEN 3 /** Type definition of eth_priv_countrycode for CMD_COUNTRYCODE */ struct eth_priv_countrycode { - /** Country Code */ + /** Country Code */ t_u8 country_code[COUNTRY_CODE_LEN]; }; -/** Type definition of mlan_ds_hs_cfg for MLAN_OID_PM_CFG_HS_CFG */ -struct eth_priv_hs_cfg { - /** MTRUE to invoke the HostCmd, MFALSE otherwise */ - t_u32 is_invoke_hostcmd; - /** Host sleep config condition */ - /** Bit0: broadcast data - * Bit1: unicast data - * Bit2: mac event - * Bit3: multicast data - */ - t_u32 conditions; - /** GPIO pin or 0xff for interface */ - t_u32 gpio; - /** Gap in milliseconds or or 0xff for special setting when GPIO is used to wakeup host */ - t_u32 gap; - /** Host sleep wake interval */ - t_u32 hs_wake_interval; - /** Parameter type*/ - t_u8 param_type_ind; - /** Indication GPIO pin number */ - t_u32 ind_gpio; - /** Level on ind_GPIO pin for normal wakeup source */ - t_u32 level; - /** Parameter type*/ - t_u8 param_type_ext; - /** Force ignore events*/ - t_u32 event_force_ignore; - /** Events use ext gap to wake up host*/ - t_u32 event_use_ext_gap; - /** Ext gap*/ - t_u8 ext_gap; - /** GPIO wave level*/ - t_u8 gpio_wave; -}; - -typedef struct _eth_priv_mgmt_frame_wakeup { - /** action - bitmap - ** On matching rx'd pkt and filter during NON_HOSTSLEEP mode: - ** Action[1]=0 Discard - ** Action[1]=1 Allow - ** Note that default action on non-match is "Allow". - ** - ** On matching rx'd pkt and filter during HOSTSLEEP mode: - ** Action[1:0]=00 Discard and Not Wake host - ** Action[1:0]=01 Discard and Wake host - ** Action[1:0]=10 Invalid - ** Note that default action on non-match is "Discard and Not Wake host". - **/ - t_u32 action; - /** Frame type(p2p, tdls...) - ** type=0: invalid - ** type=1: p2p - ** type=0xff: management frames(assoc res/rsp,probe req/rsp,...) - ** type=others: reserved - **/ - t_u32 type; - /** Frame mask according to each type - ** When type=1 for p2p, frame-mask have following define: - ** Bit Frame - ** 0 GO Negotiation Request - ** 1 GO Negotiation Response - ** 2 GO Negotiation Confirmation - ** 3 P2P Invitation Request - ** 4 P2P Invitation Response - ** 5 Device Discoverability Request - ** 6 Device Discoverability Response - ** 7 Provision Discovery Request - ** 8 Provision Discovery Response - ** 9 Notice of Absence - ** 10 P2P Presence Request - ** 11 P2P Presence Response - ** 12 GO Discoverability Request - ** 13-31 Reserved - ** - ** When type=others, frame-mask is reserved. - **/ - t_u32 frame_mask; -} eth_priv_mgmt_frame_wakeup; - -/** Type definition of eth_priv_scan_time_params */ -struct eth_priv_scan_time_params { - /** Scan channel time for specific scan in milliseconds */ - t_u32 specific_scan_time; - /** Scan channel time for active scan in milliseconds */ - t_u32 active_scan_time; - /** Scan channel time for passive scan in milliseconds */ - t_u32 passive_scan_time; -}; - -/** Type definition of eth_priv_scan_cfg */ -struct eth_priv_scan_cfg { - /** Scan type */ - t_u32 scan_type; - /** BSS mode for scanning */ - t_u32 scan_mode; - /** Scan probe */ - t_u32 scan_probe; - /** Scan time parameters */ - struct eth_priv_scan_time_params scan_time; - /** First passive scan then active scan */ - t_u8 passive_to_active_scan; - /** Extended Scan */ - t_u32 ext_scan; - /* Time gap between two scan channels in milliseconds */ - t_u32 scan_chan_gap; -}; - -enum _mlan_rate_format { - MLAN_RATE_FORMAT_LG = 0, - MLAN_RATE_FORMAT_HT, - MLAN_RATE_FORMAT_VHT, - MLAN_RATE_FORMAT_AUTO = 0xFF, -}; - -/** HT channel bandwidth */ -typedef enum _mlan_ht_bw { - MLAN_HT_BW20, - MLAN_HT_BW40, -/** VHT channel bandwidth */ - MLAN_VHT_BW80, - MLAN_VHT_BW160, -} mlan_ht_bw; -/** Type definition of mlan_power group info */ -struct eth_priv_power_group { - /** rate format (LG rate: 0; HT rate: 1; VHT rate: 2; no auto ctrl: 0xFF) */ - t_u32 rate_format; - /** bandwidth (LG: 20 MHz; HT: 20/40 MHz; VHT: 80/160/80+80 MHz) */ - t_u8 bandwidth; - /** NSS */ - t_u32 nss; - /** LG: first rate index; HT/VHT: first MCS */ - t_u8 first_rate_ind; - /** LG: last rate index; HT/VHT: last MCS */ - t_u8 last_rate_ind; - /** minmum tx power (dBm) */ - t_s8 power_min; - /** maximum tx power (dBm) */ - t_s8 power_max; - /** tx power step (dB) */ - t_s8 power_step; -}; - -/** max of power groups */ -#define MAX_POWER_GROUP 64 -/** Type definition of mlan_power_cfg_ext */ -struct eth_priv_power_cfg_ext { - /** number of power_groups */ - t_u32 num_pwr_grp; - /** array of power groups */ - struct eth_priv_power_group power_group[MAX_POWER_GROUP]; -}; - -/** Type definition of eth_priv_ds_ps_cfg */ -struct eth_priv_ds_ps_cfg { - /** PS null interval in seconds */ - t_u32 ps_null_interval; - /** Multiple DTIM interval */ - t_u32 multiple_dtim_interval; - /** Listen interval */ - t_u32 listen_interval; - /** Beacon miss timeout in milliseconds */ - t_u32 bcn_miss_timeout; - /** Delay to PS in milliseconds */ - t_s32 delay_to_ps; - /** PS mode */ - t_u32 ps_mode; -}; - -#ifdef STA_SUPPORT - -/** Maximum length of SSID */ -#define MRVDRV_MAX_SSID_LENGTH 32 - -/** Maximum length of SSID list */ -#define MRVDRV_MAX_SSID_LIST_LENGTH 10 - -/** Maximum length of BSSID list */ -#define MAX_BSSID_FILTER_LIST 5 - -/** Bssid structure */ -typedef struct { - /* bssid */ - t_u8 bssid[ETH_ALEN]; -} __ATTRIB_PACK__ wlan_ioctl_user_scan_bssid; - -/** Maximum number of channels that can be sent in a setuserscan ioctl */ -#define WLAN_IOCTL_USER_SCAN_CHAN_MAX 50 - -/** Maximum channel scratch */ -#define MAX_CHAN_SCRATCH 100 - -/** Maximum channel number for b/g band */ -#define MAX_CHAN_BG_BAND 14 - -/** Maximum number of probes to send on each channel */ -#define MAX_PROBES 5 - -/** Scan all the channels in specified band */ -#define BAND_SPECIFIED 0x80 - -/** Maximum size of IEEE Information Elements */ -#define IEEE_MAX_IE_SIZE 256 - -/** Maximum number of TID */ -#define MAX_NUM_TID 8 - /** Type enumeration of WMM AC_QUEUES */ typedef enum _mlan_wmm_ac_e { WMM_AC_BK, @@ -722,28 +346,6 @@ typedef enum _mlan_wmm_ac_e { WMM_AC_VO } __ATTRIB_PACK__ mlan_wmm_ac_e; -/** Enumeration for scan mode */ -enum { - MLAN_SCAN_MODE_UNCHANGED = 0, - MLAN_SCAN_MODE_BSS, - MLAN_SCAN_MODE_IBSS, - MLAN_SCAN_MODE_ANY -}; - -/** Enumeration for scan type */ -enum { - MLAN_SCAN_TYPE_UNCHANGED = 0, - MLAN_SCAN_TYPE_ACTIVE, - MLAN_SCAN_TYPE_PASSIVE -}; - -/** Enumeration for passive to active scan */ -enum _mlan_pass_to_act_scan { - MLAN_PASS_TO_ACT_SCAN_UNCHANGED = 0, - MLAN_PASS_TO_ACT_SCAN_EN, - MLAN_PASS_TO_ACT_SCAN_DIS -}; - /** IEEE Type definitions */ typedef enum _IEEEtypes_ElementId_e { SSID = 0, @@ -795,2092 +397,248 @@ typedef enum _IEEEtypes_ElementId_e { /** Capability Bit Map*/ #ifdef BIG_ENDIAN_SUPPORT typedef struct _IEEEtypes_CapInfo_t { - t_u8 rsrvd1:2; - t_u8 dsss_ofdm:1; - t_u8 rsvrd2:2; - t_u8 short_slot_time:1; - t_u8 rsrvd3:1; - t_u8 spectrum_mgmt:1; - t_u8 chan_agility:1; - t_u8 pbcc:1; - t_u8 short_preamble:1; - t_u8 privacy:1; - t_u8 cf_poll_rqst:1; - t_u8 cf_pollable:1; - t_u8 ibss:1; - t_u8 ess:1; + t_u8 rsrvd1 : 2; + t_u8 dsss_ofdm : 1; + t_u8 rsvrd2 : 2; + t_u8 short_slot_time : 1; + t_u8 rsrvd3 : 1; + t_u8 spectrum_mgmt : 1; + t_u8 chan_agility : 1; + t_u8 pbcc : 1; + t_u8 short_preamble : 1; + t_u8 privacy : 1; + t_u8 cf_poll_rqst : 1; + t_u8 cf_pollable : 1; + t_u8 ibss : 1; + t_u8 ess : 1; } __ATTRIB_PACK__ IEEEtypes_CapInfo_t, *pIEEEtypes_CapInfo_t; #else typedef struct _IEEEtypes_CapInfo_t { - /** Capability Bit Map : ESS */ - t_u8 ess:1; - /** Capability Bit Map : IBSS */ - t_u8 ibss:1; - /** Capability Bit Map : CF pollable */ - t_u8 cf_pollable:1; - /** Capability Bit Map : CF poll request */ - t_u8 cf_poll_rqst:1; - /** Capability Bit Map : privacy */ - t_u8 privacy:1; - /** Capability Bit Map : Short preamble */ - t_u8 short_preamble:1; - /** Capability Bit Map : PBCC */ - t_u8 pbcc:1; - /** Capability Bit Map : Channel agility */ - t_u8 chan_agility:1; - /** Capability Bit Map : Spectrum management */ - t_u8 spectrum_mgmt:1; - /** Capability Bit Map : Reserved */ - t_u8 rsrvd3:1; - /** Capability Bit Map : Short slot time */ - t_u8 short_slot_time:1; - /** Capability Bit Map : APSD */ - t_u8 apsd:1; - /** Capability Bit Map : Reserved */ - t_u8 rsvrd2:1; - /** Capability Bit Map : DSS OFDM */ - t_u8 dsss_ofdm:1; - /** Capability Bit Map : Reserved */ - t_u8 rsrvd1:2; + /** Capability Bit Map : ESS */ + t_u8 ess : 1; + /** Capability Bit Map : IBSS */ + t_u8 ibss : 1; + /** Capability Bit Map : CF pollable */ + t_u8 cf_pollable : 1; + /** Capability Bit Map : CF poll request */ + t_u8 cf_poll_rqst : 1; + /** Capability Bit Map : privacy */ + t_u8 privacy : 1; + /** Capability Bit Map : Short preamble */ + t_u8 short_preamble : 1; + /** Capability Bit Map : PBCC */ + t_u8 pbcc : 1; + /** Capability Bit Map : Channel agility */ + t_u8 chan_agility : 1; + /** Capability Bit Map : Spectrum management */ + t_u8 spectrum_mgmt : 1; + /** Capability Bit Map : Reserved */ + t_u8 rsrvd3 : 1; + /** Capability Bit Map : Short slot time */ + t_u8 short_slot_time : 1; + /** Capability Bit Map : APSD */ + t_u8 apsd : 1; + /** Capability Bit Map : Reserved */ + t_u8 rsvrd2 : 1; + /** Capability Bit Map : DSS OFDM */ + t_u8 dsss_ofdm : 1; + /** Capability Bit Map : Reserved */ + t_u8 rsrvd1 : 2; } __ATTRIB_PACK__ IEEEtypes_CapInfo_t, *pIEEEtypes_CapInfo_t; #endif /* BIG_ENDIAN_SUPPORT */ /** IEEE IE header */ typedef struct _IEEEtypes_Header_t { - /** Element ID */ + /** Element ID */ t_u8 element_id; - /** Length */ + /** Length */ t_u8 len; } __ATTRIB_PACK__ IEEEtypes_Header_t, *pIEEEtypes_Header_t; /** IEEE IE header */ -#define IEEE_HEADER_LEN sizeof(IEEEtypes_Header_t) +#define IEEE_HEADER_LEN sizeof(IEEEtypes_Header_t) +/** Maximum size of IEEE Information Elements */ +#define IEEE_MAX_IE_SIZE 256 /** Vendor specific IE header */ typedef struct _IEEEtypes_VendorHeader_t { - /** Element ID */ + /** Element ID */ t_u8 element_id; - /** Length */ + /** Length */ t_u8 len; - /** OUI */ + /** OUI */ t_u8 oui[3]; - /** OUI type */ + /** OUI type */ t_u8 oui_type; - /** OUI subtype */ + /** OUI subtype */ t_u8 oui_subtype; - /** Version */ + /** Version */ t_u8 version; } __ATTRIB_PACK__ IEEEtypes_VendorHeader_t, *pIEEEtypes_VendorHeader_t; /** Vendor specific IE */ typedef struct _IEEEtypes_VendorSpecific_t { - /** Vendor specific IE header */ + /** Vendor specific IE header */ IEEEtypes_VendorHeader_t vend_hdr; - /** IE Max - size of previous fields */ + /** IE Max - size of previous fields */ t_u8 data[IEEE_MAX_IE_SIZE - sizeof(IEEEtypes_VendorHeader_t)]; } __ATTRIB_PACK__ IEEEtypes_VendorSpecific_t, *pIEEEtypes_VendorSpecific_t; /** IEEE IE */ typedef struct _IEEEtypes_Generic_t { - /** Generic IE header */ + /** Generic IE header */ IEEEtypes_Header_t ieee_hdr; - /** IE Max - size of previous fields */ + /** IE Max - size of previous fields */ t_u8 data[IEEE_MAX_IE_SIZE - sizeof(IEEEtypes_Header_t)]; } __ATTRIB_PACK__ IEEEtypes_Generic_t, *pIEEEtypes_Generic_t; -typedef struct _wlan_get_scan_table_fixed { - /** BSSID of this network */ - t_u8 bssid[MLAN_MAC_ADDR_LENGTH]; - /** Channel this beacon/probe response was detected */ - t_u8 channel; - /** RSSI for the received packet */ - t_u8 rssi; - /** Channel Load (max = 100) */ - t_u8 chan_load; - /** TSF value from the firmware at packet reception */ - t_u64 network_tsf; -} wlan_get_scan_table_fixed; - -/** - * Structure passed in the wlan_ioctl_get_scan_table_info for each - * BSS returned in the WLAN_GET_SCAN_RESP IOCTL - */ -typedef struct _wlan_ioctl_get_scan_table_entry { - /** - * Fixed field length included in the response. - * - * Length value is included so future fixed fields can be added to the - * response without breaking backwards compatibility. Use the length - * to find the offset for the bssInfoLength field, not a sizeof() calc. - */ - t_u32 fixed_field_length; - - /** - * Length of the BSS Information (probe resp or beacon) that - * follows after the fixed_field_length - */ - t_u32 bss_info_length; - - /** - * Always present, fixed length data fields for the BSS - */ - wlan_get_scan_table_fixed fixed_fields; - - /* - * Probe response or beacon scanned for the BSS. - * - * Field layout: - * - TSF 8 octets - * - Beacon Interval 2 octets - * - Capability Info 2 octets - * - * - IEEE Infomation Elements; variable number & length per 802.11 spec - */ - /* t_u8 bss_info_buffer[1]; */ -} wlan_ioctl_get_scan_table_entry; - -/** - * Structure to store BSS info (probe resp or beacon) & IEEE IE info for each - * BSS returned in WLAN_GET_SCAN_RESP IOCTL - */ -typedef struct _wlan_ioctl_get_bss_info { - /** - * Length of the BSS Information (probe resp or beacon) that - * follows after the fixed_field - */ - t_u32 bss_info_length; - - /** - * Probe response or beacon scanned for the BSS. - * - * Field layout: - */ - /** TSF 8 octets */ - t_u8 tsf[8]; - /** Beacon Interval 2 octets */ - t_u16 beacon_interval; - /** Capability Info 2 octets */ - IEEEtypes_CapInfo_t cap_info; - - /** - * IEEE Infomation Elements; variable number & length per 802.11 spec - */ - /** SSID */ - char ssid[MRVDRV_MAX_SSID_LENGTH + 1]; - /** SSID Length */ - t_u32 ssid_len; - /** WMM Capability */ - char wmm_cap; - /** WPS Capability */ - char wps_cap; - /** Privacy Capability - WEP/WPA/RSN */ - char priv_cap; - /** HT (11N) Capability */ - char ht_cap; - /** VHT (11AC) Capability */ - char vht_cap[2]; - /* 802.11k Capability */ - char dot11k_cap; - /** 802.11r Capability */ - char dot11r_cap; -} wlan_ioctl_get_bss_info; - -/** - * Structure to save of scan table info for each BSS returned - * in WLAN_GET_SCAN_RESP IOCTL - */ -struct wlan_ioctl_get_scan_list { - /** fixed info */ - wlan_ioctl_get_scan_table_entry fixed_buf; - /** variable info - BSS info (probe resp or beacon) & IEEE IE info */ - wlan_ioctl_get_bss_info bss_info_buf; - /** pointer to next node in list */ - struct wlan_ioctl_get_scan_list *next; - /** pointer to previous node in list */ - struct wlan_ioctl_get_scan_list *prev; -}; - -/** - * Sructure to retrieve the scan table - */ -typedef struct { - /** - * - Zero based scan entry to start retrieval in command request - * - Number of scans entries returned in command response - */ - t_u32 scan_number; - /** - * Buffer marker for multiple wlan_ioctl_get_scan_table_entry structures. - * Each struct is padded to the nearest 32 bit boundary. - */ - t_u8 scan_table_entry_buf[1]; - -} wlan_ioctl_get_scan_table_info; - -enum ieee80211_channel_flags { - IEEE80211_CHAN_DISABLED = 1 << 0, - IEEE80211_CHAN_NO_IR = 1 << 1, - /* hole at 1<<2 */ - IEEE80211_CHAN_RADAR = 1 << 3, - IEEE80211_CHAN_NO_HT40PLUS = 1 << 4, - IEEE80211_CHAN_NO_HT40MINUS = 1 << 5, - IEEE80211_CHAN_NO_OFDM = 1 << 6, - IEEE80211_CHAN_NO_80MHZ = 1 << 7, - IEEE80211_CHAN_NO_160MHZ = 1 << 8, - IEEE80211_CHAN_INDOOR_ONLY = 1 << 9, - IEEE80211_CHAN_IR_CONCURRENT = 1 << 10, - IEEE80211_CHAN_NO_20MHZ = 1 << 11, - IEEE80211_CHAN_NO_10MHZ = 1 << 12, -}; - -typedef struct { - /** center freq */ - t_u16 center_freq; - /** chan num */ - t_u16 hw_value; - /** chan flags */ - t_u32 flags; - /** max power */ - int max_power; - /** dfs state */ - t_u8 dfs_state; -} __ATTRIB_PACK__ wlan_ieee80211_chan; - -typedef struct { - /** num of chan */ - t_u8 num_chan; - /** chan_list */ - wlan_ieee80211_chan chan_list[]; -} __ATTRIB_PACK__ wlan_ieee80211_chan_list; - -typedef struct { - t_u8 chan_number; - /**< Channel Number to scan */ - t_u8 radio_type; - /**< Radio type: 'B/G' Band = 0, 'A' Band = 1 */ - t_u8 scan_type;/**< Scan type: Active = 1, Passive = 2 */ - t_u8 reserved;/**< Reserved */ - t_u32 scan_time; - /**< Scan duration in milliseconds; if 0 default used */ -} __ATTRIB_PACK__ wlan_ioctl_user_scan_chan; - -typedef struct { - char ssid[MRVDRV_MAX_SSID_LENGTH + 1]; - /**< SSID */ - t_u8 max_len; /**< Maximum length of SSID */ -} __ATTRIB_PACK__ wlan_ioctl_user_scan_ssid; - -typedef struct { - - /** Flag set to keep the previous scan table intact */ - t_u8 keep_previous_scan; /* Do not erase the existing scan results */ - - /** BSS mode to be sent in the firmware command */ - t_u8 bss_mode; - - /** Configure the number of probe requests for active chan scans */ - t_u8 num_probes; - - /** Reserved */ - t_u8 reserved; - - /** BSSID filter sent in the firmware command to limit the results */ - t_u8 specific_bssid[ETH_ALEN]; - - /** SSID filter list used in the to limit the scan results */ - wlan_ioctl_user_scan_ssid ssid_list[MRVDRV_MAX_SSID_LIST_LENGTH]; - - /** Variable number (fixed maximum) of channels to scan up */ - wlan_ioctl_user_scan_chan chan_list[WLAN_IOCTL_USER_SCAN_CHAN_MAX]; - - /** Gap between two scans */ - t_u16 scan_chan_gap; - /** scan type: 0 legacy, 1: enhance scan*/ - t_u8 ext_scan_type; - /** flag to filer only probe response */ - t_u8 proberesp_only; - t_u8 random_mac[MLAN_MAC_ADDR_LENGTH]; - /** Number of BSSIDs in bssid_list*/ - t_u8 bssid_num; - /** List of BSSIDs to be filterd*/ - wlan_ioctl_user_scan_bssid bssid_list[MAX_BSSID_FILTER_LIST]; -} __ATTRIB_PACK__ wlan_ioctl_user_scan_cfg; - -/** Max Ie length */ -#define MAX_IE_SIZE 256 - -/** custom IE */ -typedef struct _custom_ie { - /** IE Index */ - t_u16 ie_index; - /** Mgmt Subtype Mask */ - t_u16 mgmt_subtype_mask; - /** IE Length */ - t_u16 ie_length; - /** IE buffer */ - t_u8 ie_buffer[]; -} __ATTRIB_PACK__ custom_ie; - /** Convert character to integer */ #define CHAR2INT(x) (((x) >= 'A') ? ((x) - 'A' + 10) : ((x) - '0')) -/** - * Hex or Decimal to Integer - * @param num string to convert into decimal or hex - */ -#define A2HEXDECIMAL(num) \ - (strncasecmp("0x", (num), 2) ? (unsigned int) strtoll((num), NULL, 0) : a2hex((num))) - -/** Convert TLV header from little endian format to CPU format */ -#define endian_convert_tlv_header_in(x) \ - { \ - (x)->tag = le16_to_cpu((x)->tag); \ - (x)->length = le16_to_cpu((x)->length); \ - } - -/** Convert TLV header to little endian format from CPU format */ -#define endian_convert_tlv_header_out(x) \ - { \ - (x)->tag = cpu_to_le16((x)->tag); \ - (x)->length = cpu_to_le16((x)->length); \ - } -/** Max IE index to FW */ -#define MAX_MGMT_IE_INDEX_TO_FW 4 -/** Max IE index per BSS */ -#define MAX_MGMT_IE_INDEX 16 - -/** Private command ID to pass custom IE list */ -#define CUSTOM_IE_CFG (SIOCDEVPRIVATE + 13) -/* TLV Definitions */ - -/** Maximum IE buffer length */ -#define MAX_IE_BUFFER_LEN 256 - -/** TLV: Management IE list */ -#define MRVL_MGMT_IE_LIST_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0x69) /* 0x0169 */ - -/** TLV: Max Management IE */ -#define MRVL_MAX_MGMT_IE_TLV_ID (PROPRIETARY_TLV_BASE_ID + 0xaa) /* 0x01aa */ - -/** custom IE info */ -typedef struct _custom_ie_info { - /** size of buffer */ - t_u16 buf_size; - /** no of buffers of buf_size */ - t_u16 buf_count; -} __ATTRIB_PACK__ custom_ie_info; - -/** TLV buffer : Max Mgmt IE */ -typedef struct _tlvbuf_max_mgmt_ie { - /** Type */ - t_u16 type; - /** Length */ - t_u16 len; - /** No of tuples */ - t_u16 count; - /** custom IE info tuples */ - custom_ie_info info[]; -} __ATTRIB_PACK__ tlvbuf_max_mgmt_ie; - -/** TLV buffer : custom IE */ -typedef struct _eth_priv_ds_misc_custom_ie { - /** Type */ - t_u16 type; - /** Length */ - t_u16 len; - /** IE data */ - custom_ie ie_data[]; -} __ATTRIB_PACK__ eth_priv_ds_misc_custom_ie; - -/*-----------------------------------------------------------------*/ -/** Register Memory Access Group */ -/*-----------------------------------------------------------------*/ -/** Enumeration for register type */ -enum _mlan_reg_type { - MLAN_REG_MAC = 1, - MLAN_REG_BBP, - MLAN_REG_RF, - MLAN_REG_CAU = 5, -}; - -/** Type definition of mlan_ds_reg_rw for MLAN_OID_REG_RW */ -struct eth_priv_ds_reg_rw { - /** Register type */ - t_u32 type; - /** Offset */ - t_u32 offset; - /** Value */ - t_u32 value; -}; - -/** Maximum EEPROM data */ -#define MAX_EEPROM_DATA 256 - -/** Type definition of mlan_ds_read_eeprom for MLAN_OID_EEPROM_RD */ -struct eth_priv_ds_read_eeprom { - /** Multiples of 4 */ - t_u16 offset; - /** Number of bytes */ - t_u16 byte_count; - /** Value */ - t_u8 value[MAX_EEPROM_DATA]; -}; - -/** Type definition of mlan_ds_mem_rw for MLAN_OID_MEM_RW */ -struct eth_priv_ds_mem_rw { - /** Address */ - t_u32 addr; - /** Value */ - t_u32 value; -}; - -/** Type definition of mlan_ds_reg_mem for MLAN_IOCTL_REG_MEM */ -struct eth_priv_ds_reg_mem { - /** Sub-command */ - t_u32 sub_command; - /** Register memory access parameter */ - union { - /** Register access for MLAN_OID_REG_RW */ - struct eth_priv_ds_reg_rw reg_rw; - /** EEPROM access for MLAN_OID_EEPROM_RD */ - struct eth_priv_ds_read_eeprom rd_eeprom; - /** Memory access for MLAN_OID_MEM_RW */ - struct eth_priv_ds_mem_rw mem_rw; - } param; -}; - -/** Data structure of WMM QoS information */ -typedef struct _IEEEtypes_WmmQosInfo_t { -#ifdef BIG_ENDIAN_SUPPORT - /** QoS UAPSD */ - t_u8 qos_uapsd:1; - /** Reserved */ - t_u8 reserved:3; - /** Parameter set count */ - t_u8 para_set_count:4; -#else - /** Parameter set count */ - t_u8 para_set_count:4; - /** Reserved */ - t_u8 reserved:3; - /** QoS UAPSD */ - t_u8 qos_uapsd:1; -#endif /* BIG_ENDIAN_SUPPORT */ -} __ATTRIB_PACK__ IEEEtypes_WmmQosInfo_t; - -/** Max channel value for BG band */ -#define MAX_BG_CHANNEL 14 - -/** Size of a TSPEC. Used to allocate necessary buffer space in commands */ -#define WMM_TSPEC_SIZE 63 - -/** Maximum number of AC QOS queues available in the driver/firmware */ -#define MAX_AC_QUEUES 4 - -/** Maximum number of User Priorities */ -#define MAX_USER_PRIORITIES 8 - -/** Extra IE bytes allocated in messages for appended IEs after a TSPEC */ -#define WMM_ADDTS_EXTRA_IE_BYTES 256 - -/** - * @brief Enumeration for the command result from an ADDTS or DELTS command - */ -typedef enum { - TSPEC_RESULT_SUCCESS = 0, - TSPEC_RESULT_EXEC_FAILURE = 1, - TSPEC_RESULT_TIMEOUT = 2, - TSPEC_RESULT_DATA_INVALID = 3, -} __ATTRIB_PACK__ mlan_wmm_tspec_result_e; - -/** - * @brief Enumeration for the action field in the Queue configure command - */ -typedef enum { - WMM_QUEUE_CONFIG_ACTION_GET = 0, - WMM_QUEUE_CONFIG_ACTION_SET = 1, - WMM_QUEUE_CONFIG_ACTION_DEFAULT = 2, - - WMM_QUEUE_CONFIG_ACTION_MAX -} __ATTRIB_PACK__ mlan_wmm_queue_config_action_e; - -/** - * @brief Enumeration for the action field in the queue stats command - */ -typedef enum { - WMM_STATS_ACTION_START = 0, - WMM_STATS_ACTION_STOP = 1, - WMM_STATS_ACTION_GET_CLR = 2, - WMM_STATS_ACTION_SET_CFG = 3, /* Not currently used */ - WMM_STATS_ACTION_GET_CFG = 4, /* Not currently used */ - - WMM_STATS_ACTION_MAX -} __ATTRIB_PACK__ mlan_wmm_stats_action_e; - -/** Data structure of WMM Aci/Aifsn */ -typedef struct _IEEEtypes_WmmAciAifsn_t { -#ifdef BIG_ENDIAN_SUPPORT - /** Reserved */ - t_u8 reserved:1; - /** Aci */ - t_u8 aci:2; - /** Acm */ - t_u8 acm:1; - /** Aifsn */ - t_u8 aifsn:4; -#else - /** Aifsn */ - t_u8 aifsn:4; - /** Acm */ - t_u8 acm:1; - /** Aci */ - t_u8 aci:2; - /** Reserved */ - t_u8 reserved:1; -#endif -} __ATTRIB_PACK__ IEEEtypes_WmmAciAifsn_t, *pIEEEtypes_WmmAciAifsn_t; - -/** Data structure of WMM ECW */ -typedef struct _IEEEtypes_WmmEcw_t { -#ifdef BIG_ENDIAN_SUPPORT - /** Maximum Ecw */ - t_u8 ecw_max:4; - /** Minimum Ecw */ - t_u8 ecw_min:4; -#else - /** Minimum Ecw */ - t_u8 ecw_min:4; - /** Maximum Ecw */ - t_u8 ecw_max:4; -#endif -} __ATTRIB_PACK__ IEEEtypes_WmmEcw_t, *pIEEEtypes_WmmEcw_t; - -/** Data structure of WMM AC parameters */ -typedef struct _IEEEtypes_WmmAcParameters_t { - IEEEtypes_WmmAciAifsn_t aci_aifsn; /**< AciAifSn */ - IEEEtypes_WmmEcw_t ecw; /**< Ecw */ - t_u16 tx_op_limit; /**< Tx op limit */ -} __ATTRIB_PACK__ IEEEtypes_WmmAcParameters_t, *pIEEEtypes_WmmAcParameters_t; - -/** Data structure of WMM Info IE */ -typedef struct _IEEEtypes_WmmInfo_t { - - /** - * WMM Info IE - Vendor Specific Header: - * element_id [221/0xdd] - * Len [7] - * Oui [00:50:f2] - * OuiType [2] - * OuiSubType [0] - * Version [1] - */ - IEEEtypes_VendorHeader_t vend_hdr; - - /** QoS information */ - IEEEtypes_WmmQosInfo_t qos_info; - -} __ATTRIB_PACK__ IEEEtypes_WmmInfo_t, *pIEEEtypes_WmmInfo_t; - -/** Data structure of WMM parameter IE */ -typedef struct _IEEEtypes_WmmParameter_t { - /** - * WMM Parameter IE - Vendor Specific Header: - * element_id [221/0xdd] - * Len [24] - * Oui [00:50:f2] - * OuiType [2] - * OuiSubType [1] - * Version [1] - */ - IEEEtypes_VendorHeader_t vend_hdr; - - /** QoS information */ - IEEEtypes_WmmQosInfo_t qos_info; - /** Reserved */ - t_u8 reserved; - - /** AC Parameters Record WMM_AC_BE, WMM_AC_BK, WMM_AC_VI, WMM_AC_VO */ - IEEEtypes_WmmAcParameters_t ac_params[MAX_AC_QUEUES]; - -} __ATTRIB_PACK__ IEEEtypes_WmmParameter_t, *pIEEEtypes_WmmParameter_t; - -/** - * @brief IOCTL structure to send an ADDTS request and retrieve the response. - * - * IOCTL structure from the application layer relayed to firmware to - * instigate an ADDTS management frame with an appropriate TSPEC IE as well - * as any additional IEs appended in the ADDTS Action frame. - * - * @sa wlan_wmm_addts_req_ioctl - */ -typedef struct { - mlan_wmm_tspec_result_e commandResult; - /**< Firmware execution result */ - - t_u32 timeout_ms; /**< Timeout value in milliseconds */ - t_u8 ieeeStatusCode; /**< IEEE status code */ - - t_u32 ieDataLen; - t_u8 ieData[WMM_TSPEC_SIZE - /**< TSPEC to send in the ADDTS */ - + WMM_ADDTS_EXTRA_IE_BYTES]; - /**< ADDTS extra IE buf */ -} wlan_ioctl_wmm_addts_req_t; - -/** - * @brief IOCTL structure to send a DELTS request. - * - * IOCTL structure from the application layer relayed to firmware to - * instigate an DELTS management frame with an appropriate TSPEC IE. - * - * @sa wlan_wmm_delts_req_ioctl - */ -typedef struct { - mlan_wmm_tspec_result_e commandResult; - /**< Firmware execution result */ - t_u8 ieeeReasonCode; /**< IEEE reason code sent, unused for WMM */ - - t_u32 ieDataLen; - t_u8 ieData[WMM_TSPEC_SIZE]; - /**< TSPEC to send in the DELTS */ -} wlan_ioctl_wmm_delts_req_t; - -/** - * @brief IOCTL structure to configure a specific AC Queue's parameters - * - * IOCTL structure from the application layer relayed to firmware to - * get, set, or default the WMM AC queue parameters. - * - * - msduLifetimeExpiry is ignored if set to 0 on a set command - * - * @sa wlan_wmm_queue_config_ioctl - */ -typedef struct { - mlan_wmm_queue_config_action_e action; - /**< Set, Get, or Default */ - mlan_wmm_ac_e accessCategory; /**< WMM_AC_BK(0) to WMM_AC_VO(3) */ - t_u16 msduLifetimeExpiry; /**< lifetime expiry in TUs */ - t_u8 supportedRates[10]; /**< Not supported yet */ -} wlan_ioctl_wmm_queue_config_t; - -/** Number of bins in the histogram for the HostCmd_DS_WMM_QUEUE_STATS */ -#define WMM_STATS_PKTS_HIST_BINS 7 - -/** - * @brief IOCTL structure to start, stop, and get statistics for a WMM AC - * - * IOCTL structure from the application layer relayed to firmware to - * start or stop statistical collection for a given AC. Also used to - * retrieve and clear the collected stats on a given AC. - * - * @sa wlan_wmm_queue_stats_ioctl - */ -typedef struct { - mlan_wmm_stats_action_e action; - /**< Start, Stop, or Get */ - t_u8 userPriority; - /**< User Priority (0 to 7) */ - t_u16 pktCount; /**< Number of successful packets transmitted */ - t_u16 pktLoss; /**< Packets lost; not included in pktCount */ - t_u32 avgQueueDelay; - /**< Average Queue delay in microseconds */ - t_u32 avgTxDelay;/**< Average Transmission delay in microseconds */ - t_u16 usedTime; /**< Calculated used time - units of 32 microsec */ - t_u16 policedTime; - /**< Calculated policed time - units of 32 microsec */ - - /** @brief Queue Delay Histogram; number of packets per queue delay range - * - * [0] - 0ms <= delay < 5ms - * [1] - 5ms <= delay < 10ms - * [2] - 10ms <= delay < 20ms - * [3] - 20ms <= delay < 30ms - * [4] - 30ms <= delay < 40ms - * [5] - 40ms <= delay < 50ms - * [6] - 50ms <= delay < msduLifetime (TUs) - */ - t_u16 delayHistogram[WMM_STATS_PKTS_HIST_BINS]; -} wlan_ioctl_wmm_queue_stats_t; - -/** - * @brief IOCTL and command sub structure for a Traffic stream status. - */ -typedef struct { - t_u8 tid; /**< TSID: Range: 0->7 */ - t_u8 valid; /**< TSID specified is valid */ - t_u8 accessCategory;/**< AC TSID is active on */ - t_u8 userPriority; /**< UP specified for the TSID */ - - t_u8 psb; /**< Power save mode for TSID: 0 (legacy), 1 (UAPSD) */ - t_u8 flowDir; /**< Upstream (0), Downlink(1), Bidirectional(3) */ - t_u16 mediumTime; /**< Medium time granted for the TSID */ -} __ATTRIB_PACK__ HostCmd_DS_WMM_TS_STATUS, - wlan_ioctl_wmm_ts_status_t, wlan_cmd_wmm_ts_status_t; - -/** - * @brief IOCTL sub structure for a specific WMM AC Status - */ -typedef struct { - /** WMM Acm */ - t_u8 wmmAcm; - /** Flow required flag */ - t_u8 flowRequired; - /** Flow created flag */ - t_u8 flowCreated; - /** Disabled flag */ - t_u8 disabled; - /** delivery enabled */ - t_u8 deliveryEnabled; - /** trigger enabled */ - t_u8 triggerEnabled; -} wlan_ioctl_wmm_queue_status_ac_t; - -/** - * @brief IOCTL structure to retrieve the WMM AC Queue status - * - * IOCTL structure from the application layer to retrieve: - * - ACM bit setting for the AC - * - Firmware status (flow required, flow created, flow disabled) - * - * @sa wlan_wmm_queue_status_ioctl - */ -typedef struct { - /** WMM AC queue status */ - wlan_ioctl_wmm_queue_status_ac_t acStatus[MAX_AC_QUEUES]; -} wlan_ioctl_wmm_queue_status_t; -#endif /* STA_SUPPORT */ - /** Command RET code, MSB is set to 1 */ -#define HostCmd_RET_BIT 0x8000 +#define HostCmd_RET_BIT 0x8000 /** General purpose action : Get */ -#define HostCmd_ACT_GEN_GET 0x0000 +#define HostCmd_ACT_GEN_GET 0x0000 /** General purpose action : Set */ -#define HostCmd_ACT_GEN_SET 0x0001 +#define HostCmd_ACT_GEN_SET 0x0001 /** General purpose action : Clear */ -#define HostCmd_ACT_GEN_CLEAR 0x0004 +#define HostCmd_ACT_GEN_CLEAR 0x0004 /** General purpose action : Remove */ -#define HostCmd_ACT_GEN_REMOVE 0x0004 +#define HostCmd_ACT_GEN_REMOVE 0x0004 /** TLV type ID definition */ -#define PROPRIETARY_TLV_BASE_ID 0x0100 +#define PROPRIETARY_TLV_BASE_ID 0x0100 /** MrvlIEtypesHeader_t */ typedef struct MrvlIEtypesHeader { - /** Header type */ + /** Header type */ t_u16 type; - /** Header length */ + /** Header length */ t_u16 len; } __ATTRIB_PACK__ MrvlIEtypesHeader_t; /** MrvlIEtypes_Data_t */ typedef struct MrvlIEtypes_Data_t { - /** Header */ + /** Header */ MrvlIEtypesHeader_t header; - /** Data */ + /** Data */ t_u8 data[1]; } __ATTRIB_PACK__ MrvlIEtypes_Data_t; -/** HostCmd_DS_802_11_SUBSCRIBE_EVENT */ -typedef struct MAPP_HostCmd_DS_802_11_SUBSCRIBE_EVENT { - /** Action */ - t_u16 action; - /** Events */ - t_u16 events; -} __ATTRIB_PACK__ HostCmd_DS_802_11_SUBSCRIBE_EVENT; - -/** MrvlIEtypes_RssiParamSet_t */ -typedef struct MrvlIEtypes_RssiThreshold { - /** Header */ - MrvlIEtypesHeader_t header; - /** RSSI value */ - t_u8 RSSI_value; - /** RSSI frequency */ - t_u8 RSSI_freq; -} __ATTRIB_PACK__ MrvlIEtypes_RssiThreshold_t; - -/** MrvlIEtypes_SnrThreshold_t */ -typedef struct MrvlIEtypes_SnrThreshold { - /** Header */ - MrvlIEtypesHeader_t header; - /** SNR value */ - t_u8 SNR_value; - /** SNR frequency */ - t_u8 SNR_freq; -} __ATTRIB_PACK__ MrvlIEtypes_SnrThreshold_t; - -/** MrvlIEtypes_FailureCount_t */ -typedef struct MrvlIEtypes_FailureCount { - /** Header */ - MrvlIEtypesHeader_t header; - /** Failure value */ - t_u8 fail_value; - /** Failure frequency */ - t_u8 fail_freq; -} __ATTRIB_PACK__ MrvlIEtypes_FailureCount_t; - -/** MrvlIEtypes_BeaconsMissed_t */ -typedef struct MrvlIEtypes_BeaconsMissed { - /** Header */ - MrvlIEtypesHeader_t header; - /** Number of beacons missed */ - t_u8 beacon_missed; - /** Reserved */ - t_u8 reserved; -} __ATTRIB_PACK__ MrvlIEtypes_BeaconsMissed_t; - -/** MrvlIEtypes_LinkQuality_t */ -typedef struct MrvlIEtypes_LinkQuality { - /** Header */ - MrvlIEtypesHeader_t header; - /** Link SNR threshold */ - t_u16 link_SNR_thrs; - /** Link SNR frequency */ - t_u16 link_SNR_freq; - /** Minimum rate value */ - t_u16 min_rate_val; - /** Minimum rate frequency */ - t_u16 min_rate_freq; - /** Tx latency value */ - t_u32 tx_latency_val; - /** Tx latency threshold */ - t_u32 tx_latency_thrs; -} __ATTRIB_PACK__ MrvlIEtypes_LinkQuality_t; - -/** Host Command ID : 802.11 subscribe event */ -#define HostCmd_CMD_802_11_SUBSCRIBE_EVENT 0x0075 - -/** TLV type : Beacon RSSI low */ -#define TLV_TYPE_RSSI_LOW (PROPRIETARY_TLV_BASE_ID + 0x04) /* 0x0104 */ -/** TLV type : Beacon SNR low */ -#define TLV_TYPE_SNR_LOW (PROPRIETARY_TLV_BASE_ID + 0x05) /* 0x0105 */ -/** TLV type : Fail count */ -#define TLV_TYPE_FAILCOUNT (PROPRIETARY_TLV_BASE_ID + 0x06) /* 0x0106 */ -/** TLV type : BCN miss */ -#define TLV_TYPE_BCNMISS (PROPRIETARY_TLV_BASE_ID + 0x07) /* 0x0107 */ -/** TLV type : Beacon RSSI high */ -#define TLV_TYPE_RSSI_HIGH (PROPRIETARY_TLV_BASE_ID + 0x16) /* 0x0116 */ -/** TLV type : Beacon SNR high */ -#define TLV_TYPE_SNR_HIGH (PROPRIETARY_TLV_BASE_ID + 0x17) /* 0x0117 */ - -/** TLV type :Link Quality */ -#define TLV_TYPE_LINK_QUALITY (PROPRIETARY_TLV_BASE_ID + 0x24) /* 0x0124 */ - -/** TLV type : Data RSSI low */ -#define TLV_TYPE_RSSI_LOW_DATA (PROPRIETARY_TLV_BASE_ID + 0x26) /* 0x0126 */ -/** TLV type : Data SNR low */ -#define TLV_TYPE_SNR_LOW_DATA (PROPRIETARY_TLV_BASE_ID + 0x27) /* 0x0127 */ -/** TLV type : Data RSSI high */ -#define TLV_TYPE_RSSI_HIGH_DATA (PROPRIETARY_TLV_BASE_ID + 0x28) /* 0x0128 */ -/** TLV type : Data SNR high */ -#define TLV_TYPE_SNR_HIGH_DATA (PROPRIETARY_TLV_BASE_ID + 0x29) /* 0x0129 */ - -/** MrvlIEtypes_PreBeaconLost_t */ -typedef struct MrvlIEtypes_PreBeaconLost { - /** Header */ - MrvlIEtypesHeader_t header; - /** Pre-Beacon Lost */ - t_u8 pre_beacon_lost; - /** Reserved */ - t_u8 reserved; -} __ATTRIB_PACK__ MrvlIEtypes_PreBeaconLost_t; - -/** TLV type: Pre-Beacon Lost */ -#define TLV_TYPE_PRE_BEACON_LOST (PROPRIETARY_TLV_BASE_ID + 0x49) /* 0x0149 */ - -/** TLV type : Extended capabilities */ -#define TLV_TYPE_EXTCAP 0x007f - -/** AutoTx_MacFrame_t */ -typedef struct AutoTx_MacFrame { - t_u16 interval; /**< in seconds */ - t_u8 priority; /**< User Priority: 0~7, ignored if non-WMM */ - t_u8 reserved; /**< set to 0 */ - t_u16 frame_len; /**< Length of MAC frame payload */ - t_u8 dest_mac_addr[MLAN_MAC_ADDR_LENGTH]; /**< Destination MAC address */ - t_u8 src_mac_addr[MLAN_MAC_ADDR_LENGTH]; /**< Source MAC address */ - t_u8 payload[]; /**< Payload */ -} __ATTRIB_PACK__ AutoTx_MacFrame_t; - -/** MrvlIEtypes_AutoTx_t */ -typedef struct MrvlIEtypes_AutoTx { - MrvlIEtypesHeader_t header; /**< Header */ - AutoTx_MacFrame_t auto_tx_mac_frame; /**< Auto Tx MAC frame */ -} __ATTRIB_PACK__ MrvlIEtypes_AutoTx_t; - -/** HostCmd_DS_802_11_AUTO_TX */ -typedef struct MAPP_HostCmd_DS_802_11_AUTO_TX { - /** Action */ - t_u16 action; /* 0 = ACT_GET; 1 = ACT_SET; */ - MrvlIEtypes_AutoTx_t auto_tx; /**< Auto Tx */ -} __ATTRIB_PACK__ HostCmd_DS_802_11_AUTO_TX; - -/** Host Command ID : 802.11 auto Tx */ -#define HostCmd_CMD_802_11_AUTO_TX 0x0082 - -/** TLV type : Auto Tx */ -#define TLV_TYPE_AUTO_TX (PROPRIETARY_TLV_BASE_ID + 0x18) /* 0x0118 */ - -/** HostCmd_DS_802_11_CFG_DATA */ -typedef struct MAPP_HostCmd_DS_802_11_CFG_DATA { - /** Action */ - t_u16 action; - /** Type */ - t_u16 type; - /** Data length */ - t_u16 data_len; - /** Data */ - t_u8 data[1]; -} __ATTRIB_PACK__ HostCmd_DS_802_11_CFG_DATA; - -/** Host Command ID : Configuration data */ -#define HostCmd_CMD_CFG_DATA 0x008f - -/** mlan_ioctl_11h_tpc_resp */ -typedef struct { - int status_code; - /**< Firmware command result status code */ - int tx_power;/**< Reported TX Power from the TPC Report */ - int link_margin; - /**< Reported Link margin from the TPC Report */ - int rssi; /**< RSSI of the received TPC Report frame */ -} __ATTRIB_PACK__ mlan_ioctl_11h_tpc_resp; - -/** Host Command ID : 802.11 TPC adapt req */ -#define HostCmd_CMD_802_11_TPC_ADAPT_REQ 0x0060 - -/** HostCmd_DS_802_11_CRYPTO */ -typedef struct MAPP_HostCmd_DS_802_11_CRYPTO { - t_u16 encdec; /**< Decrypt=0, Encrypt=1 */ - t_u16 algorithm; /**< RC4=1 AES=2 , AES_KEY_WRAP=3 */ - t_u16 key_IV_length;/**< Length of Key IV (bytes) */ - t_u8 keyIV[32]; /**< Key IV */ - t_u16 key_length; /**< Length of Key (bytes) */ - t_u8 key[32]; /**< Key */ - MrvlIEtypes_Data_t data; - /**< Plain text if encdec=Encrypt, Ciphertext data if encdec=Decrypt*/ -} __ATTRIB_PACK__ HostCmd_DS_802_11_CRYPTO; - -/** HostCmd_DS_802_11_CRYPTO_AES_CCM */ -typedef struct MAPP_HostCmd_DS_802_11_CRYPTO_AES_CCM { - t_u16 encdec; /**< Decrypt=0, Encrypt=1 */ - t_u16 algorithm; /**< AES_CCM=4 */ - t_u16 key_length; /**< Length of Key (bytes) */ - t_u8 key[32]; /**< Key */ - t_u16 nonce_length;/**< Length of Nonce (bytes) */ - t_u8 nonce[14]; /**< Nonce */ - t_u16 AAD_length; /**< Length of AAD (bytes) */ - t_u8 AAD[32]; /**< AAD */ - MrvlIEtypes_Data_t data; - /**< Plain text if encdec=Encrypt, Ciphertext data if encdec=Decrypt*/ -} __ATTRIB_PACK__ HostCmd_DS_802_11_CRYPTO_AES_CCM; - -/** HostCmd_DS_802_11_CRYPTO_WAPI */ -typedef struct MAPP_HostCmd_DS_802_11_CRYPTO_WAPI { - t_u16 encdec; /**< Decrypt=0, Encrypt=1 */ - t_u16 algorithm; /**< WAPI =5 */ - t_u16 key_length; /**< Length of Key (bytes) */ - t_u8 key[32]; /**< Key */ - t_u16 nonce_length;/**< Length of Nonce (bytes) */ - t_u8 nonce[16]; /**< Nonce */ - t_u16 AAD_length; /**< Length of AAD (bytes) */ - t_u8 AAD[48]; /**< AAD */ - t_u16 data_length; /**< Length of data (bytes) */ -} __ATTRIB_PACK__ HostCmd_DS_802_11_CRYPTO_WAPI; -/** WAPI cipher test */ -#define CIPHER_TEST_WAPI (5) -/** AES CCM cipher test */ -#define CIPHER_TEST_AES_CCM (4) -/** GCMP cipher test */ -#define CIPHER_TEST_GCMP (6) -/** Host Command ID : 802.11 crypto */ -#define HostCmd_CMD_802_11_CRYPTO 0x0078 -/** Get the current TSF */ -#define HostCmd_CMD_GET_TSF 0x0080 - -/** Read/Write Mac register */ -#define HostCmd_CMD_MAC_REG_ACCESS 0x0019 -/** Read/Write BBP register */ -#define HostCmd_CMD_BBP_REG_ACCESS 0x001a -/** Read/Write RF register */ -#define HostCmd_CMD_RF_REG_ACCESS 0x001b - -/** Host Command ID : CAU register access */ -#define HostCmd_CMD_CAU_REG_ACCESS 0x00ed - -/** Host Command ID : Memory access */ -#define HostCmd_CMD_MEM_ACCESS 0x0086 - /** channel band */ -enum { - BAND_2GHZ = 0, - BAND_5GHZ = 1, - BAND_4GHZ = 2, +enum { BAND_2GHZ = 0, + BAND_5GHZ = 1, + BAND_4GHZ = 2, }; /** channel offset */ -enum { - SEC_CHAN_NONE = 0, - SEC_CHAN_ABOVE = 1, - SEC_CHAN_5MHZ = 2, - SEC_CHAN_BELOW = 3 -}; +enum { SEC_CHAN_NONE = 0, + SEC_CHAN_ABOVE = 1, + SEC_CHAN_5MHZ = 2, + SEC_CHAN_BELOW = 3 }; /** channel bandwidth */ -enum { - CHAN_BW_20MHZ = 0, - CHAN_BW_10MHZ, - CHAN_BW_40MHZ, - CHAN_BW_80MHZ, +enum { CHAN_BW_20MHZ = 0, + CHAN_BW_10MHZ, + CHAN_BW_40MHZ, + CHAN_BW_80MHZ, }; - -/** scan mode */ -enum { - SCAN_MODE_MANUAL = 0, - SCAN_MODE_ACS, - SCAN_MODE_USER, -}; - /** Band_Config_t */ typedef struct _Band_Config_t { #ifdef BIG_ENDIAN_SUPPORT - /** Channel Selection Mode - (00)=manual, (01)=ACS, (02)=user*/ - t_u8 scanMode:2; - /** Secondary Channel Offset - (00)=None, (01)=Above, (11)=Below */ - t_u8 chan2Offset:2; - /** Channel Width - (00)=20MHz, (10)=40MHz, (11)=80MHz */ - t_u8 chanWidth:2; - /** Band Info - (00)=2.4GHz, (01)=5GHz */ - t_u8 chanBand:2; + /** Channel Selection Mode - (00)=manual, (01)=ACS, (02)=user*/ + t_u8 scanMode : 2; + /** Secondary Channel Offset - (00)=None, (01)=Above, (11)=Below */ + t_u8 chan2Offset : 2; + /** Channel Width - (00)=20MHz, (10)=40MHz, (11)=80MHz */ + t_u8 chanWidth : 2; + /** Band Info - (00)=2.4GHz, (01)=5GHz */ + t_u8 chanBand : 2; #else - /** Band Info - (00)=2.4GHz, (01)=5GHz */ - t_u8 chanBand:2; - /** Channel Width - (00)=20MHz, (10)=40MHz, (11)=80MHz */ - t_u8 chanWidth:2; - /** Secondary Channel Offset - (00)=None, (01)=Above, (11)=Below */ - t_u8 chan2Offset:2; - /** Channel Selection Mode - (00)=manual, (01)=ACS, (02)=Adoption mode*/ - t_u8 scanMode:2; + /** Band Info - (00)=2.4GHz, (01)=5GHz */ + t_u8 chanBand : 2; + /** Channel Width - (00)=20MHz, (10)=40MHz, (11)=80MHz */ + t_u8 chanWidth : 2; + /** Secondary Channel Offset - (00)=None, (01)=Above, (11)=Below */ + t_u8 chan2Offset : 2; + /** Channel Selection Mode - (00)=manual, (01)=ACS, (02)=Adoption mode*/ + t_u8 scanMode : 2; #endif } __ATTRIB_PACK__ Band_Config_t; -/** Failure */ -#define MLAN_EVENT_FAILURE -1 - -/** Netlink protocol number */ -#define NETLINK_NXP (MAX_LINKS - 1) -/** Netlink maximum payload size */ -#define NL_MAX_PAYLOAD 1024 -/** Netlink multicast group number */ -#define NL_MULTICAST_GROUP 1 -/** Default wait time in seconds for events */ -#define UAP_RECV_WAIT_DEFAULT 10 -/** Maximum number of devices */ -#define MAX_NO_OF_DEVICES 4 - -/* Event buffer */ -typedef struct _evt_buf { - /** Flag to check if event data is present in the buffer or not */ - int flag; - /** Event length */ - int length; - /** Event data */ - t_u8 buffer[NL_MAX_PAYLOAD]; -} __ATTRIB_PACK__ evt_buf; - -/** Event header */ -typedef struct _event_header { - /** Event ID */ - t_u32 event_id; - /** Event data */ - t_u8 event_data[]; -} __ATTRIB_PACK__ event_header; - -/** Event ID length */ -#define EVENT_ID_LEN 4 - -/** Event definition: Radar Detected by card */ -#define EVENT_CHANNEL_REPORT_RDY 0x00000054 - -/** Host Command ID : Channel report request */ -#define HostCmd_CMD_CHAN_REPORT_REQUEST 0x00dd -/** TLV type : Chan Load */ -#define TLV_TYPE_CHANRPT_CHAN_LOAD (PROPRIETARY_TLV_BASE_ID + 0x59) /* 0x0159 */ -/** TLV type : Noise Historgram */ -#define TLV_TYPE_CHANRPT_NOISE_HIST (PROPRIETARY_TLV_BASE_ID + 0x5a) /* 0x015a */ - -typedef struct { - t_u16 startFreq; - t_u8 chanWidth; - t_u8 chanNum; - -} __ATTRIB_PACK__ MrvlChannelDesc_t; - -typedef struct { - MrvlChannelDesc_t chanDesc; - /**< Channel band, number */ - t_u32 millisecDwellTime; /**< Channel dwell time in milliseconds */ -} __ATTRIB_PACK__ HostCmd_DS_CHAN_RPT_REQ; - -typedef struct { - - t_u32 commandResult; - /**< Rpt request command result (0 == SUCCESS) */ - t_u64 startTsf; /**< TSF Measurement started */ - t_u32 duration; /**< Duration of measurement in microsecs */ - - t_u8 tlvBuffer[1]; - /**< TLV Buffer */ -} __ATTRIB_PACK__ HostCmd_DS_CHAN_RPT_RSP; - -typedef struct { - MrvlIEtypesHeader_t Header; /**< Header */ - - t_u8 ccaBusyFraction; /**< Parts per 255 channel was busy */ -} __ATTRIB_PACK__ MrvlIEtypes_ChanRptChanLoad_t; - -typedef struct { - MrvlIEtypesHeader_t header; /**< Header */ - - t_s16 anpi; /**< ANPI calculated from the histogram */ - /** RPI histogram bins. The number of bins utilized is variable and must - be calculated by the header length */ - t_u8 rpiDensities[11]; -} __ATTRIB_PACK__ MrvlIEtypes_ChanRptNoiseHist_t; - /** Maximum length of lines in configuration file */ -#define MAX_CONFIG_LINE 1024 +#define MAX_CONFIG_LINE 1024 /** MAC BROADCAST */ -#define MAC_BROADCAST 0x1FF +#define MAC_BROADCAST 0x1FF /** MAC MULTICAST */ -#define MAC_MULTICAST 0x1FE - -/** HostCmd_DS_REG */ -typedef struct MAPP_HostCmd_DS_REG { - /** Read or write */ - t_u16 action; - /** Register offset */ - t_u16 offset; - /** Value */ - t_u32 value; -} __ATTRIB_PACK__ HostCmd_DS_REG; - -/** HostCmd_DS_MEM */ -typedef struct MAPP_HostCmd_DS_MEM { - /** Read or write */ - t_u16 action; - /** Reserved */ - t_u16 reserved; - /** Address */ - t_u32 addr; - /** Value */ - t_u32 value; -} __ATTRIB_PACK__ HostCmd_DS_MEM; - -typedef struct _HostCmd_DS_MEF_CFG { - /** Criteria */ - t_u32 Criteria; - /** Number of entries */ - t_u16 NumEntries; -} __ATTRIB_PACK__ HostCmd_DS_MEF_CFG; - -typedef struct _MEF_CFG_DATA { - /** Size */ - t_u16 size; - /** Data */ - HostCmd_DS_MEF_CFG data; -} __ATTRIB_PACK__ MEF_CFG_DATA; +#define MAC_MULTICAST 0x1FE /** HostCmd_DS_GEN */ typedef struct MAPP_HostCmd_DS_GEN { - /** Command */ + /** Command */ t_u16 command; - /** Size */ + /** Size */ t_u16 size; - /** Sequence number */ + /** Sequence number */ t_u16 seq_num; - /** Result */ + /** Result */ t_u16 result; } __ATTRIB_PACK__ HostCmd_DS_GEN; /** Size of HostCmd_DS_GEN */ -#define S_DS_GEN sizeof(HostCmd_DS_GEN) - -/** Type definition of aggr_ctrl */ -typedef struct _aggr_ctrl { - /** Enable */ - t_u16 enable; - /** Aggregation alignment */ - t_u16 aggr_align; - /** Aggregation max packet/size */ - t_u16 aggr_max_size; - /** Aggregation max packet number */ - t_u16 aggr_max_num; - /** Aggrgation timeout, in microseconds */ - t_u16 aggr_tmo; -} aggr_ctrl; - -/** Type definition of mlan_ds_misc_aggr_ctrl for MLAN_OID_MISC_AGGR_CTRL */ -typedef struct _aggr_ctrl_params { - /** Tx aggregation control */ - aggr_ctrl tx; -} aggr_ctrl_params; - -typedef struct _usb_aggr_ctrl { - /** Enable */ - t_u16 enable; - /** Aggregation mode */ - t_u16 aggr_mode; - /** Aggregation alignment */ - t_u16 aggr_align; - /** Aggregation max packet/size */ - t_u16 aggr_max; - /** Aggrgation timeout, in microseconds */ - t_u16 aggr_tmo; -} usb_aggr_ctrl; - -/** Type definition of mlan_ds_misc_usb_aggr_ctrl for MLAN_OID_MISC_USB_AGGR_CTRL */ -typedef struct _aggr_params { - /** Tx aggregation control */ - usb_aggr_ctrl tx_aggr_ctrl; - /** Rx deaggregation control */ - usb_aggr_ctrl rx_deaggr_ctrl; -} aggr_params; - -/** pkt_header */ -typedef struct _pkt_header { - /** pkt_len */ - t_u32 pkt_len; - /** pkt_type */ - t_u32 TxPktType; - /** tx control */ - t_u32 TxControl; -} pkt_header; - -/** eth_priv_802_11_header packet from FW with length */ -typedef struct _eth_priv_mgmt_frame_tx { - /** Packet Length */ - t_u16 frm_len; - /** Frame Control */ - t_u16 frm_ctl; - /** Duration ID */ - t_u16 duration_id; - /** Address1 */ - t_u8 addr1[ETH_ALEN]; - /** Address2 */ - t_u8 addr2[ETH_ALEN]; - /** Address3 */ - t_u8 addr3[ETH_ALEN]; - /** Sequence Control */ - t_u16 seq_ctl; - /** Address4 */ - t_u8 addr4[ETH_ALEN]; - /** Frame payload */ - t_u8 payload[]; -} __ATTRIB_PACK__ eth_priv_mgmt_frame_tx; - -/** frame tx ioctl number */ -#define FRAME_TX_IOCTL (SIOCDEVPRIVATE + 12) - -typedef struct { - t_u32 timeSinceLastQuery_ms; /**< Duration of stats collection */ - - t_u16 bcnCnt; /**< Number of beacons received */ - t_u16 bcnMiss; /**< Estimate of beacons missed */ - t_s16 bcnRssiAvg; /**< Avg beacon RSSI */ - t_s16 bcnSnrAvg; /**< Avg beacon SNR */ - - t_u32 rxPkts; /**< Number of packets received */ - t_s16 rxRssiAvg; /**< Avg received packet RSSI */ - t_s16 rxSnrAvg; /**< Avg received packet SNR */ - - t_u32 txPkts; /**< Number of packets transmitted */ - t_u32 txAttempts; /**< Number of attempts made */ - t_u32 txFailures; /**< Number of pkts that failed */ - t_u8 txInitRate; /**< Current rate adaptation TX rateid */ - t_u8 reserved[3]; /**< Reserved */ - - t_u16 txQueuePktCnt[MAX_AC_QUEUES]; - /**< Number of packets per AC */ - t_u32 txQueueDelay[MAX_AC_QUEUES]; - /**< Averge queue delay per AC*/ -} __ATTRIB_PACK__ HostCmd_DS_LINK_STATS_SUMMARY; - -#define HostCmd_CMD_LINK_STATS_SUMMARY 0x00d3 - -/** Type enumeration of WMM AC_QUEUES */ -typedef enum _wmm_ac { - AC_BE, - AC_BK, - AC_VI, - AC_VO, -} wmm_ac; - -/** Data structure of Host command WMM_PARAM_CFG */ -typedef struct _HostCmd_DS_WMM_PARAM_CONFIG { - /** action */ - t_u16 action; - /** AC Parameters Record WMM_AC_BE, WMM_AC_BK, WMM_AC_VI, WMM_AC_VO */ - IEEEtypes_WmmAcParameters_t ac_params[MAX_AC_QUEUES]; -} __ATTRIB_PACK__ HostCmd_DS_WMM_PARAM_CONFIG; - -/** Host Command ID : Configure ADHOC_OVER_IP parameters */ -#define HostCmd_CMD_WMM_PARAM_CONFIG 0x023a - -#ifdef WIFI_DIRECT_SUPPORT -/** flag for NOA */ -#define WIFI_DIRECT_NOA 1 -/** flag for OPP_PS */ -#define WIFI_DIRECT_OPP_PS 2 -/** Type definition of mlan_ds_wifi_direct_config for MLAN_OID_MISC_WIFI_DIRECT_CONFIG */ -typedef struct _mlan_ds_wifi_direct_config { - /** flags for NOA/OPP_PS */ - t_u8 flags; - /** NoA enable/disable */ - t_u8 noa_enable; - /** index */ - t_u16 index; - /** NoA count */ - t_u8 noa_count; - /** NoA duration */ - t_u32 noa_duration; - /** NoA interval */ - t_u32 noa_interval; - /** opp ps enable/disable */ - t_u8 opp_ps_enable; - /** CT window value */ - t_u8 ct_window; -} mlan_ds_wifi_direct_config; -#endif - -/** DFS repeater mode configuration */ -typedef struct _dfs_repeater { - /** Enable DFS repeater mode */ - t_u16 action; - /** 1 on and 0 off */ - t_u16 mode; -} dfs_repeater; - -#ifdef RX_PACKET_COALESCE -/** RX packet coalesce tlv */ -typedef struct _tlvbuf_rx_pkt_coal_t { - /** threshold for rx packets */ - t_u32 rx_pkt_count; - /** timeout for rx coalescing timer */ - t_u16 delay; -} tlvbuf_rx_pkt_coal_t; -#endif - -/** Maximum SSID length */ -#define MAX_SSID_LENGTH 32 -/** Maximum SSID length */ -#define MIN_SSID_LENGTH 1 -/** Maximum WPA passphrase length */ -#define MAX_WPA_PASSPHRASE_LENGTH 64 -/** Minimum WPA passphrase length */ -#define MIN_WPA_PASSPHRASE_LENGTH 8 - -/** channel statictics */ -typedef struct _chan_statistics_t { - /** channle number */ - t_u8 chan_num; - /** band info */ - Band_Config_t bandcfg; - /** flags */ - t_u8 flags; - /** noise */ - t_s8 noise; - /** total network */ - t_u16 total_networks; - /** scan duration */ - t_u16 cca_scan_duration; - /** busy duration */ - t_u16 cca_busy_duration; - /** min rss */ - t_u8 min_rss; - /** max rss */ - t_u8 max_rss; -} __ATTRIB_PACK__ chan_statistics_t; - -typedef struct _chan_stats { - /** Number of records in the chan_stats */ - t_u32 num_in_chan_stats; - /** channel statistics */ - chan_statistics_t stats[]; -} chan_stats; - -/** cloud keep alive parameters */ -typedef struct _cloud_keep_alive { - /** id */ - t_u8 mkeep_alive_id; - /** enable/disable of this id */ - t_u8 enable; - /** enable/disable reset*/ - t_u8 reset; - /** Reserved */ - t_u8 reserved; - /** Destination MAC address */ - t_u8 dst_mac[ETH_ALEN]; - /** Source MAC address */ - t_u8 src_mac[ETH_ALEN]; - /** packet send period */ - t_u32 sendInterval; - /** packet retry interval */ - t_u32 retryInterval; - /** packet retry count */ - t_u8 retryCount; - /** packet length */ - t_u8 pkt_len; - /** packet content */ - t_u8 pkt[255]; -} __ATTRIB_PACK__ cloud_keep_alive; - -#define TLV_TYPE_PER_PKT_CFG 0x0001 -#define MAX_NUM_ETHER_TYPE 8 -#define MAX_TXRX_CTRL 3 -#define TX_PKT_CTRL MBIT(0) -#define RX_PKT_INFO MBIT(1) -/** PER_PKT_CFG_TLV for per-packet configuration */ -typedef struct _MrvlIEtypes_per_pkt_cfg_t { - /** Header */ - MrvlIEtypesHeader_t header; - /** Tx/Rx per-packet control */ - t_u8 tx_rx_control; - /** Number of ethernet types in ether_type array */ - t_u8 proto_type_num; - /** Array of ether_type for per-packet control */ - t_u16 ether_type[]; -} MrvlIEtypes_per_pkt_cfg_t; - -#define FLAG_TX_HISTOGRAM 0x01 -#define FLAG_RX_HISTOGRAM 0x02 -#define DISABLE_TX_RX_HISTOGRAM 0x00 -#define ENABLE_TX_RX_HISTOGRAM 0x01 -#define GET_TX_RX_HISTOGRAM 0x02 -/** TX histiogram ht statistic parameters */ -typedef struct _tx_pkt_ht_rate_info { - /** tx packet counter of MCS0~MCS15 */ - t_u32 htmcs_txcnt[16]; - /** tx packet's short GI counter of MCS0~MCS15 */ - t_u32 htsgi_txcnt[16]; - /** tx STBC packet counter of MCS0~MCS15 */ - t_u32 htstbcrate_txcnt[16]; -} tx_pkt_ht_rate_info; -/** TX histiogram vht statistic parameters */ -typedef struct _tx_pkt_vht_rate_info { - /** tx packet counter of MCS0~MCS9 */ - t_u32 vhtmcs_txcnt[10]; - /** tx packet's short GI counter of MCS0~MCS9 */ - t_u32 vhtsgi_txcnt[10]; - /** tx STBC packet counter of MCS0~MCS9 */ - t_u32 vhtstbcrate_txcnt[10]; -} tx_pkt_vht_rate_info; -/** TX histiogram he statistic parameters */ -typedef struct _tx_pkt_he_rate_info { - /** tx packet counter of MCS0~MCS11 */ - t_u32 hemcs_txcnt[12]; - /** tx STBC packet counter of MCS0~MCS11 */ - t_u32 hestbcrate_txcnt[12]; -} tx_pkt_he_rate_info; -/** TX histogram statistic parameters*/ -typedef struct _tx_pkt_rate_info { - /** tx packet counter of every NSS, NSS=1,2 */ - t_u32 nss_txcnt[2]; - /** tx packet counter of every bandwith */ - t_u32 bandwidth_txcnt[3]; - /** different preamble tx packet counter */ - t_u32 preamble_txcnt[4]; - /** tx packet counter of using LDPC coding */ - t_u32 ldpc_txcnt; - /** transmitted RTS counter */ - t_u32 rts_txcnt; - /** RSSI of ack */ - t_s32 ack_RSSI; -} tx_pkt_rate_info; -/** RX histiogram ht statistic parameters */ -typedef struct _rx_pkt_ht_rate_info { - /** Rx packet counter of MCS0~MCS15 */ - t_u32 htmcs_rxcnt[16]; - /** Rx packet's short GI counter of MCS0~MCS15 */ - t_u32 htsgi_rxcnt[16]; - /** Rx STBC packet counter of MCS0~MCS15 */ - t_u32 htstbcrate_rxcnt[16]; -} rx_pkt_ht_rate_info; -/** RX histiogram vht statistic parameters */ -typedef struct _rx_pkt_vht_rate_info { - /** Rx packet counter of MCS0~MCS9 */ - t_u32 vhtmcs_rxcnt[10]; - /** Rx packet's short GI counter of MCS0~MCS9 */ - t_u32 vhtsgi_rxcnt[10]; - /** Rx STBC packet counter of MCS0~MCS9 */ - t_u32 vhtstbcrate_rxcnt[10]; -} rx_pkt_vht_rate_info; -/** RX histiogram he statistic parameters */ -typedef struct _rx_pkt_he_rate_info { - /** Rx packet counter of MCS0~MCS11 */ - t_u32 hemcs_rxcnt[12]; - /** Rx STBC packet counter of MCS0~MCS11 */ - t_u32 hestbcrate_rxcnt[12]; -} rx_pkt_he_rate_info; -/** RX histogram statistic parameters*/ -typedef struct _rx_pkt_rate_info { - /** Rx packet counter of every NSS, NSS=1,2 */ - t_u32 nss_rxcnt[2]; - /** Received packet counter which using STBC */ - t_u32 nsts_rxcnt; - /** Rx packet counter of every bandwith */ - t_u32 bandwidth_rxcnt[3]; - /** Different preamble Rx packet counter */ - t_u32 preamble_rxcnt[6]; - /** VHT SIGA2 LDPC bit*/ - t_u32 ldpc_txbfcnt[2]; - /** Average RSSI */ - t_s32 rssi_value[2]; - /** RSSI value of path A */ - t_s32 rssi_chain0[4]; - /** RSSI value of path B */ - t_s32 rssi_chain1[4]; -} rx_pkt_rate_info; -/** TX and RX histogram statistic parameters*/ -typedef struct _tx_rx_histogram { - /** Enable or disable get tx/rx histogram statistic */ - t_u8 enable; - /** Choose to get TX, RX or both histogram statistic */ - t_u8 action; -} __ATTRIB_PACK__ tx_rx_histogram; +#define S_DS_GEN sizeof(HostCmd_DS_GEN) /** max mod group */ -#define MAX_MOD_GROUP 35 +#define MAX_MOD_GROUP 35 /** modulation setting */ typedef struct _mod_group_setting { - /** modulation group */ + /** modulation group */ t_u8 mod_group; - /** power */ + /** power */ t_u8 power; } __ATTRIB_PACK__ mod_group_setting; /** chan trpc config */ typedef struct _ChanTRPCConfig_t { - /** start freq */ + /** start freq */ t_u16 start_freq; /* channel width */ t_u8 width; - /** channel number */ + /** channel number */ t_u8 chan_num; mod_group_setting mod_group[MAX_MOD_GROUP]; } __ATTRIB_PACK__ ChanTRPCConfig_t; /** MrvlIETypes_ChanTRPCConfig_t */ typedef struct _MrvlIETypes_ChanTRPCConfig_t { - /** Header */ + /** Header */ MrvlIEtypesHeader_t header; - /** start freq */ + /** start freq */ t_u16 start_freq; /* channel width */ t_u8 width; - /** channel number */ + /** channel number */ t_u8 chan_num; - /** mode groups */ + /** mode groups */ mod_group_setting mod_group[]; } __ATTRIB_PACK__ MrvlIETypes_ChanTRPCConfig_t; -/*This command gets/sets the Transmit Rate-based Power Control (TRPC) channel configuration.*/ -#define HostCmd_CHANNEL_TRPC_CONFIG 0x00fb +/*This command gets/sets the Transmit Rate-based Power Control (TRPC) channel + * configuration.*/ +#define HostCmd_CHANNEL_TRPC_CONFIG 0x00fb /** TLV OF CHAN_TRPC_CONFIG */ -#define TLV_TYPE_CHAN_TRPC_CONFIG (PROPRIETARY_TLV_BASE_ID + 137) +#define TLV_TYPE_CHAN_TRPC_CONFIG (PROPRIETARY_TLV_BASE_ID + 137) /** mlan_ds_misc_chan_trpc_cfg */ typedef struct _mlan_ds_misc_chan_trpc_cfg { - /** sub_band */ + /** sub_band */ t_u16 sub_band; - /** length */ + /** length */ t_u16 length; - /** trpc buf */ + /** trpc buf */ t_u8 trpc_buf[BUFFER_LENGTH]; } __ATTRIB_PACK__ mlan_ds_misc_chan_trpc_cfg; -/** command ID for CHAN_REGION */ -#define HostCmd_CMD_CHAN_REGION_CFG 0x0242 -#define TLV_TYPE_CHAN_ATTR_CFG (PROPRIETARY_TLV_BASE_ID + 237) //0x1ed -#define TLV_TYPE_REGION_INFO (PROPRIETARY_TLV_BASE_ID + 238) //0x1ee -#define TLV_TYPE_POWER_TABLE (PROPRIETARY_TLV_BASE_ID + 262) //0x206 -#define TLV_TYPE_POWER_TABLE_ATTR (PROPRIETARY_TLV_BASE_ID + 317) //0x23d - -/** MrvlIEtypes_otp_region_info_t */ -typedef struct MrvlIEtypes_otp_region_info { - /** Header */ - MrvlIEtypesHeader_t header; - /** country code */ - t_u8 countrycode[2]; - /** region code */ - t_u8 regioncode; - /** environment */ - t_u8 environment; - /** force_reg */ - t_u16 force_reg:1; - /** reserviced */ - t_u16 reserved:15; -} __ATTRIB_PACK__ MrvlIEtypes_otp_region_info_t; - -/** MrvlIEtypes_otp_region_info_t */ -typedef struct MrvlIEtypes_power_table_attr { - MrvlIEtypesHeader_t header; - /** rows bg = num of channel in 2g */ - t_u8 rows_bg; - /** cols_bg = num of 2g power modules + 1 */ - t_u8 cols_bg; - /** rows a = num of channel in 5g */ - t_u8 rows_a; - /** cols a = num of 5g power modules + 1 */ - t_u8 cols_a; -} __ATTRIB_PACK__ MrvlIEtypes_power_table_attr_t; - -typedef struct { - /** chan number */ - t_u8 chan_no; - /** chan attr */ - t_u8 chan_attr; -} __ATTRIB_PACK__ chan_attr_t; - -/** MrvlIEtypes_chan_attr_t */ -typedef struct MrvlIEtypes_chan_attr { - MrvlIEtypesHeader_t header; - chan_attr_t chan_attr[]; -} __ATTRIB_PACK__ MrvlIEtypes_chan_attr_t; - -typedef struct { - /** chan number */ - t_u8 chan_no; - /** power modules */ - t_u8 power[]; -} __ATTRIB_PACK__ chan_power_t; - -/** MrvlIEtypes_power_tbl_t */ -typedef struct MrvlIEtypes_power_tbl { - MrvlIEtypesHeader_t header; - chan_power_t chan_power[]; -} __ATTRIB_PACK__ MrvlIEtypes_power_table_t; - -typedef enum { - PTVER_2X2_AC = 0, - PTVER_1X1_AC = 1, - PTVER_2X2_N = 2, - PTVER_1X1_N = 3, - PTVER_1X1_AC_11P = 5, - PTVER_2X2_AC_2GVHT = 6, - PTVER_1X1_AC_2GVHT = 7, - PTVER_1X1_AC_2GVHT_11P = 8, -} __ATTRIB_PACK__ ptver_type_e; - -/** mlan_ds_misc_chan_chnrgpwr_cfg */ -typedef struct _mlan_ds_misc_chnrgpwr_cfg { - /** length */ - t_u16 length; - /** chnrgpwr buf */ - t_u8 chnrgpwr_buf[BUFFER_LENGTH]; -} __ATTRIB_PACK__ mlan_ds_misc_chnrgpwr_cfg; - -#define OTP_IDENTIFIER 0x8888 -/* mfg_rghdr_t*/ -typedef struct { - /* identifier, show always 0x8888 */ - t_u16 identifier; - /** version */ - t_u8 version; - /** num of entry */ - t_u8 numberofentries; - /** ptbase version */ - t_u8 ptbaseversion; - /** reserved */ - t_u8 reserved; - /** CRC */ - t_u32 crc; -} __ATTRIB_PACK__ mfg_rghdr_t; - -/* mfg_rgdatahdr_t */ -typedef struct { - /** country code */ - t_u8 countrycode[2]; - /** enviroment */ - t_u8 environment; - /** region code */ - t_u8 regioncode; - /** compressmethod */ - t_u16 compressmethod; - /** length */ - t_u16 length; - /** compressed table */ - t_u8 compressedtable; -} __ATTRIB_PACK__ mfg_rgdatahdr_t; - -#define MAX_MCS_POWER_INDEX 28 -#define MAX_BG_CHAN 14 -#define MAX_A_CHAN 40 - -typedef struct { - /** chan number */ - t_u8 chan_no; - /** power value */ - t_u8 pwr[MAX_MCS_POWER_INDEX]; - /** chan attr */ - t_u8 chan_attr; -} __ATTRIB_PACK__ rgchan_pwr_t; - -/** region_chan_pwr_tbl*/ -typedef struct { - /** country code */ - t_u8 countrycode[2]; - /** enviromnent */ - t_u8 environment; - /** region code */ - t_u8 regioncode; - /** 2g pwr tbl */ - rgchan_pwr_t bg_pwr_tbl[MAX_BG_CHAN]; - /** 5g pwr tbl */ - rgchan_pwr_t a_pwr_tbl[MAX_A_CHAN]; - /** max chan number in 5g */ - int max_chan_bg; - /** max power modules in 2g */ - int max_power_bg; - int max_chan_a; - /** max power modules in 5g */ - int max_power_a; - /** ptbase version for display */ - t_u8 ptbaseversion; -} __ATTRIB_PACK__ region_chan_pwr_tbl; - -#define ETH_P_WSMP 0x88dc -#define BUF_SIZ 1024 -typedef struct { - t_u8 version; - t_u8 sec_type; - t_u8 chan; - t_u8 rate; - t_u8 tx_pow; - t_u8 app_class; - t_u8 acm_len; - t_u16 len; -} __ATTRIB_PACK__ wsmp_header; - -typedef struct { - t_u16 rx_datarate; //Data rate - t_u8 rx_channel; //Channel number - t_u8 rx_antenna; //received antenna - t_s8 rx_RSSI; //RSSI info - t_u8 reserved[3]; //Reserved fields -} __ATTRIB_PACK__ dot11_rxcontrol; - -typedef struct { - t_u16 tx_datarate; //Data rate in unit of 0.5Mbps - t_u8 tx_channel; //Channel number to transmit the frame - t_u8 tx_Bw; //Bandwidth to transmit the frame - t_u8 tx_power; //Power to be used for transmission - t_u8 pkt_priority; //Priority of the packet to be transmitted - t_u8 retry_limit; //tx retry limit - t_u8 reserved[1]; //Reserved fields -} __ATTRIB_PACK__ dot11_txcontrol; - -/* CW_MODE_CTRL structure*/ -typedef struct { - t_u8 mode; - t_u8 channel; - t_u8 chanInfo; - t_u16 txPower; - t_u16 pktLength; - t_u32 rateInfo; -} __ATTRIB_PACK__ cw_mode_ctrl; - -#if defined(PCIE) -/* ssu_params_cfg */ -typedef struct _ssu_params_cfg { - /* ssu mode */ - t_u8 ssu_mode; - /* 0-3; # of FFT samples to skip */ - t_u32 nskip; - /* 0-3: # of FFT samples selected to dump */ - t_u32 nsel; - /* 0-3: Down sample ADC input for buffering */ - t_u32 adcdownsample; - /* 0-1: Mask out ADC Data from spectral packet */ - t_u32 mask_adc_pkt; - /* 0-1: Enable 16-Bit FFT output data precision in spectral packet */ - t_u32 out_16bits; - /* 0-1: Enable power spectrum in dB for spectral packe */ - t_u32 spec_pwr_enable; - /* 0-1: Enable spectral packet rate reduction in DB output format */ - t_u32 rate_deduction; - /* 0-7: Number of spectral packets over which spectral data is to be averaged. */ - t_u32 n_pkt_avg; -} __ATTRIB_PACK__ ssu_params_cfg; -#endif - -/** BF Global Configuration */ -#define BF_GLOBAL_CONFIGURATION 0x00 -/** Performs NDP sounding for PEER specified */ -#define TRIGGER_SOUNDING_FOR_PEER 0x01 -/** TX BF interval for channel sounding */ -#define SET_GET_BF_PERIODICITY 0x02 -/** Tell FW not to perform any sounding for peer */ -#define TX_BF_FOR_PEER_ENBL 0x03 -/** TX BF SNR threshold for peer */ -#define SET_SNR_THR_PEER 0x04 -/** TX Sounding*/ -#define TX_SOUNDING_CFG 0x05 - -/** bf global cfg args */ -typedef struct _bf_global_cfg { - /** Global enable/disable bf */ - t_u8 bf_enbl; - /** Global enable/disable sounding */ - t_u8 sounding_enbl; - /** FB Type */ - t_u8 fb_type; - /** SNR Threshold */ - t_u8 snr_threshold; - /** Sounding interval in milliseconds */ - t_u16 sounding_interval; - /** BF mode */ - t_u8 bf_mode; - /** Reserved */ - t_u8 reserved; -} bf_global_cfg; - -/** trigger sounding args */ -typedef struct _trigger_sound { - /** Peer MAC address */ - t_u8 peer_mac[MLAN_MAC_ADDR_LENGTH]; - /** Status */ - t_u8 status; -} trigger_sound; - -/** bf periodicity args */ -typedef struct _bf_periodicity_cfg { - /** Peer MAC address */ - t_u8 peer_mac[MLAN_MAC_ADDR_LENGTH]; - /** Current Tx BF Interval in milliseconds */ - t_u16 interval; - /** Status */ - t_u8 status; -} bf_periodicity_cfg; - -/** tx bf peer args */ -typedef struct _tx_bf_peer_cfg { - /** Peer MAC address */ - t_u8 peer_mac[MLAN_MAC_ADDR_LENGTH]; - /** Reserved */ - t_u16 reserved; - /** Enable/Disable Beamforming */ - t_u8 bf_enbl; - /** Enable/Disable sounding */ - t_u8 sounding_enbl; - /** FB Type */ - t_u8 fb_type; -} tx_bf_peer_cfg; - -/** SNR threshold args */ -typedef struct _snr_thr_cfg { - /** Peer MAC address */ - t_u8 peer_mac[MLAN_MAC_ADDR_LENGTH]; - /** SNR for peer */ - t_u8 snr; -} snr_thr_cfg; - -/** Type definition of mlan_ds_11ax_he_capa for MLAN_OID_11AX_HE_CFG */ -typedef struct _mlan_ds_11ax_he_capa { - /** tlv id of he capability */ - t_u16 id; - /** length of the payload */ - t_u16 len; - /** extension id */ - t_u8 ext_id; - /** he mac capability info */ - t_u8 he_mac_cap[6]; - /** he phy capability info */ - t_u8 he_phy_cap[11]; - /** he txrx mcs support for 80MHz */ - t_u8 he_txrx_mcs_support[4]; - /** val for txrx mcs 160Mhz or 80+80, and PPE thresholds */ - t_u8 val[28]; -} __ATTRIB_PACK__ mlan_ds_11ax_he_capa, *pmlan_ds_11ax_he_capa; - -/** Type definition of mlan_ds_11ax_he_cfg for MLAN_OID_11AX_HE_CFG */ -typedef struct _mlan_ds_11ax_he_cfg { - /** band, BIT0:2.4G, BIT1:5G*/ - t_u8 band; - /** mlan_ds_11ax_he_capa */ - mlan_ds_11ax_he_capa he_cap; -} __ATTRIB_PACK__ mlan_ds_11ax_he_cfg, *pmlan_ds_11ax_he_cfg; - -#define MLAN_11AXCMD_CFG_ID_SR_OBSS_PD_OFFSET 1 -#define MLAN_11AXCMD_CFG_ID_SR_ENABLE 2 -#define MLAN_11AXCMD_CFG_ID_BEAM_CHANGE 3 -#define MLAN_11AXCMD_CFG_ID_HTC_ENABLE 4 - -#define MLAN_11AXCMD_SR_SUBID 0x102 -#define MLAN_11AXCMD_BEAM_SUBID 0x103 -#define MLAN_11AXCMD_HTC_SUBID 0x104 - -#define MRVL_DOT11AX_ENABLE_SR_TLV_ID (PROPRIETARY_TLV_BASE_ID + 322) -#define MRVL_DOT11AX_OBSS_PD_OFFSET_TLV_ID (PROPRIETARY_TLV_BASE_ID + 323) - -#ifndef MLAN_ACT_GET -#define MLAN_ACT_GET 2 -#endif - -/** Type definition of mlan_11axcmdcfg_obss_pd_offset for MLAN_OID_11AX_CMD_CFG */ -typedef struct _mlan_11axcmdcfg_obss_pd_offset { - /** */ - t_u8 offset[2]; -} __ATTRIB_PACK__ mlan_11axcmdcfg_obss_pd_offset; - -/** Type definition of mlan_11axcmdcfg_sr_control for MLAN_OID_11AX_CMD_CFG */ -typedef struct _mlan_11axcmdcfg_sr_control { - /** 1 enable, 0 disable */ - t_u8 control; -} __ATTRIB_PACK__ mlan_11axcmdcfg_sr_control; - -/** Type definition of mlan_ds_11ax_sr_cmd for MLAN_OID_11AX_CMD_CFG */ -typedef struct _mlan_ds_11ax_sr_cmd { - /** type*/ - t_u16 type; - /** length of TLV */ - t_u16 len; - /** value */ - union { - mlan_11axcmdcfg_obss_pd_offset obss_pd_offset; - mlan_11axcmdcfg_sr_control sr_control; - } param; -} __ATTRIB_PACK__ mlan_ds_11ax_sr_cmd, *pmlan_ds_11ax_sr_cmd; - -/** Type definition of mlan_ds_11ax_beam_cmd for MLAN_OID_11AX_CMD_CFG */ -typedef struct _mlan_ds_11ax_beam_cmd { - /** command value: 1 is disable, 0 is enable*/ - t_u8 value; -} mlan_ds_11ax_beam_cmd, *pmlan_ds_11ax_beam_cmd; - -/** Type definition of mlan_ds_11ax_htc_cmd for MLAN_OID_11AX_CMD_CFG */ -typedef struct _mlan_ds_11ax_htc_cmd { - /** command value: 1 is enable, 0 is disable*/ - t_u8 value; -} mlan_ds_11ax_htc_cmd, *pmlan_ds_11ax_htc_cmd; - -/** Type definition of mlan_ds_11ax_cmd_cfg for MLAN_OID_11AX_CMD_CFG */ -typedef struct _mlan_ds_11ax_cmd_cfg { - /** Sub-command */ - t_u32 sub_command; - /** Sub-id */ - t_u32 sub_id; - /** 802.11n configuration parameter */ - union { - /** SR configuration for MLAN_11AXCMD_SR_SUBID */ - mlan_ds_11ax_sr_cmd sr_cfg; - /** Beam configuration for MLAN_11AXCMD_BEAM_SUBID */ - mlan_ds_11ax_beam_cmd beam_cfg; - /** HTC configuration for MLAN_11AXCMD_HTC_SUBID */ - mlan_ds_11ax_htc_cmd htc_cfg; - } param; -} mlan_ds_11ax_cmd_cfg, *pmlan_ds_11ax_cmd_cfg; - -/** TWT setup parameters */ -typedef struct _twt_setup { - /** Implicit, 0: TWT session is explicit, 1: Session is implicit */ - t_u8 implicit; - /** Announced, 0: Unannounced, 1: Announced TWT */ - t_u8 announced; - /** Trigger Enabled, 0: Non-Trigger enabled, 1: Trigger enabled TWT */ - t_u8 triggerEn; - /** TWT Information Disabled, 0: TWT info enabled, 1: TWT info disabled */ - t_u8 twtInfoDisabled; - /** Negotiation Type, 0: Future Individual TWT SP start time, 1: Next Wake TBTT time */ - t_u8 negotiationType; - /** TWT Wakeup Duration, time after which the TWT requesting STA can transition to doze state */ - t_u8 twtWakeupDuration; - /** Flow Identifier. Range: [0-7]*/ - t_u8 flowIdentifier; - /** Hard Constraint, 0: FW can tweak the TWT setup parameters if it is rejected by AP. - ** 1: Firmware should not tweak any parameters. */ - t_u8 hardConstraint; - /** TWT Exponent, Range: [0-63] */ - t_u8 twtExponent; - /** TWT Mantissa Range: [0-sizeof(UINT16)] */ - t_u16 twtMantissa; -} __ATTRIB_PACK__ twt_setup; - -/** TWT tear down parameters */ -typedef struct _twt_teardown { - /** TWT Flow Identifier. Range: [0-7] */ - t_u8 flowIdentifier; - /** Negotiation Type. 0: Future Individual TWT SP start time, 1: Next Wake TBTT time */ - t_u8 negotiationType; - /** Tear down all TWT. 1: To teardown all TWT, 0 otherwise */ - t_u8 teardownAllTWT; -} __ATTRIB_PACK__ twt_teardown; - -/** rx_abort_cfg parameters */ -typedef struct _rx_abort_cfg_para { - /** enable/disable Rx abort */ - int enable; - /** rx weak rssi pkt threshold */ - int rssi_threshold; -} rx_abort_cfg_para; -/** rx_abort_cfg_ext parameters */ -typedef struct _rx_abort_cfg_ext_para { - /** enable/disable Rx abort */ - int enable; - /** rssi margin */ - int rssi_margin; - /** ceil rssi threshold */ - int ceil_rssi_threshold; -} rx_abort_cfg_ext_para; - -#define TX_AMPDU_RTS_CTS 0 -#define TX_AMPDU_CTS_2_SELF 1 -#define TX_AMPDU_DISABLE_PROTECTION 2 -#define TX_AMPDU_DYNAMIC_RTS_CTS 3 - -/** tx_ampdu_prot_mode parameters */ -typedef struct _tx_ampdu_prot_mode_para { - /** set prot mode */ - int mode; -} tx_ampdu_prot_mode_para; - -/** rate adapt cfg parameters */ -typedef struct _rate_adapt_cfg_para { - /** SR(Success Rate) rateadapt */ - int sr_rateadapt; - /** set low threshold */ - int ra_low_thresh; - /** set high threshold */ - int ra_high_thresh; - /** set timer interval */ - int ra_interval; -} rate_adapt_cfg_para; - -#define CCK_DESENSE_MODE_DISABLED 0 -#define CCK_DESENSE_MODE_DYNAMIC 1 -#define CCK_DESENSE_MODE_DYN_ENH 2 -/** cck_desense_cfg parameters */ -typedef struct _cck_desense_cfg_para { - /** cck desense mode: 0:disable 1:normal 2:dynamic */ - int mode; - /** specify rssi margin */ - int margin; - /** specify ceil rssi threshold */ - int ceil_thresh; - /** cck desense "on" interval count */ - int num_on_intervals; - /** cck desense "off" interval count */ - int num_off_intervals; -} cck_desense_cfg_para; - -typedef enum _dfs_state { - /** Channel can be used, CAC (Channel Availability Check) must be done before using it */ - DFS_USEABLE = 0, - /** Channel is not available, radar was detected */ - DFS_UNAVAILABLE = 1, - /** Channel is Available, CAC is done and is free of radar */ - DFS_AVAILABLE = 2, -} dfs_state; - #endif /* _MLANUTL_H_ */ diff --git a/mxm_wifiex/wlan_src/mapp/mlanutl/timestamp.c b/mxm_wifiex/wlan_src/mapp/mlanutl/timestamp.c deleted file mode 100644 index 88aecc3..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanutl/timestamp.c +++ /dev/null @@ -1,414 +0,0 @@ -/** @file timestamp.c - * - * @brief Functions for timestamping feature - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ - -#include "timestamp.h" -#include "time.h" - -/* GLobal Declarations */ -struct timespec send_time; -struct interface_data inter; - -/** - *@brief Receive Timestamps - * - *@param argc Number of arguments - *@param argv Pointer to the arguments array - * - * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - **/ -void -receive_timestamp(int argc, char *argv[]) -{ - int sockfd; - int sockopt; - char ifName[IFNAMSIZ]; - struct ifreq if_ip; /* get ip addr */ - int so_timestamping_flags = 0; - int siocgstamp = 0; - int siocgstampns = 0; - struct timeval now; - int res; - struct ifreq if_idx; - struct ifreq if_mac; - fd_set readfs, errorfs; - - /* Get interface name */ - if (argc > 2) - strcpy(ifName, argv[1]); - else { - fprintf(stderr, - "invalid no. of arguments to receive_timestamp \n"); - exit(1); - } - - /* Header structures */ - so_timestamping_flags |= SOF_TIMESTAMPING_SOFTWARE; - so_timestamping_flags |= SOF_TIMESTAMPING_RAW_HARDWARE; - memset(&if_ip, 0, sizeof(struct ifreq)); - - /* Open PF_PACKET socket, listening for EtherType ETHER_TYPE */ - if ((sockfd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_802_EX1))) == -1) { - perror("listener: socket"); - } - - /* Get the index of the interface to receive on */ - memset(&if_idx, 0, sizeof(struct ifreq)); - strncpy(if_idx.ifr_name, ifName, IFNAMSIZ - 1); - if (ioctl(sockfd, SIOCGIFINDEX, &if_idx) < 0) - perror("SIOCGIFINDEX"); - - /* Get the MAC address of the interface to receive on */ - memset(&if_mac, 0, sizeof(struct ifreq)); - strncpy(if_mac.ifr_name, ifName, IFNAMSIZ - 1); - if (ioctl(sockfd, SIOCGIFHWADDR, &if_mac) < 0) - perror("SIOCGIFHWADDR"); - - /* Allow the socket to be reused - incase connection is closed prematurely */ - if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &sockopt, - sizeof sockopt) == -1) { - perror("setsockopt"); - close(sockfd); - exit(1); - } - - /* Bind to device */ - if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE, - ifName, IFNAMSIZ - 1) == -1) { - perror("SO_BINDTODEVICE"); - close(sockfd); - exit(1); - } - - if (so_timestamping_flags && - setsockopt(sockfd, SOL_SOCKET, SO_TIMESTAMPING, - &so_timestamping_flags, - sizeof(so_timestamping_flags)) < 0) - perror("setsockopt SO_TIMESTAMPING"); - - while (1) { - FD_ZERO(&readfs); - FD_ZERO(&errorfs); - FD_SET(sockfd, &readfs); - FD_SET(sockfd, &errorfs); - gettimeofday(&now, NULL); - res = select(sockfd + 1, &readfs, 0, &errorfs, NULL); - if (res > 0) { - recvpacket(sockfd, 0, siocgstamp, siocgstampns); - } - } -} - -/** - *@brief Send Timestamps - * - *@param argc Number of arguments - *@param argv Pointer to the arguments array - * - *@return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE - **/ -int -send_timestamp(int argc, char *argv[]) -{ - int sockfd; - struct ifreq if_idx; - struct ifreq if_mac; - int tx_len = 0, i; - char sendbuf[BUF_SIZ]; - char buff[BUF_SIZ]; - struct ether_header *eh = (struct ether_header *)sendbuf; - struct sockaddr_ll socket_address; - char ifName[IFNAMSIZ], ip[50]; - struct timeval delta; - fd_set readfs, errorfs; - int res, siocgstamp = 1, siocgstampns = 1; - int so_timestamping_flags = SOF_TIMESTAMPING_TX_HARDWARE; - struct ifreq hwtstamp; - struct hwtstamp_config hwconfig; - - so_timestamping_flags |= SOF_TIMESTAMPING_RAW_HARDWARE; - so_timestamping_flags |= SOF_TIMESTAMPING_TX_HARDWARE; - so_timestamping_flags |= SOF_TIMESTAMPING_SYS_HARDWARE; - - /* Get interface name */ - if (argc > 4) { - strcpy(ifName, argv[1]); - strcpy(ip, argv[4]); - } else { - fprintf(stderr, "invalid no. of args for send_timestamp\n"); - exit(1); - } - - /* Open RAW socket to send on */ - if ((sockfd = socket(PF_PACKET, SOCK_RAW, ETH_P_802_EX1)) == -1) { - perror("socket"); - } - - memset(&hwtstamp, 0, sizeof(hwtstamp)); - strncpy(hwtstamp.ifr_name, ifName, sizeof(hwtstamp.ifr_name)); - hwtstamp.ifr_data = (void *)&hwconfig; - memset(&hwconfig, 0, sizeof(hwconfig)); - - hwconfig.tx_type = - (so_timestamping_flags & SOF_TIMESTAMPING_TX_HARDWARE) ? - HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF; - - hwconfig.rx_filter = - (so_timestamping_flags & SOF_TIMESTAMPING_RX_HARDWARE) ? - HWTSTAMP_FILTER_PTP_V1_L4_SYNC : HWTSTAMP_FILTER_NONE; - - /* Get the index of the interface to send on */ - memset(&if_idx, 0, sizeof(struct ifreq)); - strncpy(if_idx.ifr_name, ifName, IFNAMSIZ - 1); - if (ioctl(sockfd, SIOCGIFINDEX, &if_idx) < 0) - perror("SIOCGIFINDEX"); - - /* Get the MAC address of the interface to send on */ - memset(&if_mac, 0, sizeof(struct ifreq)); - strncpy(if_mac.ifr_name, ifName, IFNAMSIZ - 1); - if (ioctl(sockfd, SIOCGIFHWADDR, &if_mac) < 0) - perror("SIOCGIFHWADDR"); - - if (so_timestamping_flags && - setsockopt(sockfd, SOL_SOCKET, SO_TIMESTAMPING, - &so_timestamping_flags, - sizeof(so_timestamping_flags)) < 0) - perror("setsockopt SO_TIMESTAMPING"); - - if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE, - ifName, IFNAMSIZ - 1) == -1) { - perror("bind"); - exit(1); - } - - /* Construct the Ethernet header */ - memset(sendbuf, 0, BUF_SIZ); - - /* Ethernet header */ - memcpy(eh->ether_shost, (u_int8_t *) & if_mac.ifr_hwaddr.sa_data, - MLAN_MAC_ADDR_LENGTH); - - eh->ether_type = htons(ETH_P_802_EX1); - - tx_len += sizeof(struct ether_header); - - get_mac(ifName, ip); - for (i = 0; i < MLAN_MAC_ADDR_LENGTH; i++) { - eh->ether_dhost[i] = (uint8_t) inter.mac[i]; - } - /* Index of the network device */ - socket_address.sll_ifindex = if_idx.ifr_ifindex; - - /* Address length */ - socket_address.sll_halen = ETH_ALEN; - memcpy(&socket_address.sll_addr, (uint8_t *) & inter.mac, - MLAN_MAC_ADDR_LENGTH); - - clock_gettime(CLOCK_REALTIME, &send_time); - sprintf(buff, "%lld.%lld", (long long)send_time.tv_sec, - (long long)send_time.tv_nsec); - strcpy((sendbuf + tx_len), buff); - - /* Send packet */ - res = sendto(sockfd, sendbuf, tx_len + strlen(buff), 0, - (struct sockaddr *)&socket_address, - sizeof(struct sockaddr_ll)); - if (res < 0) - perror("Send "); - - fprintf(stdout, "Application time : %lld.%09lld (sent)\n", - (long long)send_time.tv_sec, (long long)send_time.tv_nsec); - - delta.tv_sec = 5; - delta.tv_usec = 0; - - FD_ZERO(&readfs); - FD_ZERO(&errorfs); - FD_SET(sockfd, &readfs); - FD_SET(sockfd, &errorfs); - - res = select(sockfd + 1, &readfs, 0, &errorfs, &delta); - if (res > 0) { - recvpacket(sockfd, MSG_ERRQUEUE, siocgstamp, siocgstampns); - } - return MLAN_STATUS_SUCCESS; -} - -/** - *@brief get destination mac address - * - *@param ifc interface from which packet has to be sent - *@param ip IP Address of destination - * - *@return N/A - **/ -void -get_mac(char *ifc, char *ip) -{ - char ipAddr[20]; - char hwAddr[20]; - char device[10], temp[3], in[50]; - int i = 0, j = 0, k = 0, res = 0, retry = 0; - FILE *arpCache = fopen("/proc/net/arp", "r"); - if (!arpCache) { - fprintf(stderr, - "Arp Cache: Failed to open file \"/proc/net/arp\""); - } - - /* Ignore the first line, which contains the header */ - char header[ARP_FILE_BUFFER_LEN]; - -retry_again: - - if (!fgets(header, sizeof(header), arpCache)) - fprintf(stderr, "error getting mac from proc files"); - while (3 == fscanf(arpCache, ARP_FORMAT, ipAddr, hwAddr, device)) { - if ((!strcmp(ipAddr, ip)) && (!strcmp(ifc, device))) { - printf("Sending Packet to Peer : %s\n", hwAddr); - strcpy(inter.ip, ipAddr); - strcpy(inter.interface, device); - while (hwAddr[i] != '\0') { - if (hwAddr[i] == ':') { - inter.mac[j++] = strtol(temp, NULL, 16); - i++; - k = 0; - } else - temp[k++] = hwAddr[i++]; - } - inter.mac[j] = strtol(temp, NULL, 16); - res = 1; - } - } - if (res != 1 && retry == 0) { - sprintf(in, "ping -c 2 %s > /dev/null", ip); - system(in); - retry = 1; - rewind(arpCache); - goto retry_again; - } else if (res != 1 && retry == 1) { - printf("cannot find mac address for the specified ip\n"); - fclose(arpCache); - exit(1); - } - fclose(arpCache); -} - -/* - *@brief Receive Sync Packets - * - *@param sock socket from which packet must be recieved - *@param recvmsg_flags flags for recvmsg - *@param siocgstamp timestamp flag - *@param siocgstampns timestamp flag for nano secs - * - *@return N/A - **/ -void -recvpacket(int sock, int recvmsg_flags, int siocgstamp, int siocgstampns) -{ - unsigned char data[256]; - struct msghdr msg; - struct iovec entry; - struct sockaddr_in from_addr; - struct { - struct cmsghdr cm; - char control[512]; - } control; - int res, i; - - memset(&msg, 0, sizeof(msg)); - msg.msg_iov = &entry; - msg.msg_iovlen = 1; - entry.iov_base = data; - entry.iov_len = sizeof(data); - msg.msg_name = (caddr_t) & from_addr; - msg.msg_namelen = sizeof(from_addr); - msg.msg_control = &control; - msg.msg_controllen = sizeof(control); - - res = recvmsg(sock, &msg, recvmsg_flags | MSG_DONTWAIT); - if (res < 0) { - fprintf(stderr, "%s %s: %s\n", - "recvmsg", - (recvmsg_flags & MSG_ERRQUEUE) ? "error" : "regular", - strerror(errno)); - } else { - if (!(recvmsg_flags & MSG_ERRQUEUE)) { - printf("Received Packet from Peer : "); - for (i = 6; i < 12; i++) - printf("%02x:", data[i]); - printf("\n"); - } - printpacket(&msg, res, sock, recvmsg_flags, siocgstamp, - siocgstampns); - } -} - -/** - * @brief Prints Sent/Received Sync packets - * - * @param msg msghdr structure variable - * @param res result of recvmsg call - * @param sock socket variable - * @param recvmsg_flags flags for receive message - * @param siocgstamp timestamp flag - * @param siocgstampns timestamp flag for nano secs - * - * @return N/A - **/ -void -printpacket(struct msghdr *msg, int res, - int sock, int recvmsg_flags, int siocgstamp, int siocgstampns) -{ - struct cmsghdr *cmsg; - struct timespec now; - struct timespec *stamp; - clock_gettime(CLOCK_REALTIME, &now); - if (!(recvmsg_flags & MSG_ERRQUEUE)) { - printf("Application time : %ld.%09ld (received)\n", - (long)now.tv_sec, (long)now.tv_nsec); - } - - for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { - if (cmsg->cmsg_level == SOL_SOCKET && - cmsg->cmsg_type == SO_TIMESTAMPING) { - stamp = (struct timespec *)CMSG_DATA(cmsg); - stamp++; - /* skip deprecated HW transformed */ - stamp++; - fprintf(stdout, "HW time : %ld.%09ld\n", - (long)stamp->tv_sec, (long)stamp->tv_nsec); - if (!(recvmsg_flags & MSG_ERRQUEUE)) - fprintf(stdout, "Delta in nsecs= %lld\n", - ((long long)(now.tv_sec - - stamp->tv_sec) * - 1000000000L + now.tv_nsec) - - (stamp->tv_nsec)); - else - fprintf(stdout, "Delta in nsecs= %lld", - ((long long)(stamp->tv_sec - - send_time.tv_sec) * - 1000000000L + (stamp->tv_nsec) - - send_time.tv_nsec)); - } - } - fprintf(stdout, "\n"); -} diff --git a/mxm_wifiex/wlan_src/mapp/mlanutl/timestamp.h b/mxm_wifiex/wlan_src/mapp/mlanutl/timestamp.h deleted file mode 100644 index 0bf829a..0000000 --- a/mxm_wifiex/wlan_src/mapp/mlanutl/timestamp.h +++ /dev/null @@ -1,55 +0,0 @@ -/** @file timestamp.h - * - * @brief This file contains definitions used for application - * - * - * Copyright 2014-2020 NXP - * - * This software file (the File) is distributed by NXP - * under the terms of the GNU General Public License Version 2, June 1991 - * (the License). You may use, redistribute and/or modify the File in - * accordance with the terms and conditions of the License, a copy of which - * is available by writing to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the - * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. - * - * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE - * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE - * ARE EXPRESSLY DISCLAIMED. The License provides additional details about - * this warranty disclaimer. - * - */ - -#ifndef _TIMESTAMP_H_ -#define _TIMESTAMP_H_ - -#include "mlanutl.h" -#include -#include -#include - -#define BUF_SIZ 1024 -#define ARP_FORMAT "%s %*s %*s %s %*s %s" -#define ARP_FILE_BUFFER_LEN (1024) - -struct interface_data { - char ip[20]; - int mac[20]; - char interface[20]; -}; - -/** - * 802.1 Local Experimental 1. - */ -#ifndef ETH_P_802_EX1 -#define ETH_P_802_EX1 0x88B5 -#endif - -void receive_timestamp(int argc, char *argv[]); -int send_timestamp(int argc, char *argv[]); -void get_mac(char *ifc, char *ip); -void recvpacket(int sock, int recvmsg_flags, int siocgstamp, int siocgstampns); -void printpacket(struct msghdr *msg, int res, int sock, - int recvmsg_flags, int siocgstamp, int siocgstampns); - -#endif //_TIMESTAMP_H_