From 90dce9c6ebc56644792bcc1c91fbbfbb28f951e1 Mon Sep 17 00:00:00 2001 From: Yuvraj Singh Date: Tue, 17 Mar 2026 17:31:27 +0530 Subject: [PATCH] Driver commit for mxm5x17405_FP68_p61_v0v1-mgpl Signed-off-by: Yuvraj Singh --- BUILD.bazel | 21 + Makefile | 671 + README | 528 + README_MLAN | 5325 ++++ README_RBC | 112 + README_UAP | 2994 ++ README_WIFIDIRECT | 448 + ...-mxmdriver-linux-mxm405.p61_MGPL.spdx.json | 35 + gpl-2.0.txt | 339 + mapp/mlan2040coex/Makefile | 52 + mapp/mlan2040coex/mlan2040coex.c | 1375 + mapp/mlan2040coex/mlan2040coex.h | 230 + mapp/mlan2040coex/mlan2040misc.c | 281 + mapp/mlan2040coex/mlan2040misc.h | 420 + mapp/mlanconfig/Makefile | 48 + mapp/mlanconfig/config/11axcfg.conf | 49 + mapp/mlanconfig/config/11n_2040coex.conf | 21 + mapp/mlanconfig/config/arpfilter.conf | 29 + mapp/mlanconfig/config/auto_tx.conf | 55 + mapp/mlanconfig/config/autodfs.conf | 13 + mapp/mlanconfig/config/band_steer_cfg.conf | 60 + mapp/mlanconfig/config/bg_scan.conf | 166 + .../mlanconfig/config/bg_scan_wifidirect.conf | 88 + mapp/mlanconfig/config/cal_data.conf | 42 + mapp/mlanconfig/config/crypto_test.conf | 58 + mapp/mlanconfig/config/csi.conf | 22 + mapp/mlanconfig/config/cwmode.conf | 51 + mapp/mlanconfig/config/debug.conf | 729 + mapp/mlanconfig/config/debug_ci_mode.conf | 49 + .../config/ed_mac_ctrl_V2_8897.conf | 29 + .../config/ed_mac_ctrl_V2_8997.conf | 22 + .../config/ed_mac_ctrl_V2_909x.conf | 29 + mapp/mlanconfig/config/ftm.conf | 114 + mapp/mlanconfig/config/hal_phy_cfg.conf | 11 + mapp/mlanconfig/config/host_tdls.conf | 22 + mapp/mlanconfig/config/init_cfg.conf | 14 + mapp/mlanconfig/config/mef.conf | 167 + mapp/mlanconfig/config/mef_mdns.conf | 204 + mapp/mlanconfig/config/mef_ws_discovery.conf | 204 + mapp/mlanconfig/config/mem.conf | 17 + mapp/mlanconfig/config/mgmt_frame.conf | 30 + mapp/mlanconfig/config/mgmtfilter.conf | 15 + mapp/mlanconfig/config/null_tx.conf | 40 + mapp/mlanconfig/config/or_data.conf | 7 + mapp/mlanconfig/config/pad_cfg.conf | 29 + mapp/mlanconfig/config/pkt_coalescing.conf | 62 + mapp/mlanconfig/config/requesttpc.conf | 15 + mapp/mlanconfig/config/robust_btc.conf | 323 + mapp/mlanconfig/config/rutxpower_limit.conf | 674 + mapp/mlanconfig/config/small_debug.conf | 62 + mapp/mlanconfig/config/smc.conf | 124 + mapp/mlanconfig/config/ssu.conf | 13 + mapp/mlanconfig/config/subevent.conf | 103 + mapp/mlanconfig/config/tdls.conf | 118 + mapp/mlanconfig/config/trigger_frame_cfg.conf | 163 + mapp/mlanconfig/config/tspecs.conf | 100 + mapp/mlanconfig/config/twt.conf | 48 + mapp/mlanconfig/config/twt_Ap.conf | 25 + mapp/mlanconfig/config/tx_ctrl.conf | 58 + mapp/mlanconfig/config/txpwrlimit_cfg.conf | 1388 + .../config/txpwrlimit_cfg_8997.conf | 621 + mapp/mlanconfig/config/txrate_cfg.conf | 240 + mapp/mlanconfig/config/wifi_mod_para.conf | 204 + mapp/mlanconfig/mlanconfig.c | 4877 +++ mapp/mlanconfig/mlanconfig.h | 796 + mapp/mlanconfig/mlanhostcmd.c | 969 + mapp/mlanconfig/mlanhostcmd.h | 387 + mapp/mlanconfig/mlanmisc.c | 1024 + mapp/mlanconfig/mlanmisc.h | 668 + mapp/mlanconfig/mlanoffload.c | 3021 ++ mapp/mlanconfig/mlanoffload.h | 560 + mapp/mlanconfig/mlanregclass.c | 430 + mapp/mlanconfig/mlanregclass.h | 96 + mapp/mlanconfig/mlanroamagent.c | 3184 ++ mapp/mlanconfig/mlanroamagent.h | 321 + mapp/mlanconfig/mlanscanagent.c | 1282 + mapp/mlanconfig/mlanscanagent.h | 147 + mapp/mlanevent/Makefile | 59 + mapp/mlanevent/mlanevent.c | 2747 ++ mapp/mlanevent/mlanevent.h | 1410 + mapp/mlanutl/Makefile | 66 + mapp/mlanutl/mlanhostcmd.c | 940 + mapp/mlanutl/mlanhostcmd.h | 134 + mapp/mlanutl/mlanoffload.c | 3024 ++ mapp/mlanutl/mlanoffload.h | 505 + mapp/mlanutl/mlanregclass.c | 534 + mapp/mlanutl/mlanregclass.h | 96 + mapp/mlanutl/mlanroamagent.c | 3600 +++ mapp/mlanutl/mlanroamagent.h | 321 + mapp/mlanutl/mlanscanagent.c | 823 + mapp/mlanutl/mlanscanagent.h | 148 + mapp/mlanutl/mlanutl.c | 26452 ++++++++++++++++ mapp/mlanutl/mlanutl.h | 3936 +++ mapp/mlanutl/mlanwls.c | 1790 ++ mapp/mlanutl/mlanwls.h | 373 + mapp/mlanutl/timestamp.c | 413 + mapp/mlanutl/timestamp.h | 55 + mapp/uaputl/Makefile | 61 + mapp/uaputl/config/80211d_country_ie.conf | 49 + mapp/uaputl/config/80211d_domain.conf | 49 + mapp/uaputl/config/embedded_dhcp.conf | 9 + .../config/sample_cal_data_bg_8688.conf | 42 + mapp/uaputl/config/tdls_ext_cap.conf | 6 + mapp/uaputl/config/uapcoex.conf | 22 + mapp/uaputl/config/uaputl.conf | 153 + mapp/uaputl/config/uaputl_wifidirect.conf | 80 + mapp/uaputl/uapcmd.c | 7712 +++++ mapp/uaputl/uapcmd.h | 79 + mapp/uaputl/uaphostcmd.c | 332 + mapp/uaputl/uaputl.c | 15244 +++++++++ mapp/uaputl/uaputl.h | 2808 ++ mapp/wifidirectutl/Makefile | 64 + mapp/wifidirectutl/config/wifidirect.conf | 415 + mapp/wifidirectutl/config/wifidisplay.conf | 93 + mapp/wifidirectutl/wifi_display.c | 1302 + mapp/wifidirectutl/wifi_display.h | 257 + mapp/wifidirectutl/wifidirectutl.c | 7914 +++++ mapp/wifidirectutl/wifidirectutl.h | 1431 + mlan.mod | 2 + mlan/.mlan_module.o.d | 165 + mlan/mlan.h | 37 + mlan/mlan_11ac.c | 1431 + mlan/mlan_11ac.h | 56 + mlan/mlan_11ax.c | 1194 + mlan/mlan_11ax.h | 73 + mlan/mlan_11d.c | 1662 + mlan/mlan_11h.c | 4934 +++ mlan/mlan_11h.h | 224 + mlan/mlan_11n.c | 3285 ++ mlan/mlan_11n.h | 418 + mlan/mlan_11n_aggr.c | 616 + mlan/mlan_11n_aggr.h | 38 + mlan/mlan_11n_rxreorder.c | 1614 + mlan/mlan_11n_rxreorder.h | 105 + mlan/mlan_cfp.c | 3913 +++ mlan/mlan_cmdevt.c | 10420 ++++++ mlan/mlan_decl.h | 2695 ++ mlan/mlan_event_ids.h | 227 + mlan/mlan_fw.h | 8242 +++++ mlan/mlan_hostcmd_ids.h | 450 + mlan/mlan_ieee.h | 2232 ++ mlan/mlan_init.c | 1862 ++ mlan/mlan_init.h | 125 + mlan/mlan_ioctl.h | 6484 ++++ mlan/mlan_join.c | 2946 ++ mlan/mlan_join.h | 42 + mlan/mlan_main.h | 4342 +++ mlan/mlan_meas.c | 462 + mlan/mlan_meas.h | 55 + mlan/mlan_misc.c | 7974 +++++ mlan/mlan_module.c | 67 + mlan/mlan_pcie.c | 4850 +++ mlan/mlan_pcie.h | 505 + mlan/mlan_scan.c | 8219 +++++ mlan/mlan_shim.c | 1869 ++ mlan/mlan_sta_cmd.c | 4164 +++ mlan/mlan_sta_cmdresp.c | 3329 ++ mlan/mlan_sta_event.c | 1582 + mlan/mlan_sta_ioctl.c | 5873 ++++ mlan/mlan_sta_rx.c | 963 + mlan/mlan_sta_tx.c | 331 + mlan/mlan_txrx.c | 462 + mlan/mlan_uap.h | 57 + mlan/mlan_uap_cmdevent.c | 6399 ++++ mlan/mlan_uap_ioctl.c | 2565 ++ mlan/mlan_uap_txrx.c | 898 + mlan/mlan_util.h | 518 + mlan/mlan_wmm.c | 3653 +++ mlan/mlan_wmm.h | 246 + mlinux/mlan.h | 37 + mlinux/mlan_decl.h | 2695 ++ mlinux/mlan_ieee.h | 2232 ++ mlinux/mlan_ioctl.h | 6484 ++++ mlinux/moal_cfg80211.c | 5954 ++++ mlinux/moal_cfg80211.h | 587 + mlinux/moal_cfg80211_util.c | 6009 ++++ mlinux/moal_cfg80211_util.h | 970 + mlinux/moal_debug.c | 1577 + mlinux/moal_eth_ioctl.c | 21577 +++++++++++++ mlinux/moal_eth_ioctl.h | 711 + mlinux/moal_init.c | 2785 ++ mlinux/moal_ioctl.c | 9178 ++++++ mlinux/moal_main.c | 12818 ++++++++ mlinux/moal_main.h | 4408 +++ mlinux/moal_pcie.c | 2957 ++ mlinux/moal_pcie.h | 156 + mlinux/moal_priv.c | 6666 ++++ mlinux/moal_priv.h | 277 + mlinux/moal_proc.c | 1465 + mlinux/moal_shim.c | 5074 +++ mlinux/moal_shim.h | 119 + mlinux/moal_sta_cfg80211.c | 11093 +++++++ mlinux/moal_sta_cfg80211.h | 33 + mlinux/moal_uap.c | 4903 +++ mlinux/moal_uap.h | 619 + mlinux/moal_uap_cfg80211.c | 4278 +++ mlinux/moal_uap_cfg80211.h | 37 + mlinux/moal_uap_priv.c | 191 + mlinux/moal_uap_priv.h | 90 + mlinux/moal_uap_wext.c | 1919 ++ mlinux/moal_wext.c | 3493 ++ mlinux/moal_wext.h | 58 + moal.mod | 2 + mxmwifi.mk | 39 + script/load | 16 + script/unload | 24 + script/usbconfig | Bin 0 -> 9098 bytes script/wifidirect/start_auto_go.sh | 30 + script/wifidirect/start_find_phase.sh | 25 + script/wifidirect/start_listen_state.sh | 18 + script/wifidirect/stop_auto_go.sh | 8 + script/wifidirect/stop_wifidirect_client.sh | 6 + script/wifidirect/update_mac.sh | 16 + script/wifidisplay/start_auto_go.sh | 36 + script/wifidisplay/start_find_phase.sh | 30 + script/wifidisplay/update_mac.sh | 16 + 216 files changed, 359507 insertions(+) create mode 100644 BUILD.bazel create mode 100644 Makefile create mode 100644 README create mode 100644 README_MLAN create mode 100644 README_RBC create mode 100644 README_UAP create mode 100644 README_WIFIDIRECT create mode 100644 SBOM-WSW_driver-mxmdriver-linux-mxm405.p61_MGPL.spdx.json create mode 100644 gpl-2.0.txt create mode 100644 mapp/mlan2040coex/Makefile create mode 100644 mapp/mlan2040coex/mlan2040coex.c create mode 100644 mapp/mlan2040coex/mlan2040coex.h create mode 100644 mapp/mlan2040coex/mlan2040misc.c create mode 100644 mapp/mlan2040coex/mlan2040misc.h create mode 100644 mapp/mlanconfig/Makefile create mode 100644 mapp/mlanconfig/config/11axcfg.conf create mode 100644 mapp/mlanconfig/config/11n_2040coex.conf create mode 100644 mapp/mlanconfig/config/arpfilter.conf create mode 100644 mapp/mlanconfig/config/auto_tx.conf create mode 100644 mapp/mlanconfig/config/autodfs.conf create mode 100644 mapp/mlanconfig/config/band_steer_cfg.conf create mode 100644 mapp/mlanconfig/config/bg_scan.conf create mode 100644 mapp/mlanconfig/config/bg_scan_wifidirect.conf create mode 100644 mapp/mlanconfig/config/cal_data.conf create mode 100644 mapp/mlanconfig/config/crypto_test.conf create mode 100644 mapp/mlanconfig/config/csi.conf create mode 100644 mapp/mlanconfig/config/cwmode.conf create mode 100644 mapp/mlanconfig/config/debug.conf create mode 100644 mapp/mlanconfig/config/debug_ci_mode.conf create mode 100644 mapp/mlanconfig/config/ed_mac_ctrl_V2_8897.conf create mode 100644 mapp/mlanconfig/config/ed_mac_ctrl_V2_8997.conf create mode 100644 mapp/mlanconfig/config/ed_mac_ctrl_V2_909x.conf create mode 100644 mapp/mlanconfig/config/ftm.conf create mode 100644 mapp/mlanconfig/config/hal_phy_cfg.conf create mode 100644 mapp/mlanconfig/config/host_tdls.conf create mode 100644 mapp/mlanconfig/config/init_cfg.conf create mode 100644 mapp/mlanconfig/config/mef.conf create mode 100644 mapp/mlanconfig/config/mef_mdns.conf create mode 100644 mapp/mlanconfig/config/mef_ws_discovery.conf create mode 100644 mapp/mlanconfig/config/mem.conf create mode 100644 mapp/mlanconfig/config/mgmt_frame.conf create mode 100644 mapp/mlanconfig/config/mgmtfilter.conf create mode 100644 mapp/mlanconfig/config/null_tx.conf create mode 100644 mapp/mlanconfig/config/or_data.conf create mode 100644 mapp/mlanconfig/config/pad_cfg.conf create mode 100644 mapp/mlanconfig/config/pkt_coalescing.conf create mode 100644 mapp/mlanconfig/config/requesttpc.conf create mode 100644 mapp/mlanconfig/config/robust_btc.conf create mode 100644 mapp/mlanconfig/config/rutxpower_limit.conf create mode 100644 mapp/mlanconfig/config/small_debug.conf create mode 100644 mapp/mlanconfig/config/smc.conf create mode 100644 mapp/mlanconfig/config/ssu.conf create mode 100644 mapp/mlanconfig/config/subevent.conf create mode 100644 mapp/mlanconfig/config/tdls.conf create mode 100644 mapp/mlanconfig/config/trigger_frame_cfg.conf create mode 100644 mapp/mlanconfig/config/tspecs.conf create mode 100644 mapp/mlanconfig/config/twt.conf create mode 100644 mapp/mlanconfig/config/twt_Ap.conf create mode 100644 mapp/mlanconfig/config/tx_ctrl.conf create mode 100644 mapp/mlanconfig/config/txpwrlimit_cfg.conf create mode 100644 mapp/mlanconfig/config/txpwrlimit_cfg_8997.conf create mode 100644 mapp/mlanconfig/config/txrate_cfg.conf create mode 100644 mapp/mlanconfig/config/wifi_mod_para.conf create mode 100644 mapp/mlanconfig/mlanconfig.c create mode 100644 mapp/mlanconfig/mlanconfig.h create mode 100644 mapp/mlanconfig/mlanhostcmd.c create mode 100644 mapp/mlanconfig/mlanhostcmd.h create mode 100644 mapp/mlanconfig/mlanmisc.c create mode 100644 mapp/mlanconfig/mlanmisc.h create mode 100644 mapp/mlanconfig/mlanoffload.c create mode 100644 mapp/mlanconfig/mlanoffload.h create mode 100644 mapp/mlanconfig/mlanregclass.c create mode 100644 mapp/mlanconfig/mlanregclass.h create mode 100644 mapp/mlanconfig/mlanroamagent.c create mode 100644 mapp/mlanconfig/mlanroamagent.h create mode 100644 mapp/mlanconfig/mlanscanagent.c create mode 100644 mapp/mlanconfig/mlanscanagent.h create mode 100644 mapp/mlanevent/Makefile create mode 100644 mapp/mlanevent/mlanevent.c create mode 100644 mapp/mlanevent/mlanevent.h create mode 100644 mapp/mlanutl/Makefile create mode 100644 mapp/mlanutl/mlanhostcmd.c create mode 100644 mapp/mlanutl/mlanhostcmd.h create mode 100644 mapp/mlanutl/mlanoffload.c create mode 100644 mapp/mlanutl/mlanoffload.h create mode 100644 mapp/mlanutl/mlanregclass.c create mode 100644 mapp/mlanutl/mlanregclass.h create mode 100644 mapp/mlanutl/mlanroamagent.c create mode 100644 mapp/mlanutl/mlanroamagent.h create mode 100644 mapp/mlanutl/mlanscanagent.c create mode 100644 mapp/mlanutl/mlanscanagent.h create mode 100644 mapp/mlanutl/mlanutl.c create mode 100644 mapp/mlanutl/mlanutl.h create mode 100644 mapp/mlanutl/mlanwls.c create mode 100644 mapp/mlanutl/mlanwls.h create mode 100644 mapp/mlanutl/timestamp.c create mode 100644 mapp/mlanutl/timestamp.h create mode 100644 mapp/uaputl/Makefile create mode 100644 mapp/uaputl/config/80211d_country_ie.conf create mode 100644 mapp/uaputl/config/80211d_domain.conf create mode 100644 mapp/uaputl/config/embedded_dhcp.conf create mode 100644 mapp/uaputl/config/sample_cal_data_bg_8688.conf create mode 100644 mapp/uaputl/config/tdls_ext_cap.conf create mode 100644 mapp/uaputl/config/uapcoex.conf create mode 100644 mapp/uaputl/config/uaputl.conf create mode 100644 mapp/uaputl/config/uaputl_wifidirect.conf create mode 100644 mapp/uaputl/uapcmd.c create mode 100644 mapp/uaputl/uapcmd.h create mode 100644 mapp/uaputl/uaphostcmd.c create mode 100644 mapp/uaputl/uaputl.c create mode 100644 mapp/uaputl/uaputl.h create mode 100644 mapp/wifidirectutl/Makefile create mode 100644 mapp/wifidirectutl/config/wifidirect.conf create mode 100644 mapp/wifidirectutl/config/wifidisplay.conf create mode 100644 mapp/wifidirectutl/wifi_display.c create mode 100644 mapp/wifidirectutl/wifi_display.h create mode 100644 mapp/wifidirectutl/wifidirectutl.c create mode 100644 mapp/wifidirectutl/wifidirectutl.h create mode 100644 mlan.mod create mode 100644 mlan/.mlan_module.o.d create mode 100644 mlan/mlan.h create mode 100644 mlan/mlan_11ac.c create mode 100644 mlan/mlan_11ac.h create mode 100644 mlan/mlan_11ax.c create mode 100644 mlan/mlan_11ax.h create mode 100644 mlan/mlan_11d.c create mode 100644 mlan/mlan_11h.c create mode 100644 mlan/mlan_11h.h create mode 100644 mlan/mlan_11n.c create mode 100644 mlan/mlan_11n.h create mode 100644 mlan/mlan_11n_aggr.c create mode 100644 mlan/mlan_11n_aggr.h create mode 100644 mlan/mlan_11n_rxreorder.c create mode 100644 mlan/mlan_11n_rxreorder.h create mode 100644 mlan/mlan_cfp.c create mode 100644 mlan/mlan_cmdevt.c create mode 100644 mlan/mlan_decl.h create mode 100644 mlan/mlan_event_ids.h create mode 100644 mlan/mlan_fw.h create mode 100644 mlan/mlan_hostcmd_ids.h create mode 100644 mlan/mlan_ieee.h create mode 100644 mlan/mlan_init.c create mode 100644 mlan/mlan_init.h create mode 100644 mlan/mlan_ioctl.h create mode 100644 mlan/mlan_join.c create mode 100644 mlan/mlan_join.h create mode 100644 mlan/mlan_main.h create mode 100644 mlan/mlan_meas.c create mode 100644 mlan/mlan_meas.h create mode 100644 mlan/mlan_misc.c create mode 100644 mlan/mlan_module.c create mode 100644 mlan/mlan_pcie.c create mode 100644 mlan/mlan_pcie.h create mode 100644 mlan/mlan_scan.c create mode 100644 mlan/mlan_shim.c create mode 100644 mlan/mlan_sta_cmd.c create mode 100644 mlan/mlan_sta_cmdresp.c create mode 100644 mlan/mlan_sta_event.c create mode 100644 mlan/mlan_sta_ioctl.c create mode 100644 mlan/mlan_sta_rx.c create mode 100644 mlan/mlan_sta_tx.c create mode 100644 mlan/mlan_txrx.c create mode 100644 mlan/mlan_uap.h create mode 100644 mlan/mlan_uap_cmdevent.c create mode 100644 mlan/mlan_uap_ioctl.c create mode 100644 mlan/mlan_uap_txrx.c create mode 100644 mlan/mlan_util.h create mode 100644 mlan/mlan_wmm.c create mode 100644 mlan/mlan_wmm.h create mode 100644 mlinux/mlan.h create mode 100644 mlinux/mlan_decl.h create mode 100644 mlinux/mlan_ieee.h create mode 100644 mlinux/mlan_ioctl.h create mode 100644 mlinux/moal_cfg80211.c create mode 100644 mlinux/moal_cfg80211.h create mode 100644 mlinux/moal_cfg80211_util.c create mode 100644 mlinux/moal_cfg80211_util.h create mode 100644 mlinux/moal_debug.c create mode 100644 mlinux/moal_eth_ioctl.c create mode 100644 mlinux/moal_eth_ioctl.h create mode 100644 mlinux/moal_init.c create mode 100644 mlinux/moal_ioctl.c create mode 100644 mlinux/moal_main.c create mode 100644 mlinux/moal_main.h create mode 100644 mlinux/moal_pcie.c create mode 100644 mlinux/moal_pcie.h create mode 100644 mlinux/moal_priv.c create mode 100644 mlinux/moal_priv.h create mode 100644 mlinux/moal_proc.c create mode 100644 mlinux/moal_shim.c create mode 100644 mlinux/moal_shim.h create mode 100644 mlinux/moal_sta_cfg80211.c create mode 100644 mlinux/moal_sta_cfg80211.h create mode 100644 mlinux/moal_uap.c create mode 100644 mlinux/moal_uap.h create mode 100644 mlinux/moal_uap_cfg80211.c create mode 100644 mlinux/moal_uap_cfg80211.h create mode 100644 mlinux/moal_uap_priv.c create mode 100644 mlinux/moal_uap_priv.h create mode 100644 mlinux/moal_uap_wext.c create mode 100644 mlinux/moal_wext.c create mode 100644 mlinux/moal_wext.h create mode 100644 moal.mod create mode 100644 mxmwifi.mk create mode 100755 script/load create mode 100755 script/unload create mode 100644 script/usbconfig create mode 100755 script/wifidirect/start_auto_go.sh create mode 100755 script/wifidirect/start_find_phase.sh create mode 100755 script/wifidirect/start_listen_state.sh create mode 100755 script/wifidirect/stop_auto_go.sh create mode 100755 script/wifidirect/stop_wifidirect_client.sh create mode 100755 script/wifidirect/update_mac.sh create mode 100755 script/wifidisplay/start_auto_go.sh create mode 100755 script/wifidisplay/start_find_phase.sh create mode 100755 script/wifidisplay/update_mac.sh diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000..0b9574d --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,21 @@ +# NOTE: THIS FILE IS EXPERIMENTAL FOR THE BAZEL MIGRATION AND NOT USED FOR +# YOUR BUILDS CURRENTLY. +# +# It is not yet the source of truth for your build. If you're looking to modify +# the build file, modify the Android.bp file instead. Do *not* modify this file +# unless you have coordinated with the team managing the Soong to Bazel +# migration. + +load("//build/kernel/kleaf:kernel.bzl", "kernel_module") + +kernel_module( + name = "wlan.imx", + outs = [ + "mlan.ko", + "moal.ko", + ], + kernel_build = "//common:imx", + visibility = [ + "//common:__pkg__", + ], +) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0c2ab87 --- /dev/null +++ b/Makefile @@ -0,0 +1,671 @@ +# File: Makefile +# +# Copyright 2008-2023 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. +# + +CONFIG_COMPATDIR=n +ifeq ($(CONFIG_COMPATDIR), y) +COMPATDIR=/lib/modules/$(KERNELVERSION_X86)/build/compat-wireless-3.2-rc1-1/include +CC = $(CROSS_COMPILE)gcc -I$(COMPATDIR) +endif + +LD ?= $(CROSS_COMPILE)ld +BACKUP= /root/backup +YMD= `date +%Y%m%d%H%M` + +############################################################################# +# Configuration Options +############################################################################# +# Multi-chipsets +CONFIG_PCIE8897=n +CONFIG_PCIE8997=n +CONFIG_PCIE9097=y +CONFIG_PCIE9098=y + + +# Debug Option +# DEBUG LEVEL n/1/2: +# n: NO DEBUG +# 1: Only PRINTM(MMSG,...), PRINTM(MFATAL,...), ... +# 2: All PRINTM() +CONFIG_DEBUG=1 + +# Enable STA mode support +CONFIG_STA_SUPPORT=y + +# Enable uAP mode support +CONFIG_UAP_SUPPORT=y + +# Enable WIFIDIRECT support +CONFIG_WIFI_DIRECT_SUPPORT=y + +# Enable WIFIDISPLAY support +CONFIG_WIFI_DISPLAY_SUPPORT=y + +# Re-association in driver +CONFIG_REASSOCIATION=y + + +# Manufacturing firmware support +CONFIG_MFG_CMD_SUPPORT=y + +# OpenWrt support +CONFIG_OPENWRT_SUPPORT=n + +# Big-endian platform +CONFIG_BIG_ENDIAN=n + + + + + +# DFS testing support +CONFIG_DFS_TESTING_SUPPORT=y + +# Multi-channel support +CONFIG_MULTI_CHAN_SUPPORT=y + + +CONFIG_ANDROID_KERNEL=n + +CONFIG_DUMP_TO_PROC=n + +CONFIG_FWDUMP_VIA_PRINT=n + +CONFIG_TASKLET_SUPPORT=n + + +#32bit app over 64bit kernel support +CONFIG_USERSPACE_32BIT_OVER_KERNEL_64BIT=n + +GCC_VERSION := $(shell echo `gcc -dumpversion | cut -f1-2 -d.` \>= 4.4 | sed -e 's/\./*100+/g' | bc ) +ifeq ($(GCC_VERSION),1) + ccflags-y += -Wno-packed-bitfield-compat +endif +WimpGCC_VERSION := $(shell echo `gcc -dumpversion | cut -f1 -d.`| bc ) +ifeq ($(shell test $(WimpGCC_VERSION) -ge 7; echo $$?),0) +ccflags-y += -Wimplicit-fallthrough=3 +endif +#ccflags-y += -Wunused-but-set-variable +#ccflags-y += -Wmissing-prototypes +#ccflags-y += -Wold-style-definition +#ccflags-y += -Wtype-limits +#ccflags-y += -Wsuggest-attribute=format +#ccflags-y += -Wmissing-include-dirs +#ccflags-y += -Wshadow +#ccflags-y += -Wsign-compare +#ccflags-y += -Wunused-macros +#ccflags-y += -Wmissing-field-initializers +#ccflags-y += -Wstringop-truncation +#ccflags-y += -Wmisleading-indentation +#ccflags-y += -Wunused-const-variable + +############################################################################# +# Select Platform Tools +############################################################################# + +ifeq ($(ANDROID_BUILD), 1) + KERNEL_CFLAGS += -DANDROID + PWD := $(shell pwd) + KERNELDIR ?= $(KERNEL_SRC) + ccflags-y += -DANDROID_SDK_VERSION=$(ANDROID_SDK_VERSION) +endif + +MODEXT = ko +ccflags-y += -I$(PWD)/mlan +ccflags-y += -DLINUX + + + + + + + +KERNELVERSION_X86 := $(shell uname -r) +KERNELDIR ?= /lib/modules/$(KERNELVERSION_X86)/build +LD += -S + +BINDIR = ../bin_wlan +APPDIR= $(shell if test -d "mapp"; then echo mapp; fi) + +############################################################################# +# Compiler Flags +############################################################################# + + ccflags-y += -I$(KERNELDIR)/include + ccflags-y += -DMLAN_RELEASE_VERSION='"405.p61"' + + ccflags-y += -DFPNUM='"68"' + +ifeq ($(CONFIG_DEBUG),1) + ccflags-y += -DDEBUG_LEVEL1 +endif + +ifeq ($(CONFIG_DEBUG),2) + ccflags-y += -DDEBUG_LEVEL1 + ccflags-y += -DDEBUG_LEVEL2 + DBG= -dbg +endif + +ifeq ($(CONFIG_64BIT), y) + ccflags-y += -DMLAN_64BIT +endif + +ifeq ($(CONFIG_STA_SUPPORT),y) + ccflags-y += -DSTA_SUPPORT +ifeq ($(CONFIG_REASSOCIATION),y) + ccflags-y += -DREASSOCIATION +endif +else +CONFIG_WIFI_DIRECT_SUPPORT=n +CONFIG_WIFI_DISPLAY_SUPPORT=n +CONFIG_STA_WEXT=n +CONFIG_STA_CFG80211=n +endif + +ifeq ($(CONFIG_UAP_SUPPORT),y) + ccflags-y += -DUAP_SUPPORT +else +CONFIG_WIFI_DIRECT_SUPPORT=n +CONFIG_WIFI_DISPLAY_SUPPORT=n +CONFIG_UAP_WEXT=n +CONFIG_UAP_CFG80211=n +endif + +ifeq ($(CONFIG_WIFI_DIRECT_SUPPORT),y) + ccflags-y += -DWIFI_DIRECT_SUPPORT +endif +ifeq ($(CONFIG_WIFI_DISPLAY_SUPPORT),y) + ccflags-y += -DWIFI_DISPLAY_SUPPORT +endif + +ifeq ($(CONFIG_MFG_CMD_SUPPORT),y) + ccflags-y += -DMFG_CMD_SUPPORT +endif + +ifeq ($(CONFIG_BIG_ENDIAN),y) + ccflags-y += -DBIG_ENDIAN_SUPPORT +endif + +ifeq ($(CONFIG_USERSPACE_32BIT_OVER_KERNEL_64BIT),y) + ccflags-y += -DUSERSPACE_32BIT_OVER_KERNEL_64BIT +endif + + +ifeq ($(CONFIG_MULTI_CHAN_SUPPORT),y) + ccflags-y += -DMULTI_CHAN_SUPPORT +endif + +ifeq ($(CONFIG_DFS_TESTING_SUPPORT),y) + ccflags-y += -DDFS_TESTING_SUPPORT +endif + + +ifeq ($(CONFIG_ANDROID_KERNEL), y) + ccflags-y += -DANDROID_KERNEL + CONFIG_DUMP_TO_PROC=y +endif + +ifeq ($(CONFIG_DUMP_TO_PROC), y) + ccflags-y += -DDUMP_TO_PROC +endif + +ifeq ($(CONFIG_FWDUMP_VIA_PRINT), y) + ccflags-y += -DFWDUMP_VIA_PRINT +endif + +ifeq ($(CONFIG_TASKLET_SUPPORT), y) + ccflags-y += -DTASKLET_SUPPORT +endif + +ifeq ($(CONFIG_OPENWRT_SUPPORT), y) + ccflags-y += -DOPENWRT +endif + +ifeq ($(CONFIG_T50), y) + ccflags-y += -DT50 + ccflags-y += -DT40 + ccflags-y += -DT3T +endif + +ifeq ($(CONFIG_PCIE8897),y) + CONFIG_PCIE=y + ccflags-y += -DPCIE8897 +endif +ifeq ($(CONFIG_PCIE8997),y) + CONFIG_PCIE=y + ccflags-y += -DPCIE8997 +endif +ifeq ($(CONFIG_PCIE9097),y) + CONFIG_PCIE=y + ccflags-y += -DPCIE9097 +endif +ifeq ($(CONFIG_PCIE9098),y) + CONFIG_PCIE=y + ccflags-y += -DPCIE9098 +endif +ifeq ($(CONFIG_PCIE),y) + ccflags-y += -DPCIE +endif + +CONFIG_MAC80211_SUPPORT=n +CONFIG_MAC80211_SUPPORT_UAP=n +CONFIG_MAC80211_SUPPORT_MESH=n +ifeq ($(CONFIG_MAC80211_SUPPORT),y) + ccflags-y += -DMAC80211_SUPPORT +endif +ifeq ($(CONFIG_MAC80211_SUPPORT_UAP),y) + ccflags-y += -DMAC80211_SUPPORT_UAP +endif +ifeq ($(CONFIG_MAC80211_SUPPORT_MESH),y) + ccflags-y += -DMAC80211_SUPPORT_MESH +endif + +# add -Wno-packed-bitfield-compat when GCC version greater than 4.4 +############################################################################# +# Make Targets +############################################################################# + +ifneq ($(KERNELRELEASE),) + +ifeq ($(CONFIG_WIRELESS_EXT),y) +ifeq ($(CONFIG_WEXT_PRIV),y) + # Enable WEXT for STA + CONFIG_STA_WEXT=y + # Enable WEXT for uAP + CONFIG_UAP_WEXT=y +else +# Disable WEXT for STA + CONFIG_STA_WEXT=n +# Disable WEXT for uAP + CONFIG_UAP_WEXT=n +endif +endif + +# Enable CFG80211 for STA +ifeq ($(CONFIG_CFG80211),y) + CONFIG_STA_CFG80211=y +else +ifeq ($(CONFIG_CFG80211),m) + CONFIG_STA_CFG80211=y +else + CONFIG_STA_CFG80211=n +endif +endif + +# OpenWrt +ifeq ($(CONFIG_OPENWRT_SUPPORT), y) +ifeq ($(CPTCFG_CFG80211),y) + CONFIG_STA_CFG80211=y +else +ifeq ($(CPTCFG_CFG80211),m) + CONFIG_STA_CFG80211=y +else + CONFIG_STA_CFG80211=n +endif +endif +endif + +# Enable CFG80211 for uAP +ifeq ($(CONFIG_CFG80211),y) + CONFIG_UAP_CFG80211=y +else +ifeq ($(CONFIG_CFG80211),m) + CONFIG_UAP_CFG80211=y +else + CONFIG_UAP_CFG80211=n +endif +endif + +# OpenWrt +ifeq ($(CONFIG_OPENWRT_SUPPORT), y) +ifeq ($(CPTCFG_CFG80211),y) + CONFIG_STA_CFG80211=y +else +ifeq ($(CPTCFG_CFG80211),m) + CONFIG_STA_CFG80211=y +else + CONFIG_STA_CFG80211=n +endif +endif +endif + +ifneq ($(CONFIG_STA_SUPPORT),y) + CONFIG_WIFI_DIRECT_SUPPORT=n + CONFIG_WIFI_DISPLAY_SUPPORT=n + CONFIG_STA_WEXT=n + CONFIG_STA_CFG80211=n +endif + +ifneq ($(CONFIG_UAP_SUPPORT),y) + CONFIG_WIFI_DIRECT_SUPPORT=n + CONFIG_WIFI_DISPLAY_SUPPORT=n + CONFIG_UAP_WEXT=n + CONFIG_UAP_CFG80211=n +endif + +ifeq ($(CONFIG_STA_SUPPORT),y) +ifeq ($(CONFIG_STA_WEXT),y) + ccflags-y += -DSTA_WEXT +endif +ifeq ($(CONFIG_STA_CFG80211),y) + ccflags-y += -DSTA_CFG80211 +endif +endif +ifeq ($(CONFIG_UAP_SUPPORT),y) +ifeq ($(CONFIG_UAP_WEXT),y) + ccflags-y += -DUAP_WEXT +endif +ifeq ($(CONFIG_UAP_CFG80211),y) + ccflags-y += -DUAP_CFG80211 +endif +endif + +print: +ifeq ($(CONFIG_STA_SUPPORT),y) +ifeq ($(CONFIG_STA_WEXT),n) +ifeq ($(CONFIG_STA_CFG80211),n) + @echo "Can not build STA without WEXT or CFG80211" + exit 2 +endif +endif +endif +ifeq ($(CONFIG_UAP_SUPPORT),y) +ifeq ($(CONFIG_UAP_WEXT),n) +ifeq ($(CONFIG_UAP_CFG80211),n) + @echo "Can not build UAP without WEXT or CFG80211" + exit 2 +endif +endif +endif + + + + + +MOALOBJS = mlinux/moal_main.o \ + mlinux/moal_ioctl.o \ + mlinux/moal_shim.o \ + mlinux/moal_eth_ioctl.o \ + mlinux/moal_init.o + +MLANOBJS = mlan/mlan_shim.o mlan/mlan_init.o \ + mlan/mlan_txrx.o \ + mlan/mlan_cmdevt.o mlan/mlan_misc.o \ + mlan/mlan_cfp.o \ + mlan/mlan_module.o + +MLANOBJS += mlan/mlan_wmm.o +ifeq ($(CONFIG_PCIE),y) +MLANOBJS += mlan/mlan_pcie.o +endif +MLANOBJS += mlan/mlan_11n_aggr.o +MLANOBJS += mlan/mlan_11n_rxreorder.o +MLANOBJS += mlan/mlan_11n.o +MLANOBJS += mlan/mlan_11ac.o +MLANOBJS += mlan/mlan_11ax.o +MLANOBJS += mlan/mlan_11d.o +MLANOBJS += mlan/mlan_11h.o +ifeq ($(CONFIG_STA_SUPPORT),y) +MLANOBJS += mlan/mlan_meas.o +MLANOBJS += mlan/mlan_scan.o \ + mlan/mlan_sta_ioctl.o \ + mlan/mlan_sta_rx.o \ + mlan/mlan_sta_tx.o \ + mlan/mlan_sta_event.o \ + mlan/mlan_sta_cmd.o \ + mlan/mlan_sta_cmdresp.o \ + mlan/mlan_join.o +ifeq ($(CONFIG_STA_WEXT),y) +MOALOBJS += mlinux/moal_priv.o \ + mlinux/moal_wext.o +endif +endif +ifeq ($(CONFIG_UAP_SUPPORT),y) +MLANOBJS += mlan/mlan_uap_ioctl.o +MLANOBJS += mlan/mlan_uap_cmdevent.o +MLANOBJS += mlan/mlan_uap_txrx.o +MOALOBJS += mlinux/moal_uap.o +ifeq ($(CONFIG_UAP_WEXT),y) +MOALOBJS += mlinux/moal_uap_priv.o +MOALOBJS += mlinux/moal_uap_wext.o +endif +endif +ifeq ($(CONFIG_STA_CFG80211),y) +MOALOBJS += mlinux/moal_cfg80211.o +MOALOBJS += mlinux/moal_cfg80211_util.o +MOALOBJS += mlinux/moal_sta_cfg80211.o +endif +ifeq ($(CONFIG_UAP_CFG80211),y) +MOALOBJS += mlinux/moal_cfg80211.o +MOALOBJS += mlinux/moal_cfg80211_util.o +MOALOBJS += mlinux/moal_uap_cfg80211.o +endif + +ifdef CONFIG_PROC_FS +MOALOBJS += mlinux/moal_proc.o +MOALOBJS += mlinux/moal_debug.o +endif + +ifeq ($(CONFIG_MAC80211_SUPPORT),y) +MOALOBJS += mlinux/moal_mac80211.o +MLANOBJS += mlan/mlan_mac80211.o +endif + + + + + + + +obj-m := mlan.o +mlan-objs := $(MLANOBJS) + +ifeq ($(CONFIG_PCIE),y) +MOALOBJS += mlinux/moal_pcie.o +endif +obj-m += moal.o +moal-objs := $(MOALOBJS) + +# Otherwise we were called directly from the command line; invoke the kernel build system. +else + +default: + $(MAKE) -C $(KERNELDIR) M=$(PWD) modules + +endif + +############################################################### + +export CC LD ccflags-y KERNELDIR + +ifeq ($(CONFIG_STA_SUPPORT),y) +ifeq ($(CONFIG_UAP_SUPPORT),y) +.PHONY: mapp/mlanconfig mapp/mlan2040coex mapp/mlanevent mapp/uaputl mapp/mlanutl clean distclean +else +.PHONY: mapp/mlanconfig mapp/mlanevent mapp/mlan2040coex mapp/mlanutl mapp/mlanwls clean distclean +endif +else +ifeq ($(CONFIG_UAP_SUPPORT),y) +.PHONY: mapp/mlanevent mapp/uaputl clean distclean +endif +endif + @echo "Finished Making NXP Wlan Linux Driver" + +ifeq ($(CONFIG_STA_SUPPORT),y) +mapp/mlanconfig: + $(MAKE) -C $@ +mapp/mlanutl: + $(MAKE) -C $@ +mapp/mlan2040coex: + $(MAKE) -C $@ +endif +ifeq ($(CONFIG_UAP_SUPPORT),y) +mapp/uaputl: + $(MAKE) -C $@ +endif +ifeq ($(CONFIG_WIFI_DIRECT_SUPPORT),y) +mapp/wifidirectutl: + $(MAKE) -C $@ +endif +mapp/mlanevent: + $(MAKE) -C $@ + +echo: + +appsbuild: + + @if [ ! -d $(BINDIR) ]; then \ + mkdir $(BINDIR); \ + fi + +ifeq ($(CONFIG_STA_SUPPORT),y) + cp -f README_MLAN $(BINDIR) + cp -f README $(BINDIR) + cp -f README_RBC $(BINDIR) +ifneq ($(APPDIR),) + $(MAKE) -C mapp/mlanconfig $@ INSTALLDIR=$(BINDIR) + $(MAKE) -C mapp/mlanutl $@ INSTALLDIR=$(BINDIR) + $(MAKE) -C mapp/mlan2040coex $@ INSTALLDIR=$(BINDIR) +endif +endif +ifeq ($(CONFIG_UAP_SUPPORT),y) + cp -f README_UAP $(BINDIR) +ifneq ($(APPDIR),) + $(MAKE) -C mapp/uaputl $@ INSTALLDIR=$(BINDIR) +endif +endif +ifeq ($(CONFIG_WIFI_DIRECT_SUPPORT),y) + cp -f README_WIFIDIRECT $(BINDIR) + cp -rpf script/wifidirect $(BINDIR) +ifeq ($(CONFIG_WIFI_DISPLAY_SUPPORT),y) + cp -rpf script/wifidisplay $(BINDIR) +endif +ifneq ($(APPDIR),) + $(MAKE) -C mapp/wifidirectutl $@ INSTALLDIR=$(BINDIR) +endif +endif +ifneq ($(APPDIR),) + $(MAKE) -C mapp/mlanevent $@ INSTALLDIR=$(BINDIR) +endif + +build: echo default + + @if [ ! -d $(BINDIR) ]; then \ + mkdir $(BINDIR); \ + fi + + cp -f mlan.$(MODEXT) $(BINDIR)/mlan$(DBG).$(MODEXT) + + cp -f moal.$(MODEXT) $(BINDIR)/moal$(DBG).$(MODEXT) + cp -rpf script/load $(BINDIR)/ + cp -rpf script/unload $(BINDIR)/ + +ifeq ($(CONFIG_STA_SUPPORT),y) + cp -f README_MLAN $(BINDIR) + cp -f README $(BINDIR) + cp -f README_RBC $(BINDIR) +ifneq ($(APPDIR),) + $(MAKE) -C mapp/mlanconfig $@ INSTALLDIR=$(BINDIR) + $(MAKE) -C mapp/mlanutl $@ INSTALLDIR=$(BINDIR) + $(MAKE) -C mapp/mlan2040coex $@ INSTALLDIR=$(BINDIR) +endif +endif +ifeq ($(CONFIG_UAP_SUPPORT),y) + cp -f README_UAP $(BINDIR) +ifneq ($(APPDIR),) + $(MAKE) -C mapp/uaputl $@ INSTALLDIR=$(BINDIR) +endif +endif +ifeq ($(CONFIG_WIFI_DIRECT_SUPPORT),y) + cp -f README_WIFIDIRECT $(BINDIR) + cp -rpf script/wifidirect $(BINDIR) +ifeq ($(CONFIG_WIFI_DISPLAY_SUPPORT),y) + cp -rpf script/wifidisplay $(BINDIR) +endif +ifneq ($(APPDIR),) + $(MAKE) -C mapp/wifidirectutl $@ INSTALLDIR=$(BINDIR) +endif +endif +ifneq ($(APPDIR),) + $(MAKE) -C mapp/mlanevent $@ INSTALLDIR=$(BINDIR) +endif + +clean: + -find . -name "*.o" -exec rm {} \; + -find . -name "*.ko" -exec rm {} \; + -find . -name ".*.cmd" -exec rm {} \; + -find . -name "*.mod.c" -exec rm {} \; + -find . -name "Module.symvers" -exec rm {} \; + -find . -name "Module.markers" -exec rm {} \; + -find . -name "modules.order" -exec rm {} \; + -find . -name ".*.dwo" -exec rm {} \; + -find . -name "*dwo" -exec rm {} \; + -rm -rf .tmp_versions +ifneq ($(APPDIR),) +ifeq ($(CONFIG_STA_SUPPORT),y) + $(MAKE) -C mapp/mlanconfig $@ + $(MAKE) -C mapp/mlanutl $@ + $(MAKE) -C mapp/mlan2040coex $@ +endif +ifeq ($(CONFIG_UAP_SUPPORT),y) + $(MAKE) -C mapp/uaputl $@ +endif +ifeq ($(CONFIG_WIFI_DIRECT_SUPPORT),y) + $(MAKE) -C mapp/wifidirectutl $@ +endif + $(MAKE) -C mapp/mlanevent $@ +endif + +install: default + + cp -f mlan.$(MODEXT) $(INSTALLDIR)/mlan$(DBG).$(MODEXT) + cp -f moal.$(MODEXT) $(INSTALLDIR)/moal$(DBG).$(MODEXT) + echo $(INSTALLDIR) + echo "MX Driver Installed" + +distclean: + -find . -name "*.o" -exec rm {} \; + -find . -name "*.orig" -exec rm {} \; + -find . -name "*.swp" -exec rm {} \; + -find . -name "*.*~" -exec rm {} \; + -find . -name "*~" -exec rm {} \; + -find . -name "*.d" -exec rm {} \; + -find . -name "*.a" -exec rm {} \; + -find . -name "tags" -exec rm {} \; + -find . -name ".*" -exec rm -rf 2> /dev/null \; + -find . -name "*.ko" -exec rm {} \; + -find . -name ".*.cmd" -exec rm {} \; + -find . -name "*.mod.c" -exec rm {} \; + -find . -name ".*.dwo" -exec rm {} \; + -find . -name "*dwo" -exec rm {} \; + -rm -rf .tmp_versions +ifneq ($(APPDIR),) +ifeq ($(CONFIG_STA_SUPPORT),y) + $(MAKE) -C mapp/mlanconfig $@ + $(MAKE) -C mapp/mlanutl $@ + $(MAKE) -C mapp/mlan2040coex $@ +endif +ifeq ($(CONFIG_UAP_SUPPORT),y) + $(MAKE) -C mapp/uaputl $@ +endif +ifeq ($(CONFIG_WIFI_DIRECT_SUPPORT),y) + $(MAKE) -C mapp/wifidirectutl $@ +endif + $(MAKE) -C mapp/mlanevent $@ +endif + +# End of file diff --git a/README b/README new file mode 100644 index 0000000..454d108 --- /dev/null +++ b/README @@ -0,0 +1,528 @@ +=============================================================================== + U S E R M A N U A L + + Copyright 2008-2024 NXP + + +1) FOR DRIVER BUILD + + Goto source code directory wlan_src/. + make [clean] build + The driver and utility binaries can be found in ../bin_xxxx directory. + The driver code supports Linux kernel from 2.6.32 to 6.9.0. + +2) FOR DRIVER INSTALL + + a) Copy firmware image to /lib/firmware/nxp/, copy wifi_mod_para.conf to /lib/firmware/nxp/. + b) Install WLAN driver + There are drv_mode, max_sta_bss, max_uap_bss etc. module parameters. + The bit settings of drv_mode are, + Bit 0 : STA + Bit 1 : uAP + Bit 2 : WIFIDIRECT + Bit 4 : NAN + + max_sta_bss: Maximum number of STA BSS (default 1, max 1) + sta_name: Name of the STA interface (default: "mlan") + max_uap_bss: Maximum number of uAP BSS (default 1, max 2) + uap_name: Name of the uAP interface (default: "uap") + max_wfd_bss: Maximum number of WIFIDIRECT BSS (default 1, max 1) + wfd_name: Name of the WIFIDIRECT interface (default: "wfd") + max_vir_bss: Number of Virtual interfaces (default 0) + nan_name: Name of the NAN interface (default: "nan") + max_nan_bss: Number of NAN interfaces (default 1) + uap_oper_ctrl: uAP operation control when in-STA disconnect with ext-AP + 0: default do nothing, 2: uAP stops and restarts automatically + For example, to install multi-chip driver, + insmod mlan.ko + insmod moal.ko mod_para=nxp/wifi_mod_para.conf [drvdbg=0x7] + wifi_mod_para.conf is used to support multi-chips which has different load module parameters. It contains + the module parameters for different chips. + c) Uninstall WLAN driver, + ifconfig mlanX down + ifconfig uapX down + rmmod moal + rmmod mlan + + To load driver with MFG firmware file, use mfg_mode=1 when insmod WLAN driver and + specify MFG firmware name if needed. + + To load driver with rf_test firmware file, use rf_test_mode=1 when insmod WLAN driver. + This parameter only used for 9177(FC) + + There are some other parameters for debugging purpose etc. Use modinfo to check details. + drvdbg= + dev_cap_mask= + mac_addr=xx:xx:xx:xx:xx:xx + auto_ds=0|1|2 + ext_scan=0|1|2 + net_rx=0|1 + amsdu_deaggr=0|1 + + ps_mode=0|1|2 + tcpackenh=0|1 + sched_scan=0|1 + max_tx_buf=2048|4096|8192 + cfg_11d=0|1|2 + dts_enable=0|1 + fw_name = + e.g. copy pcieuart9098_combo_v1.bin to firmware directory, fw_name=nxp/pcieuart9098_combo_v1.bin + hw_name = + reg_work=0|1 + hw_test=0|1 + fw_serial=0|1 + req_fw_nowait=0|1 + dfs53cfg=0|1|2 + mcs32=0|1 + plinkstats=0|1|2 + Example usage: + insmod moal.ko plinkstats=0 : Disable link statistics prints + insmod moal.ko plinkstats=1 : Enable link statistics prints + insmod moal.ko plinkstats=2 : Reset link statistics prints + insmod moal.ko plinkstats=1,0x7,5,0 : Enable Num TX Packets, Num RX Packets and Channel prints on dmesg. + insmod moal.ko plinkstats=1,0xf,5,1 : Enable Num TX Packets, Num RX Packets, Channel and Region prints on dmesg, and netlink event also enabled. + Note: + 1. For more details about plinkstats parameters, refer plinkstats command details in README_MLAN file. + 2. When changing drvdbg mask dynamically while running test, set MLSTATS bit(0x800) along with the change, if wifi logging feature is enabled. + init_cfg= + e.g. copy init_cfg.conf to firmware directory, init_cfg=nxp/init_cfg.conf + cal_data_cfg= + e.g. copy cal_data.conf to firmware directory, cal_data_cfg=nxp/cal_data.conf + dpd_data_cfg= + e.g. copy dpd_data.conf to firmware directory, dpd_data_cfg=nxp/dpd_data.conf + txpwrlimit_cfg= + e.g. copy txpwrlimit_cfg_set.conf to firmware directory, txpwrlimit_cfg=nxp/txpwrlimit_cfg_set.conf + cntry_txpwr=0|1|2 + 0: Disable setting tx power table of country (default) + 1: Enable setting tx power table of country + 2: Enable setting rgpower table of country + init_hostcmd_cfg= + e.g. copy init_hostcmd_cfg.conf to firmware directory, init_hostcmd_cfg=nxp/init_hostcmd_cfg.conf + band_steer_cfg= + e.g. generate bscfg.conf by band_steer_cfg.conf, then copy bscfg.conf to firmware directory, band_steer_cfg=nxp/bscfg.conf + cfg80211_wext= + Bit 0: STA WEXT + Bit 1: uAP WEXT + Bit 2: STA CFG80211 + Bit 3: uAP CFG80211 + cfg80211_drcs=1|0 + reg_alpha2= + wq_sched_prio: Priority for work queue + wq_sched_policy: Scheduling policy for work queue + (0: SCHED_NORMAL, 1: SCHED_FIFO, 2: SCHED_RR, 3: SCHED_BATCH, 5: SCHED_IDLE) + Please note that, both wq_sched_prio and wq_sched_policy should be provided + as module parameters. If wq_sched_policy is (0, 3 or 5), then wq_sched_prio + must be 0. wq_sched_prio should be 1 to 99 otherwise. + rx_work=0|1|2 + pcie_int_mode=0|1|2 + pcie_int_mode=0|1 + ring_size=32|64|128|256|512 + low_power_mode_enable=0|1 + When low power mode is enabled, the output power will be clipped at ~+10dBm and the + expected PA current is expected to be in the 80-90 mA range for b/g/n modes + wakelock_timeout= + pmic=0|1 + indication_gpio=0xXY + hs_wake_interval= + disconnect_on_suspend=0|1 + hs_mimo_switch=0|1 + hs_auto_arp=0|1 + gtk_rekey_offload=0|1|2 + napi=0|1 + fixed_beacon_buffer=0|1 + GoAgeoutTime=0|x + multi_dtim=0|x + inact_tmo=0|x + drcs_chantime_mode=0|x + Bit31~Bit24:Channel time for channel index0; + Bit23~Bit16:mode for channel index0; 0|1 + Bit15~Bit8:Channel time for channel index1; + Bit7~Bit0:mode for channel index1; 0|1 + roamoffload_in_hs=0|1 + uap_max_sta: Maximum number of STA for UAP/GO (default 0, max 10) + host_mlme=0|1 + for supplicant/authenticator running on host side, WPA3 support is available only in host_mlme mode + for chipset 89xx FP-92, 90xx and later, host_mlme restricted to 1 + country_ie_ignore=0|1 + beacon_hints=0|1 + + chan_track=0|1 for 9098 only + keep_previous_scan=0|1, + auto_11ax=0|1, + + + Note: On some platforms (e.g. PXA910/920) double quotation marks ("") need to used + for module parameters. + insmod sdxxx.ko " ..." + +3) FOR DRIVER PROC & DEBUG + + The following info are provided in /proc/net/mwlan/adapterX/mlanY|uapY|wfdY/info, + on kernel 2.6.24 or later, the entry is /proc/mwlan/adapterX/mlanY|uapY|wfdY/info. + + driver_name = "wlan" or "uap" + driver_version = + interface_name = "mlanX", "uapX" or "wfdX" + bss_mode = "Ad-hoc" | "Managed" | "Auto" | "Unknown" + media_state = "Disconnected" | "Connected" + mac_address = <6-byte adapter MAC address> + multicase_count = // Only for STA + essid = // Only for STA + bssid = // Only for STA + channel = // Only for STA + region_code = // Only for STA + multicast_address[n] = // Only for STA + num_tx_bytes = + num_rx_bytes = + num_tx_pkts = + num_rx_pkts = + num_tx_pkts_dropped = + num_rx_pkts_dropped = + num_tx_pkts_err = + num_rx_pkts_err = + carrier "on" | "off" + tx queue "stopped" | "started" + tkip_mic_failures = 0 // Only for uAP (use of WEP/TKIP is not recommended anymore) + ccmp_decrypt_errors = 0 // Only for uAP + wep_undecryptable_count = 0 // Only for uAP (use of WEP/TKIP is not recommended anymore) + wep_icv_error_count = 0 // Only for uAP (use of WEP/TKIP is not recommended anymore) + decrypt_failure_count = 0 // Only for uAP + mcast_tx_count = 0 // Only for uAP + failed_count = 0 // Only for uAP + retry_count = 0 // Only for uAP + multiple_retry_count = 0 // Only for uAP + frame_duplicate_count = 0 // Only for uAP + rts_success_count = 0 // Only for uAP + rts_failure_count = 0 // Only for uAP + ack_failure_count = 0 // Only for uAP + rx_fragment_count = 0 // Only for uAP + mcast_rx_frame_count = 0 // Only for uAP + fcs_error_count = 0 // Only for uAP + tx_frame_count = 0 // Only for uAP + rsna_tkip_cm_invoked = 0 // Only for uAP (use of WEP/TKIP is not recommended anymore) + rsna_4way_hshk_failures = 0 // Only for uAP + + The following debug info are provided in /proc/net/mwlan/adapterX/mlanY|uapY|wfdY/debug, + on kernel 2.6.24 or later, the entry is /proc/mwlan/adapterX/mlanY|uapY|wfdY/debug. + + drvdbg = + wmm_ac_vo = + wmm_ac_vi = + wmm_ac_be = + wmm_ac_bk = + max_tx_buf_size = + tx_buf_size = + curr_tx_buf_size = + ps_mode = <0/1, CAM mode/PS mode> + ps_state = <0/1/2/3, awake state/pre-sleep state/sleep-confirm state/sleep state> + is_deep_sleep = <0/1, not deep sleep state/deep sleep state> // Only for STA + wakeup_dev_req = <0/1, wakeup device not required/required> + wakeup_tries = + hs_configured = <0/1, host sleep not configured/configured> + hs_activated = <0/1, extended host sleep not activated/activated> + tx_pkts_queued = + pps_uapsd_mode = <0/1, PPS/UAPSD mode disabled/enabled> // Only for STA + sleep_pd = // Only for STA + qos_cfg = // Only for STA + tx_lock_flag = <0/1, Tx lock flag> // Only for STA + port_open = <0/1, port open flag> // Only for STA + scan_processing = <0/1, scan processing flag> // Only for STA + num_bridge_pkts = // Only for uAP + num_drop_pkts = // Only for uAP + num_tx_timeout = + num_cmd_timeout = + timeout_cmd_id = + timeout_cmd_act = + last_cmd_id = + last_cmd_act = + last_cmd_index = <0 based last command index> + last_cmd_resp_id = + last_cmd_resp_index = <0 based last command response index> + last_event = + last_event_index = <0 based last event index> + num_cmd_h2c_fail = + num_cmd_sleep_cfm_fail = + num_tx_h2c_fail = + num_evt_deauth = // Only for STA + num_evt_disassoc = // Only for STA + num_evt_link_lost = // Only for STA + num_cmd_deauth = // Only for STA + num_cmd_assoc_ok = // Only for STA + num_cmd_assoc_fail = // Only for STA + cmd_sent = <0/1, send command resources available/sending command to device> + data_sent = <0/1, send data resources available/sending data to device> + mp_rd_bitmap = + curr_rd_port = + mp_wr_bitmap = + curr_wr_port = + txbd_rdptr = + txbd_wrptr = + rxbd_rdptr = + rxbd_wrptr = + eventbd_rdptr = + eventbd_wrptr = + cmd_resp_received = <0/1, no cmd response to process/response received and yet to process> + event_received = <0/1, no event to process/event received and yet to process> + ioctl_pending = + tx_pending = + rx_pending = + lock_count = + malloc_count = + mbufalloc_count = + malloc_cons_count = + main_state = + + Issue debug_dump command through proc. + Usage: + echo "debug_dump" > /proc/mwlan/adapterX/config + + Examples: + echo "debug_dump" > /proc/mwlan/adapterX/config # dump driver internal debug status. + To obtain fw dump or driver dump, use command: + cat /proc/mwlan/adapter0/drv_dump > file_drv_dump #save the drv dump to file_drv_dump + cat /proc/mwlan/adapter0/fw_dump > file_fw_dump #save the fw dump to file_fw_dump + cat /proc/mwlan/adapter1/drv_dump > file_drv_dump_2 #save the adapter1 drv dump to file_drv_dump_2 + To print fw dump on dmesg log, please enable 21'b bit (MFWDP_D) in drvdbg + insmod mlan.ko + insmod moal.ko mod_para=nxp/wifi_mod_para.conf [drvdbg=0x200000] + + Use dmesg or cat /var/log/debug to check driver debug messages. + To log driver debug messages to file, + a) Edit /etc/syslog.conf, add one line "*.debug /var/log/debug" + on kernel 2.6.24 or later, edit /etc/rsyslog.conf instead + b) touch /var/log/debug (if the file doesn't exist) + c) service syslog restart + on kernel 2.6.24 or later, service rsyslog restart + + Update /proc/sys/kernel/printk to change message log levels. + For example, + echo 6 > /proc/sys/kernel/printk (messages with a higher priority than 6 + will be printed to the console) + echo 15 > /proc/sys/kernel/printk (all messages will be printed to console) + +4) FOR FW RELOAD + a) Enable parallel firmware download in driver parameter + insmod sdxxx.ko fw_serial=0 + + b) default fw name for parallel firmware download + sd8887_wlan_a2.bin + + c) Trigger FW reload + echo "fw_reload=1" > /proc/mwlan/adapterX/config trigger SDIO inband firmware reset and reload firmware + echo "fw_reload=2" > /proc/mwlan/adapterX/config trigger firmware reload + echo "fw_reload=3" > /proc/mwlan/adapterX/config set firmware reload flag in driver. + echo "fw_reload=4" > /proc/mwlan/config trigger PCIe FLR and reload firmware. + echo "fw_reload=6" > /proc/mwlan/config trigger PCIe inband firmware reset and reload firmware. + + (Note: This feature will be supported on Robin3 and KF2. + For CAC-A2, it only work with the board which supports parallel fw download) + +5) FOR RF test mode commands: + + Following commands are used to perform RF testing of the wifi chipset. + Please not that these test mode commands can only be issued while the + device is in disconnected state and the uAP BSS is inactive. + Normal wifi operations cannot be used on entering RF Test Mode. + + Enter RF Test Mode: + echo "rf_test_mode=1" > /proc/mwlan/adapterX/config + + Exit RF Test Mode: + echo "rf_test_mode=0" > /proc/mwlan/adapterX/config + Please note that after exiting the RF Test Mode, the FW needs to be + reset in order to use normal wifi connectivity. + + To get the set of available RF Test Mode commands, currently set + parameters values for each command and the output, + cat /proc/mwlan/adapterX/config + + Set Radio Mode + echo "radio_mode= " + + Example: 2.4G[1x1] + echo "radio_mode=11 0" > /proc/mwlan/adapterX/config + 5G[1x1] + echo "radio_mode=3 0" > /proc/mwlan/adapterX/config + + Set Tx Antenna + For 1x1 chipsets, 1:Main, 2:Aux when antenna diversity is supported + For 2x2 chipsets, 1:Path A, 2: Path B, 3: Path A+B + Both Tx and Rx must be set to same antenna path + echo "tx_antenna=1" > /proc/mwlan/adapterX/config + + Set Rx Antenna + For 1x1 chipsets, 1:Main, 2:Aux when antenna diversity is supported + For 2x2 chipsets, 1:Path A, 2:Path B, 3:Path A+B + Both Tx and Rx must be set to same antenna path + echo "rx_antenna=1" > /proc/mwlan/adapterX/config + + Set RF band (0:2G, 1:5G) + For 2G, channel will be reset to 6, while for 5G, to channel 36 + echo "band=0" > /proc/mwlan/adapterX/config + + Set RF bandwidth (0:20MHz, 1:40MHz, 4:80MHz) + echo "bw=0" > /proc/mwlan/adapterX/config + + Set RF channel + echo "channel=6" > /proc/mwlan/adapterX/config + + Get and reset packet error rate + echo "get_and_reset_per" > /proc/mwlan/adapterX/config + + Set Tx Power + This command will set power only if caldata is already loaded in the FW. + Power (0 to 24 dBm) + Modulation (0: CCK, 1:OFDM, 2:MCS) + Path ID (0: PathA, 1:PathB, 2:PathA+B) + echo "tx_power=16 2 0" > /proc/mwlan/adapterX/config + + Set MFG HE TB Tx to configure Trigger based TX reponse + Enable Tx (0:disable, 1:enable) + Q num (0-7 : TCQs 0-7, 17-20: AXQs 0-3) + AID (Association ID as applicable) + AXQ MU Timer(to set the MU EDCA Timer for the Queue) + Tx Power (-11 to 9 dBm) + echo "he_tb_tx=1 1 5 400 10" > /proc/mwlan/adapterX/config + + Set Tx Continuous Mode + Start (0:disable, 1:enable) + Continuous Wave Mode (0:disable, 1:enable) + Payload Pattern (0 to 0xFFFFFFFF) + CS Mode (Applicable only when continuous wave is disabled) + (0:disable, 1:enable) + Active SubChannel (0:low, 1:upper, 3:both) + Tx Data Rate (Rate Index corresponding to legacy/HT/VHT rates) + + Example: To start continuous wave (tone) mode, first stop any ongoing + Tx and then start wave mode: + step1: echo "tx_continuous=0" > /proc/mwlan/adapterX/config + step2: echo "tx_continuous=1 1 0xAAA 0 3 7" > /proc/mwlan/adapterX/config + + Example: To start continuous packet mode, first stop any ongoing Tx and + then start pkt mode: + step1: echo "tx_continuous=0" > /proc/mwlan/adapterX/config + step2: echo "tx_continuous=1 0 0xAAA 0 3 7" > /proc/mwlan/adapterX/config + + stop: + echo "tx_continuous=0" > /proc/mwlan/adapterX/config + + Set Tx Frame + Start (0:disable, 1:enable) + Tx Data Rate (Rate Index corresponding to legacy/HT/VHT rates) + Payload Pattern (0 to 0xFFFFFFFF) + Payload Length (1 to 0x400) + Adjust Burst SIFS Gap (0:disable, 1:enable) + Burst SIFS in us (0 to 255us) + Short Preamble (0:disable, 1:enable) + Active SubChannel (0:low, 1:upper, 3:both) + Short GI (0:disable, 1:enable) + Adv Coding (0:disable, 1:enable) + Beamforming (0:disable, 1:enable) + GreenField Mode (0:disable, 1:enable) + STBC (0:disable, 1:enable) + Signal Bw (0: 20Mhz, 1: 40Mhz, 4:80Mhz, -1: Set to default) + NumPkt (Set to default value -1) + MaxPktExt (Set to default value -1) + BeamChange (Set to default value -1) + DCM (Set to default value -1) + Doppler (Set to default value -1) + MidamblePeriod (Set to default value -1) + QNum (Set to default value 1) + BSSID (xx:xx:xx:xx:xx:xx) + + Example: To start Tx frame with duty cycle, first stop any ongoing Tx + and then start Tx frame: + echo "tx_frame=0" > /proc/mwlan/adapterX/config + echo "tx_frame=1 7 0xAAA 0x100 1 20 0 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 05:43:3f:c4:51" > /proc/mwlan/adapterX/config + + Configure Trigger Frame + Example: To configure Trigger frame: + echo "trigger_frame=1 0 1 2 5484 0 256 0 0 2 1 0 0 0 1 60 1 0 65535 0 511 5 0 67 0 0 0 0 90 0 0 0 0" > /proc/mwlan/adapter0/config + + Example: To disable configuration of Trigger frame: + echo "trigger_frame=0" > /proc/mwlan/adapter0/config + + For more information about trigger frame configuration as per supported BW(80MHz, 40MHz and 20MHz), + Please refer : config/trigger_frame_cfg.conf + + Example : To start trigger frame transmission : + echo "rf_test_mode=1" > /proc/mwlan/adapter0/config + echo "radio_mode=3 0" > /proc/mwlan/adapterX/config + echo "bw=0" > /proc/mwlan/adapter0/config + echo "channel=36" > /proc/mwlan/adapter0/config + echo "trigger_frame=1 0 1 2 5484 0 256 0 0 0 1 0 0 0 1 60 1 0 65535 0 511 5 0 61 0 0 0 0 90 0 0 0 0" > /proc/mwlan/adapter0/config + echo "tx_frame=1 0x1102 0xabababab 200" >/proc/mwlan/adapter0/config + +6) Set host sleep parameters + + hssetpara + This command is used to set host sleep parameters. + Example: + echo "hssetpara=2 0xff 0xc8 3 400" > /proc/mwlan/adapter0/config + echo "hssetpara=2 1 0xc8 3 400 " > /proc/mwlan/adapter0/config + +7) For Antenna Diversity Command + + antcfg + This command is used to set/get the mode of Tx/Rx path. + + GET Command Format: cat /proc/mwlan/adapter0/config + SET Command Format: echo "antcfg=[m] [n] [o] [p]" > /proc/mwlan/adapter0/config + + For chip which support STREAM_2X2 + where value of m is: + Bit 0 -- Tx Path A or Tx/Rx Path A if [n] is not provided + Bit 1 -- Tx Path B or Tx/Rx Path B if [n] is not provided + Bit 0-1 -- Tx Path A+B or Tx/Rx Path A+B if [n] is not provided + For 9097/9098/IW624, LOW BYTE for 2G setting + Bit 8 -- Tx Path A or Tx/Rx Path A if [n] is not provided + Bit 9 -- Tx Path B or Tx/Rx Path B if [n] is not provided + Bit 8-9 -- Tx Path A+B or Tx/Rx Path A+B if [n] is not provided + For 9097/9098/IW624, HIGH BYTE for 5G setting + where value of n is: + Bit 0 -- Rx Path A + Bit 1 -- Rx Path B + Bit 0-1 -- Rx Path A+B + For 9097/9098/IW624, LOW BYTE for 2G setting + Bit 8 -- Rx Path A + Bit 8 -- Rx Path B + Bit 8-9 -- Rx Path A+B + For 9097/9098/IW624, HIGH BYTE for 5G setting + The Tx path setting (m) is used for both Tx and Rx if Rx path (n) is not provided. + + Examples: + cat /proc/mwlan/adapter0/config : Get Tx and Rx path + echo "antcfg=3" > /proc/mwlan/adapter0/config : Set Tx and Rx path to A+B + echo "antcfg=1 3" > /proc/mwlan/adapter0/config : Set Tx path to A and Rx path to A+B + + echo "antcfg=0x103" > /proc/mwlan/adapter0/config : Set Tx and Rx path to A+B on 2G and Tx and Rx path to A on 5G + echo "antcfg=0x103 0x103" > /proc/mwlan/adapter0/config : Set Tx path to A+B and Rx path to A+B on 2G, and Tx and Rx path to A on 5G + + echo "antcfg=0x202" > /proc/mwlan/adapter0/config : Use 5GHz path B pin for 5G TX/RX and 2GHz path B pin for 2G TX/RX + + On RD board connection is as follows : + 5GHz path A pin -> AntA + 5GHz path B pin -> AntB + 2GHz path A pin -> AntB + 2GHz path B pin -> AntA + + For chip which support SAD + where value of m is: + Bit 0 -- Tx/Rx antenna 1 + Bit 1 -- Tx/Rx antenna 2 + ... + 0xFFFF -- Tx/Rx antenna diversity + + where value of n is: + SAD evaluate time interval, only be provided when m = 0xFFFF, default value is 6s(0x1770) + + Examples: + cat /proc/mwlan/adapter0/config : Get Tx/Rx antenna mode + echo "antcfg=1" > /proc/mwlan/adapter0/config : Set Tx/Rx antenna 1 + echo "antcfg=0xFFFF" > /proc/mwlan/adapter0/config : Set Tx/Rx antenna diversity + echo "antcfg=0xFFFF 0x1770" > /proc/mwlan/adapter0/config : Set antenna evaluate time interval to 6s + + + diff --git a/README_MLAN b/README_MLAN new file mode 100644 index 0000000..cbb1784 --- /dev/null +++ b/README_MLAN @@ -0,0 +1,5325 @@ +=============================================================================== + U S E R M A N U A L + + Copyright 2008-2024 NXP + + +1) FOR DRIVER BUILD + + Goto source code directory wlan_src/. + make [clean] build + The driver and utility binaries can be found in ../bin_xxxx directory. + The driver code supports Linux kernel from 2.6.32 to 6.9.0. + +2) FOR DRIVER INSTALL + + a) Copy firmware image to /lib/firmware/nxp/, copy wifi_mod_para.conf to /lib/firmware/nxp/. + b) Install WLAN driver + There are drv_mode, max_sta_bss, max_uap_bss etc. module parameters. + The bit settings of drv_mode are, + Bit 0 : STA + Bit 1 : uAP + Bit 2 : WIFIDIRECT + Bit 4 : NAN + + max_sta_bss: Maximum number of STA BSS (default 1, max 1) + sta_name: Name of the STA interface (default: "mlan") + max_uap_bss: Maximum number of uAP BSS (default 1, max 2) + uap_name: Name of the uAP interface (default: "uap") + max_wfd_bss: Maximum number of WIFIDIRECT BSS (default 1, max 1) + wfd_name: Name of the WIFIDIRECT interface (default: "wfd") + max_vir_bss: Number of Virtual interfaces (default 0) + nan_name: Name of the NAN interface (default: "nan") + max_nan_bss: Number of NAN interfaces (default 1) + uap_oper_ctrl: uAP operation control when in-STA disconnect with ext-AP + 0: default do nothing, 2: uAP stops and restarts automatically + For example, to install multi-chip driver, + insmod mlan.ko + insmod moal.ko mod_para=nxp/wifi_mod_para.conf [drvdbg=0x7] + wifi_mod_para.conf is used to support multi-chips which has different load module parameters. It contains + the module parameters for different chips. + c) Uninstall WLAN driver, + ifconfig mlanX down + ifconfig uapX down + rmmod moal + rmmod mlan + + To load driver with MFG firmware file, use mfg_mode=1 when insmod WLAN driver and + specify MFG firmware name if needed. + + To load driver with rf_test firmware file, use rf_test_mode=1 when insmod WLAN driver. + This parameter only used for 9177(FC) + + There are some other parameters for debugging purpose etc. Use modinfo to check details. + drvdbg= + dev_cap_mask= + This load parameter is uses to configure device features support + Usage: + dev_cap_mask= + : Represents features supported + : Indicates support for 11AX + : Indicates support for 6G + Example: + To disable 11AX and 6G support: dev_cap_mask=0xfffcffff + + mac_addr=xx:xx:xx:xx:xx:xx + auto_ds=0|1|2 + ext_scan=0|1|2 + net_rx=0|1 + amsdu_deaggr=0|1 + + ps_mode=0|1|2 + tcpackenh=0|1 + sched_scan=0|1 + max_tx_buf=2048|4096|8192 + cfg_11d=0|1|2 + dts_enable=0|1 + fw_name = + e.g. copy pcieuart9098_combo_v1.bin to firmware directory, fw_name=nxp/pcieuart9098_combo_v1.bin + hw_name = + reg_work=0|1 + hw_test=0|1 + fw_serial=0|1 + req_fw_nowait=0|1 + dfs53cfg=0|1|2 + mcs32=0|1 + init_cfg= + e.g. copy init_cfg.conf to firmware directory, init_cfg=nxp/init_cfg.conf + cal_data_cfg= + e.g. copy cal_data.conf to firmware directory, cal_data_cfg=nxp/cal_data.conf + dpd_data_cfg= + e.g. copy dpd_data.conf to firmware directory, dpd_data_cfg=nxp/dpd_data.conf + txpwrlimit_cfg= + e.g. copy txpwrlimit_cfg_set.conf to firmware directory, txpwrlimit_cfg=nxp/txpwrlimit_cfg_set.conf + cntry_txpwr=0|1|2 + 0: Disable setting tx power table of country (default) + 1: Enable setting tx power table of country + 2: Enable setting rgpower table of country + init_hostcmd_cfg= + e.g. copy init_hostcmd_cfg.conf to firmware directory, init_hostcmd_cfg=nxp/init_hostcmd_cfg.conf + band_steer_cfg= + e.g. generate bscfg.conf by band_steer_cfg.conf, then copy bscfg.conf to firmware directory, band_steer_cfg=nxp/bscfg.conf + cfg80211_wext= + Bit 0: STA WEXT + Bit 1: uAP WEXT + Bit 2: STA CFG80211 + Bit 3: uAP CFG80211 + cfg80211_drcs=1|0 + reg_alpha2= + wq_sched_prio: Priority for work queue + wq_sched_policy: Scheduling policy for work queue + (0: SCHED_NORMAL, 1: SCHED_FIFO, 2: SCHED_RR, 3: SCHED_BATCH, 5: SCHED_IDLE) + Please note that, both wq_sched_prio and wq_sched_policy should be provided + as module parameters. If wq_sched_policy is (0, 3 or 5), then wq_sched_prio + must be 0. wq_sched_prio should be 1 to 99 otherwise. + rx_work=0|1|2 + pcie_int_mode=0|1|2 + pcie_int_mode=0|1 + ring_size=32|64|128|256|512 + low_power_mode_enable=0|1 + When low power mode is enabled, the output power will be clipped at ~+10dBm and the + expected PA current is expected to be in the 80-90 mA range for b/g/n modes + wakelock_timeout= + pmic=0|1 + indication_gpio=0xXY + hs_wake_interval= + disconnect_on_suspend=0|1 + hs_mimo_switch=0|1 + hs_auto_arp=0|1 + gtk_rekey_offload=0|1|2 + napi=0|1 + fixed_beacon_buffer=0|1 + GoAgeoutTime=0|x + multi_dtim=0|x + inact_tmo=0|x + drcs_chantime_mode=0|x + Bit31~Bit24:Channel time for channel index0; + Bit23~Bit16:mode for channel index0; 0|1 + Bit15~Bit8:Channel time for channel index1; + Bit7~Bit0:mode for channel index1; 0|1 + roamoffload_in_hs=0|1 + uap_max_sta: Maximum number of STA for UAP/GO (default 0, max 10) + + auto_fw_reload=0|1|3 + auto_fw_reload=0|1 + + dmcs=0|1 + + host_mlme=0|1 + for supplicant/authenticator running on host side, WPA3 support is available only in host_mlme mode + for chipset 89xx FP-92, 90xx and later, host_mlme restricted to 1 + country_ie_ignore=0|1 + beacon_hints=0|1 + edmac_ctrl=0|1 + + chan_track=0|1 for 9098 only + keep_previous_scan=0|1, + auto_11ax=0|1, + + + Note: On some platforms (e.g. PXA910/920) double quotation marks ("") need to used + for module parameters. + insmod sdxxx.ko " ..." + +3) FOR DRIVER PROC & DEBUG + + The following info are provided in /proc/net/mwlan/adapterX/mlanY|uapY|wfdY/info, + on kernel 2.6.24 or later, the entry is /proc/mwlan/adapterX/mlanY|uapY|wfdY/info. + + driver_name = "wlan" or "uap" + driver_version = + interface_name = "mlanX", "uapX" or "wfdX" + bss_mode = "Ad-hoc" | "Managed" | "Auto" | "Unknown" + media_state = "Disconnected" | "Connected" + mac_address = <6-byte adapter MAC address> + multicase_count = // Only for STA + essid = // Only for STA + bssid = // Only for STA + channel = // Only for STA + region_code = // Only for STA + multicast_address[n] = // Only for STA + num_tx_bytes = + num_rx_bytes = + num_tx_pkts = + num_rx_pkts = + num_tx_pkts_dropped = + num_rx_pkts_dropped = + num_tx_pkts_err = + num_rx_pkts_err = + carrier "on" | "off" + tx queue "stopped" | "started" + tkip_mic_failures = 0 // Only for uAP (use of WEP/TKIP is not recommended anymore) + ccmp_decrypt_errors = 0 // Only for uAP + wep_undecryptable_count = 0 // Only for uAP (use of WEP/TKIP is not recommended anymore) + wep_icv_error_count = 0 // Only for uAP (use of WEP/TKIP is not recommended anymore) + decrypt_failure_count = 0 // Only for uAP + mcast_tx_count = 0 // Only for uAP + failed_count = 0 // Only for uAP + retry_count = 0 // Only for uAP + multiple_retry_count = 0 // Only for uAP + frame_duplicate_count = 0 // Only for uAP + rts_success_count = 0 // Only for uAP + rts_failure_count = 0 // Only for uAP + ack_failure_count = 0 // Only for uAP + rx_fragment_count = 0 // Only for uAP + mcast_rx_frame_count = 0 // Only for uAP + fcs_error_count = 0 // Only for uAP + tx_frame_count = 0 // Only for uAP + rsna_tkip_cm_invoked = 0 // Only for uAP (use of WEP/TKIP is not recommended anymore) + rsna_4way_hshk_failures = 0 // Only for uAP + + The following debug info are provided in /proc/net/mwlan/adapterX/mlanY|uapY|wfdY/debug, + on kernel 2.6.24 or later, the entry is /proc/mwlan/adapterX/mlanY|uapY|wfdY/debug. + + drvdbg = + wmm_ac_vo = + wmm_ac_vi = + wmm_ac_be = + wmm_ac_bk = + max_tx_buf_size = + tx_buf_size = + curr_tx_buf_size = + ps_mode = <0/1, CAM mode/PS mode> + ps_state = <0/1/2/3, awake state/pre-sleep state/sleep-confirm state/sleep state> + is_deep_sleep = <0/1, not deep sleep state/deep sleep state> // Only for STA + wakeup_dev_req = <0/1, wakeup device not required/required> + wakeup_tries = + hs_configured = <0/1, host sleep not configured/configured> + hs_activated = <0/1, extended host sleep not activated/activated> + tx_pkts_queued = + pps_uapsd_mode = <0/1, PPS/UAPSD mode disabled/enabled> // Only for STA + sleep_pd = // Only for STA + qos_cfg = // Only for STA + tx_lock_flag = <0/1, Tx lock flag> // Only for STA + port_open = <0/1, port open flag> // Only for STA + scan_processing = <0/1, scan processing flag> // Only for STA + num_bridge_pkts = // Only for uAP + num_drop_pkts = // Only for uAP + num_tx_timeout = + num_cmd_timeout = + timeout_cmd_id = + timeout_cmd_act = + last_cmd_id = + last_cmd_act = + last_cmd_index = <0 based last command index> + last_cmd_resp_id = + last_cmd_resp_index = <0 based last command response index> + last_event = + last_event_index = <0 based last event index> + num_cmd_h2c_fail = + num_cmd_sleep_cfm_fail = + num_tx_h2c_fail = + num_evt_deauth = // Only for STA + num_evt_disassoc = // Only for STA + num_evt_link_lost = // Only for STA + num_cmd_deauth = // Only for STA + num_cmd_assoc_ok = // Only for STA + num_cmd_assoc_fail = // Only for STA + cmd_sent = <0/1, send command resources available/sending command to device> + data_sent = <0/1, send data resources available/sending data to device> + mp_rd_bitmap = + curr_rd_port = + mp_wr_bitmap = + curr_wr_port = + txbd_rdptr = + txbd_wrptr = + rxbd_rdptr = + rxbd_wrptr = + eventbd_rdptr = + eventbd_wrptr = + cmd_resp_received = <0/1, no cmd response to process/response received and yet to process> + event_received = <0/1, no event to process/event received and yet to process> + ioctl_pending = + tx_pending = + rx_pending = + lock_count = + malloc_count = + mbufalloc_count = + malloc_cons_count = + main_state = + + Issue debug_dump command through proc. + Usage: + echo "debug_dump" > /proc/mwlan/adapterX/config + + Examples: + echo "debug_dump" > /proc/mwlan/adapterX/config # dump driver internal debug status. + To obtain fw dump or driver dump, use command: + cat /proc/mwlan/adapter0/drv_dump > file_drv_dump #save the drv dump to file_drv_dump + cat /proc/mwlan/adapter0/fw_dump > file_fw_dump #save the fw dump to file_fw_dump + cat /proc/mwlan/adapter1/drv_dump > file_drv_dump_2 #save the adapter1 drv dump to file_drv_dump_2 + To print fw dump on dmesg log, please enable 21'b bit (MFWDP_D) in drvdbg + insmod mlan.ko + insmod moal.ko mod_para=nxp/wifi_mod_para.conf [drvdbg=0x200000] + + Use dmesg or cat /var/log/debug to check driver debug messages. + To log driver debug messages to file, + a) Edit /etc/syslog.conf, add one line "*.debug /var/log/debug" + on kernel 2.6.24 or later, edit /etc/rsyslog.conf instead + b) touch /var/log/debug (if the file doesn't exist) + c) service syslog restart + on kernel 2.6.24 or later, service rsyslog restart + + Update /proc/sys/kernel/printk to change message log levels. + For example, + echo 6 > /proc/sys/kernel/printk (messages with a higher priority than 6 + will be printed to the console) + echo 15 > /proc/sys/kernel/printk (all messages will be printed to console) + +4) FOR FW RELOAD + a) Enable parallel firmware download in driver parameter + insmod sdxxx.ko fw_serial=0 + + b) default fw name for parallel firmware download + sd8887_wlan_a2.bin + + c) Trigger FW reload + echo "fw_reload=1" > /proc/mwlan/adapterX/config trigger SDIO inband firmware reset and reload firmware + echo "fw_reload=2" > /proc/mwlan/adapterX/config trigger firmware reload + echo "fw_reload=3" > /proc/mwlan/adapterX/config set firmware reload flag in driver. + echo "fw_reload=4" > /proc/mwlan/config trigger PCIe FLR and reload firmware. + echo "fw_reload=6" > /proc/mwlan/config trigger PCIe inband firmware reset and reload firmware. + + (Note: This feature will be supported on Robin3 and KF2. + For CAC-A2, it only work with the board which supports parallel fw download) + +5) FOR RF test mode commands: + + Following commands are used to perform RF testing of the wifi chipset. + Please not that these test mode commands can only be issued while the + device is in disconnected state and the uAP BSS is inactive. + Normal wifi operations cannot be used on entering RF Test Mode. + + Enter RF Test Mode: + echo "rf_test_mode=1" > /proc/mwlan/adapterX/config + + Exit RF Test Mode: + echo "rf_test_mode=0" > /proc/mwlan/adapterX/config + Please note that after exiting the RF Test Mode, the FW needs to be + reset in order to use normal wifi connectivity. + + To get the set of available RF Test Mode commands, currently set + parameters values for each command and the output, + cat /proc/mwlan/adapterX/config + + Set Radio Mode + echo "radio_mode= " + + Example: 2.4G[1x1] + echo "radio_mode=11 0" > /proc/mwlan/adapterX/config + 5G[1x1] + echo "radio_mode=3 0" > /proc/mwlan/adapterX/config + + Set Tx Antenna + For 1x1 chipsets, 1:Main, 2:Aux when antenna diversity is supported + For 2x2 chipsets, 1:Path A, 2: Path B, 3: Path A+B + Both Tx and Rx must be set to same antenna path + echo "tx_antenna=1" > /proc/mwlan/adapterX/config + + Set Rx Antenna + For 1x1 chipsets, 1:Main, 2:Aux when antenna diversity is supported + For 2x2 chipsets, 1:Path A, 2:Path B, 3:Path A+B + Both Tx and Rx must be set to same antenna path + echo "rx_antenna=1" > /proc/mwlan/adapterX/config + + Set RF band (0:2G, 1:5G) + For 2G, channel will be reset to 6, while for 5G, to channel 36 + echo "band=0" > /proc/mwlan/adapterX/config + + Set RF bandwidth (0:20MHz, 1:40MHz, 4:80MHz) + echo "bw=0" > /proc/mwlan/adapterX/config + + Set RF channel + echo "channel=6" > /proc/mwlan/adapterX/config + + Get and reset packet error rate + echo "get_and_reset_per" > /proc/mwlan/adapterX/config + + Set Tx Power + This command will set power only if caldata is already loaded in the FW. + Power (0 to 24 dBm) + Modulation (0: CCK, 1:OFDM, 2:MCS) + Path ID (0: PathA, 1:PathB, 2:PathA+B) + echo "tx_power=16 2 0" > /proc/mwlan/adapterX/config + + Set MFG HE TB Tx to configure Trigger based TX reponse + Enable Tx (0:disable, 1:enable) + Q num (0-7 : TCQs 0-7, 17-20: AXQs 0-3) + AID (Association ID as applicable) + AXQ MU Timer(to set the MU EDCA Timer for the Queue) + Tx Power (-11 to 9 dBm) + echo "he_tb_tx=1 1 5 400 10" > /proc/mwlan/adapterX/config + + Set Tx Continuous Mode + Start (0:disable, 1:enable) + Continuous Wave Mode (0:disable, 1:enable) + Payload Pattern (0 to 0xFFFFFFFF) + CS Mode (Applicable only when continuous wave is disabled) + (0:disable, 1:enable) + Active SubChannel (0:low, 1:upper, 3:both) + Tx Data Rate (Rate Index corresponding to legacy/HT/VHT rates) + + Example: To start continuous wave (tone) mode, first stop any ongoing + Tx and then start wave mode: + step1: echo "tx_continuous=0" > /proc/mwlan/adapterX/config + step2: echo "tx_continuous=1 1 0xAAA 0 3 7" > /proc/mwlan/adapterX/config + + Example: To start continuous packet mode, first stop any ongoing Tx and + then start pkt mode: + step1: echo "tx_continuous=0" > /proc/mwlan/adapterX/config + step2: echo "tx_continuous=1 0 0xAAA 0 3 7" > /proc/mwlan/adapterX/config + + stop: + echo "tx_continuous=0" > /proc/mwlan/adapterX/config + + Set Tx Frame + Start (0:disable, 1:enable) + Tx Data Rate (Rate Index corresponding to legacy/HT/VHT rates) + Payload Pattern (0 to 0xFFFFFFFF) + Payload Length (1 to 0x400) + Adjust Burst SIFS Gap (0:disable, 1:enable) + Burst SIFS in us (0 to 255us) + Short Preamble (0:disable, 1:enable) + Active SubChannel (0:low, 1:upper, 3:both) + Short GI (0:disable, 1:enable) + Adv Coding (0:disable, 1:enable) + Beamforming (0:disable, 1:enable) + GreenField Mode (0:disable, 1:enable) + STBC (0:disable, 1:enable) + Signal Bw (0: 20Mhz, 1: 40Mhz, 4:80Mhz, -1: Set to default) + NumPkt (Set to default value -1) + MaxPktExt (Set to default value -1) + BeamChange (Set to default value -1) + DCM (Set to default value -1) + Doppler (Set to default value -1) + MidamblePeriod (Set to default value -1) + QNum (Set to default value 1) + BSSID (xx:xx:xx:xx:xx:xx) + + Example: To start Tx frame with duty cycle, first stop any ongoing Tx + and then start Tx frame: + echo "tx_frame=0" > /proc/mwlan/adapterX/config + echo "tx_frame=1 7 0xAAA 0x100 1 20 0 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 05:43:3f:c4:51" > /proc/mwlan/adapterX/config + + Configure Trigger Frame + Example: To configure Trigger frame: + echo "trigger_frame=1 0 1 2 5484 0 256 0 0 2 1 0 0 0 1 60 1 0 65535 0 511 5 0 67 0 0 0 0 90 0 0 0 0" > /proc/mwlan/adapter0/config + + Example: To disable configuration of Trigger frame: + echo "trigger_frame=0" > /proc/mwlan/adapter0/config + + For more information about trigger frame configuration as per supported BW(80MHz, 40MHz and 20MHz), + Please refer : config/trigger_frame_cfg.conf + + Example : To start trigger frame transmission : + echo "rf_test_mode=1" > /proc/mwlan/adapter0/config + echo "radio_mode=3 0" > /proc/mwlan/adapterX/config + echo "bw=0" > /proc/mwlan/adapter0/config + echo "channel=36" > /proc/mwlan/adapter0/config + echo "trigger_frame=1 0 1 2 5484 0 256 0 0 0 1 0 0 0 1 60 1 0 65535 0 511 5 0 61 0 0 0 0 90 0 0 0 0" > /proc/mwlan/adapter0/config + echo "tx_frame=1 0x1102 0xabababab 200" >/proc/mwlan/adapter0/config + +6) Set host sleep parameters + + hssetpara + This command is used to set host sleep parameters. + Example: + echo "hssetpara=2 0xff 0xc8 3 400" > /proc/mwlan/adapter0/config + echo "hssetpara=2 1 0xc8 3 400 " > /proc/mwlan/adapter0/config + +7) For Antenna Diversity Command + + antcfg + This command is used to set/get the mode of Tx/Rx path. + + GET Command Format: cat /proc/mwlan/adapter0/config + SET Command Format: echo "antcfg=[m] [n] [o] [p]" > /proc/mwlan/adapter0/config + + For chip which support STREAM_2X2 + where value of m is: + Bit 0 -- Tx Path A or Tx/Rx Path A if [n] is not provided + Bit 1 -- Tx Path B or Tx/Rx Path B if [n] is not provided + Bit 0-1 -- Tx Path A+B or Tx/Rx Path A+B if [n] is not provided + For 9097/9098/IW624, LOW BYTE for 2G setting + Bit 8 -- Tx Path A or Tx/Rx Path A if [n] is not provided + Bit 9 -- Tx Path B or Tx/Rx Path B if [n] is not provided + Bit 8-9 -- Tx Path A+B or Tx/Rx Path A+B if [n] is not provided + For 9097/9098/IW624, HIGH BYTE for 5G setting + where value of n is: + Bit 0 -- Rx Path A + Bit 1 -- Rx Path B + Bit 0-1 -- Rx Path A+B + For 9097/9098/IW624, LOW BYTE for 2G setting + Bit 8 -- Rx Path A + Bit 8 -- Rx Path B + Bit 8-9 -- Rx Path A+B + For 9097/9098/IW624, HIGH BYTE for 5G setting + The Tx path setting (m) is used for both Tx and Rx if Rx path (n) is not provided. + + Examples: + cat /proc/mwlan/adapter0/config : Get Tx and Rx path + echo "antcfg=3" > /proc/mwlan/adapter0/config : Set Tx and Rx path to A+B + echo "antcfg=1 3" > /proc/mwlan/adapter0/config : Set Tx path to A and Rx path to A+B + + echo "antcfg=0x103" > /proc/mwlan/adapter0/config : Set Tx and Rx path to A+B on 2G and Tx and Rx path to A on 5G + echo "antcfg=0x103 0x103" > /proc/mwlan/adapter0/config : Set Tx path to A+B and Rx path to A+B on 2G, and Tx and Rx path to A on 5G + + echo "antcfg=0x202" > /proc/mwlan/adapter0/config : Use 5GHz path B pin for 5G TX/RX and 2GHz path B pin for 2G TX/RX + + On RD board connection is as follows : + 5GHz path A pin -> AntA + 5GHz path B pin -> AntB + 2GHz path A pin -> AntB + 2GHz path B pin -> AntA + + For chip which support SAD + where value of m is: + Bit 0 -- Tx/Rx antenna 1 + Bit 1 -- Tx/Rx antenna 2 + ... + 0xFFFF -- Tx/Rx antenna diversity + + where value of n is: + SAD evaluate time interval, only be provided when m = 0xFFFF, default value is 6s(0x1770) + + Examples: + cat /proc/mwlan/adapter0/config : Get Tx/Rx antenna mode + echo "antcfg=1" > /proc/mwlan/adapter0/config : Set Tx/Rx antenna 1 + echo "antcfg=0xFFFF" > /proc/mwlan/adapter0/config : Set Tx/Rx antenna diversity + echo "antcfg=0xFFFF 0x1770" > /proc/mwlan/adapter0/config : Set antenna evaluate time interval to 6s + + + +=============================================================================== + U S E R M A N U A L F O R MLANUTL + +NAME + mlanutl - configure the additional parameters available for NXP mdriver. + +SYNOPSIS + mlanutl -v + mlanutl [parameters] ... + + mlanutl mlanX verext + mlanutl mlanX version + mlanutl mlanX hostcmd generate_raw + mlanutl mlanX hostcmd send_om_set + mlanutl mlanX getdatarate + mlanutl uapX getdatarate + mlanutl mlanX drvdbg [n] + mlanutl mlanX getlog + mlanutl mlanX getsignal [m] [n] + mlanutl mlanX signalextcfg [m] + mlanutl mlanX getsignalextv2 [m] + mlanutl mlanX getsignalext [m] + mlanutl mlanX get_txpwrlimit [raw_data_file] + mlanutl mlanX aggrpriotbl [ ... ] + mlanutl uapX aggrpriotbl [ ... ] + mlanutl mlanX addbapara [

] + mlanutl uapX addbapara [

] + mlanutl mlanX addbareject [ ... ] + mlanutl uapX addbareject [ ... ] + mlanutl mlanX dyn_bw [n] + mlanutl mlanX vhtcfg [l] [m] [n] [o] + mlanutl uapX vhtcfg [l] [m] [n] [o] + mlanutl mlanX httxcfg [] [] + mlanutl mlanX htcapinfo [] [] + mlanutl mlanX 11axcfg [config/11axcfg.conf] + mlanutl mlanX 11axcmd + mlanutl mlanX txratecfg [l] [m] [n] [o] + mlanutl uapX txratecfg [l] [m] [n] [o] + mlanutl mlanX txwatchdog [l] + mlanutl uapX txwatchdog [l] + mlanutl mlanX hssetpara condition [GPIO# [gap]] [ind_GPIO# [level]] + mlanutl mlanX mefcfg + mlanutl mlanX min_ba_threshold + mlanutl mlanX 11dcfg + mlanutl mlanX 11dclrtbl + mlanutl mlanX addts + mlanutl mlanX amsduaggrctrl + mlanutl mlanX antcfg [m] [n] + mlanutl mlanX/uapX mimoswitch [tx_antmode] [rx_antmode] + mlanutl mlanX arpfilter + mlanutl mlanX assocessid <"[essid]"> + mlanutl mlanX assocessid_bssid <"[bssid] [essid]"> + mlanutl mlanX associate " " + mlanutl mlanX get_chnrgpwr [save_region_channel_power_data_file] + mlanutl mlanX comparergpwr [target_file] + mlanutl mlanX comparetrpc [display] + mlanutl mlanX getcfgchanlist + mlanutl mlanX authtype [n] + mlanutl mlanX autotdls [n] + mlanutl mlanX tdls_idle_time [n] + mlanutl uapX dfs_offload [n] + mlanutl mlanX bandcfg [l] [m] [n] + mlanutl mlanX bcninterval [n] + mlanutl wfdX bssrole [l] + mlanutl mlanX cfgdata [] + mlanutl mlanX cfpcode [m] [n] + mlanutl mlanX changraph [ ] + mlanutl mlanX coex_rx_winsize [m] + mlanutl mlanX countrycode [l] + + mlanutl mlanX cfpinfo + mlanutl uapX cfpinfo + + mlanutl mlanX customie [[[] ] ] + mlanutl mlanX deauth [l] + mlanutl uapX deauth [l] + mlanutl mlanX deepsleep [l] [m] + mlanutl mlanX flush_time [l] [m] + mlanutl mlanX delba [ ] + mlanutl uapX delba [ ] + mlanutl mlanX delts + mlanutl mlanX dfstesting [ ] + mlanutl uapX clear_nop + mlanutl uapX nop_list + mlanutl uapX fake_radar + mlanutl uapX getchload + mlanutl dfsX dfs_cac [ ] + mlanutl dfsX autodfs [conf_file] + mlanutl mlanX dfs_repeater [n] + mlanutl mlanX dfs53cfg [n] + mlanutl uapX dfs_mode [n] + mlanutl mlanX esuppmode [l] [m] [n] + mlanutl mlanX extcapcfg [] + mlanutl mlanX fwmacaddr [mac_addr] + mlanutl mlanX getkey + mlanutl mlanX getscantable [ARGS] + mlanutl uapX getstalist + mlanutl uapX channel_switch + mlanutl uapX setmode + mlanutl mlanX hostcmd <11n_2040coex.conf> 2040coex + mlanutl mlanX hostcmd auto_tx_get + mlanutl mlanX hostcmd auto_tx_unreg + mlanutl mlanX hostcmd bgscfg + mlanutl mlanX hostcmd bgs_query + + mlanutl mlanX hostcmd coalesce_cfg + mlanutl mlanX hostcmd ed_mac_ctrl + mlanutl mlanX hostcmd crypto_test + mlanutl mlanX hostcmd nat_keep_alive + mlanutl mlanX hostcmd pad_cfg_get + mlanutl mlanX hostcmd pad_cfg_set + mlanutl mlanX hostcmd requesttpc + mlanutl mlanX hostcmd mode_get + mlanutl mlanX hostcmd mode_timeshare + mlanutl mlanX hostcmd mode_spatial + mlanutl mlanX hostcmd mode_none + mlanutl mlanX hostcmd mode_bca + mlanutl mlanX hostcmd gpio_cfg + mlanutl mlanX hostcmd external_coex_config + mlanutl mlanX hostcmd external_coex_pta_config + mlanutl mlanX hostcmd external_coex_uart_config + mlanutl mlanX hostcmd generictime + mlanutl mlanX hostcmd a2dptime + mlanutl mlanX hostcmd inquirytim + mlanutl mlanX hostcmd ap_generictime + mlanutl mlanX hostcmd ap_a2dptime + mlanutl mlanX hostcmd ap_inquirytime + mlanutl mlanX hostcmd subevent_get + mlanutl mlanX hostcmd subevent_set + mlanutl mlanX hostcmd txpwrlimit_2g_cfg_set + mlanutl mlanX hostcmd txpwrlimit_5g_cfg_set + mlanutl mlanX hostcmd txpwrlimit_cfg_get + mlanutl mlanX hostcmd txrate_cfg_get + mlanutl mlanX hostcmd txrate_cfg_set_bg + mlanutl mlanX hostcmd txrate_cfg_set_bgn + mlanutl mlanX hostcmd generate_raw + mlanutl mlanX hostcmd fwdump + + mlanutl mlanX hostcmd stop_su + mlanutl mlanX hostcmd start_su + + mlanutl mlanX hotspotcfg [] + mlanutl mlanX hscfg [condition [[GPIO# [gap]]]] [ind_GPIO# [level]] + mlanutl mlanX mgmtfilter + mlanutl mlanX auto_arp [n] + mlanutl mlanX htstreamcfg [n] + mlanutl mlanX httxbfcap [cap] + mlanutl mlanX httxbfcfg "[;GlobalData/tsData/interval/txPeerData/snrData]" + mlanutl mlanX inactivityto [k][j] + mlanutl mlanX ipaddr [";"] + mlanutl mlanX linkstats + mlanutl uapX plinkstats + mlanutl mlanX listeninterval [l] + mlanutl mlanX macctrl [n] + mlanutl uapX macctrl [n] + mlanutl mlanX memrdwr

[value] + mlanutl mlanX miracastcfg [l] [m] [n] + mlanutl mlanX mgmtframectrl [] + mlanutl uapX mgmtframectrl [] + mlanutl mlanX mgmtframetx + mlanutl mlanX netmon [ [ ]] + mlanutl mlanX offchannel [ ] + mlanutl mlanX otpuserdata + mlanutl mlanX passphrase [l] + mlanutl mlanX pb_bypass [data_1, data_2, ... data_n] + mlanutl mlanX pcieregrw [value] + mlanutl mlanX pciebar0regrw [value] + mlanutl mlanX pmfcfg + mlanutl mlanX port_ctrl [n] + mlanutl mlanX powercons [n] + mlanutl mlanX pscfg [k] [d] [l] ... + mlanutl mlanX bcntimeoutcfg [l] [m] [o] [p] + mlanutl mlanX psmode [l] + + mlanutl robustcoex [Enable/Disable] [gpionum] [gpiopolarity] + mlanutl mlanX qconfig def [Queue Id: 0-3] + mlanutl mlanX qconfig get [Queue Id: 0-3] + mlanutl mlanX qconfig set msdu [Queue Id: 0-3] + mlanutl mlanX qoscfg + mlanutl mlanX qstatus + mlanutl mlanX radioctrl [n] + mlanutl mlanX rdeeprom + mlanutl mlanX reassoctrl [n] + mlanutl mlanX regioncode [n] + mlanutl mlanX regrdwr [value] + mlanutl mlanX rejectaddbareq [conditions] + mlanutl uapX rejectaddbareq [conditions] + mlanutl mlanX scancfg [t] [m] [p] [s] [a] [b] [c] [ext] [gap] + mlanutl mlanX setuserscan [ARGS] + mlanutl mlanX cancelscan + mlanutl mlanX sleepparams [ ] + mlanutl mlanX sleeppd [n] + mlanutl mlanX sysclock [clk1] [clk2] [clk3] [clk4] + mlanutl mlanX tcpackenh [l] [m] + mlanutl mlanX tdls_channel_switch + mlanutl mlanX tdls_config <0/1> + mlanutl mlanX tdls_cs_params + mlanutl mlanX tdls_debug "allow_weak_security" <0/1> + mlanutl mlanX tdls_debug "cs_im_return" <0/1> + mlanutl mlanX tdls_debug "fail_setup_confirm" <0/1> + mlanutl mlanX tdls_debug "higher_lower_mac" <0/1> + mlanutl mlanX tdls_debug "ignore_key_expiry" <0/1> + mlanutl mlanX tdls_debug "setup_existing_link" <0/1> + mlanutl mlanX tdls_debug "setup_with_prohibited" <0/1> + mlanutl mlanX tdls_debug "stop_rx" <0/1> + mlanutl mlanX tdls_debug "wrong_bss" <0/1> + mlanutl mlanX tdls_disable_cs <0/1> + mlanutl mlanX tdls_discovery + mlanutl mlanX tdls_link_status + mlanutl mlanX tdls_powermode + mlanutl mlanX tdls_setinfo + mlanutl mlanX tdls_setup + mlanutl mlanX tdls_stop_channel_switch + mlanutl mlanX tdls_teardown + mlanutl mlanX thermal + mlanutl mlanX ts_status + mlanutl mlanX tsf + mlanutl mlanX txaggrctrl [m] + mlanutl mlanX txbufcfg + mlanutl per_pkt_cfg [tx_rx_control] [type_num] [ether_type1 ether_type2 ...] [tx_rx_control] [type_num] [ether_type1 ether_type2 ...] + mlanutl dot11_txrx + mlanutl mlanX txrxhistogram [action] [tx_rx_statics] + mlanutl uapX txrxhistogram [action] [tx_rx_statics] + mlanutl mlanX wakeupreason + mlanutl uapX wakeupreason + mlanutl mlanX warmreset + mlanutl mlanX wpssession [n] + mlanutl mlanX wmmcfg [n] + mlanutl mlanX wmmparamcfg [AC_BE AIFSN ECW_MAX ECW_MIN TX_OP] + [AC_BK AIFSN ECW_MAX ECW_MIN TX_OP] + [AC_VI AIFSN ECW_MAX ECW_MIN TX_OP] + [AC_VO AIFSN ECW_MAX ECW_MIN TX_OP] + mlanutl mlanX wwscfg [m] + mlanutl mlanX mc_cfg [n] + mlanutl mlanX mc_policy [n] + mlanutl mlanX mc_cfg_ext [c] [s] [u] [m] + mlanutl p2pX cfg_noa [h] [i] [j] [k] [l] + mlanutl p2pX cfg_opp_ps [m] [n] + mlanutl mlanX get_sensor_temp + mlanutl mlanX 11k_enable [n] + mlanutl mlanX neighbor_report + mlanutl indrstcfg [gpio_pin] + + + mlanutl uapX/mlanX ctrldeauth + + mlanutl mlanX/uapX bootsleep <1/0> + + mlanutl mlanX ssu [mode] [ssu file] + + mlanutl mlanX csi + + mlanutl mlanX arb [mode] + + mlanutl mlanX dmcs [value] + + mlanutl mlanX/uapX range_ext [mode] + mlanutl mlanX twt_setup [config/twt.conf] + mlanutl mlanX twt_teardown [config/twt.conf] + mlanutl mlanX twt_report + mlanutl rx_abort_cfg [enable] [rssi_threshold] + mlanutl ofdm_desense_cfg [enable] [cca_threshold](Only for IW416) + mlanutl rx_abort_cfg_ext [enable] [margin ceil_thresh] + mlanutl nav_mitigation [start_nav_mitigation] [threshold] + mlanutl tx_ampdu_prot_mode [mode] + mlanutl rate_adapt_cfg [low_thresh high_thresh timer_interval] + mlanutl cck_desense_cfg [mode] [margin ceil_thresh] [num_on_intervals num_off_intervals] + mlanutl mlanX/uapX lpm [mode] + mlanutl dot11mc_unassoc_ftm_cfg [enable] + mlanutl mlanX/uapX clocksync [j][k] [l] [m] [n] + mlanutl mlanX/uapX gettsfinfo [j] + mlanutl uapX backupchan [j] + mlanutl uapX targetchan [j] + mlanutl mlanX ips_cfg [1/0] + mlanutl mlanX ftm [] + mlanutl mlanX/uapX turbo_mode + mlanutl getuuid + mlanutl uapX crosssynch [j][k] [l] [m] [n] + mlanutl mlanX/uapX wlan_tsp_cfg [j] [k] [l] [m] [n] [o] [p] [q] + mlanutl led m + mlanutl mlanX auth_assoc_timeout_cfg + mlanutl uapX agcs [ARGS] + +DESCRIPTION + Those commands are used to send additional commands to the NXP MLAN + card via the Linux device driver. + + The mlanX parameter specifies the network device that is to be used to + perform this command on. It could be mlan0, mlan1 etc. + +verext + Retrieve and display an extended version string from the firmware + + Usage: + mlanutl mlanX verext [#] + + where [#] is an optional argument to retrieve a specific version string, + omission of the argument retrieves the 0 indexed string. + +version + This is used to get the current version of the driver and the firmware. + +drvdbg + This command is used to set/get the bit masks of driver debug message control. + + Usage: + mlanutl mlanX drvdbg [n] + + Where the parameter is the generic debug message control bit mask. + The following types of driver debug messages can be dynamically enabled or + disabled by setting or clearing the corresponding bits, + bit 0: MMSG PRINTM(MMSG,...) + bit 1: MFATAL PRINTM(MFATAL,...) + bit 2: MERROR PRINTM(MERROR,...) + bit 3: MDATA PRINTM(MDATA,...) + bit 4: MCMND PRINTM(MCMND,...) + bit 5: MEVENT PRINTM(MEVENT,...) + bit 6: MINTR PRINTM(MINTR,...) + bit 7: MIOCTL PRINTM(MIOCTL,...) + bit 9: MREG_D PRINTM(MREG_D,...) + bit 10: MREG PRINTM(MREG,...) + bit 11: MLSTATS PRINTM(MLSTATS,...) + ... + bit 16: MDAT_D PRINTM(MDAT_D,...), DBG_HEXDUMP(MDAT_D,...) + bit 17: MCMD_D PRINTM(MCMD_D,...), DBG_HEXDUMP(MCMD_D,...) + bit 18: MEVT_D PRINTM(MEVT_D,...), DBG_HEXDUMP(MEVT_D,...) + bit 19: MFW_D PRINTM(MFW_D,...), DBG_HEXDUMP(MFW_D,...) + bit 20: MIF_D PRINTM(MIF_D,...), DBG_HEXDUMP(MIF_D,...) + ... + bit 28: MENTRY PRINTM(MENTRY,...), ENTER(), LEAVE() + bit 29: MWARN PRINTM(MWARN,...) + bit 30: MINFO PRINTM(MINFO,...) + + If CONFIG_DEBUG=2, all kinds of debug messages can be configured. + + If CONFIG_DEBUG=1, all kinds of debug messages can be configured except + for MENTRY, MWARN and MINFO. By default MMSG, MFATAL, MERROR and MREG_D are enabled. + + Some special debug messages, + '*' // MLAN driver ISR is called (bit 6 MINTR enabled) + '|' // PS awake event is received (bit 5 MEVENT enabled) + '_' // PS sleep event is received (bit 5 MEVENT enabled) + '+' // PS sleep confirm is sent (bit 5 MEVENT enabled) + + Examples: + mlanutl mlan0 drvdbg : Get the current driver debug masks + mlanutl mlan0 drvdbg 0 : Disable all the debug messages + mlanutl mlan0 drvdbg 7 : Enable MMSG, MFATAL and MERROR messages + mlanutl mlan0 drvdbg 0x20037 : Enable MMSG, MFATAL, MEEROR, + MCMND, MEVENT and MCMD_D messages + mlanutl mlan0 drvdbg -1 : Enable all the debug messages + +hostcmd generate_raw + This command is used to generate the raw data(hostcommand block) for + hostcommand in and write that to file + + Usage: + mlanutl mlanX hostcmd generate_raw + +hostcmd send_om_set + This command is used to configure the STAUT to include OM control subfield + + Usage: + mlanutl mlanX hostcmd send_om_set + +getdatarate + This command is used to get the data rate being used in last Tx + packet and last Rx packet. + +getlog + This command is used to get the statistics available in the station. + Following stats are displayed:- + dot11MulticastTransmittedFrameCount Increments when the multicast bit is set in the destination + MAC address of a successfully transmitted MSDU + + dot11FailedCount Increments when an MSDU is not transmitted successfully + + dot11RetryCount Increments when an MSDU is successfully transmitted after one + or more retransmissions + + dot11MultipleRetryCount Increments when an MSDU is successfully transmitted after more + than one retransmission + + dot11FrameDuplicateCount Increments when a frame is received that the Sequence Control + field is indicating a duplicate count + + dot11RTSSuccessCount Increments when a CTS is received in response to an RTS + + dot11RTSFailureCount Increments when a CTS is not received in response to an RTS + + dot11ACKFaliureCount Increments when an ACK is not received when expected + + dot11ReceivedFragmentCount Increments for each successfully received MPDU of type Data or Management + + dot11MulticastReceivedFrameCount Increments when a MSDU is received with the multicast bit set in the destination MAC address + + dot11FCSErrorCount Increments when an FCS error is detected in a received MPDU + + dot11TransmittedFrameCount Increments for each successfully transmitted MSDU + + dot11WeplcvErrCnt Increment when WEP (use of WEP/TKIP is not recommended anymore)decryption error for key index 0.3 + + beaconReceivedCnt Increments when received beacon + + beaconMissedCnt Increments when beacon missed + + dot11TransmittedFrameCount Increments for each successfully transmitted MSDU + + dot11QosTransmittedFragmentCount Increments when a corresponding UP's MPDU transmitted successfully + + dot11QosFailedCount Increments when a corresponding UP's MSDU not transmitted successfully + + dot11QosRetryCount Increment when a corresponding UP's MSDU transmitted successfully after one or more retransmission + + dot11QosMultipleRetryCount Increments when a corresponding UP's MSDU is successfully transmitted after more than one retransmission + + dot11QosFrameDuplicateCount Increments when a corresponding UP's frame is received that the Sequence + Control field is indicating a duplicate frame + + dot11QosRTSSuccessCount Increments when a CTS is received in response to an RTS, which is sent for a corresponding UP's Qos frame + + dot11QosRTSFailureCount Increments when a CTS is not received in response to an RTS, which is sent for a corresponding UP's + Qos frame + + dot11QosACKFailureCount Increments when an ACK is not received when expected for a corresponding UP's Qos frame + + dot11QosReceivedFragmentCount Increments when a corresponding UP's MPDU received + + dot11QosTransmittedFrameCount Increments when a corresponding UP's MSDU transmitted + + dot11QosDiscardedFrameCount Increments when a corresponding UP's MSDU not transmitted successfully + + dot11QosMPDUsReceivedCount Increments when a corresponding UP's MDPU received + + + dot11QosRetriesReceivedCount Increments when a corresponding UP's MDPU received which retry bit is set + + dot11RSNAStatsCMACICVErrors Increment when a MPDU discard by CMAC integrity check + + dot11RSNAStatsCMACReplays Increments when a MPDU discarded by the CMAC replay error + + dot11RSNAStatsRobustMgmtCCMPReplays Increments when a robust management frame discarded by CCMP replay error + + dot11RSNAStatsTKIPICVErrors Increments when a MPDU discarded by TKIP ICV error //(use of WEP/TKIP is not recommended anymore) + + dot11RSNAStatsTKIPReplays Increments when a MPDU discarded by TKIP replay error //(use of WEP/TKIP is not recommended anymore) + + dot11RSNAStatsCCMPDecryptErrors Increments when a MPDU discarded by CCMP decryption error + + dot11RSNAStatsCCMPReplays Increments when a MPDU discarded by CCMP replay error + + dot11TransmittedAMSDUCount Increments when a A-MSDU transmitted successfully + + dot11FailedAMSDUCount Increments when a A-MSDU not transmitted successfully + + dot11RetryAMSDUCount Increments when a A-MSDU is successfully transmitted after one or more retransmissions + + dot11MultipleRetryAMSDUCount Increments when a A-MSDU is successfully transmitted after more than one retransmissions + + dot11TransmittedOctetsInAMSDUCount Increments by the number of octets in the frame body + of an A-MSDU frame when an A-MSDU frame is successfully transmitted + + dot11AMSDUAckFailureCount Increments when an acknowledgment to an A-MSDU is not received when expected. + + dot11ReceivedAMSDUCount Increments when a A-MSDU frame received + + dot11ReceivedOctetsInAMSDUCount Increments by the number of octets in the frame body + of an A-MSDU frame when an A-MSDU frame is received + + dot11TransmittedAMPDUCount Increments when an A-MPDU is transmitted + + dot11TransmittedMPDUsInAMPDUCount Increments by the number of MPDUs in the A-MPDU when an A-MPDU is transmitted + + dot11TransmittedOctetsInAMPDUCount Increments by the number of octets in the A-MPDU frame when an A-MPDU frame is transmitted + + dot11AMPDUReceivedCount Increments when the MAC receives an A-MPDU from the PHY + + dot11MPDUInReceivedAMPDUCount Increments by the number of MPDUs received in the + A-MPDU when an A-MPDU is received + + dot11ReceivedOctetsInAMPDUCount Increments by the number of octets in the A-MPDU + frame when an A-MPDU frame is received + + dot11AMPDUDelimiterCRCErrorCount Increments when an MPDU delimiter has a CRC error when this is the first + CRC error in the received A-MPDU or when the previous delimiter has been decoded correctly + + Cmd Usage: mlanutl mlanX getlog ext + The above command is used with the argument "ext" to display the following error statistics:- + + rxStuckIssueCount-1 + rxStuckIssueCount-2 + rxStuckRecoveryCount + rxStuckTsf-1 + rxStuckTsf-2 + txWatchdogRecoveryCount + txWatchdogTsf-1 + txWatchdogTsf-2 + channelSwitchAnnouncementSent + channelSwitchState + registerClass + channelNumber + channelSwitchMode + RxResetRecoveryCount + RxIsr2NotDoneCnt + gdmaAbortCnt + gResetRxMacCnt + gOwnrshpCtlErrCnt + gOwnrshpBcnErrCnt + gOwnrshpMgtErrCnt + gOwnrshpDatErrCnt + +getsignal + This command gets the last and average value of RSSI, SNR and NF of + Beacon and Data. + Note: This command is available only when STA is connected. + + where value of m is: + 1 -- RSSI (Receive Signal Strength Indication) + 2 -- SNR (Signal to Noise Ratio) + 3 -- NF (Noise Floor) + where value of n is: + 1 -- Beacon last + 2 -- Beacon average + 3 -- Data last + 4 -- Data average + + Examples: + mlanutl mlan0 getsignal 1 : Get the RSSI info (beacon last, beacon + average, data last and data average) + mlanutl mlan0 getsignal 3 4 : Get the NF of data average + mlanutl mlan0 getsignal 2 1 : Get the SNR of beacon last + mlanutl mlan0 getsignal : Get all of the signal info + mlan0 getsignal:-32 -33 -35 -36 67 59 63 56 -99 -92 -98 -92 + RSSI info: beacon last -32, beacon average -33, data last -35, data average -36 + SNR info: beacon last 67, beacon average 59, data last 63, data average 56 + NF info: beacon last -99, beacon average -92, data last -98, data average -92 + +getsignalext + This command gets the last and average value of RSSI, SNR and NF of + Beacon and Data of spectific antenna path. + Note: This command is available only when STA is connected. + Driver will enable signalext and collect signal information for one second + + where value of m is: + 1 -- PATH A + 2 -- PATH B + 3 -- PATH A+B + + Examples: + mlanutl mlan0 getsignalext :Get All path's signal. + mlanutl maln0 getsignalext 3 :Get path A+B signal + mlanutl maln0 getsignalext 1 :Get path A signal + mlanutl mlan0 getsignalext 2 :Get path B signal + + PATH A: -46 -46 -49 -49 65 45 39 42 -111 -91 -88 -91 + + PATH A: RSSI info: beacon last -46, beacon average -46, data last -49, data average -49 + SNR info: beacon last 65, beacon average 45, data last 39, data average 42 + NF info: beacon last -111, beacon average -91, data last -88, data average -91 + +signalextcfg + This command is used to enable/disable signalext + Usage: + mlanutl mlanX signalextcfg [m] + where the value of [m] is: + 1 -- enable signalext in firmware + 0 -- disable signalext in firmware + Examples: + mlanutl mlan0 signalextcfg 1 : Enable signalext in firmware + mlanutl mlan0 signalextcfg 0 : Disable signalext in firmware + +getsignalextv2 + This command gets the last and average value of RSSI, SNR and NF of + Beacon and Data of spectific antenna path. + Note: This command is available only when STA is connected. + "mlanutl mlanX signalextcfg 1" command needs to be issued before issuing this command + + where value of m is: + 1 -- PATH A + 2 -- PATH B + 3 -- PATH A+B + + Examples: + mlanutl mlan0 getsignalextv2 :Get All path's signal. + mlanutl maln0 getsignalextv2 3 :Get path A+B signal + mlanutl maln0 getsignalextv2 1 :Get path A signal + mlanutl mlan0 getsignalextv2 2 :Get path B signal + + PATH A: -46 -46 -49 -49 65 45 39 42 -111 -91 -88 -91 + + PATH A: RSSI info: beacon last -46, beacon average -46, data last -49, data average -49 + SNR info: beacon last 65, beacon average 45, data last 39, data average 42 + NF info: beacon last -111, beacon average -91, data last -88, data average -91 + +get_txpwrlimit + This command is used to get the txpwrlimit table in FW +Usage: + mlanutl mlanX get_txpwrlimit [raw_data_file] + where + 0: Get 2.4G txpwrlimit table + 0x10: Get 5G sub0 txpwrlimit table + 0x11: Get 5G sub1 txpwrlimit table + 0x12: Get 5G sub2 txpwrlimit table + 0x13: Get 5G sub3 txpwrlimit table + 0x1f: Get all 5G txpwrlimit table + 0xff: Get both 2G and 5G txpwrlimit table + driver will save fw raw data to this file. + + Examples: + mlanutl mlan0 get_txpwrlimit 0 : Get 2G txpwrlimit table. + mlanutl mlan0 get_txpwrlimit 0x10 : Get 5G sub band0 txpwrlimit table + mlanutl mlan0 get_txpwrlimit 0xff txpwrlimit.bin : Get both 2G/5G txpwrlimit table and save to txpwrlimit.bin + +aggrpriotbl + This command is used set/get the priority table for AMPDU/AMSDU traffic per tid. + This command can also be used to disable AMPDU/AMSDU for a given tid. + In case of AMPDU this priority table will be used to setup block ack (to make + sure the highest priority tid always uses AMPDU as we have limited AMPDU streams) + + where ... + + - This is priority for Tid0 for AMPDU packet. A priority could be any + values between 0 - 7, 0xff to disable aggregation. + - This is priority for Tid0 for AMSDU packet. A priority could be any + values between 0 - 7, 0xff to disable aggregation. + + eg: + mlanutl mlanX aggrpriotbl - This command will get the current Priority table for AMPDU and AMSDU. + <2 2 0 0 1 1 3 3 4 4 5 5 255 255 255 255>. This is read as + <"Prio for AMPDU for Tid0" "Prio for AMSDU for Tid0" + "Prio for AMPDU for Tid1" "Prio for AMSDU for Tid1" and so on + mlanutl mlanX aggrpriotbl 2 2 0 0 1 1 3 3 4 4 5 5 255 255 255 255 - + This will set the priority table for AMPDU and AMSDU + Priority for Tid0/AMPDU = 2, Tid0/AMSDU = 2, Tid1/AMPDU = 0, Tid1/AMSDU = 0 + and so on. Aggregation for Tid6 and Tid7 are disabled. + Here higher the priority number, higher the priority (i.e. 7 + has higher priority than 6). Similarly for AMSDU. + mlanutl mlanX aggrpriotbl 0xff 2 0xff 0 0xff 1 0xff 3 0xff 4 0xff 5 0xff 0xff 0xff 0xff - This will disable + AMPDU for all the TIDs but will still keep AMSDU enabled to Tid0 to Tid5 + + The default setting is 2 255 0 255 1 255 3 255 4 255 5 255 255 255 255 255. + + A delBA should be seen in case a disable happens on a TID for which AMPDU stream + is currently setup. + + Note:- This command should only be issue in disconnected state. + +addbapara + This command can be used to update the default ADDBA parameters. + + where is + - This is the block ack timeout for ADDBA request. + 0 : Disable (recommended for throughput test) + 1 - 65535 : Block Ack Timeout in TU + + where is + - Window size for ADDBA request. (16 is recommended and default value) + + where is + - Window size for ADDBA response. (48 is recommended and 32 is default value) + (16 is recommended for IWNCOMM AP in WAPI throughput test) + + Current window size limit for Tx as well as Rx is 1023. + + where

is + - amsdu support for ADDBA request. (1 is default value) + 0: disable amsdu in ADDBA request + 1: enable amsdu in ADDBA request + + where is + - amsdu support for ADDBA response. (1 is default value) + 0: disable amsdu in ADDBA response + 1: enable amsdu in ADDBA response + + eg: + mlanutl mlanX addbapara - This command will get the current addba params + mlanutl mlanX addbapara 1000 64 8 0 0 - This will change the ADDBA timeout to (1000 * 1024) us, + txwinsize to 64 and rxwinsize to 8 and disable amdsu in ADDBA request/response. + + The default setting is 65535 16 32 1 1. + + In case the ADDBA timeout value is updated then a ADDBA is sent for all streams + to update the timeout value. + + In case txwinsize and/or rxwinsize is updated, the effect could only be seen on + next ADDBA request/response. The current streams will not be affected with this + change. + + In case of txamsdu/rxamsdu is updated, the effect could only be seen on + next ADDBA request/response. The current streams will not be affected with this + change. AMSDU in AMPDU stream will be enabled when AP support this feature + and AMSDU is enabled in aggrpriotbl. + +addbareject + This command is used set/get the addbareject table for all the TIDs. + This command can also be used to enable rejection of ADDBA requests for a given tid. + + where ... + + - This can be 0/1 for TidX. 1 enables rejection of ADDBA request for TidX and + 0 would accept any ADDBAs for TidX. + + eg: + mlanutl mlanX addbareject - This command will get the current table. + [0 0 0 0 0 0 0 0]. ADDBA would be accepted for all TIDs. This is the default state. + + mlanutl mlanX addbareject 0 0 1 1 0 0 0 0 - This command will accept ADDBA requests for + Tid [0,1,4,5,6,7] and reject ADDBA requests for Tid [2,3] + + mlanutl mlanX addbareject 1 1 1 1 1 1 1 1 - This will enable rejection of ADDBA requests for + all Tids. + + Note:- This command should only be issue in disconnected state. + +vhtcfg + This command is used to set and get various 11ac specific configuration + for transmission and reception. For the SET operation, all paramaters + may be applied. For the GET operation, only the first two parameters are applied. + The 6th argument "rx_mcs_set" can be used to disbale/enable 802.11ac. + + where is + - This is the band setting for the vhtcfg + 0: Settings for both 2.4G and 5G bands (for SET operation, 11N BW only) + 1: Settings for 2.4G band (for 11N BW only) + 2: Settings for 5G band + + where is + - This parameter specifies the configuration of VHT operation for TX or/and VHT capabilities + 0: Unspecified + 1: configuration of VHT capabilities for Tx operations (STA only) + 2: configuration of VHT capabilities for association (STA only) + 3: configuration of VHT capabilities (uAP only) + Note: For the STA, the VHT capabilities configuration is applied in association, + whereas the VHT operations configuration is actually used in Tx. + + where [l] is + - This parameter specifies the bandwidth (BW) configuration + applied to the vhtcfg. + If is 1/3 (Tx operations), + 0: Tx BW follows the BW (20/40 MHz) from 11N CFG + 1: Tx BW follows the BW (80/160/80+80 MHz) from VHT Capabilities + defined in below for 5G band. + If is 2 (association), + 0: Rx BW follows the BW (20/40 MHz) from 11N CFG + 1: Rx BW follows the BW (80/160/80+80 MHz) from VHT Capabilities + defined in below for 5G band. + + where [m] is + - This parameter specifies the VHT capabilities info if is 2 (association) + or the VHT Tx operations if is 1 (Tx operations). + The VHT Tx operation should be a subset of VHT capabilities for association. + It is a bitmap and should be used as follows: + + Bit 31-30: Reserved and set to 0 + Bit 29: TX antenna pattern consistency + 1: antenna pattern does not change + 0: antenna pattern might change + Bit 28: RX antenna pattern consistency + 1: antenna pattern does not change + 0: antenna pattern might change + Bit 27-26: VHT link adaptation capable + 0: no feedback of VHT MFB from the STA + 1: unsolicted feedback of VHT MFB from the STA + 2: both response and unsolicted feedback of VHT MFB + from the STA + 3: reserved and set to 0 + Bit 25-23: Maximum A-MPDU length exponent + Bit 22: +HTC-VHT capable (1: enable. 0 disable) + Bit 21: VHT TXOP PS + Bit 20: MU beamformee capable (1: enable. 0 disable) + Bit 19: MU beamformer capable (1: enable. 0 disable) + Bit 18-16: Number of sounding dimensions (set to maximum-1 + if Bit 11 is 1. Otherwise, reserved and set to 0) + Bit 15-13: Compressed steering number of beamformer + antennas supported (set to maximum-1 if Bit 12 is 1. + Otherwise, reserved and set to 0) + Bit 12: SU beamformee capable (1: enable. 0 disable) + Bit 11: SU beamformer capable (1: enable. 0 disable) + Bit 10-8: Rx STBC + 0: no support + 1: support of 1 spatial stream + 2: support of 1-2 streams + 3: support of 1-3 spatial streams + 4: support of 1-4 spatial streams + 5-7: reserved and set to 0 + Bit 7: TX STBC (1: enable. 0 disable) + Bit 6: Short GI for 160 and 80+80 MHz (1: enable. 0 disable) + Bit 5: Short GI for 80 MHz (1: enable. 0 disable) + Bit 4: Rx LDPC (1: enable. 0 disable) + Bit 3-2: Supported channel width set. + 0: no support of either 160 or 80+80 MHz. + 1: support of 160 MHz + 2: support of both 160 and 80+80 MHz. + 3: reserved and set to 0. + Bit 1-0: Maximum MPDU length + 0: 3895 octets. + 1: 7991 octets. + 2: 11454 octets. + 3: reserved and set to 0. + + Note: for the STA, if is 1 (Tx operations), the bitmap for may be simplied as follows: + Bit 31-8: Reserved and set to 0 + Bit 7: Tx STBC (1: enable. 0 disable) + Bit 6: Reserved and set to 0 + Bit 5: Short GI for 80 Mhz (1: enable. 0 disable) + Bit 4: LDPC (1: enable. 0 disable) + Bit 3-0: Reserved and set to 0 + + where [n] is , + - This parameter specifies the TX MCS map. It may not be used for the STA if is 1 (Tx operations). + It is a bitmap and should be used as following + Bit 15-0: MCS map, which is defined as folows: + Bit 15-14: Max MCS for 8 SS + Bit 13-12: Max MCS for 7 SS + Bit 11-10: Max MCS for 6 SS + Bit 9-8: Max MCS for 5 SS + Bit 7-6: Max MCS for 4 SS + Bit 5-4: Max MCS for 3 SS + Bit 3-2: Max MCS for 2 SS + Bit 1-0: Max MCS for 1 SS + + where [o] is . + - This parameter specifies the RX MCS map. It may not be used for the STA if is 1 (Tx operations). + It is a bitmap with the same sructure as for + rx_mcs_map = 0xffff : FW will disable 802.11ac + rx_mcs_map = others : FW will enable 802.11ac + + Note: The user setting of vhtcap may be overwritten by the driver + if the setting of those fields is beyond the hardware capabilities. + + Examples: + mlanutl mlan0 vhtcfg 2 1 : Get current VHT configuration in 5GHz for the STA. + mlanutl mlan0 vhtcfg 2 2 : Get maximum VHT configuration in 5GHz for the STA. + mlanutl mlan0 vhtcfg 2 1 1 0x000001f0 + : Set the Tx operations configuration in 5GHz for the STA, + Tx BW follows the VHT Capabilities. + mlanutl mlan0 vhtcfg 2 2 0 0x000001f0 0xfff5 0xfffa + : Set the VHT capabilities configuration in 5GHz for the STA, + the Tx supports MCS 0-8 for both 1 and 2 spatial streams, + while the Rx supports MCS 0-9 for both 1 and 2 spatial streams. + mlanutl uap0 vhtcfg 2 3 0 0x000001f0 0xfffa 0xfffa + : Set the current/maximum VHT configuration in 5GHz for the uAP. + Both Tx and Rx supports MCS 0-9 for both 1 and 2 spatial streams. + mlanutl uap0 vhtcfg 2 3 0 0x000001b0 + : Set the VHT capability information in 5GHz for the uAP, and keep the Tx/Rx MCS Map same as before. + +dyn_bw + This command is used to set/get dynamic bandwidth. + + Usage: + mlanutl mlanX dyn_bw [n] + + where + [BIT0] + 0 = TxInfo Indicated BW Disable + 1 = TxInfo Indicated BW Enable + [BIT1] + 0 = TxInfo Dynamatic BW Disable + 1 = TxInfo Dynamatic BW Enable + [BIT2] + 0 = TxInfo Force send RTS Disable + 1 = TxInfo Force send RTS Enable + [BIT3] + 0 = Mac Dynamic BW Operation Mode Disable (Static BW Operation Mode) + 1 = Mac Dynamic BW Operation Mode Enable + other bits reserved. + + If no parameter provided, get is performed. + + Examples: + mlanutl mlan0 dyn_bw 0x1 : Enable TxInfo Indicated BW + mlanutl mlan0 dyn_bw : get current setting + +httxcfg + This command is used to configure various 11n specific configuration + for transmit (such as Short GI, Channel BW and Green field support) + + where is + This is a bitmap and should be used as following + Bit 15-8: Reserved set to 0 + Bit 7: STBC enable/disable + Bit 6: Short GI in 40 Mhz enable/disable + Bit 5: Short GI in 20 Mhz enable/disable + Bit 4: Green field enable/disable + Bit 3-2: Reserved set to 1 + Bit 1: 20/40 Mhz enable disable. + Bit 0: LDPC enable/disable + + When Bit 1 is set then firmware could transmit in 20Mhz or 40Mhz based + on rate adaptation. When this bit is reset then firmware will only + transmit in 20Mhz. + + where is + - This is the band info for settings. + 0: Settings for both 2.4G and 5G bands + 1: Settings for 2.4G band + 2: Settings for 5G band + + Example: + mlanutl mlanX httxcfg + This will display HT Tx configuration for 2.4G and 5G band. + + mlanutl mlanX httxcfg 0x62 + This will enable 20/40 and Short GI but will disable Green field for 2.4G and 5G band. + + mlanutl mlanX httxcfg 0x30 1 + This will enable Short GI 20 Mhz and Green field for 2.4G band. + + The default value is 0x20 for 2.4G and 0x62 for 5G. + + Note:- If 20/40 MHz support is disabled in htcapinfo, device will not transmit + in 40 MHz even 20/40 MHz is enabled in httxcfg. + +htcapinfo + This command is used to configure some of parameters in HTCapInfo IE + (such as Short GI, Channel BW, and Green field support) + + where is + - This is a bitmap and should be used as following + Bit 29: Green field enable/disable + Bit 26: Rx STBC Support enable/disable. (As we support + single spatial stream only 1 bit is used for Rx STBC) + Bit 25: Tx STBC support enable/disable. + Bit 24: Short GI in 40 Mhz enable/disable + Bit 23: Short GI in 20 Mhz enable/disable + Bit 22: Rx LDPC enable/disable + Bit 17: 20/40 Mhz enable disable. + Bit 8: Enable/disable 40Mhz Intolarent bit in ht capinfo. + 0 will reset this bit and 1 will set this bit in + htcapinfo attached in assoc request. + All others are reserved and should be set to 0. + + Setting of any other bits will return error. + + where is + - This is the band info for settings. + 0: Settings for both 2.4G and 5G bands + 1: Settings for 2.4G band + 2: Settings for 5G band + + Example: + mlanutl mlanX htcapinfo + This will display HT capabilties information. + If the information for 2.4G and 5G is different, + the first value is for 2.4G and the second value is for 5G. + Otherwise, it will display a single value for both bands. + + mlanutl mlanX htcapinfo 0x1820000 + This will enable Short GI, Channel BW to 20/40 and disable Green field support for 2.4G and 5G band. + + mlanutl mlanX htcapinfo 0x800000 2 + This will enable Short GI, Channel BW to 20 only, No Rx STBC support and disable Green field support for 5G band. + + The default value is 0x4800000 for 2.4G and 0x5820000 for 5G. + + Note:- This command can be issued any time but it will only come to effect from + next association. (as HTCapInfo is sent only during Association). + +11axcfg + This command is used to config 11ax HE capability using conf file. + + Usage: + mlanutl mlanX 11axcfg [conf file] + + Example: + mlanutl mlan0 11axcfg config/11axcfg.conf + mlanutl uap0 11axcfg config/11axcfg.conf + +11axcmd + This command is used to config 11ax HE capability using command. + + Usage: + mlanutl 11axcmd [value_1] [value_2] [value_3] + : spatial reuse configuration + set obss_pd offset, [value_1] = NON_SRG_OffSET, [value_2] = SRG_OFFSET + + : spatial reuse configuration + control SR, [value_1]= 1 is enable SR, [value_1] = 0 is disable SR + + : enable/disable beam change + enable beam_change when [value_1 = 0] + disable beam_change when [value_1 = 1] + + : enable/disable HTC transmission + enable transmission of HTC when [value_1 = 1] + disable transmission of HTC when [value_1 = 0] + + : set/get RTS threshold + This subcmd applies to uapX only. uAP uses it to manage the RTS/CTS used by associated non-AP HE STA + set TXOP duration RTS Threshold when [value_1 = ]. If = 1023, disable TXOP duration RTS + get TXOP duration RTS Threshold without value_1 and value_2 + Where is: + Bit 0-9: TXOP RTS Threshold + : set/get omi value + used for OMI transmission in MAC header HTC+ field, please see 11ax spec for OMI definition + set OMI: [value_1 = ] [value_2 = ] [value_3 = ] + where + is defined as: + Bit 0-2: Rx NSS + Bit 3-4: Channel Width + Bit 6 : Tx NSTS (applies to client mode only) + All other bits are not supported currently. + is defined as: + 0: OMI is transmitted in QoS NULL frame; + 1: OMI is transmitted in QoS data frame; + 0xFF: OMI is transmitted in both QoS NULL and QoS data frame. + is applied only if OMI is sent in QoS data frame. + It specifies the number of consecutive data frames containing the OMI. + + get OMI without any value + + : set/get OBSS narrow band RU tolerance time value in seconds + set tolerance time when [value_1 =

[value] + + where the parameters are, +
: memory address + [value]: value to be written + + Examples: + mlanutl mlan0 memrdwr 0x4cf70 : Read memory address 0x4cf70 + mlanutl mlan0 memrdwr 0x80000000 0xffffffff + : Write 0xffffffff to memory address 0x80000000 + +miracastcfg + This command is used to set/get the miracast configuration. + + Usage: + mlanutl mlanX miracastcfg [l] [m] [n] + + where the parameters are, + [l]: miracast mode + 0: Disable + 1: Source + 2: Sink + [m]: scan time per channel, in ms + [n]: gap during two scans, in ms + + Examples: + mlanutl mlan0 miracastcfg : Get miracast configuration + mlanutl mlan0 miracastcfg 0 : Disable miracast configuration + mlanutl mlan0 miracastcfg 1 20 40 : Set miracast mode as source, with scan time + 20ms per channel and gap during two scans 40ms + +mgmtframectrl + This command is used to set/get registered frame type to passthrough. + + Usage: + mlanutl mlanX mgmtframectrl [] + mlanutl uapX mgmtframectrl [] + + Where the parameter is: + : the bit mask of management frame reception. + : Bit 0 - Association Request + : Bit 1 - Association Response + : Bit 2 - Re-Association Request + : Bit 3 - Re-Association Response + : Bit 4 - Probe Request + : Bit 5 - Probe Response + : Bit 8 - Beacon Frames + : Bit 10 - Disassociation + : Bit 11 - Authentication + : Bit 12 - Deauthentication + : Bit 13 - Action Frames + + Examples: + mlanutl mlan0 mgmtframectrl : Get present mask + mlanutl mlan0 mgmtframectrl 0x0020 : Bit 5 is set, Forward probe response frames to application layer + +mgmtframetx + This command is used to send management frame. + + Usage: + mlanutl mlanX mgmtframetx + + Where the parameter is: + mgmt_frame.conf : The configuration file contains the management frame. + + Examples: + mlanutl mlan0 mgmtframetx config/mgmt_frame.conf + +netmon + This command is used to set/get network monitor configuration. + Note: For channel specified mode, the configuration should be issued when + STA/AP is disconnected. For in-channel sniffer mode, the configuration + can be issued irrespective of the STA/AP connected state, and requires + specification of only action and filter parameters. If any of the STA/AP + connection is active, the in-channel sniffer mode will inherently work + on the active band and channel configuration. + + Usage: + mlanutl netmon [ [ ]] + + Where the parameters are: + : mlanX + : (0) disable any network monitor activity + : (1) enable channel specified sniffer mode activity + : network monitor fitler flag + bit 0: (1/0) enable/disable management frame + bit 1: (1/0) enable/disable control frame + bit 2: (1/0) enable/disable data frame + bit 3: (1/0) enable/disable frames destined to active connection only + bit 5: (1/0) enable/disable non-BSS beacon frames + bit 6: (1/0) enable/disable Tx frames, excluding control + : 802.11 band + bit 0: B + bit 1: G + bit 2: A + bit 3: GN + bit 4: AN + bit 5: AC 2.4G + bit 6: AC 5G + : channel to monitor + : [offset] + [offset] : secondary channel bandwidth + 0 - Bandwidth 20Mhz + 1 - HT Bandwidth 40Mhz sec channel above + 3 - HT Bandwidth 40Mhz sec channel below + 4 - VHT Bandwidth 80Mhz + + Examples: + mlanutl mlan0 netmon : Get the current network monitor configuration + mlanutl mlan0 netmon 0 : Disable network monitor activity + mlanutl mlan0 netmon 1 4 11 6 : Enable channel specified sniffer activity, set filter + data frame, band B/G/GN and channel 6 + mlanutl mlan0 netmon 1 7 20 64 1 : Enable channel specified sniffer activity, set filter + management, control and data frame, band A/AN, + channel 64 and secondary channel above + +offchannel + This command is used to set/cancel the offchannel configuration. + Note: This command only can be used when cfg80211 is enabled during load time. + + Usage: + mlanutl mlanX offchannel [ ] + + where + + 0 : Cancel the offchannel configuration + 1 : Set the offchannel configuration + + The channel to configure + + The duration for which to configure + : channel bandwidth + 0 - Bandwidth 20Mhz + 1 - HT Bandwidth 40Mhz sec channel above + 3 - HT Bandwidth 40Mhz sec channel below + 4 - VHT Bandwidth 80Mhz + + Examples: + mlanutl mlan0 offchannel : Get current offchannel status. + mlanutl mlan0 offchannel 0 : Cancel the offchannel configuration. + mlanutl mlan0 offchannel 1 3 5 : Configure channel 3 for 5 milliseconds. + mlanutl mlan0 offchannel 1 36 5000 : Configure channel 36 for 5000 milliseconds. + mlanutl mlan0 offchannel 1 64 500 4 : Configure channel 64 in 80MHz for 500 milliseconds. + +otpuserdata + This command is used to get the OTP user data. + + Where + is + - This parameter specifies the length of OTP user data to be read + + Examples: + mlanutl mlan0 otpuserdata 10 : Get the 10-byte OTP user data + +passphrase + This command is used to set/get passphrase for WPA-PSK/WPA2-PSK/WPA3-SAE mode.// use of WPA/TKIP is not recommended anymore + + Where + ASCII string for ssid/passphrase/psk/sae_password. + + Setting psk for WPA3 SAE protocol is not possible, as new psk gets generated + everytime in protocol flow. + + 1) "0;" - This will get the passphrase, AKMP + for specified ssid, if none specified then it will get all. + + Example: + mlanutl mlan0 passphrase "0;ssid=nxp" + + 2) "1;; + " - Passphrase and psk cannot be provided for the same SSID. + This command takes only one SSID at a time, If ssid= is present it should contain + a passphrase or psk. If no arguments are provided then AKMP=802.1x, and passphrase + should be provided after association. + End of each parameter should be followed by a ';'(except for the last parameter) + as the delimiter. If ';' or '/' has to be used in an SSID then a '/' should be preceded + to ';' or '/' as a escape. + + Examples: + mlanutl mlan0 passphrase "1;ssid=nxpAP;passphrase=abcdefgd" + mlanutl mlan0 passphrase "1;ssid=nxp AP;psk=<64 bytes hexpsk>" + + If user wants to input the ssid as "nxp; AP" then command has to be + mlanutl mlan0 passphrase "1;ssid=nxp/; AP;passphrase=abcdefgh" + + If user wants to input the ssid as "//;" then command has to be + mlanutl mlan0 passphrase "1;ssid=/////;;passphrase=abcdefgh" + + 3) "2;" - This will clear the passphrase + for specified ssid, if none specified then it will clear all. + + Examples: + mlanutl mlan0 passphrase "2;ssid=nxp" + mlanutl mlan0 passphrase "2" : Clear all profiles and disable embedded supplicant + + 4)"1;ssid=;sae_password=" This will set WPA3 SAE ssid & password. sae_password should be within the range of 8 to 255 char. + Examples: + mlanutl mlan0 passphrase "1;ssid=nxp;sae_password=1234567890" + +pb_bypass + This command is used to get the By-passed TX packet from upper layer. + + Usage: + + mlanutl mlanX pb_bypass [data_1, data_2, ... data_n] + + where value of data_1, data_2, ... data_n isBypass TX Data + +pcieregrw + This command is used to read/write PCIE register. + + Usage: + mlanutl mlanX pcieregrw [value] + + where the parameters are, + : The offset of PCIE register + [value]: The value to write + + Examples: + mlanutl mlan0 pcieregrw 0x48 : Read PCIE register 0x48 + mlanutl mlan0 pcieregrw 0x44 8 : Write 8 to PCIE register 0x44 + +pciebar0regrw + This command is used to read/write PCIE register/memory from BAR0. + + Usage: + mlanutl mlanX pciebar0regrw [value] + + where the parameters are, + : The offset of PCIE register + [value]: The value to write + + Examples: + mlanutl mlan0 pciebar0regrw 0x48 : Read PCIE register 0x48 + mlanutl mlan0 pciebar0regrw 0x44 8 : Write 8 to PCIE register 0x44 + +pmfcfg + This command is used to set/get management frame protection parameters. + + Usage: + mlanutl mlanX pmfcfg + + where + : Management Frame Protection Capable (MFPC) + 1: Management Frame Protection Capable + 0: Management Frame Protection not Capable + : Management Frame Protection Required (MFPR) + 1: Management Frame Protection Required + 0: Management Frame Protection Optional + Default setting is PMF not capable. + m = 0, n = 1 is an invalid combination + + Examples: + mlanutl mlan0 pmfcfg : Get PMF parameters + mlanutl mlan0 pmfcfg 1 0 : Set MFPC and make MFPR optional + +port_ctrl + This command is used to Set/Get Port Control mode. No argument is used to get. + + where value of n is: + 0 -- Disable + 1 -- Enable + + Examples: + mlanutl mlan0 port_ctrl 1 : Enable Port Control mode + mlanutl mlan0 port_ctrl : Get Port Control mode status + +powercons + This command is used to set the local transmit power constraint. + Value is in dbm unit. This command is only used for ad-hoc start. + + Usage: + mlanutl mlanX powercons [n] + + Examples: + mlanutl mlanX powercons : get the current setting + mlanutl mlanX powercons 12 : set local power constraint to 12 dbm + +pscfg + This command is used to set/get PS configuration parameters. + + Usage: + mlanutl mlanX pscfg [k] [d] [l] ... + + Where the parameters: + [k]: Keep alive null packet interval (0: Unchanged, -1: Disable, n: Interval in seconds) + [d]: DTIM interval ( 0: Unchanged, + 1-5: Value, + 65534: DTIM will be ignored, listen interval will be used, + 65533: Closest DTIM to the listen interval period will be used ) + [l]: Local listen interval ( 0: Unchanged, + -1: Disable, + 1-49: Value in beacon intervals, + >= 50: Value in TUs ) + [b]: Beacon miss timeout (0: Unchanged, 1-50: Value in milliseconds, 65535: Disable) + [p]: Delay to PS (0-65535: Value in milliseconds, default 1000ms) + [m]: PS mode (0: Unchanged, 1: Auto mode, 2: PS-Poll mode, 3: PS Null mode) + No change if parameters are not provided. + + Examples: + mlanutl mlan0 pscfg : Get all the current PS configuration settings + mlanutl mlan0 pscfg 3 4 : Set PS keep alive null packet interval to 3 seconds + and DTIM interval to 4, all the other configurations + are unchanged + mlanutl mlan0 pscfg 0 0 0 0 50 2 : Set delay to PS to 50 ms and PS mode to PS-Poll mode, + keep the others unchanged + +bcntimeoutcfg + This command is used to set Beacon timeout parameters. + + Usage: + mlanutl mlanX bcntimeoutcfg [l] [m] [o] [p] + + Where the parameters: + [l]: Beacon miss timeout period Rx window (in ms) + [m]: Beacon miss timeout period (unit in beacon interval) + [o]: Beacon reacquire timeout period Rx window (unit in beacon interval) + [p]: Beacon reacquire timeout period (unit in beacon interval) + Please note that it would be better [m]+[p] not exceed 64. + Examples: + mlanutl mlan0 bcntimeoutcfg 10 30 2 30 : Set beacon timeout configure to + Beacon miss timeout period Rx window : 10 (ms) + Beacon miss timeout period : 30 (Beacon Interval) + Beacon reacquire timeout period Rx window : 2 (Beacon Interval) + Beacon reacquire timeout period : 30 (Beacon Interval) + +psmode + This command is used to set/get the IEEE PS mode configuration. + + Usage: + mlanutl mlanX psmode [l] + + where the parameter: + [l] + 0 : Disable IEEE PS mode + 1 : Enable IEEE PS mode + : Get IEEE PS mode + + Examples: + mlanutl mlan0 psmode : Get IEEE PS mode. + mlanutl mlan0 psmode 1 : Enable IEEE PS mode. + +qconfig + 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. + + Usage: + mlanutl mlanX qconfig def [Queue Id: 0-3] + mlanutl mlanX qconfig get [Queue Id: 0-3] + mlanutl mlanX qconfig set msdu [Queue Id: 0-3] + +qoscfg + This command sets WMM IE QOS info when an argument is given, and gets current WMM + IE QOS info when no argument is given. + + Examples: + mlanutl mlanX qoscfg 0x0f : Set WMM IE QOS info to 0x0f + mlanutl mlanX qoscfg : Get WMM IE QOS info + +qstatus + This command retrieves the current status of the WMM queues. If WMM + is enabled then it displays the information for each AC in a table. + + Usage: + mlanutl mlanX qstatus + +radioctrl + This command is used to turn on/off the radio. + Note: The radio can be disabled only in disconnected state. + + where value of n is: + 0 -- Disable + 1 -- Enable + + Examples: + mlanutl mlan0 radioctrl 1 : Turn the radio on + mlanutl mlan0 radioctrl : Get radio status + +rdeeprom + This command is used to read the EEPROM contents of the card. + + Usage: + mlanutl mlanX rdeeprom + + where the parameters are, + : multiples of 4 + : 4-20, multiples of 4 + + Example: + mlanutl mlan0 rdeeprom 0 20 : Read 20 bytes of EEPROM data from offset 0 + +reassoctrl + This command is used to turn on/off re-association in driver. + + Usage: + mlanutl mlanX reassoctrl [n] + + Where value of n is: + 0 -- Disable + 1 -- Enable + + Examples: + mlanutl mlan0 reassoctrl : Get re-association status + mlanutl mlan0 reassoctrl 1 : Turn re-association on + +regioncode + This command is used to set/get the region code in the station. + Note: This command should be issued at beginning before band/channel selection + and association. + + where value is 'region code' for various regions like + USA FCC, Canada IC, Europe ETSI, Japan ... + The special code (0xff) is used for Japan to support channel 1-14 in B/G/N mode. + + Examples: + mlanutl mlan0 regioncode : Get region code + mlanutl mlan0 regioncode 0x10 : Set region code to USA (0x10) + Note : in some case regioncode will be 0 after updated countycode or 80211d + i.e. mlanutl mlanX countrycode (CA, JP, CN, DE, ES AT, BR, RU) + or uaputl.exe sys_cfg_80211d state 1 country (CA, JP, CN, DE, ES AT, BR, RU) + Please use cfp instead of it. + +regrdwr + This command is used to read/write the adapter register. + + Usage: + mlanutl mlanX regrdwr [value] + + where the parameters are, + : 1:MAC, 2:BBP, 3:RF, 5:CAU, 6:PSU, 7:BCA, 8:CIU, 0x81:MAC2, 0x82:BBP2, 0x83: RF2, 0x87: BCA2 + : 1:MAC, 2:BBP, 3:RF, 5:CAU, 6:PSU, 7:BCA, 8:CIU + : 1:MAC/SOC, 2:BBP, 3:RF, 5:CAU, 6:PSU, 7:BCA + : offset of register + [value]: value to be written + Note: + BBP reg (type 2) 0xXZZZ: + X: 0=BBUD, 8=BBUA. + ZZZ: offset (0-0xFFF). + RF reg (type 3) 0xXYZZ: + + For 8887/8897/8777 + 1. If Y == 0, access RFU BASE Register. + X = Path ID (0=Path_A, 1=Path_B), ZZ = offset (0-0xFF). + 2. If Y != 0, access RFU XCVR Register on Path Y (1=Path_A, 2=Path_B). + X = Page # (0=Page_1, 1=Page_2, 2=Page_3 if chip support), ZZ: offset (0-0xFF). + For 8977/8997/8987 + X = Path ID (0-1) + Y = Page Number (0-6) in selected Path + ZZ = Register offset in selected path/page + + Examples: + mlanutl mlan0 regrdwr 1 0x60 : Read the MAC register + mlanutl mlan0 regrdwr 1 0x794 0x80000000 : Write 0x80000000 to MAC register + mlanutl mlan0 regrdwr 0x81 0x60 :Read MAC2 register + +rejectaddbareq + This command is used to set/get the conditions of rejecting addba request. + + Usage: + mlanutl mlanX rejectaddbareq [conditions] + mlanutl uapX rejectaddbareq [conditions] + + Where conditions are: + bit 0 = 1 -- reject the addba request when host sleep activated + others -- reserved + + Examples: + mlanutl mlan0 rejectaddbareq : Get the reject addba request conditions + mlanutl mlan0 rejectaddbareq 0x1 : Reject the addba request + when host sleep activated + mlanutl uap0 rejectaddbareq 0x1 : Reject the addba request + when host sleep activated + +scancfg + This command is used to set/get scan configuration parameters. + + Usage: + mlanutl mlanX scancfg [t] [m] [p] [s] [a] [b] [c] [ext] [gap] + + where the parameters: + [t]: Scan Type (0: Unchanged, 1: Active, 2: Passive, default Active) + [m]: Scan Mode (0: Unchanged, 1: BSS, 2: IBSS, 3: Any, default Any) + [p]: Scan Probes (0: Unchanged, 1-5: Number of probes per channel, default 4) + [s]: Specific Scan Time (0: Unchanged, n: Value in ms, default 110 ms, max 500 ms) + [a]: Active Scan Time (0: Unchanged, n: Value in ms, default 200 ms, max 500 ms) + [b]: Passive Scan Time (0: Unchanged, n: Value in ms, default 200 ms, max 2000 ms) + [c]: Passive to Active Scan (0: Unchanged, 1: Enable, 2: Disable, default Enable) + [ext]: Extended scan (0: Unchanged, 1: Legacy scan, 2: Extended scan, 3: Extended scan enhance) + [gap]: Time gap between two scans in milliseconds (max value 500ms) + No change if the parameter is 0 or the parameter is not provided. + + Examples: + mlanutl mlan0 scancfg : Get all the current scan configuration settings + mlanutl mlan0 scancfg 1 3 : Set scan type to active and scan mode to any, + all the other scan configurations are unchanged + mlanutl mlan0 scancfg 0 1 2 200 : Set scan mode to BSS, number of probes to 2 and + specific scan time to 200 ms, all the other scan + configurations are unchanged + mlanutl mlan0 scancfg 0 0 0 0 0 0 1 : Set Passive to Active Scan to enable, all the + other scan configurations are unchanged + mlanutl mlan0 scancfg 2 0 0 0 0 0 2 : Set scan type to passive, Passive to Active + Scan to disable, all the other scan configurations + are unchanged + +setuserscan + Initiate a customized scan and retrieve the results + + Usage: + mlanutl mlanX setuserscan [ARGS] + + Where [ARGS]: + ssid="[SSID]" specify a SSID filter for the scan + group= specify the channel group(s) to scan + chan=[chan#][band][mode] where band is [a,b,g,e] and mode is + blank for unchange, or 'c' for active or 'p' for passive + bssid=xx:xx:xx:xx:xx:xx specify a BSSID filter for the scan + wc="[WILDCARD SSID]" specify a UNIX pattern matching filter (using * + and ?) for SSIDs found in a broadcast probe + keep=[0 or 1] keep the previous scan results (1), discard (0) + dur=[scan time] time to scan for each channel in milliseconds + gap=[gap time] Time gap between two scans in milliseconds + probes=[#] number of probe requests to send on each chan + for each broadcast probe required and each SSID + specific probe required (1-5) + bss_type=[1,2,3] BSS type: 1 (Infra), 2(Adhoc), 3(Any) + sort_by_ch Sort by channel number in ascending order. + Default mode: Sort by Signal Strength in descending order. + scan_type=[0,1] ext scan type (0-1) 0: legacy, 1: enhance scan + + 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 driver. + If the dur or probes tokens are absent, the driver default setting will be + used. The bssid and ssid fields, if blank, will produce an unfiltered scan. + It's allowed to input multiple ssid/wc entries, the max entry number is 10. + The type field will default to 3 (Any) and the keep field will default to 0 + (Discard). + + Examples: + 1) Perform an active scan on channels 1, 6, and 11 in the 'g' band: + setuserscan chan=1g,6g,11g + + 2) Perform a passive scan on channel 11 for 20 ms: + setuserscan chan=11gp dur=20 + + 3) Perform an active scan on channels 1, 6, and 11; and a passive scan on + channel 36 in the 'a' band: + setuserscan chan=1g,6g,11g,36ap + + 4) Perform an active scan on channel 6 and 36 for specific SSID: + setuserscan chan=6g,36a ssid=TestAP1 ssid=TestAP2 + + 5) Scan all available channels (B/G/N, A bands) for a specific BSSID, keep + the current scan table intact, update existing or append new scan data: + setuserscan bssid=00:50:43:20:12:82 keep=1 + + 6) Scan channel 6, for all infrastructure networks, sending two probe + requests. Keep the previous scan table intact. Update any duplicate + BSSID/SSID matches with the new scan data: + setuserscan chan=6g bss_type=1 probes=2 keep=1 + + 7) Scan channel 1 and 6, for all networks matching the NXP*AP + or AP*NXP? patterns and for NXPTst SSID. Generate 3 broadcast + probes for the patterns and 3 SSID specific probes for NXPTst on + both channel 1 and channel 6. + setuserscan chan=1g,6g probes=3 wc="NXP*AP" wc="AP*NXP?" ssid="NXPTst" + + 8) Scan all the channels for specified band. + setuserscan chan=0g + 9) Perform active scan for a list of specific BSSIDs + setuserscan bssid=00:50:43:20:12:82 bssid=48:e2:44:3f:ec:76 + + 9) Scan channel 1 and 6, send 3 probe requests, scan each channel for 40 ms + with time gap of 50ms between 2 scans + setuserscan chan=1g,6g probes=3 dur=40 gap=50 + + 10) Perform an enhance scan + setuserscan scan_type=1 + + All entries in the scan table (not just the new scan data when keep=1) + will be displayed upon completion by use of the getscantable ioctl. +cancelscan + This command is used to cancel scan + Usage: + mlanutl mlanX cancelscan +sleepparams + This command is used to set the sleepclock configurations + + Usage: + mlanutl mlanX sleepparams [ ] + + where: + p1 is Sleep clock error in ppm (0-65535) + p2 is Wakeup offset in usec (0-65535) + p3 is Clock stabilization time in usec (0-65535) + p4 is Control periodic calibration (0-2) + p5 is Control the use of external sleep clock (0-2) + p6 is reserved for debug (0-65535) + + Examples: + mlanutl mlan0 sleepparams : Get current sleepclock configuration + mlanutl mlan0 sleepparams 10 1000 2000 1 0 128 : Set sleepclock configuration + +sleeppd + This command is used to configure the sleep period of the WLAN device. + + Usage: + mlanutl mlanX sleeppd [] + + Where the parameter is: + period: sleep period in milliseconds. Range 10~60. 0 for disable. + + Examples: + mlanutl mlan0 sleeppd : Get sleep period configuration + mlanutl mlan0 sleeppd 10 : Set sleep period to 10 ms + +sysclock + This command is used to set/get system clocks in MHz. + The current system clock, configurable system clocks and all of the + supported system clocks will be returned if no parameter provided. + + Examples: + mlanutl mlan0 sysclock : Get system clocks + 80 80 128 128 128 5 11 16 20 22 32 40 44 64 80 106 128 160 ... + (The current system clock is 80 MHz. + The configurable system clocks of non-security, security, non-security + A-MPDU and security A-MPDU are 80 MHz, 128 MHz, 128 MHz and 128 MHz. + The supported system clocks are 5 MHz, 11 MHz, ..., 160 MHz, 182 MHz, + 213 MHz, 256 MHz, 320 Mhz, 366 MHz , ... . the Max system clocks is different + for different chips, you could use this command to get the supported system clock) + + mlanutl mlanX sysclock 80 : Set system clock in non-security mode + to 80 MHz, no change for others + mlanutl mlanX sysclock 0 0 128 : Set system clock in non-security A-MPDU + mode to 128 MHz, no changes for others + +tcpackenh + This command is used to set/get TCP ACK enhancement mode. + + Usage: + mlanutl mlanX tcpackenh [l] [m] + + where + [l] is a control to set TCP ACK enhancement mode + 1 -- Enable TCP ACK enhancement (default) + 0 -- Disable TCP ACK enhancement + [m] is to configure TCP ACK max hold number + default value is 9, which means driver could hold up to 9 TCP ACK and + only send the last one to peer. + + Examples: + mlanutl mlan0 tcpackenh : Display TCP ACK enhancement + mlanutl mlan0 tcpackenh 1 : Enable TCP ACK enhancement + mlanutl mlan0 tcpackenh 0 : Disable TCP ACK enhancement + mlanutl mlan0 tcpackenh 1 1 : Enable TCP ACK enhancement and + configure TCP ACK drop percentage to 50% + mlanutl mlan0 tcpackenh 1 2 : Enable TCP ACK enhancement and + configure TCP ACK drop percentage to 67% + mlanutl mlan0 tcpackenh 1 3 : Enable TCP ACK enhancement and + configure TCP ACK drop percentage to 75% + mlanutl mlan0 tcpackenh 1 4 : Enable TCP ACK enhancement and + configure TCP ACK drop percentage to 80% + mlanutl mlan0 tcpackenh 1 5 : Enable TCP ACK enhancement and + configure TCP ACK drop percentage to 83% + mlanutl mlan0 tcpackenh 1 6 : Enable TCP ACK enhancement and + configure TCP ACK drop percentage to 85% + mlanutl mlan0 tcpackenh 1 7 : Enable TCP ACK enhancement and + configure TCP ACK drop percentage to 87.5% + mlanutl mlan0 tcpackenh 1 8 : Enable TCP ACK enhancement and + configure TCP ACK drop percentage to 88.8% + +host_tdls_config + This command is used to support channel switch and uapsd for host based tdls + + Usage: + mlanutl mlanX host_tdls_config + + + Where the parameter is: + host_tdls.conf: The configuration file specifying to enable/disable uapsd/cs and related parameters. + + Examples: + mlanutl mlan0 host_tdls_config config/host_tdls.conf + : enable or disable uapsd/cs, config the channel related ie, based on the configuration file. +tdls_channel_switch + This command is used to send TDLS channel switch request. + + Usage: + mlanutl mlanX tdls_channel_switch + + Where the parameter is: + tdls.conf: The configuration file for sending TDLS channel switch command. + + Examples: + mlanutl mlan0 tdls_channel_switch config/tdls.conf + : Send TDLS channel switch command, based on the configuration file. + +tdls_config + This command is used to enable/disable TDLS on device. + + Usage: + mlanutl mlanX tdls_config <0/1> + + Where the parameter is: + 0: Enable TDLS. + 1: Disable TDLS. + + Examples: + mlanutl mlan0 tdls_config 0 : Disable TDLS + mlanutl mlan0 tdls_config 1 : Enable TDLS + +tdls_cs_params + This command is used to set TDLS channel switch params + + Usage: + mlanutl mlanX tdls_cs_params + + Where the parameter is: + tdls.conf: The configuration file specifying the TDLS channel switch params. + + Examples: + mlanutl mlan0 tdls_cs_params config/tdls.conf + : Set TDLS channel switch params, based on the configuration file. + +tdls_debug + This command is used for FW debug functionality and tests. + +tdls_disable_cs + This command is used to disable TDLS channel switch + + Usage: + mlanutl mlanX tdls_disable_cs + + Where the parameter is: + tdls.conf: The configuration file to disable TDLS channel switch. + + Examples: + mlanutl mlan0 tdls_disable_cs config/tdls.conf + : Disable TDLS channel switch, based on the configuration file. + +tdls_discovery + This command is used to request TDLS discovery. + + Usage: + mlanutl mlanX tdls_discovery + + Where the parameter is: + tdls.conf: The configuration file to request TDLS discovery. + + Examples: + mlanutl mlan0 tdls_discovery config/tdls.conf + : Request TDLS discovery based on the configuration file. + +tdls_link_status [peer_mac_address] + This command is used to get link information about TDLS links or + a TDLS link correponding to peer mac address. + + Usage: + mlanutl mlanX tdls_link_status + + Where the parameter is: + tdls.conf: The configuration file to send TDLS command to get current link status. + + Examples: + mlanutl mlan0 tdls_link_status config/tdls.conf + : Send TDLS command to get current link status based on the configuration file. + +tdls_powermode + This command is used to send TDLS powermode request. + + Usage: + mlanutl mlanX tdls_powermode + + Where the parameter is: + tdls.conf: The configuration file for sending TDLS powermode command. + + Examples: + mlanutl mlan0 tdls_powermode config/tdls.conf + : Send TDLS powermode (either 0:Active, 1:PowerSave) command, based on the configuration file. + +tdls_setinfo + This command is used for setting the capabilities of the TDLS station. + + Usage: + mlanutl mlanX tdls_setinfo + + Where the parameter is: + tdls.conf: The configuration file specifying the capabilities of the TDLS station. + + Examples: + mlanutl mlan0 tdls_setinfo config/tdls.conf + : Set capabilities of the TDLS station, based on the configuration file. + +tdls_setup + This command is used to send TDLS setup request. + + Usage: + mlanutl mlanX tdls_setup + + Where the parameter is: + tdls.conf: The configuration file for sending TDLS setup request. + + Examples: + mlanutl mlan0 tdls_setup config/tdls.conf + : Send TDLS setup request, based on the configuration file. + +tdls_stop_channel_switch + This command is used to send stop TDLS channel switch request. + + Usage: + mlanutl mlanX tdls_stop_channel_switch + + Where the parameter is: + tdls.conf: The configuration file for sending stop TDLS channel switch command. + + Examples: + mlanutl mlan0 tdls_stop_channel_switch config/tdls.conf + : Send stop TDLS channel switch command, based on the configuration file. + +tdls_teardown + This command is used to send TDLS teardown request. + + Usage: + mlanutl mlanX tdls_teardown + + Where the parameter is: + tdls.conf: The configuration file for requesting teardown of TDLS link. + + Examples: + mlanutl mlan0 tdls_teardown config/tdls.conf + : Request teardown of TDLS link, based on the configuration file. + +hal_phy_cfg + This command is used to set the hal/phy related config parameters + + Usage: + mlanutl mlanX/uapX hal_phy_cfg + + Where the parameter is: + hal_phy_cfg.conf: The configuration file specifying to the values of hal/phy related config parameters + + Examples: + mlanutl mlan0 hal_phy_cfg config/hal_phy_cfg.conf + : to enable or disable 11b_psd_mask the file would contain following paramters + hal_phy_cfg{ + 11b_psd_mask_cfg=1 # 1: 11b_psd_mask_enable, 0: 11b_psd_mask_disable + } + +thermal + This command is used to get the current thermal reading. + + Examples: + mlanutl mlan0 thermal : Get thermal reading + +ts_status + This command queries the FW for the status of TSIDs 0 through 7 + configured via call admission control and displays the results in a + table. + + Usage: + mlanutl mlanX ts_status + +tsf + Set/Get the TSF timer value for the station. Station maintains a TSF timer with + modulus 2^64 counting in increments of microseconds. + + Usage: + mlanutl mlanX/uapX tsf [t] + + where, + [t] : 64bit timestamp value in microseconds + + Examples: + mlanutl mlan0 tsf : Get timestamp + mlanutl uap0 tsf 669468581993 : Set timestamp + +txaggrctrl + This command is used to enable/disable TX AMPDU on infra link when TDLS link is established + + Usage: + mlanutl mlanX txaggrctrl [m] + + Where: + [m]: 1 to enable TX AMPDU on infra link; 0 to disable TX AMPDU on infra link + + Examples: + mlanutl mlan0 txaggrctrl : Get current TX AMPDU status on infra link + mlanutl mlan0 txaggrctrl 0 : Disable TX AMPDU on infra link + mlanutl mlan0 txaggrctrl 1 : Enable TX AMPDU on infra link + + Note: + The set command only works when TDLS link is established. + +txbufcfg + This command can be used to get current buffer size. + + eg: + mlanutl mlanX txbufcfg - This will display the current buffer size. + + Note:- The actual tx buf size will depends on AP's capability and max transmit buffer size. + +opermodecfg + This command is used to set and get 11ac Operating Mode Notification configuration. + + where is + - This is the channel width setting for the opermodecfg + 1: 20MHz + 2: 40MHz + 3: 80MHz + 4: 160MHz or 80+80MHz + + where is + - This parameter specifies the nss that the STA can receive. + 1: NSS1 + 2: NSS2 + 3: NSS3 + 4: NSS4 + 5: NSS5 + 6: NSS6 + 7: NSS7 + 8: NSS8 + +wakeupreason + This command is used to get the host sleep wakeup reason. + + Usage: + mlanutl mlanX wakeupreason + mlanutl uapX wakeupreason + Examples: + mlanutl mlan0 wakeupreason : Get the host sleep wakeup reason + mlanutl uap0 wakeupreason : Get the host sleep wakeup reason + 0: unknown + 1: Broadcast data matched + 2: Multicast data matched + 3: Unicast data matched + 4: Maskable event matched + 5. Non-maskable event matched + 6: Non-maskable condition matched (EAPoL rekey) + 7: Magic pattern matched + 8: Control frame matched + 9: Management frame matched + Others: reserved. (0) + +warmreset + This command is used for warm reset of the interface. + + Usage: + mlanutl mlanX warmreset + +wpssession + This command is used to control wps session. No argument is used to get. + + where value of n is: + 0 -- Disable + 1 -- Enable + + Examples: + mlanutl mlan0 wpssession 1 : Enable wpssession + mlanutl mlan0 wpssession : Get wpssession status + +wmmcfg + This command is used to control WMM. No argument is used to get. + + where value of n is: + 0 -- Disable + 1 -- Enable + + Examples: + mlanutl mlan0 wmmcfg 1 : Enable WMM + mlanutl mlan0 wmmcfg : Get WMM status + +wmmparamcfg + This command is used to configure WMM paramameters. + + Usage: + mlanutl mlanX wmmparamcfg [AC_BE AIFSN ECW_MAX ECW_MIN TX_OP] + [AC_BK AIFSN ECW_MAX ECW_MIN TX_OP] + [AC_VI AIFSN ECW_MAX ECW_MIN TX_OP] + [AC_VO AIFSN ECW_MAX ECW_MIN TX_OP] + + The supported option are: + AC_BE: 0 + AC_BK: 1 + AC_VI: 2 + AC_V0: 3 + AIFSN: AIFSN value + ECW_MAX: ECW max + ECW_MIN: ECW min + TX_OP: TXOP Limit + empty - Get current WMM parameters + + Example: + mlanutl mlanX wmmparamcfg 0 3 10 4 0 + Set AC_BE with AIFSN 3, ECW_MAX 10, ECW_MIN 4 and TXOP 0 + + mlanutl mlanX wmmparamcfg 1 7 10 4 0 + Set AC_BK with AIFSN 7, ECW_MAX 10, ECW_MIN 4 and TXOP 0 + + mlanutl mlanX wmmparamcfg 2 2 4 3 94 + Set AC_VI with AIFSN 2, ECW_MAX 4, ECW_MIN 3 and TXOP 94 + + mlanutl mlanX wmmparamcfg 3 2 3 2 47 + Set AC_VO with AIFSN 2, ECW_MAX 3, ECW_MIN 2 and TXOP 47 + + mlanutl mlanX wmmparamcfg + Get current WMM parameters + + mlanutl mlanX wmmparamcfg 0 3 10 4 0 1 7 10 4 0 2 2 4 3 94 3 2 3 2 47 + Set AC_BE with AIFSN 3, ECW_MAX 10, ECW_MIN 4 and TXOP 0 + Set AC_BK with AIFSN 7, ECW_MAX 10, ECW_MIN 4 and TXOP 0 + Set AC_VI with AIFSN 2, ECW_MAX 4, ECW_MIN 3 and TXOP 94 + Set AC_VO with AIFSN 2, ECW_MAX 3, ECW_MIN 2 and TXOP 47 + +wwscfg + This command is used to set/get the WWS (World Wide Safe) mode. + + where value of m is: + 0 -- Disable WWS mode (default) + 1 -- Enable WWS mode + + Examples: + mlanutl mlan0 wwscfg : Get WWS mode + mlanutl mlan0 wwscfg 1 : Enable WWS mode + mlanutl mlan0 wwscfg 0 : Disable WWS mode + +mc_cfg + This command is used to set/get the channel time. + + Usage: + mlanutl mlanX mc_cfg [n] + + where : Channel time in microseconds. + + Examples: + mlanutl mlanX mc_cfg : Get Channel time and buffer weight. + mlanutl mlanX mc_cfg 10000 : Set Channel time to 10000us. + +mc_policy + This command is used to set/get the multi-channel policy. + Note: This is a device specific command. Hence, setting on one interface is + reflected on all other interfaces. + + Usage: + mlanutl mlanX mc_policy [n] + + where : Multi-channel policy + + Examples: + mlanutl mlanX mc_policy : Get multi-channel policy setting. + mlanutl mlanX mc_policy 1 : Set multi-channel policy to 1. + mlanutl mlanX mc_policy 0 : Disable multi-channel policy + +mc_cfg_ext + This command is used to set/get the drcs parameters. + + Usage: + mlanutl mlanX mc_cfg_ext [c] [s] [u] [m] + + where: + channel index0: + [c] : chantime(in TU) + [s] : switchtime(in TU) + [u] : undozetime(in TU) + [m] : mode :0x0 --- PM1(default) + 0x1 --- Null2Self + channel index1: + : chantime(in TU) + : switchtime(in TU) + : undozetime(in TU) + : mode :0x0 --- PM1(default) + 0x1 --- Null2Self + Note: + channel index0: the first channel + channel index1: the second channel + undozetime should be less than other channel's switchtime + If want to set two channels the same parameters, just ignore the last four parameters and + use [c] [s] [u] [m] to set. + Examples: + mlanutl mlanX mc_cfg_ext : Get the drcs parameters for two channels. + mlanutl mlanX mc_cfg_ext 15 10 5 0 : Set two channels:channeltime 15TU, switchtime 10TU, undozetime 5TU, mode PM1 + mlanutl mlanX mc_cfg_ext 15 10 5 0 25 15 9 0 : Set channel index0: channeltime 17TU, switchtime 10TU, undozetime 5TU, mode PM1; + set channel index1: channeltime 25TU, switchtime 15TU, undozetime 9TU, mode PM1. + +cfg_noa + This is used to get/set P2P NoA (Notice of Absence) parameters only for P2P GO. + + Usage: + mlanutl p2pX cfg_noa [h] [i] [j] [k] [l] + + where: + [h] : noa_enable : 1/0 Set to 1 to enable NoA, 0 to disable NoA. + [i] : index : 0 - 255 Identifies an instance of NoA timing. + [j] : count : 1 - 255 Indicates the number of absence intervals. + 255 means a continuous schedule. + [k] : duration : Indicates the maximum duration in units of microseconds + that P2P GO can remain absent following the start of + a NoA interval. + [l] : interval : Indicates the length of the NoA interval in units of + microseconds. + + Examples: + mlanutl p2pX cfg_noa : Get noa configuration. + mlanutl p2pX cfg_noa 1 1 255 50 100 : Set noa configuration. + +cfg_opp_ps + This is used to get/set P2P OPP-PS parameters only for P2P GO. + + Usage: + mlanutl p2pX cfg_opp_ps [m] [n] + + where: + [m] : ps_enable : 1/0 Set to 1 to indicate P2P GO is using opportunistic + power save. Set to 0 if opportunistic power save is disabled. + [n] : ct_window : A period of time in TU after a TBTT during which P2P GO + is present. 0 indicates that there shall be no + CTWindow (Client Traffic Window). + + Examples: + mlanutl p2pX cfg_opp_ps : Get noa configuration. + mlanutl p2pX cfg_opp_ps 1 7 : Set noa configuration. + +get_sensor_temp + This command is used to get SOC temperature + Usage: + mlanutl mlanX get_sensor_temp +11k_enable + This command is used to control 11K. No argument is used to get. + only available when disconnected. + + where value of n is: + 0 -- Disable + 1 -- Enable + + Examples: + mlanutl mlan0 11k_enable 1 : Enable 11k + mlanutl mlan0 11k_enable : Get 11k status + +neighbor_report + This command is used to get neighbor AP list. + You can open mlanevent to show the AP list result before issue this command. + + Usage: + mlanutl mlanX neighbor_report + +indrstcfg + This command is used to set/ get independent reset mode configuration + + Usage : + mlanutl indrstcfg [gpio_pin] + + interface : mlanX, uapX + ir_mode : 0 -- Disable + 1 -- Enable out band reset, disable in band + 2 -- Enable in band, disable out band + gpio_pin : 255 -- Default pin for reset + any other number for changing the gpio for reset. + + Example : + mlanutl mlan0 indrstcfg 1 255 : Set default pin on interface mlan0 as reset pin + mlanutl mlan0 indrstcfg 0 : Disable the gpio 17 as reset pin on interface mlan0 + mlanutl mlan0 indrstcfg : Get the status and the pin used for reset pin + mlanutl mlan0 indrstcfg 2 : Enable in band reset mode + +ctrldeauth + This command is used to set/get firmware ctrldeauth setting + Usage : + mlanutl uapX/mlanX ctrldeauth + + Where value of n is : + 0 -- Firmware will use default behavior + 1 -- Firmware will not send deauth packet when uap move to another channel. + 2 -- Firmware will send deauth before auth in STA mode + and after successful roam to another AP. + + Example : + mlanutl uap0 ctrldeauth : Get current setting + mlanutl uap0 ctrldeauth 1 : Firmware will not send deauth packet when uap move to different channel. + mlanutl mlan0 ctrldeauth 2 : Firmware will send deauth before auth in STA mode + and after successful roam to another AP + +robustcoex + This command is used to set robust coex. + + Usage : + mlanutl robustcoex [Enable/Disable] [gpionum] [gpiopolarity] + Enable/Disable : 0 -- Disable ; 1 -- Enable + gpionum : Number of gpio + gpiopolarity : polarity of gpio + + Example : + mlanutl mlan0 robustcoex gpiocfg 1 4 1 : Enable robustcoex gpio, set gpionum to 4 and gpiopolarity to 1 + mlanutl mlan0 robustcoex gpiocfg 0 : Disable robustcoex gpio + +cwmode + This command is used to set Cont. Tx/Wave mode. + + Usage: + mlanutl cwmode config/cwmode.conf + interface: mlanX + cwmode.conf: This config file specifies whether to enable/disable Cont Tx/Wave mode. + User can specify parameters like Channel, datarate, BW, Channel Offset, Band. + Detailed information about parameters is mentioned in the conf file. + Example: + mlanutl mlan0 cwmode config/cwmode.conf : Enable/Disable Cont Tx/Wave mode. + mlanutl mlan0 cwmode : Get current Tx mode + +bootsleep + This command is used to set and get boot sleep configure. + + Usage : + mlanutl mlanX/uapX bootsleep + : enable boot sleep + : 0 - disable boot sleep + : 1 - enable boot sleep + + Example : + mlanutl mlan0/uap0 bootsleep 1 : Enable boot sleep + mlanutl mlan0/uap0 bootsleep : Get boot sleep configure + +ssu + Collect spectral analysis data and save them into /data/ssudump.txt + + Usage : + mlanutl mlanX ssu [mode] [ssu file] + + mode : 2 -- Enable ssu and use FW default ssu parameter + ssu file : file to config ssu parameter + + Example : + mlanutl mlan0 ssu :Enable SSU and use driver default ssu parameter + mlanutl mlan0 ssu config/ssu.conf :Enable SSU and use ssu parameter from ssu.conf + mlanutl mlan0 ssu 2 :Enable SSU and use FW default ssu parameter + +csi + Enable/disable channel state information collection + + Usage : + mlanutl mlanX csi + disable : 0 + enable : config file with csi filters + + Example : + mlanutl mlan0 csi config/csi.conf : Enable CSI + mlanutl mlan0 csi 0 : Disable CSI + +arb + Set HW ARB mode + The command needs to be issued before association. + + Usage: + mlanutl mlanX arb [mode] + + where the parameter is: + [mode]: + 0: arb mode 0 (default) + 1: arb mode 1 + 2: arb mode 2 + 3: arb mode 3 (Improve TX throughput) + 4: arb mode 4 (Improve RX throughput) + + Example : + mlanutl mlan0 arb 1 : Set HW ARB mode 1 + +dmcs + This command is used to config DMCS or get DMCS status. + + Usage: + mlanutl mlanX dmcs [value] + + : config mapping policy + disable dynamic mapping when [value = 0] + enable dynamic mapping when [value = 1] + : get DMCS status + + Example : + mlanutl mlan0 dmcs 0 1 : Enable dynamic mapping + mlanutl mlan0 dmcs 0 0 : Disable dynamic mapping + mlanutl mlan0 dmcs 1 : Get DMCS status + +range_ext + This command is used to config range extension mode. + + Usage: + mlanutl mlanX/uapX range_ext [mode] + + where the parameter is: + [mode]: + 0: Default Mode(Auto Rate) + 1: HE ER+DCM Mode + 2: Legacy Mode(1 Mbps Rate) + + Example: + mlanutl mlan0 range_ext : get range extension mode + mlanutl mlan0 range_ext 1 : set range extension mode to HE ER+DCM mode + +twt_setup + This command is used to config TWT setup parameters using conf file. + + Usage: + mlanutl mlanX twt_setup [conf file] + + Example: + mlanutl mlan0 twt_setup config/twt.conf + +twt_teardown + This command is used to config TWT teardown parameters using conf file. + + Usage: + mlanutl mlanX twt_teardown [conf file] + + Example: + mlanutl mlan0 twt_teardown config/twt.conf + +twt_report + This command is used to get BTWT id's/schedules. + + Usage: + mlanutl mlanX twt_report + + Example: + mlanutl mlan0 twt_report + +rx_abort_cfg + This command is used to set/get static rx abort config for pkt having + weaker RSSI than threshold. This threshold will be overwritten on starting + dynamic rx abort cfg ext. + + Usage: + mlanutl rx_abort_cfg [enable] [rssi_threshold] + + Where the parameters are: + : mlanX, + uapX + [enable] : 0 - Disable Rx abort + 1 - Enable Rx abort of pkt having weak RSSI + [rssi_threshold] : weak RSSI pkt threshold in dBm (absolute value) + (default = 70) + + Examples: + mlanutl mlan0 rx_abort_cfg + - Display current rx abort configuration + mlanutl uap0 rx_abort_cfg 1 60 + - Enable rx abort and set weak RSSI Threshold to -60 dBm + mlanutl mlan0 rx_abort_cfg 1 40 + - Enable rx abort and set weak RSSI Threshold to -40 dBm + mlanutl mlan0 rx_abort_cfg 0 + - Disable rx abort +rx_abort_cfg_ext + This command is used to set/get dynamic rx abort config. This will set + threshold based on minimum of ceiling rssi threshold and the weakest + RSSI among all connected peers. Margin can be specified as an offset to + this threshold. Default margin is set to -10 dBm. Ceiling rssi threshold + can be changed by specifying. Default ceil is set to EDMAC based threshold + if EDMAC is enabled otherwise set to -62 dBm if EDMAC is disabled. + Floor rssi threshold value can also be specified to cap the weakest rssi. + Default floor rssi value is set to -82 dBm. + If thresholds are set via this command, they will take precedence over default + values. Provision is provided to restore deafault values (see examples below). + + This will be disabled on enabling fixed rx abort (rx_abort_cfg) + Note: This dynamic rx abort mode is enabled by default. + + Usage: + mlanutl rx_abort_cfg_ext [enable] [margin ceil_thresh floor_thresh] + + Where the parameters are: + : mlanX, + uapX + [enable] : 0 - Disable Rx abort + 1 - Enable Rx abort of pkt having weak RSSI + [margin] : rssi margin in dBm (absolute val) + (default = 10) + [ceil_thresh] : ceiling weak RSSI pkt threshold in dBm + (absolute value) (default = 70) + [floor_thresh] : floor weak RSSI pkt threshold in dBm + (absolute value) (default = 82) + + Examples: + mlanutl mlan0 rx_abort_cfg_ext + - Display current rx abort configuration + mlanutl uap0 rx_abort_cfg_ext 1 10 60 + - Enable dynamic rx abort, set margin to -10 dBm and set ceil + RSSI Threshold to -60 dBm + mlanutl uap0 rx_abort_cfg_ext 1 10 75 85 + - Enable dynamic rx abort, set margin to -10 dBm and set ceil + RSSI Threshold to -70 dBm, set floor RSSI Threshold to -85 dBm + mlanutl uap0 rx_abort_cfg_ext 1 10 0xff + - Enable dynamic rx abort, set margin to -10 dBm and set ceil value + to default, based on EDMAC enabled or disabled status + mlanutl mlan0 rx_abort_cfg_ext 1 5 50 + - Enable dynamic rx abort, set margin to -5 dBm and set ceil + RSSI Threshold to -50 dBm + mlanutl mlan0 rx_abort_cfg_ext 0 + - Disable dynamic rx abort + +nav_mitigation + This command is used to set/get NAV migration parameters NAV mitigation status and duration threshold in us. + threshold value will be ignored if start_nav_mitigation is passed as 0. + In case start_nav_mitigation and threshold are not passed then nav_mitigation command will return below parameters: + Current NAV mitigation status + Current NAV mitigation duration threshold in us + Counter for NAV mitigation detected + Counter for NAV mitigation stopped + + Usage: + mlanutl nav_mitigation [start_nav_mitigation] [threshold] + + Where the parameters are: + : mlanX, + uapX + [start_nav_mitigation] : 0 - Stop NAV mitigation + 1 - Start NAV mitigation + [threshold] : Duration value in us to set as threshold + + Examples: + mlanutl mlan0 nav_mitigation + - Display the values for below parameters: + Current NAV mitigation status (stopped:0, started:1) + Current NAV mitigation threshold in us + Counter for NAV mitigation detected + Counter for NAV mitigation stopped + mlanutl uap0 nav_mitigation 0 + - Stop the NAV mitigation for given interface + mlanutl uap0 nav_mitigation 1 6000 + - Start the NAV mitigation for given interface with threshold 6000us + + mlanutl mlan0 nav_mitigation 0 + - Stop the NAV mitigation for given interface + mlanutl mlan0 nav_mitigation 1 6000 + - Start the NAV mitigation for given interface with threshold 6000us + +tx_ampdu_prot_mode + This command is used to set either RTS/CTS or CTS2SELF protection mechanism + in MAC, for aggregated Tx QoS data frames. RTS/CTS is enabled by default. + + Usage: + mlanutl tx_ampdu_prot_mode [mode] + + Where the parameters are: + : mlanX, + uapX + [mode] : 0 - Set RTS/CTS mode + 1 - Set CTS2SELF mode + 2 - Disable Protection mode + 3 - Set Dynamic RTS/CTS mode + + Examples: + mlanutl mlan0 tx_ampdu_prot_mode + - Get currently set protection mode for Tx AMPDU + mlanutl mlan0 tx_ampdu_prot_mode 1 + - Set protection mode for Tx AMPDU to CTS2SELF + +rate_adapt_cfg + This command is used to switch between SR rateadapt and Legacy rateadapt. + FW default Algorithm is Legacy rateadapt + when SR rateadapt is enabled then it is used to set static threshold based + or dynamic noise based rate adaptation and set the timer interval to evaluate + sw rate adaptation.For static mode, low and high thresholds for Tx aggregated + pkt success rate should be configured. The Tx rate will decrease if success rate + goes lower than LOW_THRESH, will increase if it goes beyond HIGH_THRESH, and will + remain the same when success rate is between these thresholds.To set dynamic mode, + specify 0xff for both low and high thresh. + + Note: config can be set only before associating with an external AP + when in STA mode, or before starting bss when in uAP mode + + Usage: + mlanutl rate_adapt_cfg + [sr_rateadapt low_thresh high_thresh timer_interval] + + Where the parameters are: + : mlanX, + uapX + [sr_rateadapt] : SR Rateadapt or Legacy Rateadapt + [low_thresh] : lower tx success rate threshold + [high_thresh] : higher tx success rate threshold + [timer_interval] : interval to evaluate tx rate in sw in multiples + of 10 (ms) + + Examples: + mlanutl mlan0 rate_adapt_cfg + - Display SR rateadapt or Legacy rateadapt enabled + - Display current rate adapt configuration if SR rateadapt is enabled. + mlanutl uap0 rate_adapt_cfg 1 60 80 10 + - set lower Tx success rate threshold to 60%, higher to 80% + and evaluate tx rate every 100 ms (i.e 10 * 10 = 100 ms) + when SR Rateadapt is enabled. + mlanutl mlan0 rateadapt_cfg 0 + - switch to Legacy rateadapt. + mlanutl mlan0 rateadapt_cfg 1 + - switch to SR rateadapt. + Fw default is dynamic Success threshold enabled + with 100 ms linkadapt timer. + mlanutl mlan0 rate_adapt_cfg 1 50 70 50 + - set lower Tx success rate threshold to 50%, higher to 70% + and evaluate tx rate every 500 ms (i.e 50 * 10 = 500 ms) + when SR Rateadapt is enabled. + mlanutl mlan0 rate_adapt_cfg 1 0xff 0xff 10 + - set dynamic environment noise based mode and evaluate tx rate + every 100 ms (i.e 10 * 10 = 100 ms) + when SR Rateadapt is enabled. + +cck_desense_cfg + This command is used to configure CCK (802.11b) Desensitization RSSI + threshold. All CCK traffic beyond this threshold will be ignored, resulting + in higher Tx throughput. Threshold value is in absolute value of rssi in + dBm. In dynamic and enhanced modes, cck desense will be turned on only in + presence of an active connection and the effective CCK desense RSSI + threshold will be updated every rateadapt interval, based on: + min{ceil_thresh, [min RSSI among all connected peers] - margin} + + Further, for dynamic enhanced mode, CCK desense will be turned on/off based + on environment noise condition and ongoing Tx traffic rate. In this mode, + CCK desense will also be turned off periodically in order to allow 802.11b + Rx frames from Ext-AP, if rx rssi becomes weaker than the current threshold + or when in uAP mode, frames from clients which attempt to connect with the + uAP, but have weaker RSSI than the set threshold. + Turn on and off intervals are specified in terms of rateadapt intervals. + Please note that in this mode, if dynamic Rx Abort is enabled, then it + will turn on/off in sync with cck desense. + + Usage: + mlanutl cck_desense_cfg [mode] [margin ceil_thresh] + [num_on_intervals num_off_intervals] + + Where the parameters are: + : mlanX, + uapX + [mode] : 0 - Disable cck desense + 1 - Enable dynamic cck desense mode + 2 - Enable dynamic enhanced cck desense mode + [margin] : rssi margin in dBm (absolute val) + (default = 10) + [ceil_thresh] : ceiling weak RSSI pkt threshold in dBm + (absolute value) (default = 70) + [num_on_intervals] : number of rateadapt intervals to keep cck + desense "on" [for mode 2 only] (default = 20) + [num_off_intervals]: number of rateadapt intervals to keep cck + desense "off" [for mode 2 only] (default = 3) + + Examples: + mlanutl mlan0 cck_desense_cfg + - Display current cck desense configuration + mlanutl uap0 cck_desense_cfg 1 10 70 + - Set dynamic mode, margin to -10 dBm and ceil RSSI Threshold to + -70 dBm + mlanutl uap0 cck_desense_cfg 2 10 60 30 5 + - Set dynamic enhanced mode, margin to -10 dBm, ceil RSSI Threshold + to -60 dBm, num on intervals to 30 and num off intervals to 5. + mlanutl mlan0 cck_desense_cfg 1 10 50 + - Set dynamic mode, margin to -10 dBm and ceil RSSI Threshold to + -50 dBm + mlanutl mlan0 cck_desense_cfg 2 5 60 + - Set dynamic enhanced mode, set margin to -5 dBm, set ceil RSSI + Threshold to -60 dBm, and retain previous num on/off intervals + setting. + mlanutl mlan0 cck_desense_cfg 0 + - Disable cck desense + +lpm + This command is used to configure low power mode. + + Usage: + mlanutl mlanX/uapX lpm [mode] + + Where the paramter is: + [mode] : low power mode 0, 1, 2, 3 + + Examples: + mlanutl mlan0 lpm Get low power mode + mlanutl mlan0 lpm 1 Set low power mode to 1 + +dot11mc_unassoc_ftm_cfg + This command is used to enable or disable the configuration for + DOT11MC FTM frames exchanges in un-associated state for STA or uAP + + Usage: + mlanutl dot11mc_unassoc_ftm_cfg [enable] + + Where the parameters are: + : mlanX, + uapX + [enable] : 0 - Disable unassociated state FTM + 1 - Enable unassociated state FTM + + Examples: + mlanutl mlan0 dot11mc_unassoc_ftm_cfg + - Get current state of unassociated state FTM cfg + mlanutl mlan0 dot11mc_unassoc_ftm_cfg 1 + - Set the unassociated state FTM cfg to Enabled + +clocksync + This command is used to set and get WIFI TSF based clock sync setting + + Usage: + mlanutl mlanX/uapX clocksync [j][k] [l] [m] [n] + + where + [j] mode + - This parameter use to configure GPIO TSF latch mode + 0: GPIO level + 1: GPIO toggle + 2: GPIO toggle on Next Beacon. + [k] role + + 0: when mode set to 0 or 1 + 1: AP + 2: STA + [l] gpio pin number + [m] GPIO Level/Toggle + mode = 0 + 0: low 1: high + mode = 1 or 2 + 0: low to high + 1: high to low + [n] GPIO pulse width + mode = 0, reserved, set to 0 + mode 1 or 2 + 0: GPIO remain on toggle level (high or low) + Non-0: GPIO pulse width in microseconds (min 1 us) + + If no parameter provided, get is performed. + + Examples: + mlanutl mlan0 clocksync 0 0 5 0 0 + mlanutl mlan0 clocksync 1 0 10 1 500 + mlanutl mlan0 clocksync 1 0 5 0 0 + mlanutl mlan0 clocksync 2 1 10 1 500 + mlanutl mlan0 clocksync 2 2 3 0 0 + mlanutl mlan0 clocksync + +gettsfinfo + This command is used to get TSF info + + Usage: + mlanutl mlanX gettsfinfo [j] + where + [j] format + 0: Report GPIO assert TSF + 1: Report Beacon TSF and Offset (valid if CONFIG Mode 2) + + Examples: + mlanutl mlan0 gettsfinfo Get GPIO assert TSF + mlanutl mlan0 gettsfinfo 1 Get Beacon TSP and Offset (valid if CONFIG mode 2) + +targetchan + This command is used to get/set target channel for UAP + + Usage: + mlanutl uaX targetchan [j] + where + [j] target channel + + Examples: + mlanutl uap0 targetchan Get current target channel + mlanutl uap0 targetchan 52 Set target channel to 52 +backuptchan + This command is used to get/set backup channel for UAP + + Usage: + mlanutl uaX backupchan [j] + where + [j] backup channel + + Examples: + mlanutl uap0 backupchan Get current backup channel + mlanutl uap0 backupchan 52 Set backup channel to 52 + +ips_cfg + This command is used to get/set IPS + + Usage: + mlanutl mlanX ips_cfg [1/0] + + Examples: + mlanutl mlan0 ips_cfg Get current IPS config + mlanutl mlan0 ips_cfg 1 Enable IPS + +turbo_mode + + This command is used to set/get turbo mode. + + Usage: + ./mlanutl mlan0 turbo_mode + ./mlanutl mlan0 turbo_mode + can be 0,1,2,3,4 + + Examples: + ./mlanutl mlan0 turbo_mode 2 : sets turbo_mode to 2 + ./mlanutl mlan0 turbo_mode : gets the current turbo_mode + +getuuid + This command is used to read 16 byte uuid for a given interface and uuid remains same for + + Usage: + ./mlanutl getuuid + + Examples: + i/p: mlanutl uap0 getuuid + o/p: uuid: a0b0c0d0d0c0b0a0a0b0c0d0d0c0b0a0 + +crosssynch + This command is used to start and stop cross chip TSF synch feature + + Usage: + mlanutl uapX crosssynch [j][k] [l] [m] [n] + + where + [j] Start_stop: + - This parameter use to start of stop feature + 0: stop + 1: start + [k] Role: + 1: Master + 2: Slave + [l] period: Periodicity of toggle in us + [m] InitTSF_Low: Initial TSF, low dword + [n] InitTSF_high: Initial TSF, high dword + +Examples: + mlanutl uap0 crosssynch // Get params + mlanutl uap0 crosssynch 1 1 0xC8 0x40000 0 // start master + mlanutl uap0 crosssynch 1 2 0xC8 0x40000 0 // start slave + +wlan_tsp_cfg + This command is used to set and get the TSP configuraion. + This command also reads out CAU TSEN and RFU temperature registers + + Usage: + mlanutl mlanX/uapX wlan_tsp_cfg [j] [k] [l] [m] [n] [o] [p] [q] + + where: + [j] enable: + This parameter used to start or stop the TSP feature + 0: disable + 1: enable + [k] backoff: + Power backoff [0...10] + [l] highThreshold : High power Threshold [0...300] + [m] lowThreshold : Low power Threshold [0...300] + [n] duty_cyc_step : Duty Cycle setp [1...100] + [o] duty_cyc_min : Duty Cycle min [0...100] + [p] high_thrshld_temp : High Threshold temperature [-100 ....150] + [q] low_thrshld_temp : Low Threshold temperature [-100.... 150] + + highThreshold must be greater than lowThreshold. + High Threshold temperature must be greater than Low Threshold temperature. + +Examples: + mlanutl mlanX/uapX wlan_tsp_cfg 1 2 100 50 // enable TSP with some basic parameter values + mlanutl mlanX/uapX wlan_tsp_cfg // Get TSP config parameter values + mlanutl mlanX/uapX wlan_tsp_cfg 0 // disable(if enable=1 is already set) + +led + This command is used to set/get LED behavior parameter such as led state, duty cycle index and + cycle length index for each firmware state. + Duty cycle index and cycle length index will be set only if led state is set to user defined(5). + In case no argument passed then led command will return led state, duty cycle and + cycle length for each firmware state. + + Usage: + mlanutl led m + + Where the parameters are: + : mlanX, + uapX + [m]: Enable or Disable + 0: Disable LED feature + 1: Enable LED feature with FW default / previously configured settings + + [n]: Firmware state + 0: reserved + 1: powersave + 2: scanning + 3: Data Tx/Rx + 4: Connected and Idle + 5: Disconnected + + [o]: Led state + 0: Off + 1: On + 2: Fast blink + 3: Slow blink + 4: Medium blink + 5: User defined + + If [o] < 5, then

and are not present. + If led state = 5: + [p]: Cycle length index + 0: 37ms + 1: 74ms + 2: 149ms + 3: 298ms + 4: 596ms + 5: 1192ms + + [q]: Duty Cycle index + 0: 1/2 + 1: 1/4 + 2: 1/8 + 3: 1/16 + 4: 1/32 + + Examples: + mlanutl mlan0 led + - Display Led feature enable/disable status + - If feature is enabled, display the below parameters for each firmware state: + Led state + Cycle length index (Cycle Length) + Duty cycle index (Duty Cycle) + + mlanutl mlan0 led 0 + - Disables the feature + mlanutl mlan0 led 1 + - Enables feature with FW default / previously configured settings + mlanutl mlan0 led 1 2 2 + - Fast blink on scanning + mlanutl mlan0 led 1 2 2 3 5 1 0 + - Fast blink on scanning, For data tx/rx: cycle length is 74ms, duty cycle is 1/2. + +auth_assoc_timeout_cfg + This command is used to set/get Auth, (Re)Assoc Timeout configuration parameters. + + Usage: + mlanutl mlanX auth_assoc_timeout_cfg + + Where the parameters are: + : Max waiting time before sending Auth Timeout + (value in ms, default 2400 ms, valid range: 500-2400). + : Timeout for each AuthFrame Retry. this should be under the cap of "auth_timeout". + This is when AP does Ack for AuthRequest but No Response from AP. + (value in ms, default: 300 ms, valid range: 50-300) + : Timeout for each AuthFrame Retry. This should be under the cap of "auth timeout". + This is when AP does not Ack for AuthRequest or AuthRequest Tx fails. + (value in ms, default: 80 ms, valid range: 40-80) + : Max waiting time before sending Assoc Timeout. This is always initial connection. + (value in ms, default: 1500 ms valid range: 200-1500) + : Max waiting time before sending Assoc Timeout. + This is valid only for Roam, not for initial connection. + (value in ms, default: 330, valid range: 100-1500) + : Timeout for each Assoc/ReAssoc frame retry if acked. + (value in ms, default: 150 ms, valid range: 50-150) + + Example: + mlanutl mlan0 auth_assoc_timeout_cfg + - Get the current auth_assoc_timeout_cfg configuration + mlanutl mlan0 auth_assoc_timeout_cfg 500 50 40 200 100 50 + +agcs + Enable a Agile Channel Switch feature. When the throughput of the current active channel is poor, it can automatically scan the candidate channel list, + select the best channel from it and complete the channel switch. + + Usage: + mlanutl uapX agcs [ARGS] + + Where [ARGS]: + mode=[bitmap] bit0: Enable Agile channel switching in CarPlay. + bit1: no specific interference type check, but only check Tx or Rx throughput drop. + "mode=0" means disable this feature. + There is no case of mode=0x2. To enable bit_1 to achieve the condition to bypass + interference type check, bit0 must also be enabled at the same time. + avg_th=[0~100] Adjust the weight of TX/RX average packet count, unit is percentage. + Default is 50%. + AGCS only per ch load on NH does not need this parameter. + rx_min_pkt=[value] The requires at least average rx packets per second. + Default is 850.(850 ~= 10e6/(1460*8), 10Mbps) + AGCS only per ch load on NH does not need this parameter. + tx_min_pkt=[value] The requires at least average tx packets per second. + Default is 430.(430 ~= 5e6/(1460*8), 5Mbps) + AGCS only per ch load on NH does not need this parameter. + sample_time=[ms] periodic monitoring time. Unit is ms. + Default is 500ms + sample_window=[window size] + The latest sampled windows size. + Default is 10. + AGCS only per ch load on NH does not need this parameter. + hit_cnt=[count] The number of times that Criteria 1 or Criteria 2 is reached continuously, + to avoid being too sensitive and triggering CS/ECS + Default is 2. + AGCS only per ch load on NH does not need this parameter. + nf_margin=[adjust value] + make sure a reasonable rate can be sustained. + Default is 25. + scan_dur=[ms] time to scan for candidate channels in milliseconds. + Default is 30ms. + chload_th=[0~100] Adjustable chload threshold. The chload of the newly selected channel will be + compared with this threshold to determine whether to switch channels. + csa_cnt=[value] Channel switch count. + chan=[chan#][band] User specified candidate scan channels, where band is [a,b,g,e]. + Default is 2g: 1, 6, 11 + 5g: 36, 40, 44, 48, 149, 153, 157, 161, 165 + 6g: 37 + To achieve better channel switching, it's better to contains all below kinds of channels if support. + (2g, 5g of 2 class, and 6g) + nav_mitigation_th=[value] Adjustable long duration pkts threshold. During each monitoring period, if the long duration pkts count + received is greater than the threshold, one of the conditions will be met. + AGCS only per ch load on NH does not need this parameter. + ch_th=[value] Adjustable channel load threshold to trigger channel switch. + If FW detect the channel load is bigger than this threshold, it will trigger scan and channel switch. + Default is 75. + This threshold is only used for agcs only per ch load on NH. + + Examples: + 1) Get agcs configuration: + mlanutl uap0 agcs + agcs param: mode=0 avg_th=50 rx_min_pkt=850 tx_min_pkt=430 s_time=500 s_cnt=10 hit_cnt=2 nf_margin=25 + + 2) Disable feature: + mlanutl uap0 agcs mode=0 + + 3) Enable with default parameters: + mlanutl uap0 agcs mode=1 + + 4) Enable with partial parameters: enable agcs, set sample_time to 500ms, set scan channel duration to 30ms, + and specify candidate scan channels as 6, 36, and 37. + mlanutl uap0 agcs mode=1 sample_time=500 scan_dur=30 chan=6g,36a,37e + +=============================================================================== +=============================================================================== + U S E R M A N U A L F O R Enable Scan GAP + +Following commands can be used to enable gap between scans. + +mlanutl mlanX scancfg [t] [m] [p] [s] [a] [b] [c] [ext] [gap] +mlanutl mlanX setuserscan [ARGS] + +For detail information, please refer the command description. +=============================================================================== diff --git a/README_RBC b/README_RBC new file mode 100644 index 0000000..68aa86c --- /dev/null +++ b/README_RBC @@ -0,0 +1,112 @@ +=============================================================================== + U S E R M A N U A L for Robust BT-WLAN coex (RBC) + + Copyright 2014-2020 NXP + +=============================================================================== + +############################### + +# Abbreviations and acronyms + +############################### +RBC - Robust BT-WLAN co-existence +TMD - Time Distribute +SMPS - Spatial Multiplexing Power Save + +############################### + +# Default RBC modes: + +############################### +1. For systems where BT and WLAN have seperate antennas, RBC mode is + automatically disabled in FW after detecting this from FEM cal data. e.g. + For 1x1 Dual-Ant system and 2x2 3-Ant system RBC mode is disabled. +2. For systems where BT and WLAN share an antenna, RBC mode is automatically + enabled in FW after detecting this from FEM cal data. + Default modes: + 1x1 single antenna system: TMD RBC + 2x2 2-antenna system: 1x1 SMPS RBC + + +################################# + +# 2x2 2-antenna system RBC modes + +################################# +There are three mutually exclusive RBC modes for a 2x2 system. +The default RBC mode is 1x1 SMPS RBC. The required RBC mode must be +configured before starting uAP or associating in-STA. The mode cannot be +changed dynamically when any of these connections is active. The modes are +described below: +1. 1x1 SMPS RBC mode: WLAN switches to 1x1 FEM when BT is turned on. Also, + in-STA goes to SMPS mode w.r.t. ext-AP. When BT is turned off, WLAN + switches back to 2x2 FEM setting and in-STA moves out of SMPS. + uAP starts bss with only 1-stream even BT is off because it cannot + dynamically move between 1-stream and 2-stream rates like in-STA. To start + uAP with 2-stream, RBC mode has to be disabled. +2. 1x2 SMPS RBC mode: Similar as 1x1 SMPS RBC mode. WLAN switches to 1x2 FEM + when BT is turned on. In this mode, it is expected that when BT is not + actively transmitting, WLAN can receive on both the antennas to enhance + the range. Note that 1-stream rates are used for receive and transmit. +3. 2x2 TMD RBC mode: WLAN uses 2x2 antenna setting and timeshares the antenna + with BT. + +############################### + +# RBC mode select: + +############################### + +User can use robust_btc.conf and hostcmd to select different RBC mode: + +hostcmd mode_get +hostcmd mode_timeshare +hostcmd mode_spatial + This command is used to get/set Robust BT Coex. + mode_get: get the current mode + mode_timeshare: set Robust BT Coex to timeshare mode (default on 1x1 chips) + mode_spatial: set Robust BT Coex to spatial mode (only for, and default on 2x2 chips) + + Usage: + mlanconfig mlanX hostcmd config/robust_btc.conf mode_get + mlanconfig mlanX hostcmd config/robust_btc.conf mode_timeshare + mlanconfig mlanX hostcmd config/robust_btc.conf mode_spatial + +hostcmd gpio_cfg + This command is used to enable/disable GPIO cfg. + gpio_cfg: enable/disable GPIO cfg for external bt request (default is enable with High Polarity) + + Usage: + mlanconfig mlanX hostcmd config/robust_btc.conf gpio_cfg + +hostcmd generictime +hostcmd a2dptime +hostcmd inquirytime +hostcmd ap_generictime +hostcmd ap_a2dptime +hostcmd ap_inquirytime + This command is used to configure the time slice of COEX (only works in timeshare mode) + generictime: configure the Bttime and Wlantime in Station Generic case + a2dptime: configure the Bttime and Wlantime in Station A2DP case + inquirytime: configure the Bttime and Wlantime in Station Inquiry case + ap_generictime: configure the Bttime and Wlantime in Ap Generic case + ap_a2dptime: configure the Bttime and Wlantime in Ap A2DP case + ap_inquirytime: configure the Bttime and Wlantime in Ap Inquiry case + + Usage: + mlanutl mlanX hostcmd config/robust_btc.conf generictime + mlanutl mlanX hostcmd config/robust_btc.conf a2dptime + mlanutl mlanX hostcmd config/robust_btc.conf inquirytim + mlanutl mlanX hostcmd config/robust_btc.conf ap_generictime + mlanutl mlanX hostcmd config/robust_btc.conf ap_a2dptime + mlanutl mlanX hostcmd config/robust_btc.conf ap_inquirytime + +hostcmd external_coex_uart_gpio_config + This command is used to configure the UART+GPIO external coex mode with following parameters + Enabled: configure the feature and ouutput on GPIO 0x00 disable, 0x07 enable + ExtCoexHwIntWci2: Enable UART for coex interface 0x00 disable, 0x01 enable + + Usase: + mlanutl mlanX hostcmd config/robust_btc.conf external_coex_uart_gpio_config + diff --git a/README_UAP b/README_UAP new file mode 100644 index 0000000..17a7cc3 --- /dev/null +++ b/README_UAP @@ -0,0 +1,2994 @@ +=============================================================================== + U S E R M A N U A L + + Copyright 2009, 2023-2025 NXP + + +1) FOR DRIVER BUILD + + Goto source code directory wlan_src. + make [clean] build + The driver binaries can be found in ../bin_xxxx directory. + The driver code supports Linux kernel from 2.6.32 to 6.9.0. + +2) FOR DRIVER INSTALL + + a) Copy firmware image to /lib/firmware/nxp/, copy wifi_mod_para.conf to /lib/firmware/nxp/. + b) Install WLAN driver + There are drv_mode, max_sta_bss, max_uap_bss etc. module parameters. + The bit settings of drv_mode are, + Bit 0 : STA + Bit 1 : uAP + Bit 2 : WIFIDIRECT + Bit 4 : NAN + + max_uap_bss: Maximum number of uAP BSS (default 1, max 2) + uap_name: Name of the uAP interface (default: "uap") + + For example, to install multi-chip driver, + insmod mlan.ko + insmod moal.ko mod_para=nxp/wifi_mod_para.conf [drvdbg=0x7] + wifi_mod_para.conf is used to support multi-chips which has different load module parameters. It contains + the module parameters for different chips. + c) Uninstall WLAN driver, + ifconfig mlanX down + ifconfig uapX down + rmmod moal + rmmod mlan + + To load driver with MFG firmware file, use mfg_mode=1 when insmod WLAN driver and + specify MFG firmware name if needed. + + There are some other parameters for debugging purpose etc. Use modinfo to check details. + drvdbg= + dev_cap_mask= + mac_addr=xx:xx:xx:xx:xx:xx + auto_ds=0|1|2 + ps_mode=0|1|2 + max_tx_buf=2048|4096|8192 + cfg_11d=0|1|2 + dts_enable=0|1 + fw_name = + e.g. copy pcieuart9098_combo_v1.bin to firmware directory, fw_name=nxp/pcieuart9098_combo_v1.bin + hw_test=0|1 + fw_serial=0|1 + req_fw_nowait=0|1 + init_cfg= + e.g. copy init_cfg.conf to firmware directory, init_cfg=nxp/init_cfg.conf + cal_data_cfg= + e.g. copy cal_data.conf to firmware directory, cal_data_cfg=nxp/cal_data.conf + txpwrlimit_cfg= + e.g. copy txpwrlimit_cfg_set.conf to firmware directory, txpwrlimit_cfg=nxp/txpwrlimit_cfg_set.conf + cntry_txpwr= + init_hostcmd_cfg= + e.g. copy init_hostcmd_cfg.conf to firmware directory, init_hostcmd_cfg=nxp/init_hostcmd_cfg.conf + cfg80211_wext= + Bit 0: STA WEXT + Bit 1: uAP WEXT + Bit 2: STA CFG80211 + Bit 3: uAP CFG80211 + wq_sched_prio: Priority for work queue + wq_sched_policy: Scheduling policy for work queue + (0: SCHED_NORMAL, 1: SCHED_FIFO, 2: SCHED_RR, 3: SCHED_BATCH, 5: SCHED_IDLE) + Please note that, both wq_sched_prio and wq_sched_policy should be provided + as module parameters. If wq_sched_policy is (0, 3 or 5), then wq_sched_prio + must be 0. wq_sched_prio should be 1 to 99 otherwise. + rx_work=0|1|2 + low_power_mode_enable=0|1 + When low power mode is enabled, the output power will be clipped at ~+10dBm and the + expected PA current is expected to be in the 80-90 mA range for b/g/n modes + max_wfd_bss: Maximum number of WIFIDIRECT BSS (default 1, max 1) + wfd_name: Name of the WIFIDIRECT interface (default: "wfd") + max_vir_bss: Number of Virtual interfaces (default 0) + nan_name: Name of the NAN interface (default: "nan") + max_nan_bss: Number of NAN interfaces (default 1) + start_11ai_scan: Enable/disable 11ai bgscan (default 0, to enable:1, to disable:0) + dpd_data_cfg= + e.g. copy dpd_data.conf to firmware directory, dpd_data_cfg=nxp/dpd_data.conf + pcie_int_mode=0|1|2 + pcie_int_mode=0|1 + wakelock_timeout= + pmic=0|1 + indication_gpio=0xXY + hs_wake_interval= + disconnect_on_suspend=0|1 + hs_mimo_switch=0|1 + fixed_beacon_buffer=0|1 + GoAgeoutTime=0|x + multi_dtim=0|x + inact_tmo=0|x + drcs_chantime_mode=0|x + Bit31~Bit24:Channel time for channel index0; + Bit23~Bit16:mode for channel index0; 0|1 + Bit15~Bit8:Channel time for channel index1; + Bit7~Bit0:mode for channel index1; 0|1 + roamoffload_in_hs=0|1 + uap_max_sta: Maximum number of STA for UAP/GO (default 0, max 10) + host_mlme=0|1 + country_ie_ignore=0|1 + beacon_hints=0|1 + plinkstats=0|1|2 + Example usage: + insmod moal.ko plinkstats=0 : Disable link statistics prints + insmod moal.ko plinkstats=1 : Enable link statistics prints + insmod moal.ko plinkstats=2 : Reset link statistics prints + insmod moal.ko plinkstats=1,0x7,5,0 : Enable Num TX Packets, Num RX Packets and Channel prints on dmesg. + insmod moal.ko plinkstats=1,0xf,5,1 : Enable Num TX Packets, Num RX Packets, Channel and Region prints on dmesg, and netlink event also enabled. + Note: + 1. For more details about plinkstats parameters, refer plinkstats command details in README_MLAN file. + 2. When changing drvdbg mask dynamically while running test, set MLSTATS bit(0x800) along with the change, if wifi logging feature is enabled. + wacp_mode=0|1|2 + Note: On some platforms (e.g. PXA910/920) double quotation marks ("") need to used + for module parameters. + insmod sdxxx.ko " ..." + +3) FOR DRIVER PROC & DEBUG + The following info are provided in /proc/mwlan/adapterX/uapY/info. + + driver_name = "uap" + driver_version = + InterfaceName= "uapX" + State= "Disconnected" | "Connected" + MACAddress= <6-byte adapter MAC address> + MCCount= + num_tx_bytes = + num_rx_bytes = + num_tx_pkts = + num_rx_pkts = + num_tx_pkts_dropped = + num_rx_pkts_dropped = + num_tx_pkts_err = + num_rx_pkts_err = + num_tx_timeout = + carrier "on" | "off" + tx queue "stopped" | "started" + + The following debug info are provided in /proc/mwlan/adapterX/uapY/debug. + + drvdbg = + bit 0: MMSG PRINTM(MMSG,...) + bit 1: MFATAL PRINTM(MFATAL,...) + bit 2: MERROR PRINTM(MERROR,...) + bit 3: MDATA PRINTM(MDATA,...) + bit 4: MCMND PRINTM(MCMND,...) + bit 5: MEVENT PRINTM(MEVENT,...) + bit 6: MINTR PRINTM(MINTR,...) + bit 7: MIOCTL PRINTM(MIOCTL,...) + ... + bit 16: MDAT_D PRINTM(MDAT_D,...), DBG_HEXDUMP(MDAT_D,...) + bit 17: MCMD_D PRINTM(MCMD_D,...), DBG_HEXDUMP(MCMD_D,...) + bit 18: MEVT_D PRINTM(MEVT_D,...), DBG_HEXDUMP(MEVT_D,...) + bit 19: MFW_D PRINTM(MFW_D,...), DBG_HEXDUMP(MFW_D,...) + bit 20: MIF_D PRINTM(MIF_D,...), DBG_HEXDUMP(MIF_D,...) + ... + bit 28: MENTRY PRINTM(MENTRY,...), ENTER(), LEAVE() + bit 29: MWARN PRINTM(MWARN,...) + bit 30: MINFO PRINTM(MINFO,...) + wmm_ac_vo = + wmm_ac_vi = + wmm_ac_be = + wmm_ac_bk = + max_tx_buf_size = + tx_buf_size = + curr_tx_buf_size = + ps_mode = <0/1, CAM mode/PS mode> + ps_state = <0/1/2/3, awake state/pre-sleep state/sleep-confirm state/sleep state> + wakeup_dev_req = <0/1, wakeup device not required/required> + wakeup_tries = + hs_configured = <0/1, host sleep not configured/configured> + hs_activated = <0/1, extended host sleep not activated/activated> + tx_pkts_queued = + num_bridge_pkts = + num_drop_pkts = + num_tx_timeout = + num_cmd_timeout = + timeout_cmd_id = + timeout_cmd_act = + last_cmd_id = + last_cmd_act = + last_cmd_index = <0 based last command index> + last_cmd_resp_id = + last_cmd_resp_index = <0 based last command response index> + last_event = + last_event_index = <0 based last event index> + num_cmd_h2c_fail = + num_cmd_sleep_cfm_fail = + num_tx_h2c_fail = + cmd_sent = <0/1, send command resources available/sending command to device> + data_sent = <0/1, send data resources available/sending data to device> + mp_rd_bitmap = + curr_rd_port = + mp_wr_bitmap = + curr_wr_port = + txbd_rdptr = + txbd_wrptr = + rxbd_rdptr = + rxbd_wrptr = + eventbd_rdptr = + eventbd_wrptr = + cmd_resp_received = <0/1, no cmd response to process/response received and yet to process> + event_received = <0/1, no event to process/event received and yet to process> + ioctl_pending = + tx_pending = + rx_pending = + lock_count = + malloc_count = + mbufalloc_count = + malloc_cons_count = + main_state = + + Example: + echo "drvdbg=0x7" > /proc/mwlan/adapterX/uapY/debug #enable MMSG,MFATAL,MERROR messages + + Use dmesg or cat /var/log/debug to check driver debug messages. + + To log driver debug messages to file, + a) Edit /etc/rsyslog.conf, add one line "*.debug /var/log/debug" + b) touch /var/log/debug (if the file doesn't exist) + c) service rsyslog restart + +4) SOFT_RESET command + This command is used to perform a "soft reset" on the module. + The FW code will disable hardware and jump to boot code. + Host software will then need to re-download firmware if required. + + Usage: + echo "soft_reset=1" > /proc/mwlan/adapterX/config + +=============================================================================== + + U S E R M A N U A L F O R UAPUTL + +NAME +uaputl.exe [options] [command parameters]] + +Options: + --help Display help + -v Display version + -i + -d + +Example: + ./uaputl.exe --help + "display help for uaputl" + + ./uaputl.exe sys_config --help + "display help for sys_config command" + +This tool can be used to set/get uAP's settings. To change AP settings, you might +need to issue "bss_stop" command to stop AP before making change and issue "bss_start" +command to restart the AP after making change. + +------------------ +Supported Commands +------------------ +version +debug_level +sys_config [CONFIG_FILE_NAME] +bss_config [CONFIG_FILE_NAME] +sys_info +sys_reset +bss_start +bss_stop +sta_list +sta_deauth +sta_deauth_ext +radioctrl [0|1] +txratecfg [l] [m] [n] [o] +antcfg [m] [n] +pscfg [MODE] [CTRL INACTTO MIN_SLEEP MAX_SLEEP MIN_AWAKE MAX_AWAKE] +mic_err +key_material [KEY_ID] +sys_cfg_custom_ie [INDEX] [MASK] [IEBuffer] +coex_config [CONFIG_FILE_NAME] +hscfg [condition [[GPIO# [gap]]]] +hssetpara condition [[GPIO# [gap]]] +sys_cfg_wmm [qosinfo=] + [AC_BE AIFSN ECW_MAX ECW_MIN TX_OP] + [AC_BK AIFSN ECW_MAX ECW_MIN TX_OP] + [AC_VI AIFSN ECW_MAX ECW_MIN TX_OP] + [AC_VO AIFSN ECW_MAX ECW_MIN TX_OP] +sys_cfg_ap_wmm [0] + [AC_BE AIFSN ECW_MAX ECW_MIN TX_OP] + [AC_BK AIFSN ECW_MAX ECW_MIN TX_OP] + [AC_VI AIFSN ECW_MAX ECW_MIN TX_OP] + [AC_VO AIFSN ECW_MAX ECW_MIN TX_OP] +sys_cfg_11n [ENABLE] [HTCAP] [AMPDU] [TXBFCAP] [HT_MCS_MAP] +addbapara [timeout txwinsize rxwinsize txamsdu rxamsdu] +aggrpriotbl ... +addbareject ... +httxbfcfg [ACT_DATA] +httxcfg [] +htstreamcfg [n] +deepsleep [MODE] [IDLE_TIME] +hostcmd txpwrlimit_cfg_get +hostcmd txpwrlimit_2g_cfg_set +hostcmd txpwrlimit_5g_cfg_set +tx_data_pause [ENABLE][TX_BUF_CNT] +vhtcfg [l] [m] [n] [o] +dfstesting [ ] +cscount [] +mgmtframectrl [MASK] + +------------------------------------------------------------------- +The following commands can be issued individually for debug purpose +------------------------------------------------------------------- +sys_cfg_ap_mac_address [AP_MAC_ADDRESS] +sys_cfg_ssid [SSID] +sys_cfg_beacon_period [BEACON_PERIOD] +sys_cfg_dtim_period [DTIM_PERIOD] +sys_cfg_channel [CHANNEL] [MODE] +sys_cfg_channel_ext [CHANNEL] [BAND] [MODE] +sys_cfg_scan_channels [CHANNEL[.BAND]] +sys_cfg_rates [RATES] +sys_cfg_rates_ext [rates RATES] [mbrate RATE] +sys_cfg_bcast_ssid_ctl [0|1|2] +sys_cfg_preamble_ctl +sys_cfg_bss_status +sys_cfg_rts_threshold [RTS_THRESHOLD] +sys_cfg_frag_threshold [FRAG_THRESHOLD] +sys_cfg_rsn_replay_prot [1|0] +sys_cfg_tx_beacon_rate [TX_BEACON_RATE] +sys_cfg_mcbc_data_rate [MCBC_DATA_RATE] +sys_cfg_pkt_fwd_ctl [PKT_FWD_CTRL] +sys_cfg_sta_ageout_timer [STA_AGEOUT_TIMER] +sys_cfg_ps_sta_ageout_timer [PS_STA_AGEOUT_TIMER] +sys_cfg_auth [AUTH_MODE] +sys_cfg_protocol [PROTOCOL] [AKM_SUITE] +sys_cfg_pmf [MFPC] [MFPR] [BCN_PPROT] +sys_cfg_wep_key [INDEX ISDEFAULT KEY] (use of WEP/TKIP is not recommended anymore) +sys_cfg_cipher [PAIRWISE_CIPHER GROUP_CIPHER] +sys_cfg_pwk_cipher [] [PAIRWISE_CIPHER] +sys_cfg_gwk_cipher [GROUP_CIPHER] +sys_cfg_group_rekey_timer [GROUP_REKEY_TIMER] +sys_cfg_wpa_passphrase [PASSPHRASE] +sys_cfg_wpa3_sae_password [PASSWORD] +sys_cfg_max_sta_num [STA_NUM] +sys_cfg_retry_limit [RETRY_LIMIT] +sys_cfg_sticky_tim_config [ENABLE] [ ] +sys_cfg_sticky_tim_sta_mac_addr [CONTROL] [STA_MAC_ADDRESS] +sys_cfg_2040_coex [ENABLE] +sys_cfg_eapol_pwk_hsk [ ] +sys_cfg_eapol_gwk_hsk [ ] +sta_filter_table +regrdwr [value] +memaccess [value] +rdeeprom +cfg_data [*.conf] +sys_cfg_80211d [state STATE] [country COUNTRY] +sys_cfg_80211d_country_ie [clear | country COUNTRY] +uap_stats +sys_cfg_tdls_ext_cap [CONFIG_FILE] +sys_cfg_restrict_client_mode [ [MODE_CONFIG]] +sys_cfg_wacp_mode [Mode] +skip_cac [] + +------------------- +Details of Commands +------------------- + +version +------- + "./uaputl.exe -v" + + This command prints the uAP utility version information. + +debug_level +----------- + "./uaputl.exe -d " + + The supported debug_level are: + 0 - no debug + 1 - enable MSG_DEBUG + 2 - enable all the debug + This command use to control the debug level of uaputl.exe. + + Example: + ./uaputl.exe -d 2 sys_config + Enable all the debug in uaputl.exe + +sys_config +---------- + "./uaputl.exe sys_config [CONFIG_FILE]" + This command is used to set or get the current settings of the Micro AP. + + The supported options are: + CONFIG_FILE is file contain all the Micro AP settings. + empty - Get current Micro AP settings + + Example: + ./uaputl.exe sys_config + Get current settings of the Micro AP. + + ./uaputl.exe sys_config config/uaputl.conf + Load Micro AP's settings from uaputl.conf file and set. + +bss_config +---------- + "./uaputl.exe bss_config [CONFIG_FILE]" + This command is used to set or get the current settings of the BSS. + + The supported options are: + CONFIG_FILE is file contain all the BSS settings. + empty - Get current BSS settings + + Example: + ./uaputl.exe bss_config + Get current settings of the BSS. + + ./uaputl.exe bss_config config/uaputl.conf + Load BSS settings from uaputl.conf file and set. + +sys_info +-------- + "./uaputl.exe sys_info" + + This command returns system information such as firmware version number + and HW information. + +sys_reset +--------- + "./uaputl.exe sys_reset" + + This command is used to reset the Micro AP back to its initial state. + For example, this can be used to recover from a serious error, or before + creating a new BSS. + + This command has the following effects: + 1. The WLAN hardware MAC is reset. + 2. All MIB variables are initialized to their respective default + values. + 3. The firmware internal variables are reset to their respective + default values. + 4. The firmware state machines are reset to their respective initial + states. + +bss_start +--------- + "./uaputl.exe bss_start" + + This command starts the BSS. + There is no error for redundant bss_start command. + +bss_stop +-------- + "./uaputl.exe bss_stop" + + This command stops the BSS. The command causes the firmware to: + 1. Deauthenticate all associated client stations. + 2. Turn off the radio (hence stopping beaconing). + There is no error for redundant bss_stop command. + +sta_list +-------- + "./uaputl.exe sta_list" + + This command returns the list of client stations that are currently + associated with the AP. + + The output is formatted as shown below, for each STA: + "STA information: + ========================== + MAC Address: + Power Mgmt status: active|power save + Rssi: " + +sta_deauth +---------- + "./uaputl.exe sta_deauth " + + This command is used to de-authentciate a client station for any reason. + +radioctrl +---------- + "./uaputl.exe radioctrl [0|1]" + + This command is used to set or get the radio settings. + The supported options are: + 1 - Turn radio on + 0 - Turn radio off + empty - Get current radio setting + +txratecfg +---------- + "./uaputl.exe txratecfg [l] [m] [n] [o]" + + This command is used to set/get the transmit data rate. + + Note: + 1) Parameter [o] is optional. If [o] is not given, it will be set as 0xffff. + + Where + [l] is + - This parameter specifies the data rate format used in this command + 0: LG + 1: HT + 2: VHT + 3: HE + + 0xff: Auto + + [m] is + - This parameter specifies the rate or MCS index + If is 0 (LG), + 0 1 Mbps + 1 2 Mbps + 2 5.5 Mbps + 3 11 Mbps + 4 6 Mbps + 5 9 Mbps + 6 12 Mbps + 7 18 Mbps + 8 24 Mbps + 9 36 Mbps + 10 48 Mbps + 11 54 Mbps + If is 1 (HT), + 0 MCS0 + 1 MCS1 + 2 MCS2 + 3 MCS3 + 4 MCS4 + 5 MCS5 + 6 MCS6 + 7 MCS7 + 8 MCS8 + 9 MCS9 + 10 MCS10 + 11 MCS11 + 12 MCS12 + 13 MCS13 + 14 MCS14 + 15 MCS15 + 32 MCS32 + If is 2 (VHT), + 0 MCS0 + 1 MCS1 + 2 MCS2 + 3 MCS3 + 4 MCS4 + 5 MCS5 + 6 MCS6 + 7 MCS7 + 8 MCS8 + 9 MCS9 + [n] is + - This parameter specifies the NSS. It is valid only for VHT + If is 2 (VHT), + 1 NSS1 + 2 NSS2 + If is 3 (HE), + 0 MCS0 + 1 MCS1 + 2 MCS2 + 3 MCS3 + 4 MCS4 + 5 MCS5 + 6 MCS6 + 7 MCS7 + 8 MCS8 + 9 MCS9 + 10 MCS10 + 11 MCS11 + [n] is + - This parameter specifies the NSS. It is valid only for HE + If is 3 (HE), + 1 NSS1 + 2 NSS2 + + [o] is + Bit0 - 1: indicate preambleType + For legacy 11b: preemble type + 00 = long + 01 = short + 10/11 = reserved + For legacy 11g: reserved + For 11n: Green field PPDU indicator + 00 = HT-mix + 01 = HT-GF + 10/11 = reserved. + For 11ac: reserved. + For 11ax: + 00 = HE-SU + 10 = HE-EXT-SU + Others are reserved + + Bit 2 - 4 : indicate BW: + For HE ER: + 0 = 242-tone RU + 1 = upper frequency 106-tone RU within the primary 20 MHz + Otherwise: + 0 = 20 MHz + 1 = 40 MHz + 2 = 80 MHz + 3 = 160 MHz + + Bit 5 -6: indicate LTF + GI size + For HT: + 0 = normal + 1 = Short GI + For VHT: + 01 = Short GI + 11 = Short GI and Nsym mod 10=9 + 00 = otherwise + For HE: + 0 = 1xHELTF + GI0.8us + 1 = 2xHELTF + GI0.8us + 2 = 2xHELTF + GI1.6us + 3 = 4xHELTF + GI0.8us if DCM = 0 and STBC = 0 + 4xHELTF + GI3.2us, otherwise. + + Bit 7: Indicate STBC: + 0 = no STBC + 1 = STBC + + Bit 8: indicate DCM: + 0 = no DCM + 1 = DCM + + Bit 9: indicate coding: + 0 = BCC + 1 = LDPC + + Bit 10 - 11: reserved. + + Bit 12 - 13: Indicate maxPE + Max packet extension + 0 - 9 usec + 1 - 8 usec + 2 - 16 usec. + + Bit 14 - 15: reserved. + + 0xffff: Auto + + Examples: + ./uaputl.exe txratecfg 0 3 : Set fixed Tx rate to 11 Mbps + ./uaputl.exe txratecfg 0 11 : Set fixed Tx rate to 54 Mbps + ./uaputl.exe txratecfg 1 3 : Set fixed Tx rate to MCS3 + ./uaputl.exe txratecfg 2 3 2 : Set fixed Tx rate to MCS3 for NSS2 + ./uaputl.exe txratecfg 3 3 2 : Set fixed Tx rate to MCS3 for NSS2 + ./uaputl.exe txratecfg 3 5 2 0x2282 : Set 11AX fixed Tx rate to MCS5 for NSS2, and Preamble type is 2, BW is 0, LTF + GI size 0 + STBC is 1, DMC is 0, Coding is 1, maxPE is 2. + ./uaputl.exe txratecfg 0xff : Disable fixed rate and uses auto rate + ./uaputl.exe txratecfg : Read the current data rate setting + +antcfg +---------- + "./uaputl.exe antcfg [m] [n]" + + This command is used to set/get the transmit and receive antenna. + where value of m is: + Bit 0 -- Tx Path A + Bit 1 -- Tx Path B + Bit 0-1 -- Tx Path A+B + For 9097/9098/IW624, LOW BYTE for 2G setting + Bit 8 -- Tx Path A + Bit 9 -- Tx Path B + Bit 8-9 -- Tx Path A+B + For 9097/9098/IW624, HIGH BYTE for 5G setting + + where value of n is: + Bit 0 -- Rx Path A + Bit 1 -- Rx Path B + Bit 0-1 -- Rx Path A+B + For 9097/9098/IW624, LOW BYTE for 2G setting + Bit 8 -- Rx Path A + Bit 9 -- Rx Path B + Bit 8-9 -- Rx Path A+B + For 9097/9098/IW624, HIGH BYTE for 5G setting + The Tx path setting (m) is used if Rx path (n) is not provided. + + Examples: + ./uaputl.exe antcfg : Get Tx and Rx path + ./uaputl.exe antcfg 3 : Set Tx and Rx path to A+B + ./uaputl.exe antcfg 2 3 : Set Tx path to B and Rx path to A+B + ./uaputl.exe antcfg 0x103 : Set Tx and Rx path to A+B on 2G and Tx and Rx path to A on 5G + ./uaputl.exe antcfg 0x3 0x3 : Set Tx path to A+B and Rx path to A+B on 2G, 5G not changed + ./uaputl.exe antcfg 0x300 0x300 : Set Tx path to A+B and Rx path to A+B on 5G, 2G not changed + +sys_cfg_ap_mac_address +---------------------- + "./uaputl.exe sys_cfg_ap_mac_address [AP_MAC_ADDRESS]" + + This command is used to set or get the AP MAC address. + + If no arguments are given, this command returns the current AP MAC + address. + Otherwise, this MAC address becomes the BSSID of the infrastructure + network created by the AP. + + Example: + ./uaputl.exe sys_cfg_ap_mac_address 00:50:43:20:aa:bb + Set AP MAC address to 00:50:43:20:aa:bb + + ./uaputl.exe sys_cfg_ap_mac_address + Get AP MAC address" + +sys_cfg_ssid +------------ + "./uaputl.exe sys_cfg_ssid [SSID]" + + This command is used to set or get the AP SSID. + + If no arguments are given, this command returns the current AP SSID. + While setting, the maximum length of the SSID can be 32 characters. + + Example: + ./uaputl.exe sys_cfg_ssid microap + Set AP ssid to "microap" + + ./uaputl.exe sys_cfg_ssid + Get AP ssid + +sys_cfg_beacon_period +--------------------- + "./uaputl.exe sys_cfg_beacon_period [BEACON_PERIOD]" + + This command is used to set or get the AP beacon period. + + If no arguments are given, this command returns the current AP beacon + period. + + Beacon period is represented in milliseconds. + + Example: + ./uaputl.exe sys_cfg_beacon_period 100 + Set AP beacon period to 100 TU + + ./uaputl.exe sys_cfg_beacon_period + Get AP beacon period + +sys_cfg_dtim_period +------------------- + "./uaputl.exe sys_cfg_dtim_period [DTIM_PERIOD] + + This command is used to set or get the AP DTIM period. + + If no arguments are given, this command returns the current AP DTIM + period. + + Example: + ./uaputl.exe sys_cfg_dtim_period 3 + Set AP DTIM period to 3 + + ./uaputl.exe sys_cfg_dtim_period + Get AP DTIM period + +sys_cfg_scan_channels +--------------------- + "./uaputl.exe sys_cfg_scan_channels [CHANNEL[.BAND]]" + + This command is used to set or get the AP's scan channel list. + + If no arguments are given, this command returns the scan channel list. + If BAND is 0, channel is set in 2.4 GHz band, and if BAND is 1, channel is set to 5GHz. + Channels from only one of the bands should be specified. + Each CHANNEL.BAND pair must be separated by a space. BAND parameter is optional. + + Example: + ./uaputl.exe sys_cfg_scan_channels 1 11 6 + Set AP scan channel list to 1 11 6 + + ./uaputl.exe sys_cfg_scan_channels 11.0 6.0 + Set AP scan channel list to 11 6 + + ./uaputl.exe sys_cfg_scan_channels + Get AP scan channel list + + ./uaputl.exe sys_cfg_scan_channels 8.1 16.1 34 + Set AP scan channel list to 8 16 and 34 in 5GHz band. + + +sys_cfg_channel +--------------- + "./uaputl.exe sys_cfg_channel [CHANNEL] [MODE]" + + This command is used to set or get the AP radio channel. + + If no arguments are given, this command returns the current AP radio + channel. + + MODE: band config mode. + Bit 0: automatic channel selection (ACS) enable/disable + Bit 1: secondary channel is above primary channel enable/disable(only allow for channel 1-7) + Bit 2: secondary channel is below primary channel enable/disable(only allow for channel 5-11) + For 'a' band channel: + Bit 1: secondary channel is above primary channel enable/disable + Bit 2: secondary channel is below primary channel enable/disable + Only following pairs of channels are valid for secondary channel setting in 5GHz band. + 36, 40 + 44, 48 + 52, 56 + 60, 64 + 100, 104 + 108, 112 + 116, 120 + 124, 128 + 132, 136 + 149, 153 + 157, 161 + + Example: + ./uaputl.exe sys_cfg_channel 6 + Set AP radio channel to 6, and no secondary channel. + + ./uaputl.exe sys_cfg_channel 11 0 + Set AP radio channel to 11 with Manual Channel Select. + + ./uaputl.exe sys_cfg_channel 0 1 + Set AP to ACS. + + ./uaputl.exe sys_cfg_channel + Get AP radio channel + + ./uaputl.exe sys_cfg_channel 6 2 + Set AP primary radio channel to 6, and secondary channel is above. + ./uaputl.exe sys_cfg_channel 6 4 + Set AP primary radio channel to 6, and secondary channel is below + ./uaputl.exe sys_cfg_channel 0 3 + Set AP to ACS mode, and secondary channel is above. + ./uaputl.exe sys_cfg_channel 0 5 + Set AP to ACS mode, and secondary channel is below. + ./uaputl.exe sys_cfg_channel 36 2 + Set AP primary radio channel to 36, and secondary channel is above. + ./uaputl.exe sys_cfg_channel 40 4 + Set AP primary radio channel to 40, and secondary channel is below. + +sys_cfg_channel_ext +--------------- + "./uaputl.exe sys_cfg_channel_ext [CHANNEL] [BAND] [MODE]" + + This command is used to set or get the AP radio channel. + + If no arguments are given, this command returns the current AP radio + channel. + + BAND: 0 : 2.4GHz operation + 1 : 5GHz operation + MODE: band config mode. + Bit 0: automatic channel selection (ACS) enable/disable + Bit 1: secondary channel is above primary channel enable/disable(only allow for channel 1-7) + Bit 2: secondary channel is below primary channel enable/disable(only allow for channel 5-11) + For 'a' band channel: + Bit 1: secondary channel is above primary channel enable/disable + Bit 2: secondary channel is below primary channel enable/disable + Only following pairs of channels are valid for secondary channel setting in 5GHz band. + 36, 40 + 44, 48 + 52, 56 + 60, 64 + 100, 104 + 108, 112 + 116, 120 + 124, 128 + 132, 136 + 149, 153 + 157, 161 + Example: + ./uaputl.exe sys_cfg_channel_ext 6 + Set AP radio channel to 6, and no secondary channel. + + ./uaputl.exe sys_cfg_channel_ext 11 0 0 + Set AP radio channel to 11 in 2.4GHz band with Manual Channel Select. + + ./uaputl.exe sys_cfg_channel_ext 0 0 1 + Set AP to ACS mode and 2.4GHz band. + + ./uaputl.exe sys_cfg_channel_ext 8 0 + Set AP to channel 8 and 2.4GHz band. + + ./uaputl.exe sys_cfg_channel_ext 8 1 + Set AP to channel 8 and 5GHz band. + + ./uaputl.exe sys_cfg_channel_ext 36 1 + Set AP to channel 36 and 5GHZ band. + + ./uaputl.exe sys_cfg_channel_ext + Get AP radio channel, band and mode. + + ./uaputl.exe sys_cfg_channel_ext 6 0 2 + Set AP primary radio channel to 6, band to 2.4GHz and secondary channel is above. + ./uaputl.exe sys_cfg_channel_ext 6 0 4 + Set AP primary radio channel to 6, band to 2.4GHz and secondary channel is below + ./uaputl.exe sys_cfg_channel_ext 0 0 3 + Set AP to ACS mode, band to 2.4GHz and secondary channel is above. + ./uaputl.exe sys_cfg_channel_ext 0 0 5 + Set AP to ACS mode, band to 2.4GHz and secondary channel is below. + ./uaputl.exe sys_cfg_channel_ext 36 1 2 + Set AP primary radio channel to 36, band to 5GHz and secondary channel is above. + ./uaputl.exe sys_cfg_channel_ext 40 1 4 + Set AP primary radio channel to 40, band to 5GHz and secondary channel is below. + +sys_cfg_rates +------------- + "./uaputl.exe sys_cfg_rates [RATES]" + + If 'Rate' provided, a 'set' is performed else a 'get' is performed + RATES is provided as a set of data rates, in unit of 500 kilobits + A rate with MSB bit is basic rate, i.e 0x82 is basic rate. + + 'set' will not allowed after bss start. + + Valid rates: 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 + Non-Basic rates: 0x02, 0x04, 0x0b, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c + Basic rates: 0x82, 0x84, 0x8b, 0x96, 0x8C, 0x92, 0x98, 0xA4, 0xB0, 0xC8, 0xE0, 0xEc + + Each rate must be separated by a space. + + Example: + ./uaputl.exe sys_cfg_rates 0x82 0x84 0x96 0x0c 0x12 0x18 + ./uaputl.exe sys_cfg_rates + +sys_cfg_rates_ext +----------------- + "./uaputl.exe sys_cfg_rates_ext [rates RATES] [mbrate RATE]" + + If 'Rate' provided, a 'set' is performed else a 'get' is performed. + RATES is provided as a set of data rates, in unit of 500 kilobits + A rate with MSB bit is basic rate, i.e 0x82 is basic rate. + If only operational rates is provided, MCBC rate and unicast rate will be set to auto. + + Valid rates: 2, 4, 11, 13, 22, 12, 18, 24, 36, 48, 72, 96, 108 + Non-Basic rates: 0x02, 0x04, 0x0b, 0x0d, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c + Basic rates: 0x82, 0x84, 0x8b, 0x96, 0x8C, 0x92, 0x98, 0xA4, 0xB0, 0xC8, 0xE0, 0xEc + Rates 2, 4, 11 and 22 (in units of 500 Kbps) must be present in either of + basic or non-basic rates. If OFDM rates are enabled then 12, 24 and 48 (in + units of 500 Kbps) must be present in either basic or non-basic rates. + + Each rate must be separated by a space. + + rates followed by RATES for setting operational rates. + mbrate followed by RATE for setting multicast and broadcast rate. + + operational rates only allow to set before bss start. + + Example: + ./uaputl.exe sys_cfg_rates_ext rates 0x82 0x04 11 0x96 12 24 48 mbrate 0x16 + Set AP operation rates to 0x82,0x04,11,0x96,12,24,48, multicast rate to 0x16 + ./uaputl.exe sys_cfg_rates_ext rates 0x82 0x04 11 0x96 12 24 48 + Set AP operation rates to 0x82,0x04,11,0x96,12,24,48. + +sys_cfg_bcast_ssid_ctl +---------------------- + "./uaputl.exe sys_cfg_bcast_ssid_ctl [0|1|2]" + + This command is used to set or get the SSID broadcast feature setting. + + The supported options are: + 0 - Disable SSID broadcast, send empty SSID (length=0) in beacon. + 1 - Enable SSID broadcast + 2 - Disable SSID broadcast, clear SSID (ACSII 0) in beacon, but keep the original length + empty - Get current SSID broadcast setting + + When broadcast SSID is enabled, the AP responds to probe requests from + client stations that contain null SSID. + + When broadcast SSID is disabled (sys_cfg_bcast_ssid_ctl = 0/2), the AP: + 1. Does not respond to probe requests that contain null SSID. + 2. when sys_cfg_bcast_ssid_ctl = 0, generates beacons that contain null SSID (length=0). + 3. when sys_cfg_bcast_ssid_ctl = 2, clear SSID (ACSII 0) in beacon and keep the original length + + Example: + ./uaputl.exe sys_cfg_bcast_ssid_ctl 0 + Disable SSID broadcast, send empty SSID (length=0) in beacon. + + ./uaputl.exe sys_cfg_bcast_ssid_ctl 1 + Enable SSID broadcast + + ./uaputl.exe sys_cfg_bcast_ssid_ctl 2 + Disable SSID broadcast, clear SSID (ACSII 0) in beacon, but keep the original length + + ./uaputl.exe sys_cfg_bcast_ssid_ctl + Get SSID broadcast setting + +sys_cfg_preamble_ctl +-------------------- + "./uaputl.exe sys_cfg_preamble_ctl" + + This command is used to set/get type of preamble. + + The supported options are: + Preamble: 0 - Auto/Default + 1 - Short Preamble + 2 - Long Preamble + + Example: + ./uaputl.exe sys_cfg_preamble_ctl + Get AP preamble setting + + ./uaputl.exe sys_cfg_premable_ctl 2 + Set AP preamble setting to Long premable + +sys_cfg_bss_status +-------------------- + "./uaputl.exe sys_cfg_bss_status" + + This command is used to get current BSS status. + + Example: + ./uaputl.exe sys_cfg_bss_status + Get current BSS status + +sys_cfg_rts_threshold +--------------------- + "./uaputl.exe sys_cfg_rts_threshold [RTS_THRESHOLD]" + + This command is used to set or get the RTS threshold value. + + If no arguments are given, this command returns the current RTS threshold + value. + + Example: + ./uaputl.exe sys_cfg_rts_threshold 2347 + Set AP RTS threshold to 2347 + + ./uaputl.exe sys_cfg_rts_threshold + Get AP RTS threshold + +sys_cfg_frag_threshold +---------------------- + "./uaputl.exe sys_cfg_frag_threshold [FRAG_THRESHOLD]" + + This command is used to set or get the Fragmentation threshold value. + + If no arguments are given, this command returns the current Fragmentation threshold + value. + + Example: + ./uaputl.exe sys_cfg_frag_threshold 2346 + Set AP Fragmentation threshold to 2346 + + ./uaputl.exe sys_cfg_frag_threshold + Get AP Fragmentation threshold + + Note: Please use aggrpriotbl command to disable the AMPDU/AMSDU aggregation when frag_threshold is set. + +sys_cfg_rsn_replay_prot +----------------------- + "./uaputl.exe sys_cfg_rsn_replay_prot [1|0]" + + This command is used to enable or disable RSN replay protection. + + The supported options are: + 0 - Disable RSN replay protection + 1 - Enable RSN replay protection + empty - Get current RSN replay protection setting + + Example: + ./uaputl.exe sys_cfg_rsn_replay_prot 1 + Enable RSN replay protection + + ./uaputl.exe sys_cfg_rsn_replay_prot + Get RSN replay protection setting + +sys_cfg_tx_beacon_rate +-------------------- + "./uaputl.exe sys_cfg_tx_beacon_rate [TX_BEACON_RATE]" + + This command is used to set or get the Tx beacon rate settings. + + The supported options are: + 0 - Auto rate + >0 - Set specified beacon rate + empty - Get current beacon rate + + Tx beacon rate is represented in units of 500 kbps. While setting Tx beacon + rates, only zero or rates currently configured are allowed. + + Following is the list of supported rates in units of 500 Kbps: + 2, 4, 11, 13, 22, 12, 18, 24, 36, 48, 72, 96, 108 + 0x02, 0x04, 0x0b, 0xd, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c + + Example: + ./uaputl.exe sys_cfg_tx_beacon_rate 0x04 + Set AP Tx beacon rate to 2 M + + ./uaputl.exe sys_cfg_tx_beacon_rate 4 + Set AP Tx data beacon to 2 M + + ./uaputl.exe sys_cfg_tx_beacon_rate + Get AP Tx beacon rate + +sys_cfg_mcbc_data_rate +---------------------- + "./uaputl.exe sys_cfg_mcbc_data_rate [MCBC_DATA_RATE]" + + This command is used to set or get the MCBC data rate to use for multicast + or broadcast packet transmission. + + The supported options are: + 0 - Auto rate + >0 - Set specified MCBC data rate + empty - Get current MCBC data rate + + MCBC data rate is represented in units of 500 kbps. While setting MCBC data + rates, only zero or one of rates currently configured as basic rates are allowed. + + For example: If current basic rates is "0x82 0x84 0x8b 0x96", then the allowed + values for MCBC data rate will be "0x2 0x4 0xb 0x16". + + Example: + ./uaputl.exe sys_cfg_mcbc_data_rate 22 + Set AP MCBC data rate to 11 M + + ./uaputl.exe sys_cfg_mcbc_data_rate 0 + Set AP MCBC data rate to auto + + ./uaputl.exe sys_cfg_mcbc_data_rate + Get AP MCBC data rate + +sys_cfg_pkt_fwd_ctl +------------------- + "./uaputl.exe sys_cfg_pkt_fwd_ctl [PKT_FWD_CTRL]" + + This command is used to set or get the packet forwarding control + settings. + + where PKT_FWD_CTRL is: + bit 0 -- Packet forwarding handled by Host (0) or Firmware (1) + bit 1 -- Intra-BSS broadcast packets are allowed (0) or denied (1) + bit 2 -- Intra-BSS unicast packets are allowed (0) or denied (1) + bit 3 -- Inter-BSS unicast packets are allowed (0) or denied (1) + empty - Get current packet forwarding setting + + Example: + ./uaputl.exe sys_cfg_pkt_fwd_ctl 1 + Set AP packet forwarding control in firmware to allow all packets + + ./uaputl.exe sys_cfg_pkt_fwd_ctl 6 + Set AP packet forwarding control in Host, only allow Inter-BSS unicast packets forwarding. + + ./uaputl.exe sys_cfg_pkt_fwd_ctl 8 + Set AP packet forwarding control in Host, only allow Intra-BSS packets forwarding. + + ./uaputl.exe sys_cfg_pkt_fwd_ctl 0 + Set AP packet forwarding control in Host, allow Intra-BSS packets and + Inter-BSS unicast packets forwarding. + + ./uaputl.exe sys_cfg_pkt_fwd_ctl + Get AP packet forwarding control + +sys_cfg_sta_ageout_timer +------------------------ + "./uaputl.exe sys_cfg_sta_ageout_timer [STA_AGEOUT_TIMER]" + + This command is used to set or get the STA ageout value. + + Value of 0 will mean that stations will never be aged out. + + Minimum value for this is 100. Maximum allowed setting should be 864000. + + If no arguments are given, this command returns the current STA ageout + value. + + Ageout timer value is represented in units of 100 ms. + + Example: + ./uaputl.exe sys_cfg_sta_ageout_timer 1800 + Set AP STA ageout time to 180000 ms + + ./uaputl.exe sys_cfg_sta_ageout_timer + Get AP STA ageout time + +sys_cfg_ps_sta_ageout_timer +--------------------------- + "./uaputl.exe sys_cfg_ps_sta_ageout_timer [PS_STA_AGEOUT_TIMER]" + + This command is used to set or get the PS STA ageout value. + + Value of 0 will mean that stations will never be aged out. + + Minimum value for this is 100. Maximum allowed setting should be 864000. + + If no arguments are given, this command returns the current PS STA ageout + value. + + Ageout timer value is represented in units of 100 ms. + + Example: + ./uaputl.exe sys_cfg_ps_sta_ageout_timer 1800 + Set AP PS STA ageout time to 180000 ms + + ./uaputl.exe sys_cfg_ps_sta_ageout_timer + Get AP PS STA ageout time + +sys_cfg_auth +------------ + This command is used for embedded supplicant. + "./uaputl.exe sys_cfg_auth [AUTHMODE] [PWE derivation] [transition disable]" + + This command is used to set or get the AP authentication mode. + + The supported options are: + AUTHMODE : 0 - Open authentication + 1 - Shared key authentication + 3 - WPA3 SAE + 4 - OWE + 255 - Auto (Open and Shared key) authentication + PWE derivation : 0 - Looping only (default) + 1 - H2E only + 2 - Both looping and H2E + transition disable : 0 - transition enable (default) + 1 - transition disable + empty - Get current authentication mode + + Example: + ./uaputl.exe sys_cfg_auth 0 + Set AP authentication mode to Open. + + ./uaputl.exe sys_cfg_auth + Get AP authentication mode. + +sys_cfg_protocol +---------------- + "./uaputl.exe sys_cfg_protocol [PROTOCOL] [AKM_SUITE]" + + This command is used to set or get the encryption protocol. + + The supported options are: + PROTOCOL: + 1 No RSN + 2 WEP Static + 8 WPA // use of WPA/TKIP is not recommended anymore + 32 WPA2 + 40 WPA, WPA2 Mixed Mode // use of WPA/TKIP is not recommended anymore + 256 WPA3 SAE + 512 OWE + empty - Get current encryption protocol + + AKM_SUITE: + bit 0 KEY_MGMT_EAP + bit 1 KEY_MGMT_PSK + bit 2 KEY_MGMT_NONE + bit 8 KEY_MGMT_PSK_SHA256 + bit 10 KEY_MGMT_SAE + + Example: + ./uaputl.exe sys_cfg_protocol 2 + Set AP encryption protocol to static WEP. + + ./uaputl.exe sys_cfg_protocol + Get AP encryption protocol. + + ./uaputl.exe sys_cfg_protocol 32 0x102 + Set AP encryption protocol to WPA2 and AKM SUITE to PSK and PSK SHA256 + + ./uaputl.exe sys_cfg_protocol 40 0x100 + Set AP encryption protocol to WPA+WPA2 and AKM SUITE to PSK SHA256 // use of WPA/TKIP is not recommended anymore + + ./uaputl.exe sys_cfg_protocol 256 0x400 + Set AP encryption protocol to WPA3 SAE and AKM SUITE to SAE. + + ./uaputl.exe sys_cfg_protocol 256 0x500 + Set AP encryption protocol to WPA3 SAE + WPA2 and AKM SUITE to SAE and PSK SHA256. + + ./uaputl.exe sys_cfg_protocol 256 0x402 + Set AP encryption protocol to WPA3 SAE + WPA2 and AKM SUITE to SAE and PSK. + +sys_cfg_pmf +----------- + "./uaputl.exe sys_cfg_pmf [MFPC] [MFPR] [BCN_PPROT]" + + This command is used to set or get the PMF settings. + + The supported options are: + MFPC: 0 - Mgmt frame protection not capable + 1 - Mgmt frame protection capable + + MFPR: 0 - Mgmt frame protection not required + 1 - Mgmt frame protection required + x - don't care if MFPC = 0 + + BCN_PPROT: 0 - beacon protection not required (default) + 1 - beacon protection required + + Example: + ./uaputl.exe sys_cfg_pmf 1 1 + Set AP's PMF params to Mgmt frames protection capable and required. + + ./uaputl.exe sys_cfg_pmf 1 1 1 + Set AP's PMF params to Mgmt frames protection capable and required and also enable beacon protection. + + ./uaputl.exe sys_cfg_pmf + Get AP's PMF params settings. + +sys_cfg_ext_cap_len +------------------- + "./uaputl.exe sys_cfg_ext_cap_len [length]" + + This command is used to set or get AP extended capabilities IE Length. + + Default length value is 10. It can be changed to 8 by the command. + + Example: + ./uaputl.exe sys_cfg_ext_cap_len 8 + Set AP's extended capabilities IE Length to 8. + + ./uaputl.exe sys_cfg_ext_cap_len 5 + Invalid length value. + + ./uaputl.exe sys_cfg_ext_cap_len + Get AP's extended capabilities IE Length. + +sys_cfg_wep_key // (use of WEP/TKIP is not recommended anymore) +--------------- + "./uaputl.exe sys_cfg_wep_key [INDEX ISDEFAULT Key_0] // (use of WEP/TKIP is not recommended anymore) + [INDEX ISDEFAULT Key_1] + [INDEX ISDEFAULT Key_2] + [INDEX ISDEFAULT Key_3] + [INDEX]" + + This command is used to set or get the WEP (use of WEP/TKIP is not recommended anymore) key settings. + + The supported options are: + INDEX: 0 - KeyIndex is 0 + 1 - KeyIndex is 1 + 2 - KeyIndex is 2 + 3 - KeyIndex is 3 + ISDEFAULT: 0: KeyIndex is not the default + 1: KeyIndex is the default transmit key + + KEY_* : Key value. + empty - Get current WEP key settings for all the keys (use of WEP/TKIP is not recommended anymore) + INDEX - Only INDEX will get the key setting for the particular + KeyIndex. + + Example: + ./uaputl.exe sys_cfg_wep_key 0 1 55555 (use of WEP/TKIP is not recommended anymore) + Set AP's default transmit key to "55555", key index is 0. + + ./uaputl.exe sys_cfg_wep_key 0 1 12345678901234567890123456 (use of WEP/TKIP is not recommended anymore) + Set AP's default transmit key to "12345678901234567890123456", key index is 0. + + ./uaputl.exe sys_cfg_wep_key (use of WEP/TKIP is not recommended anymore) + Get AP all the WEP keys settings. (use of WEP/TKIP is not recommended anymore) + + ./uaputl.exe sys_cfg_wep_key 1 (use of WEP/TKIP is not recommended anymore) + Get WEP key setting for the KeyIndex = 1. (use of WEP/TKIP is not recommended anymore) + +sys_cfg_cipher +-------------- + "./uaputl.exe sys_cfg_cipher [PAIRWISE_CIPHER GROUP_CIPHER]" + + This command is used to set or get the key types for the pairwise and group key. + + The supported options are: + PAIRWISE_CIPHER: + 0 None + 4 TKIP //use of WEP/TKIP is not recommended anymore + 8 AES CCMP + 12 AES CCMP + TKIP //use of WEP/TKIP is not recommended anymore + GROUP_CIPHER: + 0 None + 4 TKIP //use of WEP/TKIP is not recommended anymore + 8 AES CCMP + empty - Get current key types + + Valid combinations of [PAIRWISE_CIPHER GROUP_CIPHER] are: + [0 0], [4 4], [8 8], [12 4]. + + Example: + ./uaputl.exe sys_cfg_cipher 4 4 + Set AP's pairwise and group key's type to TKIP. //use of WEP/TKIP is not recommended anymore + + ./uaputl.exe sys_cfg_cipher + Get AP's key types for the pairwise and group key. + +sys_cfg_pwk_cipher +------------------ + "./uaputl.exe sys_cfg_pwk_cipher [] [PAIRWISE_CIPHER]" + + This command is used to set or get protocol and corresponding pairwise cipher settings. + + The supported options are: + PROTOCOL: + 0 None + 8 WPA // use of WPA/TKIP is not recommended anymore + 32 WPA2 + 256 WPA3 SAE + PAIRWISE_CIPHER: + 0 None + 4 TKIP //use of WEP/TKIP is not recommended anymore + 8 AES CCMP + 12 AES CCMP + TKIP //use of WEP/TKIP is not recommended anymore + WPA/TKIP cipher cannot be used when uAP operates in 802.11n mode. + If only PROTOCOL is provided, pairwise cipher for that protocol is displayed. + empty - Get protocol and corresponding pairwise cipher settings. + + Example: + ./uaputl.exe sys_cfg_pwk_cipher 8 4 + Set AP's pairwise cipher to TKIP ( use of WEP/TKIP is not recommended anymore) for WPA protocol. // use of WPA/TKIP is not recommended anymore + + ./uaputl.exe sys_cfg_pwk_cipher 32 + Get AP's pairwise cipher for WPA2 protocol. + + ./uaputl.exe sys_cfg_pwk_cipher + Get AP's protocol and corresponding pairwise cipher settings. + +sys_cfg_gwk_cipher +------------------ + "./uaputl.exe sys_cfg_gwk_cipher [GROUP_CIPHER]" + + This command is used to set or get group cipher. + + The supported options are: + GROUP_CIPHER: + 0 None + 4 TKIP //use of WEP/TKIP is not recommended anymore + 8 AES CCMP + empty - Get group cipher settings. + + Example: + ./uaputl.exe sys_cfg_gwk_cipher 8 + Set AP's group cipher to AES CCMP. + + ./uaputl.exe sys_cfg_gwk_cipher + Get AP's group cipher settings. + +sys_cfg_group_rekey_timer +------------------------- + "./uaputl.exe sys_cfg_group_rekey_timer [GROUP_REKEY_TIMER]" + + This command is used to set or get the AP group re-key time interval, in seconds. + + The supported options are: + GROUP_REKEY_TIMER is represented in seconds. This is only applicable + if the protocol is WPA or WPA2. Value of 0 will disable group re-key. // use of WPA/TKIP is not recommended anymore + + empty - Get current group rekey timer + + Example: + ./uaputl.exe sys_cfg_group_rekey_timer 1800 + Set AP's group re-key time interval to 1800 s + + ./uaputl.exe sys_cfg_group_rekey_timer + Get AP's group re-key time interval. + +sys_cfg_wpa_passphrase +---------------------- + "./uaputl.exe sys_cfg_wpa_passphrase [PASSPHRASE]" + + This command is used to set or get the WPA or WPA2 passphrase. // use of WPA/TKIP is not recommended anymore + + If no arguments are given, this command returns the current WPA or WPA2 // use of WPA/TKIP is not recommended anymore + passphrase. + While setting, the maximum length of the passphrase can be 64 characters. + + Example: + ./uaputl.exe sys_cfg_wpa_passphrase 1234567890 + Set AP's WPA or WPA2 passphrase to "1234567890" // use of WPA/TKIP is not recommended anymore + + ./uaputl.exe sys_cfg_wpa_passphrase + Get AP's WPA or WPA2 passphrase. // use of WPA/TKIP is not recommended anymore + +sys_cfg_wpa3_sae_password +---------------------- + "./uaputl.exe sys_cfg_wpa3_sae_password [PASSWORD]" + + This command is used to set or get the WPA3 SAE passphrase. + + Also setting psk for WPA3 SAE protocol is not possible, as new psk gets generated + everytime in protocol flow. + + If no arguments are given, this command returns the current WPA3 SAE Password. + While setting, the maximum length of the password can be 255 characters. + + Example: + ./uaputl.exe sys_cfg_wpa3_sae_password 1234567890 + Set AP's WPA3 SAE password to "1234567890" + + ./uaputl.exe sys_cfg_wpa3_sae_password + Get AP's WPA3 SAE password. + +sys_cfg_max_sta_num +------------------- + "./uaputl.exe sys_cfg_max_sta_num [STA_NUM]" + + This command is used to set or get the maximum number of stations allowed to connect to uAP. + + If no arguments are given, this command returns the configured maximum number of stations + allowed to connect to uAP and maximum number of stations supported. + + Example: + ./uaputl.exe sys_cfg_max_sta_num 2 + Set AP's maximum station number to 2 + + ./uaputl.exe sys_cfg_max_sta_num + Get AP's maximum station number configured and maximum station number supported. + +sys_cfg_retry_limit +------------------- + "./uaputl.exe sys_cfg_retry_limit [RETRY_LIMIT]" + + This command is used to set or get the retry limit to use for packet transmissions. + + The maximum retry_limit allowed is 14. + + If no arguments are given, this command returns the current retry limit value. + + Example: + ./uaputl.exe sys_cfg_retry_limit 2 + Set AP's retry limit value to 2 + + ./uaputl.exe sys_cfg_retry_limit + Get AP's retry limit value + +sys_cfg_sticky_tim_config +------------------------- + "./uaputl.exe sys_cfg_sticky_tim_config [ENABLE] [ ]" + + This command is used to set or get sticky TIM configuration. + + ENABLE is used to enable or disable sticky TIM feature. + Following are the valid values of ENABLE + 0- disable SticktyTIM + 1- enable StickyTIM (Both DURATION in beacons and STICKY_BIT_MASK must be provided) + 2- enable StickyTIM (enable sticky TIM without changing previous values of + DURATION and STICKY_BIT_MASK) + + When bit 0 of STICKY_BIT_MASK is set, TIM bit is made sticky and when + cleared, normal TIM bit updates resume. + When bit 1 of STICKY_BIT_MASK is set, MoreData bit is made sticky and when + cleared, normal MoreData bit updates resume. + STICKY_BIT_MASK = 0 is NOT a valid configuration value. + + If no argument is given, this command returns current sticky TIM configuration. + + Example: + ./uaputl.exe sys_cfg_sticky_tim_config + Get sticky TIM configuration. + + ./uaputl.exe sys_cfg_sticky_tim_config 0 + Disable sticky TIM feature. + + ./uaputl.exe sys_cfg_sticky_tim_config 1 30 1 + Enable sticky TIM feature with DURATION of 30 beacons and + STICKY_BIT_MASK set to 1. + +sys_cfg_sticky_tim_sta_mac_addr +------------------------------- + "./uaputl.exe sys_cfg_sticky_tim_sta_mac_addr [CONTROL] [STA_MAC_ADDRESS]" + + This command is used to set or get sticky TIM control parameter for associated station. + + CONTROL when set to 1, sticky TIM bit for that station is activated. + When set to 0, sticky TIM bit for that station is deactivated. + + If no argument is given, it returns sticky TIM configuration for all associated stations. + If only STA_MAC_ADDRESS is provided, it returns sticky TIM configartion for that station. + + Example: + ./uaputl.exe sys_cfg_sticky_tim_sta_mac_addr + Get sticky TIM configuration for all associated stations. + + ./uaputl.exe sys_cfg_sticky_tim_sta_mac_addr 00:50:43:20:11:22 + Get control parameter for station 00:50:43:20:11:22. + + ./uaputl.exe sys_cfg_sticky_tim_sta_mac_addr 1 00:50:43:20:11:22 + Set control parameter for station with MAC address 00:50:43:20:11:22 to 1. + + Note:TIM bit for an associated STA is made sticky only if both below mentioned + conditions are satisfied + 1.Enable = 1 or 2 in most recently received sys_cfg_sticky_tim_config command, and + 2.Control = 1 in most recently received sys_cfg_sticky_tim_sta_mac_addr + with this station MAC address. + +sys_cfg_2040_coex +------------------------------- + "./uaputl.exe sys_cfg_2040_coex [ENABLE]" + + This command is used to set or get 20/40 BSS coexistence configuration. + + ENABLE when set to 0, disables 20/40 coex. + When set to 1, enables 20/40 coex. + + If no argument is given, it returns 20/40 BSS coex configuration. + + Example: + ./uaputl.exe sys_cfg_2040_coex + Get 20/40 BSS coexistence configuration. + + ./uaputl.exe sys_cfg_2040_coex 0 + Disable 20/40 BSS coexistence. + + ./uaputl.exe sys_cfg_2040_coex 1 + Enable 20/40 BSS coexistence. + + Note:20/40 BSS coex configuration can be set only before starting BSS. + +sys_cfg_eapol_pwk_hsk +--------------------- + "./uaputl.exe sys_cfg_eapol_pwk_hsk [ ]" + + This command is used to set or get pairwise handshake update timeout and + number of retries. + + Both TIMEOUT and number of RETRIES should be provided for a 'set'. + + If no arguments are given, this command returns timeout value and number + of + retries for pairwise key. + + Example: + ./uaputl.exe sys_cfg_eapol_pwk_hsk 50 2 + Set AP's pairwise key timeout to 50ms and number of retries to 2. + + ./uaputl.exe sys_cfg_eapol_pwk_hsk + Get AP's pairwise key timeout and number of retries. + +sys_cfg_eapol_gwk_hsk +--------------------- + "./uaputl.exe sys_cfg_eapol_gwk_hsk [ ]" + + This command is used to set or get groupwise handshake update timeout and + number of retries. + + Both TIMEOUT and number of RETRIES should be provided for a 'set'. + + If no arguments are given, this command returns timeout value and number + of retries for groupwise key. + + Example: + ./uaputl.exe sys_cfg_eapol_gwk_hsk 50 2 + Set AP's groupwise key timeout to 50ms and number of retries to 2. + + ./uaputl.exe sys_cfg_eapol_gwk_hsk + Get AP's groupwise key timeout and number of retries. + +sta_filter_table +---------------- + "./uaputl.exe sta_filter_table []" + + This command is used to get or set the client station MAC address + filter table. + + The supported options are: + FILTERMODE : 0 - Disable filter table + 1 - Allow mac address specified in the allowed list + 2 - Block MAC addresses specified in the banned list + MACADDRESS_LIST is the list of MAC addresses to be acted upon. Each + MAC address must be separated with a space. Maximum of 16 MAC addresses + are supported. + + empty - Get current client station MAC address filter table. + + Example: + ./uaputl.exe sta_filter_table 0 + Disable filter table + + ./uaputl.exe sta_filter_table 1 00:50:43:20:aa:bb + Set AP's filter mode to allow, only MAC address "00:50:43:ab:bb" will be allowed. + + ./uaputl.exe sta_filter_table + Get AP's filter table settings. + +regrdwr +------- + "./uaputl.exe regrdwr [value]" + + These commands are used to read the MAC, BBP and RF registers from the card. + TYPE can take 3 values, 1 - read/write MAC register + 2 - read/write BBP register + 3 - read/write RF register + 0x81 - read/write MAC2 register + 0x82 - read/write BBP2 register + 0x83 - read/write RF2 register + + OFFSET specifies the offset location that is to be read. + This parameter can be specified either in decimal or in hexadecimal (by preceding the number with a "0x"). + + value if specified, then that value will be written to that offset in the specified register. Value should be + specified in hexadecimal. + + Example: + ./uaputl.exe regrdwr 1 0xa123 + read MAC register 0xa123 + + ./uaputl.exe regrdwr 1 0xa123 0xaa + write 0xaa to MAC register 0xa123 + + ./uaputl.exe regrdwr 2 0x0123 + read BBP register 0x0123 + + ./uaputl.exe regrdwr 2 0x0123 0xaa + write 0xaa to BBP register 0x0123 + + ./uaputl.exe regrdwr 3 0x0123 + read RF register 0x0123 + + ./uaputl.exe regrdwr 3 0x0123 0xaa + write 0xaa to RF register 0x0123 + +memaccess +--------- + "./uaputl.exe memaccess [value]" + This commands is used to read/write to a memory address + + ADDR specifies the address of the location that is to be read/write + This parameter can be specified either in decimal or in hexadecimal (by preceding the number with a "0x"). + + value if specified, then that value will be written to that address in the specified register. + + Example: + ./uaputl.exe memaccess 0xc00153e4 + read contents of memory location 0xc00153e4 + + + ./uaputl.exe memaccess 0xc00153e4 0xaabbccdd + write value 0xaabbccdd to memory location 0xc00153e4 + +rdeeprom +-------- + "./uaputl.exe rdeeprom " + + This command is used to read bytes from offset location on + EEPROM + + offset: 0,4,8,..., multiple of 4 + bytecount: 4-20, multiple of 4 + + Example: + ./uaputl.exe rdeeprom 200 12 + read 12 bytes from offset 200 ON EEPROM + +cfg_data +-------- + "./uaputl.exe cfg_data [*.conf]" + + This command is used to set/get the configuration data to/from the firmware. + + type: 2 -- cal data + + Example: + ./uaputl.exe cfg_data 2 cal_data.conf + read cal_data from cal_data.conf and download to firmware. + ./uaputl.exe cfg_data 2 + read cal_data from firmware + +sys_cfg_80211d +-------------- + "./uaputl.exe sys_cfg_80211d [state STATE] [country COUNTRY]" + This command is used to set/get 802.11D specific parameters. + If no parameters are provided, this command returns state, country and + domain information. + + Allowed values for state are 0 for disable and 1 for enable. + COUNTRY is a two letter string input (derived from ISO 3166 code; + http://www.iso.org/iso/country_codes/iso_3166_code_lists/english_country_names_and_code_elements.htm + ) + + Countries are mapped with specific domain in file "80211d_domain.conf". In + order to set customize band setting, user can modify 80211d_domain.conf + file. + + Example: + ./uaputl.exe sys_cfg_80211d state 0 + To-disable + + ./uaputl.exe sys_cfg_80211d state 1 + To-enable + + ./uaputl.exe sys_cfg_80211d country IN + for using country as INDIA + + ./uaputl.exe sys_cfg_80211d state 1 country US + for enabling and setting country in single command. + +sys_cfg_80211d_country_ie +------------------------- + "./uaputl.exe sys_cfg_80211d_country_ie [clear | country COUNTRY]" + This command is used to set/get/clear 802.11D beacon custom country IE + parameters. If no parameters are provided, this command returns country and + domain information. The set/clear action can be specified only before + starting the bss. + + COUNTRY is a two letter string input (derived from ISO 3166 code; + http://www.iso.org/iso/country_codes/iso_3166_code_lists/english_country_names_and_code_elements.htm) + + Countries are mapped with specific domain in file "80211d_country_ie.conf". In + order to set customize band setting, user can modify 80211d_country_ie.conf + file. + + Example: + ./uaputl.exe sys_cfg_80211d_country_ie country FR + for using country as France + + ./uaputl.exe sys_cfg_80211d_country_ie clear + for clearing currently set custom country IE + +uap_stats +--------- + "./uaputl.exe uap_stats" + This command is used to get uAP statistics. + + Example: + ./uaputl.exe uap_stats + +pscfg +--------- + "./uaputl.exe pscfg [MODE] [CTRL INACTTO MIN_SLEEP MAX_SLEEP MIN_AWAKE MAX_AWAKE] + + This command is used to set or get the AP's power mode and power save params. + + The supported options are: + MODE : 0 - disable power mode + 2 - enable inactivity based power save mode + + PS PARAMS: + CTRL: 0 - disable protection frame Tx before PS + 1 - enable protection frame Tx before PS + INACTTO: Inactivity timeout in microseconds, default value is 200000 us + MIN_SLEEP: Minimum sleep duration in microseconds, default value 17000 us + MAX_SLEEP: Maximum sleep duration in microseconds, default value 17000 us + The value of MIN_SLEEP should be >= 5000 us. + The value of MAX_SLEEP should be <= beacon interval(when ctrl: 0). + The value of MAX_SLEEP should be <= 32000 us(when ctrl: 1). + + MIN_AWAKE: Minimum awake duration in microseconds, default value is 2000 us + MAX_AWAKE: Maximum awake duration in microseconds, default value is 2000 us + The value of MIN_AWAKE should be >= 2000 us. + MIN_AWAKE,MAX_AWAKE only valid when MODE is set to inactivity based power save mode. + + + empty - Get current power mode and power save params. + + Example: + ./uaputl.exe pscfg 0 + Disable AP's power mode. + + ./uaputl.exe pscfg 2 + Enable inactivity based power save mode. + + ./uaputl.exe pscfg 2 1 400000 20000 20000 10000 10000 + Enable inactivity based power save mode, enable protection, set inactivity timeout 400000 us + set minimum sleep duration to 20000 us, maximum sleep duration to 20000 us + and set minimum awake duration to 10000us, maximum awake duration to 10000 us + + ./uaputl.exe pscfg + Get current AP's power mode and power save params. + +hscfg +----- + ./uaputl.exe hscfg [condition [[GPIO# [gap]]]] + This command is used to configure the host sleep parameters. + + This command takes one (condition), two (condition and GPIO#) or three + (condition, GPIO# and gap) parameters for set. If no parameter provided, + get is performed. + + where Condition is: + bit 0 = 1 -- broadcast data + bit 1 = 1 -- unicast data + bit 2 = 1 -- mac event + bit 3 = 1 -- multicast data + bit 6 = 1 -- Wakeup when mgmt frame received. + + The host sleep mode will be cancelled if condition is set to 0xffff. + The default is 0x7. + + where GPIO is the pin number of GPIO used to wakeup the host. It could be any valid + GPIO pin# (e.g. 0-7) or 0xff (interface, e.g. SDIO will be used instead). + The default is 0xff. + + where Gap is the gap in milliseconds between wakeup signal and wakeup event or 0xff + for special setting (host acknowledge required) when GPIO is used to wakeup host. + The default is 200. + + Examples: + ./uaputl.exe hscfg : Get current host sleep mode + ./uaputl.exe hscfg 0xffff : Cancel host sleep mode + ./uaputl.exe hscfg 3 : Broadcast and unicast data + Use GPIO and gap set previously + ./uaputl.exe hscfg 2 3 : Unicast data + Use GPIO 3 and gap set previously + ./uaputl.exe hscfg 2 1 0xa0 : Unicast data + Use GPIO 1 and gap 160 ms + ./uaputl.exe hscfg 2 0xff : Unicast data + Use interface (e.g. SDIO) + Use gap set previously + ./uaputl.exe hscfg 4 3 0xff : MAC event + Use GPIO 3 + Special host sleep mode + ./uaputl.exe hscfg 1 0xff 0xff : Broadcast data + Use interface (e.g. SDIO) + Use gap 255ms + +hssetpara +--------- + ./uaputl.exe hssetpara condition [[GPIO# [gap]]] + This command is used to configure the host sleep parameters. + + Note: + 1) The usages of parameters are the same as "hscfg" command. + 2) The parameters will be saved in the driver and be used when host suspends. + +sta_deauth_ext +-------------- + "./uaputl.exe sta_deauth_ext " + + This command is used to de-authenticate a client station with specific reason code. + + Example: + ./uaputl.exe sta_deauth_ext 00:50:43:20:34:58 4 + deauth station 00:50:43:20:34:58 with IEEE reason code 4 (Disassociated due to inactivity) + +mic_err +------- + "./uaputl.exe mic_err " + + This command is used to report station mic error. + + Example: + ./uaputl.exe mic_err 00:50:43:20:34:58 + report mic err for station 00:50:43:20:34:58 + +key_material +------------ + "./uaputl.exe key_material [KEY_ID]" + + This command is used to set key. Get operation is not supported. + + MAC_ADDRESS: station mac address while setting station unicast key + ff:ff:ff:ff:ff:ff while setting multicast key + + KEY: hex string, allowed length should be 32 or 64. + KEY_ID: default value is 0. + + Example: + ./uaputl.exe key_material ff:ff:ff:ff:ff:ff 12345678901234567890123456789012 1 + set group key, key value is "12345678901234567890123456789012", key id is 1 + + ./uaputl.exe key_material 00:50:43:20:34:58 1234567890123456789012345678901234567890123456789012345678901234 + set station 00:50:43:20:34:58 unicast key, + key value is "1234567890123456789012345678901234567890123456789012345678901234" + +sys_cfg_custom_ie +----------------- + "./uaputl.exe sys_cfg_custom_ie [INDEX] [MASK] [IEBuffer]" + + This command is used to set or get custom IEs for management frames. + + The supported options are: + INDEX: 0 - IE Index is 0 + 1 - IE Index is 1 + 2 - IE Index is 2 + MAX IE Index depends on device memory. + + -1 - Append/Delete IE automatically + Delete will delete the IE from the matching IE buffer + Append will append the IE to the buffer with the same mask + MASK : Management subtype mask value as per bit definitions + : Bit 0 - Association request. + : Bit 1 - Association response. + : Bit 2 - Reassociation request. + : Bit 3 - Reassociation response. + : Bit 4 - Probe request. + : Bit 5 - Probe response. + : Bit 8 - Beacon. + MASK : MASK = 0 to clear the mask and the IE buffer + + IEBuffer: IE buffer to set in hexadecimal bytes. + The Buffer should not be space separated. + ( Maximum length = 256 bytes ) + empty - Get IE buffer, subtype mask settings for all the indices [0-3]. + INDEX - Only INDEX will get the IE buffer configured for the particular + Index. + + Example: + ./uaputl.exe sys_cfg_custom_ie + Get IE buffer, subtype mask settings for all indices. + + ./uaputl.exe sys_cfg_custom_ie 1 + Get IE buffer and subtype mask WEP key (use of WEP/TKIP is not recommended anymore) setting for the Index = 1. + + ./uaputl.exe sys_cfg_custom_ie 2 0 + Clear IE buffer and mask value for Index = 2. + + ./uaputl.exe sys_cfg_custom_ie 3 0x101 0xdd051234567890 + Set IE buffer and mask value for Index = 3. + + ./uaputl.exe sys_cfg_custom_ie -1 0x101 0xdd051234567890 + Append the specified IEBuffer at index with mask value of 0x101 + + ./uaputl.exe sys_cfg_custom_ie -1 0 0xdd051234567890 + Delete the specified IEBuffer from all the IEs. + + ./uaputl.exe sys_cfg_custom_ie 2 0 0xdd051234567890 + Delete the specified IEBuffer from the IEs at index 2. + +coex_config +----------- + "./uaputl.exe coex_config [CONFIG_FILE]" + This command is used to set or get the BT coex configuration settings. + + The supported options are: + CONFIG_FILE is file contain all the BT coex settings. + empty - Get current BT coex settings + + Example: + ./uaputl.exe coex_config + Get current BT coex settings. + + ./uaputl.exe coex_config uapcoex.conf + Load BT coex configuration settings from uapcoex.conf file and set. + +sys_cfg_wmm +----------- + "./uaputl.exe sys_cfg_wmm [qosinfo=] + [0] + [AC_BE AIFSN ECW_MAX ECW_MIN TX_OP] + [AC_BK AIFSN ECW_MAX ECW_MIN TX_OP] + [AC_VI AIFSN ECW_MAX ECW_MIN TX_OP] + [AC_VO AIFSN ECW_MAX ECW_MIN TX_OP]" + + This command can be used set/get beacon WMM parameters + + The supported option are: + qosinfo: qos information. User can set only MSB. Valid values are 0x80 and 0x00. + Lower 4 bits are managed by FW. Hence, value read for qosinfo may have + lower 4 bits non-zero. + + AC_BE: 0 + AC_BK: 1 + AC_VI: 2 + AC_V0: 3 + AIFSN: AIFSN value + ECW_MAX: ECW max + ECW_MIN: ECW min + TX_OP: TXOP Limit + empty - Get current WMM parameters + When all the parameter are 0, wmm will be disabled. + + Example: + ./uaputl.exe sys_cfg_wmm 0 3 10 4 0 + Set AC_BE with AIFSN 3, ECW_MAX 10, ECW_MIN 4 and TXOP 0 + + ./uaputl.exe sys_cfg_wmm 1 7 10 4 0 + Set AC_BK with AIFSN 7, ECW_MAX 10, ECW_MIN 4 and TXOP 0 + + ./uaputl.exe sys_cfg_wmm 2 2 4 3 94 + Set AC_VI with AIFSN 2, ECW_MAX 4, ECW_MIN 3 and TXOP 94 + + ./uaputl.exe sys_cfg_wmm 3 2 3 2 47 + Set AC_VO with AIFSN 2, ECW_MAX 3, ECW_MIN 2 and TXOP 47 + + ./uaputl.exe sys_cfg_wmm + Get current wmm parameters + + ./uaputl.exe sys_cfg_wmm 0 3 10 4 0 1 7 10 4 0 2 2 4 3 94 3 2 3 2 47 + Set AC_BE with AIFSN 3, ECW_MAX 10, ECW_MIN 4 and TXOP 0 + Set AC_BK with AIFSN 7, ECW_MAX 10, ECW_MIN 4 and TXOP 0 + Set AC_VI with AIFSN 2, ECW_MAX 4, ECW_MIN 3 and TXOP 94 + Set AC_VO with AIFSN 2, ECW_MAX 3, ECW_MIN 2 and TXOP 47 + + ./uaputl.exe sys_cfg_wmm qosinfo=0x80 0 3 10 4 0 1 7 10 4 0 2 2 4 3 94 3 2 3 2 47 + Enable wmm PS mode. + Set AC_BE with AIFSN 3, ECW_MAX 10, ECW_MIN 4 and TXOP 0 + Set AC_BK with AIFSN 7, ECW_MAX 10, ECW_MIN 4 and TXOP 0 + Set AC_VI with AIFSN 2, ECW_MAX 4, ECW_MIN 3 and TXOP 94 + Set AC_VO with AIFSN 2, ECW_MAX 3, ECW_MIN 2 and TXOP 47 + + ./uaputl.exe sys_cfg_wmm 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + ./uaputl.exe sys_cfg_wmm 0 + Disable wmm + +sys_cfg_ap_wmm +----------- + "./uaputl.exe sys_cfg_ap wmm [0] + [AC_BE AIFSN ECW_MAX ECW_MIN TX_OP] + [AC_BK AIFSN ECW_MAX ECW_MIN TX_OP] + [AC_VI AIFSN ECW_MAX ECW_MIN TX_OP] + [AC_VO AIFSN ECW_MAX ECW_MIN TX_OP]" + + This command can be used set/get AP WMM parameters + + The supported option are: + AC_BE: 0 + AC_BK: 1 + AC_VI: 2 + AC_V0: 3 + AIFSN: AIFSN value + ECW_MAX: ECW max + ECW_MIN: ECW min + TX_OP: TXOP Limit + empty - Get current AP WMM parameters + When all the parameter are 0, AP wmm will be disabled. + + Example: + ./uaputl.exe sys_cfg_ap_wmm 0 3 10 4 0 + Set AC_BE with AIFSN 3, ECW_MAX 10, ECW_MIN 4 and TXOP 0 + + ./uaputl.exe sys_cfg_ap_wmm 1 7 10 4 0 + Set AC_BK with AIFSN 7, ECW_MAX 10, ECW_MIN 4 and TXOP 0 + + ./uaputl.exe sys_cfg_ap_wmm 2 2 4 3 94 + Set AC_VI with AIFSN 2, ECW_MAX 4, ECW_MIN 3 and TXOP 94 + + ./uaputl.exe sys_cfg_ap_wmm 3 2 3 2 47 + Set AC_VO with AIFSN 2, ECW_MAX 3, ECW_MIN 2 and TXOP 47 + + ./uaputl.exe sys_cfg_ap_wmm + Get current AP wmm parameters + + ./uaputl.exe sys_cfg_ap_wmm 0 3 10 4 0 1 7 10 4 0 2 2 4 3 94 3 2 3 2 47 + Set AC_BE with AIFSN 3, ECW_MAX 10, ECW_MIN 4 and TXOP 0 + Set AC_BK with AIFSN 7, ECW_MAX 10, ECW_MIN 4 and TXOP 0 + Set AC_VI with AIFSN 2, ECW_MAX 4, ECW_MIN 3 and TXOP 94 + Set AC_VO with AIFSN 2, ECW_MAX 3, ECW_MIN 2 and TXOP 47 + + ./uaputl.exe sys_cfg_ap_wmm 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + ./uaputl.exe sys_cfg_ap_wmm 0 + Disable AP wmm + +addbapara +--------- + "./uaputl.exe addbapara [timeout txwinsize rxwinsize txamsdu rxamsdu]" + This command can be used to update the default ADDBA parameters. + + The supported options are: + timeout - This is the block ack timeout for ADDBA request. + 0 : Disable (recommended for throughput test) + 1 - 65535 : Block Ack Timeout in TU + txwinsize - Buffer size for ADDBA request. (32 is default value) + rxwinsize - Buffer size for ADDBA response. (16 is default value) + txamsdu - amsdu support for ADDBA request. (1 is default value) + 0 : Disable amsdu in ADDBA request. + 1 - Enable amsdu in ADDBA request. + rxamsdu - amsdu support for ADDBA response. (1 is default value) + 0 : Disable amsdu in ADDBA response. + 1 - Enable amsdu in ADDBA response. + empty - Get current ADDBA parameters. + + Current window size limit for Tx as well as Rx is 1023. + + Example: + ./uaputl.exe addbapara + Get the current addba params + ./uaputl.exe addbaparam 1000 64 8 0 0 + This will change the ADDBA timeout to (1000 * 1024) us, txwinsize to 64 and rxwinsize to 8 + and disable AMSDU in ADDBA request/response. + + In case the ADDBA timeout value is updated then a ADDBA is sent for all streams + to update the timeout value. + + In case txwinsize and/or rxwinsize is updated, the effect could only be seen on + next ADDBA request/response. The current streams will not be affected with this + change. + + In case of txamdsdu/rxamsdu is updated, the effect could only be seen on + next ADDBA request/response. The current streams will not be affected with this + change. AMSDU in AMPDU stream will be enabled when AP support this feature + and AMSDU is enabled in aggrpriotbl. + +sys_cfg_11n +----------- + "./uaputl.exe sys_cfg_11n [ENABLE] [HTCAP] [AMPDU] [TXBFCAP] [HT_MCS_CAP]" + This command can be used set/get 802.11n parameters. + + The supported option are: + ENABLE: 0 - disable 802.11n in uap + 1 - enable 802.11n in uap + Note: If 802.11n is disabled, 802.11ac MUST be disabled at the same time + HTCAP: HT Capabilities info (default value is 0x111c) + Bit 15-13: Reserved set to 0 + Bit 12: DSS/CCK mode in 40MHz enable/disable + Bit 11-10: Reserved set to 0 + Bit 9-8: Reserved set to 0x01 + Bit 7: STBC enable/disable + Bit 6: Short GI in 40 Mhz enable/disable + Bit 5: Short GI in 20 Mhz enable/disable + Bit 4: Green field enable/disable + Bit 3-2: Reserved set to 1 + Bit 1: 20/40 Mhz enable disable. + Bit 0: LDPC enable/disable + AMPDU: A-MPDU Parameter (default value is 0x03) + Bit 7-5: Reserved set to 0 + Bit 4-2: Minimum MPDU Start spacing + Set to 0 for no restriction + Set to 1 for 1/4 us + Set to 2 for 1/2 us + Set to 3 for 1 us + Set to 4 for 2 us + Set to 5 for 4 us + Set to 6 for 8 us + Set to 7 for 16 us + Bit 1-0: Max A-MPDU length + TXBFCAP: TX Beamforming capabilities + Bit 0 : Implicit TX BF receiving capable + Bit 1 : RX staggered sounding capable + Bit 2 : TX staggered sounding capable + Bit 3 : RX NDP capable + Bit 4 : TX NDP capable + Bit 5 : Implicit TX BF capable + Bit 6-7 : Calibration + 0: - not supported + 1: - STA can respond to a calibration request using + the CSI Report, but cannot initiate calibration + 2: - reserved + 3: - STA can both initiate and respond to a calibration request + Bit 8 : Explicit CSI TX BF capable + Bit 9 : Explicit non-compressed steering capable + Bit 10 : Explicit compressed steering capable + Bit 11-12: Explicit TX BF CSI feedback + 0: - not supported + 1: - delayed feedback + 2: - immediate feedback + 3: - delayed and immediate feedback + Bit 13-14: Explicit non-compressed BF feedback capable + 0: - not supported + 1: - delayed feedback + 2: - immediate feedback + 3: - delayed and immediate feedback + Bit 15-16: Explicit compressed BF feedback capable + 0: - not supported + 1: - delayed feedback + 2: - immediate feedback + 3: - delayed and immediate feedback + Bit 17-18: Minimal grouping + 0: - no grouping (STA supports groups of 1) + 1: - groups of 1, 2 + 2: - groups of 1, 4 + 3: - groups of 1, 2, 4 + Bit 19-20: CSI number of beamformer antennas supported + 0: - single TX antenna sounding + 1: - 2 TX antenna sounding + 2: - 3 TX antenna sounding + 3: - 4 TX antenna sounding + Bit 21-22: Non-compressed steering number of beamformer antennas supported + 0: - single TX antenna sounding + 1: - 2 TX antenna sounding + 2: - 3 TX antenna sounding + 3: - 4 TX antenna sounding + Bit 23-24: Compressed steering number of beamformer antennas supported + 0: - single TX antenna sounding + 1: - 2 TX antenna sounding + 2: - 3 TX antenna sounding + 3: - 4 TX antenna sounding + Bit 25-26: CSI max number of rows beamformer supported + 0: - single row of CSI + 1: - 2 rows of CSI + 2: - 3 rows of CSI + 3: - 4 rows of CSI + Bit 27-28: Channel estimation capability + 0: - 1 space time stream + 1: - 2 space time streams + 2: - 3 space time streams + 3: - 4 space time streams + Bit 29-31: Reserved + HT_MCS_MAP: MCS rate bitmap + Bit 0-7 : MCS_SET_0 + Bit 15-8 : MCS_SET_1 + empty - Get current 802.11n parameters. + + Example: + ./uaputl.exe sys_cfg_11n 1 0x117e 3 + enable 802.11n, and set HT Capabilities info to 0x117e, and A-MPDU Parameter to 0x03 + ./uaputl.exe sys_cfg_11n 1 0x117e 3 0xFFFFFFFF + enable 802.11n, and set HT Capabilities info to 0x117e, A-MPDU + Parameter to 0x03 and TX Beamforming capabilities to 0xFFFFFFFF + ./uaputl.exe sys_cfg_11n 1 0x117e 3 0xFFFFFFFF 0x00100023 + enable 802.11n, and set HT Capabilities info to 0x117e, A-MPDU + Parameter to 0x03, TX Beamforming capabilities to 0xFFFFFFFF and + MCS rate bitmap to 0x00100023. + ./uaputl.exe sys_cfg_11n 0 + disable 802.11n in uap + ./uaputl.exe sys_cfg_11n + Get current 802.11n parameters + +aggrpriotbl +----------- + "./uaputl.exe aggrpriotbl ... " + This command is used set/get the priority table for AMPDU/AMSDU traffic per tid. + This command can also be used to disable AMPDU/AMSDU for a given tid. + In case of AMPDU this priority table will be used to setup block ack (to make + sure the highest priority tid always uses AMPDU as we have limited AMPDU streams) + + The supported option are: + ... + + - This is priority for Tid0 for AMPDU packet. A priority could be any + values between 0 - 7, 0xff to disable aggregation. + - This is priority for Tid0 for AMSDU packet. A priority could be any + values between 0 - 7, 0xff to disable aggregation. + + empty - Get current priority table for AMPDU/AMSDU traffic. + + Example: + ./uaputl.exe aggrpriotbl + This command will get the current Priority table for AMPDU and AMSDU. + <2 2 0 0 1 1 3 3 4 4 5 5 255 255 255 255>. This is read as + <"Prio for AMPDU for Tid0" "Prio for AMSDU for Tid0" + "Prio for AMPDU for Tid1" "Prio for AMSDU for Tid1" and so on + + ./uaputl.exe aggrpriotbl 2 2 0 0 1 1 3 3 4 4 5 5 255 255 255 255 + This will set the priority table for AMPDU and AMSDU + Priority for Tid0/AMPDU = 2, Tid0/AMSDU = 2, Tid1/AMPDU = 0, Tid1/AMSDU = 0 + and so on. Aggregation for Tid6 and Tid7 are disabled. + Here higher the priority number, higher the priority (i.e. 7 + has higher priority than 6). Similarly for AMSDU. + + ./uaputl.exe aggrpriotbl 0xff 2 0xff 0 0xff 1 0xff 3 0xff 4 0xff 5 0xff 0xff 0xff 0xff + This will disable AMPDU for all the TIDs but will still keep AMSDU enabled to Tid0 to Tid5 + + The default setting is 2 255 0 255 1 255 3 255 4 255 5 255 255 255 255 255. + + A delBA should be seen in case a disable happens on a TID for which AMPDU stream + is currently setup. + + Note:- This command should only be issued in disconnected state. + +addbareject +----------- + "./uaputl.exe addbareject ... " + This command is used set/get the addbareject table for all the TIDs. + This command can also be used to enable rejection of ADDBA requests for a given tid. + + The supported option are: + ... + - This can be 0/1 for TidX. 1 enables rejection of ADDBA request for TidX and + 0 would accept any ADDBAs for TidX. + empty - Get current addbareject table for all the TIDs. + + Example: + ./uaputl.exe addbareject + This command will get the current table. + [0 0 0 0 0 0 1 1]. ADDBA would be accepted for all TIDs except for TID [6,7]. + This is the default state. + + ./uaputl.exe addbareject 0 0 1 1 0 0 0 0 + This command will accept ADDBA requests for Tid [0,1,4,5,6,7] and reject ADDBA requests for Tid [2,3] + + ./uaputl.exe addbareject 1 1 1 1 1 1 1 1 + This will enable rejection of ADDBA requests for all Tids. + + Note:- This command should only be issued in disconnected state. + +sys_cfg_tdls_ext_cap +-------------------- + + "./uaputl.exe sys_cfg_tdls_ext_cap [CONFIG_FILE]" + + This command is used to set/get TDLS extended capability settings. + + If CONFIG_FILE is provided, a SET is performed , else a GET is performed. + + Examples: + ./uaputl.exe sys_cfg_tdls_ext_cap config/tdls_ext_cap.conf + Set TDLS extended capability parameters in the config file. + ./uaputl.exe sys_cfg_tdls_ext_cap + Get TDLS extended capability parameters. + +sys_cfg_wacp_mode +----------------- + "./uaputl.exe sys_cfg_wacp_mode [MODE]" + + This commands is used to configure WACP mode. + + 0 - default mode, disable WACP + 1 - enable WACP mode 1 + 2 - enable WACP mode 2 + + Examples: + ./uaputl.exe sys_cfg_wacp_mode 1 : Enable WACP Mode 1 + ./uaputl.exe sys_cfg_wacp_mode 0 : Disable WACP Mode + + "./uaputl.exe skip_cac []" + + This command is used to enable/disable skip CAC on a particular channel. + + 5G DFS channel + 0 - disable skip cac + 1 - enable skip cac + 0 - 20 Mhz (default) + 2 - 40 Mhz + 3 - 80 Mhz + + Examples: + ./uaputl.exe skip_cac 52 1 : Enable skip CAC on channel 52 + ./uaputl.exe skip_cac 52 0 : Disable skip CAC on channel 52 + ./uaputl.exe skip_cac 52 1 3 : Enable skip CAC on channel 52 with bandwidth 80Mhz. + +httxbfcfg +--------- + "./uaputl.exe httxbfcfg [ACT_DATA]" + + This command is used to configure the TX beamforming options. + + The supported options are: + ACTION: 0 - Control global parameters for beamforming + 1 - Performs NDP Sounding for PEER + 2 - TX BF interval in milliseconds + 3 - Enable/Disable beamforming/sounding for the indicated peer. + 4 - TX BF SNR Threshold for peer + ACT_DATA: Specific data for the above actions + For ACTION 0 - Beamforming enable/disable, sounding enable/disable, + FB type, snr_threshold, sounding interval, Beamformig mode + For ACTION 1 - PEER MAC and status + For ACTION 2 - TX BF interval + For ACTION 3 - PEER MAC + For ACTION 4 - PEER MAC and SNR + empty - Get action specific settings + + Examples: + ./uaputl.exe httxbfcfg 0 : Get current global configuration parameter + ./uaputl.exe httxbfcfg 2 00:50:43:20:BF:64 : Get the TX BF periodicity for a given peer + ./uaputl.exe httxbfcfg 3 : Get the list of MAC addresses that have + beamforming and/or sounding enabled + ./uaputl.exe httxbfcfg 4 : Get the list of PEER MAC, SNR tuples + programmed into the firmware. + ./uaputl.exe httxbfcfg 0 0 0 3 10 500 5 : Disable beamforming, sounding, set FB type + to 3, snr threshold to 10, sounding interval + to 500 ms and beamforming mode to 5 + ./uaputl.exe httxbfcfg 1 00:50:43:20:BF:64 : Perform NDP Trigger sounding to peer + 00:50:43:20:BF:64 + ./uaputl.exe httxbfcfg 2 00:50:43:20:BF:64 500 : Set TX BF periodicity for peer 00:50:43:20:BF:64 + to 500 milliseconds + ./uaputl.exe httxbfcfg 3 00:50:43:20:BF:43 1 0 3 : Enable beamforming, disable sounding and set + FB type to 3 for peer 00:50:43:20:BF:43 + ./uaputl.exe httxbfcfg 4 00:50:43:20:BF:24 43 : Set TX BF SNR threshold to peer + + +httxcfg + This command is used to configure various 11n specific configuration + for transmit (such as Short GI, Channel BW and Green field support) + + where is + This is a bitmap and should be used as following + Bit 15-8: Reserved set to 0 + Bit 7: STBC enable/disable + Bit 6: Short GI in 40 Mhz enable/disable + Bit 5: Short GI in 20 Mhz enable/disable + Bit 4: Green field enable/disable + Bit 3-2: Reserved set to 1 + Bit 1: 20/40 Mhz enable disable. + Bit 0: LDPC enable/disable + + When Bit 1 is set then firmware could transmit in 20Mhz or 40Mhz based + on rate adaptation. When this bit is reset then firmware will only + transmit in 20Mhz. + + Example: + ./uaputl.exe -i uapX httxcfg + This will display HT Tx configuration. + + ./uaputl.exe -i uapX httxcfg 0x62 + This will enable 20/40 and Short GI but will disable Green field. + + ./uaputl.exe -i uapX httxcfg 0x30 + This will enable Short GI 20 Mhz and Green field. + + Note:- If 20/40 MHz support is disabled in htcapinfo, device will not transmit + in 40 MHz even 20/40 MHz is enabled in httxcfg. + +htstreamcfg + This command is used to set/get HT stream configuration. + The setting only takes effect in next association. + + Usage: + ./uaputl.exe -i uapX htstreamcfg [n] + + where + 0x11: HT stream 1x1 mode + 0x22: HT stream 2x2 mode + + Examples: + ./uaputl.exe -i uapX htstreamcfg : Get current setting + ./uaputl.exe -i uapX htstreamcfg 0x11 : Set HT stream 1x1 mode + ./uaputl.exe -i uapX htstreamcfg 0x22 : Set HT stream 2x2 mode + +deepsleep +--------- + "./uaputl.exe deepsleep [MODE] [IDLE_TIME]" + This command is used to set/get auto deep sleep mode. + + The supported option are: + [MODE]: Enable/disable auto deep sleep mode (1/0) + [IDLE_TIME]: Idle time in milliseconds after which firmware will put the device + in deep sleep mode. Default value is 100 ms. + empty - Get current deep sleep mode. + + Example: + ./uaputl.exe deepsleep : Display auto deep sleep mode + ./uaputl.exe deepsleep 1 : Enable auto deep sleep mode, idle time unchanged + ./uaputl.exe deepsleep 0 : Disable auto deep sleep mode + ./uaputl.exe deepsleep 1 500 : Enable auto deep sleep mode with idle time 500 ms + + Note: + Deepsleep must be disabled before changing idle time. + +txpwrlimit_cfg_get +txpwrlimit_2g_cfg_set +txpwrlimit_5g_cfg_set +------------------ + This command is used to set/get the configuration data of Tx power limitation. + Note: The configuration set should be issued when no STA is connected. + + Examples: + ./uaputl.exe hostcmd config/txpwrlimit_cfg.conf txpwrlimit_cfg_get + ./uaputl.exe hostcmd config/txpwrlimit_cfg.conf txpwrlimit_2g_cfg_set + ./uaputl.exe hostcmd config/txpwrlimit_cfg.conf txpwrlimit_5g_cfg_set + +tx_data_pause +------------- + "./uaputl.exe tx_data_pause [ENABLE][TX_BUF_CNT]" + + This command is used to set/get tx data pause settings. + + The supported option are: + [ENABLE]: Enable/disable pause tx events from firmware to host. + [TX_BUF_CNT]: Max number of TX buffers allowed for all PS clients + empty - Get current tx data pause settings + + Example: + ./uaputl.exe tx_data_pause : Display tx data pause settings + ./uaputl.exe tx_data_pause 1 : Enable pause tx event, max tx buffer number unchanged. + ./uaputl.exe tx_data_pause 0 : Disable pasue tx event, max tx buffer number unchanged. + ./uaputl.exe tx_data_pause 1 15 : Enable pause tx event, with max tx buffer number 15. + +vhtcfg + This command is used to set and get various 11ac specific configuration + for transmission and reception. For the SET operation, all paramaters + may be applied. For the GET operation, only the first two parameters are applied. + The 6th argument "rx_mcs_set" can be used to disbale/enable 802.11ac. + + where is + - This is the band setting for the vhtcfg + 0: Settings for both 2.4G and 5G bands (for SET operation, 11N BW only) + 1: Settings for 2.4G band (for 11N BW only) + 2: Settings for 5G band + + where is + - This parameter specifies the configuration of VHT operation for TX or/and VHT capabilities + 3: configuration of VHT capabilities (uAP only) + Note: For the UAP, only 3 is supported for txrx. + + where [l] is + - This parameter specifies the bandwidth (BW) configuration + applied to the vhtcfg. + If is 3 (For uAP), + 0: Tx BW follows the BW (20/40 MHz) from 11N CFG + 1: Tx BW follows the BW (80/160/80+80 MHz) from VHT Capabilities + defined in below for 5G band. + + where [m] is + - This parameter specifies the VHT capabilities info if is 2 (association) + or the VHT Tx operations if is 1 (Tx operations). + The VHT Tx operation should be a subset of VHT capabilities for association. + It is a bitmap and should be used as follows: + + Bit 31-30: Reserved and set to 0 + Bit 29: TX antenna pattern consistency + 1: antenna pattern does not change + 0: antenna pattern might change + Bit 28: RX antenna pattern consistency + 1: antenna pattern does not change + 0: antenna pattern might change + Bit 27-26: VHT link adaptation capable + 0: no feedback of VHT MFB from the STA + 1: unsolicted feedback of VHT MFB from the STA + 2: both response and unsolicted feedback of VHT MFB + from the STA + 3: reserved and set to 0 + Bit 25-23: Maximum A-MPDU length exponent + Bit 22: +HTC-VHT capable (1: enable. 0 disable) + Bit 21: VHT TXOP PS + Bit 20: MU beamformee capable (1: enable. 0 disable) + Bit 19: MU beamformer capable (1: enable. 0 disable) + Bit 18-16: Number of sounding dimensions (set to maximum-1 + if Bit 11 is 1. Otherwise, reserved and set to 0) + Bit 15-13: Compressed steering number of beamformer + antennas supported (set to maximum-1 if Bit 12 is 1. + Otherwise, reserved and set to 0) + Bit 12: SU beamformee capable (1: enable. 0 disable) + Bit 11: SU beamformer capable (1: enable. 0 disable) + Bit 10-8: Rx STBC + 0: no support + 1: support of 1 spatial stream + 2: support of 1-2 streams + 3: support of 1-3 spatial streams + 4: support of 1-4 spatial streams + 5-7: reserved and set to 0 + Bit 7: TX STBC (1: enable. 0 disable) + Bit 6: Short GI for 160 and 80+80 MHz (1: enable. 0 disable) + Bit 5: Short GI for 80 MHz (1: enable. 0 disable) + Bit 4: Rx LDPC (1: enable. 0 disable) + Bit 3-2: Supported channel width set. + 0: no support of either 160 or 80+80 MHz. + 1: support of 160 MHz + 2: support of both 160 and 80+80 MHz. + 3: reserved and set to 0. + Bit 1-0: Maximum MPDU length + 0: 3895 octets. + 1: 7991 octets. + 2: 11454 octets. + 3: reserved and set to 0. + + where [n] is , + - This parameter specifies the TX MCS map. It may not be used for the STA if is 1 (Tx operations). + It is a bitmap and should be used as following + Bit 15-0: MCS map, which is defined as folows: + Bit 15-14: Max MCS for 8 SS + Bit 13-12: Max MCS for 7 SS + Bit 11-10: Max MCS for 6 SS + Bit 9-8: Max MCS for 5 SS + Bit 7-6: Max MCS for 4 SS + Bit 5-4: Max MCS for 3 SS + Bit 3-2: Max MCS for 2 SS + Bit 1-0: Max MCS for 1 SS + + where [o] is . + - This parameter specifies the RX MCS map. It may not be used for the STA if is 1 (Tx operations). + It is a bitmap with the same sructure as for + rx_mcs_map = 0xffff : FW will disable 802.11ac + rx_mcs_map = others : FW will enable 802.11ac + + Note: The user setting of vhtcap may be overwritten by the driver + if the setting of those fields is beyond the hardware capabilities. + + Examples: + ./uaputl.exe -i uapX vhtcfg 2 3 : Get current VHT configuration in 5GHz for the uAP. + ./uaputl.exe -i uapX vhtcfg 2 3 0 0x000001f0 0xfffa 0xfffa + : Set the current/maximum VHT configuration in 5GHz for the uAP. + Both Tx and Rx supports MCS 0-9 for both 1 and 2 spatial streams. + ./uaputl.exe -i uapX vhtcfg 2 3 0 0x000001b0 + : Set the VHT capability information in 5GHz for the uAP, and keep the Tx/Rx MCS Map same as before. + +dfstesting +---------- + "./uaputl.exe dfstesting [ ]" + + This command is used to set/get DFS testing settings. + + The supported option are: + : user-configured Channel Availability Check in sec + 0 = disable, use default period (60 seconds) + 1-1800 = enable with that period + : user-configured Non-Occupancy Period in sec + 0 = disable, use default period (1800) + 1-65535 = enable with that period + : enable/disable no channel change on radar + 0 = disable, 1 = enable (overrides below) + : user-configured channel to change to on radar + 0 = disable, 1-255 = enable with that channel + (channel validity for region, etc. is not checked) + (only takes effect if no_chan_change = 0) + after CAC success, driver auto restart CAC again + + Example: + ./uaputl.exe dfstesting : Get current dfstesting settings + ./uaputl.exe dfstesting 60 0 0 0 0 : user_cac=60sec, others disabled/default + ./uaputl.exe dfstesting 0 0 1 0 0 : only no_chan_change enabled + ./uaputl.exe dfstesting 0 120 0 64 0 : user_nop=2min, force chan 64 on radar + ./uaputl.exe dfstesting 60 0 0 0 1 : user_cac=60sec, restart cac after success + +cscount +--------------- + + "./uaputl.exe cscount []" + + This command is used to configure the number of beacons AP sends with channel switch IE, before channel change due to + radar detection. If not configured, is set to 5 by default. + + The supported options are: + : user configured channel switch count + 5-20 = configure with that value + + Example: + ./uaputl.exe cscount : Get user configured channel switch count value + ./uaputl.exe cscount 10 : Set channel switch count to 10 + + +mgmtframectrl +------------- + "./uaputl.exe mgmtframectrl [MASK]" + + This command is used to set/get management frame control mask. + + where the parameter [MASK] is the bit mask of management frame reception. + Following are the bit definitions. + Bit 0 : Association Request + Bit 1 : Association Response + Bit 2 : Re-Association Request + Bit 3 : Re-Association Response + Bit 4 : Probe Request + Bit 5 : Probe Response + Bit 8 : Beacon Frames + + Example: + ./uaputl.exe mgmtframectrl 0x101 + Set management frame control mask to 0x101. + +restrict_client_mode +-------------------- + "./uaputl.exe restrict_client_mode [ [MODE_CONFIG]]" + + This command is used to set/get the mode in which the ex-Stations can connect to the uAP. + If no arguments are given, this command returns the current configuration. + By default this feature will be disabled. + [ENABLE]: + 1: Enable the feature. + 0: Disable the feature. + [MODE_CONFIG]: config mode. + Bit 0: B only Mode. + Bit 1: A only Mode. + Bit 2: G only Mode. + Bit 3: N only Mode. + Bit 4: AC only Mode. + + Example: + ./uaputl.exe restrict_client_mode 1 0x8. + Only N mode clients will be able to connect. Association will fail for other clients. + + ./uaputl.exe restrict_client_mode 0. + This feature is disabled. + + Note: + The set operation should be performed before bss is started. + User should make sure that the mode advertized by uAP in beacons + (i.e. combination of supported/extended rates IE and capability IEs) + is superset of the mode allowed for ex-STA associations using this TLV. + +uap_oper_ctrl +------------- + "./uaputl.exe uap_oper_ctrl [control] [chanopt] [bandcfg] [channel]" + + This command is used to set/get uAP operation control when in-STA disconnected with ext-AP. + If no arguments are given, this command returns the current configuration. + + The supported options are: + : 0 default, do nothing + 2 uAP stops and restart automatically + Specify which channel should be used when uap restarts automatically + 1: uap restarts on default 2.4G/channel 6 + 2: uap restart on band/channel configured by driver previously + 3: uap restart on band/channel configured by parameter bandcfg/channel + This parameter specifies the bandwidth when chanopt is 3 + 0: 20Mhz + 2: 40Mhz + 3: 80Mhz + This parameter specifies the channel will be used when chanopt is 3 + + Example: + ./uaputl.exe uap_oper_ctrl 2 1 + uap stops and restart automatically when in-STA disconnects with ext-AP, + and restart on default 2.4G/channel 6. + + ./uaputl.exe uap_oper_ctrl 2 2 + uap stops and restart automatically when in-STA disconnects with ext-AP, + and restart on band/channel configured by driver previously. + + ./uaputl.exe uap_oper_ctrl 2 3 2 36 + uap stops and restart automatically when in-STA disconnects with ext-AP, + and restart on channel 36, bandwidth 40. + + ./uaputl.exe uap_oper_ctrl 0 + when in-STA disconnects with ext-AP, uap will stay on current operation channel. + + ./uaputl.exe uap_oper_ctrl + Get current uap operation control setting. + +band_steering_cfg +----------------- + "./uaputl.exe band_steering_cfg [state STATE] [block_2g_prb_req NUMBER_OF_PRB_REQ_TO_BLOCK] [max_btm_req_allowed MAX_BTM_REQ_ALLOWED_FOR_2G_STICKY_STA]" + + This command is used to set/get band steering configuration. + If no arguments are given, this command returns the current configuration. + + The supported options are: + : 0 disable band steering feature + 1 enable band steering feature + This parameter specifies the number of probe requests to block before allowing response for the STA. + + Example: + ./uaputl.exe band_steering_cfg + This will return the current values for "state" and "block_2g_prb_req". + + ./uaputl.exe band_steering_cfg state 1 block_2g_prb_req 5 + This will send probe response for 6th probe requests after denying response for first 5 probe requests. + + ./uaputl.exe band_steering_cfg state 1 max_btm_req_allowed 5 + This will send max 5 bss_transition requests to station. + + ./uaputl.exe band_steering_cfg state 0 + This will disable the band steering feature. + + ./uaputl.exe band_steering_cfg state 1 block_2g_prb_req 6 max_btm_req_allowed 6 + This will send probe response for 6th probe requests after denying response for first 5 probe requests and will send max 5 bss_transition requests to station. + +beacon_stuck_detect +----------------- + "./uaputl.exe beacon_stuck_detect [beacon_stuck_detect_count] [recovery_confirm_count]" + + This command is used to set/get beacon stuck detect mechanism configuration. + If no arguments are given, this command returns the current configuration. + + The supported options are: + : + This parameter specifies number of beacon interval after which FW will check + for beacon Tx status. Value should be between 0 to 60. Default value is 20. + + : + This parameter specifies upon doing MAC reset, number of beacon interval + after which FW will check for recovery status. Value should be between 0 to 60. + Default value is 5. Also value should be less than beacon_stuck_detect_count. + + Example: + ./uaputl.exe beacon_stuck_detect + This will return the current values for "beacon_stuck_detect_count" and "recovery_confirm_count". + + ./uaputl.exe beacon_stuck_detect 20 5 + This will set beacon_stuck_detect_count to 20 and recovery_confirm_count to 5. + + ./uaputl.exe beacon_stuck_detect 0 0 + Disable the beacon stuck detect meachanism. + + "./uaputl.exe block_frame [flag]" + + This command is used to enable/disable blocking authentication frame. + + [flag] 0 - disable blocking. + 0x800 - enable blocking for authentication frame. The blocked frame will be + dropped by firmware. Other value is not allowed and will get error. + + Examples: + ./uaputl.exe -i uap0 block_frame 0x800 + The authentication frame will be blocked by firmware. + ./uaputl.exe -i uap0 block_frame 0 + Unblock frames. + +=============================================================================== + U S E R M A N U A L F O R MLANEVENT + +NAME +mlanevent.exe + +This tool can be used to listen for and obtain events from the uAP driver +through the netlink layer. + +---------------- +Supported events +---------------- +STA_DEAUTH +STA_ASSOC +BSS_START +BSS_IDLE +BSS_ACTIVE + +----------------- +Details of events +----------------- + +STA_DEAUTH +---------- + For this event, the following information is shown: + + Deauthenticated STA MAC address. + + Reason for deauthentication. + +STA_ASSOC +--------- + For this event, the following information is shown: + + STA MAC address. + +BSS_START +--------- + For this event, the following information is shown: + + AP MAC address. + +BSS_IDLE +-------- + For this event, there is no associated information. + +BSS_ACTIVE +---------- + For this event, there is no associated information. + +=============================================================================== + U S E R M A N U A L F O R IWPRIV + +NAME + This manual describes the usage of private commands used in NXP MLAN + Linux UAP Driver. + + To use parameters as hex format, a '0x' must precede it for the parameters to + be parsed properly. + +SYNOPSIS + iwpriv [sub-command] ... + + iwpriv uapX version + iwpriv uapX verext + iwpriv uapX start + iwpriv uapX stop + iwpriv uapX bssstart + iwpriv uapX bssstop + iwpriv uapX fwreload + iwpriv uapX apcfg "ASCII_CMD=AP_CFG,SSID=TEST_uAP,[SEC,][KEY,] + [CHANNEL,][PREAMBLE,][MAX_SCB,][END]" + +DESCRIPTION + Those commands are used to send additional commands to the NXP MLAN + card via the Linux device driver. + + The uapX parameter specifies the network device that is to be used to + perform this command on. It could be uap0, uap1 etc. + +version + This is used to get the current version of the driver and the firmware. + +verext + Retrieve and display an extended version string from the firmware + + Usage: + iwpriv uapX verext [#] + + where [#] is an optional argument to retrieve a specific version string, + omission of the argument retrieves the 0 indexed string. + +start + Start the uAP driver. + + Usage: + iwpriv uapX start + +stop + Stop the uAP driver. + + Usage: + iwpriv uapX stop + +bssstart + Start the AP mode, so that uAP will start transmitting beacon. + + Usage: + iwpriv uapX bssstart + +bssstop + Stop the AP mode and disconnect all stations. uAP will stop + transmitting beacon as well. + + Usage: + iwpriv uapX bssstop + +fwreload + Reload the firmware. Here string "FW_PATH=" in the path + argument is mandatory part. + + Usage: + iwpriv uapX fwreload + +apcfg + This command is used to set the AP configurations. Here string + "ASCII_CMD=AP_CFG" is minimum requirement in the ASCII string. + Note: BSS will be stopped then restarted if BSS is already started + when the command is received. + + Usage: + iwpriv uapX apcfg "ASCII_CMD=AP_CFG,SSID=TEST_uAP,[SEC=sec,] + [KEY=key,][CHANNEL=channel,][MAX_SCB=max_scb,][END]" + + Where the parameters are: + SSID: Set SSID to be used in beacon and probe response + [SEC]: Security modes - open, wep128 (use of WEP/TKIP is not recommended anymore), wpa-psk or wpa2-psk // use of WPA/TKIP is not recommended anymore + 11n will be auto disabled in wep128 (use of WEP/TKIP is not recommended anymore) and wpa-psk mode + [KEY]: Encrypted key for wep128 (use of WEP/TKIP , WPA/TKIP is not recommended anymore), wpa-psk or wpa2-psk, minimum 8 chars + [CHANNEL]: Channel to be selected + [MAX_SCB]: Maximum STA number + [END]: Optional termination in ASCII string + + Examples: + iwpriv uap0 apcfg "ASCII_CMD=AP_CFG,SSID=TEST_uAP" + : Set AP SSID to "TEST_uAP" + iwpriv uap0 apcfg "ASCII_CMD=AP_CFG,SSID=TEST_uAP,SEC=open" + : Set AP SSID to "TEST_uAP" and + security mode is disabled + iwpriv uap0 apcfg "ASCII_CMD=AP_CFG,SSID=TEST_uAP,SEC=WPA2-PSK,KEY=ecbe5facdbfe234a" + : Set AP SSID to "TEST_uAP" and security mode + to WPA2-SPK and encrypted key ecbe5facdbfe234a + iwpriv uap0 apcfg "ASCII_CMD=AP_CFG,SSID=TEST_uAP,CHANNEL=8" + : Set AP SSID to "TEST_uAP" and + set the AP channel to 8 + +=============================================================================== diff --git a/README_WIFIDIRECT b/README_WIFIDIRECT new file mode 100644 index 0000000..b56602a --- /dev/null +++ b/README_WIFIDIRECT @@ -0,0 +1,448 @@ + +=============================================================================== + + S E T U P I N S T R U C T I O N S F O R *WifiDirect* + +Driver,FW release: + +1. Make sure, bg_scan.conf,uaputl.conf has SSID starting with "DIRECT-" +2. Download uAP configuration and BG scan configuration. +3. This version of wifidirectutl breaks the backward compatibility and will work +with following releases - + 8797 >= 14.xx.16.p15 + >= 14.xx.11.p138 + 8766 >= 14.xx.11.p138 + 8787 >= 14.xx.9.p89 + + However, In case one needs to run the utility in backward compatibility mode + he can do so by running following command before running the utility - + + # export WIFIDIR_USE_FIXED_IE_INDICES=1 + + To disable backward comaptibility mode run following command - + + # export WIFIDIR_USE_FIXED_IE_INDICES=0 + +WPSWIFIDIRECT release: + +1. Modify the wifidirect.conf file to specify the correct HW addresses of + devices. The DUT mac address and peer mac address needs to be correctly + entered. + +=============================================================================== + U S E R M A N U A L F O R WIFIDIRECTUTL + +NAME + wifidirectutl + +This tool can be used to configure WifiDirect parameters. + +------------------ +Supported Commands +------------------ +wifidirect_mode [MODE] +wifidirect_config [*.conf] +wifidirect_params_config [*.conf] +wifidirect_action_frame <*.conf> | [ ] +wifidirect_discovery_request <*.conf> +wifidirect_discovery_response <*.conf> + +wifidirect_cfg_discovery_period [ ] +wifidirect_cfg_intent [IntentValue] +wifidirect_cfg_capability [ ] +wifidirect_cfg_noa [ ] +wifidirect_cfg_opp_ps [] +wifidirect_cfg_invitation_list [mac_addr] +wifidirect_cfg_listen_channel [ListenChannel] +wifidirect_cfg_op_channel [OperatingChannel] +wifidirect_cfg_persistent_group_record [index] [role] + [ ] [peermac1] [peermac2] +wifidirect_cfg_persistent_group_invoke [index] | +wifidirect_cfg_presence_req_params [ ] +wifidirect_cfg_ext_listen_time [ ] +wifidirect_cfg_provisioning_params [ ] +wifidirect_cfg_wps_params [] + +wifidirect_mode [mode] +---------- + "./wifidirectutl wifidirect_mode [mode]" + + This command is used to setup various modes for wifidirect device. + The mode 2 can be used only when wifidirect is started using mode 1. + The mode 3 should not be used for uAP. + + The supported options are: + mode : 0 - stop wifidirect mode + 1 - start wifidirect mode + 2 - start wifidirect group owner mode + 3 - start wifidirect client mode + 4 - start wifidirect find phase + 5 - stop wifidirect find phase + empty - Get current wifidirect mode + + Example: + ./wifidirectutl wifidirect_mode 0 + Stop wifidirect mode. + + ./wifidirectutl wifidirect_mode 1 + Start wifidirect mode. + + ./wifidirectutl wifidirect_mode + Get current WIFIDIRECT start/stop mode. + +wifidirect_config +---------- + "./wifidirectutl wifidirect_config [*.conf]" + + This command is used to set/get the wifidirect configuration. + + Example: + ./wifidirectutl wifidirect_config wifidirect.conf + Read configuration from wifidirect.conf and apply it. + ./wifidirectutl wifidirect_config + Read existing wifidirect configuration and display it. + +wifidirect_params_config +---------- + "./wifidirectutl wifidirect_params_config [*.conf]" + + This command is used to set/get the wifidirect parameters configuration. + + Example: + ./wifidirectutl wifidirect_params_config wifidirect.conf + Read parameter configuration from wifidirect.conf and apply it. + ./wifidirectutl wifidirect_params_config + Read existing wifidirect parameters's configuration and display it. + +wifidirect_action_frame +---------- + "./wifidirectutl wifidirect_action_frame <*.conf> | " + + This command is used to send action frames as specified in config file or on command line. + + Example: + ./wifidirectutl wifidirect_action_frame wifidirect.conf + Read action_frame from wifidirect.conf and send to peer. + ./wifidirectutl wifidirect_action_frame + Read action frame parameters from command line and send to peer. + +wifidirect_discovery_request +---------- + "./wifidirectutl wifidirect_discovery_request <*.conf>" + + This command is used to send wifidirect discovery request packet. + + Example: + ./wifidirectutl wifidirect_discovery_request wifidirect.conf + Read discovery packet from wifidirect.conf and send to peer. + +wifidirect_discovery_response +---------- + "./wifidirectutl wifidirect_discovery_response <*.conf>" + + This command is used to send wifidirect discovery response packet. + + Example: + ./wifidirectutl wifidirect_discovery_response wifidirect.conf + Read discovery packet from wifidirect.conf and send to peer. + +wifidirect_cfg_discovery_period +---------- + "./wifidirectutl wifidirect_cfg_discovery_period [ ]" + + This command is used to set or get minimum and maximum discovery period. + + Example: + ./wifidirectutl wifidirect_cfg_discovery_period 10 20 + Set minimum discovery interval to 10 and maximum discovery + interval to 20. + + ./wifidirectutl wifidirect_cfg_discovery_period + Get minimum and maximum discovery interval. + +wifidirect_cfg_intent +---------- + "./wifidirectutl wifidirect_cfg_intent [IntentValue]" + + This command is used to set or get intent value. + + Example: + ./wifidirectutl wifidirect_cfg_intent 12 + Set intent value to 12. + + ./wifidirectutl wifidirect_cfg_intent + Get Group Owner Intent. + +wifidirect_cfg_capability +---------- + "./wifidirectutl wifidirect_cfg_capability [ ]" + + This command is used to set or get device capability and group capability. + + Example: + ./wifidirectutl wifidirect_cfg_capability 10 20 + Set Device capability to 10 and group capability to 20 + + ./wifidirectutl wifidirect_cfg_capability + Get Device capability and group capability. + +wifidirect_cfg_noa +---------- + "./wifidirectutl wifidirect_cfg_noa [ ]" + + This command is used to set or get NoA parameters like count_type, duration and + interval in ms when NoA is enabled. Valid value of index is [0, 1]. + + Example: + ./wifidirectutl wifidirect_cfg_noa enable 0 10 50 100 + Enable NoA and set count to 10, duration to 50ms and interval to 100 ms + for index 0. + + ./wifidirectutl wifidirect_cfg_noa disable 1 + Disable NoA at index 1. + + ./wifidirectutl wifidirect_cfg_noa + Get NoA settings. + +wifidirect_cfg_opp_ps +---------- + "./wifidirectutl wifidirect_cfg_opp_ps []" + + This command is used to set or get Opportunistic power save and CT window. + + Example: + ./wifidirectutl wifidirect_cfg_opp_ps enable 50 + Set OppPS and CTwindow value to 50. + + ./wifidirectutl wifidirect_cfg_opp_ps disable + Disable OppPS. + + ./wifidirectutl wifidirect_cfg_opp_ps + Get OppPS and CT window. + +wifidirect_cfg_invitation_list +---------- + "./wifidirectutl wifidirect_cfg_invitation_list [mac_addr]" + + This command is used to set or get invitation list of peers. + + Example: + ./wifidirectutl wifidirect_cfg_invitation_list 00:50:43:20:23:34 + Set 00:50:43:20:23:34 in invitation list of peers. + + ./wifidirectutl wifidirect_cfg_invitation_list + Get Invitation list of peers. + +wifidirect_cfg_listen_channel +---------- + "./wifidirectutl wifidirect_cfg_listen_channel [ListenChannel]" + + This command is used to set or get Listen channel. + + Example: + ./wifidirectutl wifidirect_cfg_listen_channel 11 + Set Listen channel to 11. + + ./wifidirectutl wifidirect_cfg_listen_channel + Get Listen channel. + +wifidirect_cfg_op_channel +---------- + "./wifidirectutl wifidirect_cfg_op_channel [OperatingChannel]" + + This command is used to set or get Operating channel. + + Example: + ./wifidirectutl wifidirect_cfg_op_channel 11 + Set Operating channel to 11. + + ./wifidirectutl wifidirect_cfg_op_channel + Get Operating channel. + +wifidirect_cfg_persistent_group_record +---------- + "./wifidirectutl [index] [role] + [ ] [peermac1] [peermac2]" + + This command is used to set or get the persistent group record + maintained in the device. Valid index is from 0 to 3. The role should be + 0 for client, 1 for group-owner. + + Example: + ./wifidirectutl wifidirect_cfg_persistent_group_record 0 1 + 00:50:43:12:24:36 00:50:43:13:26:39 "DIRECT-" "1234567890" + 00:50:43:20:c2:d0 + Set persistent group record with index 0, role as group owner, bssId and + device Id, ssid="DIRECT-", passphrase="1234567890", and peer mac address. + The passphrase get converted to PSK. + + ./wifidirectutl wifidirect_cfg_persistent_group_record 1 1 + 00:50:43:12:24:36 00:50:43:13:26:39 "DIRECT-" "1234567890" + 0x1234567890123456789012345678901234567890123456789012345678901234 + Set persistent group record with index 1, role as group owner, bssId and + device Id, ssid="DIRECT-", passphrase="1234567890", and peer mac address. + The passphrase get converted to PSK. + PSK is specified with "0x" prefix and 32 bytes (64 characters). + + ./wifidirectutl wifidirect_cfg_persistent_group_record 1 + Get persistent group record with index 1. + + ./wifidirectutl wifidirect_cfg_persistent_group_record + Get persistent group record for all indices. + +wifidirect_cfg_persistent_group_invoke +---------- + "./wifidirectutl wifidirect_cfg_persistent_group_invoke [index] | " + + This command is used to invoke a particular persistent group record + from the list. Valid index is from 0 to 3. + + ./wifidirectutl wifidirect_cfg_persistent_group_invoke 2 + Invoke persistent group record with index 1. + + ./wifidirectutl wifidirect_cfg_persistent_group_invoke cancel + Cancel invokation of persistent groups. + +wifidirect_cfg_presence_req_params +---------- + "./wifidirectutl wifidirect_cfg_presence_req_params [ ]" + + This command is used to set/get presence request parameters. Type should + be 1 for preferred values and 2 for acceptable values. + + ./wifidirectutl wifidirect_cfg_presence_req_params 1 50 100 + Set duration to 50ms and interval to 100ms. + + ./wifidirectutl wifidirect_cfg_presence_req_params + Get presence request parameters. + +wifidirect_cfg_ext_listen_time +---------- + "./wifidirectutl wifidirect_cfg_ext_listen_time [ ]" + + This command is used to set/get extended listen timing parameters. + + ./wifidirectutl wifidirect_cfg_ext_listen_time 1200 1300 + Set availability period to 1200ms and availability interval to 1300 ms. + + ./wifidirectutl wifidirect_cfg_ext_listen_time + Get extended listen timing parameters. + +wifidirect_cfg_provisioning_params +---------- + "./wifidirectutl wifidirect_cfg_provisioning_params [ ]" + + This command is used to set/get provisioning protocol parameters. Action should + be 1 for request parameters and 2 for response parameters. + + ./wifidirectutl wifidirect_cfg_provisioning_params 1 0x80 0x04 + Set config method to 0x86 and device password to 0x04. + + ./wifidirectutl wifidirect_cfg_provisioning_params + Get Provision protocol parameters. + +wifidirect_cfg_wps_params +---------- + "./wifidirectutl wifidirect_cfg_wps_params []" + + This command is used to set WPS action. action can be "pin" (pin entered), + "pbc"(button pressed) or "none". + + Example: + ./wifidirectutl wifidirect_cfg_wps_params pin + Indicates pin operation + + ./wifidirectutl wifidirect_cfg_wps_params none + Indicates no operation + +=============================================================================== + U S E R M A N U A L F O R WIFIDISPLAY + +wifidisplay_mode +----------- + "./wifidirectutl wifidisplay_mode []" + This command is used to enable or disable wifi-display. The possible values are either 1 or 0. + Example: + ./wifidirectutl wifidisplay_mode 1 + Indicates enable wifi_display + + ./wifidirectutl wifidisplay_mode 0 + Indicates disable wifi_display + +wifidisplay_config +----------- + "./wifidirectutl wifidisplay_config [*.conf]" + + This command is used to set/get the wifidisplay configuration. + + Example: + ./wifidirectutl wifidisplay_config wifidisplay.conf + Read configuration from wifidisplay.conf and apply it. + ./wifidirectutl wifidisplay_config + Read existing wifidisplay configuration and display it. + +wifidisplay_update_devinfo +---------- + "./wifidirectutl wifidisplay_update_devinfo [value]" + + This command is used to set the device information of wifidisplay device information subelement. + This command will overwrite the new device information with user defined value. + + Example: + ./wifidirectutl wifidisplay_update_devinfo 10 + Update device information programmed with new value 10 by overwritting existing value. + +wifidisplay_discovery_request +---------- + "./wifidirectutl wifidisplay_discovery_request [*.config]" + + This command is used to send wifi display service discovery request. + + Example: + ./wifidirectutl wifidisplay_discovery_request wifidisplay.conf + Read discovery packet from wifidisplay.conf and send to peer. + +wifidisplay_discovery_response +---------- + "./wifidirectutl wifidisplay_discovery_response <*.conf>" + + This command is used to send wifidisplay discovery response packet. + + Example: + ./wifidirectutl wifidisplay_discovery_response wifidisplay.conf + Read discovery packet from wifidisplay.conf and send to peer. + +=============================================================================== + U S E R M A N U A L F O R MLANEVENT + +NAME +mlanevent.exe + +This tool can be used to listen for and obtain events from the driver +through the netlink layer. This is only used for display/debugging purpose. + +---------------- +Supported events +---------------- +WIFIDIRECT_GENERIC_EVENT +WIFIDIRECT_SERVICE_DISCOVERY + +----------------- +Details of events +----------------- + +WIFIDIRECT_GENERIC_EVENT +----------------- + For this event, the following information is shown: + + Event length. + + Event Type indicating Negociation, Invitation, Discoverability, + Provision discovery related Request or Response. + + Event SubType indicating Client or Group owner role. + + Peer MAC address. + + Associated WIFIDIRECT IE elements. + +WIFIDIRECT_SERVICE_DISCOVERY +--------------------- + For this event, the following information is shown: + + Peer MAC address. + + Service discovery packet details. diff --git a/SBOM-WSW_driver-mxmdriver-linux-mxm405.p61_MGPL.spdx.json b/SBOM-WSW_driver-mxmdriver-linux-mxm405.p61_MGPL.spdx.json new file mode 100644 index 0000000..d0ea16f --- /dev/null +++ b/SBOM-WSW_driver-mxmdriver-linux-mxm405.p61_MGPL.spdx.json @@ -0,0 +1,35 @@ +{ + "SPDXID": "SPDXRef-DOCUMENT", + "spdxVersion": "SPDX-2.3", + "creationInfo": { + "created": "2025-10-09T09:50:27Z", + "creators": [ + "Organization: NXP" + ], + "licenseListVersion": "3.20" + }, + "name": "WSW driver-mxmdriver-linux-mxm405.p61_MGPL", + "dataLicense": "CC0-1.0", + "documentNamespace": "https://nxp.com/spdx/3cad156d-9a7f-4f10-b718-286888260fec", + "packages": [ + { + "SPDXID": "SPDXRef-package-3cad156d-9a7f-4f10-b718-286888260fec", + "name": "WSW driver", + "versionInfo": "mxmdriver-linux-mxm405.p61_MGPL", + "licenseConcluded": "(GPL-2.0-only)", + "licenseDeclared": "(GPL-2.0-only)", + "downloadLocation": "NOASSERTION", + "originator": "Organization: NXP", + "supplier": "", + "externalRefs": [], + "filesAnalyzed": false + } + ], + "relationships": [ + { + "spdxElementId": "SPDXRef-DOCUMENT", + "relationshipType": "DESCRIBES", + "relatedSpdxElement": "SPDXRef-package-3cad156d-9a7f-4f10-b718-286888260fec" + } + ] +} \ No newline at end of file diff --git a/gpl-2.0.txt b/gpl-2.0.txt new file mode 100644 index 0000000..2c62266 --- /dev/null +++ b/gpl-2.0.txt @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your + freedom to share and change it. By contrast, the GNU General Public + License is intended to guarantee your freedom to share and change free + software--to make sure the software is free for all its users. This + General Public License applies to most of the Free Software + Foundation's software and to any other program whose authors commit to + using it. (Some other Free Software Foundation software is covered by + the GNU Lesser General Public License instead.) You can apply it to + your programs, too. + + When we speak of free software, we are referring to freedom, not + price. Our General Public Licenses are designed to make sure that you + have the freedom to distribute copies of free software (and charge for + this service if you wish), that you receive source code or can get it + if you want it, that you can change the software or use pieces of it + in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid + anyone to deny you these rights or to ask you to surrender the rights. + These restrictions translate to certain responsibilities for you if you + distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether + gratis or for a fee, you must give the recipients all the rights that + you have. You must make sure that they, too, receive or can get the + source code. And you must show them these terms so they know their + rights. + + We protect your rights with two steps: (1) copyright the software, and + (2) offer you this license which gives you legal permission to copy, + distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain + that everyone understands that there is no warranty for this free + software. If the software is modified by someone else and passed on, we + want its recipients to know that what they have is not the original, so + that any problems introduced by others will not reflect on the original + authors' reputations. + + Finally, any free program is threatened constantly by software + patents. We wish to avoid the danger that redistributors of a free + program will individually obtain patent licenses, in effect making the + program proprietary. To prevent this, we have made it clear that any + patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and + modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains + a notice placed by the copyright holder saying it may be distributed + under the terms of this General Public License. The "Program", below, + refers to any such program or work, and a "work based on the Program" + means either the Program or any derivative work under copyright law: + that is to say, a work containing the Program or a portion of it, + either verbatim or with modifications and/or translated into another + language. (Hereinafter, translation is included without limitation in + the term "modification".) Each licensee is addressed as "you". + + Activities other than copying, distribution and modification are not + covered by this License; they are outside its scope. The act of + running the Program is not restricted, and the output from the Program + is covered only if its contents constitute a work based on the + Program (independent of having been made by running the Program). + Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's + source code as you receive it, in any medium, provided that you + conspicuously and appropriately publish on each copy an appropriate + copyright notice and disclaimer of warranty; keep intact all the + notices that refer to this License and to the absence of any warranty; + and give any other recipients of the Program a copy of this License + along with the Program. + + You may charge a fee for the physical act of transferring a copy, and + you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion + of it, thus forming a work based on the Program, and copy and + distribute such modifications or work under the terms of Section 1 + above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + + These requirements apply to the modified work as a whole. If + identifiable sections of that work are not derived from the Program, + and can be reasonably considered independent and separate works in + themselves, then this License, and its terms, do not apply to those + sections when you distribute them as separate works. But when you + distribute the same sections as part of a whole which is a work based + on the Program, the distribution of the whole must be on the terms of + this License, whose permissions for other licensees extend to the + entire whole, and thus to each and every part regardless of who wrote it. + + Thus, it is not the intent of this section to claim rights or contest + your rights to work written entirely by you; rather, the intent is to + exercise the right to control the distribution of derivative or + collective works based on the Program. + + In addition, mere aggregation of another work not based on the Program + with the Program (or with a work based on the Program) on a volume of + a storage or distribution medium does not bring the other work under + the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, + under Section 2) in object code or executable form under the terms of + Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + + The source code for a work means the preferred form of the work for + making modifications to it. For an executable work, complete source + code means all the source code for all modules it contains, plus any + associated interface definition files, plus the scripts used to + control compilation and installation of the executable. However, as a + special exception, the source code distributed need not include + anything that is normally distributed (in either source or binary + form) with the major components (compiler, kernel, and so on) of the + operating system on which the executable runs, unless that component + itself accompanies the executable. + + If distribution of executable or object code is made by offering + access to copy from a designated place, then offering equivalent + access to copy the source code from the same place counts as + distribution of the source code, even though third parties are not + compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program + except as expressly provided under this License. Any attempt + otherwise to copy, modify, sublicense or distribute the Program is + void, and will automatically terminate your rights under this License. + However, parties who have received copies, or rights, from you under + this License will not have their licenses terminated so long as such + parties remain in full compliance. + + 5. You are not required to accept this License, since you have not + signed it. However, nothing else grants you permission to modify or + distribute the Program or its derivative works. These actions are + prohibited by law if you do not accept this License. Therefore, by + modifying or distributing the Program (or any work based on the + Program), you indicate your acceptance of this License to do so, and + all its terms and conditions for copying, distributing or modifying + the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the + Program), the recipient automatically receives a license from the + original licensor to copy, distribute or modify the Program subject to + these terms and conditions. You may not impose any further + restrictions on the recipients' exercise of the rights granted herein. + You are not responsible for enforcing compliance by third parties to + this License. + + 7. If, as a consequence of a court judgment or allegation of patent + infringement or for any other reason (not limited to patent issues), + conditions are imposed on you (whether by court order, agreement or + otherwise) that contradict the conditions of this License, they do not + excuse you from the conditions of this License. If you cannot + distribute so as to satisfy simultaneously your obligations under this + License and any other pertinent obligations, then as a consequence you + may not distribute the Program at all. For example, if a patent + license would not permit royalty-free redistribution of the Program by + all those who receive copies directly or indirectly through you, then + the only way you could satisfy both it and this License would be to + refrain entirely from distribution of the Program. + + If any portion of this section is held invalid or unenforceable under + any particular circumstance, the balance of the section is intended to + apply and the section as a whole is intended to apply in other + circumstances. + + It is not the purpose of this section to induce you to infringe any + patents or other property right claims or to contest validity of any + such claims; this section has the sole purpose of protecting the + integrity of the free software distribution system, which is + implemented by public license practices. Many people have made + generous contributions to the wide range of software distributed + through that system in reliance on consistent application of that + system; it is up to the author/donor to decide if he or she is willing + to distribute software through any other system and a licensee cannot + impose that choice. + + This section is intended to make thoroughly clear what is believed to + be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in + certain countries either by patents or by copyrighted interfaces, the + original copyright holder who places the Program under this License + may add an explicit geographical distribution limitation excluding + those countries, so that distribution is permitted only in or among + countries not thus excluded. In such case, this License incorporates + the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions + of the General Public License from time to time. Such new versions will + be similar in spirit to the present version, but may differ in detail to + address new problems or concerns. + + Each version is given a distinguishing version number. If the Program + specifies a version number of this License which applies to it and "any + later version", you have the option of following the terms and conditions + either of that version or of any later version published by the Free + Software Foundation. If the Program does not specify a version number of + this License, you may choose any version ever published by the Free Software + Foundation. + + 10. If you wish to incorporate parts of the Program into other free + programs whose distribution conditions are different, write to the author + to ask for permission. For software which is copyrighted by the Free + Software Foundation, write to the Free Software Foundation; we sometimes + make exceptions for this. Our decision will be guided by the two goals + of preserving the free status of all derivatives of our free software and + of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY + FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN + OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES + PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED + OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS + TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE + PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, + REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING + WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR + REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, + INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING + OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED + TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY + YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER + PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest + possible use to the public, the best way to achieve this is to make it + free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest + to attach them to the start of each source file to most effectively + convey the exclusion of warranty; and each file should have at least + the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + Also add information on how to contact you by electronic and paper mail. + + If the program is interactive, make it output a short notice like this + when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + + The hypothetical commands `show w' and `show c' should show the appropriate + parts of the General Public License. Of course, the commands you use may + be called something other than `show w' and `show c'; they could even be + mouse-clicks or menu items--whatever suits your program. + + You should also get your employer (if you work as a programmer) or your + school, if any, to sign a "copyright disclaimer" for the program, if + necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + + This General Public License does not permit incorporating your program into + proprietary programs. If your program is a subroutine library, you may + consider it more useful to permit linking proprietary applications with the + library. If this is what you want to do, use the GNU Lesser General + Public License instead of this License. diff --git a/mapp/mlan2040coex/Makefile b/mapp/mlan2040coex/Makefile new file mode 100644 index 0000000..e39b485 --- /dev/null +++ b/mapp/mlan2040coex/Makefile @@ -0,0 +1,52 @@ +# +# File : mlan2040coex/Makefile +# +# Copyright 2009-2022 NXP + +# Path to the top directory of the mlandriver distribution +PATH_TO_TOP = ../.. + +ifeq ($(findstring IMX_ANDROID,$(ccflags-y)),IMX_ANDROID) +CC=/usr/local/arm/android-ndk-r23-beta5/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang +endif + +# Determine how we should copy things to the install directory +ABSPATH := $(filter /%, $(INSTALLDIR)) +RELPATH := $(filter-out /%, $(INSTALLDIR)) +INSTALLPATH := $(ABSPATH) +ifeq ($(strip $(INSTALLPATH)),) +INSTALLPATH := $(PATH_TO_TOP)/$(RELPATH) +endif + +# Override CFLAGS for application sources, remove __ kernel namespace defines +CFLAGS := $(filter-out -D__%, $(ccflags-y)) +# remove KERNEL include dir +CFLAGS := $(filter-out -I$(KERNELDIR)%, $(CFLAGS)) + +# +# List of application executables to create +# +libobjs:= mlan2040coex.o mlan2040misc.o +exectarget=mlan2040coex +TARGETS := $(exectarget) + +# +# Make target rules +# + +# All rule compiles list of TARGETS using builtin program target from src rule +all : +$(exectarget): $(libobjs) + $(CC) $(CFLAGS) $(libobjs) -o $(exectarget) + +# Update any needed TARGETS and then copy to the install path +build appsbuild install: $(TARGETS) + @cp -f $(exectarget) $(INSTALLPATH) + +clean: + @rm -f $(exectarget) + @rm -f *.o + +distclean: clean + @rm -f *~ core + @rm -f tags diff --git a/mapp/mlan2040coex/mlan2040coex.c b/mapp/mlan2040coex/mlan2040coex.c new file mode 100644 index 0000000..d13fa5c --- /dev/null +++ b/mapp/mlan2040coex/mlan2040coex.c @@ -0,0 +1,1375 @@ +/** @file mlan2040coex.c + * + * @brief 11n 20/40 MHz Coex application + * + * + * Copyright 2009-2021 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: + 06/24/2009: initial version +************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "mlan2040coex.h" +#include "mlan2040misc.h" + +/** coex application's version number */ +#define COEX_VER "M2.0" + +#define MAX_OBSS_SCAN_RETRY 5 +/******************************************************** + Local Variables +********************************************************/ + +static char *usage[] = {"Usage: ", + " mlan2040coex [-i ] [-hvB] ", + " -h = help", + " -v = version", + " -B = run the process in background.", + " (if intfname not present then mlan0 assumed)"}; + +t_s32 sockfd = 0; /**< socket descriptor */ +char dev_name[IFNAMSIZ]; /**< device name */ + +/** Flag: is 2040coex command required */ +int coex_cmd_req_flag = FALSE; +/** Flag: is associated */ +int assoc_flag = FALSE; +/** Flag: is HT AP */ +int is_ht_ap = FALSE; +/** terminate flag */ +int terminate_flag = FALSE; + +/******************************************************** + Global Variables +********************************************************/ +/** OBSS scan parameter of associated AP */ +OBSSScanParam_t cur_obss_scan_param; +/** Legacy APs channel list */ +chan_intol_t leg_ap_chan_list[WLAN_IOCTL_USER_SCAN_CHAN_MAX]; +/** Total number of channel present in Legacy APs channel list */ +t_u8 num_leg_ap_chan; +/** Max retry for OBSS scan after association*/ +t_u8 max_obss_retry; + +/******************************************************** + Local Functions +********************************************************/ + +/** + * @brief Prepare command buffer + * @param buffer Command buffer to be filled + * @param cmd Command id + * @param num Number of arguments + * @param args Arguments list + * @return MLAN_STATUS_SUCCESS + */ +static int prepare_buffer(t_u8 *buffer, char *cmd, t_u32 num, char *args[]) +{ + t_u8 *pos = NULL; + unsigned int i = 0; + + memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); + + /* Flag it for our use */ + pos = buffer; + memcpy((char *)pos, CMD_NXP, strlen(CMD_NXP)); + pos += (strlen(CMD_NXP)); + + /* Insert command */ + strncpy((char *)pos, (char *)cmd, strlen(cmd)); + pos += (strlen(cmd)); + + /* Insert arguments */ + for (i = 0; i < num; i++) { + strncpy((char *)pos, args[i], strlen(args[i])); + pos += strlen(args[i]); + if (i < (num - 1)) { + memcpy((char *)pos, " ", strlen(" ")); + pos += 1; + } + } + + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process OBSS scan table + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_scantable(void) +{ + char ssid[MRVDRV_MAX_SSID_LENGTH + 1] = {0}; + unsigned int scan_start; + int idx, i = 0, j, already_listed, ssid_len = 0, ssid_idx; + + t_u8 *pcurrent; + t_u8 *pnext; + IEEEtypes_ElementId_e *pelement_id; + t_u8 *pelement_len, ht_cap_present, intol_bit_is_set; + int ret = MLAN_STATUS_SUCCESS; + t_s32 bss_info_len = 0; + t_u32 fixed_field_length = 0; + + IEEEtypes_CapInfo_t cap_info; + t_u8 tsf[8]; + t_u16 beacon_interval; + IEEEtypes_HTCap_t *pht_cap; + + wlan_ioctl_get_scan_table_info *prsp_info; + wlan_get_scan_table_fixed fixed_fields; + + t_u8 *buffer = NULL; + struct eth_priv_cmd *cmd = NULL; + struct ifreq ifr; + + /* Start preparing the buffer */ + /* Initialize buffer */ + buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); + if (!buffer) { + printf("ERR:Cannot allocate buffer for command!\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; + } + + /* 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 = MRVDRV_SIZE_OF_CMD_BUFFER; + + memset(&cap_info, 0x00, sizeof(cap_info)); + memset(leg_ap_chan_list, 0, sizeof(leg_ap_chan_list)); + num_leg_ap_chan = 0; + + scan_start = 1; + + do { + /* buffer = CMD_NXP + */ + prepare_buffer(buffer, "getscantable", 0, NULL); + prsp_info = (wlan_ioctl_get_scan_table_info + *)(buffer + strlen(CMD_NXP) + + strlen("getscantable")); + + prsp_info->scan_number = scan_start; + + /* 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)) { + if (errno == EAGAIN) { + ret = -EAGAIN; + } else { + perror("mlan2040coex"); + fprintf(stderr, + "mlan2040coex: getscantable fail\n"); + ret = MLAN_STATUS_FAILURE; + } + goto done; + } + + prsp_info = (wlan_ioctl_get_scan_table_info *)buffer; + pcurrent = 0; + pnext = prsp_info->scan_table_entry_buf; + + if (scan_start == 1) { + printf("----------------------------------------------\n"); + } + + for (idx = 0; (unsigned int)idx < prsp_info->scan_number; + idx++) { + /* + * Set pcurrent to pnext in case pad bytes are at the + * end of the last IE we processed. + */ + pcurrent = pnext; + + memcpy((t_u8 *)&fixed_field_length, (t_u8 *)pcurrent, + sizeof(fixed_field_length)); + pcurrent += sizeof(fixed_field_length); + + memcpy((t_u8 *)&bss_info_len, (t_u8 *)pcurrent, + sizeof(bss_info_len)); + pcurrent += sizeof(bss_info_len); + + memcpy((t_u8 *)&fixed_fields, (t_u8 *)pcurrent, + sizeof(fixed_fields)); + pcurrent += fixed_field_length; + + pnext = pcurrent + bss_info_len; + + if (bss_info_len >= + (t_s32)(sizeof(tsf) + sizeof(beacon_interval) + + sizeof(cap_info))) { + pcurrent += + (sizeof(tsf) + sizeof(beacon_interval) + + sizeof(cap_info)); + bss_info_len -= + (sizeof(tsf) + sizeof(beacon_interval) + + sizeof(cap_info)); + } + ht_cap_present = FALSE; + intol_bit_is_set = FALSE; + memset(ssid, 0, MRVDRV_MAX_SSID_LENGTH + 1); + ssid_len = 0; + while (bss_info_len >= 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(ssid, pcurrent, + *pelement_len); + ssid_len = *pelement_len; + } + break; + + case HT_CAPABILITY: + pht_cap = (IEEEtypes_HTCap_t *) + pelement_id; + ht_cap_present = TRUE; + if (IS_INTOL_BIT_SET(le16_to_cpu( + pht_cap->ht_cap + .ht_cap_info))) { + intol_bit_is_set = TRUE; + } + break; + default: + break; + } + pcurrent += *pelement_len; + bss_info_len -= (2 + *pelement_len); + } + if (!ht_cap_present || intol_bit_is_set) { + printf("%s AP found on channel number: %-3d ", + intol_bit_is_set ? "40 MHZ intolerant" : + "Legacy", + fixed_fields.channel); + if (ssid_len) { + printf("SSID: "); + /* Print out the ssid or the hex values + * if non-printable */ + for (ssid_idx = 0; ssid_idx < ssid_len; + ssid_idx++) { + if (isprint((unsigned char)ssid + [ssid_idx])) { + printf("%c", + ssid[ssid_idx]); + } else { + printf("\\%02x", + ssid[ssid_idx]); + } + } + } + printf("\n"); + + /* Verify that the channel is already listed or + * not */ + already_listed = FALSE; + for (j = 0; j < i; j++) { + if (leg_ap_chan_list[j].chan_num == + fixed_fields.channel) { + already_listed = TRUE; + if (intol_bit_is_set) + leg_ap_chan_list[j] + .is_intol_set = + intol_bit_is_set; + break; + } + } + if (!already_listed) { + /* add the channel in list */ + leg_ap_chan_list[i].chan_num = + fixed_fields.channel; + leg_ap_chan_list[i].is_intol_set = + intol_bit_is_set; + i++; + coex_cmd_req_flag = TRUE; + num_leg_ap_chan++; + } + } + } + scan_start += prsp_info->scan_number; + + } while (prsp_info->scan_number); + +done: + if (cmd) + free(cmd); + if (buffer) + free(buffer); + return ret; +} + +/** BSS Mode any (both infra and adhoc) */ +#define BSS_MODE_ANY 3 + +/** current scan config parameters */ +#define SCAN_CFG_PARAMS 7 + +/** Active : 1 , Passive : 2 */ +#define SCAN_TYPE_ACTIVE 1 + +/** + * @brief Issue get scan type command + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int get_scan_cfg(int *scan_param) +{ + t_u8 *buffer = NULL; + struct eth_priv_cmd *cmd = NULL; + struct ifreq ifr; + int ret = MLAN_STATUS_SUCCESS; + + /* Start preparing the buffer */ + /* Initialize buffer */ + buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); + if (!buffer) { + printf("ERR:Cannot allocate buffer for command!\n"); + return MLAN_STATUS_FAILURE; + } + + /* buffer = CMD_NXP + */ + prepare_buffer(buffer, "scancfg", 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 = MRVDRV_SIZE_OF_CMD_BUFFER; + + /* 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("mlan2040coex"); + fprintf(stderr, "mlan2040coex: get_scan_cfg fail\n"); + ret = MLAN_STATUS_FAILURE; + goto done; + } + scan_param = (int *)(buffer); +done: + if (cmd) + free(cmd); + if (buffer) + free(buffer); + + return ret; +} + +/** + * @brief Issue OBSS scan command + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_setuserscan(void) +{ + wlan_ioctl_user_scan_cfg scan_req; + int scan_cfg[SCAN_CFG_PARAMS]; + t_u8 *buffer = NULL, *pos = NULL; + struct eth_priv_cmd *cmd = NULL; + struct ifreq ifr; + int status = 0; + + memset(&scan_req, 0x00, sizeof(scan_req)); + memset(scan_cfg, 0x00, sizeof(scan_cfg)); + coex_cmd_req_flag = FALSE; + + if (get_scan_cfg(scan_cfg) != MLAN_STATUS_SUCCESS) { + printf("mlan2040coex: scancfg ioctl failure"); + return -EFAULT; + } + + if (scan_cfg[0] == SCAN_TYPE_ACTIVE) + scan_req.chan_list[0].scan_time = (t_u32)le16_to_cpu( + cur_obss_scan_param.obss_scan_active_dwell); + else + scan_req.chan_list[0].scan_time = (t_u32)le16_to_cpu( + cur_obss_scan_param.obss_scan_passive_total); + scan_req.bss_mode = (scan_cfg[1]) ? scan_cfg[1] : BSS_MODE_ANY; + + /* Start preparing the buffer */ + /* Initialize buffer */ + buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); + if (!buffer) { + printf("ERR:Cannot allocate buffer for command!\n"); + return MLAN_STATUS_FAILURE; + } + + /* buffer = CMD_NXP + */ + prepare_buffer(buffer, "setuserscan", 0, NULL); + pos = buffer + strlen(CMD_NXP) + strlen("setuserscan"); + + /* buffer = buffer + 'scan_req' */ + memcpy(pos, &scan_req, sizeof(wlan_ioctl_user_scan_cfg)); + + 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 = MRVDRV_SIZE_OF_CMD_BUFFER; + + /* 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("mlan2040coex"); + fprintf(stderr, "mlan2040coex: setuserscan fail\n"); + if (cmd) + free(cmd); + if (buffer) + free(buffer); + return MLAN_STATUS_FAILURE; + } + + /** process scan results */ + do { + status = process_scantable(); + } while (status == -EAGAIN); + + if (cmd) + free(cmd); + if (buffer) + free(buffer); + + 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 get connection status + * + * @param data Pointer to the output buffer holding connection status + * @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE + */ +static int get_connstatus(int *data) +{ + struct ether_addr apaddr; + struct ether_addr etherzero = {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; + t_u8 *buffer = NULL; + struct eth_priv_cmd *cmd = NULL; + struct ifreq ifr; + + /* Initialize buffer */ + buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); + if (!buffer) { + printf("ERR:Cannot allocate buffer for command!\n"); + return MLAN_STATUS_FAILURE; + } + + /* buffer = CMD_NXP + */ + prepare_buffer(buffer, "getwap", 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 = MRVDRV_SIZE_OF_CMD_BUFFER; + + /* 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("mlan2040coex"); + fprintf(stderr, "mlan2040coex: getwap fail\n"); + if (cmd) + free(cmd); + if (buffer) + free(buffer); + return MLAN_STATUS_FAILURE; + } + + memset(&apaddr, 0, sizeof(struct ether_addr)); + memcpy(&apaddr, (struct ether_addr *)(buffer), + sizeof(struct ether_addr)); + + if (!memcmp(&apaddr, ðerzero, sizeof(struct ether_addr))) { + /* not associated */ + *data = FALSE; + } else { + /* associated */ + *data = TRUE; + } + + if (buffer) + free(buffer); + if (cmd) + free(cmd); + + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Print connect and disconnect event related information + * + * @param buffer Pointer to received event buffer + * @param size Length of the received event + * + * @return N/A + */ +static void print_event_drv_connected(t_u8 *buffer, t_u16 size) +{ + struct ether_addr *wap; + struct ether_addr etherzero = {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; + char buf[32]; + + wap = (struct ether_addr *)(buffer + strlen(CUS_EVT_AP_CONNECTED)); + + if (!memcmp(wap, ðerzero, sizeof(struct ether_addr))) { + printf("---< Disconnected from AP >---\n"); + memset(&cur_obss_scan_param, 0, sizeof(cur_obss_scan_param)); + assoc_flag = FALSE; + is_ht_ap = FALSE; + } else { + memset(buf, 0, sizeof(buf)); + snprintf(buf, sizeof(buf), "%02X:%02X:%02X:%02X:%02X:%02X", + wap->ether_addr_octet[0], wap->ether_addr_octet[1], + wap->ether_addr_octet[2], wap->ether_addr_octet[3], + wap->ether_addr_octet[4], wap->ether_addr_octet[5]); + printf("---< Connected to AP: %s >---\n", buf); + /** set TRUE, if connected */ + assoc_flag = TRUE; + } +} + +/** + * @brief Parse and print received event information + * + * @param event Pointer to received event + * @param size Length of the received event + * @param evt_conn A pointer to a output buffer. It sets TRUE when it gets + * the event CUS_EVT_OBSS_SCAN_PARAM, otherwise + * FALSE + * @param if_name The interface name + * + * @return N/A + */ +static void print_event(event_header *event, t_u16 size, int *evt_conn, + char *if_name) +{ + if (!strncmp(CUS_EVT_AP_CONNECTED, (char *)event, + strlen(CUS_EVT_AP_CONNECTED))) { + if (strlen(if_name)) + printf("EVENT for interface %s\n", if_name); + print_event_drv_connected((t_u8 *)event, size); + return; + } + if (!strncmp(CUS_EVT_OBSS_SCAN_PARAM, (char *)event, + strlen(CUS_EVT_OBSS_SCAN_PARAM))) { + if (strlen(if_name)) + printf("EVENT for interface %s\n", if_name); + printf("---< %s >---\n", CUS_EVT_OBSS_SCAN_PARAM); + memset(&cur_obss_scan_param, 0, sizeof(cur_obss_scan_param)); + memcpy(&cur_obss_scan_param, + ((t_u8 *)event + strlen(CUS_EVT_OBSS_SCAN_PARAM) + 1), + sizeof(cur_obss_scan_param)); + /** set TRUE, since it is an HT AP */ + is_ht_ap = TRUE; + *evt_conn = TRUE; + return; + } + if (!strncmp(CUS_EVT_BW_CHANGED, (char *)event, + strlen(CUS_EVT_BW_CHANGED))) { + if (strlen(if_name)) + printf("EVENT for interface %s\n", if_name); + printf("---< %s >---\n", CUS_EVT_BW_CHANGED); + return; + } +} + +/** + * @brief This function parses for NETLINK events + * + * @param nlh Pointer to Netlink message header + * @param bytes_read Number of bytes to be read + * @param evt_conn A pointer to a output buffer. It sets TRUE when it gets + * the event CUS_EVT_OBSS_SCAN_PARAM, otherwise + * FALSE + * @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE + */ +static int drv_nlevt_handler(struct nlmsghdr *nlh, int bytes_read, + int *evt_conn) +{ + int len, plen; + t_u8 *buffer = NULL; + t_u32 event_id = 0; + event_header *event = NULL; + char if_name[IFNAMSIZ + 1]; + + /* Initialize receive buffer */ + buffer = (t_u8 *)malloc(NL_MAX_PAYLOAD); + if (!buffer) { + printf("ERR: Could not alloc buffer\n"); + return MLAN_STATUS_FAILURE; + } + memset(buffer, 0, NL_MAX_PAYLOAD); + + *evt_conn = FALSE; + while ((unsigned int)bytes_read >= NLMSG_HDRLEN) { + len = nlh->nlmsg_len; /* Length of message including header */ + plen = len - NLMSG_HDRLEN; + if (len > bytes_read || plen < 0) { + free(buffer); + /* malformed netlink message */ + return MLAN_STATUS_FAILURE; + } + if ((unsigned int)len > NLMSG_SPACE(NL_MAX_PAYLOAD)) { + printf("ERR:Buffer overflow!\n"); + free(buffer); + return MLAN_STATUS_FAILURE; + } + memset(buffer, 0, NL_MAX_PAYLOAD); + memcpy(buffer, NLMSG_DATA(nlh), plen); + + if (NLMSG_OK(nlh, len)) { + memcpy(&event_id, buffer, sizeof(event_id)); + + if (((event_id & 0xFF000000) == 0x80000000) || + ((event_id & 0xFF000000) == 0)) { + event = (event_header *)buffer; + } else { + memset(if_name, 0, IFNAMSIZ + 1); + memcpy(if_name, buffer, IFNAMSIZ); + event = (event_header *)(buffer + IFNAMSIZ); + } + } + + if (event) + print_event(event, bytes_read, evt_conn, if_name); + len = NLMSG_ALIGN(len); + bytes_read -= len; + nlh = (struct nlmsghdr *)((char *)nlh + len); + } + free(buffer); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Configure and read event data from netlink socket + * + * @param nl_sk Netlink socket handler + * @param msg Pointer to message header + * @param ptv Pointer to struct timeval + * + * @return Number of bytes read or MLAN_STATUS_FAILURE + */ +static int read_event(int nl_sk, struct msghdr *msg, struct timeval *ptv) +{ + int count = -1; + int ret = MLAN_STATUS_FAILURE; + fd_set rfds; + + /* Setup read fds and initialize event buffers */ + FD_ZERO(&rfds); + FD_SET(nl_sk, &rfds); + + /* Wait for reply */ + ret = select(nl_sk + 1, &rfds, NULL, NULL, ptv); + + if (ret == MLAN_STATUS_FAILURE) { + /* Error */ + terminate_flag++; + ptv->tv_sec = DEFAULT_SCAN_INTERVAL; + ptv->tv_usec = 0; + goto done; + } else if (!ret) { + if (assoc_flag && is_ht_ap) { + /** Issue OBSS scan */ + process_setuserscan(); + /** Invoke 2040coex command, if any legacy AP found or + * any AP has 40MHz intolarent bit set */ + if (coex_cmd_req_flag) + invoke_coex_command(); + } + if (assoc_flag && is_ht_ap) { + /* Timeout. Try again after BSS channel width triger + scan + interval when the STA is connected with a HT AP */ + ptv->tv_sec = (t_u32)le16_to_cpu( + cur_obss_scan_param + .bss_chan_width_trigger_scan_int); + } else { + /* Timeout. Try again after default duration when the + STA is not connected with a HT AP */ + ptv->tv_sec = DEFAULT_SCAN_INTERVAL; + } + ptv->tv_usec = 0; + goto done; + } + + if (!FD_ISSET(nl_sk, &rfds)) { + /* Unexpected error. Try again */ + ptv->tv_sec = DEFAULT_SCAN_INTERVAL; + ptv->tv_usec = 0; + goto done; + } + /* Success */ + count = recvmsg(nl_sk, msg, 0); + +done: + return count; +} + +/** + * @brief Run the application + * + * @param nl_sk Netlink socket + * + * @return N/A + */ +static void run_app(int nl_sk) +{ + struct timeval tv; + int bytes_read, evt_conn; + struct msghdr msg; + struct sockaddr_nl dest_addr; + struct nlmsghdr *nlh; + struct iovec iov; + t_u8 ret = 0; + /** Get connection status */ + if (get_connstatus(&assoc_flag) == MLAN_STATUS_FAILURE) + return; + + /* Initialize timeout value */ + tv.tv_sec = DEFAULT_SCAN_INTERVAL; + tv.tv_usec = 0; + + /* Initialize netlink header */ + nlh = (struct nlmsghdr *)malloc(NLMSG_SPACE(NL_MAX_PAYLOAD)); + if (!nlh) { + printf("ERR: Could not allocate space for netlink header\n"); + goto done; + } + memset(nlh, 0, NLMSG_SPACE(NL_MAX_PAYLOAD)); + /* Fill the netlink message header */ + nlh->nlmsg_len = NLMSG_SPACE(NL_MAX_PAYLOAD); + nlh->nlmsg_pid = getpid(); /* self pid */ + nlh->nlmsg_flags = 0; + + /* Initialize I/O vector */ + memset(&iov, 0, sizeof(struct iovec)); + iov.iov_base = (void *)nlh; + iov.iov_len = nlh->nlmsg_len; + + /* Set destination address */ + memset(&dest_addr, 0, sizeof(struct sockaddr_nl)); + dest_addr.nl_family = AF_NETLINK; + dest_addr.nl_pid = 0; /* Kernel */ + dest_addr.nl_groups = NL_MULTICAST_GROUP; + + /* 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; + + while (!terminate_flag) { + /* event buffer is received for all the interfaces */ + bytes_read = read_event(nl_sk, &msg, &tv); + /* handle only NETLINK events here */ + drv_nlevt_handler((struct nlmsghdr *)nlh, bytes_read, + &evt_conn); + if (assoc_flag && is_ht_ap) { + /** If the event is connected with an HT AP then issue + * OBSS scan immediately */ + if (evt_conn) { + while (max_obss_retry < MAX_OBSS_SCAN_RETRY) { + /** Issue OBSS scan */ + max_obss_retry++; + ret = process_setuserscan(); + if (ret == MLAN_STATUS_SUCCESS) { + /** Invoke 2040coex command, if + * any legacy AP found or + * any AP has 40MHz intolarent + * bit set */ + if (coex_cmd_req_flag) + invoke_coex_command(); + break; + } + sleep(1); + } + max_obss_retry = 0; + } + tv.tv_sec = (t_u32)le16_to_cpu( + cur_obss_scan_param + .bss_chan_width_trigger_scan_int); + } else { + tv.tv_sec = DEFAULT_SCAN_INTERVAL; + } + tv.tv_usec = 0; + } + +done: + // if (nl_sk > 0) + // close(nl_sk); + if (nlh) + free(nlh); + return; +} + +/** + * @brief Determine the netlink number + * + * @return Netlink number to use + */ +static int get_netlink_num(int dev_index) +{ + FILE *fp = NULL; + int netlink_num = -1; + char str[64]; + char *srch = "netlink_num"; + char filename[64]; + t_u8 *buffer = NULL; + struct eth_priv_cmd *cmd = NULL; + struct ifreq ifr; + + /* if dev_index is specified by user */ + if (dev_index >= 0) { + /* Try to open old driver proc: /proc/mwlan/configX first */ + if (dev_index == 0) + strncpy(filename, "/proc/mwlan/config", + sizeof(filename)); + else if (dev_index > 0) + snprintf(filename, sizeof(filename), + "/proc/mwlan/config%d", dev_index); + 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", dev_index); + fp = fopen(filename, "r"); + } + + if (fp) { + while (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; + } + } else { + /* Start preparing the buffer */ + /* Initialize buffer */ + buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); + if (!buffer) { + printf("ERR:Cannot allocate buffer for command!\n"); + return -1; + } + /* buffer = CMD_NXP + */ + prepare_buffer(buffer, "getnlnum", 0, NULL); + + cmd = (struct eth_priv_cmd *)malloc( + sizeof(struct eth_priv_cmd)); + if (!cmd) { + printf("ERR:Cannot allocate buffer for command!\n"); + 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 = MRVDRV_SIZE_OF_CMD_BUFFER; + + /* 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("mlan2040coex"); + fprintf(stderr, "mlan2040coex: getnlnum fail\n"); + goto done; + } + netlink_num = *(int *)(buffer); + } + +done: + if (cmd) + free(cmd); + if (buffer) + free(buffer); + printf("Netlink number = %d\n", netlink_num); + return netlink_num; +} + +/** + * @brief opens netlink socket to receive NETLINK events + * @return socket id --success, otherwise--MLAN_STATUS_FAILURE + */ +static int open_netlink(int dev_index) +{ + int sk = -1; + struct sockaddr_nl src_addr; + int netlink_num = 0; + + netlink_num = get_netlink_num(dev_index); + if (netlink_num < 0) { + printf("ERR:Could not get netlink socket. Invalid device number.\n"); + return sk; + } + + /* Open netlink socket */ + sk = socket(PF_NETLINK, SOCK_RAW, netlink_num); + if (sk < 0) { + printf("ERR:Could not open netlink socket.\n"); + return sk; + } + + /* Set source address */ + memset(&src_addr, 0, sizeof(src_addr)); + src_addr.nl_family = AF_NETLINK; + src_addr.nl_pid = getpid(); + src_addr.nl_groups = NL_MULTICAST_GROUP; + + /* Bind socket with source address */ + if (bind(sk, (struct sockaddr *)&src_addr, sizeof(src_addr)) < 0) { + printf("ERR:Could not bind socket!\n"); + close(sk); + return -1; + } + return sk; +} + +/** + * @brief Terminate signal handler + * @param signal Signal to handle + * @return NA + */ +static t_void terminate_handler(int signal) +{ + printf("Stopping application.\n"); +#if DEBUG + printf("Process ID of process killed = %d\n", getpid()); +#endif + terminate_flag = TRUE; +} + +/******************************************************** + Global Functions +********************************************************/ +/** + * @brief Process host command + * @param hostcmd_idx Host command index + * @param chan_list A pointer to a channel list + * @param chan_num Number of channels in the channel list + * @param reg_class Regulatory class of the channels + * @param is_intol_ap_present Flag:is there any 40 MHz intolerant AP is present + * or not + * + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +int process_host_cmd(int hostcmd_idx, t_u8 *chan_list, t_u8 chan_num, + t_u8 reg_class, t_u8 is_intol_ap_present) +{ + int ret = MLAN_STATUS_SUCCESS; + t_u8 *buffer = NULL; + struct eth_priv_cmd *cmd = NULL; + struct ifreq ifr; + + buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); + if (!buffer) { + printf("ERR:Cannot allocate buffer for command!\n"); + ret = MLAN_STATUS_FAILURE; + goto done; + } + + prepare_buffer(buffer, "hostcmd", 0, NULL); + switch (hostcmd_idx) { + case CMD_2040COEX: + prepare_coex_cmd_buff( + buffer + strlen(CMD_NXP) + strlen("hostcmd"), chan_list, + chan_num, reg_class, is_intol_ap_present); + break; + default: + break; + } + + 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 = MRVDRV_SIZE_OF_CMD_BUFFER; + + /* 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("mlan2040coex"); + fprintf(stderr, "mlan2040coex: hostcmd fail\n"); + ret = MLAN_STATUS_FAILURE; + goto done; + } + + ret = process_host_cmd_resp("hostcmd", buffer); + +done: + if (cmd) + free(cmd); + if (buffer) + free(buffer); + return ret; +} + +/** + * @brief Check the STA is 40 MHz intolerant or not + * @param intol Flag: TRUE when the STA is 40 MHz intolerant, otherwise + * FALSE + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +int is_intolerant_sta(int *intol) +{ + t_u8 *buffer = NULL; + struct eth_priv_cmd *cmd = NULL; + struct ifreq ifr; + int htcap_info, ret = MLAN_STATUS_SUCCESS; + + *intol = FALSE; + + /* Initialize buffer */ + buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); + if (!buffer) { + printf("ERR:Cannot allocate buffer for command!\n"); + ret = MLAN_STATUS_FAILURE; + goto done; + } + + /* buffer = CMD_NXP + */ + prepare_buffer(buffer, "htcapinfo", 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 = MRVDRV_SIZE_OF_CMD_BUFFER; + + /* 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("mlan2040coex"); + fprintf(stderr, "mlan2040coex: htcapinfo fail\n"); + ret = MLAN_STATUS_FAILURE; + goto done; + } + + htcap_info = *((int *)(buffer)); + + if (htcap_info & MBIT(8)) + *intol = TRUE; + +done: + if (cmd) + free(cmd); + if (buffer) + free(buffer); + return ret; +} + +/** + * @brief get region code + * @param reg_code Pointer to region code + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +int get_region_code(int *reg_code) +{ + t_u8 *buffer = NULL; + struct eth_priv_cmd *cmd = NULL; + struct ifreq ifr; + int ret = MLAN_STATUS_SUCCESS; + + /* Initialize buffer */ + buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); + if (!buffer) { + printf("ERR:Cannot allocate buffer for command!\n"); + ret = MLAN_STATUS_FAILURE; + goto done; + } + + /* buffer = CMD_NXP + */ + prepare_buffer(buffer, "regioncode", 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 = MRVDRV_SIZE_OF_CMD_BUFFER; + + /* 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("mlan2040coex"); + fprintf(stderr, "mlan2040coex: regioncode fail\n"); + ret = MLAN_STATUS_FAILURE; + goto done; + } + + memcpy(reg_code, buffer, sizeof(int)); +done: + if (cmd) + free(cmd); + if (buffer) + free(buffer); + return ret; +} + +/** No option */ +#define NO_OPTION -1 + +/** + * @brief Entry function for coex + * @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[]) +{ + char ifname[IFNAMSIZ + 1] = "mlan0"; + int c, daemonize = FALSE; + t_s32 nl_sk = 0; /**< netlink socket descriptor to receive an event */ + int dev_index = -1; /** initialise with -1 to open multiple NETLINK + Sockets */ + + char temp[2]; + int arg_count = 0; + int ifname_given = FALSE; + + memset(dev_name, 0, sizeof(dev_name)); + + for (;;) { + c = getopt(argc, argv, "Bhi:vd:"); + /* check if all command-line options have been parsed */ + if (c == NO_OPTION) + break; + + switch (c) { + case 'B': + daemonize = TRUE; + break; + case 'h': + display_usage(); + return MLAN_STATUS_SUCCESS; + case 'v': + fprintf(stdout, + "NXP 20/40coex application version %s\n", + COEX_VER); + return MLAN_STATUS_SUCCESS; + case 'i': + ifname_given = TRUE; + if (strlen(optarg) < IFNAMSIZ) + strncpy(ifname, optarg, IFNAMSIZ - 1); + else { + fprintf(stdout, "Interface name too long\n"); + display_usage(); + return MLAN_STATUS_SUCCESS; + } + arg_count += 1; + break; + case 'd': + strncpy(temp, optarg, sizeof(temp) - 1); + if (isdigit((unsigned char)temp[0])) + dev_index = atoi(temp); + arg_count += 1; + break; + default: + fprintf(stdout, "Invalid argument\n"); + display_usage(); + return MLAN_STATUS_SUCCESS; + } + } + + if (!ifname_given) { + snprintf(ifname, sizeof(ifname), "mlan%d", dev_index); + } + + if (optind < argc) { + fputs("Too many arguments.\n", stderr); + display_usage(); + goto done; + } + + strncpy(dev_name, ifname, IFNAMSIZ - 1); + + /* create a socket */ + if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { + fprintf(stderr, "mlan2040coex: Cannot open socket.\n"); + goto done; + } + + /* create netlink sockets and bind them with app side addr */ + nl_sk = open_netlink(dev_index); + + if (nl_sk < 0) { + fprintf(stderr, "mlan2040coex: Cannot open netlink socket.\n"); + goto done; + } + + signal(SIGHUP, terminate_handler); /* catch hangup signal */ + signal(SIGTERM, terminate_handler); /* catch kill signal */ + signal(SIGINT, terminate_handler); /* catch kill signal */ + signal(SIGALRM, terminate_handler); /* catch kill signal */ + + /** Make the process background-process */ + if (daemonize) { + if (daemon(0, 0)) + fprintf(stderr, "mlan2040coex: Cannot start daemon\n"); + } + + /** run the application */ + run_app(nl_sk); + +done: + if (sockfd > 0) + close(sockfd); + if (nl_sk > 0) + close(nl_sk); + + return MLAN_STATUS_SUCCESS; +} diff --git a/mapp/mlan2040coex/mlan2040coex.h b/mapp/mlan2040coex/mlan2040coex.h new file mode 100644 index 0000000..3cbf8e3 --- /dev/null +++ b/mapp/mlan2040coex/mlan2040coex.h @@ -0,0 +1,230 @@ +/** @file mlan2040coex.h + * + * @brief This file contains definitions for application + * + * + * Copyright 2009-2021 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: + 06/24/2009: initial version +************************************************************************/ +#ifndef _COEX_H_ +#define _COEX_H_ + +/** NXP private command identifier */ +#define CMD_NXP "MRVL_CMD" + +/** IOCTL number */ +#define MLAN_ETH_PRIV (SIOCDEVPRIVATE + 14) + +#if (BYTE_ORDER == LITTLE_ENDIAN) +#undef BIG_ENDIAN_SUPPORT +#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))) + +/** 64 bits byte swap */ +#define swap_byte_64(x) \ + ((t_u64)((t_u64)(((t_u64)(x)&0x00000000000000ffULL) << 56) | \ + (t_u64)(((t_u64)(x)&0x000000000000ff00ULL) << 40) | \ + (t_u64)(((t_u64)(x)&0x0000000000ff0000ULL) << 24) | \ + (t_u64)(((t_u64)(x)&0x00000000ff000000ULL) << 8) | \ + (t_u64)(((t_u64)(x)&0x000000ff00000000ULL) >> 8) | \ + (t_u64)(((t_u64)(x)&0x0000ff0000000000ULL) >> 24) | \ + (t_u64)(((t_u64)(x)&0x00ff000000000000ULL) >> 40) | \ + (t_u64)(((t_u64)(x)&0xff00000000000000ULL) >> 56))) + +/** 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) +/** CPU to little-endian convert for 64-bit */ +#define cpu_to_le64(x) swap_byte_64(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) +/** Little-endian to CPU convert for 64-bit */ +#define le64_to_cpu(x) swap_byte_64(x) +#else +/** Do nothing */ +#define cpu_to_le16(x) (x) +/** Do nothing */ +#define cpu_to_le32(x) (x) +/** Do nothing */ +#define cpu_to_le64(x) (x) +/** Do nothing */ +#define le16_to_cpu(x) (x) +/** Do nothing */ +#define le32_to_cpu(x) (x) +/** Do nothing */ +#define le64_to_cpu(x) (x) +#endif + +#ifdef __GNUC__ +/** Structure packing begins */ +#define PACK_START +/** Structure packeing end */ +#define PACK_END __attribute__((packed)) +#else +/** Structure packing begins */ +#define PACK_START __packed +/** Structure packeing end */ +#define PACK_END +#endif + +/** Character, 1 byte */ +typedef signed 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; + +#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 */ + +/** Type definition: boolean */ +typedef enum { FALSE, TRUE } boolean; + +/** Find number of elements */ +#define NELEMENTS(x) (sizeof(x) / sizeof(x[0])) +/** Success */ +#define MLAN_STATUS_SUCCESS (0) +/** Failure */ +#define MLAN_STATUS_FAILURE (-1) + +/** Enumeration for host-command index */ +enum COMMANDS { + CMD_2040COEX = 1, +}; + +/** Maximum number of channels that can be sent in a setuserscan ioctl */ +#define WLAN_IOCTL_USER_SCAN_CHAN_MAX 50 + +#ifndef ETH_ALEN +/** MAC address length */ +#define ETH_ALEN 6 +#endif + +/** 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 RTMGRP_LINK +/** Default wait time in seconds for events */ +#define UAP_RECV_WAIT_DEFAULT 10 +#ifndef NLMSG_HDRLEN +/** NL message header length */ +#define NLMSG_HDRLEN ((int)NLMSG_ALIGN(sizeof(struct nlmsghdr))) +#endif + +/** Event header */ +typedef PACK_START struct _event_header { + /** Event ID */ + t_u32 event_id; + /** Event data */ + t_u8 event_data[]; +} PACK_END event_header; + +/** Event ID length */ +#define EVENT_ID_LEN 4 + +/** Custom events definitions */ +/** AP connected event */ +#define CUS_EVT_AP_CONNECTED "EVENT=AP_CONNECTED" + +/** Custom event : BW changed */ +#define CUS_EVT_BW_CHANGED "EVENT=BW_CHANGED" +/** Custom event : OBSS scan parameter */ +#define CUS_EVT_OBSS_SCAN_PARAM "EVENT=OBSS_SCAN_PARAM" + +/** Custom events definitions end */ + +/** Structure defination of chan_intol_t*/ +typedef struct _chan_intol_t { + /** Channel numer */ + t_u8 chan_num; + /** Flag: Is any 40MHz intolerant AP found in this channel */ + t_u8 is_intol_set; +} chan_intol_t; + +/** Private command structure */ +#ifdef USERSPACE_32BIT_OVER_KERNEL_64BIT +struct eth_priv_cmd { + /** Command buffer pointer */ + t_u64 buf; + /** buffer updated by driver */ + int used_len; + /** buffer sent by application */ + int total_len; +} __ATTRIB_PACK__; +#else +struct eth_priv_cmd { + /** Command buffer */ + t_u8 *buf; + /** Used length */ + int used_len; + /** Total length */ + int total_len; +}; +#endif + +int get_region_code(int *reg_code); +int process_host_cmd(int cmd, t_u8 *chan_list, t_u8 chan_num, t_u8 reg_class, + t_u8 is_intol_ap_present); +int is_intolerant_sta(int *intol); + +#endif /* _COEX_H_ */ diff --git a/mapp/mlan2040coex/mlan2040misc.c b/mapp/mlan2040coex/mlan2040misc.c new file mode 100644 index 0000000..f375f61 --- /dev/null +++ b/mapp/mlan2040coex/mlan2040misc.c @@ -0,0 +1,281 @@ +/** @file mlan2040misc.c + * + * @brief This file contains helper functions for coex application + * + * + * Copyright 2009-2021 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: + 06/24/2009: initial version +************************************************************************/ +#include +#include +#include +#include +#include "mlan2040coex.h" +#include "mlan2040misc.h" + +/******************************************************** + Local Variables +********************************************************/ +/** Regulatory class and Channel mapping for various regions */ +static class_chan_t us_class_chan_t[] = {{32, {1, 2, 3, 4, 5, 6, 7}, 7}, + {33, {5, 6, 7, 8, 9, 10, 11}, 7}}; + +static class_chan_t europe_class_chan_t[] = { + {11, {1, 2, 3, 4, 5, 6, 7, 8, 9}, 9}, + {12, {5, 6, 7, 8, 9, 10, 11, 12, 13}, 9}}; + +static class_chan_t japan_class_chan_t[] = { + {56, {1, 2, 3, 4, 5, 6, 7, 8, 9}, 9}, + {57, {5, 6, 7, 8, 9, 10, 11, 12, 13}, 9}, + {58, {14}, 1}}; + +/** Region-code(Regulatory domain) and Class-channel table mapping */ +static region_class_chan_t region_class_chan_table[] = { + {0x10, us_class_chan_t, + sizeof(us_class_chan_t) / sizeof(class_chan_t)} /* US */ + , + {0x20, us_class_chan_t, + sizeof(us_class_chan_t) / sizeof(class_chan_t)} /* CANADA */ + , + {0x30, europe_class_chan_t, + sizeof(europe_class_chan_t) / sizeof(class_chan_t)} /* EUROPE */ + , + {0x32, europe_class_chan_t, + sizeof(europe_class_chan_t) / sizeof(class_chan_t)} /* FRANCE */ + , + {0x40, japan_class_chan_t, + sizeof(japan_class_chan_t) / sizeof(class_chan_t)} /* JAPAN */ + , + {0x41, japan_class_chan_t, + sizeof(japan_class_chan_t) / sizeof(class_chan_t)} /* JAPAN */ + , + {0x50, europe_class_chan_t, + sizeof(europe_class_chan_t) / sizeof(class_chan_t)} /* CHINA */ +}; + +/******************************************************** + Global Variables +********************************************************/ +extern t_u8 num_leg_ap_chan; +extern chan_intol_t leg_ap_chan_list[WLAN_IOCTL_USER_SCAN_CHAN_MAX]; + +/******************************************************** + Local Functions +********************************************************/ +/** + * @brief This function prepares the channel list for a particular + * regulatory class from channel number for legacy AP + * @param cur_class_chan_table A pointer to the class_chan_t + * @param num_entry Number of entry in cur_class_chan_table table + * @param chan_list A pointer to the output channel list + * @param chan_num total number of channel in output channel + * list + * @param reg_domain regulatory domain + * @param reg_class regulatory class + * @param is_intol_ap_present It sets TRUE when 40MHz intolerant AP is found + * otherwise FALSE + * @return None + */ +static void +get_channels_for_specified_reg_class(class_chan_t *cur_class_chan_table, + int num_entry, t_u8 *chan_list, + t_u8 *chan_num, t_u8 reg_domain, + t_u8 reg_class, t_u8 *is_intol_ap_present) +{ + int i, j, k, idx = 0; + + *is_intol_ap_present = FALSE; + + /* For each regulatory class */ + for (i = 0; i < num_entry; i++) { + if (cur_class_chan_table[i].reg_class == reg_class) { + /* For each channel of the regulatory class */ + for (j = 0; j < cur_class_chan_table[i].total_chan; + j++) { + for (k = 0; k < num_leg_ap_chan; k++) { + if (cur_class_chan_table[i].channels[j] == + leg_ap_chan_list[k].chan_num) { + *(chan_list + idx) = + leg_ap_chan_list[k] + .chan_num; + idx++; + if (leg_ap_chan_list[k] + .is_intol_set) + *is_intol_ap_present = + TRUE; + } + } + } + break; + } + } + /* update the total number of channel */ + *chan_num = idx--; + return; +} + +/******************************************************** + Global Functions +********************************************************/ +/** + * @brief Prepare 2040 coex command buffer + * @param buf A pointer to the command buffer + * @param chan_list Channel list + * @param num_of_chan Number of channel present in channel list + * @param reg_class Regulatory class + * @param is_intol_ap_present Flag: is any 40 MHz intolerant AP + * is present in these chaanel set + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +void prepare_coex_cmd_buff(t_u8 *buf, t_u8 *chan_list, t_u8 num_of_chan, + t_u8 reg_class, t_u8 is_intol_ap_present) +{ + HostCmd_DS_GEN *hostcmd; + MrvlIETypes_2040COEX_t *coex_ie = NULL; + MrvlIETypes_2040BssIntolerantChannelReport_t *bss_intol_ie = NULL; + t_u8 *pos = NULL; + int intol; + + hostcmd = (HostCmd_DS_GEN *)(buf + sizeof(t_u32)); + hostcmd->command = cpu_to_le16(HostCmd_CMD_11N_2040COEX); + hostcmd->size = S_DS_GEN; + pos = buf + sizeof(t_u32) + S_DS_GEN; + { + coex_ie = (MrvlIETypes_2040COEX_t *)pos; + coex_ie->header.element_id = TLV_ID_2040COEX; + coex_ie->header.len = sizeof(coex_ie->coex_elem); + /* Check STA is 40 MHz intolerant or not */ + is_intolerant_sta(&intol); + if (intol) + coex_ie->coex_elem |= MBIT(1); + + if (is_intol_ap_present) + coex_ie->coex_elem |= MBIT(2); + pos += sizeof(MrvlIETypes_2040COEX_t); + hostcmd->size += sizeof(MrvlIETypes_2040COEX_t); + } + { + bss_intol_ie = + (MrvlIETypes_2040BssIntolerantChannelReport_t *)pos; + bss_intol_ie->header.element_id = + TLV_ID_2040BSS_INTOL_CHAN_REPORT; + hostcmd->size += + sizeof(MrvlIETypes_2040BssIntolerantChannelReport_t) - + sizeof(bss_intol_ie->chan_num); + bss_intol_ie->reg_class = reg_class; + memcpy(bss_intol_ie->chan_num, chan_list, num_of_chan); + bss_intol_ie->header.len = + sizeof(bss_intol_ie->reg_class) + num_of_chan; + hostcmd->size += num_of_chan; + } + hostcmd->size = cpu_to_le16(hostcmd->size); + return; +} + +/** + * @brief Invoke multiple 2040Coex commands for multiple regulatory classes + * + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +int invoke_coex_command(void) +{ + int cur_reg_domain; + t_u8 chan_list[MAX_CHAN], is_intol_ap_present; + t_u8 num_of_chan; + int i, num_entry, ret = MLAN_STATUS_SUCCESS; + class_chan_t *cur_class_chan_table = NULL; + + /** get region code */ + ret = get_region_code(&cur_reg_domain); + if (ret != MLAN_STATUS_SUCCESS) + return ret; + /** Find region_class_chan_table for this region */ + for (i = 0; (unsigned int)i < (sizeof(region_class_chan_table) / + sizeof(region_class_chan_t)); + i++) { + if (region_class_chan_table[i].reg_domain == cur_reg_domain) { + cur_class_chan_table = + region_class_chan_table[i].class_chan_list; + num_entry = + region_class_chan_table[i].num_class_chan_entry; + break; + } + } + if (cur_class_chan_table == NULL) { + printf("No region_class_chan table found for this region\n"); + return MLAN_STATUS_FAILURE; + } + + for (i = 0; i < num_entry; i++) { + /** Get channels for the specified regulatory class */ + get_channels_for_specified_reg_class( + cur_class_chan_table, num_entry, chan_list, + &num_of_chan, cur_reg_domain, + cur_class_chan_table[i].reg_class, + &is_intol_ap_present); + + /** If any channel found for this regulatory class, then invoke + * the 2040coex command */ + if (num_of_chan > 0) { + ret = process_host_cmd( + CMD_2040COEX, chan_list, num_of_chan, + cur_class_chan_table[i].reg_class, + is_intol_ap_present); + if (ret) + break; + } + } + return ret; +} + +/** + * @brief Process host_cmd response + * + * @param cmd_name The command string + * @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->command &= ~HostCmd_RET_BIT; + if (!le16_to_cpu(hostcmd->result)) { + switch (hostcmd->command) { + } + } else { + printf("HOSTCMD failed: ReturnCode=%#04x, Result=%#04x\n", + le16_to_cpu(hostcmd->command), + le16_to_cpu(hostcmd->result)); + ret = MLAN_STATUS_FAILURE; + } + return ret; +} diff --git a/mapp/mlan2040coex/mlan2040misc.h b/mapp/mlan2040coex/mlan2040misc.h new file mode 100644 index 0000000..d1939e1 --- /dev/null +++ b/mapp/mlan2040coex/mlan2040misc.h @@ -0,0 +1,420 @@ +/** @file mlan2040misc.h + * + * @brief This file contains command definitions for application + * + * + * Copyright 2009-2021 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: + 06/24/2009: initial version +************************************************************************/ +#ifndef _COEX_MISC_H_ +#define _COEX_MISC_H_ + +/** 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 +/** TLV Id for 2040Coex IE */ +#define TLV_ID_2040COEX 0x48 +/** TLV Id for 2040BSS intolarent channel report IE */ +#define TLV_ID_2040BSS_INTOL_CHAN_REPORT 0x49 +/** Host-command for 2040coex command */ +#define HostCmd_CMD_11N_2040COEX 0x00e9 +/** Maximum scan response buffer size */ +#define SCAN_RESP_BUF_SIZE 2000 + +/** Maximum length of SSID */ +#define MRVDRV_MAX_SSID_LENGTH 32 + +/** Length of ethernet address */ +#ifndef ETH_ALEN +#define ETH_ALEN 6 +#endif +/** Maximum length of SSID list */ +#define MRVDRV_MAX_SSID_LIST_LENGTH 10 +/** Default scan interval in second*/ +#define DEFAULT_SCAN_INTERVAL 300 + +/** BIT value */ +#define MBIT(x) (((t_u32)1) << (x)) + +/** Check intolerent bit set */ +#define IS_INTOL_BIT_SET(cap_info) (cap_info & MBIT(14)) + +/** Check OBSS non-HT STAs present bit set */ +#define IS_NON_HT_STA_PRESENT(ht_info) (ht_info.field3 & MBIT(4)) + +/** 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, + HT_CAPABILITY = 45, + HT_OPERATION = 61, + BSSCO_2040 = 72, + OVERLAPBSSSCANPARAM = 74, + EXT_CAPABILITY = 127, + ERP_INFO = 42, + EXTENDED_SUPPORTED_RATES = 50, + VENDOR_SPECIFIC_221 = 221, + WMM_IE = VENDOR_SPECIFIC_221, + RSN_IE = 48, +} __attribute__((packed)) IEEEtypes_ElementId_e; + +/** HT Capabilities Data */ +typedef struct _HTCap_t { + /** HT Capabilities Info field */ + t_u16 ht_cap_info; + /** A-MPDU Parameters field */ + t_u8 ampdu_param; + /** Supported MCS Set field */ + t_u8 supported_mcs_set[16]; + /** HT Extended Capabilities field */ + t_u16 ht_ext_cap; + /** Transmit Beamforming Capabilities field */ + t_u32 tx_bf_cap; + /** Antenna Selection Capability field */ + t_u8 asel; + /** Reserved set to 0 */ + t_u16 reserved; +} __attribute__((packed)) HTCap_t, *pHTCap_t; + +/** HT Information Data */ +typedef struct _HTInfo_t { + /** Primary channel */ + t_u8 pri_chan; + /** Field 2 */ + t_u8 field2; + /** Field 3 */ + t_u16 field3; + /** Field 4 */ + t_u16 field4; + /** Bitmap indicating MCSs supported by all HT STAs in the BSS */ + t_u8 basic_mcs_set[16]; + /** Reserved set to 0 */ + t_u16 reserved; +} __attribute__((packed)) HTInfo_t, *pHTInfo_t; + +/** 20/40 BSS Coexistence Data */ +typedef struct _BSSCo2040_t { + /** 20/40 BSS Coexistence value */ + t_u8 bss_co_2040_value; + /** Reserve field */ + t_u8 reserved[3]; +} __attribute__((packed)) BSSCo2040_t, *pBSSCo2040_t; + +/** Extended Capabilities Data */ +typedef struct _ExtCap_t { + /** Extended Capabilities value */ + t_u8 ext_cap_value; + /** Reserved field */ + t_u8 reserved[3]; +} __attribute__((packed)) ExtCap_t, *pExtCap_t; + +/** Overlapping BSS Scan Parameters Data */ +typedef struct _OverlapBSSScanParam_t { + /** OBSS Scan Passive Dwell */ + t_u16 obss_scan_passive_dwell; + /** OBSS Scan Active Dwell */ + t_u16 obss_scan_active_dwell; + /** BSS Channel Width Trigger Scan Interval */ + t_u16 bss_chan_width_trigger_scan_int; + /** OBSS Scan Passive Total Per Channel */ + t_u16 obss_scan_passive_total; + /** OBSS Scan Active Total Per Channel */ + t_u16 obss_scan_active_total; + /** BSS Width Channel Transition Delay Factor */ + t_u16 bss_width_chan_trans_delay; + /** OBSS Scan Activity Threshold */ + t_u16 obss_scan_active_threshold; +} __attribute__((packed)) OBSSScanParam_t, *pOBSSScanParam_t; + +/** IEEEtypes_CapInfo_t structure*/ +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; +} __attribute__((packed)) IEEEtypes_CapInfo_t, *pIEEEtypes_CapInfo_t; + +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 + */ +} __attribute__((packed)) wlan_ioctl_user_scan_chan; + +typedef struct { + char ssid[MRVDRV_MAX_SSID_LENGTH + 1]; /**< SSID */ + t_u8 max_len; /**< Maximum length of SSID */ +} __attribute__((packed)) 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]; + +} __attribute__((packed)) wlan_ioctl_user_scan_cfg; + +/** IEEE IE header */ +typedef struct _IEEEtypes_Header_t { + /** Element ID */ + t_u8 element_id; + /** Length */ + t_u8 len; +} __attribute__((packed)) IEEEtypes_Header_t, *pIEEEtypes_Header_t; + +/** HT Capabilities IE */ +typedef struct _IEEEtypes_HTCap_t { + /** Generic IE header */ + IEEEtypes_Header_t ieee_hdr; + /** HTCap struct */ + HTCap_t ht_cap; +} __attribute__((packed)) IEEEtypes_HTCap_t, *pIEEEtypes_HTCap_t; + +/** HT Information IE */ +typedef struct _IEEEtypes_HTInfo_t { + /** Generic IE header */ + IEEEtypes_Header_t ieee_hdr; + /** HTInfo struct */ + HTInfo_t ht_info; +} __attribute__((packed)) IEEEtypes_HTInfo_t, *pIEEEtypes_HTInfo_t; + +/** 20/40 BSS Coexistence IE */ +typedef struct _IEEEtypes_2040BSSCo_t { + /** Generic IE header */ + IEEEtypes_Header_t ieee_hdr; + /** BSSCo2040_t struct */ + BSSCo2040_t bss_co_2040; +} __attribute__((packed)) IEEEtypes_2040BSSCo_t, *pIEEEtypes_2040BSSCo_t; + +/** Extended Capabilities IE */ +typedef struct _IEEEtypes_ExtCap_t { + /** Generic IE header */ + IEEEtypes_Header_t ieee_hdr; + /** ExtCap_t struct */ + ExtCap_t ext_cap; +} __attribute__((packed)) IEEEtypes_ExtCap_t, *pIEEEtypes_ExtCap_t; + +/** Overlapping BSS Scan Parameters IE */ +typedef struct _IEEEtypes_OverlapBSSScanParam_t { + /** Generic IE header */ + IEEEtypes_Header_t ieee_hdr; + /** OBSSScanParam_t struct */ + OBSSScanParam_t obss_scan_param; +} __attribute__((packed)) IEEEtypes_OverlapBSSScanParam_t, + *pIEEEtypes_OverlapBSSScanParam_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 starting at bssInfoBuffer + */ + 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; + +/** + * 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; + +/* Define general hostcmd data structure */ +/** HostCmd_DS_GEN */ +typedef struct _HostCmd_DS_GEN { + /** Command */ + t_u16 command; + /** Size */ + t_u16 size; + /** Sequence number */ + t_u16 seq_num; + /** Result */ + t_u16 result; +} __attribute__((packed)) HostCmd_DS_GEN; + +/** Size of HostCmd_DS_GEN */ +#define S_DS_GEN sizeof(HostCmd_DS_GEN) + +/** TLV related data structures*/ +/** MrvlIEtypesHeader_t */ +typedef struct _MrvlIEtypesHeader { + /** Header type */ + t_u16 type; + /** Header length */ + t_u16 len; +} __attribute__((packed)) MrvlIEtypesHeader_t; + +/** _MrvlIETypes_2040BssIntolerantChannelReport_t */ +typedef struct _MrvlIETypes_2040BssIntolerantChannelReport_t { + /** Header */ + IEEEtypes_Header_t header; + /** regulatory class */ + t_u8 reg_class; + /** channel numbers for legacy AP */ + t_u8 chan_num[1]; +} __attribute__((packed)) MrvlIETypes_2040BssIntolerantChannelReport_t; + +/** MrvlIETypes_2040COEX_t */ +typedef struct _MrvlIETypes_2040COEX_t { + /** Header */ + IEEEtypes_Header_t header; + /** 2040 coex element */ + t_u8 coex_elem; +} __attribute__((packed)) MrvlIETypes_2040COEX_t; + +typedef struct _HostCmd_DS_CMD_11N_2040COEX { + /** 2040 coex element */ + MrvlIETypes_2040COEX_t coex; + /** 2040 BSS intolerant channel report*/ + MrvlIETypes_2040BssIntolerantChannelReport_t chan_intol_report; +} __attribute__((packed)) HostCmd_DS_CMD_11N_2040COEX; + +/** Maximum number of channel per regulatory class */ +#define MAX_CHAN 20 +typedef struct _class_chan_t { + /** Regulatory class */ + t_u8 reg_class; + /** Channel numbers */ + t_u8 channels[MAX_CHAN]; + /** Total number of channels */ + t_u8 total_chan; +} class_chan_t; + +typedef struct _region_class_chan_t { + /** Regulatory domain */ + int reg_domain; + /** Channel numbers */ + class_chan_t *class_chan_list; + /** Number of class channel table entry */ + int num_class_chan_entry; +} region_class_chan_t; + +int process_host_cmd_resp(char *cmd_name, t_u8 *buf); +void prepare_coex_cmd_buff(t_u8 *buf, t_u8 *chan_list, t_u8 num_of_chan, + t_u8 reg_class, t_u8 is_intol_ap_present); +int invoke_coex_command(void); + +#endif /* _COEX_MISC_H_ */ diff --git a/mapp/mlanconfig/Makefile b/mapp/mlanconfig/Makefile new file mode 100644 index 0000000..25db488 --- /dev/null +++ b/mapp/mlanconfig/Makefile @@ -0,0 +1,48 @@ +# +# File : mlanconfig/Makefile +# +# Copyright 2008-2022 NXP + +# Path to the top directory of the mlandriver distribution +PATH_TO_TOP = ../.. + +# Determine how we should copy things to the install directory +ABSPATH := $(filter /%, $(INSTALLDIR)) +RELPATH := $(filter-out /%, $(INSTALLDIR)) +INSTALLPATH := $(ABSPATH) +ifeq ($(strip $(INSTALLPATH)),) +INSTALLPATH := $(PATH_TO_TOP)/$(RELPATH) +endif + +# Override CFLAGS for application sources, remove __ kernel namespace defines +CFLAGS := $(filter-out -D__%, $(ccflags-y)) +# remove KERNEL include dir +CFLAGS := $(filter-out -I$(KERNELDIR)%, $(CFLAGS)) + +# +# List of application executables to create +# +libobjs:= mlanconfig.o mlanhostcmd.o mlanmisc.o +exectarget=mlanconfig +TARGETS := $(exectarget) + +# +# Make target rules +# + +# All rule compiles list of TARGETS using builtin program target from src rule +all : +$(exectarget): $(libobjs) + $(CC) $(CFLAGS) $(libobjs) -o $(exectarget) + +# Update any needed TARGETS and then copy to the install path +build appsbuild install: $(TARGETS) + @cp -rf config $(INSTALLPATH) + +clean: + @rm -f $(exectarget) + @rm -f *.o + +distclean: clean + @rm -f *~ core + @rm -f tags diff --git a/mapp/mlanconfig/config/11axcfg.conf b/mapp/mlanconfig/config/11axcfg.conf new file mode 100644 index 0000000..9fed576 --- /dev/null +++ b/mapp/mlanconfig/config/11axcfg.conf @@ -0,0 +1,49 @@ +#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 08 00 82 00 08 +# HE PHY capability info +04 70 7e c9 fd 01 a0 0a 02 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/mapp/mlanconfig/config/11n_2040coex.conf b/mapp/mlanconfig/config/11n_2040coex.conf new file mode 100644 index 0000000..1e8cda7 --- /dev/null +++ b/mapp/mlanconfig/config/11n_2040coex.conf @@ -0,0 +1,21 @@ +# 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/mapp/mlanconfig/config/arpfilter.conf b/mapp/mlanconfig/config/arpfilter.conf new file mode 100644 index 0000000..a50b089 --- /dev/null +++ b/mapp/mlanconfig/config/arpfilter.conf @@ -0,0 +1,29 @@ +# File : arpfilter.conf + +######################### Host Sleep ARP/IP filtering command ################## +# add arp filter +# firmware supports 8 entries of ARP_FILTER. Each entry has 8 bytes. +# must not exceed 8x8+4=68 bytes + +arpfilter={ + TlvType:2=0x0115 + TlvLength:2={ + AddrType:2=3 # multicast + EthType:2=0xffff # Any + Ipv4Addr:4=0xffffffff # Any + AddrType:2=1 # broadcast + EthType:2=0x0608 # ARP: 0x0806 + Ipv4Addr:4=0x6200a8c0 # 192.168.0.98 + AddrType:2=2 # unicast + EthType:2=0xffff # Any + Ipv4Addr:4=0xffffffff # Any + } +} + +# remove arp filter +#arpfilter={ +# TlvType:2=0x0115 +# TlvLength:2={ +# } +#} +######################### Host Sleep ARP/IP filtering command ################## diff --git a/mapp/mlanconfig/config/auto_tx.conf b/mapp/mlanconfig/config/auto_tx.conf new file mode 100644 index 0000000..6bc9fde --- /dev/null +++ b/mapp/mlanconfig/config/auto_tx.conf @@ -0,0 +1,55 @@ +# 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 + GetTodToA: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/mapp/mlanconfig/config/autodfs.conf b/mapp/mlanconfig/config/autodfs.conf new file mode 100644 index 0000000..cd9e9f3 --- /dev/null +++ b/mapp/mlanconfig/config/autodfs.conf @@ -0,0 +1,13 @@ +#File autodfs.conf +autodfs_cfg={ + cac_start_chan=52 #Start zero dfs CAC on this channel + cac_timer=60 #CAC timer in seconds + bw=0 #Bandwidth + #0: 20MHz + #1: 40Mz above + #3: 40MHz below + #4: Bandwidth 80MHz + uap_chan_switch=0 #disable/enable uap chan switch after first CAC finished + multi_chan_dfs=1 #enable multi-channel dfs support + user_chan_list=52, 54, 56, 100 #user dfs channel list +} diff --git a/mapp/mlanconfig/config/band_steer_cfg.conf b/mapp/mlanconfig/config/band_steer_cfg.conf new file mode 100644 index 0000000..487cf59 --- /dev/null +++ b/mapp/mlanconfig/config/band_steer_cfg.conf @@ -0,0 +1,60 @@ + + +######################### band steering configure command ################## +band_steering_cfg={ + CmdCode=0x026f # do NOT change this line + + Action:1=31 # Action = BIT0|BIT1|BIT2|BIT3|BIT4 + # BIT0: State take effect + # BIT1: or this bit if want change Block2gPrbReq + # BIT2: or this bit if want change MaxBtmReqAllowed + # BIT3: or this if want to change Block2gPrbReqP2P + # BIT4: or this if want to enable/disable disassoc imminent + + 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=6 # 0~15,max bss_transition requests to station + Block2gPrbReqP2p:1=90 # percentage of probe requests to block before allowing response for the P2P client. This must be between 50 and 98. Else fw will not update the value + PrbRspBlockingCfg:1=0 #Enable/Disable sending Probe responses in Pre-Assoc method for STA. 1 to send probe responses. 0 to block probe resposes. + BtmDisassocImminent:1=0 #Enable/Disable Disassoc Imminent in BTM. 1=Enable, 0=Disable. + +# STA MAC addresses for blacklisting +# Max number of MACs supported is 20 +pattenHeaderType:2=0x0137 + patternHeaderLen:2={ + Type:1=0 #Type 0 for Blacklisted MAC Addresses + BlacklistState:1=1 #BlacklistState=1 to enable blacklisting + #BlacklistState=0 for disable blacklisting + Timeout:2=100 #Blacklisting timeout in TBTT + MAC1:6='0x11,0x22,0x33,0x44,0x55,0x66' + MAC2:6='0xaa,0xbb,0xcc,0xdd,0xee,0xff' + MAC3:6='0x11,0x22,0x33,0xaa,0xbb,0xcc' + MAC4:6='0x12,0x21,0x33,0x44,0x55,0x66' + MAC5:6='0x12,0x21,0x12,0x21,0x12,0x21' + MAC6:6='0xac,0x37,0x43,0x52,0xc7,0x34' + MAC7:6='0xaa,0xb7,0x43,0xc2,0x7c,0x33' + MAC8:6='0x07,0xb7,0x43,0xc2,0x7c,0x33' + MAC9:6='0xda,0xb7,0x43,0xc2,0x7c,0x33' + + } + +# band steering patterns to detetct dual band capability of STA +# Max number of patterns supported is 10 +# Max pattern length (for individual pattern) supported is 10 +pattenHeaderType:2=0x0137 + patternHeaderLen:2={ + Type:1=1 #Type 1 for Patterns + Len1:1=0x04 #This is pattern1 length in bytes + pattern1:4='0x11,0x22,0x33,0x44' #This is pattern represented in HEX + Len2:1=0x05 + pattern2:5='0x01,0x02,0x03,0x04,0x05' + Len3:1=0x02 + pattern3:2='0x03,0x04' + Len4:1=0x01 + pattern4:1='0x0a' + Len2:1=0x0a + pattern2:10='0x01,0x02,0x03,0x04,0x05,0x01,0x02,0x03,0x04,0x05' + } + + +} diff --git a/mapp/mlanconfig/config/bg_scan.conf b/mapp/mlanconfig/config/bg_scan.conf new file mode 100644 index 0000000..7a2b35e --- /dev/null +++ b/mapp/mlanconfig/config/bg_scan.conf @@ -0,0 +1,166 @@ +# File : bg_scan.conf +# ./mlanutl mlan0 hostcmd bg_scan.conf bgscfg +# ./mlanutl mlan0 hostcmd bg_scan.conf bgs_query + +######################### 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 ################## + +########### BG Scan Query ##################### +bgs_query={ + CmdCode=0x006c + flush:1=1 +} +########### BG Scan Query ##################### diff --git a/mapp/mlanconfig/config/bg_scan_wifidirect.conf b/mapp/mlanconfig/config/bg_scan_wifidirect.conf new file mode 100644 index 0000000..f480a9c --- /dev/null +++ b/mapp/mlanconfig/config/bg_scan_wifidirect.conf @@ -0,0 +1,88 @@ +# 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/mapp/mlanconfig/config/cal_data.conf b/mapp/mlanconfig/config/cal_data.conf new file mode 100644 index 0000000..e37f674 --- /dev/null +++ b/mapp/mlanconfig/config/cal_data.conf @@ -0,0 +1,42 @@ +01 00 0c 00 58 02 +00 40 68 0c 00 00 00 40 00 00 00 00 00 11 00 00 +00 11 00 10 00 00 00 00 00 00 00 00 00 00 00 00 +10 12 00 10 10 86 40 89 01 03 02 00 01 02 05 00 +01 03 05 00 17 17 00 05 00 00 00 00 00 00 00 00 +00 30 1f 11 00 00 00 70 00 00 00 00 13 00 1e 01 +00 1e 5e 15 29 5e 15 13 5c 1d 0d 0b 1d 0d 0b 29 +0d 0b 29 5c 0b 29 5c 1d 00 5c 1d 0d 00 00 00 00 +00 5c c0 0e 00 00 00 cc 00 5f 00 00 07 01 04 00 +00 00 0e 0d 00 00 00 00 00 00 00 00 00 00 00 ff +00 00 00 01 00 00 00 00 00 00 00 ff 00 00 00 01 +00 00 00 00 00 00 00 ff 00 00 00 01 00 00 00 00 +00 00 00 ff 00 00 00 01 00 00 00 00 06 3c 06 3d +00 00 00 00 00 00 00 00 00 00 00 00 +00 5c dc 25 00 00 01 28 00 6f 00 00 07 01 04 00 +00 00 0e 0d 00 00 00 00 00 00 00 00 00 08 00 07 +00 00 00 09 00 00 00 00 00 08 00 07 00 00 00 09 +00 00 00 00 00 08 00 07 00 00 00 09 00 00 00 00 +00 08 00 07 00 00 00 09 00 00 00 00 06 3c 06 3d +00 00 00 00 00 00 00 00 00 00 00 00 +00 14 9f 1f 00 00 01 3c 03 00 00 00 00 f1 0a f1 +00 fb 0d fb +00 20 dd 28 00 00 01 5c 08 86 00 88 ff 06 b1 05 +24 24 3c 42 00 00 24 18 a4 24 bc bc 3d 00 a0 8f +00 14 00 2a 00 00 01 70 00 00 30 00 01 05 1b 00 +00 00 00 01 +00 74 2c 10 00 00 01 e4 00 00 00 00 09 6a 09 b0 +0b 12 00 6c 04 0a 00 6c 03 03 00 6c 03 03 00 6c +3f ff ff 00 3f ff ff 01 3f ff ff 02 3f ff ff 03 +15 00 00 04 17 00 00 05 19 00 00 06 1b 00 00 07 +1d 00 00 08 1f 00 00 09 21 00 00 0a 23 00 00 0b +25 00 00 0c 28 00 00 0d 2a 00 00 0e 2d 00 00 0f +2f 00 00 10 32 00 00 11 34 00 00 12 3f ff ff 13 +3f ff ff 14 +00 74 84 10 ff ff ff ff 01 00 00 00 09 b0 09 ba +0a 0f 00 6c 04 09 00 6c 03 03 00 6c 03 03 00 6c +3f ff ff 00 3f ff ff 01 3f ff ff 02 3f ff ff 03 +15 00 00 04 17 00 00 05 1a 00 00 06 1c 00 00 07 +1f 00 00 08 21 00 00 09 23 00 00 0a 26 00 00 0b +2a 00 00 0c 2d 00 00 0d 31 00 00 0e 34 00 00 0f +3f ff ff 10 3f ff ff 11 3f ff ff 12 3f ff ff 13 +3f ff ff 14 diff --git a/mapp/mlanconfig/config/crypto_test.conf b/mapp/mlanconfig/config/crypto_test.conf new file mode 100644 index 0000000..d35812f --- /dev/null +++ b/mapp/mlanconfig/config/crypto_test.conf @@ -0,0 +1,58 @@ +# 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/mapp/mlanconfig/config/csi.conf b/mapp/mlanconfig/config/csi.conf new file mode 100644 index 0000000..19a833e --- /dev/null +++ b/mapp/mlanconfig/config/csi.conf @@ -0,0 +1,22 @@ +[headID] +00 01 02 03 +[/headID] +[tailID] +00 01 02 03 +[/tailID] +[chipID] +aa +[/chipID] +[csifilter0] +#MAC address +C0 56 27 D6 2E 3C +#Packet Type +01 +#Subtype +0D +#Other filter flags +#bit0 reserved, must be 0 +#bit1 set to 1: wait for trigger +#bit2 set to 1: send CSI error event when timeout +06 +[/csifilter0] diff --git a/mapp/mlanconfig/config/cwmode.conf b/mapp/mlanconfig/config/cwmode.conf new file mode 100644 index 0000000..1f245a2 --- /dev/null +++ b/mapp/mlanconfig/config/cwmode.conf @@ -0,0 +1,51 @@ +#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/mapp/mlanconfig/config/debug.conf b/mapp/mlanconfig/config/debug.conf new file mode 100644 index 0000000..927b36a --- /dev/null +++ b/mapp/mlanconfig/config/debug.conf @@ -0,0 +1,729 @@ +# +# File: debug.conf +# 11ax configuration commands +# + +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; +} + +#Nav mitigate command +stop_nav_mitigate={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x105 # NAV MITGATION + Value:1=0 # 0 -- stop_mitigate; +} + +start_nav_mitigate={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x105 # NAV MITIGATION + Value:1=1 # 1 -- start_mitigate; + Option:1=0 # 1 -- disable rts for nav +} + + +get_nav_mitigate={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 1 - GET + SUBID:2=0x105 # NAV MITIGATION + Value:1=0 # 0: ignore; + nav_detect_cnt:2=0 # 0: ignore; + nav_stop_cnt:2=0 # 0: ignore; +} + +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; +} + +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 + } +} + +set_bcntx={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1: SET + SUBID:2=0x118 # BCN TX Config + update:1=0x0 # Update - 1: update; 0: default + txformat:1=0x3 # Format - 3: HE; 2: VHT; 1: HT; 0: legacy + txmcsnss:1=0x0 # NSS&CS - Bit[3:0]: MCS; Bit[5:4]: NSS (0: 1SS; 1: 2SS) + txratecfg:2=0x2161 # HE ER - Refer to txratecfg: + # 0x2265: RU106, 4xHELTF+3.2GI LDPC, DCM = 0 + # 0x2065: RU106, 4xHELTF+3.2GI BCC, DCM = 0 + # 0x2365: RU106, 4xHELTF+3.2GI LDPC, DCM = 1 + # 0x2165: RU106, 4xHELTF+3.2GI BCC, DCM = 1 + # 0x2261: RU204, 4xHELTF+3.2GI LDPC, DCM = 0 + # 0x2061: RU204, 4xHELTF+3.2GI BCC, DCM = 0 + # 0x2361: RU204, 4xHELTF+3.2GI LDPC, DCM = 1 + # 0x2161: RU204, 4xHELTF+3.2GI BCC, DCM = 1 +} + +get_bcntx={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0: GET + SUBID:2=0x118 # BCN TX Config + update:1=0x0 # 0: ignore; + txformat:1=0x0 # 0: ignore; + txmcsnss:1=0x0 # 0: ignore; + txratecfg:2=0 # 0: ignore; +} + +enable_nonHT_duplicate={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x119 # NON-HT DUPLICATE + Value:1=1 # 1 -- ENABLE; +} + +disable_nonHT_duplicate={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x119 # NON-HT DUPLICATE + Value:1=0 # 0 -- DISABLE; +} + +get_nonHT_duplicate={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x119 # NON-HT DUPLICATE + Value:1=0 # 1 -- ENABLE; + # 0 -- DISABLE; +} + +stop_2NSS_Steering={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x120 # HE_CONFIG_2NSS_STEERING + Value:1=0 # 0 -- stop 2NSS steering; +} + +start_2NSS_Steering={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x120 # HE_CONFIG_2NSS_STEERING + Value:1=1 # 1 -- start 2NSS steering; +} + +set_ifb_rate={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x11a # IFB rate + checkBcnInterval:1=0x2 # specify the number of beacons elapsed for checking beacon RSSI; + bcnRssiThreshold:1=-70 # specify the beacon RSSI threshold; +} + +get_ifb_rate={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x11a # IFB rate + checkBcnInterval:1=0x0 # get the number of beacons elapsed for checking beacon RSSI ; + bcnRssiThreshold:1=0x0 # get the beacon RSSI threshold; +} + +set_null2self_count={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x121 # null2self duplicate count + Value:1=0x0 # specify the null2self duplicate count; +} + +get_null2self_count={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x121 # null2self duplicate count + Value:1=0x0 # get the null2self duplicate count; +} + +set_mgmttx={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1: SET + SUBID:2=0x11c # MGMT TX Config + update:1=0x1 # Update - 1: update; 0: default + txformat:1=0x3 # Format - 3: HE; 2: VHT; 1: HT; 0: legacy + txmcsnss:1=0x0 # NSS&CS - Bit[3:0]: MCS; Bit[5:4]: NSS (0: 1SS; 1: 2SS) + txratecfg:2=0x2361 # HE ER - Refer to txratecfg: + # 0x2265: RU106, 4xHELTF+3.2GI LDPC, DCM = 0 + # 0x2065: RU106, 4xHELTF+3.2GI BCC, DCM = 0 + # 0x2365: RU106, 4xHELTF+3.2GI LDPC, DCM = 1 + # 0x2165: RU106, 4xHELTF+3.2GI BCC, DCM = 1 + # 0x2261: RU204, 4xHELTF+3.2GI LDPC, DCM = 0 + # 0x2061: RU204, 4xHELTF+3.2GI BCC, DCM = 0 + # 0x2361: RU204, 4xHELTF+3.2GI LDPC, DCM = 1 + # 0x2161: RU204, 4xHELTF+3.2GI BCC, DCM = 1 +} + +get_mgmttx={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0: GET + SUBID:2=0x11c # MGMT TX Config + update:1=0x0 # 0: ignore; + txformat:1=0x0 # 0: ignore; + txmcsnss:1=0x0 # 0: ignore; + txratecfg:2=0 # 0: ignore; +} + +enable_nonAmpdu_rts={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x122 # NON-AMPDU RTS + Value:1=1 # 1 -- ENABLE; +} + +disable_nonAmpdu_rts={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x122 # NON-AMPDU RTS + Value:1=0 # 0 -- DISABLE; +} + +get_nonAmpdu_rts={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x122 # NON-AMPDU RTS + Value:1=0 # 1 -- ENABLE; + # 0 -- DISABLE; +} + + +set_htc_cap={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x124 # Enable HTC+ in HE MAC CAP + Value:1=0x1 # 1 -- ENABLE; 0 -- DISABLE +} + +get_htc_cap={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x124 # Enable HTC+ in HE MAC CAP + Value:1=0 # NA +} + + +set_rsptx={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1: SET + SUBID:2=0x11d # RSP TX Config + update:1=0x1 # Update - 1: update; 0: default + frmtype:1=0x35 # frame type [type and subtype: b2-b7] + # 110101 - ACK + txformat:1=0x0 # Format - 3: HE; 2: VHT; 1: HT; 0: legacy + txmcsnss:1=0x0 # NSS&CS - Bit[3:0]: MCS; Bit[5:4]: NSS (0: 1SS; 1: 2SS) + txratecfg:2=0x0 # Legacy: 1 Mbps +} + +get_rsptx={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0: GET + SUBID:2=0x11d # RSP TX Config + update:1=0x0 # 0: ignore; + frmtype:1=0x0 # frame type [type and subtype: b2-b7] + txformat:1=0x0 # 0: ignore; + txmcsnss:1=0x0 # 0: ignore; + txratecfg:2=0 # 0: ignore; +} + + +set_time_slot={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x11E # Time Slot + Value:1=20 # valid value: 9 and 20 +} + +get_time_slot={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x11E # Time Slot + Value:1=0 # NA +} + +test_independent_reset={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x117 # TEST IR +} + +enable_auto_iq_cal={ + + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x126 # AUTO_IQ_CAL + Value:1=1 # 1 -- ENABLE; +} + +disable_auto_iq_cal={ + + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x126 # AUTO_IQ_CAL + Value:1=0 # 0 -- DISABLE; +} + +get_auto_iq_cal={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x126 # AUTO_IQ_CAL + Value:1=0 # 1 -- ENABLE; + # 0 -- DISABLE; +} + +#TXOP limit WAR +enable_txop_limit={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x127 # TXOP Limit + Value:1=1 # valid value: 1: enable; 0: disable +} + +disable_txop_limit={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x127 # TXOP Limit + Value:1=0 # valid value: 1: enable; 0: disable +} + +get_txop_limit={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x127 # TXOP Limit + Value:1=0 # N/A +} + +set_ru_busy={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x128 # RU BUSY + Value:1=0 # valid value: 1: enable; 0: disable; 0xFF: origin +} + +get_ru_busy={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x128 # RU BUSY + Value:1=0 # N/A +} + +recover_ru_busy={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x128 # RU BUSY + Value:1=0xFF # valid value: 1: enable; 0: disable; 0xFF: origin +} + +#Enable Dropping Rx AMPDUs +set_drop_rxampdu={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x129 # DROP RX AMPDU + Value:4=1 # valid value: 1: enable; 0: disable; +} + +#Disable Dropping Rx AMPDUs +unset_drop_rxampdu={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x129 # DROP RX AMPDU + Value:4=0 # valid value: 1: enable; 0: disable; +} + +#Get the number of Rx AMPDUs dropped. +get_drop_rxampdu={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x129 # DROP RX AMPDU + Value:4=0 # N/A +} + + +#Set MAC recovery +set_mac_recovery={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x12a # MAC RECOVERY + Value:4=1 # valid value: 1: tx watch dog recovery; 2: Rx MAC reset; 3: tx watch dog and rx MAC; +} + +#Get MAC recovery +get_mac_recovery={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x12a # MAC RECOVERY + Value:4=1 # valid value: 1: tx watch dog recovery; 2: Rx MAC reset; 3: tx watch dog and rx MAC; +} + +set_refDesignSepcific_dfs_settings={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x12b # REFDESIGNSPECIFIC_DFS_SETTINGS + Value:1=1 # 1 -- value; +} + +clear_refDesignSepcific_dfs_settings={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x12b # REFDESIGNSPECIFIC_DFS_SETTINGS + Value:1=0 # 0 -- value; +} + +get_refDesignSepcific_dfs_settings={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x12b # REFDESIGNSPECIFIC_DFS_SETTINGS + Value:1=0 # NA +} + + +#Trigger IMD3 calibration +imd3_cal_trigger={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x12C # IMD3 cal trigger +} + +#Set A-MPDU density for MMSF +enable_mmsf={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x12D # MMSF WAR + MMSF:1=1 # 1 - enable MMSF; 0 - disable MMSF; + Density:1=0x30 # Do not change the value unless necessary +} + +disable_mmsf={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x12D # MMSF WAR + MMSF:1=0 # 1 - enable MMSF; 0 - disable MMSF; + Density:1=0x30 # Do not change the value unless necessary +} + +get_mmsf={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x12D # MMSF WAR + MMSF:1=0 # 1 -- enable MMSF; # 0 -- disable MMSF; + Density:1=0x00 # +} + +#RSSI CAP for SR Rate Adaptation. +enable_rssi_cap={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x12E # Enable RSSI CAP + Value:1=0x1 # 1 -- ENABLE; 0 -- DISABLE +} + +disable_rssi_cap={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x12E # Enable RSSI CAP + Value:1=0x0 # 1 -- ENABLE; 0 -- DISABLE +} + +get_rssi_cap={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x12E # Enable RSSI CAP + Value:1=0 # NA +} + +#Enable Tx Queue Size reported in HE SU QoS data packet +enable_qsz_rpt={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x12F # Tx Queue Size Report + QszRpt:1=1 # 1 - enable; 0 - disable; +} + +disable_qsz_rpt={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x12F # Tx Queue Size Report + QszRpt:1=0 # 1 - enable; 0 - disable; +} + +get_qsz_rpt={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x12F # Tx Queue Size Report + QszRpt:1=0 # N/A +} + +#AMPDU MAX AIR TIME: [min, max] = [1504, 5484] us +set_max_air_time={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x130 # AMPDU MAX AIR TIME + Value:2=5400 # max air time in us +} + +get_max_air_time={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x130 # AMPDU MAX AIR TIME + Value:2=0 # NA +} + +#NEW DATA RATE DROP TABLE +set_rate_drop_table={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x133 # NEW DATA RATE DROP TABLE + Value:1=0x0 # 1: new table (default); 0: old table +} + +get_rate_drop_table={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x133 # NEW DATA RATE DROP TABLE + Value:1=0 # NA +} + +#CONFIG HE ER +#BASIC HE ER: HE ER without DCM or tone106 +#DCM HE ER: Basic HE ER + HE ER with DCM +#TONE106 HE ER: Basic HE ER + HE ER with TONE 106 +#DEFAULT HE ER: HE ER + HE ER with DCM or TONE 106. +config_he_er_basic={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x134 # CONFIG HE ER + BasicHeEr:1=1 # enable basic HE ER + DcmHeEr:1=0 # disable DCM for HE ER + Tone106HeEr:1=0 # disable tone106 for HE ER +} + +config_he_er_dcm={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x134 # CONFIG HE ER + BasicHeEr:1=1 # enable basic HE ER + DcmHeEr:1=1 # enable DCM for HE ER + Tone106HeEr:1=0 # disable tone106 for HE ER +} + +config_he_er_tone106={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x134 # CONFIG HE ER + BasicHeEr:1=1 # enable basic HE ER + DcmHeEr:1=0 # disable DCM for HE ER + Tone106HeEr:1=1 # enable tone106 for HE ER +} + +config_he_er_all={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x134 # CONFIG HE ER + BasicHeEr:1=1 # enable basic HE ER + DcmHeEr:1=1 # enable DCM for HE ER + Tone106HeEr:1=1 # enable tone106 for HE ER +} + +config_he_er_default={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x134 # CONFIG HE ER + BasicHeEr:1=0 # disable basic HE ER + DcmHeEr:1=1 # enable DCM for HE ER + Tone106HeEr:1=1 # enable tone106 for HE ER +} + +get_he_er_config={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x134 # CONFIG HE ER + BasicHeER:1=0 # NA + HeErDcm:1=0 # NA + HeErTone106:1=0 # NA +} + + +#Have HT MCS0/Legacy 6 Mbps in the place of BASIC HE ER in 5G +#if BASIC HE ER is not supported by the peer. +#BASIC LG: HT MCS0/LG 6Mbps after HE20 MCS0 +#DCM LG: BASIC LG + HE ER with DCM +#TONE106 LG: BASIC LG + HE ER with TONE 106 +#DEFAULT: BASIC LG + HE ER with DCM or TONE 106. +config_he_lg_basic={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x134 # CONFIG HE ER + BasicHeEr:1=0 # enable basic HE ER + DcmHeEr:1=0 # disable DCM for HE ER + Tone106HeEr:1=0 # disable tone106 for HE ER +} + +config_he_lg_dcm={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x134 # CONFIG HE ER + BasicHeEr:1=0 # enable basic HE ER + DcmHeEr:1=1 # enable DCM for HE ER + Tone106HeEr:1=0 # disable tone106 for HE ER +} + +config_he_lg_tone106={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x134 # CONFIG HE ER + BasicHeEr:1=0 # enable basic HE ER + DcmHeEr:1=0 # disable DCM for HE ER + Tone106HeEr:1=1 # enable tone106 for HE ER +} + + + +trigger_timeout={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x135 # Trigger Timeout + Value:1=1 # 1 - Wakeupcard Timeout; 2 - Tx Timeout +} + +cm3_debugMon_handle={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x136 # CM3 debug monitor handle enable + enable:1=0x1 # 0 - Disable the exception (Clear breakpoint), + # 1 - enable the exception (set breakpoint) + recurring_bkpt:1=0x1 # 0 - bkpt will hit only once, 1 - bkpt can hit every time + # if it is 1, it ignores dump_gen_allow value + # This option is available only for data breakpoint + addr:4=0x90002114 # Code/data breakpoint Address + mask:4=0x0 # Mask (1 means that bit will be ignored) + # Please use mask as 0 only. If you use other than 0, it gives unpredictable result + add_size:1=0x2 # 0 - byte, 1 - half word, 2 - word (size for comparison) + bkpt_type:1=1 # 0 - Code, 1 - data + data_bkpt_cond:1=2 # 0 - read, 1 - write, 2 - read or write + data_bkpt_match_val_en:1=0 # 0 - match value will be ignored, 1 - match value will be compared + data_bkpt_match_val:4=0x0 # Value to be matched + dump_gen_allow:1=1 # 0 - don't generate dump, 1 - generate dump + bkpt_hit_cnt:4=0x0 # breakpoint hit count (do NOT change this line) +} + +profiling_start={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x137 # CONFIG PROFILING + profiling_command:1=1 # start profiliing +} + +profiling_stop={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x137 # CONFIG PROFILING + profiling_command:1=0 # stop profiliing +} + +profiling_report={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x137 # CONFIG PROFILING + profiling_command:1=2 # report profiliing results +} + +#Debug log +enable_debug_log={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x138 # Debug log + Value:1=1 # 1 -- enable +} + +disable_debug_log={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x138 # Debug log + Value:1=0 # 0 -- disable +} + +get_debug_log={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x138 # Debug log + Value:1=0 # NA +} + +#on demand IQ cal and DPD re-trigger - To mimic / stress test temperature triggered IQ cal and DPD +trigger_runtime_cal_and_dpd={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x151 # trigger_runtime_cal follower by dpd on demand + Value:1=0 # 0; +} diff --git a/mapp/mlanconfig/config/debug_ci_mode.conf b/mapp/mlanconfig/config/debug_ci_mode.conf new file mode 100644 index 0000000..1543f3b --- /dev/null +++ b/mapp/mlanconfig/config/debug_ci_mode.conf @@ -0,0 +1,49 @@ +# +# File: debug_ci_mode.conf +# C/I performance mode +# + +ci_mode_get={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x110 # C/I performance mode + Value:1=0 # 1 - high sensitivity mode + # 2 - high linearity mode + # 3 - dynamic switch mode +} + +ci_mode_set_hs={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x110 # C/I performance mode + Value:1=1 # 1 - high sensitivity mode +} + +ci_mode_set_hl={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x110 # C/I performance mode + Value:1=2 # 2 - high linearity mode +} + +ci_mode_set_ds={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x110 # C/I performance mode + Value:1=3 # 3 - dynamic switch mode +} + +ci_s1_timer_get={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x123 # C/I dynamic switch S1_Timer + Value:1=0 # S1_Timer (default value is 10, about 5s) +} + +ci_s1_timer_set={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x123 # C/I dynamic switch S1_Timer + Value:1=20 # S1_Timer (if value is 20, timer is about 10s) +} + diff --git a/mapp/mlanconfig/config/ed_mac_ctrl_V2_8897.conf b/mapp/mlanconfig/config/ed_mac_ctrl_V2_8897.conf new file mode 100644 index 0000000..f472e81 --- /dev/null +++ b/mapp/mlanconfig/config/ed_mac_ctrl_V2_8897.conf @@ -0,0 +1,29 @@ +# 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/mapp/mlanconfig/config/ed_mac_ctrl_V2_8997.conf b/mapp/mlanconfig/config/ed_mac_ctrl_V2_8997.conf new file mode 100644 index 0000000..76d2dab --- /dev/null +++ b/mapp/mlanconfig/config/ed_mac_ctrl_V2_8997.conf @@ -0,0 +1,22 @@ +# File : ed_mac_ctrl_V2_8997.conf +# +# ./mlanutl mlan0 hostcmd config/ed_mac_ctrl_V2_8997.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_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/mapp/mlanconfig/config/ed_mac_ctrl_V2_909x.conf b/mapp/mlanconfig/config/ed_mac_ctrl_V2_909x.conf new file mode 100644 index 0000000..73a6fcc --- /dev/null +++ b/mapp/mlanconfig/config/ed_mac_ctrl_V2_909x.conf @@ -0,0 +1,29 @@ +# File : ed_mac_ctrl_V2_909x.conf +# +# ed_mac_ctrl_v2 is used for 88W9098, 88W9097 +# ./mlanutl mlan0 hostcmd config/ed_mac_ctrl_V2_909x.conf ed_mac_ctrl_v2 +# +## Get/Set Energy Detect Threshold for EU Adaptivity test + +# Command name for GET action: DO NOT change/add. +ed_mac_ctrl_v2_get={ + CmdCode=0x0130 #Command code, DO NOT change this line +} + +# Command name for SET action. +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=0x8 # 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=0x8 # 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/mapp/mlanconfig/config/ftm.conf b/mapp/mlanconfig/config/ftm.conf new file mode 100644 index 0000000..a1b4bda --- /dev/null +++ b/mapp/mlanconfig/config/ftm.conf @@ -0,0 +1,114 @@ +# +# File: ftm.conf +# +# Copyright 2022, NXP +# +# NXP CONFIDENTIAL +# Copyright 2022, NXP . +# The source code contained or described herein and all documents related to +# the source code ("Material") are owned by NXP NXPor its +# suppliers or licensors. Title to the Material remains with NXP +# or its suppliers and licensors. The Material contains trade secrets and +# proprietary and confidential information of NXP or its suppliers and +# licensors. The Material is protected by worldwide copyright and trade secret +# laws and treaty provisions. No part of the Material may be used, copied, +# reproduced, modified, published, uploaded, posted, transmitted, distributed, +# or disclosed in any way without NXP's prior express written permission. +# +# No license under any patent, copyright, trade secret or other intellectual +# property right is granted to or conferred upon you by disclosure or delivery +# of the Materials, either expressly, by implication, inducement, estoppel or +# otherwise. Any license under such intellectual property rights must be +# express and approved by NXP in writing. +################################################################################# + +# LOCATION configuration file +# Lines that start with # are treated as comments +# Each line should not exceed 80 characters +# Format: TYPE=value +# +################################################################################# +################################################################################# +DOT11MC_CFG={ +# Indicates how many burst instances are requested for the FTM session +BURST_EXP=0 + +# Burst Duration +# 0 - 1: Reserved +# 2: 250 micro seconds +# 3: 500 micro seconds +# 4: 1 ms +# 5: 2 ms +# 6: 4 ms +# 7: 8 ms +# 8: 16 ms +# 9: 32 ms +# 10: 64 ms +# 11: 128 ms +# 12-14 reserved +BURST_DURATION=10 + +# Indicates minimum time between consecutive Fine Timing Measurement +# frames. It is specified in in units of 100 micro seconds. +MIN_DELTA=10 + +# ASAP +IS_ASAP=1 + +# FTM frames per burst +FTM_PER_BURST=10 + +# Bandwidth +# 9 - HT20 +# 10 - VHT20 +# 11 - HT40 +# 12 - VHT40 +# 13 - VHT80 +BW=13 + +# Burst Period in units of 100 milli seconds +BURST_PERIOD=5 + +} + +LCI={ +##### FOR LCI REQUEST ####### +LATITIUDE=-33.8570095 +LONGITUDE=+151.2152005 +LATITUDE_UNCERTAINITY=18 +LONGITUDE_UNCERTAINITY=18 +ALTITUDE=11.2 +ALTITUDE_UNCERTAINITY=15 +} + +CIVIC_LOC={ +##### FOR CIVIC LOCATION ####### +CIVIC_LOCATION_TYPE=1 +COUNTRY_CODE=0 #US +CIVIC_ADDRESS_TYPE=22 +ADDRESS="123, NXP India Pvt Ltd, Pune" +} + +##### FOR FQDN support in ANQP frames ##### +FQDN_SUPPORT=0 +ANQP_DIALOG_TOKEN=1 +CIVIC_LOCATION=1 +LCI_REQUEST=1 + +##### FOR NEIGHBOR Request frames ##### +NBOR_DIALOG_TOKEN=1 + +DOT11AZ_RANGING_CFG={ +##### For FTM with NTB ranging ##### +FORMAT_BW=0 + +# Maximum number of space-time streams to be used in DL/UL NDP frames in the session upto 80MHz +MAX_I2R_STS_UPTO80=0 +MAX_R2I_STS_UPTO80=1 +# Measurement freq in Hz to calculate measurement interval in ms. Recommended values ( 1-5 Hz ) +# 1Hz = 1000ms ; 2Hz = 500ms ; 3Hz= 333ms ; 4Hz = 250ms ; 5Hz = 200ms +AZ_MEASUREMENT_FREQ=2 +AZ_NUMBER_OF_MEASUREMENTS=6 +I2R_LMR_FEEDBACK=0 +} +################################################################################# diff --git a/mapp/mlanconfig/config/hal_phy_cfg.conf b/mapp/mlanconfig/config/hal_phy_cfg.conf new file mode 100644 index 0000000..312f980 --- /dev/null +++ b/mapp/mlanconfig/config/hal_phy_cfg.conf @@ -0,0 +1,11 @@ +# File : hal_phy_cfg.conf + +######################### HAL PHY PARAMETERS configuration ###################### +# starts with a command name with parameters embedded inside + +hal_phy_cfg={ + 11b_psd_mask_cfg=1 # 1: 11b_psd_mask_enable, 0: 11b_psd_mask_disable +} + +######################### HAL PHY PARAMETERS configuration ###################### + diff --git a/mapp/mlanconfig/config/host_tdls.conf b/mapp/mlanconfig/config/host_tdls.conf new file mode 100644 index 0000000..3316d79 --- /dev/null +++ b/mapp/mlanconfig/config/host_tdls.conf @@ -0,0 +1,22 @@ +# File : host_tdls.conf + +######################### HOST TDLS commands configuration ################## +# starts with a command name with parameters embedded inside + +host_tdls_config={ + uapsd_support=1 # 1: suport uapsd, 0: uapsd not support + cs_support=1 # 1: support channel switch, 0: don't support channel switch + SupportedChannels={ + FirstChannelNo=1 + NumberofSubBandChannels=11 + # multiple instances of First Channel No, Number of SubBand Channels + } + SupportedRegulatoryClasses={ + CurrentRegulatoryClass=1 + NumofRegulatoryClasses=15 + ListOfRegulatoryClasses=1,2,3,4,12,22,23,24,25,27,28,29,30,32,33 + } + +} + +######################### HOST TDLS commands configuration ################## diff --git a/mapp/mlanconfig/config/init_cfg.conf b/mapp/mlanconfig/config/init_cfg.conf new file mode 100644 index 0000000..821c024 --- /dev/null +++ b/mapp/mlanconfig/config/init_cfg.conf @@ -0,0 +1,14 @@ +# 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/mapp/mlanconfig/config/mef.conf b/mapp/mlanconfig/config/mef.conf new file mode 100644 index 0000000..37d19a4 --- /dev/null +++ b/mapp/mlanconfig/config/mef.conf @@ -0,0 +1,167 @@ +# 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/mapp/mlanconfig/config/mef_mdns.conf b/mapp/mlanconfig/config/mef_mdns.conf new file mode 100644 index 0000000..568ca6f --- /dev/null +++ b/mapp/mlanconfig/config/mef_mdns.conf @@ -0,0 +1,204 @@ +# 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/mapp/mlanconfig/config/mef_ws_discovery.conf b/mapp/mlanconfig/config/mef_ws_discovery.conf new file mode 100644 index 0000000..518a240 --- /dev/null +++ b/mapp/mlanconfig/config/mef_ws_discovery.conf @@ -0,0 +1,204 @@ +# 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/mapp/mlanconfig/config/mem.conf b/mapp/mlanconfig/config/mem.conf new file mode 100644 index 0000000..cf649c9 --- /dev/null +++ b/mapp/mlanconfig/config/mem.conf @@ -0,0 +1,17 @@ +#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/mapp/mlanconfig/config/mgmt_frame.conf b/mapp/mlanconfig/config/mgmt_frame.conf new file mode 100644 index 0000000..22b19b1 --- /dev/null +++ b/mapp/mlanconfig/config/mgmt_frame.conf @@ -0,0 +1,30 @@ +# 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/mapp/mlanconfig/config/mgmtfilter.conf b/mapp/mlanconfig/config/mgmtfilter.conf new file mode 100644 index 0000000..8ee0298 --- /dev/null +++ b/mapp/mlanconfig/config/mgmtfilter.conf @@ -0,0 +1,15 @@ +##############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/mapp/mlanconfig/config/null_tx.conf b/mapp/mlanconfig/config/null_tx.conf new file mode 100644 index 0000000..e73e216 --- /dev/null +++ b/mapp/mlanconfig/config/null_tx.conf @@ -0,0 +1,40 @@ +# auto send qos null data packet +qos_null_tx={ + CmdCode=0x0082 # do NOT change this line + Action:2=1 # do NOT change this line + AutoTxTlvType:2=0x0118 # do NOT change this line + AutoTxTlvLength:2={ # do NOT change this line + Interval:2=0x8064 # bit15:14 unit: 00-s 01-us 10-ms 11-one_shot bit13-0: interval + Priority:1=0x27 # bit7-4: bandwidth. bit3-0: priority, ignored if non-WMM + Index:1=0 # packet index. Valid 0-15 + FrameLength:2={ # do NOT change this line + DestMacAddr:6='0xc0,0x56,0x27,0xd6,0x2e,0x3c' # Peer's MAC address + SrcMacAddr:6='0x00,0x00,0x00,0x00,0x00,0x00' # do NOT change this line + Length:2='0x00,0x00' # do NOT change this line + } + } +} + +# stop auto send qos null data packet +qos_null_tx_stop={ + CmdCode=0x0082 # do NOT change this line + Action:2=1 # do NOT change this line +} + + +# send qos null data packet one time only +qos_null_one_shot={ + CmdCode=0x0082 # do NOT change this line + Action:2=1 # do NOT change this line + AutoTxTlvType:2=0x0118 # do NOT change this line + AutoTxTlvLength:2={ # do NOT change this line + Interval:2=0xc064 # bit15:14 unit: 00-s 01-us 10-ms 11-one_shot bit13-0: interval + Priority:1=0x27 # bit7-4: bandwidth. bit3-0: priority, ignored if non-WMM + Index:1=0 # packet index. Valid 0-15 + FrameLength:2={ # do NOT change this line + DestMacAddr:6='0xc0,0x56,0x27,0xd6,0x2e,0x3c' # Peer's MAC address + SrcMacAddr:6='0x00,0x00,0x00,0x00,0x00,0x00' # do NOT change this line + Length:2='0x00,0x00' # do NOT change this line + } + } +} diff --git a/mapp/mlanconfig/config/or_data.conf b/mapp/mlanconfig/config/or_data.conf new file mode 100644 index 0000000..99154f5 --- /dev/null +++ b/mapp/mlanconfig/config/or_data.conf @@ -0,0 +1,7 @@ + 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/mapp/mlanconfig/config/pad_cfg.conf b/mapp/mlanconfig/config/pad_cfg.conf new file mode 100644 index 0000000..dc996ee --- /dev/null +++ b/mapp/mlanconfig/config/pad_cfg.conf @@ -0,0 +1,29 @@ +# 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/mapp/mlanconfig/config/pkt_coalescing.conf b/mapp/mlanconfig/config/pkt_coalescing.conf new file mode 100644 index 0000000..7203724 --- /dev/null +++ b/mapp/mlanconfig/config/pkt_coalescing.conf @@ -0,0 +1,62 @@ +# File : coalesce_cfg.conf + +######################### coalesce_cfg command configuration ################## + +coalesce_cfg={ + CmdCode=0x010a # do NOT change this line + + #Action + Action:2=1 + + #NumRules: Number of rules + NumRules:2=1 + + RuleTlvType:2=0x019a + RuleTlvLength:2={ + #Number of filter fields, up to 4 entries + NumFilterField:1=2 + #Packet type + PktType:1=1 + #Max coalescing delay + MaxDelay:2=400 + + # Dest MAC address: 00:50:43:21:53:7A + #First filter field + #Operation: 0x80 equal or 0x81 no equal + Operation:1=0x80 + #Compare bytes length, up to 4 bytes + OperandLen:1=0x04 + #Offset from incoming MAC packet + Offset:2=8 + #Operand bytes stream + Bytes:4='0x43,0x21,0x53,0x7a' + + #Second filter field + Operation:1=0x80 + OperandLen:1=0x02 + Offset:2=6 + Bytes:4='0x00,0x50,0x00,0x00' + + #Third filter field + #Operation:1=0x80 + #OperandLen:1=0x02 + #Offset:2=34 + #Bytes:4='0xc0,0xa8,0x00,0x58' + + #Fourth filter field + #Operation:1=0x80 + #OperandLen:1=0x02 + #Offset:2=34 + #Bytes:4='0xc0,0xa8,0x00,0x58' + } +} + +##### Sample coalesce_cfg command configuration to reset all the previous rules ##### + +#coalesce_cfg={ +# CmdCode=0x010a # do NOT change this line +# #NumRules: Number of rules +# NumRules:2=0 +#} + +######################### End of coalesce_cfg command configuration ################## diff --git a/mapp/mlanconfig/config/requesttpc.conf b/mapp/mlanconfig/config/requesttpc.conf new file mode 100644 index 0000000..690c30d --- /dev/null +++ b/mapp/mlanconfig/config/requesttpc.conf @@ -0,0 +1,15 @@ +# 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/mapp/mlanconfig/config/robust_btc.conf b/mapp/mlanconfig/config/robust_btc.conf new file mode 100644 index 0000000..486acd8 --- /dev/null +++ b/mapp/mlanconfig/config/robust_btc.conf @@ -0,0 +1,323 @@ +# 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_bca={ + 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=0x08 # BCA Coex mode. + # Pure HW BCA based WLAN and BT traffic arbitration. + 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 enable + + 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 + + } +} + +external_coex_uwb_config={ + CmdCode=0x00e0 + Action:2=1 # 0x0 get, 0x1 set + RSVD:2=0 + RobustCoexTlvType:2=0x0238 # TLV ID + RobustCoexTlvLength:2={ + Enabled:1=0x03 # 0x03 to configure UWB + } +} + +external_coex_config_2={ + CmdCode=0x00e0 + Action:2=1 //0x0 get, 0x1 set + RSVD:2=0 + RobustCoexTlvType:2=0x0238 //TLV ID + RobustCoexTlvLength:2={ + Enabled:1=0x02 // 0x00 disable, 0x02 enable (KF2, Fixed GPIO external COEX) + + ExtHighInputPriority:1=0x02 // Input priority: 0x00 Input Low Priority, 0x01 Input Medium Priority, 0x02 Input High Priority + ExtLowInputPriority:1=0x02 + } +} + +external_coex_uart_config={ + CmdCode=0x00e0 + Action:2=1 //0x0 get, 0x1 set + RSVD:2=0 + RobustCoexTlvType:2=0x0238 //TLV ID + RobustCoexTlvLength:2={ + Enabled:1=0x04 // 0x00 disable, 0x04: UART enable + Loopback:1=0x00 // 0x00 Loopback disable, 0x01 Loopback enable 0x02 UARTGPIO, 0x06 Get LTE Stats, 0x05 Clear LTE stats + BaudRate:4=4000000 // UART Baud Rate, 4000000: 4M baudrate, 3000000 = 3M baudrate + } +} + +external_coex_pta_config={ + CmdCode=0x00e0 + Action:2=1 // 0x0 get, 0x1 set + RSVD:2=0 + RobustCoexTlvType:2=0x0238 // TLV ID + RobustCoexTlvLength:2={ + Enabled:1=0x05 // 0x05 Select PTA interface, 0x06 Select WCI-2 interface + ExtWifiBtArb:1=0x01 // 0x00 disable, 0x01 enable + PolGrantPin:1=0x01 // 0x00 active high, 0x01 active low + EnablePriPtaInt:1=0x01 // 0x00 disable, 0x01 enable + EnableStateFromPta:1=0x02 // 0x00 state input disable + // 0x01 state info is from state pin + // 0x02 state info is sampled on priority pin. + SetPriSampTiming:2=100 // Timing to sample Priority bit + SetStateInfoSampTiming:2=100 // Timing to sample Tx/Rx info + ExtRadioTrafficPrio:1=0x01 // 0x00 disable, 0x01 enable external traffic Tx/Rx Priority. + ExtCoexHwIntWci2:1=0x00 // 0x00 disable, 0x01 enable(wci-2 interface) + } +} + +external_coex_uart_gpio_config={ + CmdCode=0x00e0 + Action:2=1 // 0x0 get, 0x1 set + RSVD:2=0 + RobustCoexTlvType:2=0x0238 // TLV ID + RobustCoexTlvLength:2={ + Enabled:1=0x07 // 0x00 disable, 0x07 enable UART + GPIO feature + ExtCoexHwIntWci2:1=0x01 // 0x00 disable, 0x01 enable(coex uart interface) + } +} +#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=10 #(12.5ms)Enter value in Units (1Unit = 1.25ms), BTTime must be less than 65535 + WlanTime:2=20 #(25ms)Enter value in Units (1Unit = 1.25ms), WlanTime must be less than 65535 + } +} + +#Single Antenna Duty Cycle +#Time for 15.4 acitvity is set as Ieee154Duration +#Time for Duty cycle duration is set as TotalDuration +single_ant_duty_cycle={ + CmdCode=0x00e0 + Action:2=1 + RSVD:2=0 + RobustCoexTlvType:2=0x0390 + RobustCoexTlvLength:2={ + Enable:2=0x02 # Enable = 0x1 generic time, 0x02 Enable Duty cycle + Ieee154Duration:2=10 # (10ms) Enter value in Units (1Unit = 1ms), time for 15.4 activity within TotalDuration + TotalDuration:2=21 # (21ms) Enter value in Units (1Unit = 1ms), total duty cycle time, must be <= 100 + } +} + +#Dual Antenna Duty Cycle +#Time for 15.4 acitvity is set as Ieee154Duration +#Time for Duty cycle duration is set as TotalDuration +#Time for 15.4 far range activity is as Ieee154FarRangeDuration. Is in-addition to TotalDuration. +dual_ant_duty_cycle={ + CmdCode=0x00e0 + Action:2=1 + RSVD:2=0 + RobustCoexTlvType:2=0x0390 + RobustCoexTlvLength:2={ + Enable:2=0x02 # Enable:0x1 generic time, 0x02 Enable Dutycycle + Ieee154Duration:2=100 # (100ms) Enter value in Units (1Unit = 1ms), should be than TotalTime + TotalDuration:2=240 # (240ms) Enter value in Units (1Unit = 1ms), TotalTime must be <= 160 + Ieee154FarRangeDuration:2=60 # (60ms) Enter value in Units (1Unit = 1ms) + } +} + +#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/mapp/mlanconfig/config/rutxpower_limit.conf b/mapp/mlanconfig/config/rutxpower_limit.conf new file mode 100644 index 0000000..d366a6e --- /dev/null +++ b/mapp/mlanconfig/config/rutxpower_limit.conf @@ -0,0 +1,674 @@ +# 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/mapp/mlanconfig/config/small_debug.conf b/mapp/mlanconfig/config/small_debug.conf new file mode 100644 index 0000000..1457426 --- /dev/null +++ b/mapp/mlanconfig/config/small_debug.conf @@ -0,0 +1,62 @@ +# 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/mapp/mlanconfig/config/smc.conf b/mapp/mlanconfig/config/smc.conf new file mode 100644 index 0000000..3c58de7 --- /dev/null +++ b/mapp/mlanconfig/config/smc.conf @@ -0,0 +1,124 @@ +# 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/mapp/mlanconfig/config/ssu.conf b/mapp/mlanconfig/config/ssu.conf new file mode 100644 index 0000000..6b6de37 --- /dev/null +++ b/mapp/mlanconfig/config/ssu.conf @@ -0,0 +1,13 @@ +# 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/mapp/mlanconfig/config/subevent.conf b/mapp/mlanconfig/config/subevent.conf new file mode 100644 index 0000000..ac7f333 --- /dev/null +++ b/mapp/mlanconfig/config/subevent.conf @@ -0,0 +1,103 @@ +# 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/mapp/mlanconfig/config/tdls.conf b/mapp/mlanconfig/config/tdls.conf new file mode 100644 index 0000000..d7369cf --- /dev/null +++ b/mapp/mlanconfig/config/tdls.conf @@ -0,0 +1,118 @@ +# File : tdls.conf + +######################### TDLS commands configuration ################## +# starts with a command name with parameters embedded inside + +tdls_setinfo={ + CapInfo=0x2421 + Rate=0x02,0x04,0x0b,0x16,0x0C,0x12,0x18,0x24,0x30,0x48,0x60,0x6c + QosInfo=0x0F # 1 byte qos capability field. Valid values 0x00 or 0x0F + # For AMPDU over direct link, this should be 0x00 + ExtendCapabilities=0x00,0x00,0x00,0x50,0x20 # Enable Peer U-APSD(Bit28), TDLS channel switch(Bit30), TDLS(Bit37) + HTCapability={ + HTCapabilityInfo=0x62 # 2 byte HT capability field. + AMPDUParam=0x3 + SupportedMCSSet=0xFF,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + HTExtCapability=0x00 + TxBfCapability=0x00 + AntennaSel=0x00 + } + HTInformation={ + PrimaryChannel=1 + Field2=0x0 + Field3=0x5 + Field4=0x0 + BasicMCSSet=0xFF,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + # 16 elements as per the structure. + } + 2040BSSCoex=0x01 # 1 byte 2040 Coex field. + VHTCapability={ + VHTCapabilityInfo=0x33C00000 # 4 byte VHT capability field. + RxMCSMap=0xFFFC + RxMaxRate=0x0000 #bit 29-31 reserved + TxMCSMap=0xFFFC + TxMaxRate=0x0000 #bit 61-63 reserved + } + VHTOper={ + ChanWidth=0x01; + ChanCF1=0x01; + ChanCF2=0x01; + BasicMCSMap=0xFF, 0XFF; #Basic MCS set map, each 2 bits stands for a Nss + } +# Uncomment the RSNInfo while testing open-secure network. + RSNInfo={ + GroupCipherSuite=0x00,0x0F,0xAC,0x07 + PairwiseCipherCount=1 + PairwiseCipherSuite=0x00,0x0F,0xAC,0x04 # CCMP + #PairwiseCipherSuite=0x00,0x0F,0xAC,0x02 # TKIP multiple Pairwise Cipher Suite if count > 1. + AKMSuiteCount=1 + AKMSuite=0x00,0x0F,0xAC,0x07 # multiple AKM Suite if count > 1. + #AKMSuite=0x00,0x0F,0xAC,0x07 # multiple AKM Suite if count > 1. + RSNCapability=0x200 # Enable PeerKey + PMKIDCount=0 + } + SupportedChannels={ + FirstChannelNo=1 + NumberofSubBandChannels=11 + # multiple instances of First Channel No, Number of SubBand Channels + } + SupportedRegulatoryClasses={ + CurrentRegulatoryClass=1 + NumofRegulatoryClasses=15 + ListOfRegulatoryClasses=1,2,3,4,12,22,23,24,25,27,28,29,30,32,33 + } + +# CountryInfo={ +# CountryString="US" # 3 byte country string +# FirstChannel=1 +# NumberofChannels=11 +# TxPower=30 +# # multiple instances of First Channel, Number of Channels, Tx Power +# } +} + +tdls_discovery={ + PeerMAC=00:50:43:27:B0:41 # MAC address of Peer +} + +tdls_setup={ + PeerMAC=00:50:43:27:B0:41 # MAC address of Peer + WaitTimems=3000 # Time in milliseconds to wait + # for setup response from peer + KeyLifetime=301 # Lifetime of security key in seconds. +} + +tdls_teardown={ + PeerMAC=00:50:43:27:B0:41 # MAC address of Peer + ReasonCode=26 # Tear down reason code +} + +tdls_channel_switch={ + PeerMAC=00:50:43:27:B0:41 # MAC address of Peer + Band=0 # Band + PrimaryChannel=6 # Primary channel no for channel switching + SecondaryChannelOffset=0 # Secondary channel offset + Periodicity=1 # Channel switch periodicity + ChannelSwitchTime=10 # Channel switch time in ms. + ChannelSwitchTimeout=14 # Channel switch timeout in ms + RegulatoryClass=12 # Target regulatory class +} + +tdls_cs_params={ + UnitTime=2 # Unit time, multiples of 10 ms + ThresholdOtherLink=10 # Threshold for other link + ThresholdDirectLink=1 # Threshold for direct link +} + + +tdls_stop_channel_switch={ + PeerMAC=00:50:43:27:B0:41 # MAC address of Peer +} + +tdls_powermode={ + PeerMAC=00:50:43:27:B0:41 # MAC address of Peer + PowerMode=1 # 0: Active, 1 : Power Save +} + + +######################### TDLS commands configuration ################## diff --git a/mapp/mlanconfig/config/trigger_frame_cfg.conf b/mapp/mlanconfig/config/trigger_frame_cfg.conf new file mode 100644 index 0000000..20713a5 --- /dev/null +++ b/mapp/mlanconfig/config/trigger_frame_cfg.conf @@ -0,0 +1,163 @@ +#This is reference file to set parameters for trigger frame configuration through +#rf test mode cmd. +#Example : echo "trigger_frame=1 0 1 2 5484 0 256 0 0 2 1 0 0 0 1 60 1 0 65535 0 511 5 0 67 0 0 0 0 90 0 0 0 0" > /proc/mwlan/adapter0/config + +############## TF_Config_80MHz ######################## + +#Enable_tx = 1 + +#standalone_hetb = 0 # standalone HE TB support is not present for Skyhawk. This filed is required for Firecrest +#FRAME_CTRL_TYPE=1 #IEEE_TYPE_CONTROL +#FRAME_CTRL_SUBTYPE=2 #TRIGGER + +#configure Duration field +# Max Duration time +#FRAME_DURATION=5484 #0x156C + +#configure commoninfo field of trigger frame +# HE_trigger_frame.TrigCommonField.TriggerType = BASIC_TRIGGER; +# HE_trigger_frame.TrigCommonField.UlLen = 256; # Max +# HE_trigger_frame.TrigCommonField.MoreTF = FALSE; +# HE_trigger_frame.TrigCommonField.CSRequired = FALSE; +# HE_trigger_frame.TrigCommonField.UlBw = TB_BW_20MHZ; +# HE_trigger_frame.TrigCommonField.LTFType = LTF_1_GI_1_6uS; +# HE_trigger_frame.TrigCommonField.LTFMode = MU_MIMO_SINGLE_STREAM; +# HE_trigger_frame.TrigCommonField.LTFSymbol = 1; +# HE_trigger_frame.TrigCommonField.UlSTBC = FALSE; +# HE_trigger_frame.TrigCommonField.LdpcESS = FALSE; +# HE_trigger_frame.TrigCommonField.ApTxPwr = 10 +# HE_trigger_frame.TrigCommonField.PreFecPadFct = 0; +# HE_trigger_frame.TrigCommonField.PeDisambig = 1; +# HE_trigger_frame.TrigCommonField.SpatialReuse = 0; +# HE_trigger_frame.TrigCommonField.Doppler = FALSE; +# HE_trigger_frame.TrigCommonField.HeSig2 = 0x1FF; # reserved +#TrigCommonField=0;256;0;0;2;1;0;0;0;1;60;1;0;65535;0;511 + +#configure userinfo field of trigger frame +# HE_trigger_frame.TrigUserInfoField.AID12 = (AID & 0xFFF); +# HE_trigger_frame.TrigUserInfoField.RUAllocReg = 0; +# HE_trigger_frame.TrigUserInfoField.RUAlloc = 0x35; # 53 (106 tones) +# HE_trigger_frame.TrigUserInfoField.UlCodingType = CODING_TYPE_LDPC; +# HE_trigger_frame.TrigUserInfoField.UlMCS = 0xB; +# HE_trigger_frame.TrigUserInfoField.UlDCM = FALSE; +# HE_trigger_frame.TrigUserInfoField.SSAlloc = 0x8; +# HE_trigger_frame.TrigUserInfoField.UlTargetRSSI = 40; +#TrigUserInfoField=5;0;67;0;0;0;0;90 + +#configure trigger dependent user info field +# HE_trigger_frame.BasicTrigUserInfo.MPDU_MU_SF = MPDU_SPACING_MULT_1; +# HE_trigger_frame.BasicTrigUserInfo.TID_AL = 1; +# HE_trigger_frame.BasicTrigUserInfo.AC_PL = FALSE; +# HE_trigger_frame.BasicTrigUserInfo.Pref_AC = TB_AC_VO; +#BasicTrigUserInfo=0;0;0;0 + +#RF Test Mode Command: +echo "trigger_frame=1 0 1 2 5484 0 256 0 0 2 1 0 0 0 1 60 1 0 65535 0 511 5 0 67 0 0 0 0 90 0 0 0 0" > /proc/mwlan/adapter0/config + +############## Trigger_frame_40Mhz_RU65 ######################## + +#Enable_tx = 1 + +#standalone_hetb = 0 # standalone HE TB support is not present for Skyhawk. This filed is required for Firecrest +#FRAME_CTRL_TYPE=1 #IEEE_TYPE_CONTROL +#FRAME_CTRL_SUBTYPE=2 #TRIGGER + +#configure Duration field +# Max Duration time +#FRAME_DURATION=5484 #0x156C + +#configure commoninfo field of trigger frame +# HE_trigger_frame.TrigCommonField.TriggerType = BASIC_TRIGGER; +# HE_trigger_frame.TrigCommonField.UlLen = 256; # Max +# HE_trigger_frame.TrigCommonField.MoreTF = FALSE; +# HE_trigger_frame.TrigCommonField.CSRequired = FALSE; +# HE_trigger_frame.TrigCommonField.UlBw = TB_BW_20MHZ; +# HE_trigger_frame.TrigCommonField.LTFType = LTF_1_GI_1_6uS; +# HE_trigger_frame.TrigCommonField.LTFMode = MU_MIMO_SINGLE_STREAM; +# HE_trigger_frame.TrigCommonField.LTFSymbol = 1; +# HE_trigger_frame.TrigCommonField.UlSTBC = FALSE; +# HE_trigger_frame.TrigCommonField.LdpcESS = FALSE; +# HE_trigger_frame.TrigCommonField.ApTxPwr = 10 +# HE_trigger_frame.TrigCommonField.PreFecPadFct = 0; +# HE_trigger_frame.TrigCommonField.PeDisambig = 1; +# HE_trigger_frame.TrigCommonField.SpatialReuse = 0; +# HE_trigger_frame.TrigCommonField.Doppler = FALSE; +# HE_trigger_frame.TrigCommonField.HeSig2 = 0x1FF; # reserved +#TrigCommonField=0;256;0;1;0;1;0;0;0;1;60;1;0;65535;0;511 + +#configure userinfo field of trigger frame +# HE_trigger_frame.TrigUserInfoField.AID12 = (AID & 0xFFF); +# HE_trigger_frame.TrigUserInfoField.RUAllocReg = 0; +# HE_trigger_frame.TrigUserInfoField.RUAlloc = 0x35; # 53 (106 tones) +# HE_trigger_frame.TrigUserInfoField.UlCodingType = CODING_TYPE_LDPC; +# HE_trigger_frame.TrigUserInfoField.UlMCS = 0xB; +# HE_trigger_frame.TrigUserInfoField.UlDCM = FALSE; +# HE_trigger_frame.TrigUserInfoField.SSAlloc = 0x8; +# HE_trigger_frame.TrigUserInfoField.UlTargetRSSI = 40; +#TrigUserInfoField=5;0;65;0;0;0;0;90 + +#configure trigger dependent user info field +# HE_trigger_frame.BasicTrigUserInfo.MPDU_MU_SF = MPDU_SPACING_MULT_1; +# HE_trigger_frame.BasicTrigUserInfo.TID_AL = 1; +# HE_trigger_frame.BasicTrigUserInfo.AC_PL = FALSE; +# HE_trigger_frame.BasicTrigUserInfo.Pref_AC = TB_AC_VO; +#BasicTrigUserInfo=0;0;0;0 + +#RF Test Mode Command: +echo "trigger_frame=1 0 1 2 5484 0 256 0 1 0 1 0 0 0 1 60 1 0 65535 0 511 5 0 65 0 0 0 0 90 0 0 0 0" > /proc/mwlan/adapter0/config + + +############## Trigger_frame_20Mhz_RU61 ######################## + +#Enable_tx = 1 + +#standalone_hetb = 0 # standalone HE TB support is not present for Skyhawk. This filed is required for Firecrest +#FRAME_CTRL_TYPE=1 #IEEE_TYPE_CONTROL +#FRAME_CTRL_SUBTYPE=2 #TRIGGER + +#configure Duration field +# Max Duration time +#FRAME_DURATION=5484 #0x156C + +#configure commoninfo field of trigger frame +# HE_trigger_frame.TrigCommonField.TriggerType = BASIC_TRIGGER; +# HE_trigger_frame.TrigCommonField.UlLen = 256; # Max +# HE_trigger_frame.TrigCommonField.MoreTF = FALSE; +# HE_trigger_frame.TrigCommonField.CSRequired = FALSE; +# HE_trigger_frame.TrigCommonField.UlBw = TB_BW_20MHZ; +# HE_trigger_frame.TrigCommonField.LTFType = LTF_1_GI_1_6uS; +# HE_trigger_frame.TrigCommonField.LTFMode = MU_MIMO_SINGLE_STREAM; +# HE_trigger_frame.TrigCommonField.LTFSymbol = 1; +# HE_trigger_frame.TrigCommonField.UlSTBC = FALSE; +# HE_trigger_frame.TrigCommonField.LdpcESS = FALSE; +# HE_trigger_frame.TrigCommonField.ApTxPwr = 10 +# HE_trigger_frame.TrigCommonField.PreFecPadFct = 0; +# HE_trigger_frame.TrigCommonField.PeDisambig = 1; +# HE_trigger_frame.TrigCommonField.SpatialReuse = 0; +# HE_trigger_frame.TrigCommonField.Doppler = FALSE; +# HE_trigger_frame.TrigCommonField.HeSig2 = 0x1FF; # reserved + +#TrigCommonField=0;256;0;0;0;1;0;0;0;1;60;1;0;65535;0;511 + +#configure userinfo field of trigger frame +# HE_trigger_frame.TrigUserInfoField.AID12 = (AID & 0xFFF); +# HE_trigger_frame.TrigUserInfoField.RUAllocReg = 0; +# HE_trigger_frame.TrigUserInfoField.RUAlloc = 0x35; # 53 (106 tones) +# HE_trigger_frame.TrigUserInfoField.UlCodingType = CODING_TYPE_LDPC; +# HE_trigger_frame.TrigUserInfoField.UlMCS = 0xB; +# HE_trigger_frame.TrigUserInfoField.UlDCM = FALSE; +# HE_trigger_frame.TrigUserInfoField.SSAlloc = 0x8; +# HE_trigger_frame.TrigUserInfoField.UlTargetRSSI = 40; + +#TrigUserInfoField=5;0;61;0;0;0;0;90 + +#configure trigger dependent user info field +# HE_trigger_frame.BasicTrigUserInfo.MPDU_MU_SF = MPDU_SPACING_MULT_1; +# HE_trigger_frame.BasicTrigUserInfo.TID_AL = 1; +# HE_trigger_frame.BasicTrigUserInfo.AC_PL = FALSE; +# HE_trigger_frame.BasicTrigUserInfo.Pref_AC = TB_AC_VO; +#BasicTrigUserInfo=0;0;0;0 + +#RF Test Mode Command: +echo "trigger_frame=1 0 1 2 5484 0 256 0 0 0 1 0 0 0 1 60 1 0 65535 0 511 5 0 61 0 0 0 0 90 0 0 0 0" > /proc/mwlan/adapter0/config + diff --git a/mapp/mlanconfig/config/tspecs.conf b/mapp/mlanconfig/config/tspecs.conf new file mode 100644 index 0000000..86c1ac6 --- /dev/null +++ b/mapp/mlanconfig/config/tspecs.conf @@ -0,0 +1,100 @@ +# 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/mapp/mlanconfig/config/twt.conf b/mapp/mlanconfig/config/twt.conf new file mode 100644 index 0000000..dab9d2a --- /dev/null +++ b/mapp/mlanconfig/config/twt.conf @@ -0,0 +1,48 @@ +# File : twt.conf + +######################### TWT commands configuration ################## +# starts with a command name with parameters embedded inside + +# The TWT setup command sets or gets the TWT configuration. +twt_setup={ + Implicit=1 # Indicates that TWT session is implicit which TWT negotiation decides the TWT Wake Interval. + # 0: Explicit + # 1: Implicit + Announced=0 # Indicates that TWT requesting STA may be at doze state at beginning of TWT SP. + # 0: Unannounced + # 1: Announced TWT + TriggerEnabled=0 # Indicates that at least one trigger frame is transmitted in TWT SP. + # 0: Non-Trigger enabled + # 1: Trigger enabled TWT + TWTInformationDisabled=1 # Indicates if TWT information frames are acceptable or not during the TWT session. + # 0: TWT information enabled + # 1: TWT information disabled + NegotiationType=0 # Indicates if TWT session is Individual or Broadcast. + # 0: Future Individual TWT SP start time + # 1: Next Wake TBTT time + # 3: B-TWT Support + TWTWakeupDuration=64 # Indicates the time after which the TWT requesting STA can transition to doze state. + # Range: [0-sizeof(UINT8)] + FlowIdentifier=0 # As per specification, upto 8 implicit TWT sessions can exist in parallel based on different + # flow identifiers. For now, we can mark it as 0. + # Range: [0-7] + HardConstraint=1 # Identifies if firmware can internally change any of the TWT params in case AP sends + # TWT_REJECT to TWT Setup. + # 0: FW can tweak the TWT setup parameters if it is rejected by AP. + # 1: Firmware should not tweak any parameters. + TWTExponent=10 # Range: [0-63] + TWTMantissa=512 # Range: [0-sizeof(UINT16)] + # TWTExponent and TWTMantissa determine the time interval between successive TWT SP for + # individual TWT according to the formula Mantissa * (2^Exponent) + TWTRequestType=0 # Range: [0-7] + # 0: REQUEST_TWT + # 1: SUGGEST_TWT +} + +# The TWT teardown command is used to terminate the TWT session. +twt_teardown={ + FlowIdentifier=0 # TWT Flow Identifier. Range: [0-7] + NegotiationType=0 # 0: Future Individual TWT SP start time + # 1: Next Wake TBTT time + TearDownAllTWT=0 # 1: To teardown all TWT, 0 otherwise +} diff --git a/mapp/mlanconfig/config/twt_Ap.conf b/mapp/mlanconfig/config/twt_Ap.conf new file mode 100644 index 0000000..59d9070 --- /dev/null +++ b/mapp/mlanconfig/config/twt_Ap.conf @@ -0,0 +1,25 @@ +bcast_twt_get={ + CmdCode=0x008b # do NOT change this line + Action:2=0 # 0 - GET + SUBID:2=0x125 # Broadcast TWT AP config + Value:1=255 # Nominal Wake To be given in integer between 64-255 + Value:1=4 # Max STA Support, Do not change this value. + Value:2=796 # TWT Mantissa + Value:2=448 # TWT Offset + Value:1=9 # TWT Exponent + Value:1=0 #SP Gap +} + +bcast_twt_set={ + CmdCode=0x008b # do NOT change this line + Action:2=1 # 1 - SET + SUBID:2=0x125 # Broadcast TWT AP config + Value:1=64 # Nominal Wake To be given in integer between 64-255 + Value:1=4 # Max STA Support, Do not change this value. + Value:2=99 # TWT Mantissa + Value:2=624 # TWT Offset + Value:1=10 # TWT Exponent + Value:1=5 # SP Gap +} + +# Service Period and Gap should be such that it can accomodate All STA within 1 Beacon Period i.e. TWT Period in this case diff --git a/mapp/mlanconfig/config/tx_ctrl.conf b/mapp/mlanconfig/config/tx_ctrl.conf new file mode 100644 index 0000000..013065b --- /dev/null +++ b/mapp/mlanconfig/config/tx_ctrl.conf @@ -0,0 +1,58 @@ +#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/mapp/mlanconfig/config/txpwrlimit_cfg.conf b/mapp/mlanconfig/config/txpwrlimit_cfg.conf new file mode 100644 index 0000000..25f3fb1 --- /dev/null +++ b/mapp/mlanconfig/config/txpwrlimit_cfg.conf @@ -0,0 +1,1388 @@ +# File : txpwrlimit_cfg.conf +## Get CFG data for Tx power limitation +txpwrlimit_2g_cfg_get={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x00 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) +} + + +txpwrlimit_5g_cfg_get_sub0={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x10 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) +} + + +txpwrlimit_5g_cfg_get_sub1={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x11 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) +} + + +txpwrlimit_5g_cfg_get_sub2={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x12 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) +} + + +txpwrlimit_5g_cfg_get_sub3={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x13 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) +} + +txpwrlimit_6g_cfg_get_sub0={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x20 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) + # 0x20 6G subband0 (6G: channel 1,5,9,13,17,21,25,29) + # 0x21 6G subband1 (6G: channel 33,37,41,45,49,53,57,61) + # 0x22 6G subband2 (6G: channel 65,69,73,77,81,85,89,93) + # 0x23 6G subband3 (6G: channel 97,101,105,109,113,117,121,125) + # 0x24 6G subband4 (6G: channel 129,133,137,141,145,149,153,157) + # 0x25 6G subband5 (6G: channel 161,165,169,173,177,181,185,189) + # 0x26 6G subband6 (6G: channel 193,197,201,205,209,213,217,221) + # 0x27 6G subband7 (6G: channel 225,229,233) +} + +txpwrlimit_6g_cfg_get_sub1={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x21 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) + # 0x20 6G subband0 (6G: channel 1,5,9,13,17,21,25,29) + # 0x21 6G subband1 (6G: channel 33,37,41,45,49,53,57,61) + # 0x22 6G subband2 (6G: channel 65,69,73,77,81,85,89,93) + # 0x23 6G subband3 (6G: channel 97,101,105,109,113,117,121,125) + # 0x24 6G subband4 (6G: channel 129,133,137,141,145,149,153,157) + # 0x25 6G subband5 (6G: channel 161,165,169,173,177,181,185,189) + # 0x26 6G subband6 (6G: channel 193,197,201,205,209,213,217,221) + # 0x27 6G subband7 (6G: channel 225,229,233) +} + +txpwrlimit_6g_cfg_get_sub2={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x22 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) + # 0x20 6G subband0 (6G: channel 1,5,9,13,17,21,25,29) + # 0x21 6G subband1 (6G: channel 33,37,41,45,49,53,57,61) + # 0x22 6G subband2 (6G: channel 65,69,73,77,81,85,89,93) + # 0x23 6G subband3 (6G: channel 97,101,105,109,113,117,121,125) + # 0x24 6G subband4 (6G: channel 129,133,137,141,145,149,153,157) + # 0x25 6G subband5 (6G: channel 161,165,169,173,177,181,185,189) + # 0x26 6G subband6 (6G: channel 193,197,201,205,209,213,217,221) + # 0x27 6G subband7 (6G: channel 225,229,233) +} + +txpwrlimit_6g_cfg_get_sub3={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x23 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) + # 0x20 6G subband0 (6G: channel 1,5,9,13,17,21,25,29) + # 0x21 6G subband1 (6G: channel 33,37,41,45,49,53,57,61) + # 0x22 6G subband2 (6G: channel 65,69,73,77,81,85,89,93) + # 0x23 6G subband3 (6G: channel 97,101,105,109,113,117,121,125) + # 0x24 6G subband4 (6G: channel 129,133,137,141,145,149,153,157) + # 0x25 6G subband5 (6G: channel 161,165,169,173,177,181,185,189) + # 0x26 6G subband6 (6G: channel 193,197,201,205,209,213,217,221) + # 0x27 6G subband7 (6G: channel 225,229,233) +} + +txpwrlimit_6g_cfg_get_sub4={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x24 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) + # 0x20 6G subband0 (6G: channel 1,5,9,13,17,21,25,29) + # 0x21 6G subband1 (6G: channel 33,37,41,45,49,53,57,61) + # 0x22 6G subband2 (6G: channel 65,69,73,77,81,85,89,93) + # 0x23 6G subband3 (6G: channel 97,101,105,109,113,117,121,125) + # 0x24 6G subband4 (6G: channel 129,133,137,141,145,149,153,157) + # 0x25 6G subband5 (6G: channel 161,165,169,173,177,181,185,189) + # 0x26 6G subband6 (6G: channel 193,197,201,205,209,213,217,221) + # 0x27 6G subband7 (6G: channel 225,229,233) +} + +txpwrlimit_6g_cfg_get_sub5={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x25 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) + # 0x20 6G subband0 (6G: channel 1,5,9,13,17,21,25,29) + # 0x21 6G subband1 (6G: channel 33,37,41,45,49,53,57,61) + # 0x22 6G subband2 (6G: channel 65,69,73,77,81,85,89,93) + # 0x23 6G subband3 (6G: channel 97,101,105,109,113,117,121,125) + # 0x24 6G subband4 (6G: channel 129,133,137,141,145,149,153,157) + # 0x25 6G subband5 (6G: channel 161,165,169,173,177,181,185,189) + # 0x26 6G subband6 (6G: channel 193,197,201,205,209,213,217,221) + # 0x27 6G subband7 (6G: channel 225,229,233) +} + +txpwrlimit_6g_cfg_get_sub6={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x26 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) + # 0x20 6G subband0 (6G: channel 1,5,9,13,17,21,25,29) + # 0x21 6G subband1 (6G: channel 33,37,41,45,49,53,57,61) + # 0x22 6G subband2 (6G: channel 65,69,73,77,81,85,89,93) + # 0x23 6G subband3 (6G: channel 97,101,105,109,113,117,121,125) + # 0x24 6G subband4 (6G: channel 129,133,137,141,145,149,153,157) + # 0x25 6G subband5 (6G: channel 161,165,169,173,177,181,185,189) + # 0x26 6G subband6 (6G: channel 193,197,201,205,209,213,217,221) + # 0x27 6G subband7 (6G: channel 225,229,233) +} + +txpwrlimit_6g_cfg_get_sub7={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x27 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) + # 0x20 6G subband0 (6G: channel 1,5,9,13,17,21,25,29) + # 0x21 6G subband1 (6G: channel 33,37,41,45,49,53,57,61) + # 0x22 6G subband2 (6G: channel 65,69,73,77,81,85,89,93) + # 0x23 6G subband3 (6G: channel 97,101,105,109,113,117,121,125) + # 0x24 6G subband4 (6G: channel 129,133,137,141,145,149,153,157) + # 0x25 6G subband5 (6G: channel 161,165,169,173,177,181,185,189) + # 0x26 6G subband6 (6G: channel 193,197,201,205,209,213,217,221) + # 0x27 6G subband7 (6G: channel 225,229,233) +} + +## Set CFG data for Tx power limitation +## +## TLVStartFreq: Starting Frequency of the band for this channel +## 2407, 2414 or 2400 for 2.4 GHz +## 5000 +## 4000 +## 5955 +## TLVChanWidth: Channel Width +## 20 +## TLVChanNum : Channel Number +## TLVPwr[] : ModulationGroup +## 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 (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) +## Power Limit in dBm +## +## Note: For KF, add VHT 20/40/80 1SS/2SS mod group. + +## 2G subband0 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 + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=1 + TLVPwr:72='0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,10,10,11,10,12,10,13,10,14,10,15,10,16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,10,29,10,30,10,31,0,32,10,33,10,34,10,35,0' + } + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=2 + TLVPwr:72='0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,10,10,11,10,12,10,13,10,14,10,15,10,16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,10,29,10,30,10,31,0,32,10,33,10,34,10,35,0' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=3 + TLVPwr:72='0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,10,10,11,10,12,10,13,10,14,10,15,10,16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,10,29,10,30,10,31,0,32,10,33,10,34,10,35,0' + } + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=4 + TLVPwr:72='0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,10,10,11,10,12,10,13,10,14,10,15,10,16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,10,29,10,30,10,31,0,32,10,33,10,34,10,35,0' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=5 + TLVPwr:72='0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,10,10,11,10,12,10,13,10,14,10,15,10,16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,10,29,10,30,10,31,0,32,10,33,10,34,10,35,0' + } + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=6 + TLVPwr:72='0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,10,10,11,10,12,10,13,10,14,10,15,10,16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,10,29,10,30,10,31,0,32,10,33,10,34,10,35,0' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=7 + TLVPwr:72='0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,10,10,11,10,12,10,13,10,14,10,15,10,16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,10,29,10,30,10,31,0,32,10,33,10,34,10,35,0' + } + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=8 + TLVPwr:72='0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,10,10,11,10,12,10,13,10,14,10,15,10,16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,10,29,10,30,10,31,0,32,10,33,10,34,10,35,0' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=9 + TLVPwr:72='0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,10,10,11,10,12,10,13,10,14,10,15,10,16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,10,29,10,30,10,31,0,32,10,33,10,34,10,35,0' + } + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=10 + TLVPwr:72='0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,10,10,11,10,12,10,13,10,14,10,15,10,16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,10,29,10,30,10,31,0,32,10,33,10,34,10,35,0' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=11 + TLVPwr:72='0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,10,10,11,10,12,10,13,10,14,10,15,10,16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,10,29,10,30,10,31,0,32,10,33,10,34,10,35,0' + } + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=12 + TLVPwr:72='0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,10,10,11,10,12,10,13,10,14,10,15,10,16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,10,29,10,30,10,31,0,32,10,33,10,34,10,35,0' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=13 + TLVPwr:72='0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,10,10,11,10,12,10,13,10,14,10,15,10,16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,10,29,10,30,10,31,0,32,10,33,10,34,10,35,0' + } + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + TLVChanWidth:1=20 + TLVChanNum:1=14 + TLVPwr:72='0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,10,10,11,10,12,10,13,10,14,10,15,10,16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,10,29,10,30,10,31,0,32,10,33,10,34,10,35,0' + } +} + + +## 5G subband1 Tx power limit CFG +txpwrlimit_5g_cfg_set_sub0={ + 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=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' + } + + 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' + } + + 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' + } + + 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' + } + + 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' + } + + 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' + } + + 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' + } + + 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' + } +} + +## 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' + } + + + 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' + } + + + 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' + } + + + 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' + } + + + 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' + } + + + 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' + } + + + 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' + } + + + 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' + } + + + 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' + } + + 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' + } + + 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' + } + + + 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' + } + +} + + +## 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' + } + + + 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' + } + + + 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' + } + + + 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' + } + + + 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' + } + +} + + +## 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 + 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' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + 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' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + 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' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + 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' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + 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' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + 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' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + 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' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + 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' + } + + + 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' + } + + + 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' + } + + + 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' + } + + + 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' + } + + + 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' + } + + + 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' + } + } + +## 6G subband0 Tx power limit CFG +txpwrlimit_6g_cfg_set_sub0={ + 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=5950 + TLVChanWidth:1=20 + TLVChanNum:1=1 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=5 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=9 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=13 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=17 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=21 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=25 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=29 + 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,8' + } +} + +## 6G subband1 Tx power limit CFG +txpwrlimit_6g_cfg_set_sub1={ + 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=5950 + TLVChanWidth:1=20 + TLVChanNum:1=33 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=37 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=41 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=45 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=49 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=53 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=57 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=61 + 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,8' + } +} + +## 6G subband2 Tx power limit CFG +txpwrlimit_6g_cfg_set_sub2={ + 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=5950 + TLVChanWidth:1=20 + TLVChanNum:1=65 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=69 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=73 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=77 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=81 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=85 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=89 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=93 + 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,8' + } +} + +## 6G subband3 Tx power limit CFG +txpwrlimit_6g_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=5950 + TLVChanWidth:1=20 + TLVChanNum:1=97 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=101 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=105 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=109 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=113 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=117 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=121 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=125 + 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,8' + } +} + +## 6G subband4 Tx power limit CFG +txpwrlimit_6g_cfg_set_sub4={ + 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=5950 + TLVChanWidth:1=20 + TLVChanNum:1=129 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=133 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=137 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=141 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=145 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=149 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + 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,8' + } +} + +## 6G subband5 Tx power limit CFG +txpwrlimit_6g_cfg_set_sub5={ + 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=5950 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=169 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=173 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=177 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=181 + 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,8' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + 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,8' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + 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,8' + } +} + +## 6G subband6 Tx power limit CFG +txpwrlimit_6g_cfg_set_sub6={ + 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=5950 + TLVChanWidth:1=20 + TLVChanNum:1=193 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=197 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=201 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=205 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=209 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=213 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=217 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=221 + 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,8' + } +} + +## 6G subband7 Tx power limit CFG +txpwrlimit_6g_cfg_set_sub7={ + 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=5950 + TLVChanWidth:1=20 + TLVChanNum:1=225 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=229 + 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,8' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5950 + TLVChanWidth:1=20 + TLVChanNum:1=233 + 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,8' + } +} + + diff --git a/mapp/mlanconfig/config/txpwrlimit_cfg_8997.conf b/mapp/mlanconfig/config/txpwrlimit_cfg_8997.conf new file mode 100644 index 0000000..0f3b71a --- /dev/null +++ b/mapp/mlanconfig/config/txpwrlimit_cfg_8997.conf @@ -0,0 +1,621 @@ +# File : txpwrlimit_cfg.conf +## Get CFG data for Tx power limitation +txpwrlimit_2g_cfg_get={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x00 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) +} + + +txpwrlimit_5g_cfg_get_sub0={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x10 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) +} + + +txpwrlimit_5g_cfg_get_sub1={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x11 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) +} + + +txpwrlimit_5g_cfg_get_sub2={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x12 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) +} + + +txpwrlimit_5g_cfg_get_sub3={ + CmdCode=0x00fb # do NOT change this line + Action:2=0 # 0 - GET + SubBand:2=0x13 # 0x00 2G subband (2.4G: channel 1-14) + # 0x10 5G subband0 (5G: channel 36,40,44,48, + # 52,56,60,64) + # 0x11 5G subband1 (5G: channel 100,104,108,112, + # 116,120,124,128, + # 132,136,140,144) + # 0x12 5G subband2 (5G: channel 149,153,157,161,165,172) + # 0x13 5G subband3 (5G: channel 183,184,185,187,188, + # 189, 192,196; + # 5G: channel 7,8,11,12,16,34) +} + +## Set CFG data for Tx power limitation +## +## TLVStartFreq: Starting Frequency of the band for this channel +## 2407, 2414 or 2400 for 2.4 GHz +## 5000 +## 4000 +## TLVChanWidth: Channel Width +## 20 +## TLVChanNum : Channel Number +## TLVPwr[] : ModulationGroup +## 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 (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) +## Power Limit in dBm + +## 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 +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 + + 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' + } + 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' + } + + 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' + } + 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' + } + + 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' + } + 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' + } + + 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' + } + 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' + } + + 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' + } + 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' + } + + 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' + } + 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' + } + + 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' + } + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=2407 + 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' + } +} + +## 5G subband1 Tx power limit CFG +txpwrlimit_5g_cfg_set_sub0={ + 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=36 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=40 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=44 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=48 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=52 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=56 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=60 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=64 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } +} + +## 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:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=104 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=108 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=112 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=116 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=120 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=124 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=128 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=132 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=136 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=140 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=144 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + +} + + +## 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:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=153 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=157 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=161 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=165 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } +} + + +## 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 + TLVChanWidth:1=20 + TLVChanNum:1=183 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + TLVChanWidth:1=20 + TLVChanNum:1=184 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + TLVChanWidth:1=20 + TLVChanNum:1=185 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + TLVChanWidth:1=20 + TLVChanNum:1=187 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + TLVChanWidth:1=20 + TLVChanNum:1=188 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + TLVChanWidth:1=20 + TLVChanNum:1=189 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + TLVChanWidth:1=20 + TLVChanNum:1=192 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=4000 + TLVChanWidth:1=20 + TLVChanNum:1=196 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=7 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=8 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=11 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=12 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=16 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } + + + ChanTRPC.TlvType:2=0x0189 + ChanTRPC.TlvLength:2={ + TLVStartFreq:2=5000 + TLVChanWidth:1=20 + TLVChanNum:1=34 + TLVPwr:56='0,17,1,15,2,15,3,11,4,15,5,15,6,11,7,15,8,15,9,11,10,15,11,15,12,14,13,15,14,15,15,14,16,11,17,11,18,13,19,13,20,10,21,10,22,11,23,11,24,13,25,13,26,12,27,10' + } +} diff --git a/mapp/mlanconfig/config/txrate_cfg.conf b/mapp/mlanconfig/config/txrate_cfg.conf new file mode 100644 index 0000000..a765718 --- /dev/null +++ b/mapp/mlanconfig/config/txrate_cfg.conf @@ -0,0 +1,240 @@ +# 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 + } +} + + +txrate_cfg_set_bgn_ac_ax={ + 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 + + VHT.RateScopeDword0:4=0xffffffff + VHT.RateScopeDword1:4=0x00000000 + VHT.RateScopeDword2:4=0x00000000 + VHT.RateScopeDword3:4=0x00000000 + + HE.RateScopeDword0:4=0xffffffff + HE.RateScopeDword1:4=0x00000000 + HE.RateScopeDword2:4=0x00000000 + HE.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/mapp/mlanconfig/config/wifi_mod_para.conf b/mapp/mlanconfig/config/wifi_mod_para.conf new file mode 100644 index 0000000..5e978b8 --- /dev/null +++ b/mapp/mlanconfig/config/wifi_mod_para.conf @@ -0,0 +1,204 @@ +# Not matter how many spaces or tabs are inserted in a line, +# components and ending format must be exactly same as given +# example: +# +# [_] = { +# key=value +# } +# +# card_type : 8XXX (mandatory) +# block_id : configuration block id (optional ) +# key : module parameter name +# value : value for module parameter +# for string value, no need to add "" +# +# card_type supported: 8887/8897/8997/8977/8987/9098 +# block_id: support same chipset with +# different module parameter. +# For example to support mutiple SD8997 cards, usr can +# specify the configuration block id number [0 - 9], if not +# specified, it is taken as 0 by default. +# +# debug related module parameters could not be set via module +# configure file, ex. drvdbg could not be set in this file +# +# line started with "#" will be ignored +# refer to the USB8997_1 for parameters that could be set in +# this configuration file, and set the corresponding value +# according to your real needs + +SD8997 = { + cfg80211_wext=0xf + wfd_name=p2p + max_vir_bss=1 + cal_data_cfg=nxp/WlanCalData_ext_8997_QFN_TB.conf + drv_mode=7 +} + +#SD8997_1 = { +# cfg80211_wext=0xf +# wfd_name=wfd0 +# max_vir_bss=1 +# cal_data_cfg=nxp/WlanCalData_ext_8997_QFN_TB.conf +# drv_mode=5 +#} + +#SD8887 = { +# cfg80211_wext=0xf +# wfd_name=p2p +# max_vir_bss=1 +# cal_data_cfg=nxp/WlanCalData_ext_8997_QFN_TB.conf +# drv_mode=7 +#} + +#SD8897 = { +# cfg80211_wext=0xf +# wfd_name=p2p +# max_vir_bss=1 +# cal_data_cfg=nxp/WlanCalData_ext_8997_QFN_TB.conf +# drv_mode=7 +#} + +#SD8977 = { +# cfg80211_wext=0xf +# wfd_name=p2p +# max_vir_bss=1 +# cal_data_cfg=nxp/WlanCalData_ext_8997_QFN_TB.conf +# drv_mode=7 +#} + +#SDIW416 = { +# cfg80211_wext=0xf +# wfd_name=p2p +# hw_name=SDIW416 +# max_vir_bss=1 +# cal_data_cfg=nxp/WlanCalData_ext_8978_QFN_TB.conf +# drv_mode=7 +#} + +#SD8987 = { +# cfg80211_wext=0xf +# wfd_name=p2p +# max_vir_bss=1 +# cal_data_cfg=nxp/WlanCalData_ext_8997_QFN_TB.conf +# drv_mode=7 +#} + +#SDIW612 = { +# cfg80211_wext=0xf +# wfd_name=p2p +# hw_name=SDIW612 +# max_vir_bss=1 +# drv_mode=7 +#} + +USB8997 = { + cfg80211_wext=0xf + wfd_name=p2p + max_vir_bss=1 + cal_data_cfg=nxp/WlanCalData_ext_8997_QFN_TB.conf + drv_mode=7 +} + +#USBIW620 = { +# cfg80211_wext=0xf +# wfd_name=p2p +# hw_name=USBIW620 +# max_vir_bss=1 +# drv_mode=7 +#} + + +PCIE8997 = { + cfg80211_wext=0xf + wfd_name=p2p + max_vir_bss=1 + cal_data_cfg=nxp/WlanCalData_ext_8997_QFN_TB.conf + drv_mode=7 +} + +PCIE9098_0 = { + cfg80211_wext=0xf + wfd_name=p2p + max_vir_bss=1 + cal_data_cfg=none + drv_mode=7 + mac_addr=00:50:43:20:12:34 +} + +PCIE9098_1 = { + cfg80211_wext=0xf + wfd_name=p2p + max_vir_bss=1 + cal_data_cfg=none + drv_mode=7 + mac_addr=00:50:43:20:52:56 +} + +#USB8997 = { +# hw_test=0 +# fw_name="nxp/usbusb8997_combo_v4.bin" +# req_fw_nowait=1 +# fw_reload=3 +# fw_serial=1 +# mac_addr=00:50:43:22:1e:3d +# mfg_mode=0 +# drv_mode=0x5 +# max_sta_bss=1 +# sta_name=wlan +# max_uap_bss=1 +# uap_name=uap +# wfd_name=p2p +# max_vir_bss=1 +# max_mpl_bss=1 +# nan_name=nan +# max_nan_bss=1 +# max_11p_bss=1 +# auto_ds=0 +# ps_mode=1 +# max_tx_buf=4096 +# intmode=0 +# gpiopin=0 +# pm_keep_power=0 +# shutdown_hs=1 +# cfg_11d=1 +# start_11ai_scan=0 +# oob_mode=0 +# sdio_pd=1 +# cal_data_cfg=nxp/WlanCalData_ext_8997_QFN_TB.conf +# txpwrtlimit_cfg=nxp/txpwr_limit.conf +# cntry_txpwrt=0 +# init_hostcmd_cfg=nxp/init_hostcmd_cfg.conf +# minicard_pwrup=0 +# cfg80211_wext=0xf +# skip_fwdnld=0 +# wq_sched_prio=0 +# wq_sched_policy=0 +# rx_work=1 +# aggrctrl=1 +# usb_aggr=1 +# pcie_int_mode=1 +# low_power_mode_enable=1 +# wakelock_timeout=10 +# dev_cap_mask=0xffffffff +# sdio_rx_aggr=1 +# pmic=1 +# antcfg=0 +# uap_oper_ctrl=0 +# hs_wake_interval=400 +# indication_gpio=0xff +# disconnect_on_suspend=0 +# hs_mimo_switch=1 +# indrstcfg=0xffffffff +# fixed_beacon_buffer=0 +# GoAgeoutTime=0 +# gtk_rekey_offload=1 +# multi_dtim=0 +# inact_tmo=0 +# usb_fw_option=1 +# napi=1 +# dfs_offload=1 +# cfg80211_drcs=1 +# drcs_chantime_mode=0 +# reg_alpha2=US +#} diff --git a/mapp/mlanconfig/mlanconfig.c b/mapp/mlanconfig/mlanconfig.c new file mode 100644 index 0000000..f216ae5 --- /dev/null +++ b/mapp/mlanconfig/mlanconfig.c @@ -0,0 +1,4877 @@ +/** @file mlanconfig.c + * + * @brief Program to configure addition parameters into the mlandriver + * + * + * Copyright 2008-2021 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 + +#define MAX_MEF_NUM_ENTRIES 100 +#define MAX_TLV_ARGS 30 + +/******************************************************** + Local Variables +********************************************************/ + +/** Private ioctl commands */ +enum COMMANDS { + CMD_HOSTCMD, + CMD_MEFCFG, + CMD_ARPFILTER, + CMD_CFG_DATA, + 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 + CMD_TDLS_CONF, + CMD_TDLS_INFO, + CMD_TDLS_DISCOVERY, + CMD_TDLS_SETUP, + CMD_TDLS_TEARDOWN, + CMD_TDLS_POWERMODE, + CMD_TDLS_LINK_STATUS, + CMD_TDLS_DEBUG, + CMD_TDLS_CHANNEL_SWITCH, + CMD_TDLS_STOP_CHAN_SWITCH, + CMD_TDLS_CS_PARAMS, + CMD_TDLS_CS_DISABLE, +}; + +static t_s8 *commands[] = { + "hostcmd", + "mefcfg", + "arpfilter", + "cfgdata", + "getscantable", + "setuserscan", + "addts", + "delts", + "qconfig", + "qstats", + "ts_status", + "qstatus", + "regrdwr", + "memrdwr", + "customie", + "mgmtframetx", +#ifdef OPCHAN + "opchan", + "changroup", +#endif + "tdls_config", + "tdls_setinfo", + "tdls_discovery", + "tdls_setup", + "tdls_teardown", + "tdls_powermode", + "tdls_link_status", + "tdls_debug", + "tdls_channel_switch", + "tdls_stop_channel_switch", + "tdls_cs_params", + "tdls_disable_cs", +}; + +static t_s8 *usage[] = { + "Usage: ", + " mlanconfig -v (version)", + " mlanconfig [...]", + " where", + " mlanX : wireless network interface", + " cmd : hostcmd", + " : mefcfg", + " : customie", + " : mgmtframetx", + " : arpfilter", + " : tdls_config", + " : tdls_setinfo", + " : tdls_discovery", + " : tdls_setup", + " : tdls_teardown", + " : tdls_powermode", + " : tdls_link_status", + " : tdls_debug", + " : tdls_channel_switch", + " : tdls_stop_channel_switch", + " : tdls_cs_params", + " : tdls_disable_cs", + " : cfgdata", + " : 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 arpfilter", + " : ", + " : additional parameter for tdls_setinfo", + " : ", + " : additional parameter for tdls_discovery", + " : ", + " : additional parameter for tdls_setup", + " : ", + " : additional parameter for tdls_teardown", + " : ", + " : additional parameter for tdls_powermode", + " : ", + " : additional parameter for tdls_debug ", + " : additional parameter for tdls_channel_switch", + " : ", + " : additional parameter for tdls_stop_channel_switch", + " : ", + " : additional parameter for tdls_cs_params", + " : ", + " : additional parameter for cfgdata", + " : ", + " : 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]; /**< 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((unsigned char)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 arpfilter + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_arpfilter(int argc, char *argv[]) +{ + t_u8 *buf; + struct iwreq iwr; + t_u16 length = 0; + int ret = MLAN_STATUS_SUCCESS; + FILE *fp = NULL; + int ioctl_val, subioctl_val; + + if (get_priv_ioctl("arpfilter", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + if (argc < 4) { + printf("Error: invalid no of arguments\n"); + printf("Syntax: ./mlanconfig mlanX arpfilter \n"); + exit(1); + } + + if ((fp = fopen(argv[3], "r")) == NULL) { + fprintf(stderr, "Cannot open file %s\n", argv[3]); + return MLAN_STATUS_FAILURE; + } + buf = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); + if (buf == NULL) { + printf("Error: allocate memory for arpfilter failed\n"); + fclose(fp); + return -ENOMEM; + } + ret = prepare_arp_filter_buffer(fp, buf, &length); + fclose(fp); + + if (ret == MLAN_STATUS_FAILURE) + goto _exit_; + + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ - 1); + iwr.u.data.pointer = buf; + iwr.u.data.length = length; + iwr.u.data.flags = 0; + if (ioctl(sockfd, ioctl_val, &iwr)) { + fprintf(stderr, + "mlanconfig: arpfilter command is not supported by %s\n", + dev_name); + ret = MLAN_STATUS_FAILURE; + goto _exit_; + } + +_exit_: + if (buf) + free(buf); + + return ret; +} +/** + * @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] = {0}; + t_s32 isCurCmd = 0; + + dptr = dst; + while (fgets(buf, sizeof(buf), fp)) { + ptr = buf; + + while (*ptr) { + /* skip leading spaces */ + while (*ptr && isspace((unsigned char)*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((unsigned char)*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 + **/ +static 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 + **/ +static int string2raw(char *str, unsigned char *raw) +{ + int len = (strlen(str) + 1) / 2; + + do { + if (!isxdigit((unsigned char)*str)) { + return -1; + } + *str = toupper((unsigned char)*str); + *raw = CHAR2INT(*str) << 4; + ++str; + *str = toupper((unsigned char)*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 */ + if (buf_len > 0) + 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((unsigned char)*ptr) || *ptr == '\t')) + ptr++; + + /* skip blank lines and lines beginning with '#' */ + if (*ptr == '\0' || *ptr == '#') + break; + + if (isxdigit((unsigned char)*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 */ +#define TYPE_EQ_MAGIC \ + (MAX_OPERAND + 6) /**< magic pkt: =m operator for magic packet */ + +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((unsigned char)*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 if (!strcmp(opstr, "=m")) { + op.type = TYPE_EQ_MAGIC; + if (!push(stack, &op)) { + printf("push byte magic 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 FILTER_MAGIC TYPE_EQ_MAGIC /**< byte sequence for magic byte */ + +#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) && + (type != FILTER_MAGIC)) { + 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; + case FILTER_MAGIC: + if (!byte_find || !offset_find || !repeat_find) { + printf("Missing field for FILTER_MAGIC: 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 =m ", 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); + 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 = NULL; + 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"); + return -ENOMEM; + } + 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; + } + if (mefcmd->NumEntries > MAX_MEF_NUM_ENTRIES) { + fprintf(stderr, + "mlanconfig: MEF Entries, %d, exceeds maximum value %d\n", + mefcmd->NumEntries, + MAX_MEF_NUM_ENTRIES); + 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[21] = {0}; + 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 Performs the ioctl operation to send the command to + * the driver. + * + * @param cmd_buf Pointer to the command buffer + * @param buf_size Size of the allocated command buffer + * @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE + */ +static int tdls_ioctl(t_u8 *cmd_buf, t_u16 buf_size) +{ + struct ifreq ifr; + + /* 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_buf; + + /* Perform ioctl */ + if (ioctl(sockfd, TDLS_IOCTL, &ifr)) { + perror(""); + return MLAN_STATUS_FAILURE; + } + + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief enable/disable tdls config + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_config(int argc, char *argv[]) +{ + tdls_config *param_buf = NULL; + int ret = 0; + t_u16 cmd_len = 0; + t_u8 *buffer = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_config <0/1>\n"); + exit(1); + } + + cmd_len = sizeof(tdls_config); + + buffer = (t_u8 *)malloc(cmd_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, cmd_len); + param_buf = (tdls_config *)buffer; + param_buf->action = ACTION_TDLS_CONFIG; + + param_buf->data = (t_u16)A2HEXDECIMAL(argv[3]); + if ((param_buf->data != 0) && (param_buf->data != 1)) { + printf("ERR:Incorrect arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_config <0/1>\n"); + goto done; + } + hexdump("tdls_config ", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS %s successful.\n", + (param_buf->data) ? "enable" : "disable"); + } else { + printf("ERR:TDLS %s failed.\n", + (param_buf->data) ? "enable" : "disable"); + } + +done: + if (buffer) + free(buffer); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_setinfo + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_setinfo(int argc, char *argv[]) +{ + tdls_setinfo *param_buf = NULL; + char *line = NULL; + FILE *config_file = NULL; + int li = 0, arg_num = 0, ret = 0, i = 0, cmd_found = 0, + pairwise_index = 0, akm_index = 0, pmkid_index = 0; + char *args[MAX_TLV_ARGS] = {NULL}, *pos = NULL; + t_u16 cmd_len = 0, tlv_len = 0, tlv_len_rsn = 0, tlv_len_supp_chan = 0, + tlv_len_domain = 0; + t_u16 no_of_sub_band = 0, no_of_supp_chan_sub_band = 0, + pairwise_offset = 0, akm_offset = 0, num_of_regulatory_class = 0, + tlv_len_reg_class; + t_u16 akm_count = 0, pmk_count = 0, rsn_cap = 0; + t_u8 *buffer = NULL; + t_u8 *ptr = NULL; + char country[COUNTRY_CODE_LEN]; + tlvbuf_DomainParamSet_t *domain = NULL; + tlvbuf_SupportedChannels_t *supp_chan = NULL; + tlvbuf_RegulatoryClass_t *reg_class = NULL; + tlvbuf_HTCap_t *tlv_ht_cap = NULL; + tlvbuf_RsnParamSet_t *rsn_ie = NULL; + tlvbuf_HTInfo_t *tlv_ht_info = NULL; + t_u8 pairwise_cipher_suite[PAIRWISE_CIPHER_SUITE_LEN]; + t_u8 akm_suite[AKM_SUITE_LEN]; + t_u8 pmkid[PMKID_LEN]; + tlvbuf_VHTCap_t *tlv_vht_cap = NULL; + tlvbuf_VHTOpra_t *tlv_vht_oper = NULL; + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_setinfo \n"); + exit(1); + } + + cmd_len = sizeof(tdls_setinfo); + + 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); + param_buf = (tdls_setinfo *)buffer; + param_buf->action = ACTION_TDLS_SETINFO; + + /* 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 (!cmd_found && strncmp(args[0], argv[2], strlen(args[0]))) + continue; + + cmd_found = 1; + if (strcmp(args[0], "CapInfo") == 0) { + param_buf->cap_info = (t_u16)A2HEXDECIMAL(args[1]); + param_buf->cap_info = cpu_to_le16(param_buf->cap_info); + } else if (strcmp(args[0], "Rate") == 0) { + tlvbuf_RatesParamSet_t *tlv = NULL; + /* Append a new TLV */ + tlv_len = sizeof(tlvbuf_RatesParamSet_t) + arg_num - 1; + tlv = (tlvbuf_RatesParamSet_t *)(buffer + cmd_len); + cmd_len += tlv_len; + /* Set TLV fields */ + tlv->tag = TLV_TYPE_RATES; + tlv->length = MIN(MAX_TLV_ARGS - 1, arg_num - 1); + for (i = 0; i < tlv->length; i++) { + tlv->rates[i] = (t_u8)A2HEXDECIMAL(args[i + 1]); + } + endian_convert_tlv_header_out(tlv); + } else if (strcmp(args[0], "QosInfo") == 0) { + tlvbuf_QosInfo_t *tlv = NULL; + /* Append a new TLV */ + tlv_len = sizeof(tlvbuf_QosInfo_t); + tlv = (tlvbuf_QosInfo_t *)(buffer + cmd_len); + cmd_len += tlv_len; + /* Set TLV fields */ + tlv->tag = TLV_TYPE_QOSINFO; + tlv->length = sizeof(tlvbuf_QosInfo_t) - TLVHEADER_LEN; + tlv->u.qos_info_byte = (t_u8)A2HEXDECIMAL(args[1]); + if ((tlv->u.qos_info_byte != 0) && + (tlv->u.qos_info_byte != 0x0F)) { + printf("Invalid QosInfo. Should be 0x00 or 0x0F.\n"); + goto done; + } + endian_convert_tlv_header_out(tlv); + } else if (strcmp(args[0], "ExtendCapabilities") == 0) { + tlvbuf_ExtCap_t *tlv = NULL; + /* Append a new TLV */ + tlv_len = sizeof(tlvbuf_ExtCap_t) + arg_num - 1; + tlv = (tlvbuf_ExtCap_t *)(buffer + cmd_len); + cmd_len += tlv_len; + /* Set TLV fields */ + tlv->tag = TLV_TYPE_EXTCAP; + tlv->length = MIN(MAX_TLV_ARGS - 1, arg_num - 1); + for (i = 0; i < tlv->length; i++) { + tlv->ext_cap[i] = + (t_u8)A2HEXDECIMAL(args[i + 1]); + } + endian_convert_tlv_header_out(tlv); + } else if (strcmp(args[0], "HTCapability") == 0) { + /* Append a new TLV */ + tlv_ht_cap = (tlvbuf_HTCap_t *)(buffer + cmd_len); + tlv_len = sizeof(tlvbuf_HTCap_t); + tlv_ht_cap->tag = TLV_TYPE_HT_CAP; + tlv_ht_cap->length = + sizeof(tlvbuf_HTCap_t) - TLVHEADER_LEN; + cmd_len += tlv_len; + endian_convert_tlv_header_out(tlv_ht_cap); + } else if (strcmp(args[0], "HTCapabilityInfo") == 0) { + tlv_ht_cap->ht_cap.ht_cap_info = + (t_u16)A2HEXDECIMAL(args[1]); + tlv_ht_cap->ht_cap.ht_cap_info = + cpu_to_le16(tlv_ht_cap->ht_cap.ht_cap_info); + } else if (strcmp(args[0], "AMPDUParam") == 0) { + tlv_ht_cap->ht_cap.ampdu_param = + (t_u8)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "SupportedMCSSet") == 0) { + for (i = 0; i < MCS_SET_LEN; i++) + tlv_ht_cap->ht_cap.supported_mcs_set[i] = + (t_u8)A2HEXDECIMAL(args[i + 1]); + } else if (strcmp(args[0], "HTExtCapability") == 0) { + tlv_ht_cap->ht_cap.ht_ext_cap = + (t_u16)A2HEXDECIMAL(args[1]); + tlv_ht_cap->ht_cap.ht_ext_cap = + cpu_to_le16(tlv_ht_cap->ht_cap.ht_ext_cap); + } else if (strcmp(args[0], "TxBfCapability") == 0) { + tlv_ht_cap->ht_cap.tx_bf_cap = + (t_u32)A2HEXDECIMAL(args[1]); + tlv_ht_cap->ht_cap.tx_bf_cap = + cpu_to_le32(tlv_ht_cap->ht_cap.tx_bf_cap); + } else if (strcmp(args[0], "AntennaSel") == 0) { + tlv_ht_cap->ht_cap.asel = (t_u8)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "HTInformation") == 0) { + /* Append a new TLV */ + tlv_ht_info = (tlvbuf_HTInfo_t *)(buffer + cmd_len); + tlv_len = sizeof(tlvbuf_HTInfo_t); + tlv_ht_info->tag = TLV_TYPE_HT_INFO; + tlv_ht_info->length = + sizeof(tlvbuf_HTInfo_t) - TLVHEADER_LEN; + cmd_len += tlv_len; + endian_convert_tlv_header_out(tlv_ht_info); + } else if (strcmp(args[0], "PrimaryChannel") == 0) { + tlv_ht_info->ht_info.pri_chan = A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "Field2") == 0) { + tlv_ht_info->ht_info.field2 = A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "Field3") == 0) { + tlv_ht_info->ht_info.field3 = + (t_u16)A2HEXDECIMAL(args[1]); + tlv_ht_info->ht_info.field3 = + cpu_to_le16(tlv_ht_info->ht_info.field3); + } else if (strcmp(args[0], "Field4") == 0) { + tlv_ht_info->ht_info.field4 = + (t_u16)A2HEXDECIMAL(args[1]); + tlv_ht_info->ht_info.field4 = + cpu_to_le16(tlv_ht_info->ht_info.field4); + } else if (strcmp(args[0], "BasicMCSSet") == 0) { + if ((arg_num - 1) != MCS_SET_LEN) { + printf("Incorrect number of arguments for BasicMCSSet.\n"); + goto done; + } + for (i = 0; i < MCS_SET_LEN; i++) + tlv_ht_info->ht_info.basic_mcs_set[i] = + (t_u8)A2HEXDECIMAL(args[i + 1]); + } else if (strcmp(args[0], "2040BSSCoex") == 0) { + tlvbuf_2040BSSCo_t *tlv = NULL; + /* Append a new TLV */ + tlv_len = sizeof(tlvbuf_2040BSSCo_t); + tlv = (tlvbuf_2040BSSCo_t *)(buffer + cmd_len); + cmd_len += tlv_len; + /* Set TLV fields */ + tlv->tag = TLV_TYPE_2040BSS_COEXISTENCE; + tlv->length = + sizeof(tlvbuf_2040BSSCo_t) - TLVHEADER_LEN; + tlv->bss_co_2040.bss_co_2040_value = + (t_u8)A2HEXDECIMAL(args[1]); + endian_convert_tlv_header_out(tlv); + } else if (strcmp(args[0], "RSNInfo") == 0) { + /* Append a new TLV */ + rsn_ie = (tlvbuf_RsnParamSet_t *)(buffer + cmd_len); + tlv_len_rsn = sizeof(tlvbuf_RsnParamSet_t); + rsn_ie->tag = TLV_TYPE_RSN_IE; + rsn_ie->version = VERSION_RSN_IE; + rsn_ie->version = cpu_to_le16(rsn_ie->version); + cmd_len += tlv_len_rsn; + } else if (strcmp(args[0], "GroupCipherSuite") == 0) { + for (i = 0; i < GROUP_CIPHER_SUITE_LEN; i++) + rsn_ie->group_cipher_suite[i] = + (t_u8)A2HEXDECIMAL(args[i + 1]); + } else if (strcmp(args[0], "PairwiseCipherCount") == 0) { + if (rsn_ie) { + rsn_ie->pairwise_cipher_count = + (t_u16)atoi(args[1]); + rsn_ie->pairwise_cipher_count = cpu_to_le16( + rsn_ie->pairwise_cipher_count); + } + } else if (strncmp(args[0], "PairwiseCipherSuite", 19) == 0) { + if (pairwise_index > MAX_PAIRWISE_CIPHER_SUITE_COUNT) { + printf("PairwiseCipherSuite exceeds max count\n"); + goto done; + } + tlv_len_rsn += PAIRWISE_CIPHER_SUITE_LEN; + cmd_len += PAIRWISE_CIPHER_SUITE_LEN; + for (i = 0; i < PAIRWISE_CIPHER_SUITE_LEN; i++) { + pairwise_cipher_suite[i] = + (t_u8)A2HEXDECIMAL(args[i + 1]); + } + memcpy((t_u8 *)(rsn_ie->pairwise_cipher_suite + + (pairwise_index * + PAIRWISE_CIPHER_SUITE_LEN)), + pairwise_cipher_suite, + PAIRWISE_CIPHER_SUITE_LEN); + pairwise_index++; + pairwise_offset = + pairwise_index * PAIRWISE_CIPHER_SUITE_LEN; + } else if (strcmp(args[0], "AKMSuiteCount") == 0) { + /* pairwise_cipher_suite + pairwise_offset */ + ptr = (t_u8 *)(rsn_ie->pairwise_cipher_suite + + pairwise_offset); + tlv_len_rsn += sizeof(t_u16); + cmd_len += sizeof(t_u16); + akm_count = (t_u16)atoi(args[1]); + akm_count = cpu_to_le16(akm_count); + memcpy(ptr, &akm_count, sizeof(t_u16)); + } else if (strncmp(args[0], "AKMSuite", 8) == 0) { + if (akm_index > MAX_AKM_SUITE_COUNT) { + printf("AKMSuite exceeds max count\n"); + goto done; + } + /* pairwise_cipher_suite + pairwise_offset + + * sizeof(t_u16) for akm_count */ + ptr = (t_u8 *)(rsn_ie->pairwise_cipher_suite + + pairwise_offset + sizeof(t_u16)); + tlv_len_rsn += AKM_SUITE_LEN; + cmd_len += AKM_SUITE_LEN; + for (i = 0; i < AKM_SUITE_LEN; i++) { + akm_suite[i] = (t_u8)A2HEXDECIMAL(args[i + 1]); + } + memcpy((t_u8 *)(ptr + (akm_index * AKM_SUITE_LEN)), + akm_suite, AKM_SUITE_LEN); + akm_index++; + akm_offset = akm_index * AKM_SUITE_LEN; + } else if (strcmp(args[0], "RSNCapability") == 0) { + /* pairwise_cipher_suite + pairwise_offset + + sizeof(t_u16) for akm_count + + akm_offset */ + ptr = (t_u8 *)(rsn_ie->pairwise_cipher_suite + + pairwise_offset + sizeof(t_u16)) + + akm_offset; + tlv_len_rsn += sizeof(t_u16); + cmd_len += sizeof(t_u16); + rsn_cap = (t_u16)A2HEXDECIMAL(args[1]); + rsn_cap = cpu_to_le16(rsn_cap); + memcpy(ptr, &rsn_cap, sizeof(t_u16)); + } else if (strcmp(args[0], "PMKIDCount") == 0) { + /* pairwise_cipher_suite + pairwise_offset + + sizeof(t_u16) for akm_count + + akm_offset + sizeof(t_u16) for RSNCapability */ + ptr = (t_u8 *)(rsn_ie->pairwise_cipher_suite + + pairwise_offset + sizeof(t_u16)) + + akm_offset + sizeof(t_u16); + tlv_len_rsn += sizeof(t_u16); + cmd_len += sizeof(t_u16); + pmk_count = (t_u16)atoi(args[1]); + pmk_count = cpu_to_le16(pmk_count); + memcpy(ptr, &pmk_count, sizeof(t_u16)); + rsn_ie->length = tlv_len_rsn - TLVHEADER_LEN; + endian_convert_tlv_header_out(rsn_ie); + } else if (strncmp(args[0], "PMKIDList", 9) == 0) { + if (pmkid_index > MAX_PMKID_COUNT) { + printf("PMKIDSuite exceeds max count\n"); + goto done; + } + /* pairwise_cipher_suite + pairwise_offset + + sizeof(t_u16) for akm_count + + akm_offset + sizeof(t_u16) for RSNCapability + + sizeof(t_u16) for PMKIDCount*/ + ptr = (t_u8 *)(rsn_ie->pairwise_cipher_suite + + pairwise_offset + sizeof(t_u16)) + + akm_offset + sizeof(t_u16) + sizeof(t_u16); + for (i = 0; i < PMKID_LEN; i++) + pmkid[i] = (t_u8)A2HEXDECIMAL(args[i + 1]); + memcpy((t_u8 *)(ptr + (pmkid_index * PMKID_LEN)), pmkid, + PMKID_LEN); + pmkid_index++; + tlv_len_rsn += PMKID_LEN; + cmd_len += PMKID_LEN; + /* undo conversion done in PMKIDCount */ + endian_convert_tlv_header_in(rsn_ie); + rsn_ie->length = tlv_len_rsn - TLVHEADER_LEN; + endian_convert_tlv_header_out(rsn_ie); + } else if (strcmp(args[0], "SupportedChannels") == 0) { + /* Append a new TLV */ + supp_chan = (tlvbuf_SupportedChannels_t *)(buffer + + cmd_len); + supp_chan->tag = TLV_TYPE_SUPPORTED_CHANNELS; + supp_chan->length = sizeof(tlvbuf_SupportedChannels_t) - + TLVHEADER_LEN; + tlv_len_supp_chan = sizeof(tlvbuf_SupportedChannels_t); + cmd_len += tlv_len_supp_chan; + } else if (strncmp(args[0], "FirstChannelNo", 14) == 0) { + if (supp_chan) + supp_chan->subband[no_of_supp_chan_sub_band] + .start_chan = atoi(args[1]); + } else if (strcmp(args[0], "NumberofSubBandChannels") == 0) { + if (supp_chan) { + supp_chan->subband[no_of_supp_chan_sub_band] + .num_chans = atoi(args[1]); + no_of_supp_chan_sub_band++; + tlv_len_supp_chan += + sizeof(IEEEtypes_SupportChan_Subband_t); + supp_chan->length += + sizeof(IEEEtypes_SupportChan_Subband_t); + cmd_len += + sizeof(IEEEtypes_SupportChan_Subband_t); + endian_convert_tlv_header_out(supp_chan); + } + } else if (strcmp(args[0], "SupportedRegulatoryClasses") == 0) { + /* Append a new TLV */ + reg_class = + (tlvbuf_RegulatoryClass_t *)(buffer + cmd_len); + tlv_len_reg_class = sizeof(tlvbuf_RegulatoryClass_t); + reg_class->tag = TLV_TYPE_REGULATORY_CLASSES; + cmd_len += tlv_len_reg_class; + } else if (strcmp(args[0], "CurrentRegulatoryClass") == 0) { + if (reg_class) { + reg_class->regulatory_class + .cur_regulatory_class = atoi(args[1]); + reg_class->length = 1; + } + } else if (strcmp(args[0], "NumofRegulatoryClasses") == 0) { + if (reg_class) { + num_of_regulatory_class = atoi(args[1]); + reg_class->length += num_of_regulatory_class; + cmd_len += num_of_regulatory_class; + endian_convert_tlv_header_out(reg_class); + } + } else if (strcmp(args[0], "ListOfRegulatoryClasses") == 0) { + if (reg_class) { + for (i = 0; i < num_of_regulatory_class; i++) + reg_class->regulatory_class + .regulatory_classes_list[i] = + (t_u8)A2HEXDECIMAL(args[i + 1]); + } + } else if (strcmp(args[0], "CountryInfo") == 0) { + /* Append a new TLV */ + domain = (tlvbuf_DomainParamSet_t *)(buffer + cmd_len); + domain->tag = TLV_TYPE_DOMAIN; + domain->length = + sizeof(tlvbuf_DomainParamSet_t) - TLVHEADER_LEN; + tlv_len_domain = sizeof(tlvbuf_DomainParamSet_t); + cmd_len += tlv_len_domain; + } else if (strcmp(args[0], "CountryString") == 0) { + strncpy(country, args[1] + 1, strlen(args[1]) - 2); + country[strlen(args[1]) - 2] = '\0'; + for (i = 1; (unsigned int)i < strlen(country) - 2; + i++) { + if ((country[i] < 'A') || (country[i] > 'z')) { + printf("Invalid Country Code\n"); + goto done; + } + if (country[i] > 'Z') + country[i] = country[i] - 'a' + 'A'; + } + memset(domain->country_code, ' ', + sizeof(domain->country_code)); + memcpy(domain->country_code, country, strlen(country)); + } else if (strncmp(args[0], "FirstChannel", 12) == 0) { + domain->sub_band[no_of_sub_band].first_chan = + atoi(args[1]); + } else if (strncmp(args[0], "NumberofChannels", 16) == 0) { + domain->sub_band[no_of_sub_band].no_of_chan = + atoi(args[1]); + } else if (strncmp(args[0], "TxPower", 7) == 0) { + domain->sub_band[no_of_sub_band].max_tx_pwr = + atoi(args[1]); + no_of_sub_band++; + domain->length += sizeof(IEEEtypes_SubbandSet_t); + tlv_len_domain += sizeof(IEEEtypes_SubbandSet_t); + cmd_len += sizeof(IEEEtypes_SubbandSet_t); + endian_convert_tlv_header_out(domain); + } else if (strcmp(args[0], "VHTCapability") == 0) { + /* Append a new TLV */ + tlv_vht_cap = (tlvbuf_VHTCap_t *)(buffer + cmd_len); + tlv_len = sizeof(tlvbuf_VHTCap_t); + tlv_vht_cap->tag = TLV_TYPE_VHT_CAP; + tlv_vht_cap->length = + sizeof(tlvbuf_VHTCap_t) - TLVHEADER_LEN; + cmd_len += tlv_len; + endian_convert_tlv_header_out(tlv_vht_cap); + } else if (strcmp(args[0], "VHTCapabilityInfo") == 0) { + tlv_vht_cap->vht_cap.vht_cap_info = + (t_u32)A2HEXDECIMAL(args[1]); + tlv_vht_cap->vht_cap.vht_cap_info = + cpu_to_le16(tlv_vht_cap->vht_cap.vht_cap_info); + } else if (strcmp(args[0], "RxMCSMap") == 0) { + tlv_vht_cap->vht_cap.mcs_sets.rx_mcs_map = + (t_u16)A2HEXDECIMAL(args[1]); + tlv_vht_cap->vht_cap.mcs_sets.rx_mcs_map = cpu_to_le16( + tlv_vht_cap->vht_cap.mcs_sets.rx_mcs_map); + } else if (strcmp(args[0], "TxMCSMap") == 0) { + tlv_vht_cap->vht_cap.mcs_sets.tx_mcs_map = + (t_u16)A2HEXDECIMAL(args[1]); + tlv_vht_cap->vht_cap.mcs_sets.tx_mcs_map = cpu_to_le16( + tlv_vht_cap->vht_cap.mcs_sets.tx_mcs_map); + } else if (strcmp(args[0], "RxMaxRate") == 0) { + tlv_vht_cap->vht_cap.mcs_sets.rx_max_rate = + (t_u16)A2HEXDECIMAL(args[1]); + tlv_vht_cap->vht_cap.mcs_sets.rx_max_rate = cpu_to_le16( + tlv_vht_cap->vht_cap.mcs_sets.rx_max_rate); + } else if (strcmp(args[0], "TxMaxRate") == 0) { + tlv_vht_cap->vht_cap.mcs_sets.tx_max_rate = + (t_u16)A2HEXDECIMAL(args[1]); + tlv_vht_cap->vht_cap.mcs_sets.tx_max_rate = cpu_to_le16( + tlv_vht_cap->vht_cap.mcs_sets.tx_max_rate); + } else if (strcmp(args[0], "VHTOper") == 0) { + /* Append a new TLV */ + tlv_vht_oper = (tlvbuf_VHTOpra_t *)(buffer + cmd_len); + tlv_len = sizeof(tlvbuf_VHTOpra_t); + tlv_vht_oper->tag = TLV_TYPE_VHT_OPER; + tlv_vht_oper->length = + sizeof(tlvbuf_VHTOpra_t) - TLVHEADER_LEN; + cmd_len += tlv_len; + endian_convert_tlv_header_out(tlv_vht_oper); + } else if (strcmp(args[0], "ChanWidth") == 0) { + tlv_vht_oper->chan_width = A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "ChanCF1") == 0) { + tlv_vht_oper->chan_cf1 = A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "ChanCF2") == 0) { + tlv_vht_oper->chan_cf2 = (t_u16)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "BasicMCSMap") == 0) { + if ((arg_num - 1) != VHT_MCS_MAP_LEN) { + printf("Incorrect number of arguments for BasicMCSMap.\n"); + goto done; + } + for (i = 0; i < VHT_MCS_MAP_LEN; i++) + tlv_vht_oper->basic_mcs_map[i] = + (t_u8)A2HEXDECIMAL(args[i + 1]); + } + } + /* adjust for size of action and tlv_len, capInfo */ + param_buf->tlv_len = cmd_len - sizeof(tdls_setinfo); + + hexdump("tdls_setinfo", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS Info settings sucessfully set.\n"); + } else { + printf("ERR:Could not set TDLS info configuration.\n"); + } + +done: + if (config_file) + fclose(config_file); + if (buffer) + free(buffer); + if (line) + free(line); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_discovery + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_discovery(int argc, char *argv[]) +{ + tdls_discovery *param_buf = NULL; + tdls_discovery_resp *resp_buf = NULL; + char *line = NULL; + FILE *config_file = NULL; + int li = 0, ret = 0, cmd_found = 0, rssi = 0; + char *args[30] = {NULL}, *pos = NULL, mac_addr[21] = {0}; + t_u8 peer_mac[ETH_ALEN]; + t_u16 cmd_len = 0, buf_len = 0, resp_len = 0; + t_u8 *buffer = NULL, *raw = NULL; + IEEEtypes_Header_t *tlv = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_discovery \n"); + exit(1); + } + + cmd_len = sizeof(tdls_discovery); + buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; + + buffer = (t_u8 *)malloc(buf_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, buf_len); + param_buf = (tdls_discovery *)buffer; + param_buf->action = ACTION_TDLS_DISCOVERY; + + /* Check if file exists */ + config_file = fopen(argv[3], "r"); + if (config_file == NULL) { + printf("\nERR:Config file can not open.\n"); + free(buffer); + return MLAN_STATUS_FAILURE; + } + 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)) { + if (!cmd_found && strncmp(args[0], argv[2], strlen(args[0]))) + continue; + + cmd_found = 1; + if (strcmp(args[0], "PeerMAC") == 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; + } + memcpy(param_buf->peer_mac, peer_mac, ETH_ALEN); + } else if (strcmp(args[0], "}") == 0 && cmd_found) { + break; + } + } + hexdump("tdls_discovery", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + hexdump("tdls_response", buffer, 0x40, ' '); + printf("TDLS discovery done.\n"); + resp_buf = (tdls_discovery_resp *)buffer; + resp_len = resp_buf->payload_len; + printf("Response Length = %d\n", resp_len); + if (resp_len > 0) { + /* MAC */ + raw = resp_buf->peer_mac; + printf("\tPeer - %02x:%02x:%02x:%02x:%02x:%02x\n", + (unsigned int)raw[0], (unsigned int)raw[1], + (unsigned int)raw[2], (unsigned int)raw[3], + (unsigned int)raw[4], (unsigned int)raw[5]); + + /* RSSI, CapInfo */ + rssi = (int)(resp_buf->rssi); + if (rssi > 0x7f) + rssi = -(256 - rssi); + printf("\tRssi : %d dBm\n", rssi); + printf("\tCapInfo = 0x%02X\n", resp_buf->cap_info); + + resp_len -= ETH_ALEN + sizeof(resp_buf->rssi) + + sizeof(resp_buf->cap_info); + + /* TLVs */ + tlv = (IEEEtypes_Header_t *)&resp_buf->tlv_buffer; + while (resp_len > IEEE_HEADER_LEN) { + switch (tlv->element_id) { + case TLV_TYPE_RATES: + printf("\tRates : "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + case TLV_EXTENDED_SUPPORTED_RATES: + printf("\tExtended Rates : "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + case TLV_TYPE_QOSINFO: + printf("\tQosInfo "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + + case TLV_TYPE_EXTCAP: + printf("\tExtended Cap "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + + case TLV_TYPE_HT_CAP: + printf("\tHT Cap "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + + case TLV_TYPE_HT_INFO: + printf("\tHT Info"); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + + case TLV_TYPE_2040BSS_COEXISTENCE: + printf("\t2040 BSS Coex "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + + case TLV_TYPE_RSN_IE: + printf("\tRSN IE "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + + case TLV_TYPE_SUPPORTED_CHANNELS: + printf("\tSupported Channels "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + + case TLV_TYPE_DOMAIN: + printf("\tDomain Info "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + case TLV_LINK_IDENTIFIER: + printf("\tLink identifier : "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + case TLV_TIMEOUT_INTERVAL: + printf("\tTimeout interval : "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + case TLV_TYPE_REGULATORY_CLASSES: + printf("\t Regulatory classes : "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + default: + printf("Unknown TLV\n"); + hexdump(NULL, ((t_u8 *)tlv), + IEEE_HEADER_LEN + tlv->len, + ' '); + break; + } + resp_len -= tlv->len + IEEE_HEADER_LEN; + tlv = (IEEEtypes_Header_t *)((t_u8 *)tlv + + tlv->len + + IEEE_HEADER_LEN); + } + } + + } else { + printf("ERR:Command response = Fail!\n"); + } +done: + + if (config_file != NULL) + fclose(config_file); + if (buffer) + free(buffer); + if (line) + free(line); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_setup + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_setup(int argc, char *argv[]) +{ + tdls_setup *param_buf = NULL; + char *line = NULL; + FILE *config_file = NULL; + int li = 0, ret = 0, cmd_found = 0; + char *args[30] = {NULL}, *pos = NULL, mac_addr[21] = {0}; + t_u8 peer_mac[ETH_ALEN]; + t_u16 cmd_len = 0; + t_u8 *buffer = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_setup \n"); + exit(1); + } + + cmd_len = sizeof(tdls_setup); + + buffer = (t_u8 *)malloc(cmd_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, cmd_len); + param_buf = (tdls_setup *)buffer; + param_buf->action = ACTION_TDLS_SETUP; + + /* Check if file exists */ + config_file = fopen(argv[3], "r"); + if (config_file == NULL) { + printf("\nERR:Config file can not open.\n"); + free(buffer); + return MLAN_STATUS_FAILURE; + } + 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)) { + if (!cmd_found && strncmp(args[0], argv[2], strlen(args[0]))) + continue; + + cmd_found = 1; + + if (strcmp(args[0], "PeerMAC") == 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; + } + memcpy(param_buf->peer_mac, peer_mac, ETH_ALEN); + } else if (strcmp(args[0], "WaitTimems") == 0) { + param_buf->wait_time = (t_u32)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "KeyLifetime") == 0) { + param_buf->key_life_time = (t_u32)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "}") == 0 && cmd_found) { + break; + } + } + hexdump("tdls_setup", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS setup request successful.\n"); + } else { + printf("ERR:TDLS setup request failed.\n"); + } + +done: + if (config_file != NULL) + fclose(config_file); + if (buffer) + free(buffer); + if (line) + free(line); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_teardown + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_teardown(int argc, char *argv[]) +{ + tdls_teardown *param_buf = NULL; + char *line = NULL; + FILE *config_file = NULL; + int li = 0, ret = 0, cmd_found = 0; + char *args[30] = {NULL}, *pos = NULL, mac_addr[21] = {0}; + t_u8 peer_mac[ETH_ALEN]; + t_u16 cmd_len = 0; + t_u8 *buffer = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_teardown \n"); + exit(1); + } + + cmd_len = sizeof(tdls_teardown); + + buffer = (t_u8 *)malloc(cmd_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, cmd_len); + param_buf = (tdls_teardown *)buffer; + param_buf->action = ACTION_TDLS_TEARDOWN; + + /* Check if file exists */ + config_file = fopen(argv[3], "r"); + if (config_file == NULL) { + printf("\nERR:Config file can not open.\n"); + free(buffer); + return MLAN_STATUS_FAILURE; + } + 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)) { + if (!cmd_found && strncmp(args[0], argv[2], strlen(args[0]))) + continue; + + cmd_found = 1; + + if (strcmp(args[0], "PeerMAC") == 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; + } + memcpy(param_buf->peer_mac, peer_mac, ETH_ALEN); + } else if (strcmp(args[0], "ReasonCode") == 0) { + param_buf->reason_code = (t_u16)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "}") == 0 && cmd_found) { + break; + } + } + hexdump("tdls_teardown", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS teardown request successful.\n"); + } else { + printf("ERR:TDLS teardown request failed.\n"); + } + +done: + if (config_file != NULL) + fclose(config_file); + if (buffer) + free(buffer); + if (line) + free(line); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_powermode + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_powermode(int argc, char *argv[]) +{ + tdls_powermode *param_buf = NULL; + char *line = NULL; + FILE *config_file = NULL; + int li = 0, ret = 0, cmd_found = 0; + char *args[30] = {NULL}, *pos = NULL, mac_addr[21] = {0}; + t_u8 peer_mac[ETH_ALEN]; + t_u16 cmd_len = 0; + t_u8 *buffer = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_powermode \n"); + exit(1); + } + + cmd_len = sizeof(tdls_powermode); + + buffer = (t_u8 *)malloc(cmd_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, cmd_len); + param_buf = (tdls_powermode *)buffer; + param_buf->action = ACTION_TDLS_POWER_MODE; + + /* Check if file exists */ + config_file = fopen(argv[3], "r"); + if (config_file == NULL) { + printf("\nERR:Config file can not open.\n"); + free(buffer); + return MLAN_STATUS_FAILURE; + } + 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)) { + if (!cmd_found && strncmp(args[0], argv[2], strlen(args[0]))) + continue; + + cmd_found = 1; + + if (strcmp(args[0], "PeerMAC") == 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; + } + memcpy(param_buf->peer_mac, peer_mac, ETH_ALEN); + } else if (strcmp(args[0], "PowerMode") == 0) { + param_buf->power_mode = (t_u16)A2HEXDECIMAL(args[1]); + if (param_buf->power_mode > 1) { + printf("ERR: Incorrect PowerMode value %s\n", + args[1]); + goto done; + } + } else if (strcmp(args[0], "}") == 0 && cmd_found) { + break; + } + } + hexdump("tdls_powermode", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS powermode request successful.\n"); + } else { + printf("ERR:TDLS powermode request failed.\n"); + } + +done: + if (config_file != NULL) + fclose(config_file); + if (buffer) + free(buffer); + if (line) + free(line); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_link_status + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_link_status(int argc, char *argv[]) +{ + int ret = 0; + tdls_link_status *param_buf = NULL; + tdls_link_status_resp *resp_buf = NULL; + t_u16 cmd_len = 0, buf_len = 0, resp_len = 0, curr_link_len = 0; + t_u8 no_of_links = 0, peer_mac[ETH_ALEN] = {0}; + t_u8 *buffer = NULL, *raw = NULL; + tdls_each_link_status *link_ptr = NULL; + + /* Check arguments */ + if (argc != 3 && argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_link_status [peer_mac_addr]\n"); + exit(1); + } + + cmd_len = sizeof(tdls_link_status); + buf_len = MRVDRV_SIZE_OF_CMD_BUFFER; + + buffer = (t_u8 *)malloc(buf_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, buf_len); + param_buf = (tdls_link_status *)buffer; + param_buf->action = ACTION_TDLS_LINK_STATUS; + + if (argc == 4) { + if ((ret = mac2raw(argv[3], peer_mac)) != MLAN_STATUS_SUCCESS) { + printf("ERR: %s Address \n", + ret == MLAN_STATUS_FAILURE ? + "Invalid MAC" : + ret == MAC_BROADCAST ? "Broadcast" : + "Multicast"); + goto done; + } + if (memcmp(peer_mac, "\x00\x00\x00\x00\x00\x00", ETH_ALEN)) { + memcpy(buffer + cmd_len, peer_mac, ETH_ALEN); + cmd_len += ETH_ALEN; + } + } + + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + hexdump("tdls_response", buffer, 0x60, ' '); + printf("TDLS Link Status - .\n"); + resp_buf = (tdls_link_status_resp *)buffer; + resp_len = resp_buf->payload_len; + printf("Response Length = %d\n", resp_len); + no_of_links = resp_buf->active_links; + printf("No of active links = %d\n", no_of_links); + resp_len--; + link_ptr = resp_buf->link_stats; + while (resp_len > 0 && no_of_links > 0) { + curr_link_len = 0; + /* MAC */ + raw = link_ptr->peer_mac; + printf("\tPeer - %02x:%02x:%02x:%02x:%02x:%02x\n", + (unsigned int)raw[0], (unsigned int)raw[1], + (unsigned int)raw[2], (unsigned int)raw[3], + (unsigned int)raw[4], (unsigned int)raw[5]); + + printf("\t %s initiated link.\n", + (link_ptr->link_flags & 0x01) ? "Self" : "Peer"); + printf("\t Security %s.\n", + (link_ptr->link_flags & 0x02) ? "Enabled" : + "Disabled"); + printf("\t Self PS status = %s.\n", + (link_ptr->link_flags & 0x04) ? "Sleep" : + "Active"); + printf("\t Peer PS status = %s.\n", + (link_ptr->link_flags & 0x08) ? "Sleep" : + "Active"); + printf("\t Channel switch is %ssupported\n", + (link_ptr->link_flags & 0x10) ? "" : "NOT "); + printf("\t Current Channel %s\n", + (link_ptr->link_flags & 0x20) ? "off" : "base"); + + if (link_ptr->traffic_status) { + printf("\t Buffered traffic for"); + printf("%s", (link_ptr->traffic_status & 0x01) ? + "AC_BK, " : + ""); + printf("%s", (link_ptr->traffic_status & 0x02) ? + "AC_BE, " : + ""); + printf("%s", (link_ptr->traffic_status & 0x04) ? + "AC_VI, " : + ""); + printf("%s", (link_ptr->traffic_status & 0x08) ? + "AC_VO" : + ""); + printf(".\n"); + } + printf("\t Successive Tx Failure count = %d\n", + link_ptr->tx_fail_count); + printf("\t Active channel number = %d\n", + link_ptr->active_channel); + printf("\t Last Data RSSI = %d dBm\n", + link_ptr->data_rssi_last); + printf("\t Last Data NF = %d dBm\n", + link_ptr->data_nf_last); + printf("\t Average Data RSSI = %d dBm\n", + link_ptr->data_rssi_avg); + printf("\t Average Data NF = %d dBm\n", + link_ptr->data_nf_avg); + printf("\t Tx data rate = %d Mbps\n", + link_ptr->u.final_data_rate); + + /* size of unsecure structure */ + curr_link_len = + sizeof(tdls_each_link_status) - + (sizeof(t_u32) + sizeof(t_u8) + sizeof(t_u8)); + + if (link_ptr->link_flags & 0x02) { + /* security details */ + printf("\t Security Method = %s\n", + (link_ptr->security_method == 1) ? + "AES" : + "None"); + printf("\t Key Lifetime = %d ms\n\t", + link_ptr->key_lifetime); + hexdump("Key", ((t_u8 *)link_ptr->key), + link_ptr->key_length, ' '); + curr_link_len += sizeof(t_u32) + sizeof(t_u8) + + sizeof(t_u8) + + link_ptr->key_length; + } + resp_len -= curr_link_len; + link_ptr = + (tdls_each_link_status *)(((t_u8 *)link_ptr) + + curr_link_len); + printf(".\n"); + } + + } else { + printf("ERR:Command response = Fail!\n"); + } +done: + if (buffer) + free(buffer); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_channel_swtich + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_channel_switch(int argc, char *argv[]) +{ + tdls_channel_switch *param_buf = NULL; + char *line = NULL; + FILE *config_file = NULL; + int li = 0, ret = 0, cmd_found = 0; + char *args[30] = {NULL}, *pos = NULL, mac_addr[21] = {0}; + t_u8 peer_mac[ETH_ALEN]; + t_u16 cmd_len = 0; + t_u8 *buffer = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_channel_switch \n"); + exit(1); + } + + cmd_len = sizeof(tdls_channel_switch); + + buffer = (t_u8 *)malloc(cmd_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, cmd_len); + param_buf = (tdls_channel_switch *)buffer; + param_buf->action = ACTION_TDLS_INIT_CHAN_SWITCH; + + /* Check if file exists */ + config_file = fopen(argv[3], "r"); + if (config_file == NULL) { + printf("\nERR:Config file can not open.\n"); + free(buffer); + return MLAN_STATUS_FAILURE; + } + 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)) { + if (!cmd_found && strncmp(args[0], argv[2], strlen(args[0]))) + continue; + + cmd_found = 1; + + if (strcmp(args[0], "PeerMAC") == 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; + } + memcpy(param_buf->peer_mac, peer_mac, ETH_ALEN); + } else if (strcmp(args[0], "Band") == 0) { + param_buf->band = (t_u16)A2HEXDECIMAL(args[1]); + if (param_buf->band != BAND_BG && + param_buf->band != BAND_A) { + printf("ERR: Incorrect Band value %s\n", + args[1]); + goto done; + } + } else if (strcmp(args[0], "RegulatoryClass") == 0) { + param_buf->regulatory_class = + (t_u16)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "PrimaryChannel") == 0) { + param_buf->primary_channel = + (t_u16)A2HEXDECIMAL(args[1]); + if (param_buf->band == BAND_BG && + param_buf->primary_channel < MIN_BG_CHANNEL && + param_buf->primary_channel > MAX_BG_CHANNEL) { + printf("ERR: Incorrect Primary Channel value %s\n", + args[1]); + goto done; + } else if (param_buf->band == BAND_A && + param_buf->primary_channel < MIN_A_CHANNEL && + param_buf->primary_channel > MAX_A_CHANNEL) { + printf("ERR: Incorrect Primary Channel value %s\n", + args[1]); + goto done; + } + } else if (strcmp(args[0], "SecondaryChannelOffset") == 0) { + param_buf->secondary_channel_offset = + (t_u16)A2HEXDECIMAL(args[1]); + if (param_buf->secondary_channel_offset != 0 && + param_buf->secondary_channel_offset != + SECOND_CHANNEL_ABOVE && + param_buf->secondary_channel_offset != + SECOND_CHANNEL_BELOW) { + printf("ERR: Incorrect Secondary Channel Offset value %s\n", + args[1]); + goto done; + } + } else if (strcmp(args[0], "ChannelSwitchTime") == 0) { + param_buf->switch_time = (t_u16)A2HEXDECIMAL(args[1]); + if (param_buf->switch_time == 0) { + printf("ERR: Incorrect Channel Switch time %s\n", + args[1]); + goto done; + } + } else if (strcmp(args[0], "ChannelSwitchTimeout") == 0) { + param_buf->switch_timeout = + (t_u16)A2HEXDECIMAL(args[1]); + if (param_buf->switch_timeout == 0) { + printf("ERR: Incorrect Channel Switch timeout %s\n", + args[1]); + goto done; + } + } else if (strcmp(args[0], "Periodicity") == 0) { + param_buf->periodicity = (t_u16)A2HEXDECIMAL(args[1]); + if (param_buf->periodicity != NO_PERIODIC_SWITCH && + param_buf->periodicity != ENABLE_PERIODIC_SWITCH) { + printf("ERR: Incorrect Periodicity value %s\n", + args[1]); + goto done; + } + } else if (strcmp(args[0], "}") == 0 && cmd_found) { + break; + } + } + hexdump("tdls_channel_switch", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS channel switch request successful.\n"); + } else { + printf("ERR:TDLS channel switch request failed.\n"); + } + +done: + if (config_file != NULL) + fclose(config_file); + if (buffer) + free(buffer); + if (line) + free(line); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief disable tdls_channel_swtich + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_disable_channel_switch(int argc, char *argv[]) +{ + tdls_disable_cs *param_buf = NULL; + int ret = 0; + t_u16 cmd_len = 0; + t_u8 *buffer = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_disable_cs <0/1>\n"); + exit(1); + } + + cmd_len = sizeof(tdls_disable_cs); + + buffer = (t_u8 *)malloc(cmd_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, cmd_len); + param_buf = (tdls_disable_cs *)buffer; + param_buf->action = ACTION_TDLS_CS_DISABLE; + + param_buf->data = (t_u16)A2HEXDECIMAL(argv[3]); + if ((param_buf->data != 0) && (param_buf->data != 1)) { + printf("ERR:Incorrect arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_disable_cs <0/1>\n"); + goto done; + } + hexdump("tdls_disable_cs", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS disable channel switch successful.\n"); + } else { + printf("ERR:TDLS disable channel switch failed.\n"); + } + +done: + if (buffer) + free(buffer); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_stop_channel_switch + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_stop_channel_switch(int argc, char *argv[]) +{ + tdls_stop_chan_switch *param_buf = NULL; + char *line = NULL; + FILE *config_file = NULL; + int li = 0, ret = 0, cmd_found = 0; + char *args[30] = {NULL}, *pos = NULL, mac_addr[21] = {0}; + t_u8 peer_mac[ETH_ALEN]; + t_u16 cmd_len = 0; + t_u8 *buffer = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_stop_channel_switch \n"); + exit(1); + } + + cmd_len = sizeof(tdls_stop_chan_switch); + + buffer = (t_u8 *)malloc(cmd_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, cmd_len); + param_buf = (tdls_stop_chan_switch *)buffer; + param_buf->action = ACTION_TDLS_STOP_CHAN_SWITCH; + + /* Check if file exists */ + config_file = fopen(argv[3], "r"); + if (config_file == NULL) { + printf("\nERR:Config file can not open.\n"); + free(buffer); + return MLAN_STATUS_FAILURE; + } + 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)) { + if (!cmd_found && strncmp(args[0], argv[2], strlen(args[0]))) + continue; + + cmd_found = 1; + + if (strcmp(args[0], "PeerMAC") == 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; + } + memcpy(param_buf->peer_mac, peer_mac, ETH_ALEN); + } else if (strcmp(args[0], "}") == 0 && cmd_found) { + break; + } + } + hexdump("tdls_stop_channel_switch", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS stop channel switch successful.\n"); + } else { + printf("ERR:TDLS stop channel switch failed.\n"); + } + +done: + if (config_file != NULL) + fclose(config_file); + if (buffer) + free(buffer); + if (line) + free(line); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_cs_params + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_cs_params(int argc, char *argv[]) +{ + tdls_cs_params *param_buf = NULL; + char *line = NULL; + FILE *config_file = NULL; + int li = 0, ret = 0, cmd_found = 0; + char *args[30] = {NULL}, *pos = NULL; + t_u16 cmd_len = 0; + t_u8 *buffer = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_cs_params \n"); + exit(1); + } + + cmd_len = sizeof(tdls_cs_params); + + buffer = (t_u8 *)malloc(cmd_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, cmd_len); + param_buf = (tdls_cs_params *)buffer; + param_buf->action = ACTION_TDLS_CS_PARAMS; + + /* Check if file exists */ + config_file = fopen(argv[3], "r"); + if (config_file == NULL) { + printf("\nERR:Config file can not open.\n"); + free(buffer); + return MLAN_STATUS_FAILURE; + } + 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)) { + if (!cmd_found && strncmp(args[0], argv[2], strlen(args[0]))) + continue; + + cmd_found = 1; + + if (strcmp(args[0], "UnitTime") == 0) { + param_buf->unit_time = (t_u8)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "ThresholdOtherLink") == 0) { + param_buf->threshold_otherlink = + (t_u8)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "ThresholdDirectLink") == 0) { + param_buf->threshold_directlink = + (t_u8)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "}") == 0 && cmd_found) { + break; + } + } + hexdump("tdls_cs_params", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS set channel switch parameters successful.\n"); + } else { + printf("ERR:TDLS set channel switch parameters failed.\n"); + } +done: + if (config_file != NULL) + fclose(config_file); + if (buffer) + free(buffer); + if (line) + free(line); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_debug + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_debug(int argc, char *argv[]) +{ + int ret = 0; + tdls_debug *param_buf = NULL; + t_u16 cmd_len = 0; + t_u8 *buffer = NULL; + t_u16 action = 0, value = 0; + + /* Check arguments */ + if (argc < 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_debug \n"); + exit(1); + } + + cmd_len = sizeof(tdls_debug); + + /* wrong_bss */ + if (!strcmp(argv[3], "wrong_bss")) { + cmd_len += sizeof(t_u16); + action = ACTION_TDLS_DEBUG_WRONG_BSS; + if (argc < 5) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_debug wrong_bss <0/1>\n"); + exit(1); + } + value = (t_u16)A2HEXDECIMAL(argv[4]); + } + /* same link */ + else if (!strcmp(argv[3], "setup_existing_link")) { + cmd_len += sizeof(t_u16); + action = ACTION_TDLS_DEBUG_SETUP_SAME_LINK; + if (argc < 5) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_debug setup_existing_link <0/1>\n"); + exit(1); + } + value = (t_u16)A2HEXDECIMAL(argv[4]); + } + /* fail_setup_confirm */ + else if (!strcmp(argv[3], "fail_setup_confirm")) { + cmd_len += sizeof(t_u16); + action = ACTION_TDLS_DEBUG_FAIL_SETUP_CONFIRM; + if (argc < 5) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_debug fail_setup_confirm <0/1>\n"); + exit(1); + } + value = (t_u16)A2HEXDECIMAL(argv[4]); + } + /* setup prohibited*/ + else if (!strcmp(argv[3], "setup_with_prohibited")) { + cmd_len += sizeof(t_u16); + action = ACTION_TDLS_DEBUG_SETUP_PROHIBITED; + if (argc < 5) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_debug setup_with_prohibited <0/1>\n"); + exit(1); + } + value = (t_u16)A2HEXDECIMAL(argv[4]); + } + /* setup higher/lower mac */ + else if (!strcmp(argv[3], "higher_lower_mac")) { + cmd_len += sizeof(t_u16); + action = ACTION_TDLS_DEBUG_HIGHER_LOWER_MAC; + if (argc < 5) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_debug higher_lower_mac <0/1>\n"); + exit(1); + } + value = (t_u16)A2HEXDECIMAL(argv[4]); + } + /* ignore key lifetime expiry */ + else if (!strcmp(argv[3], "ignore_key_expiry")) { + cmd_len += sizeof(t_u16); + action = ACTION_TDLS_DEBUG_IGNORE_KEY_EXPIRY; + if (argc < 5) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_debug ignore_key_expiry <0/1>\n"); + exit(1); + } + value = (t_u16)A2HEXDECIMAL(argv[4]); + } + /* allow weak security */ + else if (!strcmp(argv[3], "allow_weak_security")) { + cmd_len += sizeof(t_u16); + action = ACTION_TDLS_DEBUG_ALLOW_WEAK_SECURITY; + if (argc < 5) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_debug allow_weak_security <0/1>\n"); + exit(1); + } + value = (t_u16)A2HEXDECIMAL(argv[4]); + } + /* stop RX */ + else if (!strcmp(argv[3], "stop_rx")) { + cmd_len += sizeof(t_u16); + action = ACTION_TDLS_DEBUG_STOP_RX; + if (argc < 5) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_debug stop_rx <0/1>\n"); + exit(1); + } + value = (t_u16)A2HEXDECIMAL(argv[4]); + } + /* Immediate return */ + else if (!strcmp(argv[3], "cs_im_return")) { + cmd_len += sizeof(t_u16); + action = ACTION_TDLS_DEBUG_CS_RET_IM; + if (argc < 5) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanconfig mlanX tdls_debug cs_im_return <0/1>\n"); + exit(1); + } + value = (t_u16)A2HEXDECIMAL(argv[4]); + } else { + printf("ERR:Incorrect command!\n"); + exit(1); + } + + buffer = (t_u8 *)malloc(cmd_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + return -1; + } + memset(buffer, 0, cmd_len); + param_buf = (tdls_debug *)buffer; + param_buf->action = action; + memcpy(param_buf->data, &value, sizeof(value)); + + hexdump("tdls_debug", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS debug request successful.\n"); + } else { + printf("ERR:TDLS debug request failed.\n"); + } + + if (buffer) + free(buffer); + 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_ARPFILTER: + process_arpfilter(argc, argv); + break; + case CMD_CFG_DATA: + process_cfg_data(argc, argv); + break; + 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; + case CMD_TDLS_CONF: + process_tdls_config(argc, argv); + break; + case CMD_TDLS_INFO: + process_tdls_setinfo(argc, argv); + break; + case CMD_TDLS_DISCOVERY: + process_tdls_discovery(argc, argv); + break; + case CMD_TDLS_SETUP: + process_tdls_setup(argc, argv); + break; + case CMD_TDLS_TEARDOWN: + process_tdls_teardown(argc, argv); + break; + case CMD_TDLS_POWERMODE: + process_tdls_powermode(argc, argv); + break; + case CMD_TDLS_LINK_STATUS: + process_tdls_link_status(argc, argv); + break; + case CMD_TDLS_CHANNEL_SWITCH: + process_tdls_channel_switch(argc, argv); + break; + case CMD_TDLS_STOP_CHAN_SWITCH: + process_tdls_stop_channel_switch(argc, argv); + break; + case CMD_TDLS_CS_PARAMS: + process_tdls_cs_params(argc, argv); + break; + case CMD_TDLS_CS_DISABLE: + process_tdls_disable_channel_switch(argc, argv); + break; + case CMD_TDLS_DEBUG: + process_tdls_debug(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/mapp/mlanconfig/mlanconfig.h b/mapp/mlanconfig/mlanconfig.h new file mode 100644 index 0000000..795ab13 --- /dev/null +++ b/mapp/mlanconfig/mlanconfig.h @@ -0,0 +1,796 @@ +/** @file mlanconfig.h + * + * @brief This file contains definitions for application + * + * + * Copyright 2008-2021 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) + +/** band BG */ +#define BAND_BG 0 +/** band A */ +#define BAND_A 1 +/** secondary channel is above */ +#define SECOND_CHANNEL_ABOVE 0x1 +/** secondary channel is below */ +#define SECOND_CHANNEL_BELOW 0x3 +/** NO PERIODIC SWITCH */ +#define NO_PERIODIC_SWITCH 0 +/** Enable periodic channel switch */ +#define ENABLE_PERIODIC_SWITCH 1 +/** Min channel value for BG band */ +#define MIN_BG_CHANNEL 1 +/** Max channel value for BG band */ +#define MAX_BG_CHANNEL 14 +/** Max channel value for A band */ +#define MIN_A_CHANNEL 36 +/** Max channel value for A band */ +#define MAX_A_CHANNEL 252 + +/** Host Command ioctl number */ +#define TDLS_IOCTL (SIOCDEVPRIVATE + 5) +/** TDLS action definitions */ +/** Action ID for TDLS config */ +#define ACTION_TDLS_CONFIG 0x0000 +/** Action ID for TDLS setinfo request */ +#define ACTION_TDLS_SETINFO 0x0001 +/** Action ID for TDLS Discovery request */ +#define ACTION_TDLS_DISCOVERY 0x0002 +/** Action ID for TDLS setup request */ +#define ACTION_TDLS_SETUP 0x0003 +/** Action ID for TDLS Teardown request */ +#define ACTION_TDLS_TEARDOWN 0x0004 +/** Action ID for TDLS power mode */ +#define ACTION_TDLS_POWER_MODE 0x0005 +/**Action ID for init TDLS Channel Switch*/ +#define ACTION_TDLS_INIT_CHAN_SWITCH 0x06 +/** Action ID for stop TDLS Channel Switch */ +#define ACTION_TDLS_STOP_CHAN_SWITCH 0x07 +/** Action ID for configure CS related parameters */ +#define ACTION_TDLS_CS_PARAMS 0x08 +/** Action ID for TDLS Disable Channel switch */ +#define ACTION_TDLS_CS_DISABLE 0x09 +/** Action ID for TDLS Link status */ +#define ACTION_TDLS_LINK_STATUS 0x000A +/** Action ID for TDLS CS immediate return */ +#define ACTION_TDLS_DEBUG_CS_RET_IM 0xFFF7 +/** Action ID for TDLS Stop RX */ +#define ACTION_TDLS_DEBUG_STOP_RX 0xFFF8 +/** Action ID for TDLS Allow weak security */ +#define ACTION_TDLS_DEBUG_ALLOW_WEAK_SECURITY 0xFFF9 +/** Action ID for TDLS Ignore key lifetime expiry */ +#define ACTION_TDLS_DEBUG_IGNORE_KEY_EXPIRY 0xFFFA +/** Action ID for TDLS Higher/Lower mac Test */ +#define ACTION_TDLS_DEBUG_HIGHER_LOWER_MAC 0xFFFB +/** Action ID for TDLS Prohibited Test */ +#define ACTION_TDLS_DEBUG_SETUP_PROHIBITED 0xFFFC +/** Action ID for TDLS Existing link Test */ +#define ACTION_TDLS_DEBUG_SETUP_SAME_LINK 0xFFFD +/** Action ID for TDLS Fail Setup Confirm */ +#define ACTION_TDLS_DEBUG_FAIL_SETUP_CONFIRM 0xFFFE +/** Action ID for TDLS WRONG BSS Test */ +#define ACTION_TDLS_DEBUG_WRONG_BSS 0xFFFF + +/** TLV type : Rates */ +#define TLV_TYPE_RATES 0x0001 +/** TLV type : Domain */ +#define TLV_TYPE_DOMAIN 0x0007 +/** TLV type : Supported channels */ +#define TLV_TYPE_SUPPORTED_CHANNELS 0x0024 +/** TLV type : HT Capabilities */ +#define TLV_TYPE_HT_CAP 0x002d +/** TLV type : Qos Info */ +#define TLV_TYPE_QOSINFO 0x002e +/** TLV type : RSN IE */ +#define TLV_TYPE_RSN_IE 0x0030 +/** TLV type : extended supported rates */ +#define TLV_EXTENDED_SUPPORTED_RATES 0x0032 +/** TLV type : timeout interval */ +#define TLV_TIMEOUT_INTERVAL 0x0038 +/** TLV type : Regulatory classes */ +#define TLV_TYPE_REGULATORY_CLASSES 0x003b +/** TLV type : HT Information */ +#define TLV_TYPE_HT_INFO 0x003d +/** TLV type : 20/40 BSS Coexistence */ +#define TLV_TYPE_2040BSS_COEXISTENCE 0x0048 +/** TLv Type : Link identifier */ +#define TLV_LINK_IDENTIFIER 0x0065 +/** TLV type : Extended capabilities */ +#define TLV_TYPE_EXTCAP 0x007f + +/** TLV type : VHT capabilities */ +#define TLV_TYPE_VHT_CAP 0x00BF +/** TLV type : VHT operations */ +#define TLV_TYPE_VHT_OPER 0x00C0 +/** Length of Basic MCS MAP */ +#define VHT_MCS_MAP_LEN 2 + +/** Country code length */ +#define COUNTRY_CODE_LEN 3 +/** Length of Group Cipher Suite */ +#define GROUP_CIPHER_SUITE_LEN 4 +/** Length of Pairwise Cipher Suite */ +#define PAIRWISE_CIPHER_SUITE_LEN 4 +/** Length of AKM Suite */ +#define AKM_SUITE_LEN 4 +/** PMKID length */ +#define PMKID_LEN 16 +/** Maximum number of pairwise_cipher_suite */ +#define MAX_PAIRWISE_CIPHER_SUITE_COUNT 2 +/** Maximum number of AKM suite */ +#define MAX_AKM_SUITE_COUNT 2 +/** Maximum number of PMKID list count */ +#define MAX_PMKID_COUNT 2 +/** Length of MCS set */ +#define MCS_SET_LEN 16 +/** Version in RSN IE */ +#define VERSION_RSN_IE 0x0001 + +/** tdls setinfo */ +typedef struct _tdls_setinfo { + /** Action */ + t_u16 action; + /** (TLV + capInfo) length */ + t_u16 tlv_len; + /** Capability Info */ + t_u16 cap_info; + /** tdls info */ + t_u8 tlv_buffer[]; +} __ATTRIB_PACK__ tdls_setinfo; + +/** tdls discovery */ +typedef struct _tdls_discovery { + /** Action */ + t_u16 action; + /** Peer MAC address */ + t_u8 peer_mac[ETH_ALEN]; +} __ATTRIB_PACK__ tdls_discovery; + +/** tdls link status */ +typedef struct _tdls_links_status { + /** Action */ + t_u16 action; +} __ATTRIB_PACK__ tdls_link_status; + +/** tdls discovery response */ +typedef struct _tdls_discovery_resp { + /** Action */ + t_u16 action; + /** payload length */ + t_u16 payload_len; + /** peer mac Address */ + t_u8 peer_mac[ETH_ALEN]; + /** RSSI */ + signed char rssi; + /** Cap Info */ + t_u16 cap_info; + /** TLV buffer */ + t_u8 tlv_buffer[]; +} __ATTRIB_PACK__ tdls_discovery_resp; + +/** tdls each link rate information */ +typedef struct _tdls_link_rate_info { + /** Tx Data Rate */ + t_u8 tx_data_rate; + /** Tx Rate HT info*/ + t_u8 tx_rate_htinfo; +} __ATTRIB_PACK__ tdls_link_rate_info; + +/** tdls each link status */ +typedef struct _tdls_each_link_status { + /** peer mac Address */ + t_u8 peer_mac[ETH_ALEN]; + /** Link Flags */ + t_u8 link_flags; + /** Traffic Status */ + t_u8 traffic_status; + /** Tx Failure Count */ + t_u8 tx_fail_count; + /** Channel Number */ + t_u32 active_channel; + /** Last Data RSSI in dBm */ + t_s16 data_rssi_last; + /** Last Data NF in dBm */ + t_s16 data_nf_last; + /** AVG DATA RSSI in dBm */ + t_s16 data_rssi_avg; + /** AVG DATA NF in dBm */ + t_s16 data_nf_avg; + union { + /** tdls rate info */ + tdls_link_rate_info rate_info; + /** final rate value*/ + t_u16 final_data_rate; + } u; + /** Security Method */ + t_u8 security_method; + /** Key Lifetime */ + t_u32 key_lifetime; + /** Key Length */ + t_u8 key_length; + /** actual key */ + t_u8 key[]; +} __ATTRIB_PACK__ tdls_each_link_status; + +/** tdls link status response */ +typedef struct _tdls_link_status_resp { + /** Action */ + t_u16 action; + /** payload length */ + t_u16 payload_len; + /** number of links */ + t_u8 active_links; + /** structure for link status */ + tdls_each_link_status link_stats[1]; +} __ATTRIB_PACK__ tdls_link_status_resp; + +/** tdls setup */ +typedef struct _tdls_setup { + /** Action */ + t_u16 action; + /** Peer MAC address */ + t_u8 peer_mac[ETH_ALEN]; + /** Time to wait for response from peer*/ + t_u32 wait_time; + /** Key Life Time */ + t_u32 key_life_time; +} __ATTRIB_PACK__ tdls_setup; + +/** tdls tear down */ +typedef struct _tdls_tear_down { + /** Action */ + t_u16 action; + /** Peer MAC address */ + t_u8 peer_mac[ETH_ALEN]; + /** Reason code */ + t_u16 reason_code; +} __ATTRIB_PACK__ tdls_teardown; + +/** tdls power mode */ +typedef struct _tdls_power_mode { + /** Action */ + t_u16 action; + /** Peer MAC address */ + t_u8 peer_mac[ETH_ALEN]; + /** Power mode */ + t_u16 power_mode; +} __ATTRIB_PACK__ tdls_powermode; + +/** tdls channel switch info */ +typedef struct _tdls_channel_switch { + /** Action */ + t_u16 action; + /** peer mac Address */ + t_u8 peer_mac[ETH_ALEN]; + /** Channel Switch primary channel no */ + t_u8 primary_channel; + /** Channel Switch secondary channel offset */ + t_u8 secondary_channel_offset; + /** Channel Switch Band */ + t_u8 band; + /** Channel Switch time*/ + t_u16 switch_time; + /** Channel Switch timeout*/ + t_u16 switch_timeout; + /** Channel Regulatory class*/ + t_u8 regulatory_class; + /** Channel Switch periodicity*/ + t_u8 periodicity; +} __ATTRIB_PACK__ tdls_channel_switch; + +/** tdls stop channel switch */ +typedef struct _tdls_stop_chan_switch { + /** Action */ + t_u16 action; + /** Peer MAC address */ + t_u8 peer_mac[ETH_ALEN]; +} __ATTRIB_PACK__ tdls_stop_chan_switch; + +/** tdls disable channel switch */ +typedef struct _tdls_disable_cs { + /** Action */ + t_u16 action; + /** Data*/ + t_u16 data; +} __ATTRIB_PACK__ tdls_disable_cs, tdls_config; + +/** tdls channel switch parameters */ +typedef struct _tdls_cs_params { + /** Action */ + t_u16 action; + /** unit time, multiples of 10ms */ + t_u8 unit_time; + /** threshold for other link */ + t_u8 threshold_otherlink; + /** threshold for direct link */ + t_u8 threshold_directlink; +} __ATTRIB_PACK__ tdls_cs_params; + +/** tdls debug */ +typedef struct _tdls_debug { + /** Action */ + t_u16 action; + /** Data */ + t_u8 data[]; +} __ATTRIB_PACK__ tdls_debug; + +/** TLV header */ +#define TLVHEADER /** Tag */ \ + t_u16 tag; \ + /** Length */ \ + t_u16 length + +/** Length of TLV header */ +#define TLVHEADER_LEN 4 + +/** Data structure for subband set */ +typedef struct _IEEEtypes_SubbandSet_t { + /** First channel */ + t_u8 first_chan; + /** Number of channels */ + t_u8 no_of_chan; + /** Maximum Tx power */ + t_u8 max_tx_pwr; +} __ATTRIB_PACK__ IEEEtypes_SubbandSet_t, *pIEEEtypes_SubbandSet_t; + +/** tlvbuf_DomainParamSet_t */ +typedef struct _tlvbuf_DomainParamSet { + /** Header */ + TLVHEADER; + /** Country code */ + t_u8 country_code[COUNTRY_CODE_LEN]; + /** Set of subbands */ + IEEEtypes_SubbandSet_t sub_band[]; +} __ATTRIB_PACK__ tlvbuf_DomainParamSet_t; + +/** 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; + +/** Qos Info TLV */ +typedef struct _tlvbuf_QosInfo_t { + /** Header */ + TLVHEADER; + /** QosInfo */ + union { + /** QosInfo bitfield */ + IEEEtypes_WmmQosInfo_t qos_info; + /** QosInfo byte */ + t_u8 qos_info_byte; + } u; +} __ATTRIB_PACK__ tlvbuf_QosInfo_t; + +/** HT Capabilities Data */ +typedef struct _HTCap_t { + /** HT Capabilities Info field */ + t_u16 ht_cap_info; + /** A-MPDU Parameters field */ + t_u8 ampdu_param; + /** Supported MCS Set field */ + t_u8 supported_mcs_set[16]; + /** HT Extended Capabilities field */ + t_u16 ht_ext_cap; + /** Transmit Beamforming Capabilities field */ + t_u32 tx_bf_cap; + /** Antenna Selection Capability field */ + t_u8 asel; +} __ATTRIB_PACK__ HTCap_t, *pHTCap_t; + +/** HT Information Data */ +typedef struct _HTInfo_t { + /** Primary channel */ + t_u8 pri_chan; + /** Field 2 */ + t_u8 field2; + /** Field 3 */ + t_u16 field3; + /** Field 4 */ + t_u16 field4; + /** Bitmap indicating MCSs supported by all HT STAs in the BSS */ + t_u8 basic_mcs_set[16]; +} __ATTRIB_PACK__ HTInfo_t, *pHTInfo_t; + +/** 20/40 BSS Coexistence Data */ +typedef struct _BSSCo2040_t { + /** 20/40 BSS Coexistence value */ + t_u8 bss_co_2040_value; +} __ATTRIB_PACK__ BSSCo2040_t, *pBSSCo2040_t; + +/** HT Capabilities element */ +typedef struct _tlvbuf_HTCap_t { + /** Header */ + TLVHEADER; + /** HTCap struct */ + HTCap_t ht_cap; +} __ATTRIB_PACK__ tlvbuf_HTCap_t; + +/** HT Information element */ +typedef struct _tlvbuf_HTInfo_t { + /** Header */ + TLVHEADER; + + /** HTInfo struct */ + HTInfo_t ht_info; +} __ATTRIB_PACK__ tlvbuf_HTInfo_t; + +/** VHT MCS rate set field, refer to 802.11ac */ +typedef struct _VHT_MCS_set { + t_u16 rx_mcs_map; + t_u16 rx_max_rate; /* bit 29-31 reserved */ + t_u16 tx_mcs_map; + t_u16 tx_max_rate; /* bit 61-63 reserved */ +} __ATTRIB_PACK__ VHT_MCS_set_t, *pVHT_MCS_set_t; + +typedef struct _VHT_capa { + t_u32 vht_cap_info; + VHT_MCS_set_t mcs_sets; +} __ATTRIB_PACK__ VHT_capa_t, *pVHT_capa_t; + +/** VHT Capabilities IE */ +typedef struct _IEEEtypes_VHTCap_t { + /** Header */ + TLVHEADER; + /** VHTInfo struct */ + VHT_capa_t vht_cap; +} __ATTRIB_PACK__ tlvbuf_VHTCap_t, *ptlvbuf_VHTCap_t; + +/** VHT Operations IE */ +typedef struct _IEEEtypes_VHTOprat_t { + /** Header */ + TLVHEADER; + /** VHTOpra struct */ + t_u8 chan_width; + t_u8 chan_cf1; + t_u8 chan_cf2; + /** Basic MCS set map, each 2 bits stands for a Nss */ + t_u8 basic_mcs_map[VHT_MCS_MAP_LEN]; +} __ATTRIB_PACK__ tlvbuf_VHTOpra_t, *ptlvbuf_VHTOpra_t; + +/** 20/40 BSS Coexistence element */ +typedef struct _tlvbuf_2040BSSCo_t { + /** Header */ + TLVHEADER; + + /** BSSCo2040_t struct */ + BSSCo2040_t bss_co_2040; +} __ATTRIB_PACK__ tlvbuf_2040BSSCo_t; + +/** Extended Capabilities element */ +typedef struct _tlvbuf_ExtCap_t { + /** Header */ + TLVHEADER; + /** ExtCap_t struct */ + t_u8 ext_cap[]; +} __ATTRIB_PACK__ tlvbuf_ExtCap_t; + +/** tlvbuf_RatesParamSet_t */ +typedef struct _tlvbuf_RatesParamSet_t { + /** Header */ + TLVHEADER; + /** Rates */ + t_u8 rates[]; +} __ATTRIB_PACK__ tlvbuf_RatesParamSet_t; + +/* IEEE Supported Channel sub-band description (7.3.2.19) */ +/* Sub-band description used in the supported channels element. */ +typedef struct _IEEEtypes_SupportChan_Subband_t { + t_u8 start_chan; /**< Starting channel in the subband */ + t_u8 num_chans; /**< Number of channels in the subband */ + +} __ATTRIB_PACK__ IEEEtypes_SupportChan_Subband_t; + +/* IEEE Supported Channel element (7.3.2.19) */ +/** + * Sent in association requests. Details the sub-bands and number + * of channels supported in each subband + */ +typedef struct _tlvbuf_SupportedChannels_t { + /** Header */ + TLVHEADER; /**< IEEE Element ID = 36 */ + /** Configured sub-bands information in the element */ + IEEEtypes_SupportChan_Subband_t subband[]; +} __ATTRIB_PACK__ tlvbuf_SupportedChannels_t; + +/* IEEE Supported Regulatory Classes description (7.3.2.54) */ +typedef struct _IEEEtypes_RegulatoryClass_t { + /** current regulatory class */ + t_u8 cur_regulatory_class; + /** supported regulatory class list */ + t_u8 regulatory_classes_list[]; + +} __ATTRIB_PACK__ IEEEtypes_RegulatoryClass_t; + +/* IEEE Supported Regulatory Classes TLV (7.3.2.54) */ +typedef struct _tlvbuf_RegulatoryClass_t { + /** Header */ + TLVHEADER; /**< IEEE Element ID = 59 */ + /** supported regulatory class */ + IEEEtypes_RegulatoryClass_t regulatory_class; +} __ATTRIB_PACK__ tlvbuf_RegulatoryClass_t; + +/** tlvbuf_RsnParamSet_t */ +typedef struct _tlvbuf_RsnParamSet_t { + /** Header */ + TLVHEADER; + /** Version */ + t_u16 version; + /** Group Cipher Suite */ + t_u8 group_cipher_suite[4]; + /** Pairwise Cipher Suite count */ + t_u16 pairwise_cipher_count; + /** Pairwise Cipher Suite */ + t_u8 pairwise_cipher_suite[]; +#if 0 + /* below is only to keep a reference + * of the remaining elements in the + * structure + */ + /** AKM Suite Sount */ + t_u16 akm_suite_count; + /** AKM Suite */ + t_u8 akm_suite[0]; + /** RSN Capability */ + t_u16 rsn_capability; + /** PMKID Count */ + t_u16 pmkid_count; + /** PMKID list */ + t_u8 pmkid_list[]; +#endif +} __ATTRIB_PACK__ tlvbuf_RsnParamSet_t; + +extern t_s32 sockfd; /**< socket */ +extern t_s8 dev_name[IFNAMSIZ]; /**< device name */ + +#endif /* _MLANCONFIG_H_ */ diff --git a/mapp/mlanconfig/mlanhostcmd.c b/mapp/mlanconfig/mlanhostcmd.c new file mode 100644 index 0000000..e7ba640 --- /dev/null +++ b/mapp/mlanconfig/mlanhostcmd.c @@ -0,0 +1,969 @@ +/** @file mlanhostcmd.c + * + * @brief This file contains mlanconfig helper functions + * + * + * Copyright 2008-2021 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((unsigned char)*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((unsigned char)*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((unsigned char)*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((unsigned char)*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 ARP filter buffer + * @param fp File handler + * @param buf A pointer to the buffer + * @param length A pointer to the length of buffer + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +int prepare_arp_filter_buffer(FILE *fp, t_u8 *buf, t_u16 *length) +{ + t_s8 line[256], *pos; + int ln = 0; + int ret = MLAN_STATUS_SUCCESS; + int arpfilter_found = 0; + + memset(buf, 0, MRVDRV_SIZE_OF_CMD_BUFFER); + while ((pos = mlan_config_get_line(fp, line, sizeof(line), &ln))) { + if (strcmp(pos, "arpfilter={") == 0) { + arpfilter_found = 1; + mlan_get_hostcmd_data(fp, &ln, buf, length); + break; + } + } + if (!arpfilter_found) { + fprintf(stderr, + "mlanconfig: 'arpfilter' not found in conf file"); + ret = MLAN_STATUS_FAILURE; + } + 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/mapp/mlanconfig/mlanhostcmd.h b/mapp/mlanconfig/mlanhostcmd.h new file mode 100644 index 0000000..adfa872 --- /dev/null +++ b/mapp/mlanconfig/mlanhostcmd.h @@ -0,0 +1,387 @@ +/** @file mlanhostcmd.h + * + * @brief This file contains command structures for mlanconfig application + * + * + * Copyright 2008-2021 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 (4 * 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_arp_filter_buffer(FILE *fp, t_u8 *buf, t_u16 *length); +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/mapp/mlanconfig/mlanmisc.c b/mapp/mlanconfig/mlanmisc.c new file mode 100644 index 0000000..82f1377 --- /dev/null +++ b/mapp/mlanconfig/mlanmisc.c @@ -0,0 +1,1024 @@ +/** @file mlanmisc.c + * + * @brief Program to prepare command buffer + * + * + * Copyright 2008-2021 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 +********************************************************/ + +/** + * @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"); + ret = -ENOMEM; + goto done; + } + 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 < (int)bss_info->ssid_len; + ssid_idx++) { + if (isprint((unsigned char)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((unsigned char)*( + 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((unsigned char)*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(( + unsigned char)*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/mapp/mlanconfig/mlanmisc.h b/mapp/mlanconfig/mlanmisc.h new file mode 100644 index 0000000..3c60cdb --- /dev/null +++ b/mapp/mlanconfig/mlanmisc.h @@ -0,0 +1,668 @@ +/** @file mlanmisc.h + * + * @brief This file contains command definitions for application + * + * + * Copyright 2014-2021 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 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; + +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/mapp/mlanconfig/mlanoffload.c b/mapp/mlanconfig/mlanoffload.c new file mode 100644 index 0000000..c3d4c7e --- /dev/null +++ b/mapp/mlanconfig/mlanoffload.c @@ -0,0 +1,3021 @@ +/** @file mlanoffload.c + * + * @brief This files contains mlanconfig offload command handling. + * + * + * Copyright 2008-2021 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 "mlanconfig.h" +#include "mlanhostcmd.h" +#include "mlanmisc.h" +#include "mlanoffload.h" + +/******************************************************** + Local Variables +********************************************************/ + +typedef struct { + t_u8 chanNum; /**< Channel Number */ + t_u8 chanLoad; /**< Channel Load fraction */ + t_s16 anpi; /**< Channel ANPI */ + +} ChanRptInfo_t; + +/** 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"}; + +/******************************************************** + 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; + if (((ptr = strrchr(data, '\r')) == NULL) && + ((ptr = strrchr(data, '\n')) == 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 ((ptr = strstr(line, "}")) != NULL) { + /* end of network */ + break; + + } else if (line[0] == '#') { + /* comments go ahead */ + continue; + + } else if ((ptr = strstr(line, "bssid=")) != NULL) { + 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 ((ptr = strstr(line, "ssid=")) != NULL) { + ptr = ptr + strlen("ssid="); + + if ((*ptr != '"') || + ((eptr = 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 ((ptr = strstr(line, "psk=")) != NULL) { + ptr = ptr + strlen("psk="); + if (*ptr != '"') { + p_head->psk_config = 1; + strncpy((char *)p_head->psk, ptr, KEY_LEN); + } else { + if ((eptr = strrchr(ptr + 1, '"')) == NULL) { + fprintf(stderr, + "passphrase not within quotes.\n"); + break; + } + p_head->passphrase_len = + MIN(PHRASE_LEN, eptr - ptr - 1); + strncpy(p_head->passphrase, ptr + 1, + p_head->passphrase_len); + } + } else if ((ptr = strstr(line, "wep_key")) != NULL) { + ptr = ptr + strlen("wep_key"); + key_cnt = atoi(ptr); + ptr++; + if (*ptr != '=') { + fprintf(stderr, + "invalid wep_key, missing =.\n"); + break; + } + if (((eptr = strrchr(ptr + 1, '\r')) == NULL) && + ((eptr = strrchr(ptr + 1, '\n')) == NULL)) { + fprintf(stderr, + "missing EOL from the wep_key config\n"); + break; + } + ptr++; + if (*ptr == '"') { + if ((eptr = strrchr(ptr + 1, '"')) == 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 ((ptr = strstr(line, "key_mgmt=")) != NULL) { + ptr = ptr + strlen("key_mgmt="); + if ((eptr = strstr(ptr, "WPA-EAP")) != NULL) { + p_head->key_mgmt |= + PROFILE_DB_KEY_MGMT_IEEE8021X; + } + if ((eptr = strstr(ptr, "WPA-PSK")) != NULL) { + p_head->key_mgmt |= PROFILE_DB_KEY_MGMT_PSK; + } + if ((eptr = strstr(ptr, "FT-EAP")) != NULL) { + p_head->key_mgmt |= + PROFILE_DB_KEY_MGMT_FT_IEEE8021X; + } + if ((eptr = strstr(ptr, "FT-PSK")) != NULL) { + p_head->key_mgmt |= PROFILE_DB_KEY_MGMT_FT_PSK; + } + if ((eptr = strstr(ptr, "WPA-EAP-SHA256")) != NULL) { + p_head->key_mgmt |= + PROFILE_DB_KEY_MGMT_SHA256_IEEE8021X; + } + if ((eptr = strstr(ptr, "WPA-PSK-SHA256")) != NULL) { + p_head->key_mgmt |= + PROFILE_DB_KEY_MGMT_SHA256_PSK; + } + if ((eptr = strstr(ptr, "CCKM")) != NULL) { + p_head->key_mgmt |= PROFILE_DB_KEY_MGMT_CCKM; + } + if ((eptr = strstr(ptr, "NONE")) != NULL) { + p_head->key_mgmt |= PROFILE_DB_KEY_MGMT_NONE; + } + } else if ((ptr = strstr(line, "proto=")) != NULL) { + ptr = ptr + strlen("proto="); + if ((eptr = strstr(ptr, "WPA")) != NULL) { + p_head->protocol |= PROFILE_DB_PROTO_WPA; + } + + if ((eptr = strstr(ptr, "RSN")) != NULL) { + p_head->protocol |= PROFILE_DB_PROTO_WPA2; + } + } else if ((ptr = strstr(line, "pairwise=")) != NULL) { + ptr = ptr + strlen("pairwise="); + if ((eptr = strstr(ptr, "CCMP")) != NULL) { + p_head->pairwise_cipher |= + PROFILE_DB_CIPHER_CCMP; + } + if ((eptr = strstr(ptr, "TKIP")) != NULL) { + p_head->pairwise_cipher |= + PROFILE_DB_CIPHER_TKIP; + } + } else if ((ptr = strstr(line, "groupwise=")) != NULL) { + ptr = ptr + strlen("groupwise="); + if ((eptr = strstr(ptr, "CCMP")) != NULL) { + p_head->groupwise_cipher |= + PROFILE_DB_CIPHER_CCMP; + } + if ((eptr = strstr(ptr, "TKIP")) != NULL) { + p_head->groupwise_cipher |= + PROFILE_DB_CIPHER_TKIP; + } + } else if ((ptr = strstr(line, "wep_tx_keyidx=")) != NULL) { + ptr = ptr + strlen("wep_tx_keyidx="); + p_head->wep_key_idx = atoi(ptr); + } else if ((ptr = strstr(line, "roaming=")) != NULL) { + ptr = ptr + strlen("roaming="); + p_head->roaming = atoi(ptr); + } else if ((ptr = strstr(line, "ccx=")) != NULL) { + ptr = ptr + strlen("ccx="); + p_head->ccx = atoi(ptr); + } else if ((ptr = strstr(line, "mode=")) != NULL) { + 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 i = 0; + t_u8 *buffer; + t_u16 temp, tempc; + FILE *fp; + char line[0x100]; + struct iwreq iwr; + profile_entry_t *p_head = NULL; + int ioctl_val, subioctl_val, ret = MLAN_STATUS_SUCCESS; + + if ((fp = fopen(filename, "r")) == NULL) { + perror("fopen"); + fprintf(stderr, "Cannot open file %s\n", filename); + return MLAN_STATUS_FAILURE; + } + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + fclose(fp); + return -EOPNOTSUPP; + } + + buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); + if (buffer == NULL) { + printf("Error: allocate memory for profile command failed\n"); + fclose(fp); + return -ENOMEM; + } + + 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"); + free(buffer); + fclose(fp); + return MLAN_STATUS_FAILURE; + } + 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 + */ + i = 0; + memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); + + /* Cmd Header : Command */ + tempc = cpu_to_le16(HostCmd_CMD_PROFILEDB); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i = sizeof(HostCmd_DS_GEN); + + /* set action as set */ + tempc = cpu_to_le16(HostCmd_ACT_GEN_SET); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + + /* ssid */ + tempc = cpu_to_le16(TLV_TYPE_SSID); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + temp = strlen((char *)p_head->ssid); + tempc = cpu_to_le16(temp); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + memcpy((void *)(buffer + i), p_head->ssid, temp); + i += temp; + + if (memcmp(p_head->bssid, "\x00\x00\x00\x00\x00\x00", + ETH_ALEN)) { + /* bssid */ + tempc = cpu_to_le16(TLV_TYPE_BSSID); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + temp = ETH_ALEN; + tempc = cpu_to_le16(temp); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + memcpy((void *)(buffer + i), p_head->bssid, temp); + i += temp; + } + + /* proto */ + if (p_head->protocol == 0) { + p_head->protocol = 0xFFFF; + } + + tempc = cpu_to_le16(TLV_TYPE_PROTO); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + temp = 2; + tempc = cpu_to_le16(temp); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + memcpy((buffer + i), &(p_head->protocol), temp); + i += temp; + + /* key_mgmt */ + if (p_head->key_mgmt == 0) { + p_head->key_mgmt = 0xFFFF; + } + + tempc = cpu_to_le16(TLV_TYPE_AKMP); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + temp = 2; + tempc = cpu_to_le16(temp); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + memcpy((buffer + i), &(p_head->key_mgmt), temp); + i += 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((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + temp = 2; + tempc = cpu_to_le16(temp); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + buffer[i] = p_head->pairwise_cipher; + i += 1; + buffer[i] = p_head->groupwise_cipher; + i += 1; + + if (p_head->passphrase_len) { + /* passphrase */ + tempc = cpu_to_le16(TLV_TYPE_PASSPHRASE); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + temp = p_head->passphrase_len; + tempc = cpu_to_le16(temp); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + memcpy((void *)(buffer + i), p_head->passphrase, temp); + i += temp; + } + + if (p_head->psk_config) { + /* psk method */ + tempc = cpu_to_le16(TLV_TYPE_PMK); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + temp = 32; + tempc = cpu_to_le16(temp); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + memcpy((void *)(buffer + i), p_head->psk, temp); + i += temp; + } + + for (ret = 0; ret < WEP_KEY_CNT; ret++) { + if (p_head->wep_key_len[ret]) { + /* TAG_WEP_KEY */ + tempc = cpu_to_le16(TLV_TYPE_WEP_KEY); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + /* wep_key_len + sizeof(keyIndex) + + * sizeof(IsDefault) */ + temp = p_head->wep_key_len[ret]; + tempc = cpu_to_le16(temp + 2); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + *(buffer + i) = ret; + i += 1; + *(buffer + i) = (ret == p_head->wep_key_idx); + i += 1; + memcpy((void *)(buffer + i), + p_head->wep_key[ret], temp); + i += temp; + } + } + + if (p_head->roaming | p_head->ccx) { + tempc = cpu_to_le16(TLV_TYPE_OFFLOAD_ENABLE); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + temp = 2; + tempc = cpu_to_le16(temp); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 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((buffer + i), &tempc, sizeof(t_u16)); + i += temp; + } + + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.pointer = (caddr_t)buffer; + iwr.u.data.length = i; + iwr.u.data.flags = 0; + + /* update length in the header now */ + temp = i; + tempc = cpu_to_le16(temp); + memcpy((buffer + 2), &tempc, sizeof(t_u16)); + + fprintf(stdout, "Downloading profile: %s ... ", p_head->ssid); + fflush(stdout); + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("hostcmd : profiledb ioctl"); + } else { + /* + * Header: Cmd, Size, Seqnum, Result + * Offload of Result = 2+2+2 = 6 + */ + memcpy(&temp, ((t_u8 *)iwr.u.data.pointer) + 6, + sizeof(t_u16)); + temp = le16_to_cpu(temp); + if (temp != 0) { + printf("hostcmd : profiledb ioctl failure, code %d\n", + temp); + if (p_head) + free(p_head); + break; + } + } + + fprintf(stdout, "done.\n"); + + if (p_head) + free(p_head); + } + + free(buffer); + fclose(fp); + return ret; +} + +static int chanrpt_getValues(t_u8 chanNum, t_u16 startFreq, t_u32 duration, + t_s16 *pAnpi, t_u8 *pLoadPercent) +{ + int ioctl_val, subioctl_val, cmdlen; + struct iwreq iwr; + t_u8 *buf; + t_u8 *pByte; + int respLen; + MrvlIEtypes_Data_t *pTlvHdr; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_CHAN_RPT_RSP *pChanRptRsp; + HostCmd_DS_CHAN_RPT_REQ *pChanRptReq; + + MrvlIEtypes_ChanRptChanLoad_t *pLoadRpt; + MrvlIEtypes_ChanRptNoiseHist_t *pNoiseRpt; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + buf = (t_u8 *)calloc(sizeof(t_u8), 1000); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + cmdlen = sizeof(HostCmd_DS_GEN) + sizeof(HostCmd_DS_CHAN_RPT_REQ); + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = cpu_to_le16(HostCmd_CMD_CHAN_REPORT_REQUEST); + hostcmd->size = cmdlen; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pChanRptReq = (HostCmd_DS_CHAN_RPT_REQ *)(buf + sizeof(HostCmd_DS_GEN)); + pChanRptRsp = (HostCmd_DS_CHAN_RPT_RSP *)(buf + sizeof(HostCmd_DS_GEN)); + + memset((void *)pChanRptReq, 0x00, sizeof(HostCmd_DS_CHAN_RPT_REQ)); + + pChanRptReq->chanDesc.chanNum = chanNum; + pChanRptReq->chanDesc.startFreq = startFreq; + pChanRptReq->millisecDwellTime = duration; + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmdlen; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: chanrpt hostcmd ioctl"); + free(buf); + return -EFAULT; + } + + /* 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; + + 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_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)); + respLen -= (pTlvHdr->header.len + sizeof(pTlvHdr->header)); + respLen = (respLen > 0) ? respLen : 0; + } + + free(buf); + + return MLAN_STATUS_SUCCESS; +} + +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"); +} + +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); +} + +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); +} + +static void chanrpt_graph(void) +{ + int idx; + ChanRptInfo_t chanRpt[14]; + + 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); + } + + chanrpt_print_anpi(chanRpt, NELEMENTS(chanRpt)); + chanrpt_print_chanLoad(chanRpt, NELEMENTS(chanRpt)); +} + +static void chanrpt_graph_loop(boolean loopOnLoad, boolean loopOnAnpi, + int loops) +{ + int idx; + int loopsLeft; + ChanRptInfo_t chanRpt[14]; + ChanRptInfo_t chanRptAvg[14]; + + 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); + } + + idx = 0; + loopsLeft = loops; + + while (loopsLeft) { + chanRpt[idx].chanNum = idx + 1; + chanrpt_getValues(idx + 1, 0, 75, &chanRpt[idx].anpi, + &chanRpt[idx].chanLoad); + + 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); + + if (loopOnAnpi) { + chanrpt_print_anpi(chanRpt, NELEMENTS(chanRpt)); + } + + if (loopOnLoad) { + chanrpt_print_chanLoad(chanRpt, NELEMENTS(chanRpt)); + } + + idx = (idx + 1) % NELEMENTS(chanRpt); + + if (idx == 0) { + loopsLeft--; + } + } + + if (loopOnAnpi) { + chanrpt_print_anpi(chanRptAvg, NELEMENTS(chanRptAvg)); + } + + if (loopOnLoad) { + chanrpt_print_chanLoad(chanRptAvg, NELEMENTS(chanRptAvg)); + } +} + +/******************************************************** + Global Functions +********************************************************/ + +/** + * @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 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, + MAX(((unsigned int)sub_cmd[idx].match_len), + strlen(argv[3]))) == 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 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 ioctl_val, subioctl_val; + struct iwreq iwr; + HostCmd_DS_GEN *hostcmd; + t_u8 *buf, *pos; + HostCmd_DS_MEASUREMENT_Timing *cfg_timing_cmd; + MrvlIETypes_MeasTiming_t *cfg_timing_tlv; + int idx, cmd_len, rsp_len; + t_u8 sel = 0; + t_u16 tlv_len = 0; + + 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; + } + + timing_sel_t sel_str[] = {{"disconnected", 1}, + {"adhoc", 1}, + {"fullpower", 1}, + {"ieeeps", 1}, + {"periodic", 1}}; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = (sizeof(HostCmd_DS_GEN) + sizeof(t_u16) + + sizeof(MrvlIETypes_MeasTiming_t) * 4); + + buf = (t_u8 *)calloc(sizeof(t_u8), cmd_len); + + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = cpu_to_le16(HostCmd_CMD_MEASUREMENT_TIMING_CONFIG); + hostcmd->size = (sizeof(HostCmd_DS_GEN) + sizeof(t_u16)); + hostcmd->seq_num = 0; + hostcmd->result = 0; + pos = buf + sizeof(HostCmd_DS_GEN); + + cfg_timing_cmd = (HostCmd_DS_MEASUREMENT_Timing *)pos; + if (argc == 7) { + cfg_timing_cmd->action = cpu_to_le16(HostCmd_ACT_GEN_SET); + } else { + cfg_timing_cmd->action = cpu_to_le16(HostCmd_ACT_GEN_GET); + } + + cfg_timing_tlv = (MrvlIETypes_MeasTiming_t *)cfg_timing_cmd->tlv_buffer; + + if (argc == 7) { + cfg_timing_tlv->header.type = + cpu_to_le16(TLV_TYPE_MEASUREMENT_TIMING); + cfg_timing_tlv->header.len = + cpu_to_le16(sizeof(MrvlIETypes_MeasTiming_t) - + sizeof(cfg_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]); + free(buf); + return -EINVAL; + } + + cfg_timing_tlv->mode = cpu_to_le32(sel); + cfg_timing_tlv->max_off_channel = cpu_to_le32(atoi(argv[5])); + cfg_timing_tlv->max_on_channel = cpu_to_le32(atoi(argv[6])); + + hostcmd->size += sizeof(MrvlIETypes_MeasTiming_t); + } + + hostcmd->size = cpu_to_le16(hostcmd->size); + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: measurement timing ioctl"); + free(buf); + return -EFAULT; + } + + 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 -= (sizeof(HostCmd_DS_GEN) + sizeof(t_u16)); + pos = buf + sizeof(HostCmd_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: + cfg_timing_tlv = (MrvlIETypes_MeasTiming_t *)pos; + tlv_len = le16_to_cpu(cfg_timing_tlv->header.len); + printf("%15s | %14d | %13d\n", + sel_str[le32_to_cpu(cfg_timing_tlv->mode) - 1] + .str, + (int)le32_to_cpu( + cfg_timing_tlv->max_off_channel), + (int)le32_to_cpu( + cfg_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"); + free(buf); + + return MLAN_STATUS_SUCCESS; +} + +/** + * @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[]) +{ + unsigned int mac[ETH_ALEN] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; + int tmpIdx; + char *ssid = NULL; + struct iwreq iwr; + int i = 0; + t_u8 *buffer; + t_u16 temp, tempc; + int ioctl_val, subioctl_val; + + if (argc < 4) { + fprintf(stderr, "Invalid number of argument!\n"); + return MLAN_STATUS_FAILURE; + } + /* initialize BSSID with all FFs, indicate flushall */ + for (i = 0; i < ETH_ALEN; i++) { + mac[i] = 0xFF; + } + + 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"); + return -ENOMEM; + } + printf("Driver profile delete request\n"); + } else { + printf("Error: missing required option for command (ssid, bssid)\n"); + return -ENOMEM; + } + } else if (!strncmp(argv[3], "flush", sizeof("flush"))) { + printf("Driver profile flush request\n"); + } else { + return profile_read_download(argv[3]); + } + + buffer = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER); + if (buffer == NULL) { + printf("Error: allocate memory for profile command failed\n"); + return -ENOMEM; + } + + i = 0; + memset(buffer, 0, MRVDRV_SIZE_OF_CMD_BUFFER); + + /* Cmd Header : Command */ + tempc = cpu_to_le16(HostCmd_CMD_PROFILEDB); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i = sizeof(HostCmd_DS_GEN); + + /* set action as del */ + tempc = cpu_to_le16(HostCmd_ACT_GEN_REMOVE); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + + /* ssid */ + if (ssid) { + printf("For ssid %s\n", ssid); + tempc = cpu_to_le16(TLV_TYPE_SSID); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + temp = strlen((char *)ssid); + tempc = cpu_to_le16(temp); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + memcpy((void *)(buffer + i), ssid, temp); + i += 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((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + temp = ETH_ALEN; + tempc = cpu_to_le16(temp); + memcpy((buffer + i), &tempc, sizeof(t_u16)); + i += 2; + for (tmpIdx = 0; (unsigned int)tmpIdx < NELEMENTS(mac); + tmpIdx++) { + buffer[i + tmpIdx] = (t_u8)mac[tmpIdx]; + } + i += temp; + } + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + free(buffer); + return -EOPNOTSUPP; + } + + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.pointer = (caddr_t)buffer; + iwr.u.data.length = i; + iwr.u.data.flags = 0; + + /* update length in the header now */ + temp = i; + tempc = cpu_to_le16(temp); + memcpy((buffer + 2), &tempc, sizeof(t_u16)); + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("hostcmd : profiledb ioctl"); + free(buffer); + return MLAN_STATUS_FAILURE; + } else { + /* + * Header: Cmd, Size, Seqnum, Result + * Offload of Result = 2+2+2 = 6 + */ + memcpy(&temp, ((t_u8 *)iwr.u.data.pointer) + 6, sizeof(t_u16)); + temp = le16_to_cpu(temp); + if (temp != 0) { + printf("hostcmd : profiledb ioctl failure, code %d\n", + temp); + free(buffer); + return MLAN_STATUS_FAILURE; + } + } + + free(buffer); + return MLAN_STATUS_SUCCESS; +} + +int process_chanrpt(int argc, char *argv[]) +{ + int ioctl_val, subioctl_val, cmdlen; + struct iwreq iwr; + t_u8 *buf; + t_u8 *pByte; + t_u8 numBins; + t_u8 idx; + int respLen; + 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; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + buf = (t_u8 *)calloc(sizeof(t_u8), 1000); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + cmdlen = sizeof(HostCmd_DS_GEN) + sizeof(HostCmd_DS_CHAN_RPT_REQ); + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = cpu_to_le16(HostCmd_CMD_CHAN_REPORT_REQUEST); + hostcmd->size = cmdlen; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pChanRptReq = (HostCmd_DS_CHAN_RPT_REQ *)(buf + sizeof(HostCmd_DS_GEN)); + pChanRptRsp = (HostCmd_DS_CHAN_RPT_RSP *)(buf + sizeof(HostCmd_DS_GEN)); + + memset((void *)pChanRptReq, 0x00, sizeof(HostCmd_DS_CHAN_RPT_REQ)); + + if ((argc != 5) && (argc != 6)) { + printf("\nchanrpt syntax: chanrpt [sFreq]\n\n"); + free(buf); + return MLAN_STATUS_FAILURE; + } + + 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])); + } + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmdlen; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: chanrpt hostcmd ioctl"); + free(buf); + return -EFAULT; + } + + /* 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, + le16_to_cpu(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"); + + free(buf); + + return MLAN_STATUS_SUCCESS; +} + +int process_chan_graph(int argc, char *argv[]) +{ + if (argc == 3) { + chanrpt_graph(); + } else if (argc == 5) { + if (strcmp(argv[3], "load") == 0) { + chanrpt_graph_loop(TRUE, FALSE, atoi(argv[4])); + } else if (strcmp(argv[3], "anpi") == 0) { + chanrpt_graph_loop(FALSE, TRUE, atoi(argv[4])); + } else if (strcmp(argv[3], "anpiload") == 0) { + chanrpt_graph_loop(TRUE, TRUE, atoi(argv[4])); + } else { + printf("\nchangraph syntax:" + " changraph \n\n"); + } + } + + return MLAN_STATUS_SUCCESS; +} + +int process_assoc_timing(int argc, char *argv[]) +{ + int ioctl_val, subioctl_val, cmdlen; + struct iwreq iwr; + t_u8 *buf, *pos; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_AssociationTiming_t *assoctiming; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmdlen = + sizeof(HostCmd_DS_GEN) + sizeof(HostCmd_DS_AssociationTiming_t); + + buf = (t_u8 *)calloc(sizeof(t_u8), cmdlen); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = cpu_to_le16(HostCmd_CMD_ASSOCIATION_TIMING); + hostcmd->size = cpu_to_le16(cmdlen); + hostcmd->seq_num = 0; + hostcmd->result = 0; + pos = buf + sizeof(HostCmd_DS_GEN); + + assoctiming = (HostCmd_DS_AssociationTiming_t *)pos; + assoctiming->Action = cpu_to_le16(HostCmd_ACT_GEN_GET); + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmdlen; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: hostcmd ioctl"); + free(buf); + return -EFAULT; + } + + 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; + } + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmdlen; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: hostcmd ioctl"); + free(buf); + return -EFAULT; + } + } + + 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(""); + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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(void) +{ + int ioctl_val, subioctl_val; + struct iwreq iwr; + t_u8 assocRspBuffer[500]; /* Stack buf can be as large as ioctl allows + */ + IEEEtypes_AssocRsp_t *pAssocRsp; + + pAssocRsp = (IEEEtypes_AssocRsp_t *)assocRspBuffer; + + if (get_priv_ioctl("getassocrsp", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.pointer = (caddr_t)assocRspBuffer; + iwr.u.data.length = sizeof(assocRspBuffer); + iwr.u.data.flags = subioctl_val; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: getassocrsp ioctl"); + return -EFAULT; + } + + if (iwr.u.data.length) { + printf("getassocrsp: Status[%d], Cap[0x%04x]:\n", + pAssocRsp->StatusCode, *(t_u16 *)&pAssocRsp->Capability); + hexdump(NULL, assocRspBuffer, iwr.u.data.length, ' '); + } else { + printf("getassocrsp: \n"); + } + + return MLAN_STATUS_SUCCESS; +} + +int process_link_stats(int argc, char *argv[]) +{ + int ioctl_val, subioctl_val, cmdlen; + struct iwreq iwr; + t_u8 *buf; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_LINK_STATS_SUMMARY *pStats; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmdlen = sizeof(HostCmd_DS_GEN) + sizeof(HostCmd_DS_LINK_STATS_SUMMARY); + buf = (t_u8 *)calloc(sizeof(t_u8), cmdlen); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + 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; + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmdlen; + + pStats = + (HostCmd_DS_LINK_STATS_SUMMARY *)(buf + sizeof(HostCmd_DS_GEN)); + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: linkstats hostcmd ioctl"); + free(buf); + return -EFAULT; + } + + if (argc > 3) { + if (memcmp(argv[3], "line", strlen("line")) != 0) { + printf(" dur bc bm br bs" + " rp rr rs" + " tp ta tf tr" + " vo vi be bk\n"); + } + + printf("%6u " + "%3u %3u %3d %2d " + "%5u %3d %3d" + " %5u %5u %5u %3s" + " %3u %3u %3u %3u\n", + (int)le32_to_cpu(pStats->timeSinceLastQuery_ms), + + le16_to_cpu(pStats->bcnCnt), + le16_to_cpu(pStats->bcnMiss), + le16_to_cpu(pStats->bcnRssiAvg), + le16_to_cpu(pStats->bcnSnrAvg), + + (int)le32_to_cpu(pStats->rxPkts), + le16_to_cpu(pStats->rxRssiAvg), + le16_to_cpu(pStats->rxSnrAvg), + + (int)le32_to_cpu(pStats->txPkts), + (int)le32_to_cpu(pStats->txAttempts), + (int)le32_to_cpu(pStats->txFailures), + rateIdStr[pStats->txInitRate], + + (int)le32_to_cpu(pStats->txQueueDelay[WMM_AC_VO]) / 1000, + (int)le32_to_cpu(pStats->txQueueDelay[WMM_AC_VI]) / 1000, + (int)le32_to_cpu(pStats->txQueueDelay[WMM_AC_BE]) / 1000, + (int)le32_to_cpu(pStats->txQueueDelay[WMM_AC_BK]) / + 1000); + } else { + printf("duration: %u\n", + (int)le32_to_cpu(pStats->timeSinceLastQuery_ms)); + + printf("bcnCnt: %u\n", le16_to_cpu(pStats->bcnCnt)); + printf("bcnMiss: %u\n", le16_to_cpu(pStats->bcnMiss)); + printf("bcnRssiAvg: %d\n", le16_to_cpu(pStats->bcnRssiAvg)); + printf("bcnSnrAvg: %d\n", le16_to_cpu(pStats->bcnSnrAvg)); + + printf("rxPkts: %u\n", (int)le32_to_cpu(pStats->rxPkts)); + printf("rxRssiAvg: %d\n", le16_to_cpu(pStats->rxRssiAvg)); + printf("rxSnrAvg: %d\n", le16_to_cpu(pStats->rxSnrAvg)); + + printf("txPkts: %u\n", (int)le32_to_cpu(pStats->txPkts)); + printf("txAttempts: %u\n", + (int)le32_to_cpu(pStats->txAttempts)); + printf("txFailures: %u\n", + (int)le32_to_cpu(pStats->txFailures)); + printf("txInitRate: %s\n", rateIdStr[pStats->txInitRate]); + + printf("txAcVo: %u [ %u ]\n", + le16_to_cpu(pStats->txQueuePktCnt[WMM_AC_VO]), + (int)le32_to_cpu(pStats->txQueueDelay[WMM_AC_VO]) / + 1000); + printf("txAcVi: %u [ %u ]\n", + le16_to_cpu(pStats->txQueuePktCnt[WMM_AC_VI]), + (int)le32_to_cpu(pStats->txQueueDelay[WMM_AC_VI]) / + 1000); + printf("txAcBe: %u [ %u ]\n", + le16_to_cpu(pStats->txQueuePktCnt[WMM_AC_BE]), + (int)le32_to_cpu(pStats->txQueueDelay[WMM_AC_BE]) / + 1000); + printf("txAcBk: %u [ %u ]\n", + le16_to_cpu(pStats->txQueuePktCnt[WMM_AC_BK]), + (int)le32_to_cpu(pStats->txQueueDelay[WMM_AC_BK]) / + 1000); + } + + free(buf); + + return MLAN_STATUS_SUCCESS; +} + +#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(t_u8 *cmdBuf, int tlv_size, t_u8 displayResult) +{ + HostCmd_DS_OPCHAN_CHANGROUP_CONFIG *pChanGroup; + HostCmd_DS_GEN *hostcmd; + int ioctl_val, subioctl_val; + + struct iwreq iwr; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return; + } + + pChanGroup = + (HostCmd_DS_OPCHAN_CHANGROUP_CONFIG *)(cmdBuf + + sizeof(HostCmd_DS_GEN)); + + hostcmd = (HostCmd_DS_GEN *)cmdBuf; + hostcmd->command = cpu_to_le16(HostCmd_CMD_OPCHAN_CHANGROUP_CONFIG); + hostcmd->seq_num = 0; + hostcmd->result = 0; + hostcmd->size = cpu_to_le16(sizeof(HostCmd_DS_GEN) + + sizeof(pChanGroup->action) + tlv_size); + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)cmdBuf; + iwr.u.data.length = sizeof(HostCmd_DS_GEN) + 2000; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: changroup hostcmd ioctl"); + return; + } + + if (displayResult) { + dumpCgBuf(pChanGroup->tlv_buffer, + (le16_to_cpu(hostcmd->size) - sizeof(HostCmd_DS_GEN) - + sizeof(pChanGroup->action))); + } +} + +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 ioctl_val, subioctl_val, cmdlen; + struct iwreq iwr; + t_u8 *buf; + 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"); + return -EOPNOTSUPP; + } + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmdlen = sizeof(HostCmd_DS_GEN) + 2000; + buf = (t_u8 *)calloc(sizeof(t_u8), cmdlen); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmdlen; + + pOpChanConfig = + (HostCmd_DS_OPCHAN_CONFIG *)(buf + sizeof(HostCmd_DS_GEN)); + + if ((argc == 4) && (strcmp(argv[3], "clear") != 0)) { + /* With 4 arguments cmd must be: mlanconfig mlan0 opchan clear + */ + printf("Invalid command arguments.\n"); + free(buf); + return -EOPNOTSUPP; + } else if (argc == 5) { + pOpChanConfig->action = cpu_to_le16(HostCmd_ACT_GEN_SET); + + if ((fp = fopen(argv[3], "r")) == NULL) { + fprintf(stderr, "Cannot open file %s\n", argv[3]); + free(buf); + exit(1); + } + + 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 = + le16_to_cpu(sizeof(ccTlv) - sizeof(ccTlv.header)); + ccTlv.header.type = le16_to_cpu(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]); + free(buf); + if (fp) + fclose(fp); + return -EFAULT; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + 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); + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: changroup hostcmd ioctl"); + free(buf); + if (fp) + fclose(fp); + return -EFAULT; + } + + 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); + } + + free(buf); + if (fp) + fclose(fp); + return 0; +} + +int process_changroup(int argc, char *argv[]) +{ + char line[100]; + char section[80]; + int ln = 0; + t_u8 sectionFound = 0; + int totalTlvBytes = 0; + FILE *fp = NULL; + t_u8 *cmdBuf; + + 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 */ + return -EOPNOTSUPP; + } + + cmdBuf = (t_u8 *)calloc(sizeof(t_u8), sizeof(HostCmd_DS_GEN) + 2000); + if (!cmdBuf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + pChanGroup = + (HostCmd_DS_OPCHAN_CHANGROUP_CONFIG *)(cmdBuf + + sizeof(HostCmd_DS_GEN)); + + if (argc == 5) { + pChanGroup->action = cpu_to_le16(HostCmd_ACT_GEN_SET); + + if ((fp = fopen(argv[3], "r")) == NULL) { + fprintf(stderr, "Cannot open file %s\n", argv[3]); + free(cmdBuf); + exit(1); + } + + 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]); + if (fp) + fclose(fp); + free(cmdBuf); + return 0; + } + + execChanGroupCmd(cmdBuf, 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(cmdBuf, totalTlvBytes, TRUE); + } + } + + free(cmdBuf); + + if (fp) + fclose(fp); + puts(""); + + return 0; +} +#endif + +/* +** Process mlanconfig fcontrol command: +** +** mlanconfig 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 ioctl_val, subioctl_val, cmdlen; + struct iwreq iwr; + t_u8 idx; + t_u8 *buf; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_OFFLOAD_FEATURE_CONTROL *pFcontrol; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmdlen = sizeof(HostCmd_DS_GEN) + 100; + buf = (t_u8 *)calloc(sizeof(t_u8), cmdlen); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + pFcontrol = + (HostCmd_DS_OFFLOAD_FEATURE_CONTROL *)(buf + + sizeof(HostCmd_DS_GEN)); + + if (argc < 4) { + printf("Wrong number of arguments\n"); + free(buf); + return -EINVAL; + } + + pFcontrol->controlSelect = atoi(argv[3]); + cmdlen = (sizeof(HostCmd_DS_GEN) + sizeof(pFcontrol->controlSelect)); + + for (idx = 4; idx < argc; idx++) { + pFcontrol->controlBitmap[idx - 4] = a2hex_or_atoi(argv[idx]); + cmdlen++; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = cpu_to_le16(HostCmd_CMD_OFFLOAD_FEATURE_CONTROL); + hostcmd->size = cpu_to_le16(cmdlen); + hostcmd->seq_num = 0; + hostcmd->result = 0; + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmdlen; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: fcontrol hostcmd ioctl"); + free(buf); + return -EFAULT; + } + + cmdlen = (le16_to_cpu(hostcmd->size) - sizeof(HostCmd_DS_GEN)); + + printf("Control[%d]", pFcontrol->controlSelect); + cmdlen--; + + for (idx = 0; idx < cmdlen; idx++) { + printf("\t0x%02x", pFcontrol->controlBitmap[idx]); + } + + printf("\n"); + + free(buf); + + return MLAN_STATUS_SUCCESS; +} + +/* +** Process mlanconfig iapp command: +** +** mlanconfig 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 ioctl_val, subioctl_val, cmdlen; + struct iwreq iwr; + t_u8 idx; + t_u8 *buf; + t_u8 fixlen; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_IAPP_PROXY *pIappProxy; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmdlen = sizeof(HostCmd_DS_GEN) + sizeof(HostCmd_DS_IAPP_PROXY) + 100; + buf = (t_u8 *)calloc(sizeof(t_u8), cmdlen); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + pIappProxy = (HostCmd_DS_IAPP_PROXY *)(buf + sizeof(HostCmd_DS_GEN)); + + if (argc < 6) { + printf("Wrong number of arguments\n"); + free(buf); + return -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 = (sizeof(HostCmd_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 = (HostCmd_DS_GEN *)buf; + 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); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmdlen; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: iapp hostcmd ioctl"); + free(buf); + return -EFAULT; + } + + 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"); + + free(buf); + + return MLAN_STATUS_SUCCESS; +} + +int process_dscpmap(int argc, char *argv[]) +{ + int ioctl_val, subioctl_val; + struct iwreq iwr; + unsigned int dscp, tid, idx; + t_u8 dscp_map[64]; + + if (get_priv_ioctl("dscpmap", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + /* Get the current dscp -> TID mapping table in the driver */ + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.pointer = (caddr_t)dscp_map; + iwr.u.data.length = 0; + iwr.u.data.flags = subioctl_val; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: dscpmap ioctl"); + return -EFAULT; + } + + 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 >= 0) && (tid < 8)) { + dscp_map[idx - 3] = tid; + } + } + } else { + /* 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 >= 0) && + (tid < 8)) { + dscp_map[dscp] = tid; + } + } + } + + /* Set the updated dscp -> TID mapping table */ + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.pointer = (caddr_t)dscp_map; + iwr.u.data.length = sizeof(dscp_map); + iwr.u.data.flags = subioctl_val; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: dscpmap ioctl"); + return -EFAULT; + } + + /* Display the active dscp -> TID mapping table */ + if (iwr.u.data.length) { + printf("DscpMap:\n"); + hexdump(NULL, dscp_map, iwr.u.data.length, ' '); + } + + return MLAN_STATUS_SUCCESS; +} + +int process_rf_tx_power(int argc, char *argv[]) +{ + int ioctl_val, subioctl_val, cmdlen; + struct iwreq iwr; + t_u8 *buf; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_802_11_RF_TX_POWER *pRfTxPower; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmdlen = sizeof(HostCmd_DS_GEN) + sizeof(HostCmd_DS_802_11_RF_TX_POWER); + buf = (t_u8 *)calloc(sizeof(t_u8), cmdlen); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + pRfTxPower = + (HostCmd_DS_802_11_RF_TX_POWER *)(buf + sizeof(HostCmd_DS_GEN)); + + memset(pRfTxPower, 0x00, sizeof(HostCmd_DS_802_11_RF_TX_POWER)); + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = cpu_to_le16(HostCmd_CMD_802_11_RF_TX_POWER); + hostcmd->size = cpu_to_le16(cmdlen); + hostcmd->seq_num = 0; + hostcmd->result = 0; + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmdlen; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: hostcmd ioctl"); + free(buf); + return -EFAULT; + } + + 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"); + + free(buf); + + return MLAN_STATUS_SUCCESS; +} + +int process_authenticate(int argc, char *argv[]) +{ + int ioctl_val, subioctl_val, cmdlen; + struct iwreq iwr; + t_u8 *buf; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_802_11_AUTHENTICATE *pAuth; + unsigned int mac[ETH_ALEN]; + int tmpIdx; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + if (argc != 4) { + printf("Wrong number of arguments\n"); + return -EINVAL; + } + + cmdlen = + sizeof(HostCmd_DS_GEN) + sizeof(HostCmd_DS_802_11_AUTHENTICATE); + buf = (t_u8 *)calloc(sizeof(t_u8), cmdlen); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + pAuth = (HostCmd_DS_802_11_AUTHENTICATE *)(buf + + sizeof(HostCmd_DS_GEN)); + + 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 = (HostCmd_DS_GEN *)buf; + hostcmd->command = cpu_to_le16(HostCmd_CMD_802_11_AUTHENTICATE); + hostcmd->size = cpu_to_le16(cmdlen); + hostcmd->seq_num = 0; + hostcmd->result = 0; + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmdlen; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: hostcmd ioctl"); + free(buf); + return -EFAULT; + } + + free(buf); + + return MLAN_STATUS_SUCCESS; +} + +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("mlanconfig: 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("mlanconfig: 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 ioctl_val, subioctl_val, cmdlen; + struct iwreq iwr; + t_u8 *buf; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_CHAN_TRPC_CONFIG *pChanTrpc; + MrvlIEtypes_ChanTrpcCfg_t *pChanTrpcTlv; + int totalTlvBytes = 0; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmdlen = sizeof(HostCmd_DS_GEN) + 2000; + buf = (t_u8 *)calloc(sizeof(t_u8), cmdlen); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + pChanTrpc = + (HostCmd_DS_CHAN_TRPC_CONFIG *)(buf + sizeof(HostCmd_DS_GEN)); + pChanTrpc->action = cpu_to_le16(HostCmd_ACT_GEN_GET); + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = cpu_to_le16(HostCmd_CMD_CHAN_TRPC_CONFIG); + hostcmd->seq_num = 0; + hostcmd->result = 0; + hostcmd->size = + cpu_to_le16(sizeof(HostCmd_DS_GEN) + sizeof(pChanTrpc->action)); + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmdlen; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: chantrpc hostcmd ioctl"); + free(buf); + return -EFAULT; + } + + totalTlvBytes = + (le16_to_cpu(iwr.u.data.length) - 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; + } + + free(buf); + + return 0; +} + +int process_txpowdisp(int argc, char *argv[]) +{ + int ioctl_val, subioctl_val, cmdlen; + struct iwreq iwr; + t_u8 *buf; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_802_11_RF_TX_POWER *pRfTxPower; + RatePower_t ratePower[50]; + int rateIdx, rates; + int connected; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + buf = (t_u8 *)calloc(sizeof(t_u8), 2000); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + pRfTxPower = + (HostCmd_DS_802_11_RF_TX_POWER *)(buf + sizeof(HostCmd_DS_GEN)); + + memset(pRfTxPower, 0x00, sizeof(HostCmd_DS_802_11_RF_TX_POWER)); + + cmdlen = sizeof(HostCmd_DS_GEN) + sizeof(HostCmd_DS_802_11_RF_TX_POWER); + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = cpu_to_le16(HostCmd_CMD_802_11_RF_TX_POWER); + hostcmd->size = cpu_to_le16(cmdlen); + hostcmd->seq_num = 0; + hostcmd->result = 0; + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmdlen; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: hostcmd ioctl"); + free(buf); + return -EFAULT; + } + + 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"); + + free(buf); + + return MLAN_STATUS_SUCCESS; +} + +int process_tsf(int argc, char *argv[]) +{ + int ioctl_val, subioctl_val, cmdlen; + struct iwreq iwr; + t_u8 *buf; + HostCmd_DS_GEN *hostcmd; + int x; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmdlen = sizeof(HostCmd_DS_GEN) + sizeof(t_u64); + buf = (t_u8 *)calloc(sizeof(t_u8), cmdlen); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + memset(buf, 0x00, cmdlen); + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = cpu_to_le16(HostCmd_CMD_GET_TSF); + hostcmd->size = cpu_to_le16(cmdlen); + hostcmd->seq_num = 0; + hostcmd->result = 0; + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmdlen; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: hostcmd ioctl"); + free(buf); + return -EFAULT; + } + + printf("TSF="); + + for (x = 7; x >= 0; x--) { + printf("%02x", buf[sizeof(HostCmd_DS_GEN) + x]); + } + + puts("\n"); + + return 0; +} diff --git a/mapp/mlanconfig/mlanoffload.h b/mapp/mlanconfig/mlanoffload.h new file mode 100644 index 0000000..8f8587c --- /dev/null +++ b/mapp/mlanconfig/mlanoffload.h @@ -0,0 +1,560 @@ +/** @file mlanoffload.h + * + * @brief This files contains mlanconfig offload command handling. + * + * + * Copyright 2008-2021 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_ + +/** 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 { + t_u16 startFreq; + t_u8 chanWidth; + t_u8 chanNum; + +} __ATTRIB_PACK__ MrvlChannelDesc_t; + +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 { + 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 scanReqId; /**< Scan request id assigned in table */ +} __ATTRIB_PACK__ MrvlIEtypes_ChanRptBcn_t; + +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; + +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 + +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; + +/** 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_chan_graph(int argc, char *argv[]); +int process_assoc_timing(int argc, char *argv[]); +int process_get_assocrsp(void); +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_dscpmap(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[]); +int process_tsf(int argc, char *argv[]); + +#endif /* _MLANOFFLOAD_H_ */ diff --git a/mapp/mlanconfig/mlanregclass.c b/mapp/mlanconfig/mlanregclass.c new file mode 100644 index 0000000..ef7bf11 --- /dev/null +++ b/mapp/mlanconfig/mlanregclass.c @@ -0,0 +1,430 @@ +/** @file mlanregclass.c + * + * @brief This files contains mlanconfig regclass command handling. + * + * + * Copyright 2008-2021 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 "mlanconfig.h" +#include "mlanhostcmd.h" +#include "mlanmisc.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 ioctl_val, subioctl_val; + struct iwreq iwr; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_REGCLASS_GET_CHAN_TABLE *get_table; + t_u8 *buf, *pos; + int idx, cmd_len; + t_u16 regLimits; + boolean invalid_cmd = FALSE; + + buf = 0; + + if (argv[0] == NULL) { + invalid_cmd = TRUE; + } else { + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = sizeof(HostCmd_DS_GEN) + + sizeof(HostCmd_DS_REGCLASS_GET_CHAN_TABLE); + buf = (t_u8 *)calloc(sizeof(t_u8), cmd_len); + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = HostCmd_CMD_REGCLASS_CHAN_TABLE; + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + pos = buf + sizeof(HostCmd_DS_GEN); + + 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"); + if (buf) { + free(buf); + } + return MLAN_STATUS_FAILURE; + } + + hostcmd->command = cpu_to_le16(hostcmd->command); + hostcmd->size = cpu_to_le16(cmd_len); + + get_table->table_select = cpu_to_le16((t_u16)(get_table->table_select)); + + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + iwr.u.data.flags = 0; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: regClassIoctl ioctl"); + free(buf); + return -EFAULT; + } + + 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"); + + free(buf); + + return MLAN_STATUS_SUCCESS; +} + +/** + * @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 ioctl_val, subioctl_val, cmd_len; + struct iwreq iwr; + t_u8 *buf, *pos; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_REGCLASS_CONFIG_USER_TABLE *cfg_user_table; + + if (argv[0] == NULL) { + printf("\nCountry string not specified\n"); + return MLAN_STATUS_FAILURE; + } + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = sizeof(HostCmd_DS_GEN) + + sizeof(HostCmd_DS_REGCLASS_CONFIG_USER_TABLE); + buf = (t_u8 *)calloc(sizeof(t_u8), cmd_len); + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = HostCmd_CMD_REGCLASS_CONFIG_USER_TABLE; + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + 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))); + + hostcmd->command = cpu_to_le16(hostcmd->command); + hostcmd->size = cpu_to_le16(cmd_len); + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: regClassIoctl ioctl"); + free(buf); + return -EFAULT; + } + + 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)); + } + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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 ioctl_val, subioctl_val, cmd_len; + struct iwreq iwr; + t_u8 *buf, *pos; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_REGCLASS_MULTIDOMAIN_CONTROL *multidomain_ctrl; + boolean invalid_cmd = FALSE; + + if (argv[0] == NULL) { + invalid_cmd = TRUE; + } else { + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = sizeof(HostCmd_DS_GEN) + + sizeof(HostCmd_DS_REGCLASS_MULTIDOMAIN_CONTROL); + + buf = (t_u8 *)calloc(sizeof(t_u8), cmd_len); + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = HostCmd_CMD_REGCLASS_MULTIDOMAIN_CONTROL; + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + 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; + free(buf); + } + } + + if (invalid_cmd) { + printf("\nUnknown multiDomain command; valid [on, off]\n\n"); + return MLAN_STATUS_FAILURE; + } + + multidomain_ctrl->multidomain_enable = + cpu_to_le32(multidomain_ctrl->multidomain_enable); + + hostcmd->command = cpu_to_le16(hostcmd->command); + hostcmd->size = cpu_to_le16(cmd_len); + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: regClass ioctl"); + free(buf); + return -EFAULT; + } 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)); + } + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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/mapp/mlanconfig/mlanregclass.h b/mapp/mlanconfig/mlanregclass.h new file mode 100644 index 0000000..c782dab --- /dev/null +++ b/mapp/mlanconfig/mlanregclass.h @@ -0,0 +1,96 @@ +/** @file mlanregclass.h + * + * @brief This files contains mlanconfig regclass command handling. + * + * + * Copyright 2008-2021 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/mapp/mlanconfig/mlanroamagent.c b/mapp/mlanconfig/mlanroamagent.c new file mode 100644 index 0000000..57784e9 --- /dev/null +++ b/mapp/mlanconfig/mlanroamagent.c @@ -0,0 +1,3184 @@ +/** @file mlanroamagent.c + * + * @brief This files contains mlanconfig roamagent command handling. + * + * + * Copyright 2008-2021 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 "mlanconfig.h" +#include "mlanhostcmd.h" +#include "mlanmisc.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 ioctl_val, subioctl_val, cmd_len; + int failCount, failTimeThresh; + int state; + int i; + struct iwreq iwr; + t_u8 *buf, *pos, *tlvptr; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *statsthreshold; + MrvlIEtypes_FailureCount_t *pFailureCount; + MrvlIEtypesHeader_t *pTlvHdr; + + const char *states[] = {"Stable", "Degrading", "Unacceptable", + "Hardroam"}; + + state = STATE_HARDROAM; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = sizeof(HostCmd_DS_GEN) + sizeof(statsthreshold->action) + + sizeof(statsthreshold->State) + + sizeof(statsthreshold->Profile); + + buf = (t_u8 *)calloc(sizeof(t_u8), cmd_len); + if (!buf) { + puts("\nMemory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = + cpu_to_le16(HostCmd_CMD_ROAMAGENT_STATISTICS_THRESHOLD); + hostcmd->size = cpu_to_le16(cmd_len); + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + statsthreshold = (HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *)pos; + statsthreshold->action = cpu_to_le16(HostCmd_ACT_GEN_GET); + + /* Can be extended to all states later */ + for (state = STATE_HARDROAM - 1; state < STATE_HARDROAM; state++) { + statsthreshold->State = state + 1; + /* + * ENDIANNESS + */ + + /* + * Prepare wireless request struct and fire ioctl + */ + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: roamstatistics ioctl"); + free(buf); + return -EFAULT; + } + + 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); + } + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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 ioctl_val, subioctl_val, cmd_len; + int bcnmiss, state = STATE_HARDROAM, i; + struct iwreq iwr; + t_u8 *buf, *pos, *tlvptr; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *statsthreshold; + MrvlIEtypes_BeaconsMissed_t *pBeaconMissed; + MrvlIEtypesHeader_t *pTlvHdr; + + const char *states[] = {"Stable", "Degrading", "Unacceptable", + "Hardroam"}; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = sizeof(HostCmd_DS_GEN) + sizeof(statsthreshold->action) + + sizeof(statsthreshold->State) + + sizeof(statsthreshold->Profile); + + buf = (t_u8 *)calloc(sizeof(t_u8), cmd_len); + if (!buf) { + puts("\nMemory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = + cpu_to_le16(HostCmd_CMD_ROAMAGENT_STATISTICS_THRESHOLD); + hostcmd->size = cpu_to_le16(cmd_len); + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + statsthreshold = (HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *)pos; + statsthreshold->action = cpu_to_le16(HostCmd_ACT_GEN_GET); + + /* Can be extended to all states later */ + for (state = STATE_HARDROAM - 1; state < STATE_HARDROAM; state++) { + statsthreshold->State = state + 1; + /* + * ENDIANNESS + */ + + /* + * Prepare wireless request struct and fire ioctl + */ + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: beacon miss ioctl"); + free(buf); + return -EFAULT; + } + + 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); + } + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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 ioctl_val, subioctl_val, cmd_len, cmdresplen; + int state = 0, i = 0, profile = 1; + struct iwreq iwr; + t_u8 *buf, *pos; + 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 (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + 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]); + return MLAN_STATUS_FAILURE; + } + } + /* + * STATISTICS_THRESHOLD + */ + cmd_len = cmdresplen = + sizeof(HostCmd_DS_GEN) + sizeof(statsthreshold->action) + + sizeof(statsthreshold->State) + sizeof(statsthreshold->Profile); + if (type == RSSI_THRESHOLD) { + cmdresplen += sizeof(MrvlIEtypes_BeaconHighRssiThreshold_t) + + sizeof(MrvlIEtypes_BeaconLowRssiThreshold_t); + } else { + cmdresplen += sizeof(MrvlIEtypes_BeaconHighSnrThreshold_t) + + sizeof(MrvlIEtypes_BeaconLowSnrThreshold_t); + } + + buf = (t_u8 *)calloc(sizeof(t_u8), cmdresplen); + if (!buf) { + puts("\nMemory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = HostCmd_CMD_ROAMAGENT_STATISTICS_THRESHOLD; + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + statsthreshold = (HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *)pos; + statsthreshold->action = HostCmd_ACT_GEN_GET; + + 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 = HostCmd_CMD_ROAMAGENT_STATISTICS_THRESHOLD; + /* + * ENDIANNESS + */ + hostcmd->command = cpu_to_le16(hostcmd->command); + hostcmd->size = cpu_to_le16(cmd_len); + statsthreshold->action = cpu_to_le16(statsthreshold->action); + + /* + * Prepare wireless request struct and fire ioctl + */ + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: roamstatistics ioctl"); + free(buf); + return -EFAULT; + } + + 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)); + free(buf); + return MLAN_STATUS_FAILURE; + } + + 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(""); + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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 ioctl_val, cmd_len, cmdresplen, subioctl_val; + struct iwreq iwr; + t_u8 *buf, *pos; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_ASSESSMENT *pNborAssessment; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + /* + * NEIGHBOR_ASSESSMENT + */ + cmd_len = sizeof(HostCmd_DS_GEN); + cmd_len += sizeof(pNborAssessment->action); + + cmdresplen = sizeof(HostCmd_DS_GEN); + cmdresplen += sizeof(HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_ASSESSMENT); + + buf = (t_u8 *)calloc(sizeof(t_u8), cmdresplen); + if (!buf) { + puts("\nMemory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = HostCmd_CMD_ROAMAGENT_NEIGHBOR_ASSESSMENT; + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + pNborAssessment = (HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_ASSESSMENT *)pos; + pNborAssessment->action = HostCmd_ACT_GEN_GET; + + /* + * ENDIANNESS + */ + hostcmd->command = cpu_to_le16(hostcmd->command); + hostcmd->size = cpu_to_le16(cmd_len); + pNborAssessment->action = cpu_to_le16(pNborAssessment->action); + + /* + * Prepare wireless request struct and fire ioctl + */ + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: GetNeibhorAssesinfo ioctl"); + free(buf); + return -EFAULT; + } + /* + * 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)); + free(buf); + return (MLAN_STATUS_SUCCESS); +} + +/** + * @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 ioctl_val, subioctl_val, i, cmd_len, cmdresplen; + struct iwreq iwr; + char neighflag[6]; + ExactTime_t t; + t_u8 *buf, *pos, *tlvptr; + t_u16 tlv; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_CMD_ROAMAGENT_NEIGHBORLIST *pNborList; + MrvlIEtypes_NeighborEntry_t *pNeighbor; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + /* + * NEIGHBOR_LIST + */ + cmd_len = sizeof(HostCmd_DS_GEN) + sizeof(pNborList->action); + + buf = (t_u8 *)calloc(sizeof(t_u8), MRVDRV_SIZE_OF_CMD_BUFFER); + if (!buf) { + puts("\nMemory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = HostCmd_CMD_ROAMAGENT_NEIGHBORLIST; + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + pNborList = (HostCmd_DS_CMD_ROAMAGENT_NEIGHBORLIST *)pos; + pNborList->action = HostCmd_ACT_GEN_GET; + + /* + * ENDIANNESS + */ + hostcmd->command = cpu_to_le16(hostcmd->command); + hostcmd->size = cpu_to_le16(cmd_len); + pNborList->action = cpu_to_le16(pNborList->action); + + /* + * Prepare wireless request struct and fire ioctl + */ + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: roamneighborlist ioctl"); + free(buf); + return -EFAULT; + } + + 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: + puts("\nIncorrect response.\n"); + break; + } + } + + if (i == 0) { + puts("< Empty >"); + } + + puts(""); + + free(buf); + + return MLAN_STATUS_SUCCESS; +} + +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 ioctl_val, subioctl_val, cmd_len, i; + struct iwreq iwr; + t_u8 *buf, *pos; + t_u16 Metrics = 0; + 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"); + return MLAN_STATUS_FAILURE; + } + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = (sizeof(HostCmd_DS_GEN) + + sizeof(HostCmd_DS_CMD_ROAMAGENT_ADV_METRIC_THRESHOLD)); + + buf = (t_u8 *)calloc(sizeof(t_u8), cmd_len); + if (!buf) { + puts("\nMemory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = HostCmd_CMD_ROAMAGENT_ADV_METRIC_THRESHOLD; + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + metricscmd = (HostCmd_DS_CMD_ROAMAGENT_ADV_METRIC_THRESHOLD *)pos; + metricscmd->action = HostCmd_ACT_GEN_GET; + + /* + * ENDIANNESS + */ + hostcmd->command = cpu_to_le16(hostcmd->command); + hostcmd->size = cpu_to_le16(cmd_len); + metricscmd->action = cpu_to_le16(metricscmd->action); + + /* + * Prepare wireless request struct and fire ioctl + */ + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: roam set matrics ioctl"); + free(buf); + return -EFAULT; + } + + 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)); + } + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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 ioctl_val, subioctl_val, cmd_len, cmdresplen; + int state = 0, scanmode = 0; + struct iwreq iwr; + t_u8 *buf, *pos, *tlvptr; + t_u16 tlv; + 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]; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + /* + * NEIGHBOR_SCANPERIOD + */ + cmd_len = sizeof(HostCmd_DS_GEN) + sizeof(scanPeriodInfo->action); + + buf = (t_u8 *)calloc(sizeof(t_u8), MRVDRV_SIZE_OF_CMD_BUFFER); + if (!buf) { + puts("\nMemory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = HostCmd_CMD_ROAMAGENT_NEIGHBOR_SCAN_PERIOD; + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + scanPeriodInfo = + (HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_SCANPERIOD_RSP *)pos; + scanPeriodInfo->action = HostCmd_ACT_GEN_GET; + + /* + * ENDIANNESS + */ + hostcmd->command = cpu_to_le16(hostcmd->command); + hostcmd->size = cpu_to_le16(cmd_len); + scanPeriodInfo->action = cpu_to_le16(scanPeriodInfo->action); + + /* + * Prepare wireless request struct and fire ioctl + */ + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: roamscanperiod ioctl"); + free(buf); + return -EFAULT; + } + + 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"); + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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 ioctl_val, subioctl_val, cmd_len, cmdresplen; + struct iwreq iwr; + t_u8 *buf, *pos; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_CMD_ROAMAGENT_CONTROL *roamcontrolcmd; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = cmdresplen = + sizeof(HostCmd_DS_GEN) + sizeof(roamcontrolcmd->action); + cmdresplen += sizeof(HostCmd_DS_CMD_ROAMAGENT_CONTROL) - + sizeof(roamcontrolcmd->action); + + buf = (t_u8 *)calloc(sizeof(t_u8), cmdresplen); + if (!buf) { + puts("\nMemory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = HostCmd_CMD_ROAMAGENT_CONTROL; + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + roamcontrolcmd = (HostCmd_DS_CMD_ROAMAGENT_CONTROL *)pos; + + roamcontrolcmd->action = HostCmd_ACT_GEN_GET; + + /* + * ENDIANNESS + */ + hostcmd->command = cpu_to_le16(hostcmd->command); + hostcmd->size = cpu_to_le16(cmd_len); + + roamcontrolcmd->action = cpu_to_le16(roamcontrolcmd->action); + + /* + * Prepare wireless request struct and fire ioctl + */ + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: roamcontrol ioctl"); + free(buf); + return -EFAULT; + } + + memcpy((void *)pcontrol, (void *)roamcontrolcmd, + sizeof(HostCmd_DS_CMD_ROAMAGENT_CONTROL)); + free(buf); + 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 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 ioctl_val, subioctl_val, cmd_len, cmdresplen; + struct iwreq iwr; + t_u8 *buf, *pos; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_CMD_ROAMAGENT_BACKOFF *roambackoffcmd; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = cmdresplen = + sizeof(HostCmd_DS_GEN) + sizeof(roambackoffcmd->action); + cmdresplen += sizeof(HostCmd_DS_CMD_ROAMAGENT_BACKOFF) - + sizeof(roambackoffcmd->action); + + buf = (t_u8 *)calloc(sizeof(t_u8), cmdresplen); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = HostCmd_CMD_ROAMAGENT_BACKOFF; + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + roambackoffcmd = (HostCmd_DS_CMD_ROAMAGENT_BACKOFF *)pos; + + roambackoffcmd->action = HostCmd_ACT_GEN_GET; + + /* + * ENDIANNESS + */ + hostcmd->command = cpu_to_le16(hostcmd->command); + hostcmd->size = cpu_to_le16(cmd_len); + + roambackoffcmd->action = cpu_to_le16(roambackoffcmd->action); + + /* + * Prepare wireless request struct and fire ioctl + */ + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: roambackoff ioctl"); + free(buf); + return -EFAULT; + } + /* + * 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)); + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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 ioctl_val, subioctl_val, cmd_len; + int bcnmiss; + struct iwreq iwr; + t_u8 *buf, *pos; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *statsthreshold; + MrvlIEtypes_BeaconsMissed_t *beaconmiss; + + if (argc != 1) { + puts("\nIncorrect number of arguments.\n"); + return MLAN_STATUS_FAILURE; + } + + bcnmiss = atoi(argv[0]); + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = sizeof(HostCmd_DS_GEN) + sizeof(statsthreshold->action) + + sizeof(statsthreshold->State) + + sizeof(statsthreshold->Profile) + + sizeof(MrvlIEtypes_BeaconsMissed_t); + + buf = (t_u8 *)calloc(sizeof(t_u8), cmd_len); + if (!buf) { + puts("\nMemory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = + cpu_to_le16(HostCmd_CMD_ROAMAGENT_STATISTICS_THRESHOLD); + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + 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)); + + hostcmd->size = cpu_to_le16(cmd_len); + + /* + * Prepare wireless request struct and fire ioctl + */ + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: setra ioctl"); + free(buf); + return -EFAULT; + } + + 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); + } + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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 ioctl_val, subioctl_val, cmd_len; + int failCount, failTimeThresh; + struct iwreq iwr; + t_u8 *buf, *pos; + 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"); + return MLAN_STATUS_FAILURE; + } + + failCount = atoi(argv[0]); + failTimeThresh = atoi(argv[1]); + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = (sizeof(HostCmd_DS_GEN) + sizeof(statsthreshold->action) + + sizeof(statsthreshold->State) + + sizeof(statsthreshold->Profile) + + sizeof(MrvlIEtypes_FailureCount_t)); + + buf = (t_u8 *)calloc(sizeof(t_u8), cmd_len); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = + cpu_to_le16(HostCmd_CMD_ROAMAGENT_STATISTICS_THRESHOLD); + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + statsthreshold = (HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *)pos; + 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)); + + hostcmd->size = cpu_to_le16(cmd_len); + + /* + * Prepare wireless request struct and fire ioctl + */ + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: setra ioctl"); + free(buf); + return -EFAULT; + } + + 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); + } + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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 ioctl_val, subioctl_val, cmd_len; + int i, state = 0, low = 0, high = 0, lowval, highval; + struct iwreq iwr; + t_u8 *buf, *pos; + 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"); + return MLAN_STATUS_FAILURE; + } + + 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"); + return MLAN_STATUS_FAILURE; + } + if (argc != 3 && argc != 5) { + puts("\nIncorrect number of arguments.\n"); + return MLAN_STATUS_FAILURE; + } + 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"); + return MLAN_STATUS_FAILURE; + } + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = sizeof(HostCmd_DS_GEN) + sizeof(statsthreshold->action) + + sizeof(statsthreshold->State) + + sizeof(statsthreshold->Profile); + 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); + } + } + + buf = (t_u8 *)calloc(sizeof(t_u8), cmd_len); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = HostCmd_CMD_ROAMAGENT_STATISTICS_THRESHOLD; + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + statsthreshold = (HostCmd_DS_CMD_ROAMAGENT_STATISTICS_THRESHOLD *)pos; + + statsthreshold->action = 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); + } + } + + /* + * ENDIANNESS + */ + hostcmd->command = cpu_to_le16(hostcmd->command); + hostcmd->size = cpu_to_le16(cmd_len); + + statsthreshold->action = cpu_to_le16(statsthreshold->action); + + /* + * Prepare wireless request struct and fire ioctl + */ + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = + (sizeof(HostCmd_DS_GEN) + sizeof(statsthreshold->action) + + sizeof(statsthreshold->State) + + sizeof(statsthreshold->Profile) + i); + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: setra ioctl"); + free(buf); + return -EFAULT; + } + + 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)); + } + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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 ioctl_val, subioctl_val, cmd_len; + int scanmode = 0, period = 0, state = 0; + struct iwreq iwr; + t_u8 *buf, *pos; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_SCANPERIOD *scanPeriodInfo; + + if (argv[0] == NULL) { + puts("\nInsufficient arguments.. \n"); + return MLAN_STATUS_FAILURE; + } + + /* scanperiod */ + if (argc != 3) { + puts("\nIncorrect number of arguments.\n"); + return MLAN_STATUS_FAILURE; + } + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + 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"); + return MLAN_STATUS_FAILURE; + } + + 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"); + return MLAN_STATUS_FAILURE; + } + period = atoi(argv[2]); + /* TODO validation check on period */ + + cmd_len = sizeof(HostCmd_DS_GEN) + + sizeof(HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_SCANPERIOD); + + buf = (t_u8 *)calloc(sizeof(t_u8), cmd_len); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = HostCmd_CMD_ROAMAGENT_NEIGHBOR_SCAN_PERIOD; + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + scanPeriodInfo = (HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_SCANPERIOD *)pos; + + 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 + */ + hostcmd->command = cpu_to_le16(hostcmd->command); + hostcmd->size = cpu_to_le16(cmd_len); + + 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); + + /* + * Prepare wireless request struct and fire ioctl + */ + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: roamscanperiod ioctl"); + free(buf); + return -EFAULT; + } + + 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)); + } + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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 ioctl_val, subioctl_val, cmd_len, ret; + int trackcount = 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; + struct iwreq iwr; + signed char temp; + t_u8 *buf, *pos; + char *valid_cmds[] = {"trackcount", "qualoffset", "blacklistdur", + "stalecount", "staleperiod", "roamthresh"}; + + /** blacklistdur sub commands */ + char *valid_blcmds[] = {"short", "long"}; + + /** qualoffset sub commands */ + char *valid_bfcmds[] = {"rssi"}; + + int i = 0; + int j = 0; + + 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"); + + return MLAN_STATUS_FAILURE; + } + + if (argc < 2 || argc > 18) { + puts("\nIncorrect number of arguments.\n"); + return MLAN_STATUS_FAILURE; + } + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = sizeof(HostCmd_DS_GEN) + + sizeof(HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_ASSESSMENT); + + buf = (t_u8 *)calloc(sizeof(t_u8), cmd_len); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = HostCmd_CMD_ROAMAGENT_NEIGHBOR_ASSESSMENT; + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + pNborAssessment = (HostCmd_DS_CMD_ROAMAGENT_NEIGHBOR_ASSESSMENT *)pos; + + /* Get parameters unspecified on command line */ + if (getNborAssessment(pNborAssessment) != MLAN_STATUS_SUCCESS) { + free(buf); + return MLAN_STATUS_FAILURE; + } + + 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]); + free(buf); + return MLAN_STATUS_FAILURE; + } + + 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]); + free(buf); + return ret; + } + 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]); + free(buf); + return ret; + } 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(""); + + free(buf); + return MLAN_STATUS_FAILURE; + } + + 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 = 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"); + free(buf); + return (MLAN_STATUS_FAILURE); + } + + /* + * ENDIANNESS + */ + hostcmd->command = cpu_to_le16(hostcmd->command); + hostcmd->size = cpu_to_le16(cmd_len); + + 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); + + /* + * Prepare wireless request struct and fire ioctl + */ + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: roam neighbor assessment ioctl"); + free(buf); + return -EFAULT; + } + + 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(); + } + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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 ioctl_val, subioctl_val, cmd_len, ret; + 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 */ + struct iwreq iwr; + t_u8 *buf, *pos; + 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"); + return MLAN_STATUS_FAILURE; + } + + if (argc < 1 || argc > 38) { + puts("\nIncorrect number of arguments.\n"); + return MLAN_STATUS_FAILURE; + } + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = (sizeof(HostCmd_DS_GEN) + + sizeof(HostCmd_DS_CMD_ROAMAGENT_ADV_METRIC_THRESHOLD)); + + buf = (t_u8 *)calloc(sizeof(t_u8), cmd_len); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = HostCmd_CMD_ROAMAGENT_ADV_METRIC_THRESHOLD; + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + metricscmd = (HostCmd_DS_CMD_ROAMAGENT_ADV_METRIC_THRESHOLD *)pos; + metricscmd->action = HostCmd_ACT_GEN_SET; + + /* clear [ Beacon/Data/PER ] */ + if (!strncmp("clear", argv[j], strlen("clear"))) { + if (argc == 1) { + puts("\nInvalid number of argument"); + free(buf); + return MLAN_STATUS_FAILURE; + } + 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]); + free(buf); + return MLAN_STATUS_FAILURE; + } 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]); + free(buf); + return MLAN_STATUS_FAILURE; + } + + 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 + */ + hostcmd->command = cpu_to_le16(hostcmd->command); + hostcmd->size = cpu_to_le16(cmd_len); + + 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); + + /* + * Prepare wireless request struct and fire ioctl + */ + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: roam metrics ioctl"); + free(buf); + return -EFAULT; + } + + 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)); + } + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process maintenance of Neighbor list + * + * @param argc # arguments + * @param argv A pointer to arguments array + * + */ +static int roamSetNborMaintenance(int argc, char *argv[]) +{ + int ioctl_val, subioctl_val, cmd_len; + struct iwreq iwr; + t_u8 *buf, *pos; + 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"); + return MLAN_STATUS_FAILURE; + } + + if (argc != 2) { + puts("\nIncorrect number of arguments.\n"); + return MLAN_STATUS_FAILURE; + } + 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]); + return MLAN_STATUS_FAILURE; + } + 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"); + return MLAN_STATUS_FAILURE; + } + 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; + } + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = sizeof(HostCmd_DS_GEN) + + sizeof(HostCmd_DS_CMD_ROAMAGENT_NEIGHBORLIST_MAINTENANCE); + + buf = (t_u8 *)calloc(sizeof(t_u8), cmd_len); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = HostCmd_CMD_ROAMAGENT_NEIGHBORLIST_MAINTENANCE; + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + pNborMaintainance = + (HostCmd_DS_CMD_ROAMAGENT_NEIGHBORLIST_MAINTENANCE *)pos; + + pNborMaintainance->action = + ((i == 0) ? HostCmd_ACT_ADD_TO_BLACKLIST : + HostCmd_ACT_REMOVE_FROM_BLACKLIST); + for (k = 0; k < ETH_ALEN; k++) { + pNborMaintainance->BSSID[k] = *(mac + k); + } + + /* + * ENDIANNESS + */ + hostcmd->command = cpu_to_le16(hostcmd->command); + hostcmd->size = cpu_to_le16(cmd_len); + pNborMaintainance->action = cpu_to_le16(pNborMaintainance->action); + + /* + * Prepare wireless request struct and fire ioctl + */ + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: neighborlist maintain"); + free(buf); + return -EFAULT; + } + + 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)); + } + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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 ioctl_val, subioctl_val, cmd_len; + struct iwreq iwr; + t_u8 *buf, *pos, i = 0; + int spflag[2] = {0, 0}; /*scan,priod*/ + t_u16 minscan; + t_u32 bperiod; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_CMD_ROAMAGENT_BACKOFF *roambackoffcmd; + + if (argv[0] == NULL) { + puts("\nInsufficient arguments.. \n"); + return MLAN_STATUS_FAILURE; + } + /* BackOff */ + if ((argc != 2) && (argc != 4)) { + puts("\nIncorrect number of arguments.\n"); + return MLAN_STATUS_FAILURE; + } + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + 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_len = sizeof(HostCmd_DS_GEN) + + sizeof(HostCmd_DS_CMD_ROAMAGENT_BACKOFF); + + buf = (t_u8 *)calloc(sizeof(t_u8), cmd_len); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = HostCmd_CMD_ROAMAGENT_BACKOFF; + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + roambackoffcmd = (HostCmd_DS_CMD_ROAMAGENT_BACKOFF *)pos; + + switch (spflag[0] + spflag[1]) { + case 0: + /* error */ + puts("\nIncorrect arguments for setra backoff command.\n"); + free(buf); + return MLAN_STATUS_FAILURE; + break; + + case 1: + /* get missing parameter */ + if (getBackOff(roambackoffcmd) != MLAN_STATUS_SUCCESS) { + free(buf); + return MLAN_STATUS_FAILURE; + } + if (spflag[0] == 0) { + minscan = roambackoffcmd->Scans; + } else { + bperiod = roambackoffcmd->Period; + } + break; + + case 2: + default: + break; + } + + roambackoffcmd->action = HostCmd_ACT_GEN_SET; + roambackoffcmd->Scans = minscan; + roambackoffcmd->Period = bperiod; + + /* + * ENDIANNESS + */ + hostcmd->command = cpu_to_le16(hostcmd->command); + hostcmd->size = cpu_to_le16(cmd_len); + + roambackoffcmd->action = cpu_to_le16(roambackoffcmd->action); + roambackoffcmd->Scans = cpu_to_le16(roambackoffcmd->Scans); + roambackoffcmd->Period = cpu_to_le32(roambackoffcmd->Period); + + /* + * Prepare wireless request struct and fire ioctl + */ + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: roambackoff ioctl"); + free(buf); + return -EFAULT; + } + + 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)); + } + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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 ioctl_val, subioctl_val, cmd_len; + struct iwreq iwr; + t_u8 *buf, *pos; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_CMD_ROAMAGENT_CONTROL *roamcontrolcmd; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = sizeof(HostCmd_DS_GEN) + + sizeof(HostCmd_DS_CMD_ROAMAGENT_CONTROL); + + buf = (t_u8 *)calloc(sizeof(t_u8), cmd_len); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = HostCmd_CMD_ROAMAGENT_CONTROL; + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_DS_GEN); + + roamcontrolcmd = (HostCmd_DS_CMD_ROAMAGENT_CONTROL *)pos; + + /* get current value */ + if (getControl(roamcontrolcmd) != MLAN_STATUS_SUCCESS) { + free(buf); + return MLAN_STATUS_FAILURE; + } + + roamcontrolcmd->action = 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; + } + + /* + * ENDIANNESS + */ + hostcmd->command = cpu_to_le16(hostcmd->command); + hostcmd->size = cpu_to_le16(cmd_len); + + roamcontrolcmd->action = cpu_to_le16(roamcontrolcmd->action); + + /* + * Prepare wireless request struct and fire ioctl + */ + memset(&iwr, 0, sizeof(iwr)); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: roamcontrol ioctl"); + free(buf); + return -EFAULT; + } + + 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)); + } + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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/mapp/mlanconfig/mlanroamagent.h b/mapp/mlanconfig/mlanroamagent.h new file mode 100644 index 0000000..4fb6a66 --- /dev/null +++ b/mapp/mlanconfig/mlanroamagent.h @@ -0,0 +1,321 @@ +/** @file mlanroamagent.h + * + * @brief This files contains mlanconfig roamagent command handling. + * + * + * Copyright 2008-2021 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/mapp/mlanconfig/mlanscanagent.c b/mapp/mlanconfig/mlanscanagent.c new file mode 100644 index 0000000..8e61ce2 --- /dev/null +++ b/mapp/mlanconfig/mlanscanagent.c @@ -0,0 +1,1282 @@ +/** @file mlanscanagent.c + * + * @brief This files contains mlanconfig scanagent command handling. + * + * + * Copyright 2008-2021 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 "mlanconfig.h" +#include "mlanhostcmd.h" +#include "mlanmisc.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 ioctl_val, subioctl_val, cmd_len; + struct iwreq iwr; + t_u8 *buf, *pos; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_SCANAGENT_SCAN_TABLE_LIMITS *scan_table_limits; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = sizeof(HostCmd_DS_GEN) + + sizeof(HostCmd_DS_SCANAGENT_SCAN_TABLE_LIMITS); + buf = (t_u8 *)calloc(sizeof(t_u8), cmd_len); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + 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; + + pos = buf + sizeof(HostCmd_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); + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: scanAgentIoctl ioctl"); + free(buf); + return -EFAULT; + } + + 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)); + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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 ioctl_val, subioctl_val; + struct iwreq iwr; + HostCmd_DS_GEN *hostcmd; + t_u8 *buf, *pos; + HostCmd_DS_SCANAGENT_CONFIG_TIMING *cfg_timing_cmd; + MrvlIEtypes_ConfigScanTiming_t *cfg_timing_tlv; + int idx, cmd_len, 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 (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = (sizeof(HostCmd_DS_GEN) + sizeof(t_u16) + + sizeof(MrvlIEtypes_ConfigScanTiming_t) * 5); + + buf = (t_u8 *)calloc(sizeof(t_u8), cmd_len); + + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = cpu_to_le16(HostCmd_CMD_SCANAGENT_SCAN_TIMING); + hostcmd->size = (sizeof(HostCmd_DS_GEN) + sizeof(t_u16)); + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_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 = + (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]); + free(buf); + return -EINVAL; + } + + /* + * 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])); + + hostcmd->size += sizeof(MrvlIEtypes_ConfigScanTiming_t); + } + + hostcmd->size = cpu_to_le16(hostcmd->size); + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: scanAgentIoctl ioctl"); + free(buf); + return -EFAULT; + } + + printf("-----------------------------------------------" + "--------------------------------\n"); + printf("%57s\n", "ScanAgent Timing Profiles (in ms)"); + printf("-----------------------------------------------" + "--------------------------------\n"); + printf("%13s | %10s | %12s | %14s | %12s\n", "Profile", "Dwell", + "MaxOffChan", "MinLinkReturn", "RspTimeout"); + printf("-----------------------------------------------" + "--------------------------------\n"); + + /* Changed to TLV parsing */ + rsp_len = le16_to_cpu(hostcmd->size); + rsp_len -= (sizeof(HostCmd_DS_GEN) + sizeof(t_u16)); + pos = buf + sizeof(HostCmd_DS_GEN) + sizeof(t_u16); + + while ((unsigned int)rsp_len > sizeof(MrvlIEtypesHeader_t)) { + switch (le16_to_cpu(*(t_u16 *)(pos))) { + case TLV_TYPE_SCAN_TIMING: + cfg_timing_tlv = (MrvlIEtypes_ConfigScanTiming_t *)pos; + tlv_len = le16_to_cpu(cfg_timing_tlv->header.len); + printf("%13s | %10d | %12d | %14d | %12d\n", + sel_str[le32_to_cpu(cfg_timing_tlv->mode) - 1] + .str, + (int)le32_to_cpu(cfg_timing_tlv->dwell), + (int)le32_to_cpu(cfg_timing_tlv->max_off), + (int)le32_to_cpu(cfg_timing_tlv->min_link), + (int)le32_to_cpu(cfg_timing_tlv->rsp_timeout)); + break; + } + pos += tlv_len + sizeof(MrvlIEtypesHeader_t); + rsp_len -= tlv_len + sizeof(MrvlIEtypesHeader_t); + rsp_len = (rsp_len > 0) ? rsp_len : 0; + } + + printf("\n"); + free(buf); + + return MLAN_STATUS_SUCCESS; +} + +/** + * @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 ioctl_val, subioctl_val, cmd_len; + struct iwreq iwr; + t_u8 *buf, *pos; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_SCANAGENT_CONFIG_PROFILE_SCAN *cfg_profile_scan; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = sizeof(HostCmd_DS_GEN) + + sizeof(HostCmd_DS_SCANAGENT_CONFIG_PROFILE_SCAN); + + buf = (t_u8 *)calloc(sizeof(t_u8), cmd_len); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + 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; + pos = buf + sizeof(HostCmd_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); + } + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: scanAgentIoctl ioctl"); + free(buf); + return -EFAULT; + } + + 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); + } + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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 ioctl_val, subioctl_val; + struct iwreq iwr; + int arg_idx, cmd_len, tmp_idx; + t_u8 *buf, *pos, *tlv_pos; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_SCANAGENT_SCAN_EXEC *scan_exec; + MrvlIEtypes_SsIdParamSet_t *ssid; + MrvlIEtypes_Bssid_List_t *bssid; + MrvlIEtypes_ConfigScanTiming_t *cfg_timing_tlv; + unsigned int mac[ETH_ALEN]; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = (sizeof(HostCmd_DS_GEN) + + sizeof(HostCmd_DS_SCANAGENT_SCAN_EXEC) - + sizeof(scan_exec->tlv_buffer)); + + /* Not sure of the length so, allocate Max command size */ + buf = (t_u8 *)calloc(sizeof(t_u8), MRVDRV_SIZE_OF_CMD_BUFFER); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = cpu_to_le16(HostCmd_CMD_SCANAGENT_SCAN_EXEC); + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + + pos = buf + sizeof(HostCmd_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; + + 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); + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: scanAgentIoctl ioctl"); + free(buf); + return -EFAULT; + } else { + printf("\nScan Scheduled, ID = %d\n\n", + (int)le32_to_cpu(scan_exec->scan_req_id_out)); + } + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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 ioctl_val, subioctl_val, cmd_len; + struct iwreq iwr; + t_u8 *buf, *pos; + HostCmd_DS_GEN *hostcmd; + HostCmd_DS_SCANAGENT_TABLE_MAINTENANCE *table_maintenance; + + if (get_priv_ioctl("hostcmd", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + cmd_len = (sizeof(HostCmd_DS_GEN) + + sizeof(HostCmd_DS_SCANAGENT_TABLE_MAINTENANCE) - + sizeof(table_maintenance->tlv_buffer)); + + /* Not sure of the length so, allocate Max command size */ + buf = (t_u8 *)calloc(sizeof(t_u8), MRVDRV_SIZE_OF_CMD_BUFFER); + if (!buf) { + printf("Memory allocation failed\n"); + return -ENOMEM; + } + + hostcmd = (HostCmd_DS_GEN *)buf; + hostcmd->command = cpu_to_le16(HostCmd_CMD_SCANAGENT_TABLE_MAINTENANCE); + hostcmd->size = 0; + hostcmd->seq_num = 0; + hostcmd->result = 0; + pos = buf + sizeof(HostCmd_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, &cmd_len); + + hostcmd->size = cpu_to_le16(cmd_len); + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.flags = 0; + iwr.u.data.pointer = (caddr_t)buf; + iwr.u.data.length = cmd_len; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: scanAgentIoctl ioctl"); + free(buf); + return -EFAULT; + } + + free(buf); + return MLAN_STATUS_SUCCESS; +} + +/** + * @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)); +} + +/** + * @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 scanRspBuffer[600]; /* Stack buffer can be as large as ioctl allows + */ + + t_u8 scanStart; + int idx; + int detail_idx; + t_u8 scanReqId; + + t_u8 *pCurrent; + t_u8 *pNext; + IEEEtypes_ElementId_e *pElementId; + t_u8 *pElementLen; + int ssid_idx; + char ssid[33]; + int ssidLen; + + IEEEtypes_CapInfo_t capInfo = {0}; + t_u8 tsf[8]; + t_u16 beaconInterval; + + IEEEtypes_VendorSpecific_t *pWpaIe; + const t_u8 wpa_oui[4] = {0x00, 0x50, 0xf2, 0x01}; + + IEEEtypes_WmmParameter_t *pWmmIe; + 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}; + + IEEEtypes_MobilityDomain_t *pMdie; + char wmmCap; + char wps_cap; + char dot11kCap; + char privCap; + char ht_cap; + char vht_cap[2]; + int arg_idx; + int tmp_idx; + + t_u8 entryFlags; + t_u8 channel = 0; + t_u16 ageInSecs; + t_u8 in_bssid[ETH_ALEN]; + + unsigned int mac[ETH_ALEN]; + + wlan_ioctl_user_scan_ssid ssidList[10]; + + int num_ssid; + boolean displayHelp = FALSE; + int displayedInfo; + int display; + + wlan_get_scan_table_fixed fixed_fields; + t_u32 fixed_field_length; + t_u32 bss_info_length; + + wlan_ioctl_get_scan_table_info *pRspInfo; + + pRspInfo = (wlan_ioctl_get_scan_table_info *)scanRspBuffer; + + if (get_priv_ioctl("getscantable", &ioctl_val, &subioctl_val) == + MLAN_STATUS_FAILURE) { + return -EOPNOTSUPP; + } + + entryFlags = 0; + ageInSecs = 0; + scanReqId = 0; + memset(in_bssid, 0x00, sizeof(in_bssid)); + memset(ssidList, 0x00, sizeof(ssidList)); + idx = 0; + detail_idx = 0; + num_ssid = 0; + + for (arg_idx = 0; arg_idx < argc; arg_idx++) { + if (strncmp(argv[arg_idx], "id=", strlen("id=")) == 0) { + scanReqId = + strtol(argv[arg_idx] + strlen("id="), NULL, 10); + } else if ((strncmp(argv[arg_idx], "held", strlen("held")) == + 0) || + (strncmp(argv[arg_idx], "hold", strlen("hold")) == + 0)) { + entryFlags |= SCAN_QUERY_ENTRY_FLAGS_HELD; + } else if (strncmp(argv[arg_idx], "lock", strlen("lock")) == + 0) { + entryFlags |= SCAN_QUERY_ENTRY_FLAGS_LOCKED; + } else if (strncmp(argv[arg_idx], "help", strlen("help")) == + 0) { + displayHelp = TRUE; + } else if (strncmp(argv[arg_idx], "age=", strlen("age=")) == + 0) { + ageInSecs = strtol(argv[arg_idx] + strlen("age="), NULL, + 10); + } else if ((strncmp(argv[arg_idx], "ssid=", strlen("ssid=")) == + 0) && + (num_ssid < NELEMENTS(ssidList))) { + ssidList[num_ssid].max_len = + strlen(argv[arg_idx]) - strlen("ssid="); + strncpy(ssidList[num_ssid].ssid, + argv[arg_idx] + strlen("ssid="), + ssidList[num_ssid].max_len); + num_ssid++; + } else if (strncmp(argv[arg_idx], "bssid=", strlen("bssid=")) == + 0) { + 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 (idx = 0; (unsigned int)idx < NELEMENTS(mac); + idx++) { + in_bssid[idx] = (t_u8)mac[idx]; + } + } else if (strncmp(argv[arg_idx], + "detail=", strlen("detail=")) == 0) { + detail_idx = strtol(argv[arg_idx] + strlen("detail="), + NULL, 10); + } + } + + if (detail_idx) { + pRspInfo->scan_number = detail_idx; + pRspInfo->reqId = scanReqId; + pRspInfo->entryFlags = entryFlags; + pRspInfo->ageInSecs = ageInSecs; + memcpy(pRspInfo->bssid, in_bssid, sizeof(pRspInfo->bssid)); + if (num_ssid <= 1) { + /* Let the driver/fw filter if only 1 SSID is specified + */ + memcpy(pRspInfo->ssid, ssidList[0].ssid, + sizeof(pRspInfo->ssid)); + pRspInfo->ssid_len = ssidList[0].max_len; + } else { + /* Application filters for multiple SSIDs, don't pass + * down */ + memset(pRspInfo->ssid, 0x00, sizeof(pRspInfo->ssid)); + pRspInfo->ssid_len = 0; + } + return process_getscantable_idx(pRspInfo); + } + + displayedInfo = FALSE; + scanStart = 1; + + printf("---------------------------------------"); + printf("---------------------------------------\n"); + printf("# | ch | ss | npi | ld | bssid | cap | " + "SSID \n"); + printf("---------------------------------------"); + printf("---------------------------------------\n"); + + do { + pRspInfo->scan_number = scanStart; + pRspInfo->reqId = scanReqId; + pRspInfo->entryFlags = entryFlags; + pRspInfo->ageInSecs = ageInSecs; + memcpy(pRspInfo->bssid, in_bssid, sizeof(pRspInfo->bssid)); + if (num_ssid <= 1) { + /* Let the driver/fw filter if only 1 SSID is specified + */ + memcpy(pRspInfo->ssid, ssidList[0].ssid, + sizeof(pRspInfo->ssid)); + pRspInfo->ssid_len = ssidList[0].max_len; + } else { + /* Application filters for multiple SSIDs, don't pass + * down */ + memset(pRspInfo->ssid, 0x00, sizeof(pRspInfo->ssid)); + pRspInfo->ssid_len = 0; + } + + /* + * Set up and execute the ioctl call + */ + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.pointer = (caddr_t)pRspInfo; + iwr.u.data.length = sizeof(scanRspBuffer); + iwr.u.data.flags = subioctl_val; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: getscantable ioctl"); + return -EFAULT; + } + + pCurrent = 0; + pNext = pRspInfo->scan_table_entry_buf; + + for (idx = 0; idx < pRspInfo->scan_number; idx++) { + ssidLen = 0; + display = FALSE; + + /* + * Set pCurrent to pNext in case pad bytes are at the + * end of the last IE we processed. + */ + pCurrent = pNext; + + 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; + + /* Set next to be the start of the next scan entry */ + pNext = pCurrent + bss_info_length; + + if (bss_info_length >= + (sizeof(tsf) + sizeof(beaconInterval) + + sizeof(capInfo))) { + /* 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(&beaconInterval, pCurrent, + sizeof(beaconInterval)); + pCurrent += sizeof(beaconInterval); + bss_info_length -= sizeof(beaconInterval); + + /* capability information is 2 byte long */ + memcpy(&capInfo, pCurrent, sizeof(capInfo)); + pCurrent += sizeof(capInfo); + bss_info_length -= sizeof(capInfo); + } + + wmmCap = ' '; /* M (WMM), C (WMM-Call Admission Control) + */ + wps_cap = ' '; /* "S" */ + ht_cap = ' '; /* "N" */ + + /* "P" for Privacy (WEP) since "W" is WPA, and "2" is + * RSN/WPA2 */ + privCap = capInfo.privacy ? 'P' : ' '; + + dot11kCap = capInfo.radio_measurement ? 'K' : ' '; + pMdie = NULL; + + memset(ssid, 0, MRVDRV_MAX_SSID_LENGTH + 1); + + while (bss_info_length >= 2) { + pElementId = (IEEEtypes_ElementId_e *)pCurrent; + pElementLen = pCurrent + 1; + pCurrent += 2; + + switch (*pElementId) { + case SSID: + if (*pElementLen && + *pElementLen <= + MRVDRV_MAX_SSID_LENGTH) { + memcpy(ssid, pCurrent, + *pElementLen); + ssidLen = *pElementLen; + } + break; + + case DS_PARAM_SET: + channel = *pCurrent; + break; + + case WPA_IE: + pWpaIe = (IEEEtypes_VendorSpecific_t *) + pElementId; + if ((memcmp(pWpaIe->vend_hdr.oui, + wpa_oui, + sizeof(pWpaIe->vend_hdr + .oui)) == + 0) && + (pWpaIe->vend_hdr.oui_type == + wpa_oui[3])) { + /* Don't set privcap if WPA2/RSN + * already found */ + if (privCap != '2') { + /* WPA IE found, 'W' for + * WPA */ + privCap = 'W'; + } + } else { + pWmmIe = + (IEEEtypes_WmmParameter_t + *)pElementId; + if ((memcmp(pWmmIe->vend_hdr.oui, + wmm_oui, + sizeof(pWmmIe->vend_hdr + .oui)) == + 0) && + (pWmmIe->vend_hdr.oui_type == + wmm_oui[3])) { + /* Check the subtype: 1 + * == parameter, 0 == + * info */ + if ((pWmmIe->vend_hdr + .oui_subtype == + 1) && + pWmmIe->ac_params[WMM_AC_VO] + .aci_aifsn + .acm) { + /* Call + * admission on + * VO; 'C' for + * CAC */ + wmmCap = 'C'; + } else { + /* No CAC; 'M' + * for uh, WMM + */ + wmmCap = 'M'; + } + } + } + break; + + case RSN_IE: + /* RSN IE found; '2' for WPA2 (RSN) */ + privCap = '2'; + break; + case HT_CAPABILITY: + ht_cap = 'N'; + break; + case VHT_CAPABILITY: + vht_cap[0] = 'A'; + vht_cap[1] = 'C'; + break; + case MDIE: + /* Mobility domain IE. Use to indicate + * 11r and MDID */ + pMdie = (IEEEtypes_MobilityDomain_t *) + pElementId; + break; + + default: + break; + } + + pCurrent += *pElementLen; + bss_info_length -= (2 + *pElementLen); + } + + if (num_ssid) { + /* Display filter based on potential multiple + * SSID input */ + + if (ssidLen) { + for (tmp_idx = 0; + !display && (tmp_idx < num_ssid); + tmp_idx++) { + if ((ssidLen == + ssidList[tmp_idx].max_len) && + (memcmp(ssid, + ssidList[tmp_idx] + .ssid, + ssidLen) == 0)) { + display = TRUE; + } + } + } + } else { + display = TRUE; + } + + if (display) { + displayedInfo = TRUE; + + printf("%02u| %03d |%4d |%4d |%3d%% | " + "%02x:%02x:%02x:%02x:%02x:%02x |", + scanStart + idx, channel, + fixed_fields.rssi, fixed_fields.anpi, + 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]); + + /* "A" for Adhoc + * "I" for Infrastructure, + * "D" for DFS (Spectrum Mgmt) + */ + printf(" %c%c%c%c%c%c%c%c%c%c | ", + capInfo.ibss ? 'A' : 'I', + privCap, /* P (WEP), W (WPA), 2 (WPA2) */ + capInfo.spectrum_mgmt ? 'D' : ' ', + wmmCap, /* M (WMM), C (WMM-Call Admission + Control) */ + dot11kCap, /* K */ + pMdie ? 'R' : ' ', /* 802.11r */ + wps_cap, /* S */ + ht_cap, /* N */ + vht_cap[0], vht_cap[1]); /* AC */ + + /* Print out the ssid or the hex values if + * non-printable */ + for (ssid_idx = 0; ssid_idx < ssidLen; + ssid_idx++) { + if (isprint(ssid[ssid_idx])) { + printf("%c", ssid[ssid_idx]); + } else { + printf("\\%02x", + ssid[ssid_idx]); + } + } + + if (pMdie) { + printf(" [%04x]", pMdie->MDID); + } + printf("\n"); + + if (argc > 3 && strcmp(argv[3], "tsf") == 0) { + t_u8 *pByte; + + /* TSF is a t_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]); + } + } + } + scanStart += pRspInfo->scan_number; + + } while (pRspInfo->scan_number); + + pRspInfo->scan_number = -1; + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + iwr.u.data.pointer = (caddr_t)pRspInfo; + iwr.u.data.length = sizeof(scanRspBuffer); + iwr.u.data.flags = subioctl_val; + + if (ioctl(sockfd, ioctl_val, &iwr) < 0) { + perror("mlanconfig: getscantable ioctl"); + return -EFAULT; + } + + if (displayedInfo) { + if (displayHelp) { + printf("\n\n" + "Capability Legend (Not all may be supported)\n" + "-----------------\n" + " I [ Infrastructure ]\n" + " A [ Ad-hoc ]\n" + " P [ WEP ]\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 [HT (11ac) ]\n" + "\n\n"); + } + } else { + printf("< No Scan Results >\n"); + } + + return MLAN_STATUS_SUCCESS; +} + +/** + * @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: + * + * bssid=xx:xx:xx:xx:xx:xx specify a BSSID filter for the scan + * ssid="[SSID]" specify a SSID filter for the scan + + * @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; + int arg_idx; + int tmp_idx; + int num_ssid; + unsigned int mac[ETH_ALEN]; + + memset(&scan_req, 0x00, sizeof(scan_req)); + 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) { + if (num_ssid < MRVDRV_MAX_SSID_LIST_LENGTH) { + /* + * "ssid" token string handler + */ + 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], "group=", strlen("group=")) == + 0) { + sscanf(argv[arg_idx] + strlen("group="), "0x%x", + &tmp_idx); + scan_req.chan_group = tmp_idx; + } + } + + strncpy(iwr.ifr_name, dev_name, IFNAMSIZ); + 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(argc, argv); + + return MLAN_STATUS_SUCCESS; +} diff --git a/mapp/mlanconfig/mlanscanagent.h b/mapp/mlanconfig/mlanscanagent.h new file mode 100644 index 0000000..57a283a --- /dev/null +++ b/mapp/mlanconfig/mlanscanagent.h @@ -0,0 +1,147 @@ +/** @file mlanscanagent.h + * + * @brief This files contains mlanconfig scanagent command handling. + * + * + * Copyright 2008-2021 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; + +#endif /* _MLAN_SCANAGENT_H_ */ diff --git a/mapp/mlanevent/Makefile b/mapp/mlanevent/Makefile new file mode 100644 index 0000000..036edce --- /dev/null +++ b/mapp/mlanevent/Makefile @@ -0,0 +1,59 @@ +# File : mlanevent/Makefile +# +# Copyright 2008-2022 NXP + +# Path to the top directory of the wlan distribution +PATH_TO_TOP = ../.. + +ifeq ($(findstring IMX_ANDROID,$(ccflags-y)),IMX_ANDROID) +CC=/usr/local/arm/android-ndk-r23-beta5/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang +endif + +# Determine how we should copy things to the install directory +ABSPATH := $(filter /%, $(INSTALLDIR)) +RELPATH := $(filter-out /%, $(INSTALLDIR)) +INSTALLPATH := $(ABSPATH) +ifeq ($(strip $(INSTALLPATH)),) +INSTALLPATH := $(PATH_TO_TOP)/$(RELPATH) +endif + +# Override CFLAGS for application sources, remove __ kernel namespace defines +CFLAGS := $(filter-out -D__%, $(ccflags-y)) +# remove KERNEL include dir +CFLAGS := $(filter-out -I$(KERNELDIR)%, $(CFLAGS)) + + +#CFLAGS += -DAP22 -fshort-enums +CFLAGS += -Wall +#ECHO = @ +ifeq (,$(findstring ANDROID_KERNEL, $(CFLAGS))) +LIBS=-lrt +endif + + + +.PHONY: default tags all + +OBJECTS = mlanevent.o +HEADERS = mlanevent.h + +TARGET = mlanevent.exe + +build appsbuild default: $(TARGET) + @cp -f $(TARGET) $(INSTALLPATH) + +all : tags default + +$(TARGET): $(OBJECTS) $(HEADERS) + $(ECHO)$(CC) $(LIBS) -o $@ $(OBJECTS) + +%.o: %.c $(HEADERS) + $(ECHO)$(CC) $(CFLAGS) -c -o $@ $< + +tags: + ctags -R -f tags.txt + +distclean clean: + $(ECHO)$(RM) $(OBJECTS) $(TARGET) + $(ECHO)$(RM) tags.txt + diff --git a/mapp/mlanevent/mlanevent.c b/mapp/mlanevent/mlanevent.c new file mode 100644 index 0000000..da744ee --- /dev/null +++ b/mapp/mlanevent/mlanevent.c @@ -0,0 +1,2747 @@ +/** @file mlanevent.c + * + * @brief Program to receive events from the driver/firmware of the uAP + * driver. + * + * + * Copyright 2008-2021, 2025 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/18/08: Initial creation +****************************************************************************/ + +/**************************************************************************** + Header files +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "mlanevent.h" +#ifdef WIFI_DIRECT_SUPPORT +#include +#endif +#include + +/**************************************************************************** + Definitions +****************************************************************************/ +/** Enable or disable debug outputs */ +#define DEBUG 0 + +/**************************************************************************** + Global variables +****************************************************************************/ +/** Termination flag */ +int terminate_flag = 0; + +/**************************************************************************** + Local functions +****************************************************************************/ +/** + * @brief Signal handler + * + * @param sig Received signal number + * @return N/A + */ +static void sig_handler(int sig) +{ + printf("Stopping application.\n"); +#if DEBUG + printf("Process ID of process killed = %d\n", getpid()); +#endif + terminate_flag = 1; +} + +/** + * @brief Dump hex data + * + * @param p A pointer to data buffer + * @param len The len of data buffer + * @param delim Deliminator character + * @return Hex integer + */ +static void hexdump(void *p, t_s32 len, char delim) +{ + t_s32 i; + t_u8 *s = p; + 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"); + } +} + +/** + * @brief Hex to number + * + * @param c Hex value + * @return Integer value or -1 + */ +static int hex2num(char c) +{ + if (c >= '0' && c <= '9') + return c - '0'; + if (c >= 'a' && c <= 'f') + return c - 'a' + 10; + if (c >= 'A' && c <= 'F') + return c - 'A' + 10; + + return -1; +} + +/** + * @brief Check hex string + * + * @param hex A pointer to hex string + * @return 0 or MLAN_EVENT_FAILURE + */ +int ishexstring(void *hex) +{ + int i, a; + char *p = hex; + int len = strlen(p); + if (!strncasecmp("0x", p, 2)) { + p += 2; + len -= 2; + } + for (i = 0; i < len; i++) { + a = hex2num(*p); + if (a < 0) + return MLAN_EVENT_FAILURE; + p++; + } + return 0; +} + +/** + * @brief Convert char to hex integer + * + * @param chr Char + * @return Hex integer + */ +static unsigned char hexc2bin(char 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 + */ +unsigned int a2hex(char *s) +{ + unsigned int val = 0; + if (!strncasecmp("0x", s, 2)) { + s += 2; + } + while (*s && isxdigit((unsigned char)*s)) { + val = (val << 4) + hexc2bin(*s++); + } + return val; +} + +/** + * @brief Prints a MAC address in colon separated form from raw data + * + * @param raw A pointer to the hex data buffer + * @return N/A + */ +static 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 Print usage information + * + * @return N/A + */ +static void print_usage(void) +{ + printf("\n"); + printf("Usage : mlanevent.exe [-v] [-h]\n"); + printf(" -v : Print version information\n"); + printf(" -h : Print help information\n"); + printf(" -i : Specify device number from 0 to %d\n", + MAX_NO_OF_DEVICES - 1); + printf(" 0xff for all devices\n"); + printf("\n"); +} + +/** + * @brief Parse and print STA deauthentication event data + * + * @param buffer Pointer to received event buffer + * @param size Length of the received event data + * @return N/A + */ +static void print_event_sta_deauth(t_u8 *buffer, t_u16 size) +{ + eventbuf_sta_deauth *event_body = NULL; + + if (size < sizeof(eventbuf_sta_deauth)) { + printf("ERR:Event buffer too small!\n"); + return; + } + event_body = (eventbuf_sta_deauth *)buffer; + event_body->reason_code = uap_le16_to_cpu(event_body->reason_code); + printf("EVENT: STA_DEAUTH\n"); + printf("Deauthenticated STA MAC: "); + print_mac(event_body->sta_mac_address); + printf("\nReason: "); + switch (event_body->reason_code) { + case 1: + printf("Client station leaving the network\n"); + break; + case 2: + printf("Client station aged out\n"); + break; + case 3: + printf("Client station deauthenticated by user's request\n"); + break; + case 4: + printf("Client station authentication failure\n"); + break; + case 5: + printf("Client station association failure\n"); + break; + case 6: + printf("Client mac address is blocked by ACL filter\n"); + break; + case 7: + printf("Client station table is full\n"); + break; + case 8: + printf("Client 4-way handshake timeout\n"); + break; + case 9: + printf("Client group key handshake timeout\n"); + break; + default: + printf("Unspecified\n"); + break; + } + return; +} + +/** + * @brief Parse and print WEP ICV error event data + * + * @param buffer Pointer to received event buffer + * @param size Length of the received event data + * @return N/A + */ +static void print_event_wep_icv_error(t_u8 *buffer, t_u16 size) +{ + int i = 0; + eventbuf_wep_icv_error *event_body = NULL; + + if (size < sizeof(eventbuf_wep_icv_error)) { + printf("ERR:Event buffer too small!\n"); + return; + } + event_body = (eventbuf_wep_icv_error *)buffer; + event_body->reason_code = uap_le16_to_cpu(event_body->reason_code); + printf("EVENT: WEP_ICV_ERROR\n"); + printf("Deauthenticated STA MAC: "); + print_mac(event_body->sta_mac_address); + printf("WEP key index = %d\n", event_body->wep_key_index); + printf("WEP key length = %d\n", event_body->wep_key_length); + printf("WEP key : \n"); + for (i = 0; i < event_body->wep_key_length; i++) { + printf("%02x ", event_body->wep_key[i]); + } + printf("\n"); + return; +} + +/** + * @brief Prints mgmt frame + * + * @param mgmt_tlv A pointer to mgmt_tlv + * @param tlv_len Length of tlv payload + * @return N/A + */ +static void print_mgmt_frame(MrvlIETypes_MgmtFrameSet_t *mgmt_tlv, int tlv_len) +{ + IEEEtypes_AssocRqst_t *assoc_req = NULL; + IEEEtypes_ReAssocRqst_t *reassoc_req = NULL; + IEEEtypes_AssocRsp_t *assoc_resp = NULL; + t_u16 frm_ctl = 0; + printf("\nMgmt Frame:\n"); + memcpy(&frm_ctl, &mgmt_tlv->frame_control, sizeof(t_u16)); + printf("FrameControl: 0x%x\n", frm_ctl); + if (mgmt_tlv->frame_control.type != 0) { + printf("Frame type=%d subtype=%d:\n", + mgmt_tlv->frame_control.type, + mgmt_tlv->frame_control.sub_type); + hexdump(mgmt_tlv->frame_contents, tlv_len - sizeof(t_u16), ' '); + return; + } + switch (mgmt_tlv->frame_control.sub_type) { + case SUBTYPE_ASSOC_REQUEST: + printf("Assoc Request:\n"); + assoc_req = (IEEEtypes_AssocRqst_t *)mgmt_tlv->frame_contents; + printf("CapInfo: 0x%x ListenInterval: 0x%x \n", + uap_le16_to_cpu(assoc_req->cap_info), + uap_le16_to_cpu(assoc_req->listen_interval)); + printf("AssocReqIE:\n"); + hexdump(assoc_req->ie_buffer, + tlv_len - sizeof(IEEEtypes_AssocRqst_t) - + sizeof(IEEEtypes_FrameCtl_t), + ' '); + break; + case SUBTYPE_REASSOC_REQUEST: + printf("ReAssoc Request:\n"); + reassoc_req = + (IEEEtypes_ReAssocRqst_t *)mgmt_tlv->frame_contents; + printf("CapInfo: 0x%x ListenInterval: 0x%x \n", + uap_le16_to_cpu(reassoc_req->cap_info), + uap_le16_to_cpu(reassoc_req->listen_interval)); + printf("Current AP address: "); + print_mac(reassoc_req->current_ap_addr); + printf("\nReAssocReqIE:\n"); + hexdump(reassoc_req->ie_buffer, + tlv_len - sizeof(IEEEtypes_ReAssocRqst_t) - + sizeof(IEEEtypes_FrameCtl_t), + ' '); + break; + case SUBTYPE_ASSOC_RESPONSE: + case SUBTYPE_REASSOC_RESPONSE: + if (mgmt_tlv->frame_control.sub_type == SUBTYPE_ASSOC_RESPONSE) + printf("Assoc Response:\n"); + else + printf("ReAssoc Response:\n"); + assoc_resp = (IEEEtypes_AssocRsp_t *)mgmt_tlv->frame_contents; + printf("CapInfo: 0x%x StatusCode: %d AID: 0x%x \n", + uap_le16_to_cpu(assoc_resp->cap_info), + (int)(uap_le16_to_cpu(assoc_resp->status_code)), + uap_le16_to_cpu(assoc_resp->aid) & 0x3fff); + break; + default: + printf("Frame subtype = %d:\n", + mgmt_tlv->frame_control.sub_type); + hexdump(mgmt_tlv->frame_contents, tlv_len - sizeof(t_u16), ' '); + break; + } + return; +} + +/** + * @brief Parse and print RSN connect event data + * + * @param buffer Pointer to received buffer + * @param size Length of the received event data + * @return N/A + */ +static void print_event_rsn_connect(t_u8 *buffer, t_u16 size) +{ + int tlv_buf_left = size; + t_u16 tlv_type, tlv_len; + tlvbuf_header *tlv = NULL; + eventbuf_rsn_connect *event_body = NULL; + if (size < sizeof(eventbuf_rsn_connect)) { + printf("ERR:Event buffer too small!\n"); + return; + } + event_body = (eventbuf_rsn_connect *)buffer; + printf("EVENT: RSN_CONNECT\n"); + printf("Station MAC: "); + print_mac(event_body->sta_mac_address); + printf("\n"); + tlv_buf_left = size - sizeof(eventbuf_rsn_connect); + if (tlv_buf_left < (int)sizeof(tlvbuf_header)) + return; + tlv = (tlvbuf_header *)(buffer + sizeof(eventbuf_rsn_connect)); + + while (tlv_buf_left >= (int)sizeof(tlvbuf_header)) { + tlv_type = uap_le16_to_cpu(tlv->type); + tlv_len = uap_le16_to_cpu(tlv->len); + if ((sizeof(tlvbuf_header) + tlv_len) > + (unsigned int)tlv_buf_left) { + printf("wrong tlv: tlvLen=%d, tlvBufLeft=%d\n", tlv_len, + tlv_buf_left); + break; + } + switch (tlv_type) { + case IEEE_WPA_IE: + printf("WPA IE:\n"); + hexdump((t_u8 *)tlv + sizeof(tlvbuf_header), tlv_len, + ' '); + break; + case IEEE_RSN_IE: + printf("RSN IE:\n"); + hexdump((t_u8 *)tlv + sizeof(tlvbuf_header), tlv_len, + ' '); + break; + default: + printf("unknown tlv: %d\n", tlv_type); + break; + } + tlv_buf_left -= (sizeof(tlvbuf_header) + tlv_len); + tlv = (tlvbuf_header *)((t_u8 *)tlv + tlv_len + + sizeof(tlvbuf_header)); + } + return; +} + +/** + * @brief Parse and print STA associate event data + * + * @param buffer Pointer to received buffer + * @param size Length of the received event data + * @return N/A + */ +static void print_event_sta_assoc(t_u8 *buffer, t_u16 size) +{ + int tlv_buf_left = size; + t_u16 tlv_type, tlv_len; + tlvbuf_header *tlv = NULL; + MrvlIEtypes_WapiInfoSet_t *wapi_tlv = NULL; + MrvlIETypes_MgmtFrameSet_t *mgmt_tlv = NULL; + eventbuf_sta_assoc *event_body = NULL; + if (size < sizeof(eventbuf_sta_assoc)) { + printf("ERR:Event buffer too small!\n"); + return; + } + event_body = (eventbuf_sta_assoc *)buffer; + printf("EVENT: STA_ASSOCIATE\n"); + printf("Associated STA MAC: "); + print_mac(event_body->sta_mac_address); + printf("\n"); + tlv_buf_left = size - sizeof(eventbuf_sta_assoc); + if (tlv_buf_left < (int)sizeof(tlvbuf_header)) + return; + tlv = (tlvbuf_header *)(buffer + sizeof(eventbuf_sta_assoc)); + + while (tlv_buf_left >= (int)sizeof(tlvbuf_header)) { + tlv_type = uap_le16_to_cpu(tlv->type); + tlv_len = uap_le16_to_cpu(tlv->len); + if ((sizeof(tlvbuf_header) + tlv_len) > + (unsigned int)tlv_buf_left) { + printf("wrong tlv: tlvLen=%d, tlvBufLeft=%d\n", tlv_len, + tlv_buf_left); + break; + } + switch (tlv_type) { + case MRVL_WAPI_INFO_TLV_ID: + wapi_tlv = (MrvlIEtypes_WapiInfoSet_t *)tlv; + printf("WAPI Multicast PN:\n"); + hexdump(wapi_tlv->multicast_PN, tlv_len, ' '); + break; + case MRVL_MGMT_FRAME_TLV_ID: + mgmt_tlv = (MrvlIETypes_MgmtFrameSet_t *)tlv; + print_mgmt_frame(mgmt_tlv, tlv_len); + break; + default: + printf("unknown tlv: %d\n", tlv_type); + break; + } + tlv_buf_left -= (sizeof(tlvbuf_header) + tlv_len); + tlv = (tlvbuf_header *)((t_u8 *)tlv + tlv_len + + sizeof(tlvbuf_header)); + } + return; +} + +/** + * @brief Parse and print BSS start event data + * + * @param buffer Pointer to received buffer + * @param size Length of the received event data + * @return N/A + */ +static void print_event_bss_start(t_u8 *buffer, t_u16 size) +{ + eventbuf_bss_start *event_body = NULL; + int tlv_buf_left = size; + t_u16 tlv_type, tlv_len; + tlvbuf_header *tlv = NULL; + tlvbuf_channel_config *channel_tlv = NULL; + + if (size < sizeof(eventbuf_bss_start)) { + printf("ERR:Event buffer too small!\n"); + return; + } + event_body = (eventbuf_bss_start *)buffer; + printf("EVENT: BSS_START "); + printf("BSS MAC: "); + print_mac(event_body->ap_mac_address); + printf("\n"); + tlv_buf_left = size - sizeof(eventbuf_bss_start); + if (tlv_buf_left < (int)sizeof(tlvbuf_header)) + return; + tlv = (tlvbuf_header *)(buffer + sizeof(eventbuf_bss_start)); + + while (tlv_buf_left >= (int)sizeof(tlvbuf_header)) { + tlv_type = uap_le16_to_cpu(tlv->type); + tlv_len = uap_le16_to_cpu(tlv->len); + if ((sizeof(tlvbuf_header) + tlv_len) > + (unsigned int)tlv_buf_left) { + printf("wrong tlv: tlvLen=%d, tlvBufLeft=%d\n", tlv_len, + tlv_buf_left); + break; + } + switch (tlv_type) { + case MRVL_CHANNELCONFIG_TLV_ID: + channel_tlv = (tlvbuf_channel_config *)tlv; + printf("Channel = %d\n", channel_tlv->chan_number); + printf("Band = %s\n", + (channel_tlv->bandcfg.chanBand == BAND_5GHZ) ? + "5GHz" : + "2.4GHz"); + printf("Channel Select Mode = %s\n", + (channel_tlv->bandcfg.scanMode == + SCAN_MODE_ACS) ? + "ACS" : + "Manual"); + if (channel_tlv->bandcfg.chan2Offset == SEC_CHAN_NONE) + printf("no secondary channel\n"); + else if (channel_tlv->bandcfg.chan2Offset == + SEC_CHAN_ABOVE) + printf("secondary channel is above primary channel\n"); + else if (channel_tlv->bandcfg.chan2Offset == + SEC_CHAN_BELOW) + printf("secondary channel is below primary channel\n"); + break; + default: +#if DEBUG + printf("unknown tlv: %d\n", tlv_type); +#endif + break; + } + tlv_buf_left -= (sizeof(tlvbuf_header) + tlv_len); + tlv = (tlvbuf_header *)((t_u8 *)tlv + tlv_len + + sizeof(tlvbuf_header)); + } + + return; +} + +/** + * @brief Parse and print MIC Countermeasures state + * + * @param buffer Pointer to received buffer + * @param size Length of the received event data + * @return N/A + */ +static void print_event_mic_countermeasures(t_u8 *buffer, t_u16 size) +{ + eventbuf_mic_countermeasures *event_body = NULL; + + if (size < sizeof(eventbuf_mic_countermeasures)) { + printf("ERR:Event buffer too small!\n"); + return; + } + event_body = (eventbuf_mic_countermeasures *)buffer; + if (event_body->status) + printf("EVENT: Countermeasures active.\n"); + else + printf("EVENT: Countermeasures inactive\n"); + return; +} + +#ifdef WIFI_DIRECT_SUPPORT +/** + * @brief Print WIFI_WPS IE elements from event payload + * + * @param buffer Pointer to received buffer + * @param size Length of the received event data + * @return N/A + */ +static void print_wifi_wps_ie_elements(t_u8 *buffer, t_u16 size) +{ + t_u8 *ptr = buffer; + t_u8 *array_ptr; + int i; + t_u16 wps_len = 0, wps_type = 0; + t_u16 ie_len_wps = size; + + while (ie_len_wps > sizeof(tlvbuf_wps_ie)) { + memcpy(&wps_type, ptr, sizeof(t_u16)); + memcpy(&wps_len, ptr + 2, sizeof(t_u16)); + endian_convert_tlv_wps_header_in(wps_type, wps_len); + switch (wps_type) { + case SC_Version: { + tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; + printf("\t WPS Version = 0x%2x\n", *(wps_tlv->data)); + } break; + case SC_Simple_Config_State: { + tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; + printf("\t WPS setupstate = 0x%x\n", *(wps_tlv->data)); + } break; + case SC_Request_Type: { + tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; + printf("\t WPS RequestType = 0x%x\n", *(wps_tlv->data)); + } break; + case SC_Response_Type: { + tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; + printf("\t WPS ResponseType = 0x%x\n", + *(wps_tlv->data)); + } break; + case SC_Config_Methods: { + t_u16 wps_config_methods = 0; + tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; + memcpy(&wps_config_methods, wps_tlv->data, + sizeof(t_u16)); + wps_config_methods = ntohs(wps_config_methods); + printf("\t WPS SpecConfigMethods = 0x%x\n", + wps_config_methods); + } break; + case SC_UUID_E: { + tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; + array_ptr = wps_tlv->data; + printf("\t WPS UUID = "); + for (i = 0; i < wps_len; i++) + printf("0x%02X ", *array_ptr++); + printf("\n"); + } break; + case SC_Primary_Device_Type: { + tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; + array_ptr = wps_tlv->data; + printf("\t WPS Primary Device Type = "); + for (i = 0; i < wps_len; i++) + printf("0x%02X ", *array_ptr++); + printf("\n"); + } break; + case SC_RF_Band: { + tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; + printf("\t WPS RF Band = 0x%x\n", *(wps_tlv->data)); + } break; + case SC_Association_State: { + t_u16 wps_association_state = 0; + tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; + memcpy(&wps_association_state, wps_tlv->data, + sizeof(t_u16)); + wps_association_state = ntohs(wps_association_state); + printf("\t WPS Association State = 0x%x\n", + wps_association_state); + } break; + case SC_Configuration_Error: { + t_u16 wps_configuration_error = 0; + tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; + memcpy(&wps_configuration_error, wps_tlv->data, + sizeof(t_u16)); + wps_configuration_error = + ntohs(wps_configuration_error); + printf("\t WPS Configuration Error = 0x%x\n", + wps_configuration_error); + } break; + case SC_Device_Password_ID: { + t_u16 wps_device_password_id = 0; + tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; + memcpy(&wps_device_password_id, wps_tlv->data, + sizeof(t_u16)); + wps_device_password_id = ntohs(wps_device_password_id); + printf("\t WPS Device Password ID = 0x%x\n", + wps_device_password_id); + } break; + case SC_Device_Name: { + tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; + array_ptr = wps_tlv->data; + printf("\t WPS Device Name = "); + for (i = 0; i < wps_len; i++) + printf("%c", *array_ptr++); + printf("\n"); + } break; + case SC_Manufacturer: { + tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; + array_ptr = wps_tlv->data; + printf("\t WPS Manufacturer = "); + for (i = 0; i < wps_len; i++) + printf("%c", *array_ptr++); + printf("\n"); + } break; + case SC_Model_Name: { + tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; + array_ptr = wps_tlv->data; + printf("\t WPS Model Name = "); + for (i = 0; i < wps_len; i++) + printf("%c", *array_ptr++); + printf("\n"); + } break; + case SC_Model_Number: { + tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; + array_ptr = wps_tlv->data; + printf("\t WPS Model Number = "); + for (i = 0; i < wps_len; i++) + printf("%c", *array_ptr++); + printf("\n"); + } break; + case SC_Serial_Number: { + tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; + array_ptr = wps_tlv->data; + printf("\t WPS Serial Number = "); + for (i = 0; i < wps_len; i++) + printf("%c", *array_ptr++); + printf("\n"); + } break; + case SC_Vendor_Extension: { + tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; + array_ptr = wps_tlv->data; + printf("\t WPS 2.0 Vendor Extension = "); + for (i = 0; i < wps_len; i++) + printf("%x", *array_ptr++); + printf("\n"); + } break; + case SC_Selected_Registrar: { + tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; + printf("\t Selected Registrar = %d\n", + *(wps_tlv->data)); + } break; + case SC_SelectedRegistrarConfigMethods: { + t_u16 sr_config_methods = 0; + tlvbuf_wps_ie *wps_tlv = (tlvbuf_wps_ie *)ptr; + memcpy(&sr_config_methods, wps_tlv->data, + sizeof(t_u16)); + sr_config_methods = ntohs(sr_config_methods); + printf("\t Selected Registrar Configuration Methods = 0x%x\n", + sr_config_methods); + } break; + default: + printf("unknown ie=0x%x, len=%d\n", wps_type, wps_len); + break; + } + ptr += wps_len + sizeof(tlvbuf_wps_ie); + /* Take care of error condition */ + if (wps_len + sizeof(tlvbuf_wps_ie) <= ie_len_wps) + ie_len_wps -= wps_len + sizeof(tlvbuf_wps_ie); + else + ie_len_wps = 0; + } +} + +/** + * @brief Print WIFIDIRECT IE elements from event payload + * + * @param buffer Pointer to received buffer + * @param size Length of the received event data + * @return N/A + */ +static void print_wifidirect_ie_elements(t_u8 *buffer, t_u16 size) +{ + t_u8 *ptr = buffer; + t_u8 *array_ptr, *orig_ptr = NULL; + int i; + static t_u16 len = 0; + static t_u16 saved_len = 0; + static t_u16 pending_len = 0; + static t_u8 type = 0; + static t_u8 next_byte = WIFIDIRECT_OVERLAP_TYPE; + static t_u8 saved_data[WIFI_IE_MAX_PAYLOAD] = {0}; + t_u16 temp; + t_u16 left_len = size; + + while (left_len > 0) { + if (next_byte == WIFIDIRECT_OVERLAP_TYPE) { + type = *ptr; + next_byte = WIFIDIRECT_OVERLAP_LEN; + left_len--; + ptr++; + } + if (left_len >= sizeof(len) && + next_byte == WIFIDIRECT_OVERLAP_LEN) { + memcpy(&len, ptr, sizeof(t_u16)); + len = uap_le16_to_cpu(len); + next_byte = WIFIDIRECT_OVERLAP_DATA; + left_len -= sizeof(t_u16); + ptr += sizeof(t_u16); + + /* case when Type, Len in one frame and data in next */ + if (left_len == 0) { + memcpy(saved_data, + ptr - WIFIDIRECT_IE_HEADER_LEN, + WIFIDIRECT_IE_HEADER_LEN); + saved_len = WIFIDIRECT_IE_HEADER_LEN; + pending_len = len; + } + } + if (left_len > 0 && next_byte == WIFIDIRECT_OVERLAP_DATA) { + /* copy next data */ + if (pending_len > 0 && + (left_len <= (WIFI_IE_MAX_PAYLOAD - saved_len))) { + memcpy(saved_data + saved_len, ptr, + pending_len); + orig_ptr = ptr; + ptr = saved_data; + } else { + ptr -= WIFIDIRECT_IE_HEADER_LEN; + } + + if (!pending_len && !orig_ptr && left_len < len) { + /* save along with type and len */ + memcpy(saved_data, + ptr - WIFIDIRECT_IE_HEADER_LEN, + left_len + WIFIDIRECT_IE_HEADER_LEN); + saved_len = left_len + WIFIDIRECT_IE_HEADER_LEN; + pending_len = len - left_len; + break; + } + switch (type) { + case TLV_TYPE_WIFIDIRECT_DEVICE_ID: { + tlvbuf_wifidirect_device_id *wifidirect_tlv = + (tlvbuf_wifidirect_device_id *)ptr; + printf("\t Device ID - "); + print_mac(wifidirect_tlv->dev_mac_address); + printf("\n"); + } break; + case TLV_TYPE_WIFIDIRECT_CAPABILITY: { + tlvbuf_wifidirect_capability *wifidirect_tlv = + (tlvbuf_wifidirect_capability *)ptr; + printf("\t Device capability = %d\n", + (int)wifidirect_tlv->dev_capability); + printf("\t Group capability = %d\n", + (int)wifidirect_tlv->group_capability); + } break; + case TLV_TYPE_WIFIDIRECT_GROUPOWNER_INTENT: { + tlvbuf_wifidirect_group_owner_intent + *wifidirect_tlv = + (tlvbuf_wifidirect_group_owner_intent + *)ptr; + printf("\t Group owner intent = %d\n", + (int)wifidirect_tlv->dev_intent); + } break; + case TLV_TYPE_WIFIDIRECT_MANAGEABILITY: { + tlvbuf_wifidirect_manageability *wifidirect_tlv = + (tlvbuf_wifidirect_manageability *)ptr; + printf("\t Manageability = %d\n", + (int)wifidirect_tlv->manageability); + } break; + case TLV_TYPE_WIFIDIRECT_INVITATION_FLAG: { + tlvbuf_wifidirect_invitation_flag *wifidirect_tlv = + (tlvbuf_wifidirect_invitation_flag *)ptr; + printf("\t Invitation Flag = %d\n", + (int)wifidirect_tlv->invitation_flag & + INVITATION_FLAG_MASK); + } break; + case TLV_TYPE_WIFIDIRECT_CHANNEL_LIST: { + tlvbuf_wifidirect_channel_list *wifidirect_tlv = + (tlvbuf_wifidirect_channel_list *)ptr; + chan_entry *temp_ptr; + printf("\t Country String %c%c", + wifidirect_tlv->country_string[0], + wifidirect_tlv->country_string[1]); + if (isalpha(wifidirect_tlv->country_string[2])) + printf("%c", + wifidirect_tlv + ->country_string[2]); + printf("\n"); + temp_ptr = (chan_entry *)wifidirect_tlv + ->wifidirect_chan_entry_list; + temp = uap_le16_to_cpu(wifidirect_tlv->length) - + (sizeof(tlvbuf_wifidirect_channel_list) - + WIFIDIRECT_IE_HEADER_LEN); + while (temp) { + printf("\t Regulatory_class = %d\n", + (int)(temp_ptr->regulatory_class)); + printf("\t No of channels = %d\n", + (int)temp_ptr->num_of_channels); + printf("\t Channel list = "); + for (i = 0; + i < temp_ptr->num_of_channels; + i++) { + printf("%d ", + *(temp_ptr->chan_list + + i)); + } + printf("\n"); + temp -= sizeof(chan_entry) + + temp_ptr->num_of_channels; + temp_ptr = + (chan_entry + *)((t_u8 *)temp_ptr + + sizeof(chan_entry) + + temp_ptr->num_of_channels); + } + printf("\n"); + } break; + case TLV_TYPE_WIFIDIRECT_NOTICE_OF_ABSENCE: { + tlvbuf_wifidirect_notice_of_absence + *wifidirect_tlv = + (tlvbuf_wifidirect_notice_of_absence + *)ptr; + noa_descriptor *temp_ptr; + printf("\t Instance of Notice of absence timing %d\n", + (int)wifidirect_tlv->noa_index); + printf("\t CTWindow and Opportunistic power save parameters %d\n", + (int)wifidirect_tlv->ctwindow_opp_ps); + temp_ptr = + (noa_descriptor *)wifidirect_tlv + ->wifidirect_noa_descriptor_list; + temp = uap_le16_to_cpu(wifidirect_tlv->length) - + (sizeof(tlvbuf_wifidirect_notice_of_absence) - + WIFIDIRECT_IE_HEADER_LEN); + while (temp) { + printf("\t Count or Type = %d\n", + (int)temp_ptr->count_type); + printf("\t Duration = %dms\n", + uap_le32_to_cpu( + temp_ptr->duration)); + printf("\t Interval = %dms\n", + uap_le32_to_cpu( + temp_ptr->interval)); + printf("\t Start Time = %d\n", + uap_le32_to_cpu( + temp_ptr->start_time)); + printf("\n"); + temp_ptr = + (noa_descriptor + *)((t_u8 *)temp_ptr + + sizeof(noa_descriptor)); + temp -= sizeof(noa_descriptor); + } + } break; + case TLV_TYPE_WIFIDIRECT_DEVICE_INFO: { + tlvbuf_wifidirect_device_info *wifidirect_tlv = + (tlvbuf_wifidirect_device_info *)ptr; + printf("\t Device address - "); + print_mac(wifidirect_tlv->dev_address); + printf("\n"); + printf("\t Config methods - 0x%02X\n", + ntohs(wifidirect_tlv->config_methods)); + printf("\t Primay device type = %02d-%02X%02X%02X%02X-%02d\n", + (int)ntohs( + wifidirect_tlv->primary_category), + (int)wifidirect_tlv->primary_oui[0], + (int)wifidirect_tlv->primary_oui[1], + (int)wifidirect_tlv->primary_oui[2], + (int)wifidirect_tlv->primary_oui[3], + (int)ntohs( + wifidirect_tlv + ->primary_subcategory)); + printf("\t Secondary Device Count = %d\n", + (int)wifidirect_tlv->secondary_dev_count); + array_ptr = wifidirect_tlv->secondary_dev_info; + for (i = 0; + i < wifidirect_tlv->secondary_dev_count; + i++) { + memcpy(&temp, array_ptr, sizeof(t_u16)); + printf("\t Secondary device type = %02d-", + ntohs(temp)); + array_ptr += sizeof(temp); + printf("%02X%02X%02X%02X", array_ptr[0], + array_ptr[1], array_ptr[2], + array_ptr[3]); + array_ptr += 4; + memcpy(&temp, array_ptr, sizeof(t_u16)); + printf("-%02d\n", ntohs(temp)); + array_ptr += sizeof(temp); + } + /* display device name */ + array_ptr = + wifidirect_tlv->secondary_dev_info + + (wifidirect_tlv->secondary_dev_count * + WPS_DEVICE_TYPE_LEN) + + 2 * sizeof(t_u16); + if (*(t_u16 *)(((t_u8 *)(wifidirect_tlv + ->secondary_dev_info)) + + (wifidirect_tlv + ->secondary_dev_count * + WPS_DEVICE_TYPE_LEN) + + 2 * sizeof(t_u16))) + printf("\t Device Name = "); + memcpy(&temp, + (((t_u8 *)(wifidirect_tlv + ->secondary_dev_info)) + + (wifidirect_tlv->secondary_dev_count * + WPS_DEVICE_TYPE_LEN) + + sizeof(t_u16)), + sizeof(t_u16)); + temp = ntohs(temp); + for (i = 0; i < temp; i++) + printf("%c", *array_ptr++); + printf("\n"); + } break; + case TLV_TYPE_WIFIDIRECT_GROUP_INFO: { + tlvbuf_wifidirect_group_info *wifidirect_tlv = + (tlvbuf_wifidirect_group_info *)ptr; + t_u8 wifidirect_client_dev_length; + wifidirect_client_dev_info *temp_ptr; + temp_ptr = (wifidirect_client_dev_info + *)wifidirect_tlv + ->wifidirect_client_dev_list; + if (temp_ptr == NULL) + break; + wifidirect_client_dev_length = + temp_ptr->dev_length; + temp = uap_le16_to_cpu(wifidirect_tlv->length) - + wifidirect_client_dev_length; + while (temp_ptr) { + printf("\t Group WifiDirect Client Device address - "); + print_mac( + temp_ptr->wifidirect_dev_address); + printf("\n"); + printf("\t Group WifiDirect Client Interface address - "); + print_mac( + temp_ptr->wifidirect_intf_address); + printf("\n"); + printf("\t Group WifiDirect Client Device capability = %d\n", + (int)temp_ptr + ->wifidirect_dev_capability); + printf("\t Group WifiDirect Client Config methods - 0x%02X\n", + ntohs(temp_ptr->config_methods)); + printf("\t Group WifiDirect Client Primay device type = %02d-%02X%02X%02X%02X-%02d\n", + (int)ntohs( + temp_ptr->primary_category), + (int)temp_ptr->primary_oui[0], + (int)temp_ptr->primary_oui[1], + (int)temp_ptr->primary_oui[2], + (int)temp_ptr->primary_oui[3], + (int)ntohs( + temp_ptr->primary_subcategory)); + printf("\t Group WifiDirect Client Secondary Device Count = %d\n", + (int)temp_ptr + ->wifidirect_secondary_dev_count); + array_ptr = + temp_ptr->wifidirect_secondary_dev_info; + for (i = 0; + i < + temp_ptr->wifidirect_secondary_dev_count; + i++) { + memcpy(&temp, array_ptr, + sizeof(t_u16)); + printf("\t Group WifiDirect Client Secondary device type = %02d-", + ntohs(temp)); + array_ptr += sizeof(temp); + printf("%02X%02X%02X%02X", + array_ptr[0], + array_ptr[1], + array_ptr[2], + array_ptr[3]); + array_ptr += 4; + memcpy(&temp, array_ptr, + sizeof(t_u16)); + printf("-%02d\n", ntohs(temp)); + array_ptr += sizeof(temp); + } + /* display device name */ + array_ptr = + temp_ptr->wifidirect_device_name + + temp_ptr->wifidirect_secondary_dev_count * + WPS_DEVICE_TYPE_LEN; + printf("\t Group WifiDirect Device Name = "); + memcpy(&temp, + (((t_u8 *)(&temp_ptr->wifidirect_device_name_len)) + + temp_ptr->wifidirect_secondary_dev_count * + WPS_DEVICE_TYPE_LEN), + sizeof(t_u16)); + temp = ntohs(temp); + for (i = 0; i < temp; i++) + printf("%c", *array_ptr++); + printf("\n"); + temp_ptr += + wifidirect_client_dev_length; + temp -= wifidirect_client_dev_length; + if (temp_ptr) + wifidirect_client_dev_length = + temp_ptr->dev_length; + } + printf("\n"); + } break; + case TLV_TYPE_WIFIDIRECT_GROUP_ID: { + tlvbuf_wifidirect_group_id *wifidirect_tlv = + (tlvbuf_wifidirect_group_id *)ptr; + printf("\t Group address - "); + print_mac(wifidirect_tlv->group_address); + printf("\n"); + printf("\t Group ssid = "); + for (i = 0; + (unsigned int)i < + uap_le16_to_cpu(wifidirect_tlv->length) - + (sizeof(tlvbuf_wifidirect_group_id) - + WIFIDIRECT_IE_HEADER_LEN); + i++) + printf("%c", + wifidirect_tlv->group_ssid[i]); + printf("\n"); + } break; + case TLV_TYPE_WIFIDIRECT_GROUP_BSS_ID: { + tlvbuf_wifidirect_group_bss_id *wifidirect_tlv = + (tlvbuf_wifidirect_group_bss_id *)ptr; + printf("\t Group BSS Id - "); + print_mac(wifidirect_tlv->group_bssid); + printf("\n"); + } break; + case TLV_TYPE_WIFIDIRECT_INTERFACE: { + tlvbuf_wifidirect_interface *wifidirect_tlv = + (tlvbuf_wifidirect_interface *)ptr; + printf("\t Interface Id - "); + print_mac(wifidirect_tlv->interface_id); + printf("\t Interface count = %d", + (int)wifidirect_tlv->interface_count); + for (i = 0; i < wifidirect_tlv->interface_count; + i++) { + printf("\n\t Interface address [%d]", + i + 1); + print_mac( + &wifidirect_tlv->interface_idlist + [i * ETH_ALEN]); + } + printf("\n"); + } break; + case TLV_TYPE_WIFIDIRECT_CHANNEL: { + tlvbuf_wifidirect_channel *wifidirect_tlv = + (tlvbuf_wifidirect_channel *)ptr; + printf("\t Listen Channel Country String %c%c", + wifidirect_tlv->country_string[0], + wifidirect_tlv->country_string[1]); + if (isalpha(wifidirect_tlv->country_string[2])) + printf("%c", + wifidirect_tlv + ->country_string[2]); + printf("\n"); + printf("\t Listen Channel regulatory class = %d\n", + (int)wifidirect_tlv->regulatory_class); + printf("\t Listen Channel number = %d\n", + (int)wifidirect_tlv->channel_number); + } break; + + case TLV_TYPE_WIFIDIRECT_OPCHANNEL: { + tlvbuf_wifidirect_channel *wifidirect_tlv = + (tlvbuf_wifidirect_channel *)ptr; + printf("\t Operating Channel Country String %c%c", + wifidirect_tlv->country_string[0], + wifidirect_tlv->country_string[1]); + if (isalpha(wifidirect_tlv->country_string[2])) + printf("%c", + wifidirect_tlv + ->country_string[2]); + printf("\n"); + printf("\t Operating Channel regulatory class = %d\n", + (int)wifidirect_tlv->regulatory_class); + printf("\t Operating Channel number = %d\n", + (int)wifidirect_tlv->channel_number); + } break; + + case TLV_TYPE_WIFIDIRECT_CONFIG_TIMEOUT: { + tlvbuf_wifidirect_config_timeout *wifidirect_tlv = + (tlvbuf_wifidirect_config_timeout *)ptr; + printf("\t GO configuration timeout = %d msec\n", + (int)wifidirect_tlv->group_config_timeout * + 10); + printf("\t Client configuration timeout = %d msec\n", + (int)wifidirect_tlv + ->device_config_timeout * + 10); + } break; + case TLV_TYPE_WIFIDIRECT_EXTENDED_LISTEN_TIME: { + tlvbuf_wifidirect_ext_listen_time *wifidirect_tlv = + (tlvbuf_wifidirect_ext_listen_time *)ptr; + printf("\t Availability Period = %d msec\n", + (int)wifidirect_tlv->availability_period); + printf("\t Availability Interval = %d msec\n", + (int)wifidirect_tlv + ->availability_interval); + } break; + case TLV_TYPE_WIFIDIRECT_INTENDED_ADDRESS: { + tlvbuf_wifidirect_intended_addr *wifidirect_tlv = + (tlvbuf_wifidirect_intended_addr *)ptr; + printf("\t Intended Interface Address - "); + print_mac(wifidirect_tlv->group_address); + printf("\n"); + } break; + + case TLV_TYPE_WIFIDIRECT_STATUS: { + tlvbuf_wifidirect_status *wifidirect_tlv = + (tlvbuf_wifidirect_status *)ptr; + printf("\t Status = %d\n", + wifidirect_tlv->status_code); + } break; + + default: + printf("unknown ie=0x%x, len=%d\n", type, len); + break; + } + next_byte = WIFIDIRECT_OVERLAP_TYPE; + if (orig_ptr) + ptr = orig_ptr + pending_len; + } + ptr += len + WIFIDIRECT_IE_HEADER_LEN; + left_len -= len; + } + printf("\n"); + return; +} + +/** + * @brief Parse and print WIFIDIRECT generic event data + * + * @param buffer Pointer to received buffer + * @param size Length of the received event data + * @return N/A + */ +static void print_event_wifidirect_generic(t_u8 *buffer, t_u16 size) +{ + const t_u8 wifi_oui[3] = {0x50, 0x6F, 0x9A}; + const t_u8 wps_oui[3] = {0x00, 0x50, 0xF2}; + apeventbuf_wifidirect_generic *wifidirect_event; + wifidirect_ie_header *wifidirect_wps_header; + t_u16 wifidirect_wps_len = 0, type, sub_type; + printf("EVENT: WIFIDIRECT \n"); + wifidirect_event = (apeventbuf_wifidirect_generic *)(buffer); + printf("Event length = %d\n", + uap_le16_to_cpu(wifidirect_event->event_length)); + printf("Event Type = "); + type = uap_le16_to_cpu(wifidirect_event->event_type); + switch (type) { + case 0: + printf("Negotiation Request\n"); + break; + case 1: + printf("Negotiation Response\n"); + break; + case 2: + printf("Negotiation Result\n"); + break; + case 3: + printf("Invitation Request\n"); + break; + case 4: + printf("Invitation Response\n"); + break; + case 5: + printf("Discoverability Request\n"); + break; + case 6: + printf("Discoverability Response\n"); + break; + case 7: + printf("Provision Discovery Request\n"); + break; + case 8: + printf("Provision Discovery Response\n"); + break; + case 9: + printf("GO Negotiation response Tx Event\n"); + break; + case 10: + printf("GO Negotiation confirm Tx Event\n"); + break; + case 14: + printf("Peer Detected event\n"); + break; + case 15: + printf("Client associated event\n"); + break; + case 16: + printf("FW debug event: %s\n", + wifidirect_event->entire_ie_list); + return; + default: + printf("Unknown\n"); + break; + } + sub_type = uap_le16_to_cpu(wifidirect_event->event_sub_type); + if (type == 2) { + switch (sub_type) { + case 0: + printf("Event SubType = No Role\n"); + break; + case 1: + printf("Event SubType = Group Owner Role\n"); + break; + case 2: + printf("Event SubType = Client Role\n"); + break; + default: + printf("Event SubType = %d\n", sub_type); + break; + } + } else if (type == 3 || type == 4) { + switch (sub_type & 0x03) /* lower 2 bits */ { + case 0: + printf("Event SubType = No Role\n"); + break; + case 1: + printf("Event SubType = Group Owner Role\n"); + break; + case 2: + printf("Event SubType = Client Role\n"); + break; + } + switch ((sub_type & 0x1C) >> 2) /* next 3 bits */ { + case 0: + printf("Packet processing state = None\n"); + break; + case 1: + printf("Packet processing state = Processing\n"); + break; + case 2: + printf("Packet processing state = Insufficient information, Dropped\n"); + break; + case 3: + printf("Packet processing state = Success\n"); + break; + case 4: + printf("Packet processing state = Fail\n"); + break; + default: + printf("Event SubType = %d\n", sub_type); + break; + } + } else if (type == 7 || type == 8) { + switch (sub_type) { + case 0: + printf("Event SubType = No Config Method\n"); + break; + case 8: + printf("Event SubType = Config Method Display\n"); + break; + case 0x80: + printf("Event SubType = Config Method Push Button\n"); + break; + case 0x100: + printf("Event SubType = Config Method Keypad\n"); + break; + default: + printf("Event SubType = %d\n", sub_type); + break; + } + } + printf("Peer Mac Address - "); + print_mac(wifidirect_event->peer_mac_addr); + printf("\n"); + /* Print rest of IE elements */ + wifidirect_wps_header = + (wifidirect_ie_header *)(wifidirect_event->entire_ie_list); + wifidirect_wps_len = uap_le16_to_cpu(wifidirect_event->event_length) - + sizeof(apeventbuf_wifidirect_generic); + + while (wifidirect_wps_len >= sizeof(wifidirect_ie_header)) { + if (!memcmp(wifidirect_wps_header->oui, wifi_oui, + sizeof(wifi_oui)) || + !(memcmp(wifidirect_wps_header->oui, wps_oui, + sizeof(wps_oui)))) { + switch (wifidirect_wps_header->oui_type) { + case WIFIDIRECT_OUI_TYPE: + print_wifidirect_ie_elements( + wifidirect_wps_header->ie_list, + wifidirect_wps_header->ie_length - + sizeof(wifidirect_wps_header + ->oui) - + sizeof(wifidirect_wps_header + ->oui_type)); + printf("\n"); + break; + case WIFI_WPS_OUI_TYPE: + print_wifi_wps_ie_elements( + wifidirect_wps_header->ie_list, + wifidirect_wps_header->ie_length - + sizeof(wifidirect_wps_header + ->oui) - + sizeof(wifidirect_wps_header + ->oui_type)); + printf("\n"); + break; + } + } + wifidirect_wps_len -= + wifidirect_wps_header->ie_length + IE_HEADER_LEN; + wifidirect_wps_header = + (wifidirect_ie_header + *)(((t_u8 *)wifidirect_wps_header) + + wifidirect_wps_header->ie_length + + IE_HEADER_LEN); + } +} + +/** + * @brief Parse and print WIFIDIRECT service discovery event data + * + * @param buffer Pointer to received buffer + * @param size Length of the received event data + * @return N/A + */ +static void print_event_wifidirect_service_discovery(t_u8 *buffer, t_u16 size) +{ + unsigned int i; + t_u16 event_len = 0; + t_u16 dns_len = 0, dns_type; + t_u8 action = 0; /* req = 0, resp = 1 */ + apeventbuf_wifidirect_discovery_request *wifidirect_disc_req; + apeventbuf_wifidirect_discovery_response *wifidirect_disc_resp; + printf("EVENT: WIFIDIRECT SERVICE DISCOVERY\n"); + memcpy(&event_len, buffer, sizeof(t_u16)); + event_len = uap_le16_to_cpu(event_len); + printf("Event length = %d\n", event_len); + printf("Service Discovery packet:\n"); + /* check request /response Byte at offset 2+6+2 */ + action = *(buffer + sizeof(t_u16) + ETH_ALEN + sizeof(t_u8)); + if (action == WIFIDIRECT_DISCOVERY_REQUEST_ACTION) { + wifidirect_disc_req = (apeventbuf_wifidirect_discovery_request + *)(buffer + sizeof(t_u16)); + printf("\t Peer Mac Address - "); + print_mac(wifidirect_disc_req->peer_mac_addr); + printf("\n\t Category = %d\n", wifidirect_disc_req->category); + printf("\t Action = %d\n", wifidirect_disc_req->action); + printf("\t Dialog taken = %d\n", + wifidirect_disc_req->dialog_taken); + printf("\t Advertize protocol IE - 0x%02x, 0x%02x, 0x%02x, 0x%02x\n", + wifidirect_disc_req->advertize_protocol_ie[0], + wifidirect_disc_req->advertize_protocol_ie[1], + wifidirect_disc_req->advertize_protocol_ie[2], + wifidirect_disc_req->advertize_protocol_ie[3]); + printf("\t Request query length = %d\n", + uap_le16_to_cpu(wifidirect_disc_req->query_len)); + printf("\t Information Id - 0x%02x, 0x%02x\n", + wifidirect_disc_req->info_id[0], + wifidirect_disc_req->info_id[1]); + printf("\t Request length = %d\n", + uap_le16_to_cpu(wifidirect_disc_req->request_len)); + printf("\t OUI - 0x%02x, 0x%02x, 0x%02x\n", + wifidirect_disc_req->oui[0], wifidirect_disc_req->oui[1], + wifidirect_disc_req->oui[2]); + printf("\t OUI sub type = %d\n", + wifidirect_disc_req->oui_sub_type); + printf("\t Service update Indicator = %d\n", + uap_le16_to_cpu( + wifidirect_disc_req->service_update_indicator)); + printf("\t Vendor length = %d\n", + uap_le16_to_cpu(wifidirect_disc_req->vendor_len)); + printf("\t Service protocol = %d\n", + wifidirect_disc_req->service_protocol); + printf("\t Service transaction Id = %d\n", + wifidirect_disc_req->service_transaction_id); + printf("\t Query Data = "); + if (wifidirect_disc_req->service_protocol == 1) { + printf(" * Bonjour * \n"); + printf("\t\t DNS = "); + dns_len = uap_le16_to_cpu( + wifidirect_disc_req->vendor_len) - + WIFIDIRECT_DISCOVERY_BONJOUR_FIXED_LEN; + for (i = 0; i < dns_len; i++) + printf("%02x ", + (int)*(wifidirect_disc_req->disc_query.u + .bonjour.dns + + i)); + memcpy(&dns_type, + (&wifidirect_disc_req->disc_query.u.bonjour + .dns_type + + dns_len), + sizeof(dns_type)); + dns_type = uap_le16_to_cpu(dns_type); + printf("\n\t\t DNS Type = %d\n", dns_type); + printf("\t\t Version = %d\n", + *(&wifidirect_disc_req->disc_query.u.bonjour + .version + + dns_len)); + } else if (wifidirect_disc_req->service_protocol == 2) { + printf(" * uPnP * \n"); + printf("\t\t Version = %d\n", + wifidirect_disc_req->disc_query.u.upnp.version); + dns_len = uap_le16_to_cpu( + wifidirect_disc_req->vendor_len) - + WIFIDIRECT_DISCOVERY_UPNP_FIXED_LEN; + printf("\t\t Value = "); + for (i = 0; i < dns_len; i++) + printf("%02x ", + (int)*(wifidirect_disc_req->disc_query.u + .upnp.value + + i)); + } + printf("\n"); + } else if (action == WIFIDIRECT_DISCOVERY_RESPONSE_ACTION) { + wifidirect_disc_resp = (apeventbuf_wifidirect_discovery_response + *)(buffer + sizeof(t_u16)); + printf("\t Peer Mac Address - "); + print_mac(wifidirect_disc_resp->peer_mac_addr); + printf("\n\t Category = %d\n", wifidirect_disc_resp->category); + printf("\t Action = %d\n", wifidirect_disc_resp->action); + printf("\t Dialog taken = %d\n", + wifidirect_disc_resp->dialog_taken); + printf("\t Status code = %d\n", + wifidirect_disc_resp->status_code); + printf("\t GAS reply - 0x%02x\n", + uap_le16_to_cpu(wifidirect_disc_resp->gas_reply)); + printf("\t Advertize protocol IE - 0x%02x, 0x%02x, 0x%02x, 0x%02x\n", + wifidirect_disc_resp->advertize_protocol_ie[0], + wifidirect_disc_resp->advertize_protocol_ie[1], + wifidirect_disc_resp->advertize_protocol_ie[2], + wifidirect_disc_resp->advertize_protocol_ie[3]); + printf("\t Response query length = %d\n", + uap_le16_to_cpu(wifidirect_disc_resp->query_len)); + printf("\t Information Id - 0x%02x, 0x%02x\n", + wifidirect_disc_resp->info_id[0], + wifidirect_disc_resp->info_id[1]); + printf("\t Response length = %d\n", + uap_le16_to_cpu(wifidirect_disc_resp->response_len)); + printf("\t OUI - 0x%02x, 0x%02x, 0x%02x\n", + wifidirect_disc_resp->oui[0], + wifidirect_disc_resp->oui[1], + wifidirect_disc_resp->oui[2]); + printf("\t OUI sub type = %d\n", + wifidirect_disc_resp->oui_sub_type); + printf("\t Service update Indicator = %d\n", + uap_le16_to_cpu( + wifidirect_disc_resp->service_update_indicator)); + printf("\t Vendor length = %d\n", + uap_le16_to_cpu(wifidirect_disc_resp->vendor_len)); + printf("\t Service protocol = %d\n", + wifidirect_disc_resp->service_protocol); + printf("\t Service transaction Id = %d\n", + wifidirect_disc_resp->service_transaction_id); + printf("\t Status Code = %d\n", + wifidirect_disc_resp->disc_status_code); + printf("\t Response Data = "); + if (wifidirect_disc_resp->service_protocol == 1) { + printf(" * Bonjour * \n"); + /* + printf("\t\t DNS = "); + dns_len = + uap_le16_to_cpu(wifidirect_disc_resp->vendor_len) - + (WIFIDIRECT_DISCOVERY_BONJOUR_FIXED_LEN + + 1); for( i=0; i < dns_len; i++) + printf("%c",*(wifidirect_disc_resp->disc_resp.u.bonjour.dns + + i)); memcpy(&dns_type, + (&wifidirect_disc_req->disc_query.u.bonjour.dns_type + + dns_len), sizeof(dns_type)); + dns_type = uap_le16_to_cpu(dns_type); + printf("\n\t\t DNS Type = %d\n", dns_type); + printf("\t\t Version = %d\n", + *(&wifidirect_disc_resp->disc_resp.u.bonjour.version + + dns_len)); + */ + } else if (wifidirect_disc_resp->service_protocol == 2) { + printf(" * uPnP * \n"); + printf("\t\t Version = %d\n", + wifidirect_disc_resp->disc_resp.u.upnp.version); + dns_len = uap_le16_to_cpu( + wifidirect_disc_resp->vendor_len) - + WIFIDIRECT_DISCOVERY_UPNP_FIXED_LEN; + printf("\t\t Value = "); + for (i = 0; i < dns_len; i++) + printf("%02x ", + (int)*(wifidirect_disc_resp->disc_resp.u + .upnp.value + + i)); + } + printf("\n"); + } +} +#endif + +/** + * @brief Parse and print TDLS generic event data + * + * @param buffer Pointer to received buffer + * @param size Length of the received event data + * @return N/A + */ +static void print_event_tdls_generic(t_u8 *buffer, t_u16 size) +{ + eventbuf_tdls_generic *tdls_event; + eventbuf_tdls_debug *tdls_debug; + eventbuf_tdls_packet *tdls_pkt; + printf("EVENT: TDLS\n"); + tdls_event = (eventbuf_tdls_generic *)(buffer); + printf("Event Type = "); + switch (uap_le16_to_cpu(tdls_event->event_type)) { + case TDLS_EVENT_TYPE_SETUP_FAILURE: + printf("TDLS setup failure\n"); + break; + case TDLS_EVENT_TYPE_SETUP_REQ_RCVD: + printf("TDLS setup request received from peer\n"); + break; + case TDLS_EVENT_TYPE_LINK_TORN_DOWN: + printf("TDLS link torn down\n"); + break; + case TDLS_EVENT_TYPE_LINK_ESTABLISHED: + printf("TDLS link established\n"); + break; + case TDLS_EVENT_TYPE_DEBUG: + tdls_debug = (eventbuf_tdls_debug *)(buffer); + printf("TDLS debug event, "); + printf("TSF = %lld\n", uap_le64_to_cpu(tdls_debug->tsf)); + printf("String = "); + printf((char *)(tdls_debug->string), + uap_le32_to_cpu(tdls_debug->first_arg), + uap_le32_to_cpu(tdls_debug->second_arg), + uap_le32_to_cpu(tdls_debug->third_arg)); + printf("\n"); + return; + case TDLS_EVENT_TYPE_PACKET: + tdls_pkt = (eventbuf_tdls_packet *)(buffer); + printf("TDLS packet len=%d\n", tdls_pkt->length); + hexdump((t_u8 *)tdls_pkt->data, tdls_pkt->length, ' '); + return; + case TDLS_EVENT_TYPE_CHAN_SWITCH_RESULT: + if (tdls_event->u.switch_result.status) { + printf("TDLS Channel Switch Failed! current channel=%d Reasoncode %d\n", + tdls_event->u.switch_result.current_channel, + tdls_event->u.switch_result.reason); + } else { + printf("TDLS Channel Switch Successful. current channel=%d\n", + tdls_event->u.switch_result.current_channel); + } + break; + case TDLS_EVENT_TYPE_START_CHAN_SWITCH: + printf("TDLS Start channel switch...\n"); + break; + case TDLS_EVENT_TYPE_CHAN_SWITCH_STOPPED: + printf("TDLS Channel Switch stopped! reason=%d\n", + tdls_event->u.cs_stop_reason); + break; + default: + printf("Unknown\n"); + break; + } + printf("Peer Mac Address - "); + print_mac(tdls_event->peer_mac_addr); + printf("\n"); + if (uap_le16_to_cpu(tdls_event->event_type) == + TDLS_EVENT_TYPE_SETUP_FAILURE) { + switch (uap_le16_to_cpu(tdls_event->u.reason_code)) { + case 1: + printf("Reason Code = Internal error\n"); + break; + case 7: + printf("Reason Code = Timeout waiting for response\n"); + break; + case 8: + printf("Reason Code = Non-zero setup response status\n"); + break; + default: + printf("Reason Code = %d\n", + uap_le16_to_cpu(tdls_event->u.reason_code)); + break; + } + } else if (uap_le16_to_cpu(tdls_event->event_type) == + TDLS_EVENT_TYPE_LINK_TORN_DOWN) { + switch (uap_le16_to_cpu(tdls_event->u.reason_code)) { + case 3: + printf("Reason Code = Peer station is leaving BSS\n"); + break; + case 25: + printf("Reason Code = Peer station is unreachable on direct link\n"); + break; + case 26: + printf("Reason Code = Unspecified\n"); + break; + case 211: + printf("Reason Code = Setup received from TDLS peer\n"); + break; + case 212: + printf("Reason Code = Clearing TDLS connections due to deauth/disassoc\n"); + break; + default: + printf("Reason Code = %d\n", + uap_le16_to_cpu(tdls_event->u.reason_code)); + break; + } + } else if (uap_le16_to_cpu(tdls_event->event_type) == + TDLS_EVENT_TYPE_LINK_ESTABLISHED) { + int ie_len = uap_le16_to_cpu(tdls_event->u.ie_length); + if (ie_len) { + printf("Peer IE len=%d\n", ie_len); + hexdump((t_u8 *)tdls_event->ie_ptr, ie_len, ' '); + } + } +} + +/** + * @brief Prints station reject state + * + * @param state Fail state + * @return N/A + */ +static void print_reject_state(t_u8 state) +{ + switch (state) { + case REJECT_STATE_FAIL_EAPOL_2: + printf("Reject state: FAIL_EAPOL_2\n"); + break; + case REJECT_STATE_FAIL_EAPOL_4: + printf("Reject state: FAIL_EAPOL_4:\n"); + break; + case REJECT_STATE_FAIL_EAPOL_GROUP_2: + printf("Reject state: FAIL_EAPOL_GROUP_2\n"); + break; + default: + printf("ERR: unknown reject state %d\n", state); + break; + } + return; +} + +/** + * @brief Prints station reject reason + * + * @param reason Reason code + * @return N/A + */ +static void print_reject_reason(t_u16 reason) +{ + switch (reason) { + case IEEEtypes_REASON_INVALID_IE: + printf("Reject reason: Invalid IE\n"); + break; + case IEEEtypes_REASON_MIC_FAILURE: + printf("Reject reason: Mic Failure\n"); + break; + default: + printf("Reject reason: %d\n", reason); + break; + } + return; +} + +/** + * @brief Prints EAPOL state + * + * @param state Eapol state + * @return N/A + */ +static void print_eapol_state(t_u8 state) +{ + switch (state) { + case EAPOL_START: + printf("Eapol state: EAPOL_START\n"); + break; + case EAPOL_WAIT_PWK2: + printf("Eapol state: EAPOL_WAIT_PWK2\n"); + break; + case EAPOL_WAIT_PWK4: + printf("Eapol state: EAPOL_WAIT_PWK4\n"); + break; + case EAPOL_WAIT_GTK2: + printf("Eapol state: EAPOL_WAIT_GTK2\n"); + break; + case EAPOL_END: + printf("Eapol state: EAPOL_END\n"); + break; + default: + printf("ERR: unknow eapol state%d\n", state); + break; + } + return; +} + +/** + * @brief Parse and print debug event data + * + * @param buffer Pointer to received buffer + * @param size Length of the received event data + * @return N/A + */ +static void print_event_debug(t_u8 *buffer, t_u16 size) +{ + eventbuf_debug *event_body = NULL; + if (size < sizeof(eventbuf_debug)) { + printf("ERR:Event buffer too small!\n"); + return; + } + event_body = (eventbuf_debug *)buffer; + printf("Debug Event Type: %s\n", + (event_body->debug_type == 0) ? "EVENT" : "INFO"); + printf("%s log:\n", (uap_le32_to_cpu(event_body->debug_id_major) == + DEBUG_ID_MAJ_AUTHENTICATOR) ? + "Authenticator" : + "Assoc_agent"); + if (uap_le32_to_cpu(event_body->debug_id_major) == + DEBUG_ID_MAJ_AUTHENTICATOR) { + switch (uap_le32_to_cpu(event_body->debug_id_minor)) { + case DEBUG_MAJ_AUTH_MIN_PWK1: + printf("EAPOL Key message 1 (PWK):\n"); + hexdump((t_u8 *)&event_body->info.eapol_pwkmsg, + sizeof(eapol_keymsg_debug_t), ' '); + break; + case DEBUG_MAJ_AUTH_MIN_PWK2: + printf("EAPOL Key message 2 (PWK):\n"); + hexdump((t_u8 *)&event_body->info.eapol_pwkmsg, + sizeof(eapol_keymsg_debug_t), ' '); + break; + case DEBUG_MAJ_AUTH_MIN_PWK3: + printf("EAPOL Key message 3 (PWK):\n"); + hexdump((t_u8 *)&event_body->info.eapol_pwkmsg, + sizeof(eapol_keymsg_debug_t), ' '); + break; + case DEBUG_MAJ_AUTH_MIN_PWK4: + printf("EAPOL Key message 4: (PWK)\n"); + hexdump((t_u8 *)&event_body->info.eapol_pwkmsg, + sizeof(eapol_keymsg_debug_t), ' '); + break; + case DEBUG_MAJ_AUTH_MIN_GWK1: + printf("EAPOL Key message 1: (GWK)\n"); + hexdump((t_u8 *)&event_body->info.eapol_pwkmsg, + sizeof(eapol_keymsg_debug_t), ' '); + break; + case DEBUG_MAJ_AUTH_MIN_GWK2: + printf("EAPOL Key message 2: (GWK)\n"); + hexdump((t_u8 *)&event_body->info.eapol_pwkmsg, + sizeof(eapol_keymsg_debug_t), ' '); + break; + case DEBUG_MAJ_AUTH_MIN_STA_REJ: + printf("Reject STA MAC: "); + print_mac(event_body->info.sta_reject.sta_mac_addr); + printf("\n"); + print_reject_state( + event_body->info.sta_reject.reject_state); + print_reject_reason(uap_le16_to_cpu( + event_body->info.sta_reject.reject_reason)); + break; + case DEBUG_MAJ_AUTH_MIN_EAPOL_TR: + printf("STA MAC: "); + print_mac(event_body->info.eapol_state.sta_mac_addr); + printf("\n"); + print_eapol_state( + event_body->info.eapol_state.eapol_state); + break; + default: + printf("ERR: unknow debug_id_minor: %d\n", + (int)uap_le32_to_cpu( + event_body->debug_id_minor)); + hexdump(buffer, size, ' '); + return; + } + } else if (uap_le32_to_cpu(event_body->debug_id_major) == + DEBUG_ID_MAJ_ASSOC_AGENT) { + switch (uap_le32_to_cpu(event_body->debug_id_minor)) { + case DEBUG_ID_MAJ_ASSOC_MIN_WPA_IE: + printf("STA MAC: "); + print_mac(event_body->info.wpaie.sta_mac_addr); + printf("\n"); + printf("wpa ie:\n"); + hexdump(event_body->info.wpaie.wpa_ie, MAX_WPA_IE_LEN, + ' '); + break; + case DEBUG_ID_MAJ_ASSOC_MIN_STA_REJ: + printf("Reject STA MAC: "); + print_mac(event_body->info.sta_reject.sta_mac_addr); + printf("\n"); + print_reject_state( + event_body->info.sta_reject.reject_state); + print_reject_reason(uap_le16_to_cpu( + event_body->info.sta_reject.reject_reason)); + break; + default: + printf("ERR: unknow debug_id_minor: %d\n", + (int)uap_le32_to_cpu( + event_body->debug_id_minor)); + hexdump(buffer, size, ' '); + return; + } + } + return; +} + +/** + * @brief Parse and print received nlist event information + * + * @param buffer Pointer to the data buffer + * @param size Length of the received event + * @return N/A + */ +static void print_event_11k_nlist_report(t_u8 *buffer, t_u16 size) +{ + int tlv_buf_left = 0; + tlvbuf_header *tlv; + nlist_entry_tlv *nlist; + int entry_num = 0; + t_u16 tlv_type, tlv_len; + + if (size < 2) { + printf("No neighbor AP list found: %d\n", size); + return; + } + tlv_buf_left = *(t_u16 *)buffer; + tlv_buf_left = uap_le16_to_cpu(tlv_buf_left); + if (tlv_buf_left < (int)sizeof(tlvbuf_header)) + return; + printf("neighbor AP list tlv len: %d\n", tlv_buf_left); + tlv = (tlvbuf_header *)(buffer + 2); + while (tlv_buf_left >= (int)sizeof(tlvbuf_header)) { + tlv_type = uap_le16_to_cpu(tlv->type); + tlv_len = uap_le16_to_cpu(tlv->len); + if ((sizeof(tlvbuf_header) + tlv_len) > + (unsigned int)tlv_buf_left) { + printf("wrong tlv: tlvLen=%d, tlvBufLeft=%d\n", tlv_len, + tlv_buf_left); + break; + } + switch (tlv_type) { + case MRVL_NEIGHBOR_REPORT_TLV_ID: + nlist = (nlist_entry_tlv *)tlv; + printf("Neighbor entry %d:\n", entry_num); + printf("BSSID: %02x:%02x:%02x:%02x:%02x:%02x \n", + nlist->bssid[0], nlist->bssid[1], + nlist->bssid[2], nlist->bssid[3], + nlist->bssid[4], nlist->bssid[5]); + printf("BSSID Info: %02x:%02x:%02x:%02x \n", + nlist->bssid_info[0], nlist->bssid_info[1], + nlist->bssid_info[2], nlist->bssid_info[3]); + printf("reg class: %d, chan: %d, phy: %d \n", + nlist->reg_class, nlist->chan, nlist->phy_type); + if (tlv_len > sizeof(nlist_entry_tlv)) { + printf("sub IE:\n"); + hexdump((t_u8 *)tlv + sizeof(nlist_entry_tlv), + tlv_len - sizeof(nlist_entry_tlv) + + sizeof(tlvbuf_header), + ' '); + } + entry_num++; + break; + default: +#if DEBUG + printf("unknown tlv: %d\n", tlv_type); +#endif + break; + } + tlv_buf_left -= (sizeof(tlvbuf_header) + tlv_len); + tlv = (tlvbuf_header *)((t_u8 *)tlv + tlv_len + + sizeof(tlvbuf_header)); + } + return; +} + +/** + * @brief Parse and print received event information + * + * @param event Pointer to received event + * @param size Length of the received event + * @return N/A + */ +static void print_event(event_header *event, t_u16 size, char *if_name) +{ + t_u32 event_id = event->event_id; + switch (event_id) { + case MICRO_AP_EV_ID_STA_DEAUTH: + print_event_sta_deauth(event->event_data, size - EVENT_ID_LEN); + break; + case MICRO_AP_EV_ID_STA_ASSOC: + print_event_sta_assoc(event->event_data, size - EVENT_ID_LEN); + break; + case MICRO_AP_EV_ID_BSS_START: + print_event_bss_start(event->event_data, size - EVENT_ID_LEN); + break; + case MICRO_AP_EV_ID_DEBUG: + print_event_debug(event->event_data, size - EVENT_ID_LEN); + break; + case MICRO_AP_EV_BSS_IDLE: + printf("EVENT: BSS_IDLE\n"); + break; + case MICRO_AP_EV_BSS_ACTIVE: + printf("EVENT: BSS_ACTIVE\n"); + break; + case MICRO_AP_EV_RSN_CONNECT: + print_event_rsn_connect(event->event_data, size - EVENT_ID_LEN); + break; + case MICRO_AP_EV_ID_MIC_COUNTERMEASURES: + print_event_mic_countermeasures(event->event_data, + size - EVENT_ID_LEN); + break; +#ifdef WIFI_DIRECT_SUPPORT + case EVENT_WIFIDIRECT_GENERIC: + print_event_wifidirect_generic(event->event_data, + size - EVENT_ID_LEN); + break; + case EVENT_WIFIDIRECT_SERVICE_DISCOVERY: + print_event_wifidirect_service_discovery(event->event_data, + size - EVENT_ID_LEN); + break; +#endif + + case EVENT_TDLS_GENERIC: + print_event_tdls_generic(event->event_data, + size - EVENT_ID_LEN); + break; + case UAP_EVENT_ID_DRV_HS_ACTIVATED: + printf("EVENT: uAP HS_ACTIVATED\n"); + break; + case UAP_EVENT_ID_DRV_HS_DEACTIVATED: + printf("EVENT: uAP HS_DEACTIVATED\n"); + break; + case UAP_EVENT_ID_HS_WAKEUP: + printf("EVENT: uAP HS_WAKEUP\n"); + break; + case UAP_EVENT_HOST_SLEEP_AWAKE: + break; + case UAP_EVENT_ID_DRV_MGMT_FRAME: + printf("EVENT: Mgmt frame from FW\n"); + hexdump((void *)event, size, ' '); + break; + case MICRO_AP_EV_WMM_STATUS_CHANGE: + printf("EVENT: WMM_STATUS_CHANGE\n"); + break; + case EVENT_RADAR_DETECTED: + printf("EVENT: RADAR_DETECTED\n"); + break; + case EVENT_CHANNEL_REPORT_RDY: + printf("EVENT: CHANNEL_REPORT_READY\n"); + hexdump((void *)event, size, ' '); + break; + case EVENT_WEP_ICV_ERROR: + print_event_wep_icv_error(event->event_data, + size - EVENT_ID_LEN); + break; + case EVENT_ID_DRV_SCAN_REPORT: + printf("Scan request completed.\n"); + break; + case EVENT_NLIST_REPORT: + printf("EVENT: 11k neighbor AP list report\n"); + print_event_11k_nlist_report(event->event_data, + size - EVENT_ID_LEN); + break; + default: + /* Handle string based events */ +#define CUS_EVT_PORT_RELEASE "EVENT=PORT_RELEASE" + if (!strncmp((char *)event, CUS_EVT_PORT_RELEASE, + strlen(CUS_EVT_PORT_RELEASE))) { + printf("EVENT: PORT_RELEASE.\n"); + break; + } +#define CUS_EVT_TDLS_CONNECTED "EVENT=TDLS_CONNECTED" + if (!strncmp((char *)event, CUS_EVT_TDLS_CONNECTED, + strlen(CUS_EVT_TDLS_CONNECTED))) { + printf("EVENT: TDLS_CONNECTED\n"); + print_mac((t_u8 *)event + + strlen(CUS_EVT_TDLS_CONNECTED)); + printf("\n"); + break; + } +#define CUS_EVT_TDLS_TEARDOWN "EVENT=TDLS_TEARDOWN" + if (!strncmp((char *)event, CUS_EVT_TDLS_TEARDOWN, + strlen(CUS_EVT_TDLS_TEARDOWN))) { + printf("EVENT: TDLS_TEARDOWN\n"); + print_mac((t_u8 *)event + + strlen(CUS_EVT_TDLS_TEARDOWN)); + printf("\n"); + break; + } +#define CUS_EVT_STA_CONNECTED "EVENT=STA_CONNECTED" + if (!strncmp((char *)event, CUS_EVT_STA_CONNECTED, + strlen(CUS_EVT_STA_CONNECTED))) { + printf("EVENT: STA_CONNECTED\n"); + print_mac((t_u8 *)event + + strlen(CUS_EVT_STA_CONNECTED) + 1); + printf("\n"); + break; + } +#define CUS_EVT_STA_DISCONNECTED "EVENT=STA_DISCONNECTED" + if (!strncmp((char *)event, CUS_EVT_STA_DISCONNECTED, + strlen(CUS_EVT_STA_DISCONNECTED))) { + printf("EVENT: STA_DISCONNECTED\n"); + break; + } +#define CUS_EVT_AP_CONNECTED "EVENT=AP_CONNECTED" + if (!strncmp((char *)event, CUS_EVT_AP_CONNECTED, + strlen(CUS_EVT_AP_CONNECTED))) { + printf("EVENT: AP_CONNECTED\n"); + print_mac((t_u8 *)event + strlen(CUS_EVT_AP_CONNECTED)); + printf("\n"); + break; + } +#define CUS_EVT_ADHOC_LINK_SENSED "EVENT=ADHOC_LINK_SENSED" + if (!strncmp((char *)event, CUS_EVT_ADHOC_LINK_SENSED, + strlen(CUS_EVT_ADHOC_LINK_SENSED))) { + printf("EVENT: ADHOC_LINK_SENSED\n"); + break; + } +#define CUS_EVT_ADHOC_LINK_LOST "EVENT=ADHOC_LINK_LOST" + if (!strncmp((char *)event, CUS_EVT_ADHOC_LINK_LOST, + strlen(CUS_EVT_ADHOC_LINK_LOST))) { + printf("EVENT: ADHOC_LINK_LOST\n"); + break; + } +#define CUS_EVT_OBSS_SCAN_PARAM "EVENT=OBSS_SCAN_PARAM" + if (!strncmp((char *)event, CUS_EVT_OBSS_SCAN_PARAM, + strlen(CUS_EVT_OBSS_SCAN_PARAM))) { + printf("EVENT: OBSS_SCAN_PARAM\n"); + break; + } +#define CUS_EVT_BW_CHANGED "EVENT=BW_CHANGED" + if (!strncmp((char *)event, CUS_EVT_BW_CHANGED, + strlen(CUS_EVT_BW_CHANGED))) { + printf("EVENT: BW_CHANGED\n"); + break; + } +#define CUS_EVT_MLME_MIC_ERR_UNI "MLME-MICHAELMICFAILURE.indication unicast" + if (!strncmp((char *)event, CUS_EVT_MLME_MIC_ERR_UNI, + strlen(CUS_EVT_MLME_MIC_ERR_UNI))) { + printf("EVENT: MLME-MICHAELMICFAILURE.indication unicast\n"); + break; + } +#define CUS_EVT_MLME_MIC_ERR_MUL "MLME-MICHAELMICFAILURE.indication multicast" + if (!strncmp((char *)event, CUS_EVT_MLME_MIC_ERR_MUL, + strlen(CUS_EVT_MLME_MIC_ERR_MUL))) { + printf("EVENT: MLME-MICHAELMICFAILURE.indication multicast\n"); + break; + } +#define CUS_EVT_BEACON_RSSI_LOW "EVENT=BEACON_RSSI_LOW" + if (!strncmp((char *)event, CUS_EVT_BEACON_RSSI_LOW, + strlen(CUS_EVT_BEACON_RSSI_LOW))) { + printf("EVENT: BEACON_RSSI_LOW\n"); + break; + } +#define CUS_EVT_BEACON_RSSI_HIGH "EVENT=BEACON_RSSI_HIGH" + if (!strncmp((char *)event, CUS_EVT_BEACON_RSSI_HIGH, + strlen(CUS_EVT_BEACON_RSSI_HIGH))) { + printf("EVENT: BEACON_RSSI_HIGH\n"); + break; + } +#define CUS_EVT_BEACON_SNR_LOW "EVENT=BEACON_SNR_LOW" + if (!strncmp((char *)event, CUS_EVT_BEACON_SNR_LOW, + strlen(CUS_EVT_BEACON_SNR_LOW))) { + printf("EVENT: BEACON_SNR_LOW\n"); + break; + } +#define CUS_EVT_BEACON_SNR_HIGH "EVENT=BEACON_SNR_HIGH" + if (!strncmp((char *)event, CUS_EVT_BEACON_SNR_HIGH, + strlen(CUS_EVT_BEACON_SNR_HIGH))) { + printf("EVENT: BEACON_SNR_HIGH\n"); + break; + } +#define CUS_EVT_MAX_FAIL "EVENT=MAX_FAIL" + if (!strncmp((char *)event, CUS_EVT_MAX_FAIL, + strlen(CUS_EVT_MAX_FAIL))) { + printf("EVENT: MAX_FAIL\n"); + break; + } +#define CUS_EVT_DATA_RSSI_LOW "EVENT=DATA_RSSI_LOW" + if (!strncmp((char *)event, CUS_EVT_DATA_RSSI_LOW, + strlen(CUS_EVT_DATA_RSSI_LOW))) { + printf("EVENT: DATA_RSSI_LOW\n"); + break; + } +#define CUS_EVT_DATA_SNR_LOW "EVENT=DATA_SNR_LOW" + if (!strncmp((char *)event, CUS_EVT_DATA_SNR_LOW, + strlen(CUS_EVT_DATA_SNR_LOW))) { + printf("EVENT: DATA_SNR_LOW\n"); + break; + } +#define CUS_EVT_DATA_RSSI_HIGH "EVENT=DATA_RSSI_HIGH" + if (!strncmp((char *)event, CUS_EVT_DATA_RSSI_HIGH, + strlen(CUS_EVT_DATA_RSSI_HIGH))) { + printf("EVENT: DATA_RSSI_HIGH\n"); + break; + } +#define CUS_EVT_DATA_SNR_HIGH "EVENT=DATA_SNR_HIGH" + if (!strncmp((char *)event, CUS_EVT_DATA_SNR_HIGH, + strlen(CUS_EVT_DATA_SNR_HIGH))) { + printf("EVENT: DATA_SNR_HIGH\n"); + break; + } +#define CUS_EVT_LINK_QUALITY "EVENT=LINK_QUALITY" + if (!strncmp((char *)event, CUS_EVT_LINK_QUALITY, + strlen(CUS_EVT_LINK_QUALITY))) { + printf("EVENT: LINK_QUALITY\n"); + break; + } +#define CUS_EVT_WEP_ICV_ERR "EVENT=WEP_ICV_ERR" + if (!strncmp((char *)event, CUS_EVT_WEP_ICV_ERR, + strlen(CUS_EVT_WEP_ICV_ERR))) { + printf("EVENT: WEP_ICV_ERR\n"); + break; + } +#define CUS_EVT_CHANNEL_SWITCH_ANN "EVENT=CHANNEL_SWITCH_ANN" + if (!strncmp((char *)event, CUS_EVT_CHANNEL_SWITCH_ANN, + strlen(CUS_EVT_CHANNEL_SWITCH_ANN))) { + printf("EVENT: CHANNEL_SWITCH_ANN\n"); + break; + } +#define CUS_EVT_HS_WAKEUP "HS_WAKEUP" + if (!strncmp((char *)event, CUS_EVT_HS_WAKEUP, + strlen(CUS_EVT_HS_WAKEUP))) { + printf("EVENT: HS_WAKEUP\n"); + break; + } +#define CUS_EVT_HS_ACTIVATED "HS_ACTIVATED" + if (!strncmp((char *)event, CUS_EVT_HS_ACTIVATED, + strlen(CUS_EVT_HS_ACTIVATED))) { + printf("EVENT: HS_ACTIVATED\n"); + break; + } +#define CUS_EVT_HS_DEACTIVATED "HS_DEACTIVATED" + if (!strncmp((char *)event, CUS_EVT_HS_DEACTIVATED, + strlen(CUS_EVT_HS_DEACTIVATED))) { + printf("EVENT: HS_DEACTIVATED\n"); + break; + } +/** Custom indication message sent to the application layer for WMM changes */ +#define WMM_CONFIG_CHANGE_INDICATION "WMM_CONFIG_CHANGE.indication" + if (!strncmp((char *)event, WMM_CONFIG_CHANGE_INDICATION, + strlen(WMM_CONFIG_CHANGE_INDICATION))) { + printf("EVENT: STA_DISCONNECTED\n"); + break; + } +#define CUS_EVT_DRIVER_HANG "EVENT=DRIVER_HANG" + if (!strncmp((char *)event, CUS_EVT_DRIVER_HANG, + strlen(CUS_EVT_DRIVER_HANG))) { + printf("EVENT: DRIVER_HANG\n"); + break; + } +#define CUS_EVT_FW_DUMP_DONE "EVENT=FW_DUMP_DONE" + if (!strncmp((char *)event, CUS_EVT_FW_DUMP_DONE, + strlen(CUS_EVT_FW_DUMP_DONE))) { + printf("EVENT: FW_DUMP_DONE\n"); + break; + } +#define CUS_EVT_FW_RECOVER_START "EVENT=FW_RECOVER_START" + if (!strncmp((char *)event, CUS_EVT_FW_RECOVER_START, + strlen(CUS_EVT_FW_RECOVER_START))) { + printf("EVENT: FW_RECOVER_START\n"); + break; + } +#define CUS_EVT_FW_RECOVER_SUCCESS "EVENT=FW_RECOVER_SUCCESS" + if (!strncmp((char *)event, CUS_EVT_FW_RECOVER_SUCCESS, + strlen(CUS_EVT_FW_RECOVER_SUCCESS))) { + printf("EVENT: FW_RECOVER_SUCCESS\n"); + break; + } +#define CUS_EVT_FW_RECOVER_FAIL "EVENT=FW_RECOVER_FAILURE" + if (!strncmp((char *)event, CUS_EVT_FW_RECOVER_FAIL, + strlen(CUS_EVT_FW_RECOVER_FAIL))) { + printf("EVENT: FW_RECOVER_FAILURE\n"); + break; + } +#define CUS_EVT_CHAN_SWITCH_COMPLETE "EVENT=CHANNEL_SWITCH_COMPLETE" + if (!strncmp((char *)event, CUS_EVT_CHAN_SWITCH_COMPLETE, + strlen(CUS_EVT_CHAN_SWITCH_COMPLETE))) { + printf("%s\n", (char *)event); + break; + } +#define CUS_EVT_PRINT_LINK_STATS "EVENT=PRINT_LINK_STATS" + if (!strncmp((char *)event, CUS_EVT_PRINT_LINK_STATS, + strlen(CUS_EVT_PRINT_LINK_STATS))) { + printf("%s\n", (char *)event); + break; + } +/** Custom event : Radar Detected */ +#define CUS_EVT_RADAR_DETECTED "EVENT=RADAR_DETECTED" +/** Custom event : CAC finished */ +#define CUS_EVT_CAC_FINISHED "EVENT=CAC_FINISHED" +/** Custom event : CAC Started */ +#define CUS_EVT_CAC_START "EVENT=CAC_START" + if (!strncmp((char *)event, CUS_EVT_RADAR_DETECTED, + strlen(CUS_EVT_RADAR_DETECTED))) { + printf("%s\n", (char *)event); + break; + } + if (!strncmp((char *)event, CUS_EVT_CAC_FINISHED, + strlen(CUS_EVT_CAC_FINISHED))) { + printf("%s\n", (char *)event); + break; + } + if (!strncmp((char *)event, CUS_EVT_CAC_START, + strlen(CUS_EVT_CAC_START))) { + printf("%s\n", (char *)event); + break; + } + if (!strncmp((char *)event, CUS_EVT_TOD_TOA, + strlen(CUS_EVT_TOD_TOA))) { + printf("EVENT: MLAN ToD(Tx Pkt) and ToA(Ack Pkt)\n"); + printf("%s\n", (char *)event); + break; + } + + if (!strncmp((char *)event, CUS_EVT_MLAN_CSI, + strlen(CUS_EVT_MLAN_CSI))) { + struct stat fbuf; + int fstat; + FILE *csi_fp = NULL; + char filename[64]; + /* Mask out Bit15,14,13 for RAW CSI */ + t_u16 csi_length = + 0x1fff & + ((event_mlan_csi *)event)->csi_record.Len; + t_u16 seq = ((event_mlan_csi *)event)->sequence; + static t_u16 last_seq = 0; + static t_u16 total_lost_count = 0; + + /* Print CSI EVENT data */ + printf("EVENT: MLAN_CSI\n"); + printf("Sequence: %d\n", + ((event_mlan_csi *)event)->sequence); + printf("Length: %d DWORDs\n", csi_length); + printf("CSI record:\n"); + hexdump((void *)&( + ((event_mlan_csi *)event)->csi_record), + 4 * csi_length, ' '); + + /* Save CSI data to file */ + + snprintf(filename, sizeof(filename), "csidump_%s.txt", + if_name); + fstat = stat(filename, &fbuf); + + if ((fstat == 0) && + (fbuf.st_size >= CSI_DUMP_FILE_MAX)) { + printf("File %s reached maximum size. Not saving CSI records.\n", + filename); + printf("ERR: Lost csi event as %s reached maximum size for %d times\n", + filename, seq - last_seq); + } else { + t_u16 fpos; + csi_fp = fopen(filename, "a+"); + + if (seq == 0 || last_seq == 0 || + seq == (last_seq + 1)) + last_seq = seq; + else { + total_lost_count += seq - last_seq; + printf("ERR: Lost csi event for %d times, total_lost_count = %d\n", + seq - last_seq, + total_lost_count); + last_seq = seq; + } + + if (csi_fp) { + for (fpos = 0; fpos < csi_length; + fpos++) { + fprintf(csi_fp, "%08x ", + *((t_u32 *)&( + ((event_mlan_csi + *) + event) + ->csi_record) + + fpos)); + } + fclose(csi_fp); + } + if (chmod(filename, S_IRUSR | S_IWUSR | + S_IRGRP | S_IWGRP | + S_IROTH | + S_IWOTH)) { + printf("ERR: Unable to change file permissions\n"); + } + } + break; + } +#define FW_DEBUG_INFO "EVENT=FW_DEBUG_INFO" + if (!strncmp((char *)event, FW_DEBUG_INFO, + strlen(FW_DEBUG_INFO))) { + printf("EVENT: FW_DEBUG_INFO\n"); + printf("%s\n", (t_u8 *)event + + strlen(CUS_EVT_STA_CONNECTED) + + 1); + printf("\n"); + break; + } + printf("ERR:Undefined event type (0x%X). Dumping event buffer:\n", + (unsigned int)event_id); + hexdump((void *)event, size, ' '); + break; + } + return; +} + +/** + * @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 + */ +static 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"); + return MLAN_EVENT_FAILURE; + } +#if DEBUG + printf("DBG:Received message payload (%d)\n", count); +#endif + if (count > (int)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 + */ +static 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; +} + +/* Command line options */ +static const struct option long_opts[] = {{"help", no_argument, NULL, 'h'}, + {"version", no_argument, NULL, 'v'}, + {NULL, 0, NULL, 0}}; + +/** + * @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] = {0}; + + /* Try to open old driver proc: /proc/mwlan/configX first */ + if (i == 0) + strncpy(filename, "/proc/mwlan/config", sizeof(filename)); + else if (i > 0) + snprintf(filename, sizeof(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 (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; + } + printf("Netlink number = %d\n", netlink_num); + return netlink_num; +} + +/**************************************************************************** + Global functions +****************************************************************************/ +/** + * @brief The main function + * + * @param argc Number of arguments + * @param argv Pointer to the arguments + * @return 0 or 1 + */ +int main(int argc, char *argv[]) +{ + int opt; + 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 = NULL; + struct timeval current_time; + struct tm *timeinfo; + 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, dev_index = -1; + + /* Check command line options */ + while ((opt = getopt_long(argc, argv, "hvti:", long_opts, NULL)) > 0) { + switch (opt) { + case 'h': + print_usage(); + return 0; + case 'v': + printf("mlanevent version : %s\n", MLAN_EVENT_VERSION); + return 0; + break; + case 'i': + if ((IS_HEX_OR_DIGIT(argv[2]) == MLAN_EVENT_FAILURE) || + ((A2HEXDECIMAL(argv[2]) >= MAX_NO_OF_DEVICES) && + (A2HEXDECIMAL(argv[2]) != 0xff))) { + print_usage(); + return 1; + } else { + dev_index = A2HEXDECIMAL(argv[2]); + argc -= optind; + argv += optind; + } + break; + default: + print_usage(); + return 1; + } + } + + if (optind < argc) { + fputs("Too many arguments.\n", stderr); + print_usage(); + return 1; + } + evt_recv_buf = malloc(sizeof(evt_buf) * MAX_NO_OF_DEVICES); + if (!evt_recv_buf) { + printf("ERR: Fail to allocate evt_recv_buf\n"); + return 1; + } + memset(evt_recv_buf, 0, sizeof(evt_buf) * MAX_NO_OF_DEVICES); + if ((dev_index >= 0) && (dev_index < MAX_NO_OF_DEVICES)) { + no_of_sk = 1; + } else { + /* 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; + if (no_of_sk == 1) { + netlink_num[i] = get_netlink_num(dev_index); + if (netlink_num[i] < 0) { + printf("ERR:Could not get netlink socket. Invalid device number.\n"); + ret = MLAN_EVENT_FAILURE; + goto done; + } + } else { + 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; + } + } + gettimeofday(¤t_time, NULL); + + printf("\n"); + printf("**********************************************\n"); + if ((timeinfo = localtime(&(current_time.tv_sec)))) + printf("mlanevent start time : %s", asctime(timeinfo)); + printf(" %u usecs\n", + (unsigned int)current_time.tv_usec); + printf("**********************************************\n"); + + 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++; + gettimeofday(¤t_time, NULL); + printf("\n"); + printf("============================================\n"); + printf("Received event"); + if ((timeinfo = + localtime(&(current_time.tv_sec)))) + printf(": %s", asctime(timeinfo)); + printf(" %u usecs\n", + (unsigned int)current_time.tv_usec); + printf("============================================\n"); + + 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); + printf("EVENT for interface %s\n", + if_name); + event = (event_header + *)((t_u8 *)(evt_recv_buf[i] + .buffer) + + IFNAMSIZ); + ret -= IFNAMSIZ; + evt_recv_buf[i].length -= IFNAMSIZ; + } +#if DEBUG + printf("DBG:Received buffer =\n"); + hexdump(evt_recv_buf[i].buffer, + evt_recv_buf[i].length + IFNAMSIZ, ' '); +#endif + print_event(event, evt_recv_buf[i].length, + if_name); + /* Reset event flag after reading */ + evt_recv_buf[i].flag = 0; + } + } + fflush(stdout); + } + gettimeofday(¤t_time, NULL); + printf("\n"); + printf("*********************************************\n"); + if ((timeinfo = localtime(&(current_time.tv_sec)))) + printf("mlanevent end time : %s", asctime(timeinfo)); + printf(" %u usecs\n", + (unsigned int)current_time.tv_usec); + printf("Total events : %u\n", num_events); + printf("*********************************************\n"); +done: + for (i = 0; i < no_of_sk; i++) { + if (nl_sk[i] > 0) + close(nl_sk[i]); + } + if (nlh) + free(nlh); + if (evt_recv_buf) + free(evt_recv_buf); + return 0; +} diff --git a/mapp/mlanevent/mlanevent.h b/mapp/mlanevent/mlanevent.h new file mode 100644 index 0000000..049636c --- /dev/null +++ b/mapp/mlanevent/mlanevent.h @@ -0,0 +1,1410 @@ +/** @file mlanevent.h + * + * @brief Header file for mlanevent application + * + * + * Copyright 2008-2025 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/18/08: Initial creation +************************************************************************/ + +#ifndef _MLAN_EVENT_H +#define _MLAN_EVENT_H + +/** Character, 1 byte */ +typedef signed 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 long long t_s64; +/** Unsigned long long integer */ +typedef unsigned long long t_u64; + +#if (BYTE_ORDER == LITTLE_ENDIAN) +#undef BIG_ENDIAN_SUPPORT +#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))) + +/** 64 bits byte swap */ +#define swap_byte_64(x) \ + ((t_u64)((t_u64)(((t_u64)(x)&0x00000000000000ffULL) << 56) | \ + (t_u64)(((t_u64)(x)&0x000000000000ff00ULL) << 40) | \ + (t_u64)(((t_u64)(x)&0x0000000000ff0000ULL) << 24) | \ + (t_u64)(((t_u64)(x)&0x00000000ff000000ULL) << 8) | \ + (t_u64)(((t_u64)(x)&0x000000ff00000000ULL) >> 8) | \ + (t_u64)(((t_u64)(x)&0x0000ff0000000000ULL) >> 24) | \ + (t_u64)(((t_u64)(x)&0x00ff000000000000ULL) >> 40) | \ + (t_u64)(((t_u64)(x)&0xff00000000000000ULL) >> 56))) + +#ifdef BIG_ENDIAN_SUPPORT +/** Convert from 16 bit little endian format to CPU format */ +#define uap_le16_to_cpu(x) swap_byte_16(x) +/** Convert from 32 bit little endian format to CPU format */ +#define uap_le32_to_cpu(x) swap_byte_32(x) +/** Convert from 64 bit little endian format to CPU format */ +#define uap_le64_to_cpu(x) swap_byte_64(x) +/** Convert to 16 bit little endian format from CPU format */ +#define uap_cpu_to_le16(x) swap_byte_16(x) +/** Convert to 32 bit little endian format from CPU format */ +#define uap_cpu_to_le32(x) swap_byte_32(x) +/** Convert to 64 bit little endian format from CPU format */ +#define uap_cpu_to_le64(x) swap_byte_64(x) +#else /* BIG_ENDIAN_SUPPORT */ +/** Do nothing */ +#define uap_le16_to_cpu(x) x +/** Do nothing */ +#define uap_le32_to_cpu(x) x +/** Do nothing */ +#define uap_le64_to_cpu(x) x +/** Do nothing */ +#define uap_cpu_to_le16(x) x +/** Do nothing */ +#define uap_cpu_to_le32(x) x +/** Do nothing */ +#define uap_cpu_to_le64(x) x +#endif /* BIG_ENDIAN_SUPPORT */ + +/** Convert WPS TLV header from network to host order */ +#define endian_convert_tlv_wps_header_in(t, l) \ + { \ + (t) = ntohs(t); \ + (l) = ntohs(l); \ + } + +/** + * 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))) + +/** + * Check of decimal or hex string + * @param num string + */ +#define IS_HEX_OR_DIGIT(num) \ + (strncasecmp("0x", (num), 2) ? ISDIGIT((num)) : ishexstring((num))) + +/** MLan Event application version string */ +#define MLAN_EVENT_VERSION "MlanEvent 2.0" + +/** Failure */ +#define MLAN_EVENT_FAILURE -1 + +#ifdef __GNUC__ +/** Structure packing begins */ +#define PACK_START +/** Structure packeing end */ +#define PACK_END __attribute__((packed)) +#else +/** Structure packing begins */ +#define PACK_START __packed +/** Structure packeing end */ +#define PACK_END +#endif + +#ifndef ETH_ALEN +/** MAC address length */ +#define ETH_ALEN 6 +#endif + +/** Netlink protocol number */ +#define NETLINK_NXP (MAX_LINKS - 1) +/** Netlink maximum payload size */ +#define NL_MAX_PAYLOAD (3 * 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 6 + +#ifndef NLMSG_HDRLEN +/** NL message header length */ +#define NLMSG_HDRLEN ((int)NLMSG_ALIGN(sizeof(struct nlmsghdr))) +#endif + +/** Event ID mask */ +#define EVENT_ID_MASK 0xffff + +/** BSS number mask */ +#define BSS_NUM_MASK 0xf + +/** Get BSS number from event cause (bit 23:16) */ +#define EVENT_GET_BSS_NUM(event_cause) (((event_cause) >> 16) & BSS_NUM_MASK) + +/** Invitation Flag mask */ +#define INVITATION_FLAG_MASK 0x01 + +/* Event buffer */ +typedef PACK_START 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]; +} PACK_END evt_buf; + +/** Event header */ +typedef PACK_START struct _event_header { + /** Event ID */ + t_u32 event_id; + /** Event data */ + t_u8 event_data[]; +} PACK_END event_header; + +/** Event ID length */ +#define EVENT_ID_LEN 4 + +/** Event ID : WMM status change */ +#define MICRO_AP_EV_WMM_STATUS_CHANGE 0x00000017 + +/** Event ID: STA deauth */ +#define MICRO_AP_EV_ID_STA_DEAUTH 0x0000002c + +/** Event ID: STA associated */ +#define MICRO_AP_EV_ID_STA_ASSOC 0x0000002d + +/** Event ID: BSS started */ +#define MICRO_AP_EV_ID_BSS_START 0x0000002e + +/** Event ID: Debug event */ +#define MICRO_AP_EV_ID_DEBUG 0x00000036 + +/** Event ID: BSS idle event */ +#define MICRO_AP_EV_BSS_IDLE 0x00000043 + +/** Event ID: BSS active event */ +#define MICRO_AP_EV_BSS_ACTIVE 0x00000044 + +/** Event ID: WEP ICV error */ +#define EVENT_WEP_ICV_ERROR 0x00000046 + +#ifdef WIFI_DIRECT_SUPPORT +/** Event ID: UAP,STA wifidirect generic event */ +#define EVENT_WIFIDIRECT_GENERIC 0x00000049 + +/** Event ID: UAP,STA wifidirect service discovery event */ +#define EVENT_WIFIDIRECT_SERVICE_DISCOVERY 0x0000004a +#endif + +/** Event ID: MIC Countermeasures event */ +#define MICRO_AP_EV_ID_MIC_COUNTERMEASURES 0x0000004c + +/** Event ID: RSN Connect event */ +#define MICRO_AP_EV_RSN_CONNECT 0x00000051 + +/** Event ID: TDLS generic event */ +#define EVENT_TDLS_GENERIC 0x00000052 + +/** event type for tdls setup failure */ +#define TDLS_EVENT_TYPE_SETUP_FAILURE 1 +/** event type for tdls setup request received */ +#define TDLS_EVENT_TYPE_SETUP_REQ_RCVD 2 +/** event type for tdls link torn down */ +#define TDLS_EVENT_TYPE_LINK_TORN_DOWN 3 +/** event type for tdls link established */ +#define TDLS_EVENT_TYPE_LINK_ESTABLISHED 4 +/** event type for tdls debug */ +#define TDLS_EVENT_TYPE_DEBUG 5 +/** event type for tdls packet */ +#define TDLS_EVENT_TYPE_PACKET 6 +/** event type for channel switch result */ +#define TDLS_EVENT_TYPE_CHAN_SWITCH_RESULT 7 +/** event type for start channel switch */ +#define TDLS_EVENT_TYPE_START_CHAN_SWITCH 8 +/** event type for stop channel switch */ +#define TDLS_EVENT_TYPE_CHAN_SWITCH_STOPPED 9 + +/** Event ID: Radar Detected */ +#define EVENT_RADAR_DETECTED 0x00000053 +/** Event ID: Channel Report Ready */ +#define EVENT_CHANNEL_REPORT_RDY 0x00000054 + +/** Event ID: NLIST REPORT */ +#define EVENT_NLIST_REPORT 0x00000079 +/** NLIST_REPORT TLV */ +#define MRVL_NEIGHBOR_REPORT_TLV_ID 0x1de + +/** HS WAKE UP event id */ +#define UAP_EVENT_ID_HS_WAKEUP 0x80000001 +/** HS_ACTIVATED event id */ +#define UAP_EVENT_ID_DRV_HS_ACTIVATED 0x80000002 +/** HS DEACTIVATED event id */ +#define UAP_EVENT_ID_DRV_HS_DEACTIVATED 0x80000003 +/** HOST SLEEP AWAKE event id in legacy PS*/ +#define UAP_EVENT_HOST_SLEEP_AWAKE 0x00000012 + +/** HS WAKE UP event id */ +#define UAP_EVENT_ID_DRV_MGMT_FRAME 0x80000005 + +/** SCAN REPORT Event id */ +#define EVENT_ID_DRV_SCAN_REPORT 0x80000009 + +#define EVENT_DPD_CAL 0x000000A8 + +/** WPA IE Tag */ +#define IEEE_WPA_IE 221 +/** RSN IE Tag */ +#define IEEE_RSN_IE 48 + +/** TLV ID : WAPI Information */ +#define MRVL_WAPI_INFO_TLV_ID 0x0167 + +/** TLV ID : Management Frame */ +#define MRVL_MGMT_FRAME_TLV_ID 0x0168 + +/** TLV Id : Channel Config */ +#define MRVL_CHANNELCONFIG_TLV_ID 0x012a + +/** Assoc Request */ +#define SUBTYPE_ASSOC_REQUEST 0 +/** Assoc Response */ +#define SUBTYPE_ASSOC_RESPONSE 1 +/** ReAssoc Request */ +#define SUBTYPE_REASSOC_REQUEST 2 +/** ReAssoc Response */ +#define SUBTYPE_REASSOC_RESPONSE 3 +/** WEP key user input length */ +#define WEP_KEY_USER_INPUT 13 + +/** TLV buffer header*/ +typedef PACK_START struct _tlvbuf_header { + /** Header type */ + t_u16 type; + /** Header length */ + t_u16 len; +} PACK_END tlvbuf_header; + +/** Event body : STA deauth */ +typedef PACK_START struct _eventbuf_sta_deauth { + /** Deauthentication reason */ + t_u16 reason_code; + /** MAC address of deauthenticated STA */ + t_u8 sta_mac_address[ETH_ALEN]; +} PACK_END eventbuf_sta_deauth; + +/** Event body : WEP ICV error */ +typedef PACK_START struct _eventbuf_wep_icv_error { + /** Deauthentication reason */ + t_u16 reason_code; + /** MAC address of deauthenticated STA */ + t_u8 sta_mac_address[ETH_ALEN]; + /** WEP key index */ + t_u8 wep_key_index; + /** WEP key length */ + t_u8 wep_key_length; + /** WEP key */ + t_u8 wep_key[WEP_KEY_USER_INPUT]; +} PACK_END eventbuf_wep_icv_error; + +/** Event body : STA associated */ +typedef PACK_START struct _eventbuf_sta_assoc { + /** Reserved */ + t_u8 reserved[2]; + /** MAC address of associated STA */ + t_u8 sta_mac_address[ETH_ALEN]; + /** Assoc request/response buffer */ + t_u8 assoc_payload[]; +} PACK_END eventbuf_sta_assoc; + +/** Event body : RSN Connect */ +typedef PACK_START struct _eventbuf_rsn_connect { + /** Reserved */ + t_u8 reserved[2]; + /** MAC address of Station */ + t_u8 sta_mac_address[ETH_ALEN]; + /** WPA/WPA2 TLV IEs */ + t_u8 tlv_list[]; +} PACK_END eventbuf_rsn_connect; + +/** Event body : BSS started */ +typedef PACK_START struct _eventbuf_bss_start { + /** Reserved */ + t_u8 reserved[2]; + /** MAC address of BSS */ + t_u8 ap_mac_address[ETH_ALEN]; +} PACK_END eventbuf_bss_start; + +/** Event body : MIC Countermeasures */ +typedef PACK_START struct _eventbuf_mic_countermeasures { + /** Status */ + t_u16 status; +} PACK_END eventbuf_mic_countermeasures; + +/** + * IEEE 802.11 MAC Message Data Structures + * + * Each IEEE 802.11 MAC message includes a MAC header, a frame body (which + * can be empty), and a frame check sequence field. This section gives the + * structures that used for the MAC message headers and frame bodies that + * can exist in the three types of MAC messages - 1) Control messages, + * 2) Data messages, and 3) Management messages. + */ +typedef PACK_START struct _IEEEtypes_FrameCtl_t { + /** Protocol Version */ + t_u8 protocol_version : 2; + /** Type */ + t_u8 type : 2; + /** Sub Type */ + t_u8 sub_type : 4; + /** To DS */ + t_u8 to_ds : 1; + /** From DS */ + t_u8 from_ds : 1; + /** More Frag */ + t_u8 more_frag : 1; + /** Retry */ + t_u8 retry : 1; + /** Power Mgmt */ + t_u8 pwr_mgmt : 1; + /** More Data */ + t_u8 more_data : 1; + /** Wep */ + t_u8 wep : 1; + /** Order */ + t_u8 order : 1; +} PACK_END IEEEtypes_FrameCtl_t; + +/** IEEEtypes_AssocRqst_t */ +typedef PACK_START struct _IEEEtypes_AssocRqst_t { + /** Capability Info */ + t_u16 cap_info; + /** Listen Interval */ + t_u16 listen_interval; + /** IE Buffer */ + t_u8 ie_buffer[]; +} PACK_END IEEEtypes_AssocRqst_t; + +/** IEEEtypes_AssocRsp_t */ +typedef PACK_START struct _IEEEtypes_AssocRsp_t { + /** Capability Info */ + t_u16 cap_info; + /** Status Code */ + t_u16 status_code; + /** AID */ + t_u16 aid; +} PACK_END IEEEtypes_AssocRsp_t; + +/** IEEEtypes_ReAssocRqst_t */ +typedef PACK_START struct _IEEEtypes_ReAssocRqst_t { + /** Capability Info */ + t_u16 cap_info; + /** Listen Interval */ + t_u16 listen_interval; + /** Current AP Address */ + t_u8 current_ap_addr[ETH_ALEN]; + /** IE Buffer */ + t_u8 ie_buffer[]; +} PACK_END IEEEtypes_ReAssocRqst_t; + +/** channel band */ +enum { BAND_2GHZ = 0, + BAND_5GHZ = 1, + BAND_6GHZ = 2, + BAND_4GHZ = 3, +}; + +/** channel offset */ +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, + +}; + +/** scan mode */ +enum { SCAN_MODE_MANUAL = 0, + SCAN_MODE_ACS, + SCAN_MODE_USER, +}; + +/** Band_Config_t */ +typedef PACK_START 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; +#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; +#endif +} PACK_END Band_Config_t; + +/** TLV buffer : Channel Config */ +typedef PACK_START struct _tlvbuf_channel_config { + /** Type */ + t_u16 type; + /** Length */ + t_u16 len; + /** Band Configuration */ + Band_Config_t bandcfg; + /** Channel number */ + t_u8 chan_number; +} PACK_END tlvbuf_channel_config; + +/** MrvlIEtypes_WapiInfoSet_t */ +typedef PACK_START struct _MrvlIEtypes_WapiInfoSet_t { + /** Type */ + t_u16 type; + /** Length */ + t_u16 len; + /** Multicast PN */ + t_u8 multicast_PN[16]; +} PACK_END MrvlIEtypes_WapiInfoSet_t; + +/** MrvlIETypes_MgmtFrameSet_t */ +typedef PACK_START struct _MrvlIETypes_MgmtFrameSet_t { + /** Type */ + t_u16 type; + /** Length */ + t_u16 len; + /** Frame Control */ + IEEEtypes_FrameCtl_t frame_control; + /** Frame Contents */ + t_u8 frame_contents[]; +} PACK_END MrvlIETypes_MgmtFrameSet_t; + +/** Debug Type : Event */ +#define DEBUG_TYPE_EVENT 0 +/** Debug Type : Info */ +#define DEBUG_TYPE_INFO 1 + +/** Major debug id: Authenticator */ +#define DEBUG_ID_MAJ_AUTHENTICATOR 1 +/** Minor debug id: PWK1 */ +#define DEBUG_MAJ_AUTH_MIN_PWK1 0 +/** Minor debug id: PWK2 */ +#define DEBUG_MAJ_AUTH_MIN_PWK2 1 +/** Minor debug id: PWK3 */ +#define DEBUG_MAJ_AUTH_MIN_PWK3 2 +/** Minor debug id: PWK4 */ +#define DEBUG_MAJ_AUTH_MIN_PWK4 3 +/** Minor debug id: GWK1 */ +#define DEBUG_MAJ_AUTH_MIN_GWK1 4 +/** Minor debug id: GWK2 */ +#define DEBUG_MAJ_AUTH_MIN_GWK2 5 +/** Minor debug id: station reject */ +#define DEBUG_MAJ_AUTH_MIN_STA_REJ 6 +/** Minor debug id: EAPOL_TR */ +#define DEBUG_MAJ_AUTH_MIN_EAPOL_TR 7 + +/** Major debug id: Assoicate agent */ +#define DEBUG_ID_MAJ_ASSOC_AGENT 2 +/** Minor debug id: WPA IE*/ +#define DEBUG_ID_MAJ_ASSOC_MIN_WPA_IE 0 +/** Minor debug id: station reject */ +#define DEBUG_ID_MAJ_ASSOC_MIN_STA_REJ 1 + +/** ether_hdr */ +typedef PACK_START struct { + /** Dest address */ + t_u8 da[ETH_ALEN]; + /** Src address */ + t_u8 sa[ETH_ALEN]; + /** Header type */ + t_u16 type; +} PACK_END ether_hdr_t; + +/** 8021x header */ +typedef PACK_START struct { + /** Protocol version*/ + t_u8 protocol_ver; + /** Packet type*/ + t_u8 pckt_type; + /** Packet len */ + t_u8 pckt_body_len; +} PACK_END hdr_8021x_t; + +/** Nonce size */ +#define NONCE_SIZE 32 +/** Max WPA IE len */ +#define MAX_WPA_IE_LEN 64 +/** EAPOL mic size */ +#define EAPOL_MIC_SIZE 16 + +/** EAPOL key message */ +typedef PACK_START struct { + /** Ether header */ + ether_hdr_t ether_hdr; + /** 8021x header */ + hdr_8021x_t hdr_8021x; + /** desc_type */ + t_u8 desc_type; + /** Key info */ + t_u16 k; + /** Key length */ + t_u16 key_length; + /** Replay count */ + t_u32 replay_cnt[2]; + /** Key nonce */ + t_u8 key_nonce[NONCE_SIZE]; + /** Key IV */ + t_u8 eapol_key_iv[16]; + /** Key RSC */ + t_u8 key_rsc[8]; + /** Key ID */ + t_u8 key_id[8]; + /** Key MIC */ + t_u8 key_mic[EAPOL_MIC_SIZE]; + /** Key len */ + t_u16 key_material_len; + /** Key data */ + t_u8 key_data[MAX_WPA_IE_LEN]; +} PACK_END eapol_keymsg_debug_t; + +/** Failure after receive EAPOL MSG2 PMK */ +#define REJECT_STATE_FAIL_EAPOL_2 1 +/** Failure after receive EAPOL MSG4 PMK*/ +#define REJECT_STATE_FAIL_EAPOL_4 2 +/** Failure after receive EAPOL Group MSG2 GWK */ +#define REJECT_STATE_FAIL_EAPOL_GROUP_2 3 + +/** Fail reason: Invalid ie */ +#define IEEEtypes_REASON_INVALID_IE 13 +/** Fail reason: Mic failure */ +#define IEEEtypes_REASON_MIC_FAILURE 14 + +/** Station reject */ +typedef PACK_START struct { + /** Reject state */ + t_u8 reject_state; + /** Reject reason */ + t_u16 reject_reason; + /** Station mac address */ + t_u8 sta_mac_addr[ETH_ALEN]; +} PACK_END sta_reject_t; + +/** wpa_ie */ +typedef PACK_START struct { + /** Station mac address */ + t_u8 sta_mac_addr[ETH_ALEN]; + /** WPA IE */ + t_u8 wpa_ie[MAX_WPA_IE_LEN]; +} PACK_END wpaie_t; + +/** Initial state of the state machine */ +#define EAPOL_START 1 +/** Sent eapol msg1, wait for msg2 from the client */ +#define EAPOL_WAIT_PWK2 2 +/** Sent eapol msg3, wait for msg4 from the client */ +#define EAPOL_WAIT_PWK4 3 +/** Sent eapol group key msg1, wait for group msg2 from the client */ +#define EAPOL_WAIT_GTK2 4 +/** Eapol handshake complete */ +#define EAPOL_END 5 + +#ifdef WIFI_DIRECT_SUPPORT +/** TLV : WifiDirect status */ +#define TLV_TYPE_WIFIDIRECT_STATUS 0x0000 +/** TLV : WifiDirect param capability */ +#define TLV_TYPE_WIFIDIRECT_CAPABILITY 0x0002 +/** TLV : WifiDirect param device Id */ +#define TLV_TYPE_WIFIDIRECT_DEVICE_ID 0x0003 +/** TLV : WifiDirect param group owner intent */ +#define TLV_TYPE_WIFIDIRECT_GROUPOWNER_INTENT 0x0004 +/** TLV : WifiDirect param config timeout */ +#define TLV_TYPE_WIFIDIRECT_CONFIG_TIMEOUT 0x0005 +/** TLV : WifiDirect param channel */ +#define TLV_TYPE_WIFIDIRECT_CHANNEL 0x0006 +/** TLV : WifiDirect param group bssId */ +#define TLV_TYPE_WIFIDIRECT_GROUP_BSS_ID 0x0007 +/** TLV : WifiDirect param extended listen time */ +#define TLV_TYPE_WIFIDIRECT_EXTENDED_LISTEN_TIME 0x0008 +/** TLV : WifiDirect param intended address */ +#define TLV_TYPE_WIFIDIRECT_INTENDED_ADDRESS 0x0009 +/** TLV : WifiDirect param manageability */ +#define TLV_TYPE_WIFIDIRECT_MANAGEABILITY 0x000a +/** TLV : WifiDirect param channel list */ +#define TLV_TYPE_WIFIDIRECT_CHANNEL_LIST 0x000b +/** TLV : WifiDirect Notice of Absence */ +#define TLV_TYPE_WIFIDIRECT_NOTICE_OF_ABSENCE 0x000c +/** TLV : WifiDirect param device Info */ +#define TLV_TYPE_WIFIDIRECT_DEVICE_INFO 0x000d +/** TLV : WifiDirect param Group Info */ +#define TLV_TYPE_WIFIDIRECT_GROUP_INFO 0x000e +/** TLV : WifiDirect param group Id */ +#define TLV_TYPE_WIFIDIRECT_GROUP_ID 0x000f +/** TLV : WifiDirect param interface */ +#define TLV_TYPE_WIFIDIRECT_INTERFACE 0x0010 +/** TLV : WifiDirect param operating channel */ +#define TLV_TYPE_WIFIDIRECT_OPCHANNEL 0x0011 +/** TLV : WifiDirect param invitation flag */ +#define TLV_TYPE_WIFIDIRECT_INVITATION_FLAG 0x0012 + +/** WPS Device Info OUI+Type+SubType Length */ +#define WPS_DEVICE_TYPE_LEN 8 + +/** IE header len */ +#define IE_HEADER_LEN 2 + +/** WIFIDIRECT IE header len */ +#define WIFIDIRECT_IE_HEADER_LEN 3 + +/** OUI Type WIFIDIRECT */ +#define WIFIDIRECT_OUI_TYPE 9 +/** OUI Type WPS */ +#define WIFI_WPS_OUI_TYPE 4 + +/* + * To handle overlapping WIFIDIRECT IEs + */ +/** IE next byte type */ +#define WIFIDIRECT_OVERLAP_TYPE 1 +/** IE next byte length */ +#define WIFIDIRECT_OVERLAP_LEN 2 +/** IE next byte data */ +#define WIFIDIRECT_OVERLAP_DATA 3 + +/** Max payload for IE buffer */ +#define WIFI_IE_MAX_PAYLOAD 256 + +/** Fixed length fields in bonjour payload query data */ +#define WIFIDIRECT_DISCOVERY_BONJOUR_FIXED_LEN 5 + +/** Fixed length fields in uPnP payload query data */ +#define WIFIDIRECT_DISCOVERY_UPNP_FIXED_LEN 3 + +/** Action field for discovery request */ +#define WIFIDIRECT_DISCOVERY_REQUEST_ACTION 10 + +/** Action field for discovery response */ +#define WIFIDIRECT_DISCOVERY_RESPONSE_ACTION 11 + +/** TLV buffer : WifiDirect Status */ +typedef PACK_START struct _tlvbuf_wifidirect_status { + /** TLV Header tag */ + t_u8 tag; + /** TLV Header length */ + t_u16 length; + /** WIFIDIRECT status code */ + t_u8 status_code; +} PACK_END tlvbuf_wifidirect_status; + +/** TLV buffer : wifidirect IE device Id */ +typedef PACK_START struct _tlvbuf_wifidirect_device_id { + /** TLV Header tag */ + t_u8 tag; + /** TLV Header length */ + t_u16 length; + /** WIFIDIRECT device MAC address */ + t_u8 dev_mac_address[ETH_ALEN]; +} PACK_END tlvbuf_wifidirect_device_id; + +/** TLV buffer : wifidirect IE capability */ +typedef PACK_START struct _tlvbuf_wifidirect_capability { + /** TLV Header tag */ + t_u8 tag; + /** TLV Header length */ + t_u16 length; + /** WIFIDIRECT device capability */ + t_u8 dev_capability; + /** WIFIDIRECT group capability */ + t_u8 group_capability; +} PACK_END tlvbuf_wifidirect_capability; + +/** TLV buffer : wifidirect IE Group owner intent */ +typedef PACK_START struct _tlvbuf_wifidirect_group_owner_intent { + /** TLV Header tag */ + t_u8 tag; + /** TLV Header length */ + t_u16 length; + /** WIFIDIRECT device group owner intent */ + t_u8 dev_intent; +} PACK_END tlvbuf_wifidirect_group_owner_intent; + +/** TLV buffer : WifiDirect IE Manageability */ +typedef PACK_START struct _tlvbuf_wifidirect_manageability { + /** TLV Header tag */ + t_u8 tag; + /** TLV Header length */ + t_u16 length; + /** WIFIDIRECT Manageability */ + t_u8 manageability; +} PACK_END tlvbuf_wifidirect_manageability; + +/** TLV buffer : WifiDirect IE Invitation Flag */ +typedef PACK_START struct _tlvbuf_wifidirect_invitation_flag { + /** TLV Header tag */ + t_u8 tag; + /** TLV Header length */ + t_u16 length; + /** WIFIDIRECT Manageability */ + t_u8 invitation_flag; +} PACK_END tlvbuf_wifidirect_invitation_flag; + +/** TLV buffer : wifidirect IE capability */ +typedef PACK_START struct _tlvbuf_wifidirect_channel { + /** TLV Header tag */ + t_u8 tag; + /** TLV Header length */ + t_u16 length; + /** WIFIDIRECT country string */ + t_u8 country_string[3]; + /** WIFIDIRECT regulatory class */ + t_u8 regulatory_class; + /** WIFIDIRECT channel number */ + t_u8 channel_number; +} PACK_END tlvbuf_wifidirect_channel; + +/** Channel Entry */ +typedef PACK_START struct _chan_entry { + /** WIFIDIRECT regulatory class */ + t_u8 regulatory_class; + /** WIFIDIRECT no of channels */ + t_u8 num_of_channels; + /** WIFIDIRECT channel number */ + t_u8 chan_list[]; +} PACK_END chan_entry; + +/** TLV buffer : wifidirect IE channel list */ +typedef PACK_START struct _tlvbuf_wifidirect_channel_list { + /** TLV Header tag */ + t_u8 tag; + /** TLV Header length */ + t_u16 length; + /** WIFIDIRECT country string */ + t_u8 country_string[3]; + /** WIFIDIRECT channel entries */ + chan_entry wifidirect_chan_entry_list[]; +} PACK_END tlvbuf_wifidirect_channel_list; + +/** NoA Descriptor */ +typedef PACK_START struct _noa_descriptor { + /** WIFIDIRECT count OR type */ + t_u8 count_type; + /** WIFIDIRECT duration */ + t_u32 duration; + /** WIFIDIRECT interval */ + t_u32 interval; + /** WIFIDIRECT start time */ + t_u32 start_time; +} PACK_END noa_descriptor; + +/** TLV buffer : WifiDirect IE Notice of Absence */ +typedef PACK_START struct _tlvbuf_wifidirect_notice_of_absence { + /** TLV Header tag */ + t_u8 tag; + /** TLV Header length */ + t_u16 length; + /** WIFIDIRECT NoA Index */ + t_u8 noa_index; + /** WIFIDIRECT CTWindow and OppPS parameters */ + t_u8 ctwindow_opp_ps; + /** WIFIDIRECT NoA Descriptor list */ + noa_descriptor wifidirect_noa_descriptor_list[]; +} PACK_END tlvbuf_wifidirect_notice_of_absence; + +/** TLV buffer : wifidirect IE device Info */ +typedef PACK_START struct _tlvbuf_wifidirect_device_info { + /** TLV Header tag */ + t_u8 tag; + /** TLV Header length */ + t_u16 length; + /** WIFIDIRECT device address */ + t_u8 dev_address[ETH_ALEN]; + /** WPS config methods */ + t_u16 config_methods; + /** Primary device type : category */ + t_u16 primary_category; + /** Primary device type : OUI */ + t_u8 primary_oui[4]; + /** Primary device type : sub-category */ + t_u16 primary_subcategory; + /** Secondary Device Count */ + t_u8 secondary_dev_count; + /** Secondary Device Info */ + t_u8 secondary_dev_info[]; +#if 0 + /** WPS Device Name Tag */ + t_u16 device_name_type; + /** WPS Device Name Length */ + t_u16 device_name_len; + /** Device name */ + t_u8 device_name[]; +#endif +} PACK_END tlvbuf_wifidirect_device_info; + +typedef PACK_START struct _wifidirect_client_dev_info { + /** Length of each device */ + t_u8 dev_length; + /** WIFIDIRECT device address */ + t_u8 wifidirect_dev_address[ETH_ALEN]; + /** WIFIDIRECT Interface address */ + t_u8 wifidirect_intf_address[ETH_ALEN]; + /** WIFIDIRECT Device capability*/ + t_u8 wifidirect_dev_capability; + /** WPS config methods */ + t_u16 config_methods; + /** Primary device type : category */ + t_u16 primary_category; + /** Primary device type : OUI */ + t_u8 primary_oui[4]; + /** Primary device type : sub-category */ + t_u16 primary_subcategory; + /** Secondary Device Count */ + t_u8 wifidirect_secondary_dev_count; + /** Secondary Device Info */ + t_u8 wifidirect_secondary_dev_info[0]; + /** WPS WIFIDIRECT Device Name Tag */ + t_u16 wifidirect_device_name_type; + /** WPS WIFIDIRECT Device Name Length */ + t_u16 wifidirect_device_name_len; + /** WIFIDIRECT Device name */ + t_u8 wifidirect_device_name[]; +} PACK_END wifidirect_client_dev_info; + +typedef PACK_START struct _tlvbuf_wifidirect_group_info { + /** TLV Header tag */ + t_u8 tag; + /** TLV Header length */ + t_u16 length; + /** Secondary Device Info */ + t_u8 wifidirect_client_dev_list[]; +} PACK_END tlvbuf_wifidirect_group_info; + +/** TLV buffer : wifidirect IE group Id */ +typedef PACK_START struct _tlvbuf_wifidirect_group_id { + /** TLV Header tag */ + t_u8 tag; + /** TLV Header length */ + t_u16 length; + /** WIFIDIRECT group MAC address */ + t_u8 group_address[ETH_ALEN]; + /** WIFIDIRECT group SSID */ + t_u8 group_ssid[]; +} PACK_END tlvbuf_wifidirect_group_id; + +/** TLV buffer : wifidirect IE group BSS Id */ +typedef PACK_START struct _tlvbuf_wifidirect_group_bss_id { + /** TLV Header tag */ + t_u8 tag; + /** TLV Header length */ + t_u16 length; + /** WIFIDIRECT group Bss Id */ + t_u8 group_bssid[ETH_ALEN]; +} PACK_END tlvbuf_wifidirect_group_bss_id; + +/** TLV buffer : wifidirect IE Interface */ +typedef PACK_START struct _tlvbuf_wifidirect_interface { + /** TLV Header tag */ + t_u8 tag; + /** TLV Header length */ + t_u16 length; + /** WIFIDIRECT interface Id */ + t_u8 interface_id[ETH_ALEN]; + /** WIFIDIRECT interface count */ + t_u8 interface_count; + /** WIFIDIRECT interface addresslist */ + t_u8 interface_idlist[]; +} PACK_END tlvbuf_wifidirect_interface; + +/** TLV buffer : WifiDirect configuration timeout */ +typedef PACK_START struct _tlvbuf_wifidirect_config_timeout { + /** TLV Header tag */ + t_u8 tag; + /** TLV Header length */ + t_u16 length; + /** Group configuration timeout */ + t_u8 group_config_timeout; + /** Device configuration timeout */ + t_u8 device_config_timeout; +} PACK_END tlvbuf_wifidirect_config_timeout; + +/** TLV buffer : WifiDirect extended listen time */ +typedef PACK_START struct _tlvbuf_wifidirect_ext_listen_time { + /** TLV Header tag */ + t_u8 tag; + /** TLV Header length */ + t_u16 length; + /** Availability period */ + t_u16 availability_period; + /** Availability interval */ + t_u16 availability_interval; +} PACK_END tlvbuf_wifidirect_ext_listen_time; + +/** TLV buffer : WifiDirect Intended Interface Address */ +typedef PACK_START struct _tlvbuf_wifidirect_intended_addr { + /** TLV Header tag */ + t_u8 tag; + /** TLV Header length */ + t_u16 length; + /** WIFIDIRECT Group interface address */ + t_u8 group_address[ETH_ALEN]; +} PACK_END tlvbuf_wifidirect_intended_addr; + +/** TLV buffer : Wifi WPS IE */ +typedef PACK_START struct _tlvbuf_wifi_wps_ie { + /** TLV Header tag */ + t_u16 tag; + /** TLV Header length */ + t_u16 length; + /** WIFI WPS IE data */ + t_u8 data[]; +} PACK_END tlvbuf_wps_ie; + +/** WifiDirect IE Header */ +typedef PACK_START struct _wifidirect_ie_header { + /** Element ID */ + t_u8 element_id; + /** IE Length */ + t_u8 ie_length; + /** OUI */ + t_u8 oui[3]; + /** OUI type */ + t_u8 oui_type; + /** IE List of TLV */ + t_u8 ie_list[]; +} PACK_END wifidirect_ie_header; + +/** Event : WifiDirect Generic event */ +typedef PACK_START struct _apeventbuf_wifidirect_generic { + /** Event Length */ + t_u16 event_length; + /** Event Type */ + t_u16 event_type; + /** Event SubType */ + t_u16 event_sub_type; + /** Peer mac address */ + t_u8 peer_mac_addr[ETH_ALEN]; + /** IE List of TLV */ + t_u8 entire_ie_list[]; +} PACK_END apeventbuf_wifidirect_generic; + +/** Internal WIFIDIRECT structure for Query Data */ +typedef PACK_START struct wifidirect_query_data { + union { + PACK_START struct upnp_specific_query { + /** version field */ + t_u8 version; + /** value */ + t_u8 value[]; + } PACK_END upnp; + + PACK_START struct bonjour_specific_query { + /** DNS name */ + t_u8 dns[0]; + /** DNS type */ + t_u8 dns_type; + /** version field */ + t_u8 version; + } PACK_END bonjour; + } u; +} PACK_END wifidirect_query_data; + +/** Internal WIFIDIRECT structure for Response Data */ +typedef PACK_START struct wifidirect_Response_data { + union { + PACK_START struct upnp_specific_response { + /** version field */ + t_u8 version; + /** value */ + t_u8 value[]; + } PACK_END upnp; + + PACK_START struct bonjour_specific_response { + /** DNS name */ + t_u8 dns[0]; + /** DNS type */ + t_u8 dns_type; + /** version field */ + t_u8 version; + /** DNS name */ + t_u8 record[]; + } PACK_END bonjour; + } u; +} PACK_END wifidirect_response_data; + +/** Event : Service Discovery request */ +typedef PACK_START struct _apeventbuf_wifidirect_discovery_request { + /** Peer mac address */ + t_u8 peer_mac_addr[ETH_ALEN]; + /** Category */ + t_u8 category; + /** Action */ + t_u8 action; + /** Dialog taken */ + t_u8 dialog_taken; + /** Advertize protocol IE */ + t_u8 advertize_protocol_ie[4]; + /** Query request Length */ + t_u16 query_len; + /** Information identifier */ + t_u8 info_id[2]; + /** Request Length */ + t_u16 request_len; + /** OUI */ + t_u8 oui[3]; + /** OUI sub type */ + t_u8 oui_sub_type; + /** Service update indicator */ + t_u16 service_update_indicator; + /** Vendor Length */ + t_u16 vendor_len; + /** Service protocol */ + t_u8 service_protocol; + /** Service transaction Id */ + t_u8 service_transaction_id; + /** Query Data */ + wifidirect_query_data disc_query; +} PACK_END apeventbuf_wifidirect_discovery_request; + +/** HostCmd_CMD_WIFIDIRECT_SERVICE_DISCOVERY response */ +typedef PACK_START struct _apeventbuf_wifidirect_discovery_response { + /** Peer mac address */ + t_u8 peer_mac_addr[ETH_ALEN]; + /** Category */ + t_u8 category; + /** Action */ + t_u8 action; + /** Dialog taken */ + t_u8 dialog_taken; + /** Status code */ + t_u8 status_code; + /** GAS comback reply */ + t_u16 gas_reply; + /** Advertize protocol IE */ + t_u8 advertize_protocol_ie[4]; + /** Query response Length */ + t_u16 query_len; + /** Information identifier */ + t_u8 info_id[2]; + /** Response Length */ + t_u16 response_len; + /** OUI */ + t_u8 oui[3]; + /** OUI sub type */ + t_u8 oui_sub_type; + /** Service update indicator */ + t_u16 service_update_indicator; + /** Vendor Length */ + t_u16 vendor_len; + /** Service protocol */ + t_u8 service_protocol; + /** Service transaction Id */ + t_u8 service_transaction_id; + /** Discovery status code */ + t_u8 disc_status_code; + /** Response Data */ + wifidirect_response_data disc_resp; +} PACK_END apeventbuf_wifidirect_discovery_response; + +/** enum : WPS attribute type */ +typedef enum { + SC_AP_Channel = 0x1001, + SC_Association_State = 0x1002, + SC_Authentication_Type = 0x1003, + SC_Authentication_Type_Flags = 0x1004, + SC_Authenticator = 0x1005, + SC_Config_Methods = 0x1008, + SC_Configuration_Error = 0x1009, + SC_Confirmation_URL4 = 0x100A, + SC_Confirmation_URL6 = 0x100B, + SC_Connection_Type = 0x100C, + SC_Connection_Type_Flags = 0x100D, + SC_Credential = 0x100E, + SC_Device_Name = 0x1011, + SC_Device_Password_ID = 0x1012, + SC_E_Hash1 = 0x1014, + SC_E_Hash2 = 0x1015, + SC_E_SNonce1 = 0x1016, + SC_E_SNonce2 = 0x1017, + SC_Encrypted_Settings = 0x1018, + SC_Encryption_Type = 0X100F, + SC_Encryption_Type_Flags = 0x1010, + SC_Enrollee_Nonce = 0x101A, + SC_Feature_ID = 0x101B, + SC_Identity = 0X101C, + SC_Identity_Proof = 0X101D, + SC_Key_Wrap_Authenticator = 0X101E, + SC_Key_Identifier = 0X101F, + SC_MAC_Address = 0x1020, + SC_Manufacturer = 0x1021, + SC_Message_Type = 0x1022, + SC_Model_Name = 0x1023, + SC_Model_Number = 0x1024, + SC_Network_Index = 0x1026, + SC_Network_Key = 0x1027, + SC_Network_Key_Index = 0x1028, + SC_New_Device_Name = 0x1029, + SC_New_Password = 0x102A, + SC_OOB_Device_Password = 0X102C, + SC_OS_Version = 0X102D, + SC_Power_Level = 0X102F, + SC_PSK_Current = 0x1030, + SC_PSK_Max = 0x1031, + SC_Public_Key = 0x1032, + SC_Radio_Enabled = 0x1033, + SC_Reboot = 0x1034, + SC_Registrar_Current = 0x1035, + SC_Registrar_Established = 0x1036, + SC_Registrar_List = 0x1037, + SC_Registrar_Max = 0x1038, + SC_Registrar_Nonce = 0x1039, + SC_Request_Type = 0x103A, + SC_Response_Type = 0x103B, + SC_RF_Band = 0X103C, + SC_R_Hash1 = 0X103D, + SC_R_Hash2 = 0X103E, + SC_R_SNonce1 = 0X103F, + SC_R_SNonce2 = 0x1040, + SC_Selected_Registrar = 0x1041, + SC_Serial_Number = 0x1042, + SC_Simple_Config_State = 0x1044, + SC_SSID = 0x1045, + SC_Total_Networks = 0x1046, + SC_UUID_E = 0x1047, + SC_UUID_R = 0x1048, + SC_Vendor_Extension = 0x1049, + SC_Version = 0x104A, + SC_X_509_Certificate_Request = 0x104B, + SC_X_509_Certificate = 0x104C, + SC_EAP_Identity = 0x104D, + SC_Message_Counter = 0x104E, + SC_Public_Key_Hash = 0x104F, + SC_Rekey_Key = 0x1050, + SC_Key_Lifetime = 0x1051, + SC_Permitted_Config_Methods = 0x1052, + SC_SelectedRegistrarConfigMethods = 0x1053, + SC_Primary_Device_Type = 0x1054, + SC_Secondary_Device_Type_List = 0x1055, + SC_Portable_Device = 0x1056, + SC_AP_Setup_Locked = 0x1057, + SC_Application_List = 0x1058, + SC_EAP_Type = 0x1059, + SC_Initialization_Vector = 0x1060, + SC_Key_Provided_Auto = 0x1061, + SC_8021x_Enabled = 0x1062, + SC_App_Session_key = 0x1063, + SC_WEP_Transmit_Key = 0x1064, +} wps_simple_config_attribute; +#endif + +/** structure for channel switch result from TDLS FW */ +typedef PACK_START struct _Channel_switch_result { + /** current channel, 0 - base channel, 1 - off channel*/ + t_u8 current_channel; + /** channel switch status*/ + t_u8 status; + /** channel switch fauilure reason code*/ + t_u8 reason; +} PACK_END Channel_switch_result; + +/** Event : TDLS Generic event */ +typedef PACK_START struct _eventbuf_tdls_generic { + /** Event Type */ + t_u16 event_type; + /** Peer mac address */ + t_u8 peer_mac_addr[ETH_ALEN]; + union { + /** channel switch result structure*/ + Channel_switch_result switch_result; + /** channel switch stop reason */ + t_u8 cs_stop_reason; + /** Reason code */ + t_u16 reason_code; + /** IE Length */ + t_u16 ie_length; + } u; + /** IE pointer */ + t_u8 ie_ptr[]; +} PACK_END eventbuf_tdls_generic; + +/** Event : TDLS Debug event */ +typedef PACK_START struct _eventbuf_tdls_debug { + /** Event Type */ + t_u16 event_type; + /** TimeStamp value */ + t_u64 tsf; + /** First argument */ + t_u32 first_arg; + /** Second argument */ + t_u32 second_arg; + /** Third argument */ + t_u32 third_arg; + /** Third argument */ + t_u16 string_len; + /** Third argument */ + t_u8 string[]; +} PACK_END eventbuf_tdls_debug; + +/** Event : TDLS packet event */ +typedef PACK_START struct _eventbuf_tdls_packet { + /** Event Type */ + t_u16 event_type; + /** Length */ + t_u16 length; + /** packet data */ + t_u8 data[]; +} PACK_END eventbuf_tdls_packet; + +/** Eapol state */ +typedef PACK_START struct { + /** Eapol state*/ + t_u8 eapol_state; + /** Station address*/ + t_u8 sta_mac_addr[ETH_ALEN]; +} PACK_END eapol_state_t; + +/** Debug Info */ +typedef PACK_START union { + /** Eapol key message */ + eapol_keymsg_debug_t eapol_pwkmsg; + /** Station reject*/ + sta_reject_t sta_reject; + /** WPA IE */ + wpaie_t wpaie; + /** Eapol state */ + eapol_state_t eapol_state; +} PACK_END d_info; + +/** Event body : Debug */ +typedef PACK_START struct _eventbuf_debug { + /** Debug type */ + t_u8 debug_type; + /** Major debug id */ + t_u32 debug_id_major; + /** Minor debug id */ + t_u32 debug_id_minor; + /** Debug Info */ + d_info info; +} PACK_END eventbuf_debug; + +/** Event body : 11K NLIST */ +typedef PACK_START struct _nlist_entry_tlv { + tlvbuf_header hdr; + t_u8 bssid[6]; + t_u8 bssid_info[4]; + t_u8 reg_class; + t_u8 chan; + t_u8 phy_type; +} PACK_END nlist_entry_tlv; + +int ishexstring(void *hex); +unsigned int a2hex(char *s); +/** + * @brief isdigit for String. + * + * @param x Char string + * @return MLAN_EVENT_FAILURE for non-digit. + * 0 for digit + */ +static inline int ISDIGIT(char *x) +{ + unsigned int i; + for (i = 0; i < strlen(x); i++) + if (isdigit((unsigned char)x[i]) == 0) + return MLAN_EVENT_FAILURE; + return 0; +} + +#define CUS_EVT_TOD_TOA "EVENT=TOD-TOA" + +#define CUS_EVT_MLAN_CSI "EVENT=MLAN_CSI" +#define CSI_DUMP_FILE_MAX 1200000 // 1.2MB +/** CSI record data structure */ +typedef PACK_START struct _csi_record_ds { + /** Length in DWORDS, including header */ + t_u16 Len; + /** CSI signature. 0xABCD fixed */ + t_u16 CSI_Sign; + /** User defined HeaderID */ + t_u32 CSI_HeaderID; + /** Packet info field */ + t_u16 PKT_info; + /** Frame control field for the received packet*/ + t_u16 FCF; + /** Timestamp when packet received */ + t_u64 TSF; + /** Received Packet Destination MAC Address */ + t_u8 Dst_MAC[6]; + /** Received Packet Source MAC Address */ + t_u8 Src_MAC[6]; + /** RSSI for antenna A */ + t_u8 Rx_RSSI_A; + /** RSSI for antenna B */ + t_u8 Rx_RSSI_B; + /** Noise floor for antenna A */ + t_u8 Rx_NF_A; + /** Noise floor for antenna A */ + t_u8 Rx_NF_B; + /** Rx signal strength above noise floor */ + t_u8 Rx_SINR; + /** Channel */ + t_u8 channel; + /** user defined Chip ID */ + t_u16 chip_id; + /** Reserved */ + t_u32 rsvd; + /** CSI data length in DWORDs */ + t_u32 CSI_Data_Length; + /** Start of CSI data */ + t_u8 CSI_Data[0]; + /** At the end of CSI raw data, user defined TailID of 4 bytes*/ +} PACK_END csi_record_ds; +/** Event body : MLAN_CSI */ +typedef PACK_START struct _event_mlan_csi { + /** Event string: EVENT=MLAN_CSI */ + char event_str[14]; + /** Event sequence # */ + t_u16 sequence; + csi_record_ds csi_record; +} PACK_END event_mlan_csi; + +#endif /* _MLAN_EVENT_H */ diff --git a/mapp/mlanutl/Makefile b/mapp/mlanutl/Makefile new file mode 100644 index 0000000..b051088 --- /dev/null +++ b/mapp/mlanutl/Makefile @@ -0,0 +1,66 @@ +# File : mlanutl/Makefile +# +# Copyright 2011-2022 NXP + +# Path to the top directory of the wlan distribution +PATH_TO_TOP = ../.. + +ifeq ($(findstring IMX_ANDROID,$(ccflags-y)),IMX_ANDROID) +CC=/usr/local/arm/android-ndk-r23-beta5/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang +endif + +# Determine how we should copy things to the install directory +ABSPATH := $(filter /%, $(INSTALLDIR)) +RELPATH := $(filter-out /%, $(INSTALLDIR)) +INSTALLPATH := $(ABSPATH) +ifeq ($(strip $(INSTALLPATH)),) +INSTALLPATH := $(PATH_TO_TOP)/$(RELPATH) +endif + +# Override CFLAGS for application sources, remove __ kernel namespace defines +CFLAGS := $(filter-out -D__%, $(ccflags-y)) +# remove KERNEL include dir +CFLAGS := $(filter-out -I$(KERNELDIR)%, $(CFLAGS)) + + +#CFLAGS += -DAP22 -fshort-enums +CFLAGS += -Wall +CFLAGS += -Wno-stringop-truncation +#ECHO = @ +ifeq (,$(findstring ANDROID_KERNEL, $(CFLAGS))) +LIBS=-lrt +endif + +.PHONY: default tags all + +OBJECTS = mlanutl.o +HEADERS = mlanutl.h + + + + + +OBJECTS := $(OBJECTS) mlanwls.o +HEADERS := $(HEADERS) mlanwls.h + +exectarget=mlanutl +TARGET := $(exectarget) + +build appsbuild default: $(TARGET) + @cp -f $(TARGET) $(INSTALLPATH) + +all : tags default + +$(TARGET): $(OBJECTS) $(HEADERS) + $(ECHO)$(CC) $(LIBS) -o $@ $(OBJECTS) + +%.o: %.c $(HEADERS) + $(ECHO)$(CC) $(CFLAGS) -c -o $@ $< + +tags: + ctags -R -f tags.txt + +distclean clean: + $(ECHO)$(RM) $(OBJECTS) $(TARGET) + $(ECHO)$(RM) tags.txt + diff --git a/mapp/mlanutl/mlanhostcmd.c b/mapp/mlanutl/mlanhostcmd.c new file mode 100644 index 0000000..2366717 --- /dev/null +++ b/mapp/mlanutl/mlanhostcmd.c @@ -0,0 +1,940 @@ +/** @file mlanhostcmd.c + * + * @brief This file contains mlanutl helper functions + * + * + * Copyright 2008-2021 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((unsigned char)*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((unsigned char)*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 ARP filter buffer + * @param fp File handler + * @param buf A pointer to the buffer + * @param length A pointer to the length of buffer + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +int prepare_arp_filter_buffer(FILE *fp, t_u8 *buf, t_u16 *length) +{ + t_s8 line[256], *pos; + int ln = 0; + int ret = MLAN_STATUS_SUCCESS; + int arpfilter_found = 0; + + memset(buf, 0, MRVDRV_SIZE_OF_CMD_BUFFER); + while ((pos = mlan_config_get_line(fp, line, sizeof(line), &ln))) { + if (strcmp(pos, "arpfilter={") == 0) { + arpfilter_found = 1; + mlan_get_hostcmd_data(fp, &ln, buf, length); + break; + } + } + if (!arpfilter_found) { + fprintf(stderr, "mlanutl: 'arpfilter' not found in conf file"); + ret = MLAN_STATUS_FAILURE; + } + 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/mapp/mlanutl/mlanhostcmd.h b/mapp/mlanutl/mlanhostcmd.h new file mode 100644 index 0000000..15e6ee1 --- /dev/null +++ b/mapp/mlanutl/mlanhostcmd.h @@ -0,0 +1,134 @@ +/** @file mlanhostcmd.h + * + * @brief This file contains command structures for mlanutl application + * + * + * Copyright 2008-2021 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/mapp/mlanutl/mlanoffload.c b/mapp/mlanutl/mlanoffload.c new file mode 100644 index 0000000..d4c37f1 --- /dev/null +++ b/mapp/mlanutl/mlanoffload.c @@ -0,0 +1,3024 @@ +/** @file mlanoffload.c + * + * @brief This files contains mlanutl offload command handling. + * + * + * Copyright 2008-2021 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/mapp/mlanutl/mlanoffload.h b/mapp/mlanutl/mlanoffload.h new file mode 100644 index 0000000..689d40d --- /dev/null +++ b/mapp/mlanutl/mlanoffload.h @@ -0,0 +1,505 @@ +/** @file mlanoffload.h + * + * @brief This files contains mlanutl offload command handling. + * + * + * Copyright 2008-2021 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/mapp/mlanutl/mlanregclass.c b/mapp/mlanutl/mlanregclass.c new file mode 100644 index 0000000..8be4125 --- /dev/null +++ b/mapp/mlanutl/mlanregclass.c @@ -0,0 +1,534 @@ +/** @file mlanregclass.c + * + * @brief This files contains mlanutl regclass command handling. + * + * + * Copyright 2008-2021 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/mapp/mlanutl/mlanregclass.h b/mapp/mlanutl/mlanregclass.h new file mode 100644 index 0000000..15bdb33 --- /dev/null +++ b/mapp/mlanutl/mlanregclass.h @@ -0,0 +1,96 @@ +/** @file mlanregclass.h + * + * @brief This files contains mlanutl regclass command handling. + * + * + * Copyright 2008-2021 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/mapp/mlanutl/mlanroamagent.c b/mapp/mlanutl/mlanroamagent.c new file mode 100644 index 0000000..b77a397 --- /dev/null +++ b/mapp/mlanutl/mlanroamagent.c @@ -0,0 +1,3600 @@ +/** @file mlanroamagent.c + * + * @brief This files contains mlanutl roamagent command handling. + * + * + * Copyright 2008-2021 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/mapp/mlanutl/mlanroamagent.h b/mapp/mlanutl/mlanroamagent.h new file mode 100644 index 0000000..0cef79f --- /dev/null +++ b/mapp/mlanutl/mlanroamagent.h @@ -0,0 +1,321 @@ +/** @file mlanroamagent.h + * + * @brief This files contains mlanutl roamagent command handling. + * + * + * Copyright 2008-2021 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/mapp/mlanutl/mlanscanagent.c b/mapp/mlanutl/mlanscanagent.c new file mode 100644 index 0000000..46398c0 --- /dev/null +++ b/mapp/mlanutl/mlanscanagent.c @@ -0,0 +1,823 @@ +/** @file mlanscanagent.c + * + * @brief This files contains mlanutl scanagent command handling. + * + * + * Copyright 2008-2021 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/mapp/mlanutl/mlanscanagent.h b/mapp/mlanutl/mlanscanagent.h new file mode 100644 index 0000000..76ae0ac --- /dev/null +++ b/mapp/mlanutl/mlanscanagent.h @@ -0,0 +1,148 @@ +/** @file mlanscanagent.h + * + * @brief This files contains mlanutl scanagent command handling. + * + * + * Copyright 2008-2021 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/mapp/mlanutl/mlanutl.c b/mapp/mlanutl/mlanutl.c new file mode 100644 index 0000000..2600eca --- /dev/null +++ b/mapp/mlanutl/mlanutl.c @@ -0,0 +1,26452 @@ +/** @file mlanutl.c + * + * @brief Program to control parameters in the mlandriver + * + * + * Copyright 2011-2025 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 +************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "mlanutl.h" + +extern int mlanwls_main(int argc, char *argv[]); + +/** Supported stream modes */ +#define HT_STREAM_MODE_1X1 0x11 +#define HT_STREAM_MODE_2X2 0x22 + +/** mlanutl version number */ +#define MLANUTL_VER "M1.3" + +/** Termination flag */ +int terminate_flag = 0; + +#define MAX_MEF_NUM_ENTRIES 100 + +/******************************************************** + 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", +}; + +/** 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"}; + +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)"}; + +#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 MREG_D MBIT(9) +#define MREG MBIT(10) +#define MLSTATS MBIT(11) + +#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) + +#ifdef DEBUG_LEVEL2 +#define MENTRY MBIT(28) +#define MWARN MBIT(29) +#define MINFO MBIT(30) +#endif +#endif + +#define MAX_CH_LOAD_DURATION 10 + +static int process_version(int argc, char *argv[]); +static int process_verext(int argc, char *argv[]); +static int process_hostcmd(int argc, char *argv[]); +#ifdef DEBUG_LEVEL1 +static int process_drvdbg(int argc, char *argv[]); +#endif +static int process_datarate(int argc, char *argv[]); +static int process_getlog(int argc, char *argv[]); +static int process_get_txpwrlimit(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_vhtcfg(int argc, char *argv[]); +static int process_dyn_bw(int argc, char *argv[]); +static int process_11axcfg(int argc, char *argv[]); +static int process_11axcmdcfg(int argc, char *argv[]); +static int process_txratecfg(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_hssetpara(int argc, char *argv[]); +static int process_mefcfg(int argc, char *argv[]); +static int process_min_ba_threshold_cfg(int argc, char *argv[]); +static int process_txwatchdog(int argc, char *argv[]); +static int process_turbo_mode(int argc, char *argv[]); +static int process_getuuid(int argc, char *argv[]); +static int process_crosssynch(int argc, char *argv[]); +static int process_tsp(int argc, char *argv[]); + +static int process_multi_chan_cfg(int argc, char *argv[]); +static int process_multi_chan_policy(int argc, char *argv[]); +static int process_drcs_time_slicing_cfg(int argc, char *argv[]); +static int process_dot11_txrx(int argc, char *argv[]); +static int process_bandcfg(int argc, char *argv[]); +static int process_delba(int argc, char *argv[]); +static int process_rejectaddbareq(int argc, char *argv[]); +static int process_opermodecfg(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 +#if defined(UAP_SUPPORT) +static int process_setmode(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_flush_time(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_gpio_tsf_latch(int argc, char *argv[]); +static int process_get_tsf_info(int argc, char *argv[]); +static int process_backup_channel(int argc, char *argv[]); +static int process_target_channel(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 +static int process_hscfg(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_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_host_tdls_config(int argc, char *argv[]); +static int process_tdls_config(int argc, char *argv[]); +static int process_tdls_setinfo(int argc, char *argv[]); +static int process_tdls_discovery(int argc, char *argv[]); +static int process_tdls_setup(int argc, char *argv[]); +static int process_tdls_teardown(int argc, char *argv[]); +static int process_tdls_powermode(int argc, char *argv[]); +static int process_tdls_link_status(int argc, char *argv[]); +static int process_tdls_debug(int argc, char *argv[]); +static int process_tdls_channel_switch(int argc, char *argv[]); +static int process_tdls_stop_channel_switch(int argc, char *argv[]); +static int process_tdls_cs_params(int argc, char *argv[]); +static int process_tdls_disable_channel_switch(int argc, char *argv[]); +static int process_tdls_idle_time(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 STA_SUPPORT +static int process_arpfilter(int argc, char *argv[]); +#endif +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[]); +static int process_plinkstats(int argc, char *argv[]); +#if defined(STA_SUPPORT) +static int process_pmfcfg(int argc, char *argv[]); +#endif +#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[]); +#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_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[]); +static int process_sleep_params(int argc, char *argv[]); +static int process_net_monitor(int argc, char *argv[]); +#if defined(DFS_TESTING_SUPPORT) +static int process_dfs_testing(int argc, char *argv[]); +static int process_clear_nop(int argc, char *argv[]); +static int process_nop_list(int argc, char *argv[]); +static int process_do_fake_radar(int argc, char *argv[]); +#endif +static int process_dfs53cfg(int argc, char *argv[]); +static int process_dfs_mode(int argc, char *argv[]); +static int process_do_dfs_cac(int argc, char *argv[]); +static int process_autodfs_cfg(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_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 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[]); +static int process_txaggrctrl(int argc, char *argv[]); +static int process_auto_tdls(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_11k_cfg(int argc, char *argv[]); +static int process_11k_neighbor_report(int argc, char *argv[]); +static int process_extend_channel_switch(int argc, char *argv[]); +static int process_set_channel_switch_param(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[]); +int process_tsf(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_csi_cmd(int argc, char *argv[]); +static int process_range_ext(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_twt_report(int argc, char *argv[]); + +static int process_ftm_cmd(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_nav_mitigation(int argc, char *argv[]); +static int process_led(int argc, char *argv[]); +static int process_tx_ampdu_prot_mode(int argc, char *argv[]); +static int process_dot11mc_unassoc_ftm_cfg(int argc, char *argv[]); +static int process_hal_phy_cfg(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_ofdm_desense_cfg(int argc, char *argv[]); +static int process_lpm(int argc, char *argv[]); + +static int process_arbcfg(int argc, char *argv[]); +static int process_ips_cfg(int argc, char *argv[]); +static int process_ch_load(int argc, char *argv[]); +static int process_ch_load_results(int argc, char *argv[]); + +static int process_auth_assoc_timeout_cfg(int argc, char *argv[]); +#ifdef UAP_SUPPORT +static int process_agcs(int argc, char *argv[]); +#endif +static int process_foundry_type(int argc, char *argv[]); + +struct command_node command_list[] = { + {"version", process_version}, + {"verext", process_verext}, + {"hostcmd", process_hostcmd}, +#ifdef DEBUG_LEVEL1 + {"drvdbg", process_drvdbg}, +#endif + {"getdatarate", process_datarate}, + {"getlog", process_getlog}, + {"get_txpwrlimit", process_get_txpwrlimit}, +#ifdef STA_SUPPORT + {"getsignal", process_get_signal}, + {"getsignalext", process_get_signal_ext}, + {"getsignalextv2", process_get_signal_ext}, + {"signalextcfg", process_signalext_cfg}, +#endif + {"vhtcfg", process_vhtcfg}, + {"dyn_bw", process_dyn_bw}, + {"11axcfg", process_11axcfg}, + {"11axcmd", process_11axcmdcfg}, + {"txratecfg", process_txratecfg}, + {"addbapara", process_addbapara}, + {"aggrpriotbl", process_aggrpriotbl}, + {"addbareject", process_addbareject}, + {"httxcfg", process_httxcfg}, + {"htcapinfo", process_htcapinfo}, + {"hssetpara", process_hssetpara}, + {"mefcfg", process_mefcfg}, + {"min_ba_threshold", process_min_ba_threshold_cfg}, + {"bandcfg", process_bandcfg}, + {"delba", process_delba}, + {"rejectaddbareq", process_rejectaddbareq}, + {"opermodecfg", process_opermodecfg}, + {"esuppmode", process_esuppmode}, + {"passphrase", process_passphrase}, + {"deauth", process_deauth}, +#ifdef UAP_SUPPORT + {"getstalist", process_getstalist}, +#endif +#if defined(UAP_SUPPORT) + {"setmode", process_setmode}, +#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}, + {"flush_time", process_flush_time}, + {"ipaddr", process_ipaddr}, + {"otpuserdata", process_otpuserdata}, + {"countrycode", process_countrycode}, + {"clocksync", process_gpio_tsf_latch}, + {"gettsfinfo", process_get_tsf_info}, + {"targetchan", process_target_channel}, + {"backupchan", process_backup_channel}, + {"tcpackenh", process_tcpackenh}, +#ifdef REASSOCIATION + {"assocessid", process_assocessid}, + {"assocessid_bssid", process_assocessid}, +#endif +#ifdef STA_SUPPORT + {"listeninterval", process_listeninterval}, + {"psmode", process_psmode}, +#endif + {"hscfg", process_hscfg}, + {"wakeupreason", process_wakeupresaon}, + {"mgmtfilter", process_mgmtfilter}, + {"scancfg", process_scancfg}, + {"warmreset", process_warmreset}, + {"txpowercfg", process_txpowercfg}, + {"pscfg", process_pscfg}, + {"bcntimeoutcfg", process_bcntimeoutcfg}, + {"sleeppd", process_sleeppd}, + {"txcontrol", process_txcontrol}, + {"host_tdls_config", process_host_tdls_config}, + {"tdls_config", process_tdls_config}, + {"tdls_setinfo", process_tdls_setinfo}, + {"tdls_discovery", process_tdls_discovery}, + {"tdls_setup", process_tdls_setup}, + {"tdls_teardown", process_tdls_teardown}, + {"tdls_powermode", process_tdls_powermode}, + {"tdls_link_status", process_tdls_link_status}, + {"tdls_debug", process_tdls_debug}, + {"tdls_channel_switch", process_tdls_channel_switch}, + {"tdls_stop_channel_switch", process_tdls_stop_channel_switch}, + {"tdls_cs_params", process_tdls_cs_params}, + {"tdls_disable_cs", process_tdls_disable_channel_switch}, + {"tdls_idle_time", process_tdls_idle_time}, + {"dfs_offload", process_dfs_offload_enable}, + {"customie", process_customie}, + {"regrdwr", process_regrdwr}, + {"rdeeprom", process_rdeeprom}, + {"memrdwr", process_memrdwr}, +#ifdef STA_SUPPORT + {"arpfilter", process_arpfilter}, +#endif + {"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}, + {"plinkstats", process_plinkstats}, +#if defined(STA_SUPPORT) + {"pmfcfg", process_pmfcfg}, +#endif +#if defined(STA_SUPPORT) && defined(STA_WEXT) + {"radioctrl", process_radio_ctrl}, +#endif + {"wmmcfg", process_wmm_cfg}, + {"wmmparamcfg", process_wmm_param_config}, +#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}, + {"inactivityto", process_inactivity_timeout_ext}, + {"amsduaggrctrl", process_11n_amsdu_aggr_ctrl}, + {"httxbfcap", process_tx_bf_cap_ioctl}, + {"sleepparams", process_sleep_params}, + {"netmon", process_net_monitor}, +#if defined(DFS_TESTING_SUPPORT) + {"dfstesting", process_dfs_testing}, + {"clear_nop", process_clear_nop}, + {"nop_list", process_nop_list}, + {"fake_radar", process_do_fake_radar}, +#endif + {"dfs53cfg", process_dfs53cfg}, + {"dfs_mode", process_dfs_mode}, + {"dfs_cac", process_do_dfs_cac}, + {"autodfs", process_autodfs_cfg}, + {"cfpcode", process_cfp_code}, + {"antcfg", process_set_get_tx_rx_ant}, + {"get_chnrgpwr", process_get_chnrgpwr}, + {"comparergpwr", process_compare_rgpwr}, + {"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}, + {"mc_cfg", process_multi_chan_cfg}, + {"mc_policy", process_multi_chan_policy}, + {"mc_cfg_ext", process_drcs_time_slicing_cfg}, +#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}, + {"txaggrctrl", process_txaggrctrl}, + {"autotdls", process_auto_tdls}, +#ifdef PCIE + {"pcieregrw", process_pcie_reg_rw}, + {"pciebar0regrw", process_pcie_bar0_reg_rw}, +#endif + {"get_sensor_temp", process_get_sensor_temp}, + {"11k_enable", process_11k_cfg}, + {"neighbor_report", process_11k_neighbor_report}, + {"channel_switch", process_extend_channel_switch}, + {"chanswitch_param", process_set_channel_switch_param}, + {"auto_arp", process_auto_arp}, + {"txrxhistogram", process_txrxhistogram}, + {"indrstcfg", process_ind_rst_cfg}, + {"tsf", process_tsf}, + {"dot11_txrx", process_dot11_txrx}, + {"per_pkt_cfg", process_per_pkt_cfg}, + {"robustcoex", process_robustcoex}, +#if defined(PCIE) + {"ssu", process_ssu_cmd}, +#endif + {"ctrldeauth", process_ctrldeauth}, + {"bootsleep", process_bootsleep}, + {"csi", process_csi_cmd}, + {"dmcs", process_dmcs}, + {"range_ext", process_range_ext}, + {"twt_setup", process_twt_setup}, + {"twt_teardown", process_twt_teardown}, + {"twt_report", process_twt_report}, + {"rx_abort_cfg", process_rx_abort_cfg}, + {"ofdm_desense_cfg", process_ofdm_desense_cfg}, + {"rx_abort_cfg_ext", process_rx_abort_cfg_ext}, + {"nav_mitigation", process_nav_mitigation}, + {"led", process_led}, + {"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}, + {"arb", process_arbcfg}, + {"dot11mc_unassoc_ftm_cfg", process_dot11mc_unassoc_ftm_cfg}, + {"ftm", process_ftm_cmd}, + {"hal_phy_cfg", process_hal_phy_cfg}, + {"ips_cfg", process_ips_cfg}, + {"getchload", process_ch_load}, + {"getloadresults", process_ch_load_results}, + {"txwatchdog", process_txwatchdog}, + {"getuuid", process_getuuid}, + {"turbo_mode", process_turbo_mode}, + {"crosssynch", process_crosssynch}, + {"wlan_tsp_cfg", process_tsp}, + {"auth_assoc_timeout_cfg", process_auth_assoc_timeout_cfg}, + {"foundry_type", process_foundry_type}, +#ifdef UAP_SUPPORT + {"agcs", process_agcs}, +#endif +}; + +static char *usage[] = { + "Usage: ", " mlanutl -v (version)", + " mlanutl [...]", " where", + " ifname : wireless network interface name, such as mlanX or uapX", + " cmd :", " version", " verext", " hostcmd", +#ifdef DEBUG_LEVEL1 + " drvdbg", +#endif + " getdatarate", " getlog", " get_txpwrlimit", +#ifdef STA_SUPPORT + " getsignal", " signalextcfg", " getsignalext", + " getsignalextv2", +#endif + " vhtcfg", " dyn_bw", " 11axcfg", + " 11axcmd", " txratecfg", " httxcfg", + " htcapinfo", " aggrpriotbl", " addbapara", + " addbareject", " hssetpara", " mefcfg", + " min_ba_threshold", " 11dcfg", " 11dclrtbl", + " addbapara", " addbareject", " addts", + " amsduaggrctrl", " antcfg", +#ifdef STA_SUPPORT + " arpfilter", +#endif +#ifdef REASSOCIATION + " assocessid", " assocessid_bssid", +#endif + " associate", " authtype", " autotdls", + " 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", " flush_time", + " delba", " delts", +#if defined(DFS_TESTING_SUPPORT) + " dfstesting", " clear_nop", " nop_list", + " fake_radar", +#endif + " dfs53cfg", " dfs_mode", " dfs_cac", + " autodfs", " dfs_repeater", " dscpmap", + " esuppmode", +#ifdef STA_SUPPORT + " extcapcfg", " cancelscan", +#endif + " fwmacaddr", + /* #ifdef FW_WAKEUP_METHOD */ + " fwwakeupmethod", + /* #endif */ + " getkey", +#ifdef STA_SUPPORT + " getscantable", +#endif +#ifdef UAP_SUPPORT + " getstalist", +#endif +#if defined(UAP_SUPPORT) + " setmode", +#endif + " hotspotcfg", " hscfg", " mgmtfilter", + " htstreamcfg", " mimoswitch", " httxbfcap", + " httxbfcfg", " inactivityto", " ipaddr", + " linkstats", " plinkstats", +#ifdef STA_SUPPORT + " listeninterval", +#endif + " macctrl", " memrdwr", +#ifdef WIFI_DIRECT_SUPPORT + " miracastcfg", +#endif + " mgmtframectrl", " mgmtframetx", " netmon", +#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 STA_SUPPORT + " setuserscan", +#endif + " sleepparams", " sleeppd", " sysclock", + " clocksync", " gettsfinfo", " targetschan", + " backupchan", " tcpackenh", " tdls_idle_time", + " tdls_channel_switch", " tdls_config", + " tdls_cs_params", " tdls_debug", + " tdls_disable_cs", " tdls_discovery", + " tdls_link_status", " tdls_powermode", + " tdls_setinfo", " tdls_setup", + " tdls_stop_channel_switch", " tdls_teardown", + " thermal", " ts_status", " tsf", + " txaggrctrl", " txbufcfg", " txcontrol", + " txpowercfg", " txwatchdog", " opermodecfg", + " wakeupreason", " warmreset", " wmmcfg", + " wmmparamcfg", " wpssession", +#ifndef OPCHAN + " wwscfg", +#endif + " mc_cfg", " mc_policy", " mc_cfg_ext", + " get_sensor_temp", " 11k_enable", + " neighbor_report", " channel_switch", + " chanswitch_param", " indrstcfg", + " dfs_offload", + + " cwmode", " txrxhistogram", " per_pkt_cfg", + " dot11_txrx", " robustcoex", " ctrldeauth", + " dmcs", " range_ext", " twt_setup", + " twt_teardown", " twt_report", " rx_abort_cfg", + " rx_abort_cfg_ext", " nav_mitigation", + " tx_ampdu_prot_mode", " rate_adapt_cfg", + " cck_desense_cfg", " ofdm_desense_cfg", + " get_chnrgpwr", " comparergpwr", + " comparetrpc", " getcfgchanlist", " lpm", + " arb", " dot11mc_unassoc_ftm_cfg", + " hal_phy_cfg", " ips_cfg", " getchload", + " ftm", " getuuid", " crosssynch", + " wlan_tsp_cfg", + " auth_assoc_timeout_cfg" + " foundry_type", +#ifdef UAP_SUPPORT + " agcs" +#endif +}; + +/** Socket */ +t_s32 sockfd; +/** Device name */ +char dev_name[IFNAMSIZ]; +#define HOSTCMD "hostcmd" + +char *config_get_line(char *s, int size, FILE *stream, int *line, char **_pos); +#define BSSID_FILTER 1 +#define SSID_FILTER 2 +/******************************************************** + Global Variables +********************************************************/ + +int setuserscan_filter = 0; +int num_ssid_filter = 0; +/******************************************************** + Local Functions +********************************************************/ +/** + * @brief Convert char to hex integer + * + * @param chr Char to convert + * @return Hex integer or 0 + */ +static 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(char *prompt, t_void *p, t_s32 len, char 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(char 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(char *s) +{ + t_u32 val = 0; + + if (!strncasecmp("0x", s, 2)) { + s += 2; + } + + while (*s && isxdigit((unsigned char)*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(char *value) +{ + if (value[0] == '0' && (value[1] == 'X' || value[1] == 'x')) { + return a2hex(value + 2); + } else { + return (t_u32)atoi(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 + */ +static char *convert2hex(char *ptr, t_u8 *chr) +{ + t_u8 val; + + for (val = 0; *ptr && isxdigit((unsigned char)*ptr); ptr++) { + val = (val * 16) + hexval(*ptr); + } + + *chr = val; + + return ptr; +} + +/** + * @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 and execute command + * + * @param argc Number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS for success, otherwise failure + */ +static int process_command(int argc, char *argv[]) +{ + int i = 0, ret = MLAN_STATUS_NOTFOUND; + struct command_node *node = NULL; + + for (i = 0; i < (int)NELEMENTS(command_list); i++) { + node = &command_list[i]; + if (!strcasecmp(node->name, argv[2])) { + ret = node->handler(argc, argv); + break; + } + } + + return ret; +} + +/** + * @brief Prepare command buffer + * @param buffer Command buffer to be filled + * @param cmd Command id + * @param num Number of arguments + * @param args Arguments list + * @return MLAN_STATUS_SUCCESS + */ +static int prepare_buffer(t_u8 *buffer, char *cmd, t_u32 num, char *args[]) +{ + t_u8 *pos = NULL; + unsigned int i = 0; + unsigned int remaining = BUFFER_LENGTH; + + memset(buffer, 0, BUFFER_LENGTH); + + /* Flag it for our use */ + pos = buffer; + memcpy((char *)pos, CMD_NXP, strlen(CMD_NXP)); + pos += (strlen(CMD_NXP)); + remaining -= strlen(CMD_NXP); + + /* Insert command */ + if (remaining < strlen(cmd)) + return MLAN_STATUS_FAILURE; + strncpy((char *)pos, (char *)cmd, strlen(cmd)); + pos += (strlen(cmd)); + remaining -= strlen(cmd); + + /* Insert arguments */ + for (i = 0; i < num; i++) { + if (remaining < strlen(args[i])) + return MLAN_STATUS_FAILURE; + strncpy((char *)pos, args[i], strlen(args[i])); + pos += strlen(args[i]); + remaining -= strlen(args[i]); + + if (i < (num - 1)) { + if (remaining < 1) + return MLAN_STATUS_FAILURE; + memcpy((char *)pos, " ", strlen(" ")); + pos += 1; + remaining -= 1; + } + } + + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Trims leading and traling spaces only + * @param str A pointer to argument string + * @return pointer to trimmed string + */ +static char *trim_spaces(char *str) +{ + char *str_end = NULL; + + if (!str) + return NULL; + + /* Trim leading spaces */ + while (!*str && isspace((unsigned char)*str)) + str++; + + if (*str == 0) /* All spaces? */ + return str; + + /* Trim trailing spaces */ + str_end = str + strlen(str) - 1; + while (str_end > str && isspace((unsigned char)*str_end)) + str_end--; + + /* null terminate the string */ + *(str_end + 1) = '\0'; + + return str; +} + +/** + * @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] = {0}; + t_s32 isCurCmd = 0; + + dptr = dst; + while (fgets((char *)buf, sizeof(buf), fp)) { + ptr = buf; + + while (*ptr) { + /* skip leading spaces */ + while (*ptr && isspace((unsigned char)*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; + else + isCurCmd = 1; + } + + /* Ignore the rest if it is not correct cmd */ + if (!isCurCmd) + break; + + if (*ptr == '[' && *(ptr + 1) == '/') + return dptr - dst; + + if (isxdigit((unsigned char)*ptr)) { + ptr = (t_s8 *)convert2hex((char *)ptr, dptr++); + } else { + /* Invalid character on data line */ + ptr++; + } + } + } + + return MLAN_STATUS_FAILURE; +} + +/** + * @brief Process version + * @param argc Number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_version(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)) { + perror("mlanutl"); + fprintf(stderr, "mlanutl: version fail\n"); + if (cmd) + free(cmd); + if (buffer) + free(buffer); + return MLAN_STATUS_FAILURE; + } + + /* Process result */ + printf("Version string received: %s\n", buffer); + + if (buffer) + free(buffer); + if (cmd) + free(cmd); + + return MLAN_STATUS_SUCCESS; +} + +/** + * @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; +} + +int process_host_cmd_resp(char *cmd_name, t_u8 *buf); + +/** + * @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 + */ +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 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; + char 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 > BUFFER_LENGTH) { + 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; +} + +/** + * @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 + */ +static 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; + t_u32 hostcmd_size = 0; + int ln = 0; + int cmdname_found = 0, cmdcode_found = 0; + + hostcmd = (HostCmd_DS_GEN *)(buf + sizeof(t_u32)); + 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) { + 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) { + t_u16 len = 0; + cmdcode_found = 1; + 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); + 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 = (t_u32)(hostcmd->size); + hostcmd->size = cpu_to_le16(hostcmd->size); + memcpy(buf, (t_u8 *)&hostcmd_size, sizeof(t_u32)); + + return MLAN_STATUS_SUCCESS; +} + +/** + * @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[]) +{ + 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; + char cmdname[256]; + boolean call_ioctl = TRUE; + t_u32 buf_len = 0, i, j, k; + char *line = NULL, *pos = NULL; + int li = 0, blk_count = 0, ob = 0; + int ret = MLAN_STATUS_SUCCESS; + + struct cmd_node { + char cmd_string[256]; + struct cmd_node *next; + }; + struct cmd_node *command = NULL, *header = NULL, *new_node = NULL; + + if (argc < 5) { + printf("Error: invalid no of arguments\n"); + printf("Syntax: ./mlanutl mlanX hostcmd \n"); + ret = MLAN_STATUS_FAILURE; + goto done; + } + + snprintf(cmdname, sizeof(cmdname), "%s", argv[4]); + + if (!strcmp(cmdname, "generate_raw")) { + call_ioctl = FALSE; + } + if (!call_ioctl && argc != 6) { + printf("Error: invalid no of arguments\n"); + printf("Syntax: ./mlanutl mlanX hostcmd %s \n", + cmdname); + ret = MLAN_STATUS_FAILURE; + goto done; + } + + fp = fopen(argv[3], "r"); + if (fp == NULL) { + fprintf(stderr, "Cannot open file %s\n", argv[3]); + ret = MLAN_STATUS_FAILURE; + goto done; + } + + /* Initialize buffer */ + buffer = (t_u8 *)malloc(BUFFER_LENGTH); + if (!buffer) { + printf("ERR:Cannot allocate buffer for command!\n"); + fclose(fp); + ret = MLAN_STATUS_FAILURE; + goto done; + } + 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"); + fclose(fp); + ret = MLAN_STATUS_FAILURE; + goto done; + } + memset(line, 0, MAX_CONFIG_LINE); + + while (config_get_line(line, MAX_CONFIG_LINE, fp, &li, &pos)) { + line = trim_spaces(line); + if (line[strlen(line) - 1] == '{') { + if (ob == 0) { + new_node = (struct cmd_node *)malloc( + sizeof(struct cmd_node)); + if (!new_node) { + printf("ERR:Cannot allocate memory for cmd_node\n"); + fclose(fp); + ret = MLAN_STATUS_FAILURE; + goto done; + } + memset(new_node, 0, + sizeof(struct cmd_node)); + new_node->next = NULL; + if (blk_count == 0) { + header = new_node; + command = new_node; + } else { + command->next = new_node; + command = new_node; + } + strncpy(command->cmd_string, line, + (strchr(line, '=') - line)); + memmove(command->cmd_string, + trim_spaces( + command->cmd_string), + strlen(trim_spaces( + command->cmd_string)) + + 1); + } + ob++; + continue; /* goto while() */ + } + if (line[strlen(line) - 1] == '}') { + ob--; + if (ob == 0) + blk_count++; + 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 */ + + fp_raw = fopen(argv[5], "w"); + if (fp_raw == NULL) { + fprintf(stderr, + "Cannot open the destination raw_data file %s\n", + argv[5]); + fclose(fp); + ret = MLAN_STATUS_FAILURE; + goto done; + } + + /* prepare .dtsi output */ + snprintf(cmdname, sizeof(cmdname), "%s.dtsi", argv[5]); + fp_dtsi = fopen(cmdname, "w"); + if (fp_dtsi == NULL) { + fprintf(stderr, "Cannot open the destination file %s\n", + cmdname); + fclose(fp); + fclose(fp_raw); + ret = MLAN_STATUS_FAILURE; + goto done; + } + + for (k = 0; k < (t_u32)blk_count && command != NULL; k++) { + if (MLAN_STATUS_FAILURE == + prepare_host_cmd_buffer(fp, command->cmd_string, + buffer)) + memset(buffer, 0, BUFFER_LENGTH); + + memcpy(&buf_len, buffer, sizeof(t_u32)); + if (buf_len) { + 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"); + fprintf(fp_raw, "%s={\n", command->cmd_string); + fprintf(fp_dtsi, + "/ {\n\tmarvell_cfgdata {\n\t\tmarvell,%s = /bits/ 8 <\n", + command->cmd_string); + i = j = 0; + while (i < buf_len) { + for (j = 0; j < 16; j++) { + fprintf(fp_raw, "%02x ", + *(raw_buf + i)); + if (i >= 8) { + fprintf(fp_dtsi, + "0x%02x", + *(raw_buf + i)); + if ((j < 16 - 1) && + (i < buf_len - 1)) + fprintf(fp_dtsi, + " "); + } + if (++i >= buf_len) + break; + } + fputc('\n', fp_raw); + fputc('\n', fp_dtsi); + } + fprintf(fp_raw, "}"); + fprintf(fp_dtsi, "\t\t>;\n\t};\n};\n"); + } + command = command->next; + rewind(fp); + } + + fclose(fp_dtsi); + 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; + header = header->next; + free(command); + } + if (line) + free(line); + if (buffer) + free(buffer); + if (cmd) + free(cmd); + return ret; +} + +#ifdef DEBUG_LEVEL1 +/** + * @brief Process driver debug configuration + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_drvdbg(int argc, char *argv[]) +{ + t_u8 *buffer = NULL; + struct eth_priv_cmd *cmd = NULL; + struct ifreq ifr; + t_u32 drvdbg; + + /* 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: drvdbg config fail\n"); + if (cmd) + free(cmd); + if (buffer) + free(buffer); + return MLAN_STATUS_FAILURE; + } + + /* Process result */ + if (argc == 3) { + memcpy(&drvdbg, buffer, sizeof(drvdbg)); + printf("drvdbg: 0x%08x\n", drvdbg); +#ifdef DEBUG_LEVEL2 + printf("MINFO (%08x) %s\n", MINFO, + (drvdbg & MINFO) ? "X" : ""); + printf("MWARN (%08x) %s\n", MWARN, + (drvdbg & MWARN) ? "X" : ""); + printf("MENTRY (%08x) %s\n", MENTRY, + (drvdbg & MENTRY) ? "X" : ""); +#endif + printf("MMPA_D (%08x) %s\n", MMPA_D, + (drvdbg & MMPA_D) ? "X" : ""); + printf("MIF_D (%08x) %s\n", MIF_D, + (drvdbg & MIF_D) ? "X" : ""); + printf("MFW_D (%08x) %s\n", MFW_D, + (drvdbg & MFW_D) ? "X" : ""); + printf("MEVT_D (%08x) %s\n", MEVT_D, + (drvdbg & MEVT_D) ? "X" : ""); + printf("MCMD_D (%08x) %s\n", MCMD_D, + (drvdbg & MCMD_D) ? "X" : ""); + printf("MDAT_D (%08x) %s\n", MDAT_D, + (drvdbg & MDAT_D) ? "X" : ""); + printf("MREG (%08x) %s\n", MREG, (drvdbg & MREG) ? "X" : ""); + printf("MREG_D (%08x) %s\n", MREG_D, + (drvdbg & MREG_D) ? "X" : ""); + printf("MLSTATS(%08x) %s\n", MLSTATS, + (drvdbg & MLSTATS) ? "X" : ""); + printf("MIOCTL (%08x) %s\n", MIOCTL, + (drvdbg & MIOCTL) ? "X" : ""); + printf("MINTR (%08x) %s\n", MINTR, + (drvdbg & MINTR) ? "X" : ""); + printf("MEVENT (%08x) %s\n", MEVENT, + (drvdbg & MEVENT) ? "X" : ""); + printf("MCMND (%08x) %s\n", MCMND, + (drvdbg & MCMND) ? "X" : ""); + printf("MDATA (%08x) %s\n", MDATA, + (drvdbg & MDATA) ? "X" : ""); + printf("MERROR (%08x) %s\n", MERROR, + (drvdbg & MERROR) ? "X" : ""); + printf("MFATAL (%08x) %s\n", MFATAL, + (drvdbg & MFATAL) ? "X" : ""); + printf("MMSG (%08x) %s\n", MMSG, (drvdbg & MMSG) ? "X" : ""); + } + + if (buffer) + free(buffer); + if (cmd) + free(cmd); + + return MLAN_STATUS_SUCCESS; +} +#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 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 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 (argc == 4 && !(strcmp(argv[3], "ext"))) { + printf("rxStuckIssueCount-1 %u\n" + "rxStuckIssueCount-2 %u\n" + "rxStuckRecoveryCountPolling %u\n" + "rxStuckRecoveryCountInterrupt %u\n" + "rxStuckTsf-1 %llu\n" + "rxStuckTsf-2 %llu\n" + "txWatchdogRecoveryCount %u\n" + "txWatchdogTsf-1 %llu\n" + "txWatchdogTsf-2 %llu\n" + "channelSwitchAnnouncementSent %u\n" + "channelSwitchState %u\n" + "registerClass %u\n" + "channelNumber %u\n" + "channelSwitchMode %u\n" + "RxResetRecoveryCount %u\n" + "RxIsr2NotDoneCnt %u\n" + "gdmaAbortCnt %u\n" + "gResetRxMacCnt %u\n" + "SdmaStuckCnt %u\n" + "gOwnrshpCtlErrCnt %u\n" + "gOwnrshpBcnErrCnt %u\n" + "gOwnrshpMgtErrCnt %u\n" + "gOwnrshpDatErrCnt %u\n" + "bigtk_mmeGoodCnt %u\n" + "bigtk_replayErrCnt %u\n" + "bigtk_micErrCnt %u\n" + "bigtk_mmeNotFoundCnt %u\n" + "current_temperature %u\n" + "TxPwrMethod %s\n" + "isDPDdone %s\n", + stats->rx_stuck_issue_cnt[0], + stats->rx_stuck_issue_cnt[1], + stats->rx_stuck_poll_recovery_cnt, + stats->rx_stuck_intr_recovery_cnt, + stats->rx_stuck_tsf[0], stats->rx_stuck_tsf[1], + stats->tx_watchdog_recovery_cnt, + stats->tx_watchdog_tsf[0], stats->tx_watchdog_tsf[1], + stats->channel_switch_ann_sent, + stats->channel_switch_state, stats->reg_class, + stats->channel_number, stats->channel_switch_mode, + stats->rx_reset_mac_recovery_cnt, + stats->rx_Isr2_NotDone_Cnt, stats->gdma_abort_cnt, + stats->g_reset_rx_mac_cnt, stats->SdmaStuckCnt, + stats->dwCtlErrCnt, stats->dwBcnErrCnt, + stats->dwMgtErrCnt, stats->dwDatErrCnt, + stats->bigtk_mmeGoodCnt, stats->bigtk_replayErrCnt, + stats->bigtk_micErrCnt, stats->bigtk_mmeNotFoundCnt, + stats->currTemp, (stats->TXpwrMethod ? "OLPC" : "CLPC"), + ((stats->isDPDdone == 0xFF) ? + "INVALID" : + (stats->isDPDdone ? "YES" : "NO"))); + } + + 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 (stats->cca_cnt_us != 0) { + printf("cca_cnt_us %llu\n" + "rxAirtime_us %llu\n" + "txAirtime_us %llu\n", + stats->cca_cnt_us, stats->rxAirtime_us, + stats->txAirtime_us); + } + + if (buffer) + free(buffer); + if (cmd) + free(cmd); + + return MLAN_STATUS_SUCCESS; +} + +#ifdef STA_SUPPORT +/** + * @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(int argc, char *argv[]) +{ +#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; + struct ifreq ifr; + + 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 > 5) { + printf("Error: invalid no of arguments\n"); + printf("mlanutl mlanX getsignal [m] [n]\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 = + (int)MIN((int)cmd->used_len, (int)(DATA_SIZE * sizeof(int))); + if (copy_size > 0) + memcpy(&data, buffer, copy_size); + printf("Get signal output is\t"); + for (i = 0; i < (int)(copy_size / sizeof(int)); i++) + 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; + if (copy_size > 0) + 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); + if (cmd) + free(cmd); + + return ret; +} +#endif /* #ifdef STA_SUPPORT */ + +/** + * @brief Get fw support band from driver + * + * @param fw_band a pointer to return FW band + * + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ + +int get_bandcfg(t_u32 *fw_band) +{ + t_u8 *buffer = NULL; + 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; + } + + prepare_buffer(buffer, PRIV_CMD_BANDCFG, 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(""); + fprintf(stderr, "get bandcfg failed\n"); + if (cmd) + free(cmd); + if (buffer) + free(buffer); + return MLAN_STATUS_FAILURE; + } + + bandcfg = (struct eth_priv_bandcfg *)buffer; + *fw_band = bandcfg->fw_bands; + + if (cmd) + free(cmd); + if (buffer) + free(buffer); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Check if 6GHz sub band supported + * + * @return if supported return 1; otherwise 0 + */ +static t_u8 is_6g_sub_band_allowed(void) +{ + int ret = 0; + return ret; +} + +/** + * @brief Get txpwrlimit + * + * @param argc Number of arguments + * @param argv Pointer to the arguments array + * + * @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) +{ + struct ifreq ifr; + mlan_ds_misc_chan_trpc_cfg *trcp_cfg = NULL; + MrvlIETypes_ChanTRPCConfig_t *trpc_tlv = NULL; + MrvlIEtypes_Data_t *pTlvHdr; + int left_len; + int mod_num = 0; + int i = 0; + int j = 0; + t_u8 *pByte = NULL; + + 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->sub_band = sub_band; + 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_txpwrlimit fail\n"); + return MLAN_STATUS_FAILURE; + } + /* Process result */ + printf("------------------------------------------------------------------------------------\n"); + printf("Get txpwrlimit: sub_band=0x%x len=%d\n", trcp_cfg->sub_band, + trcp_cfg->length); + pByte = trcp_cfg->trpc_buf + S_DS_GEN + 4; + left_len = trcp_cfg->length - S_DS_GEN - 4; + while (left_len >= (int)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_CHAN_TRPC_CONFIG: + trpc_tlv = (MrvlIETypes_ChanTRPCConfig_t *)pTlvHdr; + printf("StartFreq: %d\n", + le16_to_cpu(trpc_tlv->start_freq)); + printf("ChanNum: %d\n", trpc_tlv->chan_num); + mod_num = (pTlvHdr->header.len - 4) / + sizeof(mod_group_setting); + printf("Pwr:"); + for (i = 0; i < mod_num; i++) { + if (i == (mod_num - 1)) + printf("%d,%d", + trpc_tlv->mod_group[i].mod_group, + trpc_tlv->mod_group[i].power); + else + printf("%d,%d,", + trpc_tlv->mod_group[i].mod_group, + trpc_tlv->mod_group[i].power); + } + printf("\n \n"); + break; + default: + break; + } + left_len -= (pTlvHdr->header.len + sizeof(pTlvHdr->header)); + pByte += pTlvHdr->header.len + sizeof(pTlvHdr->header); + } + if (fp_raw) { + switch (sub_band) { + case 0: + fprintf(fp_raw, "txpwrlimit_2g_get={\n"); + break; + case 0x10: + fprintf(fp_raw, "txpwrlimit_5g_sub0_get={\n"); + break; + case 0x11: + fprintf(fp_raw, "txpwrlimit_5g_sub1_get={\n"); + break; + case 0x12: + fprintf(fp_raw, "txpwrlimit_5g_sub2_get={\n"); + break; + case 0x13: + fprintf(fp_raw, "txpwrlimit_5g_sub3_get={\n"); + break; + case 0x20: + fprintf(fp_raw, "txpwrlimit_6g_sub0_get={\n"); + break; + case 0x21: + fprintf(fp_raw, "txpwrlimit_6g_sub1_get={\n"); + break; + case 0x22: + fprintf(fp_raw, "txpwrlimit_6g_sub2_get={\n"); + break; + case 0x23: + fprintf(fp_raw, "txpwrlimit_6g_sub3_get={\n"); + break; + case 0x24: + fprintf(fp_raw, "txpwrlimit_6g_sub4_get={\n"); + break; + case 0x25: + fprintf(fp_raw, "txpwrlimit_6g_sub5_get={\n"); + break; + case 0x26: + fprintf(fp_raw, "txpwrlimit_6g_sub6_get={\n"); + break; + case 0x27: + fprintf(fp_raw, "txpwrlimit_6g_sub7_get={\n"); + break; + default: + break; + } + i = j = 0; + while (i < trcp_cfg->length) { + for (j = 0; j < 16; j++) { + fprintf(fp_raw, "%02x ", trcp_cfg->trpc_buf[i]); + if (++i >= trcp_cfg->length) + break; + } + fputc('\n', fp_raw); + } + fprintf(fp_raw, "}\n\n"); + } + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Get txpwrlimit + * + * @param argc Number of arguments + * @param argv Pointer to the arguments array + * + * @return MLAN_STATUS_SUCCESS/MLAN_STATUS_FAILURE + */ +static int process_get_txpwrlimit(int argc, char *argv[]) +{ + t_u8 *buffer = NULL; + struct eth_priv_cmd *cmd = NULL; + int ret = MLAN_STATUS_SUCCESS; + t_u16 sub_band = 0; + FILE *fp_raw = NULL; + + /* Initialize buffer */ + buffer = (t_u8 *)malloc(sizeof(mlan_ds_misc_chan_trpc_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_chan_trpc_cfg) + strlen(argv[2])); + /* Sanity tests */ + if (argc < 4) { + printf("Error: invalid no of arguments\n"); + printf("mlanutl mlanX/uapX get_txpwrlimit [0/0x10/0x11/0x12/0x13/0x1f/0x20/0x21/0x22/0x23/0x24/0x25/0x26/0x27/0x2f/0xff]\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; + } + sub_band = a2hex_or_atoi(argv[3]); + if (argc == 5) { + fp_raw = fopen(argv[4], "w"); + if (fp_raw == NULL) { + fprintf(stderr, + "Cannot open the destination raw_data file %s\n", + argv[4]); + ret = MLAN_STATUS_FAILURE; + goto done; + } + } + switch (sub_band) { + case 0: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x20: + case 0x21: + case 0x22: + case 0x23: + case 0x24: + case 0x25: + case 0x26: + case 0x27: + ret = get_txpwrlimit(fp_raw, argv, sub_band, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + 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); + ret = get_txpwrlimit(fp_raw, argv, 0x11, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + ret = get_txpwrlimit(fp_raw, argv, 0x12, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + ret = get_txpwrlimit(fp_raw, argv, 0x13, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + break; + case 0x2f: + ret = get_txpwrlimit(fp_raw, argv, 0x20, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + ret = get_txpwrlimit(fp_raw, argv, 0x21, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + ret = get_txpwrlimit(fp_raw, argv, 0x22, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + ret = get_txpwrlimit(fp_raw, argv, 0x23, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + ret = get_txpwrlimit(fp_raw, argv, 0x24, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + ret = get_txpwrlimit(fp_raw, argv, 0x25, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + ret = get_txpwrlimit(fp_raw, argv, 0x26, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + ret = get_txpwrlimit(fp_raw, argv, 0x27, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + 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); + ret = get_txpwrlimit(fp_raw, argv, 0x10, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + ret = get_txpwrlimit(fp_raw, argv, 0x11, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + ret = get_txpwrlimit(fp_raw, argv, 0x12, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + ret = get_txpwrlimit(fp_raw, argv, 0x13, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + if (is_6g_sub_band_allowed()) { + ret = get_txpwrlimit( + fp_raw, argv, 0x20, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + ret = get_txpwrlimit( + fp_raw, argv, 0x21, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + ret = get_txpwrlimit( + fp_raw, argv, 0x22, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + ret = get_txpwrlimit( + fp_raw, argv, 0x23, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + ret = get_txpwrlimit( + fp_raw, argv, 0x24, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + ret = get_txpwrlimit( + fp_raw, argv, 0x25, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + ret = get_txpwrlimit( + fp_raw, argv, 0x26, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + ret = get_txpwrlimit( + fp_raw, argv, 0x27, buffer, + sizeof(mlan_ds_misc_chan_trpc_cfg) + + strlen(argv[2]), + cmd); + } + break; + default: + printf("Error: invalid arguments\n"); + printf("mlanutl mlanX/uapX get_txpwrlimit [0/0x10/0x11/0x12/0x13/0x1f/0xff]\n"); + printf("mlanutl mlanX/uapX get_txpwrlimit [0x20/0x21/0x22/0x23/0x24/0x25/0x26/0x27/0xff]\n"); + break; + } +done: + if (fp_raw) + fclose(fp_raw); + 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 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 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; +} + +#define MASK_11AX_HE_RTS_THRESHOLD 0x3FF +#define MASK_11AX_OM_CONTROL 0xFFF + +/** + * @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"); + id_len += + 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; + +#define MAX_CFG_ID_SIZE 2 + if (strcmp(argv[3], "obss_pd_offset") == 0) { + snprintf(argv[3], MAX_CFG_ID_SIZE, "%d", + MLAN_11AXCMD_CFG_ID_SR_OBSS_PD_OFFSET); + } else if (strcmp(argv[3], "enable_sr") == 0) { + snprintf(argv[3], MAX_CFG_ID_SIZE, "%d", + MLAN_11AXCMD_CFG_ID_SR_ENABLE); + } else if (strcmp(argv[3], "beam_change") == 0) { + snprintf(argv[3], MAX_CFG_ID_SIZE, "%d", + MLAN_11AXCMD_CFG_ID_BEAM_CHANGE); + } else if (strcmp(argv[3], "enable_htc") == 0) { + snprintf(argv[3], MAX_CFG_ID_SIZE, "%d", + MLAN_11AXCMD_CFG_ID_HTC_ENABLE); + } else if (strcmp(argv[3], "txop_rts") == 0) { + snprintf(argv[3], MAX_CFG_ID_SIZE, "%d", + MLAN_11AXCMD_CFG_ID_TXOP_RTS); + } else if (strcmp(argv[3], "set_bsrp") == 0) { + snprintf(argv[3], MAX_CFG_ID_SIZE, "%d", + MLAN_11AXCMD_CFG_ID_SET_BSRP); + } else if (strcmp(argv[3], "tx_omi") == 0) { + snprintf(argv[3], MAX_CFG_ID_SIZE, "%d", + MLAN_11AXCMD_CFG_ID_TX_OMI); + } else if (strcmp(argv[3], "obssnbru_toltime") == 0) { + snprintf(argv[3], MAX_CFG_ID_SIZE, "%d", + MLAN_11AXCMD_CFG_ID_OBSSNBRU_TOLTIME); + } else if (strcmp(argv[3], "llde") == 0) { + snprintf(argv[3], MAX_CFG_ID_SIZE, "%d", + MLAN_11AXCMD_CFG_ID_LLDE); + } else { + printf("ERR:unknown command %s!\n", argv[3]); + 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 = 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_SET) { + if (atoi(argv[3]) == MLAN_11AXCMD_CFG_ID_OBSSNBRU_TOLTIME) { + if (argv[4] == 0) { + printf("Invalid OBSSNBRU tolerance time: Valid range[1..3600]\n"); + free(buffer); + return MLAN_STATUS_FAILURE; + } + } else if ((atoi(argv[3]) == MLAN_11AXCMD_CFG_ID_TX_OMI) && + (argv[5] != 0)) { + if ((strcmp(argv[5], "1") == 0) || + (strcmp(argv[5], "0xFF") == 0)) { + printf("Please make transmission of data packet (ping, fast ping or iperf)\n"); + } + } + } + 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; + case MLAN_11AXCMD_TXOPRTS_SUBID: + printf("txop RTS Threshold: 0x%x\n", + axcmd->param.txop_cfg.rts_thres & + MASK_11AX_HE_RTS_THRESHOLD); + break; + case MLAN_11AXCMD_TXOMI_SUBID: + printf("tx OMI: 0x%x\n", axcmd->param.txomi_cfg.omi & + MASK_11AX_OM_CONTROL); + if (axcmd->param.txomi_cfg.tx_option == 0x0) { + printf("tx Option: %d, number of tx data packets = %d\n", + axcmd->param.txomi_cfg.tx_option, + axcmd->param.txomi_cfg.num_data_pkts); + } else { + printf("tx Option: %d or 0xFF, number of tx data packets = %d\n", + axcmd->param.txomi_cfg.tx_option, + axcmd->param.txomi_cfg.num_data_pkts); + } + break; + case MLAN_11AXCMD_OBSS_TOLTIME_SUBID: + if (axcmd->param.toltime_cfg.tol_time > 3600 || + !axcmd->param.toltime_cfg.tol_time) + printf("OBSS Narrow Bandwidth RU tolerance Time: disabled\n"); + else + printf("OBSS Narrow Bandwidth RU Tolerance Time: %d sec\n", + axcmd->param.toltime_cfg.tol_time); + break; + case MLAN_11AXCMD_SET_BSRP_SUBID: + printf("set BSRP %s(%d)\n", + axcmd->param.setbsrp_cfg.value == 1 ? "enabled" : + "disabled", + axcmd->param.setbsrp_cfg.value); + break; + case MLAN_11AXCMD_LLDE_SUBID: + printf("LLDE %s\n", + (axcmd->param.llde_cfg.llde ? "enabled" : + "disabled")); + printf("mu_rts_successcnt %d\n", + axcmd->param.llde_cfg.mu_rts_successcnt); + printf("mu_rts_failcnt %d\n", + axcmd->param.llde_cfg.mu_rts_failcnt); + printf("basic_trigger_successcnt %d\n", + axcmd->param.llde_cfg.basic_trigger_successcnt); + printf("basic_trigger_failcnt %d\n", + axcmd->param.llde_cfg.basic_trigger_failcnt); + printf("tbppdu_nullcnt %d\n", + axcmd->param.llde_cfg.tbppdu_nullcnt); + printf("tbppdu_datacnt %d\n", + axcmd->param.llde_cfg.tbppdu_datacnt); + 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 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 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; + ed_mac_ctrl ed_ctrl; + + 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; + } + case HostCmd_ROBUST_COEX: { + host_RobustCoexLteStats_t *RobustCoexLteStat = + (host_RobustCoexLteStats_t *)(buf + S_DS_GEN); + if (RobustCoexLteStat->ResponseType == + EXT_LTE_RESP_GETSTAT) { + printf("==============LTE COEX STATS================\n"); + printf("Responsetype: %d \n", + RobustCoexLteStat->ResponseType); + printf("Count_LTE_TX_NOTIFY: %d \n", + (unsigned int)le32_to_cpu( + RobustCoexLteStat + ->Count_LTE_TX_NOTIFY)); + printf("Count_LTE_RX_PROTECT: %d \n", + (unsigned int)le32_to_cpu( + RobustCoexLteStat + ->Count_LTE_RX_PROTECT)); + printf("Count_LTE_TX_SUSPEND: %d \n", + (unsigned int)le32_to_cpu( + RobustCoexLteStat + ->Count_LTE_TX_SUSPEND)); + printf("Count_LTE_RX_NOTIFY: %d \n", + (unsigned int)le32_to_cpu( + RobustCoexLteStat + ->Count_LTE_RX_NOTIFY)); + } else if (RobustCoexLteStat->ResponseType == + EXT_LTE_RESP_RSTSTAT) { + printf("LTE STAT Counters cleared \n"); + } else // else print default cmdresp + { + 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; + case HostCmd_CMD_ED_CTRL: + /* + * Read/Write EDMAC control parameters. + */ + 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, ' '); + + memcpy(&ed_ctrl, buf + S_DS_GEN, + sizeof(struct _ed_mac_ctrl)); + printf("edmac_2G:0x%02x\noffset_2G:0x%02x\n" + "edmac_5G:0x%02x\noffset_5G:0x%02x\n" + "\n", + ed_ctrl.ed_ctrl_2g, ed_ctrl.ed_offset_2g, + ed_ctrl.ed_ctrl_5g, ed_ctrl.ed_offset_5g); + 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 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; +} + +#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 */ +#define TYPE_EQ_MAGIC (MAX_OPERAND + 6) /**< magic pkt: =m 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((unsigned char)*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 if (!strcmp(opstr, "=m")) { + op.type = TYPE_EQ_MAGIC; + parse_hex(opstr, op.val); + if (!push(stack, &op)) { + printf("push magic byte sequence 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 FILTER_MAGIC TYPE_EQ_MAGIC /**< byte sequence for magic packet */ + +#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) && + (type != FILTER_MAGIC)) { + 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; + case FILTER_MAGIC: + if (!byte_find || !offset_find || !repeat_find) { + printf("Missing field for FILTER_MAGIC: 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 =m ", 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); + 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; +} + +#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) { + printf("ERR:Cannot allocate buffer for command!\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, 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; + } + if (mefcmd->NumEntries > MAX_MEF_NUM_ENTRIES) { + fprintf(stderr, + "mlanutl: MEF Entries, %d, exceeds maximum value %d\n", + mefcmd->NumEntries, + MAX_MEF_NUM_ENTRIES); + 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 Check the Hex String + * @param s A pointer to the string + * @return MLAN_STATUS_SUCCESS --HexString, MLAN_STATUS_FAILURE --not + * HexString + */ +static int ishexstring(char *s) +{ + int ret = MLAN_STATUS_FAILURE; + t_s32 tmp; + + if (!strncasecmp("0x", s, 2)) { + s += 2; + } + while (*s) { + tmp = toupper((unsigned char)*s); + if (((tmp >= 'A') && (tmp <= 'F')) || + ((tmp >= '0') && (tmp <= '9'))) { + ret = MLAN_STATUS_SUCCESS; + } else { + ret = MLAN_STATUS_FAILURE; + break; + } + s++; + } + + 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 broadcast mac + * MAC_MULTICAST - if multicast mac + */ +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 + */ +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; +} + +/** + * @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 Signal handler + * + * @param sig Received signal number + * + * @return N/A + */ +static void sig_handler(int sig) +{ + printf("Stopping application.\n"); + terminate_flag = 1; +} + +/** + * @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 + **/ +static int string2raw(char *str, unsigned char *raw) +{ + int len = (strlen(str) + 1) / 2; + + do { + if (!isxdigit((unsigned char)*str)) { + return -1; + } + *str = toupper((unsigned char)*str); + *raw = CHAR2INT(*str) << 4; + ++str; + *str = toupper((unsigned char)*str); + if (*str == '\0') + break; + *raw |= CHAR2INT(*str); + ++raw; + } while (*++str != '\0'); + return len; +} + +/** + * @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((unsigned char)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 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] = {0}; + + /* Try to open old driver proc: /proc/mwlan/configX first */ + if (i == 0) + strncpy(filename, "/proc/mwlan/config", sizeof(filename) - 1); + else if (i > 0) + snprintf(filename, sizeof(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 + */ +static 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 > (int)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 + */ +static 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 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 + */ +static int wait_event(t_u32 eventID, t_u8 *pEvent, int *pEventLen) +{ + 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 = NULL; + 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; + + if (!pEvent || !pEventLen) { + printf("ERR:Input paramater(s) 'pEvent' or 'pEventLen' is NULL"); + goto done; + } + evt_recv_buf = malloc(sizeof(evt_buf) * MAX_NO_OF_DEVICES); + if (!evt_recv_buf) { + printf("ERR:Fail to allocate evt_recv_buf\n"); + goto done; + } + memset(evt_recv_buf, 0, sizeof(evt_buf) * MAX_NO_OF_DEVICES); + + 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; + } + } + + 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); + if (evt_recv_buf) + free(evt_recv_buf); + 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 Process band configuration + * @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[]) +{ + 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; + } + + 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: bandcfg fail\n"); + if (cmd) + free(cmd); + if (buffer) + free(buffer); + return MLAN_STATUS_FAILURE; + } + + /* 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 (buffer) + free(buffer); + if (cmd) + free(cmd); + + 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 + */ +static 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 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 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; +} + +/** + * @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_USABLE) { + 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 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; + int length = 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); + if (argc >= 4) { + length = strlen(CMD_NXP) + strlen(argv[2]); + strncpy((char *)(buffer + length), argv[3], + BUFFER_LENGTH - 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; + + /* 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; + int length = 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); + if (argc >= 4) { + length = strlen(CMD_NXP) + strlen(argv[2]); + strncpy((char *)(buffer + length), argv[3], + BUFFER_LENGTH - 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; + + /* 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, req_len; + t_u8 *ie_buf = NULL; + + /* Initialize buffer */ + req_len = sizeof(struct eth_priv_getstalist) + + (MAX_STA_LIST_IE_SIZE * MAX_AP_CLIENTS); + req_len += strlen(CMD_NXP) + strlen(argv[2]); + + if (req_len < BUFFER_LENGTH) + req_len = BUFFER_LENGTH; + + buffer = (t_u8 *)malloc(req_len); + 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); + ie_buf = (t_u8 *)&list->client_info[0]; + ie_buf += sizeof(struct ap_client_info) * 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"); + printf("Mode: %s\n", + (list->client_info[i].bandmode == BAND_B) ? + "11b," : + (list->client_info[i].bandmode == BAND_G) ? + "11g," : + (list->client_info[i].bandmode == BAND_A) ? + "11a," : + (list->client_info[i].bandmode == BAND_GN) ? + "2.4G_11n," : + (list->client_info[i].bandmode == BAND_AN) ? + "5G_11n," : + (list->client_info[i].bandmode == BAND_GAC) ? + "2.4G_11ac," : + (list->client_info[i].bandmode == BAND_AAC) ? + "5G_11ac," : + (list->client_info[i].bandmode == BAND_GAX) ? + "2.4G_11ax," : + (list->client_info[i].bandmode == BAND_AAX) ? + "5G_11ax," : + "unknown"); + /** 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 (list->client_info[i].ie_len) { + hexdump("IE", (void *)ie_buf, + list->client_info[i].ie_len, ' '); + ie_buf += list->client_info[i].ie_len; + } + } + + if (buffer) + free(buffer); + if (cmd) + free(cmd); + + return MLAN_STATUS_SUCCESS; +} + +#endif + +#if defined(UAP_SUPPORT) +static int process_setmode(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: setmode fail\n"); + if (cmd) + free(cmd); + if (buffer) + free(buffer); + return MLAN_STATUS_FAILURE; + } + /* Process result */ + if (argc == 3) { + /* GET operation */ + printf("setmode: %d\n", buffer[0]); + } + 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 + */ +static 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 + */ +static 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 + */ + +static 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"); + + if (stats->num_in_chan_stats > WLAN_IOCTL_USER_SCAN_CHAN_MAX) { + perror("mlanutl"); + fprintf(stderr, + "mlanutl: getchstats fail. Number of channels, %d, exceeds limit of %d\n", + stats->num_in_chan_stats, + WLAN_IOCTL_USER_SCAN_CHAN_MAX); + if (cmd) + free(cmd); + if (buffer) + free(buffer); + return MLAN_STATUS_FAILURE; + } + + for (i = 0; i < (int)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; + + t_u8 offset, pairwise_cnt, auth_key_mgmt_cnt; + t_u8 *pData; + 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}; + t_u8 *pext_id; + + IEEEtypes_RSNIE_t *prsn_ie; + const t_u8 auth_sae_oui[4] = {0x00, 0x0f, 0xac, 0x08}; + const t_u8 auth_sha256_oui[4] = {0x00, 0x0f, 0xac, 0x0B}; // 802.1x + // using + // SUITE-B, + // SHA-256 + const t_u8 auth_sha384_oui[4] = {0x00, 0x0f, 0xac, 0x0C}; // 802.1x + // using + // SUITE-B, + // SHA-384 + const t_u8 auth_ft_sha384_oui[4] = {0x00, 0x0f, 0xac, 0x0D}; // FT over + // 802.1x, + // SHA-384 + + 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"); + if (buffer) + free(buffer); + if (cmd) + free(cmd); + 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] = ' '; + bss_info->he_cap[0] = ' '; + bss_info->he_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'; + + /* Check if RSN IE has SAE/OWE OUI */ + prsn_ie = (IEEEtypes_RSNIE_t *) + pelement_id; + pData = prsn_ie->data; + + /* Skip Group Cipher Suite TLV */ + offset = 4; + pData = pData + offset; + pairwise_cnt = *pData; + pData = pData + 2; + + /* Skip the Pairwise cipher suite TLVs + */ + offset = pairwise_cnt * 4; + pData = pData + offset; + + /* Get count for Auth Key Management + * TLVs */ + auth_key_mgmt_cnt = *pData; + pData = pData + 2; + + /* Parse through all the AKM Suites to + * get desired OUI */ + + while (auth_key_mgmt_cnt) { + if (!memcmp(pData, auth_sae_oui, + 4) || + !memcmp(pData, + auth_sha256_oui, + 4) || + !memcmp(pData, + auth_sha384_oui, + 4) || + !memcmp(pData, + auth_ft_sha384_oui, + 4)) + + { + bss_info->priv_cap = + '3'; + break; + } + pData += 4; + auth_key_mgmt_cnt--; + } + + 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; + case EXTENSION: + pext_id = (t_u8 *)pelement_id + + sizeof(IEEEtypes_Header_t); + if (*pext_id == HE_CAPABILITY) { + bss_info->he_cap[0] = 'A'; + bss_info->he_cap[1] = 'X'; + } + 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; + + if (bss_info->he_cap[0] == 'A' && bss_info->he_cap[1] == 'X') + 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->he_cap[0], /* AX */ + bss_info->he_cap[1]); + else + 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((unsigned char)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" + " AX [HE (11ax) ]\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((unsigned char)*( + 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((unsigned char)*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(( + unsigned char)*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 '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; + memcpy((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"; + if (scan_req->bssid_num >= MAX_BSSID_FILTER_LIST) { + perror("mlanutl"); + fprintf(stderr, + "mlanutl: getscantable fail. Number of bssid's, %d, exceeds limit of %d\n", + scan_req->bssid_num, MAX_BSSID_FILTER_LIST); + if (buffer) + free(buffer); + if (cmd) + free(cmd); + return MLAN_STATUS_FAILURE; + } + 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 AMPDU reordering flush time configuration + * @param argc Number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_flush_time(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: flush_time fail\n"); + if (cmd) + free(cmd); + if (buffer) + free(buffer); + return MLAN_STATUS_FAILURE; + } + + /* Process result */ + printf("flush time: %s\n", buffer); + + if (buffer) + free(buffer); + if (cmd) + free(cmd); + + return MLAN_STATUS_SUCCESS; +} + +/** + * @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; + int length = 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); + if (argc >= 4) { + length = strlen(CMD_NXP) + strlen(argv[2]); + strncpy((char *)(buffer + length), argv[3], + BUFFER_LENGTH - 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; + + /* 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, (int)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; + int length = 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); + if (argc >= 4) { + length = strlen(CMD_NXP) + strlen(argv[2]); + strncpy((char *)(buffer + length), argv[3], + BUFFER_LENGTH - 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; + + /* 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 Set/Get GPIO TSF LATCH configuration + * @param argc Number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_gpio_tsf_latch(int argc, char *argv[]) +{ + t_u8 *buffer = NULL; + struct eth_priv_cmd *cmd = NULL; + mlan_ds_gpio_tsf_latch *cfg = NULL; + struct ifreq ifr; + + if (argc < 3 || argc > 8) { + fprintf(stderr, "mlanutl: 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: clock sync fail\n"); + if (cmd) + free(cmd); + if (buffer) + free(buffer); + return MLAN_STATUS_FAILURE; + } + + /* Process result */ + if (argc == 3) { + cfg = (mlan_ds_gpio_tsf_latch *)buffer; + /* Show Clock sync configure */ + printf("Clock sync Configuration:\n"); + printf(" Clock Syc Mode: %d (%s)\n", + cfg->clock_sync_mode, + (cfg->clock_sync_mode == 0) ? + "GPIO Level" : + ((cfg->clock_sync_mode == 1) ? + "GPIO toggle" : + ((cfg->clock_sync_mode == 2) ? + "GPIO toggle on Next Beacon" : + "Invalid Mode set"))); + if (cfg->clock_sync_mode == 2) + printf(" Clock Syc Role: %d \n", + cfg->clock_sync_Role); + printf(" Clock Syc GPIO Pin Number: %d \n", + cfg->clock_sync_gpio_pin_number); + if (cfg->clock_sync_mode == 0) { + printf(" Clock Syc GPIO Level: %d (%s) \n", + cfg->clock_sync_gpio_level_toggle, + (cfg->clock_sync_gpio_level_toggle == 0) ? + "Low" : + ((cfg->clock_sync_gpio_level_toggle == + 1) ? + "High" : + "Invalid")); + } else if (cfg->clock_sync_mode == 1 || + cfg->clock_sync_mode == 2) { + printf(" Clock Syc GPIO Level: %d (%s) \n", + cfg->clock_sync_gpio_level_toggle, + (cfg->clock_sync_gpio_level_toggle == 0) ? + "Low to High" : + ((cfg->clock_sync_gpio_level_toggle == + 1) ? + "High to Low" : + "Invalid")); + printf(" Clock Syc GPIO Pulse Width: %d microsecond \n", + cfg->clock_sync_gpio_pulse_width); + } + } + + if (buffer) + free(buffer); + if (cmd) + free(cmd); + + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process Get TSF INFO + * @param argc Number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_get_tsf_info(int argc, char *argv[]) +{ + t_u8 *buffer = NULL; + struct eth_priv_cmd *cmd = NULL; + mlan_ds_tsf_info *tsf_info = NULL; + struct ifreq ifr; + + if (argc < 3 || argc > 4) { + fprintf(stderr, "mlanutl: 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: get tsf info fail\n"); + if (cmd) + free(cmd); + if (buffer) + free(buffer); + return MLAN_STATUS_FAILURE; + } + + /* Process result */ + tsf_info = (mlan_ds_tsf_info *)buffer; + printf("tsf format: %d\n", tsf_info->tsf_format); + printf("tsf info: %d\n", tsf_info->tsf_info); + printf("tsf: %llu\n", tsf_info->tsf); + printf("tsf offset: %d\n", tsf_info->tsf_offset); + + if (buffer) + free(buffer); + if (cmd) + free(cmd); + + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Set/Get target channel + * @param argc Number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_target_channel(int argc, char *argv[]) +{ + int ret = 0, channel = 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 uapX targetchan [#]\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 targetchan 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: targetchan fail\n"); + ret = MLAN_STATUS_FAILURE; + goto done; + } + + /* Process result */ + if (argc == 3) { + memcpy(&channel, buffer, sizeof(channel)); + printf("target channel=%d\n", channel); + } + +done: + if (buffer) + free(buffer); + if (cmd) + free(cmd); + + return ret; +} + +/** + * @brief Set/Get backup channel + * @param argc Number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_backup_channel(int argc, char *argv[]) +{ + int ret = 0, channel = 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 uapX backupchan [#]\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 backupchan 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: backupchan fail\n"); + ret = MLAN_STATUS_FAILURE; + goto done; + } + + /* Process result */ + if (argc == 3) { + memcpy(&channel, buffer, sizeof(channel)); + printf("backup channel=%d\n", channel); + } + +done: + if (buffer) + free(buffer); + if (cmd) + free(cmd); + + return ret; +} + +/** + * @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[]) +{ + int data[2]; + t_u8 *buffer = NULL; + struct eth_priv_cmd *cmd = NULL; + struct ifreq ifr; + + if (argc < 3 || argc > 5) { + fprintf(stderr, "mlanutl: 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: tcpackenh fail\n"); + if (cmd) + free(cmd); + if (buffer) + free(buffer); + return MLAN_STATUS_FAILURE; + } + + memset(data, 0, sizeof(data)); + /* Process result */ + memcpy(data, buffer, sizeof(data)); + if (argc == 3) { + /* GET operation */ + printf("TCP Ack enhancement Configuration:\n"); + printf(" Mode: %d\n", data[0]); + printf(" TCP_ACK_MAX_HOLD: %d\n", data[1]); + } + + 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; + int length = 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); + if (argc >= 4) { + length = strlen(CMD_NXP) + strlen(argv[2]); + strncpy((char *)(buffer + length), argv[3], + BUFFER_LENGTH - 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; + + /* 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 + +/** + * @brief Process hscfg configuration + * @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[]) +{ + t_u8 *buffer = NULL; + struct eth_priv_cmd *cmd = NULL; + struct ifreq ifr; + struct eth_priv_hs_cfg *hscfg; + + /* 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: 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); + printf(" wake_interval %d\n", (int)hscfg->hs_wake_interval); + } + + 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; + memcpy((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; + } + + if (numEntries > 0) + 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 6 GHz scancfg configuration + * @param argc Number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ + +/** + * @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)); + 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: 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"); + if (cmd) + free(cmd); + if (buffer) + free(buffer); + return MLAN_STATUS_FAILURE; + } + + /* 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 < (int)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; +} + +/** + * @brief Performs the ioctl operation to send the command to driver. + * @param cmd_buf Pointer to the command buffer + * @param buf_size Size of the allocated command buffer + * @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE + */ +static int tdls_ioctl(t_u8 *cmd_buf, t_u16 buf_size) +{ + struct ifreq ifr; + + /* 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_buf; + + /* Perform ioctl */ + if (ioctl(sockfd, TDLS_IOCTL, &ifr)) { + perror(""); + return MLAN_STATUS_FAILURE; + } + + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief host tdls config + * @param argc Number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_host_tdls_config(int argc, char *argv[]) +{ + host_tdls_cfg *param_buf = NULL; + char *line = NULL; + FILE *config_file = NULL; + int li = 0, ret = 0, i = 0, cmd_found = 0; + char *args[30], *pos = NULL; + t_u16 cmd_len = 0, tlv_len_supp_chan = 0; + t_u16 no_of_supp_chan_sub_band = 0, num_of_regulatory_class = 0, + tlv_len_reg_class; + t_u8 *buffer = NULL; + tlvbuf_SupportedChannels_t *supp_chan = NULL; + tlvbuf_RegulatoryClass_t *reg_class = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX host_tdls_config \n"); + printf("Syntax: ./mlanutl mlanX host_tdls_config <0/1> \n "); + exit(1); + } + + cmd_len = sizeof(host_tdls_cfg); + + buffer = (t_u8 *)malloc(BUFFER_LENGTH); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, BUFFER_LENGTH); + param_buf = (host_tdls_cfg *)buffer; + param_buf->action = ACTION_HOST_TDLS_CONFIG; + + /* Check if file exists */ + config_file = fopen(argv[3], "r"); + if (config_file == NULL) { + printf("ERR:Incorrect arguments.\n"); + printf("Syntax: ./mlanutl mlanX host_tdls_config \n"); + exit(1); + } + 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)) { + parse_line(line, args, 30); + if (!cmd_found && strncmp(args[0], argv[2], strlen(args[0]))) + continue; + + cmd_found = 1; + if (strcmp(args[0], "uapsd_support") == 0) { + param_buf->uapsd_support = (t_u8)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "cs_support") == 0) { + param_buf->cs_support = (t_u8)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "SupportedChannels") == 0) { + /* Append a new TLV */ + supp_chan = (tlvbuf_SupportedChannels_t *)(buffer + + cmd_len); + supp_chan->tag = TLV_TYPE_SUPPORTED_CHANNELS; + supp_chan->length = sizeof(tlvbuf_SupportedChannels_t) - + TLVHEADER_LEN; + tlv_len_supp_chan = sizeof(tlvbuf_SupportedChannels_t); + cmd_len += tlv_len_supp_chan; + } else if (strncmp(args[0], "FirstChannelNo", 14) == 0) { + if (supp_chan) + supp_chan->subband[no_of_supp_chan_sub_band] + .start_chan = atoi(args[1]); + } else if (strcmp(args[0], "NumberofSubBandChannels") == 0) { + if (supp_chan) { + supp_chan->subband[no_of_supp_chan_sub_band] + .num_chans = atoi(args[1]); + no_of_supp_chan_sub_band++; + tlv_len_supp_chan += + sizeof(IEEEtypes_SupportChan_Subband_t); + supp_chan->length += + sizeof(IEEEtypes_SupportChan_Subband_t); + cmd_len += + sizeof(IEEEtypes_SupportChan_Subband_t); + endian_convert_tlv_header_out(supp_chan); + } + } else if (strcmp(args[0], "SupportedRegulatoryClasses") == 0) { + /* Append a new TLV */ + reg_class = + (tlvbuf_RegulatoryClass_t *)(buffer + cmd_len); + tlv_len_reg_class = sizeof(tlvbuf_RegulatoryClass_t); + reg_class->tag = TLV_TYPE_REGULATORY_CLASSES; + cmd_len += tlv_len_reg_class; + } else if (strcmp(args[0], "CurrentRegulatoryClass") == 0) { + if (reg_class) { + reg_class->regulatory_class + .cur_regulatory_class = atoi(args[1]); + reg_class->length = 1; + } + } else if (strcmp(args[0], "NumofRegulatoryClasses") == 0) { + if (reg_class) { + num_of_regulatory_class = atoi(args[1]); + reg_class->length += num_of_regulatory_class; + cmd_len += num_of_regulatory_class; + endian_convert_tlv_header_out(reg_class); + } + } else if (strcmp(args[0], "ListOfRegulatoryClasses") == 0) { + if (reg_class) { + for (i = 0; i < num_of_regulatory_class; i++) + reg_class->regulatory_class + .regulatory_classes_list[i] = + (t_u8)A2HEXDECIMAL(args[i + 1]); + } + } + } + /* adjust for size of action and tlv_len, capInfo */ + param_buf->tlv_len = cmd_len - sizeof(host_tdls_cfg); + + hexdump("host_tdls_config", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS Info settings sucessfully set.\n"); + } else { + printf("ERR:Could not set TDLS info configuration.\n"); + } + +done: + if (config_file) + fclose(config_file); + if (buffer) + free(buffer); + if (line) + free(line); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief enable/disable tdls config + * @param argc Number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_config(int argc, char *argv[]) +{ + tdls_config *param_buf = NULL; + int ret = 0; + t_u16 cmd_len = 0; + t_u8 *buffer = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_config <0/1>\n"); + exit(1); + } + + cmd_len = sizeof(tdls_config); + + buffer = (t_u8 *)malloc(cmd_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, cmd_len); + param_buf = (tdls_config *)buffer; + param_buf->action = ACTION_TDLS_CONFIG; + + param_buf->data = (t_u16)A2HEXDECIMAL(argv[3]); + if ((param_buf->data != 0) && (param_buf->data != 1)) { + printf("ERR:Incorrect arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_config <0/1>\n"); + goto done; + } + hexdump("tdls_config ", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS %s successful.\n", + (param_buf->data) ? "enable" : "disable"); + } else { + printf("ERR:TDLS %s failed.\n", + (param_buf->data) ? "enable" : "disable"); + } + +done: + if (buffer) + free(buffer); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_setinfo + * @param argc Number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_setinfo(int argc, char *argv[]) +{ + tdls_setinfo *param_buf = NULL; + char *line = NULL; + FILE *config_file = NULL; + int li = 0, arg_num = 0, ret = 0, i = 0, cmd_found = 0, + pairwise_index = 0, akm_index = 0, pmkid_index = 0; + char *args[30], *pos = NULL; + t_u16 cmd_len = 0, tlv_len = 0, tlv_len_rsn = 0, tlv_len_supp_chan = 0, + tlv_len_domain = 0; + t_u16 no_of_sub_band = 0, no_of_supp_chan_sub_band = 0, + pairwise_offset = 0, akm_offset = 0, num_of_regulatory_class = 0, + tlv_len_reg_class; + t_u16 akm_count = 0, pmk_count = 0, rsn_cap = 0; + t_u8 *buffer = NULL; + t_u8 *ptr = NULL; + char country[COUNTRY_CODE_LEN]; + tlvbuf_DomainParamSet_t *domain = NULL; + tlvbuf_SupportedChannels_t *supp_chan = NULL; + tlvbuf_RegulatoryClass_t *reg_class = NULL; + tlvbuf_HTCap_t *tlv_ht_cap = NULL; + tlvbuf_RsnParamSet_t *rsn_ie = NULL; + tlvbuf_HTInfo_t *tlv_ht_info = NULL; + t_u8 pairwise_cipher_suite[PAIRWISE_CIPHER_SUITE_LEN]; + t_u8 akm_suite[AKM_SUITE_LEN]; + t_u8 pmkid[PMKID_LEN]; + tlvbuf_VHTCap_t *tlv_vht_cap = NULL; + tlvbuf_VHTOpra_t *tlv_vht_oper = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_setinfo \n"); + exit(1); + } + + cmd_len = sizeof(tdls_setinfo); + + buffer = (t_u8 *)malloc(BUFFER_LENGTH); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, BUFFER_LENGTH); + param_buf = (tdls_setinfo *)buffer; + param_buf->action = ACTION_TDLS_SETINFO; + + /* 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, 30); + if (!cmd_found && strncmp(args[0], argv[2], strlen(args[0]))) + continue; + + cmd_found = 1; + if (arg_num == 0) { + printf("ERR:No arguments passed with the command!\n"); + goto done; + } + if (strcmp(args[0], "CapInfo") == 0) { + param_buf->cap_info = (t_u16)A2HEXDECIMAL(args[1]); + param_buf->cap_info = cpu_to_le16(param_buf->cap_info); + } else if (strcmp(args[0], "Rate") == 0) { + tlvbuf_RatesParamSet_t *tlv = NULL; + /* Append a new TLV */ + tlv_len = sizeof(tlvbuf_RatesParamSet_t) + arg_num - 1; + tlv = (tlvbuf_RatesParamSet_t *)(buffer + cmd_len); + cmd_len += tlv_len; + /* Set TLV fields */ + tlv->tag = TLV_TYPE_RATES; + tlv->length = arg_num - 1; + for (i = 0; i < tlv->length; i++) { + tlv->rates[i] = (t_u8)A2HEXDECIMAL(args[i + 1]); + } + endian_convert_tlv_header_out(tlv); + } else if (strcmp(args[0], "QosInfo") == 0) { + tlvbuf_QosInfo_t *tlv = NULL; + /* Append a new TLV */ + tlv_len = sizeof(tlvbuf_QosInfo_t); + tlv = (tlvbuf_QosInfo_t *)(buffer + cmd_len); + cmd_len += tlv_len; + /* Set TLV fields */ + tlv->tag = TLV_TYPE_QOSINFO; + tlv->length = sizeof(tlvbuf_QosInfo_t) - TLVHEADER_LEN; + tlv->u.qos_info_byte = (t_u8)A2HEXDECIMAL(args[1]); + if ((tlv->u.qos_info_byte != 0) && + (tlv->u.qos_info_byte != 0x0F)) { + printf("Invalid QosInfo. Should be 0x00 or 0x0F.\n"); + goto done; + } + endian_convert_tlv_header_out(tlv); + } else if (strcmp(args[0], "ExtendCapabilities") == 0) { + tlvbuf_ExtCap_t *tlv = NULL; + /* Append a new TLV */ + tlv_len = sizeof(tlvbuf_ExtCap_t) + arg_num - 1; + tlv = (tlvbuf_ExtCap_t *)(buffer + cmd_len); + cmd_len += tlv_len; + /* Set TLV fields */ + tlv->tag = TLV_TYPE_EXTCAP; + tlv->length = arg_num - 1; + for (i = 0; i < tlv->length; i++) { + tlv->ext_cap[i] = + (t_u8)A2HEXDECIMAL(args[i + 1]); + } + endian_convert_tlv_header_out(tlv); + } else if (strcmp(args[0], "HTCapability") == 0) { + /* Append a new TLV */ + tlv_ht_cap = (tlvbuf_HTCap_t *)(buffer + cmd_len); + tlv_len = sizeof(tlvbuf_HTCap_t); + tlv_ht_cap->tag = TLV_TYPE_HT_CAP; + tlv_ht_cap->length = + sizeof(tlvbuf_HTCap_t) - TLVHEADER_LEN; + cmd_len += tlv_len; + endian_convert_tlv_header_out(tlv_ht_cap); + } else if (strcmp(args[0], "HTCapabilityInfo") == 0) { + if (tlv_ht_cap) { + tlv_ht_cap->ht_cap.ht_cap_info = + (t_u16)A2HEXDECIMAL(args[1]); + tlv_ht_cap->ht_cap.ht_cap_info = cpu_to_le16( + tlv_ht_cap->ht_cap.ht_cap_info); + } + } else if (strcmp(args[0], "AMPDUParam") == 0) { + if (tlv_ht_cap) + tlv_ht_cap->ht_cap.ampdu_param = + (t_u8)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "SupportedMCSSet") == 0) { + if (tlv_ht_cap) { + for (i = 0; i < MCS_SET_LEN; i++) + tlv_ht_cap->ht_cap.supported_mcs_set[i] = + (t_u8)A2HEXDECIMAL(args[i + 1]); + } + } else if (strcmp(args[0], "HTExtCapability") == 0) { + if (tlv_ht_cap) { + tlv_ht_cap->ht_cap.ht_ext_cap = + (t_u16)A2HEXDECIMAL(args[1]); + tlv_ht_cap->ht_cap.ht_ext_cap = cpu_to_le16( + tlv_ht_cap->ht_cap.ht_ext_cap); + } + } else if (strcmp(args[0], "TxBfCapability") == 0) { + if (tlv_ht_cap) { + tlv_ht_cap->ht_cap.tx_bf_cap = + (t_u32)A2HEXDECIMAL(args[1]); + tlv_ht_cap->ht_cap.tx_bf_cap = cpu_to_le32( + tlv_ht_cap->ht_cap.tx_bf_cap); + } + } else if (strcmp(args[0], "AntennaSel") == 0) { + if (tlv_ht_cap) + tlv_ht_cap->ht_cap.asel = + (t_u8)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "HTInformation") == 0) { + /* Append a new TLV */ + tlv_ht_info = (tlvbuf_HTInfo_t *)(buffer + cmd_len); + tlv_len = sizeof(tlvbuf_HTInfo_t); + tlv_ht_info->tag = TLV_TYPE_HT_INFO; + tlv_ht_info->length = + sizeof(tlvbuf_HTInfo_t) - TLVHEADER_LEN; + cmd_len += tlv_len; + endian_convert_tlv_header_out(tlv_ht_info); + } else if (strcmp(args[0], "PrimaryChannel") == 0) { + if (tlv_ht_info) + tlv_ht_info->ht_info.pri_chan = + A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "Field2") == 0) { + if (tlv_ht_info) + tlv_ht_info->ht_info.field2 = + A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "Field3") == 0) { + if (tlv_ht_info) { + tlv_ht_info->ht_info.field3 = + (t_u16)A2HEXDECIMAL(args[1]); + tlv_ht_info->ht_info.field3 = cpu_to_le16( + tlv_ht_info->ht_info.field3); + } + } else if (strcmp(args[0], "Field4") == 0) { + if (tlv_ht_info) { + tlv_ht_info->ht_info.field4 = + (t_u16)A2HEXDECIMAL(args[1]); + tlv_ht_info->ht_info.field4 = cpu_to_le16( + tlv_ht_info->ht_info.field4); + } + } else if (strcmp(args[0], "BasicMCSSet") == 0) { + if (tlv_ht_info) { + if ((arg_num - 1) != MCS_SET_LEN) { + printf("Incorrect number of arguments for BasicMCSSet.\n"); + goto done; + } + for (i = 0; i < MCS_SET_LEN; i++) + tlv_ht_info->ht_info.basic_mcs_set[i] = + (t_u8)A2HEXDECIMAL(args[i + 1]); + } + } else if (strcmp(args[0], "2040BSSCoex") == 0) { + tlvbuf_2040BSSCo_t *tlv = NULL; + /* Append a new TLV */ + tlv_len = sizeof(tlvbuf_2040BSSCo_t); + tlv = (tlvbuf_2040BSSCo_t *)(buffer + cmd_len); + cmd_len += tlv_len; + /* Set TLV fields */ + tlv->tag = TLV_TYPE_2040BSS_COEXISTENCE; + tlv->length = + sizeof(tlvbuf_2040BSSCo_t) - TLVHEADER_LEN; + tlv->bss_co_2040.bss_co_2040_value = + (t_u8)A2HEXDECIMAL(args[1]); + endian_convert_tlv_header_out(tlv); + } else if (strcmp(args[0], "RSNInfo") == 0) { + /* Append a new TLV */ + rsn_ie = (tlvbuf_RsnParamSet_t *)(buffer + cmd_len); + tlv_len_rsn = sizeof(tlvbuf_RsnParamSet_t); + rsn_ie->tag = TLV_TYPE_RSN_IE; + rsn_ie->version = VERSION_RSN_IE; + rsn_ie->version = cpu_to_le16(rsn_ie->version); + cmd_len += tlv_len_rsn; + } else if (strcmp(args[0], "GroupCipherSuite") == 0) { + for (i = 0; i < GROUP_CIPHER_SUITE_LEN; i++) + rsn_ie->group_cipher_suite[i] = + (t_u8)A2HEXDECIMAL(args[i + 1]); + } else if (strcmp(args[0], "PairwiseCipherCount") == 0) { + rsn_ie->pairwise_cipher_count = (t_u16)atoi(args[1]); + rsn_ie->pairwise_cipher_count = + cpu_to_le16(rsn_ie->pairwise_cipher_count); + } else if (strncmp(args[0], "PairwiseCipherSuite", 19) == 0) { + if (pairwise_index > MAX_PAIRWISE_CIPHER_SUITE_COUNT) { + printf("PairwiseCipherSuite exceeds max count\n"); + goto done; + } + tlv_len_rsn += PAIRWISE_CIPHER_SUITE_LEN; + cmd_len += PAIRWISE_CIPHER_SUITE_LEN; + for (i = 0; i < PAIRWISE_CIPHER_SUITE_LEN; i++) { + pairwise_cipher_suite[i] = + (t_u8)A2HEXDECIMAL(args[i + 1]); + } + memcpy((t_u8 *)(rsn_ie->pairwise_cipher_suite + + (pairwise_index * + PAIRWISE_CIPHER_SUITE_LEN)), + pairwise_cipher_suite, + PAIRWISE_CIPHER_SUITE_LEN); + pairwise_index++; + pairwise_offset = + pairwise_index * PAIRWISE_CIPHER_SUITE_LEN; + } else if (strcmp(args[0], "AKMSuiteCount") == 0) { + /* pairwise_cipher_suite + pairwise_offset */ + ptr = (t_u8 *)(rsn_ie->pairwise_cipher_suite + + pairwise_offset); + tlv_len_rsn += sizeof(t_u16); + cmd_len += sizeof(t_u16); + akm_count = (t_u16)atoi(args[1]); + akm_count = cpu_to_le16(akm_count); + if (ptr) + memcpy(ptr, &akm_count, sizeof(t_u16)); + } else if (strncmp(args[0], "AKMSuite", 8) == 0) { + if (akm_index > MAX_AKM_SUITE_COUNT) { + printf("AKMSuite exceeds max count\n"); + goto done; + } + /* pairwise_cipher_suite + pairwise_offset + + * sizeof(t_u16) for akm_count */ + ptr = (t_u8 *)(rsn_ie->pairwise_cipher_suite + + pairwise_offset + sizeof(t_u16)); + tlv_len_rsn += AKM_SUITE_LEN; + cmd_len += AKM_SUITE_LEN; + for (i = 0; i < AKM_SUITE_LEN; i++) { + akm_suite[i] = (t_u8)A2HEXDECIMAL(args[i + 1]); + } + if (ptr) + memcpy((t_u8 *)(ptr + + (akm_index * AKM_SUITE_LEN)), + akm_suite, AKM_SUITE_LEN); + akm_index++; + akm_offset = akm_index * AKM_SUITE_LEN; + } else if (strcmp(args[0], "RSNCapability") == 0) { + /* pairwise_cipher_suite + pairwise_offset + + sizeof(t_u16) for akm_count + + akm_offset */ + ptr = (t_u8 *)(rsn_ie->pairwise_cipher_suite + + pairwise_offset + sizeof(t_u16)) + + akm_offset; + tlv_len_rsn += sizeof(t_u16); + cmd_len += sizeof(t_u16); + rsn_cap = (t_u16)A2HEXDECIMAL(args[1]); + rsn_cap = cpu_to_le16(rsn_cap); + memcpy(ptr, &rsn_cap, sizeof(t_u16)); + } else if (strcmp(args[0], "PMKIDCount") == 0) { + /* pairwise_cipher_suite + pairwise_offset + + sizeof(t_u16) for akm_count + + akm_offset + sizeof(t_u16) for RSNCapability */ + ptr = (t_u8 *)(rsn_ie->pairwise_cipher_suite + + pairwise_offset + sizeof(t_u16)) + + akm_offset + sizeof(t_u16); + tlv_len_rsn += sizeof(t_u16); + cmd_len += sizeof(t_u16); + pmk_count = (t_u16)atoi(args[1]); + pmk_count = cpu_to_le16(pmk_count); + memcpy(ptr, &pmk_count, sizeof(t_u16)); + rsn_ie->length = tlv_len_rsn - TLVHEADER_LEN; + endian_convert_tlv_header_out(rsn_ie); + } else if (strncmp(args[0], "PMKIDList", 9) == 0) { + if (pmkid_index > MAX_PMKID_COUNT) { + printf("PMKIDSuite exceeds max count\n"); + goto done; + } + /* pairwise_cipher_suite + pairwise_offset + + sizeof(t_u16) for akm_count + + akm_offset + sizeof(t_u16) for RSNCapability + + sizeof(t_u16) for PMKIDCount*/ + ptr = (t_u8 *)(rsn_ie->pairwise_cipher_suite + + pairwise_offset + sizeof(t_u16)) + + akm_offset + sizeof(t_u16) + sizeof(t_u16); + for (i = 0; i < PMKID_LEN; i++) + pmkid[i] = (t_u8)A2HEXDECIMAL(args[i + 1]); + if (ptr) + memcpy((t_u8 *)(ptr + + (pmkid_index * PMKID_LEN)), + pmkid, PMKID_LEN); + pmkid_index++; + tlv_len_rsn += PMKID_LEN; + cmd_len += PMKID_LEN; + /* undo conversion done in PMKIDCount */ + endian_convert_tlv_header_in(rsn_ie); + rsn_ie->length = tlv_len_rsn - TLVHEADER_LEN; + endian_convert_tlv_header_out(rsn_ie); + } else if (strcmp(args[0], "SupportedChannels") == 0) { + /* Append a new TLV */ + supp_chan = (tlvbuf_SupportedChannels_t *)(buffer + + cmd_len); + supp_chan->tag = TLV_TYPE_SUPPORTED_CHANNELS; + supp_chan->length = sizeof(tlvbuf_SupportedChannels_t) - + TLVHEADER_LEN; + tlv_len_supp_chan = sizeof(tlvbuf_SupportedChannels_t); + cmd_len += tlv_len_supp_chan; + } else if (strncmp(args[0], "FirstChannelNo", 14) == 0) { + if (supp_chan) + supp_chan->subband[no_of_supp_chan_sub_band] + .start_chan = atoi(args[1]); + } else if (strcmp(args[0], "NumberofSubBandChannels") == 0) { + if (supp_chan) { + supp_chan->subband[no_of_supp_chan_sub_band] + .num_chans = atoi(args[1]); + no_of_supp_chan_sub_band++; + tlv_len_supp_chan += + sizeof(IEEEtypes_SupportChan_Subband_t); + supp_chan->length += + sizeof(IEEEtypes_SupportChan_Subband_t); + cmd_len += + sizeof(IEEEtypes_SupportChan_Subband_t); + endian_convert_tlv_header_out(supp_chan); + } + } else if (strcmp(args[0], "SupportedRegulatoryClasses") == 0) { + /* Append a new TLV */ + reg_class = + (tlvbuf_RegulatoryClass_t *)(buffer + cmd_len); + tlv_len_reg_class = sizeof(tlvbuf_RegulatoryClass_t); + reg_class->tag = TLV_TYPE_REGULATORY_CLASSES; + cmd_len += tlv_len_reg_class; + } else if (strcmp(args[0], "CurrentRegulatoryClass") == 0) { + if (reg_class) { + reg_class->regulatory_class + .cur_regulatory_class = atoi(args[1]); + reg_class->length = 1; + } + } else if (strcmp(args[0], "NumofRegulatoryClasses") == 0) { + if (reg_class) { + num_of_regulatory_class = atoi(args[1]); + reg_class->length += num_of_regulatory_class; + cmd_len += num_of_regulatory_class; + endian_convert_tlv_header_out(reg_class); + } + } else if (strcmp(args[0], "ListOfRegulatoryClasses") == 0) { + if (reg_class) { + for (i = 0; i < num_of_regulatory_class; i++) + reg_class->regulatory_class + .regulatory_classes_list[i] = + (t_u8)A2HEXDECIMAL(args[i + 1]); + } + } else if (strcmp(args[0], "CountryInfo") == 0) { + /* Append a new TLV */ + domain = (tlvbuf_DomainParamSet_t *)(buffer + cmd_len); + domain->tag = TLV_TYPE_DOMAIN; + domain->length = + sizeof(tlvbuf_DomainParamSet_t) - TLVHEADER_LEN; + tlv_len_domain = sizeof(tlvbuf_DomainParamSet_t); + cmd_len += tlv_len_domain; + } else if (strcmp(args[0], "CountryString") == 0) { + strncpy(country, args[1] + 1, strlen(args[1]) - 2); + country[strlen(args[1]) - 2] = '\0'; + for (i = 1; (unsigned int)i < strlen(country) - 2; + i++) { + if ((country[i] < 'A') || (country[i] > 'z')) { + printf("Invalid Country Code\n"); + goto done; + } + if (country[i] > 'Z') + country[i] = country[i] - 'a' + 'A'; + } + if (domain) { + memset(domain->country_code, ' ', + sizeof(domain->country_code)); + memcpy(domain->country_code, country, + strlen(country)); + } + } else if (strncmp(args[0], "FirstChannel", 12) == 0) { + if (domain) + domain->sub_band[no_of_sub_band].first_chan = + atoi(args[1]); + } else if (strncmp(args[0], "NumberofChannels", 16) == 0) { + if (domain) + domain->sub_band[no_of_sub_band].no_of_chan = + atoi(args[1]); + } else if (strncmp(args[0], "TxPower", 7) == 0) { + if (domain) { + domain->sub_band[no_of_sub_band].max_tx_pwr = + atoi(args[1]); + no_of_sub_band++; + domain->length += + sizeof(IEEEtypes_SubbandSet_t); + tlv_len_domain += + sizeof(IEEEtypes_SubbandSet_t); + cmd_len += sizeof(IEEEtypes_SubbandSet_t); + endian_convert_tlv_header_out(domain); + } + } else if (strcmp(args[0], "VHTCapability") == 0) { + /* Append a new TLV */ + tlv_vht_cap = (tlvbuf_VHTCap_t *)(buffer + cmd_len); + tlv_len = sizeof(tlvbuf_VHTCap_t); + tlv_vht_cap->tag = VHT_CAPABILITY; + tlv_vht_cap->length = + sizeof(tlvbuf_VHTCap_t) - TLVHEADER_LEN; + cmd_len += tlv_len; + endian_convert_tlv_header_out(tlv_vht_cap); + } else if (strcmp(args[0], "VHTCapabilityInfo") == 0) { + if (tlv_vht_cap) { + tlv_vht_cap->vht_cap.vht_cap_info = + (t_u32)A2HEXDECIMAL(args[1]); + tlv_vht_cap->vht_cap.vht_cap_info = cpu_to_le16( + tlv_vht_cap->vht_cap.vht_cap_info); + } + } else if (strcmp(args[0], "RxMCSMap") == 0) { + if (tlv_vht_cap) { + tlv_vht_cap->vht_cap.mcs_sets.rx_mcs_map = + (t_u16)A2HEXDECIMAL(args[1]); + tlv_vht_cap->vht_cap.mcs_sets.rx_mcs_map = + cpu_to_le16( + tlv_vht_cap->vht_cap.mcs_sets + .rx_mcs_map); + } + } else if (strcmp(args[0], "TxMCSMap") == 0) { + if (tlv_vht_cap) { + tlv_vht_cap->vht_cap.mcs_sets.tx_mcs_map = + (t_u16)A2HEXDECIMAL(args[1]); + tlv_vht_cap->vht_cap.mcs_sets.tx_mcs_map = + cpu_to_le16( + tlv_vht_cap->vht_cap.mcs_sets + .tx_mcs_map); + } + } else if (strcmp(args[0], "RxMaxRate") == 0) { + if (tlv_vht_cap) { + tlv_vht_cap->vht_cap.mcs_sets.rx_max_rate = + (t_u16)A2HEXDECIMAL(args[1]); + tlv_vht_cap->vht_cap.mcs_sets.rx_max_rate = + cpu_to_le16( + tlv_vht_cap->vht_cap.mcs_sets + .rx_max_rate); + } + } else if (strcmp(args[0], "TxMaxRate") == 0) { + if (tlv_vht_cap) { + tlv_vht_cap->vht_cap.mcs_sets.tx_max_rate = + (t_u16)A2HEXDECIMAL(args[1]); + tlv_vht_cap->vht_cap.mcs_sets.tx_max_rate = + cpu_to_le16( + tlv_vht_cap->vht_cap.mcs_sets + .tx_max_rate); + } + } else if (strcmp(args[0], "VHTOper") == 0) { + /* Append a new TLV */ + tlv_vht_oper = (tlvbuf_VHTOpra_t *)(buffer + cmd_len); + tlv_len = sizeof(tlvbuf_VHTOpra_t); + tlv_vht_oper->tag = VHT_OPERATION; + tlv_vht_oper->length = + sizeof(tlvbuf_VHTOpra_t) - TLVHEADER_LEN; + cmd_len += tlv_len; + endian_convert_tlv_header_out(tlv_vht_oper); + } else if (strcmp(args[0], "ChanWidth") == 0) { + if (tlv_vht_oper) + tlv_vht_oper->chan_width = + A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "ChanCF1") == 0) { + if (tlv_vht_oper) + tlv_vht_oper->chan_cf1 = A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "ChanCF2") == 0) { + if (tlv_vht_oper) + tlv_vht_oper->chan_cf2 = + (t_u16)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "BasicMCSMap") == 0) { + if (tlv_vht_oper) { + if ((arg_num - 1) != VHT_MCS_MAP_LEN) { + printf("Incorrect number of arguments for BasicMCSMap.\n"); + goto done; + } + for (i = 0; i < VHT_MCS_MAP_LEN; i++) + tlv_vht_oper->basic_mcs_map[i] = + (t_u8)A2HEXDECIMAL(args[i + 1]); + } + } + } + /* adjust for size of action and tlv_len, capInfo */ + param_buf->tlv_len = cmd_len - sizeof(tdls_setinfo); + + hexdump("tdls_setinfo", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS Info settings sucessfully set.\n"); + } else { + printf("ERR:Could not set TDLS info configuration.\n"); + } + +done: + if (config_file) + fclose(config_file); + if (buffer) + free(buffer); + if (line) + free(line); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_discovery + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_discovery(int argc, char *argv[]) +{ + tdls_discovery *param_buf = NULL; + tdls_discovery_resp *resp_buf = NULL; + char *line = NULL; + FILE *config_file = NULL; + int li = 0, ret = 0, cmd_found = 0, rssi = 0; + char *args[30], *pos = NULL, mac_addr[21] = {0}; + t_u8 peer_mac[ETH_ALEN]; + t_u16 cmd_len = 0, buf_len = 0, resp_len = 0; + t_u8 *buffer = NULL, *raw = NULL; + IEEEtypes_Header_t *tlv = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_discovery \n"); + exit(1); + } + + cmd_len = sizeof(tdls_discovery); + buf_len = BUFFER_LENGTH; + + buffer = (t_u8 *)malloc(buf_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, buf_len); + param_buf = (tdls_discovery *)buffer; + param_buf->action = ACTION_TDLS_DISCOVERY; + + /* Check if file exists */ + config_file = fopen(argv[3], "r"); + if (config_file == NULL) { + printf("\nERR:Config file can not open.\n"); + ret = MLAN_STATUS_FAILURE; + 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)) { + parse_line(line, args, 30); + if (!cmd_found && strncmp(args[0], argv[2], strlen(args[0]))) + continue; + + cmd_found = 1; + if (strcmp(args[0], "PeerMAC") == 0) { + strncpy(mac_addr, args[1], 20); + ret = mac2raw(mac_addr, peer_mac); + if (ret != MLAN_STATUS_SUCCESS) { + printf("ERR: %s Address \n", + ret == MLAN_STATUS_FAILURE ? + "Invalid MAC" : + ret == MAC_BROADCAST ? + "Broadcast" : + "Multicast"); + goto done; + } + memcpy(param_buf->peer_mac, peer_mac, ETH_ALEN); + } else if (strcmp(args[0], "}") == 0 && cmd_found) { + break; + } + } + hexdump("tdls_discovery", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + hexdump("tdls_response", buffer, 0x40, ' '); + printf("TDLS discovery done.\n"); + resp_buf = (tdls_discovery_resp *)buffer; + resp_len = resp_buf->payload_len; + printf("Response Length = %d\n", resp_len); + if (resp_len > 0) { + /* MAC */ + raw = resp_buf->peer_mac; + printf("\tPeer - %02x:%02x:%02x:%02x:%02x:%02x\n", + (unsigned int)raw[0], (unsigned int)raw[1], + (unsigned int)raw[2], (unsigned int)raw[3], + (unsigned int)raw[4], (unsigned int)raw[5]); + + /* RSSI, CapInfo */ + rssi = (int)(resp_buf->rssi); + if (rssi > 0x7f) + rssi = -(256 - rssi); + printf("\tRssi : %d dBm\n", rssi); + printf("\tCapInfo = 0x%02X\n", resp_buf->cap_info); + + resp_len -= ETH_ALEN + sizeof(resp_buf->rssi) + + sizeof(resp_buf->cap_info); + + /* TLVs */ + tlv = (IEEEtypes_Header_t *)&resp_buf->tlv_buffer; + while (resp_len > IEEE_HEADER_LEN) { + switch (tlv->element_id) { + case TLV_TYPE_RATES: + printf("\tRates : "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + case TLV_EXTENDED_SUPPORTED_RATES: + printf("\tExtended Rates : "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + case TLV_TYPE_QOSINFO: + printf("\tQosInfo "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + + case TLV_TYPE_EXTCAP: + printf("\tExtended Cap "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + + case TLV_TYPE_HT_CAP: + printf("\tHT Cap "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + + case TLV_TYPE_HT_INFO: + printf("\tHT Info"); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + + case TLV_TYPE_2040BSS_COEXISTENCE: + printf("\t2040 BSS Coex "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + + case TLV_TYPE_RSN_IE: + printf("\tRSN IE "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + + case TLV_TYPE_SUPPORTED_CHANNELS: + printf("\tSupported Channels "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + + case TLV_TYPE_DOMAIN: + printf("\tDomain Info "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + case TLV_LINK_IDENTIFIER: + printf("\tLink identifier : "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + case TLV_TIMEOUT_INTERVAL: + printf("\tTimeout interval : "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + case TLV_TYPE_REGULATORY_CLASSES: + printf("\t Regulatory classes : "); + hexdump(NULL, + ((t_u8 *)tlv) + IEEE_HEADER_LEN, + tlv->len, ' '); + break; + default: + printf("Unknown TLV\n"); + hexdump(NULL, ((t_u8 *)tlv), + IEEE_HEADER_LEN + tlv->len, + ' '); + break; + } + resp_len -= tlv->len + IEEE_HEADER_LEN; + tlv = (IEEEtypes_Header_t *)((t_u8 *)tlv + + tlv->len + + IEEE_HEADER_LEN); + } + } + + } else { + printf("ERR:Command response = Fail!\n"); + } +done: + if (config_file) + fclose(config_file); + if (buffer) + free(buffer); + if (line) + free(line); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_setup + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_setup(int argc, char *argv[]) +{ + tdls_setup *param_buf = NULL; + char *line = NULL; + FILE *config_file = NULL; + int li = 0, ret = 0, cmd_found = 0; + char *args[30], *pos = NULL, mac_addr[21] = {0}; + t_u8 peer_mac[ETH_ALEN]; + t_u16 cmd_len = 0; + t_u8 *buffer = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_setup \n"); + exit(1); + } + + cmd_len = sizeof(tdls_setup); + + buffer = (t_u8 *)malloc(cmd_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, cmd_len); + param_buf = (tdls_setup *)buffer; + param_buf->action = ACTION_TDLS_SETUP; + + /* Check if file exists */ + config_file = fopen(argv[3], "r"); + if (config_file == NULL) { + printf("\nERR:Config file can not open.\n"); + ret = MLAN_STATUS_FAILURE; + 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)) { + parse_line(line, args, 30); + if (!cmd_found && strncmp(args[0], argv[2], strlen(args[0]))) + continue; + + cmd_found = 1; + + if (strcmp(args[0], "PeerMAC") == 0) { + strncpy(mac_addr, args[1], 20); + ret = mac2raw(mac_addr, peer_mac); + if (ret != MLAN_STATUS_SUCCESS) { + printf("ERR: %s Address \n", + ret == MLAN_STATUS_FAILURE ? + "Invalid MAC" : + ret == MAC_BROADCAST ? + "Broadcast" : + "Multicast"); + goto done; + } + memcpy(param_buf->peer_mac, peer_mac, ETH_ALEN); + } else if (strcmp(args[0], "WaitTimems") == 0) { + param_buf->wait_time = (t_u32)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "KeyLifetime") == 0) { + param_buf->key_life_time = (t_u32)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "}") == 0 && cmd_found) { + break; + } + } + hexdump("tdls_setup", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS setup request successful.\n"); + } else { + printf("ERR:TDLS setup request failed.\n"); + } + +done: + if (config_file) + fclose(config_file); + if (buffer) + free(buffer); + if (line) + free(line); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_teardown + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_teardown(int argc, char *argv[]) +{ + tdls_teardown *param_buf = NULL; + char *line = NULL; + FILE *config_file = NULL; + int li = 0, ret = 0, cmd_found = 0; + char *args[30], *pos = NULL, mac_addr[21] = {0}; + t_u8 peer_mac[ETH_ALEN]; + t_u16 cmd_len = 0; + t_u8 *buffer = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_teardown \n"); + exit(1); + } + + cmd_len = sizeof(tdls_teardown); + + buffer = (t_u8 *)malloc(cmd_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, cmd_len); + param_buf = (tdls_teardown *)buffer; + param_buf->action = ACTION_TDLS_TEARDOWN; + + /* Check if file exists */ + config_file = fopen(argv[3], "r"); + if (config_file == NULL) { + printf("\nERR:Config file can not open.\n"); + ret = MLAN_STATUS_FAILURE; + 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)) { + parse_line(line, args, 30); + if (!cmd_found && strncmp(args[0], argv[2], strlen(args[0]))) + continue; + + cmd_found = 1; + + if (strcmp(args[0], "PeerMAC") == 0) { + strncpy(mac_addr, args[1], 20); + ret = mac2raw(mac_addr, peer_mac); + if (ret != MLAN_STATUS_SUCCESS) { + printf("ERR: %s Address \n", + ret == MLAN_STATUS_FAILURE ? + "Invalid MAC" : + ret == MAC_BROADCAST ? + "Broadcast" : + "Multicast"); + goto done; + } + memcpy(param_buf->peer_mac, peer_mac, ETH_ALEN); + } else if (strcmp(args[0], "ReasonCode") == 0) { + param_buf->reason_code = (t_u16)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "}") == 0 && cmd_found) { + break; + } + } + hexdump("tdls_teardown", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS teardown request successful.\n"); + } else { + printf("ERR:TDLS teardown request failed.\n"); + } + +done: + if (config_file) + fclose(config_file); + if (buffer) + free(buffer); + if (line) + free(line); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_powermode + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_powermode(int argc, char *argv[]) +{ + tdls_powermode *param_buf = NULL; + char *line = NULL; + FILE *config_file = NULL; + int li = 0, ret = 0, cmd_found = 0; + char *args[30], *pos = NULL, mac_addr[21] = {0}; + t_u8 peer_mac[ETH_ALEN]; + t_u16 cmd_len = 0; + t_u8 *buffer = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_powermode \n"); + exit(1); + } + + cmd_len = sizeof(tdls_powermode); + + buffer = (t_u8 *)malloc(cmd_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, cmd_len); + param_buf = (tdls_powermode *)buffer; + param_buf->action = ACTION_TDLS_POWER_MODE; + + /* Check if file exists */ + config_file = fopen(argv[3], "r"); + if (config_file == NULL) { + printf("\nERR:Config file can not open.\n"); + ret = MLAN_STATUS_FAILURE; + 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)) { + parse_line(line, args, 30); + if (!cmd_found && strncmp(args[0], argv[2], strlen(args[0]))) + continue; + + cmd_found = 1; + + if (strcmp(args[0], "PeerMAC") == 0) { + strncpy(mac_addr, args[1], 20); + ret = mac2raw(mac_addr, peer_mac); + if (ret != MLAN_STATUS_SUCCESS) { + printf("ERR: %s Address \n", + ret == MLAN_STATUS_FAILURE ? + "Invalid MAC" : + ret == MAC_BROADCAST ? + "Broadcast" : + "Multicast"); + goto done; + } + memcpy(param_buf->peer_mac, peer_mac, ETH_ALEN); + } else if (strcmp(args[0], "PowerMode") == 0) { + param_buf->power_mode = (t_u16)A2HEXDECIMAL(args[1]); + if (param_buf->power_mode > 1) { + printf("ERR: Incorrect PowerMode value %s\n", + args[1]); + goto done; + } + } else if (strcmp(args[0], "}") == 0 && cmd_found) { + break; + } + } + hexdump("tdls_powermode", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS powermode request successful.\n"); + } else { + printf("ERR:TDLS powermode request failed.\n"); + } + +done: + if (config_file) + fclose(config_file); + if (buffer) + free(buffer); + if (line) + free(line); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_link_status + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_link_status(int argc, char *argv[]) +{ + int ret = 0; + tdls_link_status *param_buf = NULL; + tdls_link_status_resp *resp_buf = NULL; + t_u16 cmd_len = 0, buf_len = 0, resp_len = 0, curr_link_len = 0; + t_u8 no_of_links = 0, peer_mac[ETH_ALEN] = {0}; + t_u8 *buffer = NULL, *raw = NULL; + tdls_each_link_status *link_ptr = NULL; + + /* Check arguments */ + if (argc != 3 && argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_link_status [peer_mac_addr]\n"); + exit(1); + } + + cmd_len = sizeof(tdls_link_status); + buf_len = BUFFER_LENGTH; + + buffer = (t_u8 *)malloc(buf_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, buf_len); + param_buf = (tdls_link_status *)buffer; + param_buf->action = ACTION_TDLS_LINK_STATUS; + + if (argc == 4) { + ret = mac2raw(argv[3], peer_mac); + if (ret != MLAN_STATUS_SUCCESS) { + printf("ERR: %s Address \n", + ret == MLAN_STATUS_FAILURE ? + "Invalid MAC" : + ret == MAC_BROADCAST ? "Broadcast" : + "Multicast"); + goto done; + } + if (memcmp(peer_mac, "\x00\x00\x00\x00\x00\x00", ETH_ALEN)) { + memcpy(buffer + cmd_len, peer_mac, ETH_ALEN); + cmd_len += ETH_ALEN; + } + } + + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + hexdump("tdls_response", buffer, 0x60, ' '); + printf("TDLS Link Status - .\n"); + resp_buf = (tdls_link_status_resp *)buffer; + resp_len = resp_buf->payload_len; + printf("Response Length = %d\n", resp_len); + no_of_links = resp_buf->active_links; + printf("No of active links = %d\n", no_of_links); + resp_len--; + link_ptr = resp_buf->link_stats; + while (resp_len > 0 && no_of_links > 0) { + curr_link_len = 0; + /* MAC */ + raw = link_ptr->peer_mac; + printf("\tPeer - %02x:%02x:%02x:%02x:%02x:%02x\n", + (unsigned int)raw[0], (unsigned int)raw[1], + (unsigned int)raw[2], (unsigned int)raw[3], + (unsigned int)raw[4], (unsigned int)raw[5]); + + printf("\t %s initiated link.\n", + (link_ptr->link_flags & 0x01) ? "Self" : "Peer"); + printf("\t Security %s.\n", + (link_ptr->link_flags & 0x02) ? "Enabled" : + "Disabled"); + printf("\t Self PS status = %s.\n", + (link_ptr->link_flags & 0x04) ? "Sleep" : + "Active"); + printf("\t Peer PS status = %s.\n", + (link_ptr->link_flags & 0x08) ? "Sleep" : + "Active"); + printf("\t Channel switch is %ssupported\n", + (link_ptr->link_flags & 0x10) ? "" : "NOT "); + printf("\t Current Channel %s\n", + (link_ptr->link_flags & 0x20) ? "off" : "base"); + + if (link_ptr->traffic_status) { + printf("\t Buffered traffic for"); + printf("%s", (link_ptr->traffic_status & 0x01) ? + "AC_BK, " : + ""); + printf("%s", (link_ptr->traffic_status & 0x02) ? + "AC_BE, " : + ""); + printf("%s", (link_ptr->traffic_status & 0x04) ? + "AC_VI, " : + ""); + printf("%s", (link_ptr->traffic_status & 0x08) ? + "AC_VO" : + ""); + printf(".\n"); + } + printf("\t Successive Tx Failure count = %d\n", + link_ptr->tx_fail_count); + printf("\t Active channel number = %d\n", + link_ptr->active_channel); + printf("\t Last Data RSSI = %d dBm\n", + link_ptr->data_rssi_last); + printf("\t Last Data NF = %d dBm\n", + link_ptr->data_nf_last); + printf("\t Average Data RSSI = %d dBm\n", + link_ptr->data_rssi_avg); + printf("\t Average Data NF = %d dBm\n", + link_ptr->data_nf_avg); + printf("\t Tx data rate = %d Mbps\n", + link_ptr->u.final_data_rate); + + /* size of unsecure structure */ + curr_link_len = + sizeof(tdls_each_link_status) - + (sizeof(t_u32) + sizeof(t_u8) + sizeof(t_u8)); + + if (link_ptr->link_flags & 0x02) { + /* security details */ + printf("\t Security Method = %s\n", + (link_ptr->security_method == 1) ? + "AES" : + "None"); + printf("\t Key Lifetime = %d ms\n\t", + link_ptr->key_lifetime); + hexdump("Key", ((t_u8 *)link_ptr->key), + link_ptr->key_length, ' '); + curr_link_len += sizeof(t_u32) + sizeof(t_u8) + + sizeof(t_u8) + + link_ptr->key_length; + } + resp_len -= curr_link_len; + link_ptr = + (tdls_each_link_status *)(((t_u8 *)link_ptr) + + curr_link_len); + printf(".\n"); + } + + } else { + printf("ERR:Command response = Fail!\n"); + } +done: + if (buffer) + free(buffer); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_channel_swtich + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_channel_switch(int argc, char *argv[]) +{ + tdls_channel_switch *param_buf = NULL; + char *line = NULL; + FILE *config_file = NULL; + int li = 0, ret = 0, cmd_found = 0; + char *args[30], *pos = NULL, mac_addr[21] = {0}; + t_u8 peer_mac[ETH_ALEN]; + t_u16 cmd_len = 0; + t_u8 *buffer = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_channel_switch \n"); + exit(1); + } + + cmd_len = sizeof(tdls_channel_switch); + + buffer = (t_u8 *)malloc(cmd_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, cmd_len); + param_buf = (tdls_channel_switch *)buffer; + param_buf->action = ACTION_TDLS_INIT_CHAN_SWITCH; + + /* Check if file exists */ + config_file = fopen(argv[3], "r"); + if (config_file == NULL) { + printf("\nERR:Config file can not open.\n"); + ret = MLAN_STATUS_FAILURE; + 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)) { + parse_line(line, args, 30); + if (!cmd_found && strncmp(args[0], argv[2], strlen(args[0]))) + continue; + + cmd_found = 1; + + if (strcmp(args[0], "PeerMAC") == 0) { + strncpy(mac_addr, args[1], 20); + ret = mac2raw(mac_addr, peer_mac); + if (ret != MLAN_STATUS_SUCCESS) { + printf("ERR: %s Address \n", + ret == MLAN_STATUS_FAILURE ? + "Invalid MAC" : + ret == MAC_BROADCAST ? + "Broadcast" : + "Multicast"); + goto done; + } + memcpy(param_buf->peer_mac, peer_mac, ETH_ALEN); + } else if (strcmp(args[0], "Band") == 0) { + param_buf->band = (t_u16)A2HEXDECIMAL(args[1]); + if (param_buf->band != BAND_BG_TDLS && + param_buf->band != BAND_A_TDLS) { + printf("ERR: Incorrect Band value %s\n", + args[1]); + goto done; + } + } else if (strcmp(args[0], "RegulatoryClass") == 0) { + param_buf->regulatory_class = + (t_u16)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "PrimaryChannel") == 0) { + param_buf->primary_channel = + (t_u16)A2HEXDECIMAL(args[1]); + if (param_buf->band == BAND_BG_TDLS && + param_buf->primary_channel < MIN_BG_CHANNEL && + param_buf->primary_channel > MAX_BG_CHANNEL) { + printf("ERR: Incorrect Primary Channel value %s\n", + args[1]); + goto done; + } else if (param_buf->band == BAND_A_TDLS && + param_buf->primary_channel < MIN_A_CHANNEL && + param_buf->primary_channel > MAX_A_CHANNEL) { + printf("ERR: Incorrect Primary Channel value %s\n", + args[1]); + goto done; + } + } else if (strcmp(args[0], "SecondaryChannelOffset") == 0) { + param_buf->secondary_channel_offset = + (t_u16)A2HEXDECIMAL(args[1]); + if (param_buf->secondary_channel_offset != + SEC_CHAN_NONE && + param_buf->secondary_channel_offset != + SEC_CHAN_ABOVE && + param_buf->secondary_channel_offset != + SEC_CHAN_BELOW) { + printf("ERR: Incorrect Secondary Channel Offset value %s\n", + args[1]); + goto done; + } + } else if (strcmp(args[0], "ChannelSwitchTime") == 0) { + param_buf->switch_time = (t_u16)A2HEXDECIMAL(args[1]); + if (param_buf->switch_time == 0) { + printf("ERR: Incorrect Channel Switch time %s\n", + args[1]); + goto done; + } + } else if (strcmp(args[0], "ChannelSwitchTimeout") == 0) { + param_buf->switch_timeout = + (t_u16)A2HEXDECIMAL(args[1]); + if (param_buf->switch_timeout == 0) { + printf("ERR: Incorrect Channel Switch timeout %s\n", + args[1]); + goto done; + } + } else if (strcmp(args[0], "Periodicity") == 0) { + param_buf->periodicity = (t_u16)A2HEXDECIMAL(args[1]); + if (param_buf->periodicity != NO_PERIODIC_SWITCH && + param_buf->periodicity != ENABLE_PERIODIC_SWITCH) { + printf("ERR: Incorrect Periodicity value %s\n", + args[1]); + goto done; + } + } else if (strcmp(args[0], "}") == 0 && cmd_found) { + break; + } + } + hexdump("tdls_channel_switch", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS channel switch request successful.\n"); + } else { + printf("ERR:TDLS channel switch request failed.\n"); + } + +done: + if (config_file) + fclose(config_file); + if (buffer) + free(buffer); + if (line) + free(line); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief disable tdls_channel_swtich + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_disable_channel_switch(int argc, char *argv[]) +{ + tdls_disable_cs *param_buf = NULL; + int ret = 0; + t_u16 cmd_len = 0; + t_u8 *buffer = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_disable_cs <0/1>\n"); + exit(1); + } + + cmd_len = sizeof(tdls_disable_cs); + + buffer = (t_u8 *)malloc(cmd_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, cmd_len); + param_buf = (tdls_disable_cs *)buffer; + param_buf->action = ACTION_TDLS_CS_DISABLE; + + param_buf->data = (t_u16)A2HEXDECIMAL(argv[3]); + if ((param_buf->data != 0) && (param_buf->data != 1)) { + printf("ERR:Incorrect arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_disable_cs <0/1>\n"); + goto done; + } + hexdump("tdls_disable_cs", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS disable channel switch successful.\n"); + } else { + printf("ERR:TDLS disable channel switch failed.\n"); + } + +done: + if (buffer) + free(buffer); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_stop_channel_switch + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_stop_channel_switch(int argc, char *argv[]) +{ + tdls_stop_chan_switch *param_buf = NULL; + char *line = NULL; + FILE *config_file = NULL; + int li = 0, ret = 0, cmd_found = 0; + char *args[30], *pos = NULL, mac_addr[21] = {0}; + t_u8 peer_mac[ETH_ALEN]; + t_u16 cmd_len = 0; + t_u8 *buffer = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_stop_channel_switch \n"); + exit(1); + } + + cmd_len = sizeof(tdls_stop_chan_switch); + + buffer = (t_u8 *)malloc(cmd_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, cmd_len); + param_buf = (tdls_stop_chan_switch *)buffer; + param_buf->action = ACTION_TDLS_STOP_CHAN_SWITCH; + + /* Check if file exists */ + config_file = fopen(argv[3], "r"); + if (config_file == NULL) { + printf("\nERR:Config file can not open.\n"); + ret = MLAN_STATUS_FAILURE; + 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)) { + parse_line(line, args, 30); + if (!cmd_found && strncmp(args[0], argv[2], strlen(args[0]))) + continue; + + cmd_found = 1; + + if (strcmp(args[0], "PeerMAC") == 0) { + strncpy(mac_addr, args[1], 20); + ret = mac2raw(mac_addr, peer_mac); + if (ret != MLAN_STATUS_SUCCESS) { + printf("ERR: %s Address \n", + ret == MLAN_STATUS_FAILURE ? + "Invalid MAC" : + ret == MAC_BROADCAST ? + "Broadcast" : + "Multicast"); + goto done; + } + memcpy(param_buf->peer_mac, peer_mac, ETH_ALEN); + } else if (strcmp(args[0], "}") == 0 && cmd_found) { + break; + } + } + hexdump("tdls_stop_channel_switch", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS stop channel switch successful.\n"); + } else { + printf("ERR:TDLS stop channel switch failed.\n"); + } + +done: + if (config_file) + fclose(config_file); + if (buffer) + free(buffer); + if (line) + free(line); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_cs_params + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_cs_params(int argc, char *argv[]) +{ + tdls_cs_params *param_buf = NULL; + char *line = NULL; + FILE *config_file = NULL; + int li = 0, ret = 0, cmd_found = 0; + char *args[30], *pos = NULL; + t_u16 cmd_len = 0; + t_u8 *buffer = NULL; + + /* Check arguments */ + if (argc != 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_cs_params \n"); + exit(1); + } + + cmd_len = sizeof(tdls_cs_params); + + buffer = (t_u8 *)malloc(cmd_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + goto done; + } + memset(buffer, 0, cmd_len); + param_buf = (tdls_cs_params *)buffer; + param_buf->action = ACTION_TDLS_CS_PARAMS; + + /* Check if file exists */ + config_file = fopen(argv[3], "r"); + if (config_file == NULL) { + printf("\nERR:Config file can not open.\n"); + ret = MLAN_STATUS_FAILURE; + 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)) { + parse_line(line, args, 30); + if (!cmd_found && strncmp(args[0], argv[2], strlen(args[0]))) + continue; + + cmd_found = 1; + + if (strcmp(args[0], "UnitTime") == 0) { + param_buf->unit_time = (t_u8)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "ThresholdOtherLink") == 0) { + param_buf->threshold_otherlink = + (t_u8)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "ThresholdDirectLink") == 0) { + param_buf->threshold_directlink = + (t_u8)A2HEXDECIMAL(args[1]); + } else if (strcmp(args[0], "}") == 0 && cmd_found) { + break; + } + } + hexdump("tdls_cs_params", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS set channel switch parameters successful.\n"); + } else { + printf("ERR:TDLS set channel switch parameters failed.\n"); + } +done: + if (config_file) + fclose(config_file); + if (buffer) + free(buffer); + if (line) + free(line); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls_debug + * @param argc number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_debug(int argc, char *argv[]) +{ + int ret = 0; + tdls_debug *param_buf = NULL; + t_u16 cmd_len = 0; + t_u8 *buffer = NULL; + t_u16 action = 0, value = 0; + + /* Check arguments */ + if (argc < 4) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_debug \n"); + exit(1); + } + + cmd_len = sizeof(tdls_debug); + + /* wrong_bss */ + if (!strcmp(argv[3], "wrong_bss")) { + cmd_len += sizeof(t_u16); + action = ACTION_TDLS_DEBUG_WRONG_BSS; + if (argc < 5) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_debug wrong_bss <0/1>\n"); + exit(1); + } + value = (t_u16)A2HEXDECIMAL(argv[4]); + } + /* same link */ + else if (!strcmp(argv[3], "setup_existing_link")) { + cmd_len += sizeof(t_u16); + action = ACTION_TDLS_DEBUG_SETUP_SAME_LINK; + if (argc < 5) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_debug setup_existing_link <0/1>\n"); + exit(1); + } + value = (t_u16)A2HEXDECIMAL(argv[4]); + } + /* fail_setup_confirm */ + else if (!strcmp(argv[3], "fail_setup_confirm")) { + cmd_len += sizeof(t_u16); + action = ACTION_TDLS_DEBUG_FAIL_SETUP_CONFIRM; + if (argc < 5) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_debug fail_setup_confirm <0/1>\n"); + exit(1); + } + value = (t_u16)A2HEXDECIMAL(argv[4]); + } + /* setup prohibited*/ + else if (!strcmp(argv[3], "setup_with_prohibited")) { + cmd_len += sizeof(t_u16); + action = ACTION_TDLS_DEBUG_SETUP_PROHIBITED; + if (argc < 5) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_debug setup_with_prohibited <0/1>\n"); + exit(1); + } + value = (t_u16)A2HEXDECIMAL(argv[4]); + } + /* setup higher/lower mac */ + else if (!strcmp(argv[3], "higher_lower_mac")) { + cmd_len += sizeof(t_u16); + action = ACTION_TDLS_DEBUG_HIGHER_LOWER_MAC; + if (argc < 5) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_debug higher_lower_mac <0/1>\n"); + exit(1); + } + value = (t_u16)A2HEXDECIMAL(argv[4]); + } + /* ignore key lifetime expiry */ + else if (!strcmp(argv[3], "ignore_key_expiry")) { + cmd_len += sizeof(t_u16); + action = ACTION_TDLS_DEBUG_IGNORE_KEY_EXPIRY; + if (argc < 5) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_debug ignore_key_expiry <0/1>\n"); + exit(1); + } + value = (t_u16)A2HEXDECIMAL(argv[4]); + } + /* allow weak security */ + else if (!strcmp(argv[3], "allow_weak_security")) { + cmd_len += sizeof(t_u16); + action = ACTION_TDLS_DEBUG_ALLOW_WEAK_SECURITY; + if (argc < 5) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_debug allow_weak_security <0/1>\n"); + exit(1); + } + value = (t_u16)A2HEXDECIMAL(argv[4]); + } + /* stop RX */ + else if (!strcmp(argv[3], "stop_rx")) { + cmd_len += sizeof(t_u16); + action = ACTION_TDLS_DEBUG_STOP_RX; + if (argc < 5) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_debug stop_rx <0/1>\n"); + exit(1); + } + value = (t_u16)A2HEXDECIMAL(argv[4]); + } + /* Immediate return */ + else if (!strcmp(argv[3], "cs_im_return")) { + cmd_len += sizeof(t_u16); + action = ACTION_TDLS_DEBUG_CS_RET_IM; + if (argc < 5) { + printf("ERR:Incorrect number of arguments.\n"); + printf("Syntax: ./mlanutl mlanX tdls_debug cs_im_return <0/1>\n"); + exit(1); + } + value = (t_u16)A2HEXDECIMAL(argv[4]); + } else { + printf("ERR:Incorrect command!\n"); + exit(1); + } + + buffer = (t_u8 *)malloc(cmd_len); + if (!buffer) { + printf("ERR:Cannot allocate memory!\n"); + return -1; + } + memset(buffer, 0, cmd_len); + param_buf = (tdls_debug *)buffer; + param_buf->action = action; + memcpy(param_buf->data, &value, sizeof(value)); + + hexdump("tdls_debug", buffer, cmd_len, ' '); + /* Send collective command */ + ret = tdls_ioctl((t_u8 *)buffer, cmd_len); + + /* Process response */ + if (ret == MLAN_STATUS_SUCCESS) { + printf("TDLS debug request successful.\n"); + } else { + printf("ERR:TDLS debug request failed.\n"); + } + + if (buffer) + free(buffer); + return MLAN_STATUS_SUCCESS; +} + +/** + * @brief Process tdls idle time set/get + * @param argc Number of arguments + * @param argv A pointer to arguments array + * @return MLAN_STATUS_SUCCESS--success, otherwise--fail + */ +static int process_tdls_idle_time(int argc, char *argv[]) +{ + t_u8 *buffer = NULL; + struct eth_priv_cmd *cmd = NULL; + struct ifreq ifr; + int tdls_idle_time = 0; + + /* Check arguments */ + if (argc < 3 || argc > 4) { + printf("ERR:Incorrect number of arguments!\n"); + printf("Syntax: ./mlanutl mlanX tdls_idle_time