diff --git a/wmi/inc/wmi_unified_api.h b/wmi/inc/wmi_unified_api.h index 04cb185639..c1d6e0f115 100644 --- a/wmi/inc/wmi_unified_api.h +++ b/wmi/inc/wmi_unified_api.h @@ -38,6 +38,7 @@ #include "ol_defines.h" #include "wmi.h" #include "htc_api.h" +#include "wmi_unified_param.h" typedef cdf_nbuf_t wmi_buf_t; #define wmi_buf_data(_buf) cdf_nbuf_data(_buf) @@ -49,7 +50,7 @@ typedef cdf_nbuf_t wmi_buf_t; * @ready_cbk: ready calback * @wma_process_fw_event_handler_cbk: generic event handler callback */ -struct wmi_ops { +struct wmi_rx_ops { void (*service_ready_cbk)(void *ctx, void *ev); void (*service_ready_ext_cbk)(void *ctx, void *ev); void (*ready_cbk)(void *ctx, void *ev); @@ -76,7 +77,7 @@ enum wmi_target_type { */ void *wmi_unified_attach(void *scn_handle, osdev_t osdev, enum wmi_target_type target_type, - bool use_cookie, struct wmi_ops *ops); + bool use_cookie, struct wmi_rx_ops *ops); /** * detach for unified WMI @@ -202,4 +203,117 @@ static inline bool wmi_get_runtime_pm_inprogress(wmi_unified_t wmi_handle) */ void wmi_process_fw_event(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf); uint16_t wmi_get_max_msg_len(wmi_unified_t wmi_handle); + + +int32_t wmi_unified_vdev_create_send(void *wmi_hdl, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct vdev_create_params *param); + +int32_t wmi_unified_vdev_delete_send(void *wmi_hdl, + uint8_t if_id); + +int32_t wmi_unified_vdev_start_send(void *wmi_hdl, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct vdev_start_params *param); + +int32_t wmi_unified_vdev_restart_send(void *wmi_hdl, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct vdev_start_params *param); + +int32_t wmi_unified_vdev_stop_send(void *wmi_hdl, + uint8_t vdev_id); + +int32_t wmi_unified_vdev_up_send(void *wmi_hdl, + uint8_t bssid[IEEE80211_ADDR_LEN], + struct vdev_up_params *params); + +int32_t wmi_unified_vdev_down_send(void *wmi_hdl, + uint8_t vdev_id); + +int32_t wmi_unified_vdev_set_param_send(void *wmi_hdl, + struct vdev_set_params *param); + +int32_t wmi_unified_peer_delete_send(void *wmi_hdl, + uint8_t + peer_addr[IEEE80211_ADDR_LEN], + uint8_t vdev_id); + +int32_t wmi_unified_peer_flush_tids_send(void *wmi_hdl, + uint8_t peer_addr[IEEE80211_ADDR_LEN], + struct peer_flush_params *param); + +int32_t wmi_set_peer_param_send(void *wmi_hdl, + uint8_t peer_addr[IEEE80211_ADDR_LEN], + struct peer_set_params *param); + +int32_t wmi_unified_peer_create_send(void *wmi_hdl, + struct peer_create_params *param); + +int32_t wmi_unified_stats_request_send(void *wmi_hdl, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct stats_request_params *param); + +int32_t wmi_unified_green_ap_ps_send(void *wmi_hdl, + uint32_t value, uint8_t mac_id); + + +int32_t wmi_unified_wow_enable_send(void *wmi_hdl, + struct wow_cmd_params *param, + uint8_t mac_id); + +int32_t wmi_unified_packet_log_enable_send(void *wmi_hdl, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct packet_enable_params *param); + + +int32_t wmi_unified_suspend_send(void *wmi_hdl, + struct suspend_params *param, + uint8_t mac_id); + +int32_t wmi_unified_resume_send(void *wmi_hdl, + uint8_t mac_id); + +int32_t +wmi_unified_pdev_param_send(void *wmi_hdl, + struct pdev_params *param, + uint8_t mac_id); + +int32_t wmi_unified_beacon_send_cmd(void *wmi_hdl, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct beacon_params *param); + +int32_t wmi_unified_peer_assoc_send(void *wmi_hdl, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct peer_assoc_params *param); + +int32_t wmi_unified_sta_ps_cmd_send(void *wmi_hdl, + struct sta_ps_params *param); + +int32_t wmi_unified_ap_ps_cmd_send(void *wmi_hdl, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct ap_ps_params *param); + +int32_t wmi_unified_scan_start_cmd_send(void *wmi_hdl, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_start_params *param); + +int32_t wmi_unified_scan_stop_cmd_send(void *wmi_hdl, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_stop_params *param); + +int32_t wmi_unified_scan_chan_list_cmd_send(void *wmi_hdl, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_chan_list_params *param); + + +int32_t wmi_crash_inject(void *wmi_hdl, + struct crash_inject *param); + +int32_t wmi_unified_pdev_utf_cmd_send(void *wmi_hdl, + struct pdev_utf_params *param, + uint8_t mac_id); + +int32_t wmi_unified_dbglog_cmd_send(void *wmi_hdl, + struct dbglog_params *param); + #endif /* _WMI_UNIFIED_API_H_ */ diff --git a/wmi/inc/wmi_unified_non_tlv.h b/wmi/inc/wmi_unified_non_tlv.h new file mode 100644 index 0000000000..9e6fc5a1f0 --- /dev/null +++ b/wmi/inc/wmi_unified_non_tlv.h @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2016 The Linux Foundation. All rights reserved. + * + * Previously licensed under the ISC license by Qualcomm Atheros, Inc. + * + * + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all + * copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * This file was originally distributed by Qualcomm Atheros, Inc. + * under proprietary terms before Copyright ownership was assigned + * to the Linux Foundation. + */ + +#include +#include "a_types.h" +#include "wmi_unified_param.h" + +#include "ol_defines.h" /* Fix Me: wmi_unified_t structure definition */ + +int32_t send_vdev_create_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct vdev_create_params *param); + +int32_t send_vdev_delete_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t if_id); + +int32_t send_vdev_stop_cmd_non_tlv(wmi_unified_t wmi, + uint8_t vdev_id); + +int32_t send_vdev_down_cmd_non_tlv(wmi_unified_t wmi, + uint8_t vdev_id); + +int32_t send_peer_flush_tids_cmd_non_tlv(wmi_unified_t wmi, + uint8_t peer_addr[IEEE80211_ADDR_LEN], + struct peer_flush_params *param); + +int32_t send_peer_delete_cmd_non_tlv(wmi_unified_t wmi, + uint8_t peer_addr[IEEE80211_ADDR_LEN], + uint8_t vdev_id); + +int32_t send_peer_param_cmd_non_tlv(wmi_unified_t wmi, + uint8_t peer_addr[IEEE80211_ADDR_LEN], + struct peer_set_params *param); + +int32_t send_vdev_up_cmd_non_tlv(wmi_unified_t wmi, + uint8_t bssid[IEEE80211_ADDR_LEN], + struct vdev_up_params *params); + +int32_t send_peer_create_cmd_non_tlv(wmi_unified_t wmi, + struct peer_create_params *param); + +int32_t send_green_ap_ps_cmd_non_tlv(wmi_unified_t wmi_handle, + uint32_t value, uint8_t mac_id); + +int32_t +send_pdev_utf_cmd_non_tlv(wmi_unified_t wmi_handle, + struct pdev_utf_params *param, + uint8_t mac_id); + +int32_t +send_pdev_param_cmd_non_tlv(wmi_unified_t wmi_handle, + struct pdev_params *param, + uint8_t mac_id); + +int32_t send_suspend_cmd_non_tlv(wmi_unified_t wmi_handle, + struct suspend_params *param, + uint8_t mac_id); + +int32_t send_resume_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t mac_id); + +int32_t send_wow_enable_cmd_non_tlv(wmi_unified_t wmi_handle, + struct wow_cmd_params *param, + uint8_t mac_id); + +int32_t send_set_ap_ps_param_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t *peer_addr, + struct ap_ps_params *param); + +int32_t send_set_sta_ps_param_cmd_non_tlv(wmi_unified_t wmi_handle, + struct sta_ps_params *param); + +int32_t send_crash_inject_cmd_non_tlv(wmi_unified_t wmi_handle, + struct crash_inject *param); + +int32_t +send_dbglog_cmd_non_tlv(wmi_unified_t wmi_handle, + struct dbglog_params *dbglog_param); + +int32_t send_vdev_set_param_cmd_non_tlv(wmi_unified_t wmi_handle, + struct vdev_set_params *param); + +int32_t send_stats_request_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct stats_request_params *param); + +int32_t send_packet_log_enable_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct packet_enable_params *param); + +int32_t send_beacon_send_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct beacon_params *param); + +int32_t send_peer_assoc_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct peer_assoc_params *param); + +int32_t send_scan_start_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_start_params *param); + +int32_t send_scan_stop_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_stop_params *param); + +int32_t send_scan_chan_list_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_chan_list_params *param); + diff --git a/wmi/inc/wmi_unified_param.h b/wmi/inc/wmi_unified_param.h new file mode 100644 index 0000000000..4f5bb925cf --- /dev/null +++ b/wmi/inc/wmi_unified_param.h @@ -0,0 +1,532 @@ +/* + * Copyright (c) 2016 The Linux Foundation. All rights reserved. + * + * Previously licensed under the ISC license by Qualcomm Atheros, Inc. + * + * + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all + * copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * This file was originally distributed by Qualcomm Atheros, Inc. + * under proprietary terms before Copyright ownership was assigned + * to the Linux Foundation. + */ + +/* + * This file contains the API definitions for the Unified Wireless Module + * Interface (WMI). + */ + +#ifndef _WMI_UNIFIED_PARAM_H_ +#define _WMI_UNIFIED_PARAM_H_ +#include "wmi_unified.h" +#define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ +#define MAX_UTF_EVENT_LENGTH 2048 +#define WMI_MAC_MAX_SSID_LENGTH 32 +#define WMI_SCAN_MAX_NUM_SSID 0x0A +#define mgmt_tx_dl_frm_len 64 +#define WMI_SMPS_MASK_LOWER_16BITS 0xFF +#define WMI_SMPS_MASK_UPPER_3BITS 0x7 +#define WMI_SMPS_PARAM_VALUE_S 29 +#define MAX_WMI_UTF_LEN 252 +/** + * struct vdev_create_params - vdev create cmd parameter + * @if_id: interface id + * @type: interface type + * @subtype: interface subtype + */ +struct vdev_create_params { + uint8_t if_id; + uint32_t type; + uint32_t subtype; +}; + +/** + * struct vdev_delete_params - vdev delete cmd parameter + * @if_id: interface id + */ +struct vdev_delete_params { + uint8_t if_id; +}; + +/** + * struct vdev_start_params - vdev start cmd parameter + * @beacon_intval: beacon intval + * @dtim_period: dtim period + * @max_txpow: max tx power + * @phy_ch_width chan_width: channel width + * @is_dfs: flag to check if dfs enabled + * @vdev_id: vdev id + * @chan: channel no + * @oper_mode: operating mode + * @length: length + * @ssId[32]: ssid + * @hidden_ssid: hidden ssid + * @pmf_enabled: is pmf enabled + * @vht_capable: is vht capable + * @ch_center_freq_seg0: center freq seq 0 + * @ch_center_freq_seg1: center freq seq 1 + * @ht_capable: is ht capable + * @dfs_pri_multiplier: DFS multiplier + * @dot11_mode: dot11 mode + * @is_half_rate: Indicates half rate channel + * @is_quarter_rate: Indicates quarter rate channel + * @preferred_tx_streams: preferred tx streams + * @preferred_rx_streams: preferred rx streams + */ +struct vdev_start_params { + uint32_t beacon_intval; + uint32_t dtim_period; + int32_t max_txpow; + bool is_dfs; + uint8_t vdev_id; + uint8_t chan; + uint8_t oper_mode; + uint8_t length; + uint8_t ssId[32]; + uint8_t hidden_ssid; + uint8_t pmf_enabled; + uint8_t vht_capable; + uint8_t ch_center_freq_seg0; + uint8_t ch_center_freq_seg1; + uint8_t ht_capable; + int32_t dfs_pri_multiplier; + uint8_t dot11_mode; + bool is_half_rate; + bool is_quarter_rate; + uint32_t preferred_tx_streams; + uint32_t preferred_rx_streams; +}; + +/** + * struct vdev_stop_params - vdev stop cmd parameter + * @vdev_id: vdev id + */ +struct vdev_stop_params { + uint8_t vdev_id; +}; + +/** + * struct vdev_up_params - vdev up cmd parameter + * @vdev_id: vdev id + * @assoc_id: association id + */ +struct vdev_up_params { + uint8_t vdev_id; + uint16_t assoc_id; +}; + +/** + * struct vdev_down_params - vdev down cmd parameter + * @vdev_id: vdev id + */ +struct vdev_down_params { + uint8_t vdev_id; +}; + +/** + * struct vdev_set_params - vdev set cmd parameter + * @if_id: vdev id + * @param_id: parameter id + * @param_value: parameter value + */ +struct vdev_set_params { + uint32_t if_id; + uint32_t param_id; + uint32_t param_value; +}; + +/** + * struct peer_delete_params - peer delete cmd parameter + * @vdev_id: vdev id + */ +struct peer_delete_params { + uint8_t vdev_id; +}; + +/** + * struct peer_flush_params - peer flush cmd parameter + * @peer_tid_bitmap: peer tid bitmap + * @vdev_id: vdev id + */ +struct peer_flush_params { + uint32_t peer_tid_bitmap; + uint8_t vdev_id; +}; + +/** + * struct peer_set_params - peer set cmd parameter + * @param_id: parameter id + * @param_value: parameter value + * @vdev_id: vdev id + */ +struct peer_set_params { + uint32_t param_id; + uint32_t param_value; + uint32_t vdev_id; +}; + +/** + * struct peer_create_params - peer create cmd parameter + * @peer_addr: peer mac addr + * @peer_type: peer type + * @vdev_id: vdev id + */ +struct peer_create_params { + const uint8_t *peer_addr; + uint32_t peer_type; + uint32_t vdev_id; +}; + +/** + * struct peer_remove_params - peer remove cmd parameter + * @bssid: bss id + * @vdev_id: vdev id + * @roam_synch_in_progress: flag to indicate if roaming is in progress + */ +struct peer_remove_params { + uint8_t *bssid; + uint8_t vdev_id; + bool roam_synch_in_progress; +}; + +/** + * struct stats_request_params - stats_request cmd parameter + * @stats_id: statistics id + * @vdev_id: vdev id + */ +struct stats_request_params { + uint32_t stats_id; + uint32_t vdev_id; +}; + +/** + * struct green_ap_ps_params - green ap ps cmd parameter + * @value: parameter value + */ +struct green_ap_ps_params { + uint32_t value; +}; + +/** + * struct wow_cmd_params - wow cmd parameter + * @enable: wow enable or disable flag + * @can_suspend_link: flag to indicate if link can be suspended + * @pause_iface_config: interface config + */ +struct wow_cmd_params { + bool enable; + bool can_suspend_link; + uint8_t pause_iface_config; +}; + +/** + * struct packet_enable_params - packet enable cmd parameter + * @vdev_id: vdev id + * @enable: flag to indicate if parameter can be enabled or disabled + */ +struct packet_enable_params { + uint8_t vdev_id; + bool enable; +}; + +/** + * struct suspend_params - suspend cmd parameter + * @disable_target_intr: disable target interrupt + */ +struct suspend_params { + uint8_t disable_target_intr; +}; + +/** + * struct pdev_params - pdev set cmd parameter + * @param_id: parameter id + * @param_value: parameter value + */ +struct pdev_params { + uint32_t param_id; + uint32_t param_value; +}; + +/** + * struct beacon_params - beacon template cmd parameter + * @vdev_id: vdev id + * @tim_ie_offset: tim ie offset + * @tmpl_len: beacon template length + * @tmpl_len_aligned: beacon template alignment + * @frm: beacon template parameter + */ +struct beacon_params { + uint8_t vdev_id; + uint32_t tim_ie_offset; + uint32_t tmpl_len; + uint32_t tmpl_len_aligned; + uint8_t *frm; +}; + +/** + * struct peer_assoc_params - peer assoc cmd parameter + * @peer_macaddr: peer mac address + * @vdev_id: vdev id + * @peer_new_assoc: peer association type + * @peer_associd: peer association id + * @peer_flags: peer flags + * @peer_caps: peer capabalities + * @peer_listen_intval: peer listen interval + * @peer_ht_caps: HT capabalities + * @peer_max_mpdu: 0 : 8k , 1 : 16k, 2 : 32k, 3 : 64k + * @peer_mpdu_density: 3 : 0~7 : 2^(11nAMPDUdensity -4) + * @peer_rate_caps: peer rate capabalities + * @peer_nss: peer nss + * @peer_phymode: peer phymode + * @peer_ht_info: peer HT info + * @peer_legacy_rates: peer legacy rates + * @peer_ht_rates: peer ht rates + * @num_peer_legacy_rates: no of peer legacy rates + * @num_peer_ht_rates: no of peer ht rates + * @rx_max_rate: max rx rates + * @rx_mcs_set: rx mcs + * @tx_max_rate: max tx rates + * @tx_mcs_set: tx mcs + * @vht_capable: VHT capabalities + */ +struct peer_assoc_params { + wmi_mac_addr peer_macaddr; + uint32_t vdev_id; + uint32_t peer_new_assoc; + uint32_t peer_associd; + uint32_t peer_flags; + uint32_t peer_caps; + uint32_t peer_listen_intval; + uint32_t peer_ht_caps; + uint32_t peer_max_mpdu; + uint32_t peer_mpdu_density; + uint32_t peer_rate_caps; + uint32_t peer_nss; + uint32_t peer_vht_caps; + uint32_t peer_phymode; + uint32_t peer_ht_info[2]; + wmi_rate_set peer_legacy_rates; + wmi_rate_set peer_ht_rates; + uint32_t num_peer_legacy_rates; + uint32_t num_peer_ht_rates; + uint32_t rx_max_rate; + uint32_t rx_mcs_set; + uint32_t tx_max_rate; + uint32_t tx_mcs_set; + uint8_t vht_capable; +}; + +/** + * struct sta_ps_params - sta ps cmd parameter + * @vdev_id: vdev id + * @param: sta ps paramter + * @value: sta ps parameter value + */ +struct sta_ps_params { + uint32_t vdev_id; + uint32_t param; + uint32_t value; +}; + +/** + * struct ap_ps_params - ap ps cmd parameter + * @vdev_id: vdev id + * @param: ap ps paramter + * @value: ap ps paramter value + */ +struct ap_ps_params { + uint32_t vdev_id; + uint32_t param; + uint32_t value; +}; + +/** + * struct mac_ssid - mac ssid structure + * @length: + * @mac_ssid[WMI_MAC_MAX_SSID_LENGTH]: + */ +struct mac_ssid { + uint8_t length; + uint8_t mac_ssid[WMI_MAC_MAX_SSID_LENGTH]; +} cdf_packed; + +/** + * struct scan_start_params - start scan cmd parameter + * @scan_id: scan id + * @scan_req_id: requeted scan id + * @vdev_id: vdev id + * @scan_priority: scan priority + * @notify_scan_events: flag to indicate if scan to be notified + * @dwell_time_active: active dwell time + * @dwell_time_passive: passive dwell time + * @min_rest_time: min rest time + * @max_rest_time: max rest time + * @repeat_probe_time: repeat probe time + * @probe_spacing_time: probe spacing time + * @idle_time: idle time + * @max_scan_time: max scan time + * @probe_delay: probe delay + * @scan_ctrl_flags: scan control flag + * @burst_duration: burst duration + * @num_chan: no of channel + * @num_bssid: no of bssid + * @num_ssids: no of ssid + * @ie_len: ie length + * @n_probes: no of probe + * @chan_list: channel list + * @ie_len_with_pad: ie length with padding + * @num_ssid: no of ssid + * @sid: pointer to mac_ssid structure + * @uie_fieldOffset: ie field offset + * @mac_add_bytes: mac address bytes + */ +struct scan_start_params { + uint32_t scan_id; + uint32_t scan_req_id; + uint32_t vdev_id; + uint32_t scan_priority; + uint32_t notify_scan_events; + uint32_t dwell_time_active; + uint32_t dwell_time_passive; + uint32_t min_rest_time; + uint32_t max_rest_time; + uint32_t repeat_probe_time; + uint32_t probe_spacing_time; + uint32_t idle_time; + uint32_t max_scan_time; + uint32_t probe_delay; + uint32_t scan_ctrl_flags; + uint32_t burst_duration; + uint32_t num_chan; + uint32_t num_bssid; + uint32_t num_ssids; + uint32_t ie_len; + uint32_t n_probes; + uint32_t *chan_list; + uint32_t ie_len_with_pad; + struct mac_ssid ssid[WMI_SCAN_MAX_NUM_SSID]; + uint8_t *ie_base; + uint16_t uie_fieldOffset; + uint8_t mac_add_bytes[IEEE80211_ADDR_LEN]; +}; + +/** + * struct scan_stop_params - stop scan cmd parameter + * @requestor: scan requestor + * @scan_id: scan id + * @req_type: scan request type + * @vdev_id: vdev id + */ +struct scan_stop_params { + uint32_t requestor; + uint32_t scan_id; + uint32_t req_type; + uint32_t vdev_id; +}; + +/** + * struct scan_chan_list_params - scan channel list cmd parameter + * @num_scan_chans: no of scan channels + * @chan_info: pointer to wmi channel info + */ +struct scan_chan_list_params { + uint8_t num_scan_chans; + wmi_channel *chan_info; +}; + +/** + * struct fw_hang_params - fw hang command parameters + * @type: 0:unused 1: ASSERT, 2:not respond detect command, 3:simulate ep-full + * @delay_time_ms: 0xffffffff means the simulate will delay for random time (0 ~0xffffffff ms) + */ +struct fw_hang_params { + uint32_t type; + uint32_t delay_time_ms; +}; + +/** + * struct pdev_utf_params - pdev utf command parameters + * @utf_payload: + * @len: + */ +struct pdev_utf_params { + uint8_t *utf_payload; + uint32_t len; +}; + +/** + * struct crash_inject - crash inject command parameters + * @type: crash inject type + * @delay_time_ms: time in milliseconds for FW to delay the crash + */ +struct crash_inject { + uint32_t type; + uint32_t delay_time_ms; +}; + +/** + * struct dbglog_params - fw deboglog command parameters + * @param: command parameter + * @val: parameter value + * @module_id_bitmap: fixed length module id bitmap + * @bitmap_len: module id bitmap length + */ +struct dbglog_params { + uint32_t param; + uint32_t val; + uint32_t *module_id_bitmap; + uint32_t bitmap_len; +}; + +/** + * struct seg_hdr_info - header info + * @len: length + * @msgref: message refrence + * @segmentInfo: segment info + * @pad: padding + */ +struct seg_hdr_info { + uint32_t len; + uint32_t msgref; + uint32_t segmentInfo; + uint32_t pad; +}; + +/** + * struct wmi_mgmt_params - wmi mgmt cmd paramters + * @tx_frame: management tx frame + * @frmLen: frame length + * @vdev_id: vdev id + * @tx_complete_cb: tx download callback handler + * @tx_ota_post_proc_cb: OTA complition handler + * @chanfreq: channel frequency + * @pdata: frame data + * @wmi_desc: command descriptor + */ +struct wmi_mgmt_params { + void *tx_frame; + uint16_t frm_len; + uint8_t vdev_id; + void *tx_complete_cb; + void *tx_ota_post_proc_cb; + uint16_t chanfreq; + void *pdata; + struct wmi_desc_t *wmi_desc; + void *cdf_ctx; +}; +#endif /* _WMI_UNIFIED_PARAM_H_ */ + diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index 80322f8759..c530f1cbe5 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -26,7 +26,8 @@ */ /* - * This file contains the API definitions for the Unified Wireless Module Interface (WMI). + * This file contains the API definitions for the Unified Wireless + * Module Interface (WMI). */ #ifndef _WMI_UNIFIED_PRIV_H_ #define _WMI_UNIFIED_PRIV_H_ @@ -67,6 +68,109 @@ struct fwdebug { }; #endif /* WLAN_OPEN_SOURCE */ +struct wmi_ops { +int32_t (*send_vdev_create_cmd)(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct vdev_create_params *param); + +int32_t (*send_vdev_delete_cmd)(wmi_unified_t wmi_handle, + uint8_t if_id); + +int32_t (*send_vdev_stop_cmd)(wmi_unified_t wmi, + uint8_t vdev_id); + +int32_t (*send_vdev_down_cmd)(wmi_unified_t wmi, + uint8_t vdev_id); + +int32_t (*send_peer_flush_tids_cmd)(wmi_unified_t wmi, + uint8_t peer_addr[IEEE80211_ADDR_LEN], + struct peer_flush_params *param); + +int32_t (*send_peer_delete_cmd)(wmi_unified_t wmi, + uint8_t peer_addr[IEEE80211_ADDR_LEN], + uint8_t vdev_id); + +int32_t (*send_peer_param_cmd)(wmi_unified_t wmi, + uint8_t peer_addr[IEEE80211_ADDR_LEN], + struct peer_set_params *param); + +int32_t (*send_vdev_up_cmd)(wmi_unified_t wmi, + uint8_t bssid[IEEE80211_ADDR_LEN], + struct vdev_up_params *params); + +int32_t (*send_peer_create_cmd)(wmi_unified_t wmi, + struct peer_create_params *param); + +int32_t (*send_green_ap_ps_cmd)(wmi_unified_t wmi_handle, + uint32_t value, uint8_t mac_id); + +int32_t +(*send_pdev_utf_cmd)(wmi_unified_t wmi_handle, + struct pdev_utf_params *param, + uint8_t mac_id); + +int32_t +(*send_pdev_param_cmd)(wmi_unified_t wmi_handle, + struct pdev_params *param, + uint8_t mac_id); + +int32_t (*send_suspend_cmd)(wmi_unified_t wmi_handle, + struct suspend_params *param, + uint8_t mac_id); + +int32_t (*send_resume_cmd)(wmi_unified_t wmi_handle, + uint8_t mac_id); + +int32_t (*send_wow_enable_cmd)(wmi_unified_t wmi_handle, + struct wow_cmd_params *param, + uint8_t mac_id); + +int32_t (*send_set_ap_ps_param_cmd)(wmi_unified_t wmi_handle, + uint8_t *peer_addr, + struct ap_ps_params *param); + +int32_t (*send_set_sta_ps_param_cmd)(wmi_unified_t wmi_handle, + struct sta_ps_params *param); + +int32_t (*send_crash_inject_cmd)(wmi_unified_t wmi_handle, + struct crash_inject *param); + +int32_t +(*send_dbglog_cmd)(wmi_unified_t wmi_handle, + struct dbglog_params *dbglog_param); + +int32_t (*send_vdev_set_param_cmd)(wmi_unified_t wmi_handle, + struct vdev_set_params *param); + +int32_t (*send_stats_request_cmd)(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct stats_request_params *param); + +int32_t (*send_packet_log_enable_cmd)(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct packet_enable_params *param); + +int32_t (*send_beacon_send_cmd)(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct beacon_params *param); + +int32_t (*send_peer_assoc_cmd)(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct peer_assoc_params *param); + +int32_t (*send_scan_start_cmd)(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_start_params *param); + +int32_t (*send_scan_stop_cmd)(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_stop_params *param); + +int32_t (*send_scan_chan_list_cmd)(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_chan_list_params *param); +}; + struct wmi_unified { ol_scn_t scn_handle; /* handle to device */ osdev_t osdev; /* handle to use OS-independent services */ @@ -96,10 +200,11 @@ struct wmi_unified { cdf_atomic_t runtime_pm_inprogress; #endif - int (*wma_process_fw_event_handler_cbk)(struct wmi_unified *wmi_handle, - wmi_buf_t evt_buf); - struct wmi_ops ops; + struct wmi_rx_ops rx_ops; + struct wmi_ops *ops; void *event_handler_cookie[WMI_UNIFIED_MAX_EVENT]; bool use_cookie; }; +struct wmi_ops *wmi_get_tlv_ops(void); +struct wmi_ops *wmi_get_non_tlv_ops(void); #endif diff --git a/wmi/inc/wmi_unified_tlv.h b/wmi/inc/wmi_unified_tlv.h new file mode 100644 index 0000000000..298b4b626d --- /dev/null +++ b/wmi/inc/wmi_unified_tlv.h @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2016 The Linux Foundation. All rights reserved. + * + * Previously licensed under the ISC license by Qualcomm Atheros, Inc. + * + * + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all + * copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * This file was originally distributed by Qualcomm Atheros, Inc. + * under proprietary terms before Copyright ownership was assigned + * to the Linux Foundation. + */ + +#include +#include "a_types.h" +#include "wmi_unified_param.h" +#include "ol_defines.h" /* Fix Me: wmi_unified_t structure definition */ + +int32_t send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct vdev_create_params *param); + +int32_t send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t if_id); + +int32_t send_vdev_stop_cmd_tlv(wmi_unified_t wmi, + uint8_t vdev_id); + +int32_t send_vdev_down_cmd_tlv(wmi_unified_t wmi, + uint8_t vdev_id); + +int32_t send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi, + uint8_t peer_addr[IEEE80211_ADDR_LEN], + struct peer_flush_params *param); + +int32_t send_peer_delete_cmd_tlv(wmi_unified_t wmi, + uint8_t peer_addr[IEEE80211_ADDR_LEN], + uint8_t vdev_id); + +int32_t send_peer_param_cmd_tlv(wmi_unified_t wmi, + uint8_t peer_addr[IEEE80211_ADDR_LEN], + struct peer_set_params *param); + +int32_t send_vdev_up_cmd_tlv(wmi_unified_t wmi, + uint8_t bssid[IEEE80211_ADDR_LEN], + struct vdev_up_params *params); + +int32_t send_peer_create_cmd_tlv(wmi_unified_t wmi, + struct peer_create_params *param); + +int32_t send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle, + uint32_t value, uint8_t mac_id); + +int32_t +send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle, + struct pdev_utf_params *param, + uint8_t mac_id); + +int32_t +send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle, + struct pdev_params *param, + uint8_t mac_id); + +int32_t send_suspend_cmd_tlv(wmi_unified_t wmi_handle, + struct suspend_params *param, + uint8_t mac_id); + +int32_t send_resume_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t mac_id); + +int32_t send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle, + struct wow_cmd_params *param, + uint8_t mac_id); + +int32_t send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t *peer_addr, + struct ap_ps_params *param); + +int32_t send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle, + struct sta_ps_params *param); + +int32_t send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle, + struct crash_inject *param); + +int32_t +send_dbglog_cmd_tlv(wmi_unified_t wmi_handle, + struct dbglog_params *dbglog_param); + + +int32_t send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle, + struct vdev_set_params *param); + +int32_t send_stats_request_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct stats_request_params *param); + +int32_t send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct packet_enable_params *param); + +int32_t send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct beacon_params *param); + +int32_t send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct peer_assoc_params *param); + +int32_t send_scan_start_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_start_params *param); + +int32_t send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_stop_params *param); + +int32_t send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_chan_list_params *param); + diff --git a/wmi/src/wmi_unified.c b/wmi/src/wmi_unified.c index 8340c667f4..d6d2f38f0b 100644 --- a/wmi/src/wmi_unified.c +++ b/wmi/src/wmi_unified.c @@ -43,6 +43,7 @@ #include "wma_api.h" #include "wma.h" #include "mac_trace.h" +#include "wmi_unified_param.h" #define WMI_MIN_HEAD_ROOM 64 @@ -1034,7 +1035,8 @@ static void wmi_process_fw_event_mc_thread_ctx(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf; evt_buf = (wmi_buf_t) htc_packet->pPktContext; - wmi_handle->ops.wma_process_fw_event_handler_cbk(wmi_handle, evt_buf); + wmi_handle->rx_ops.wma_process_fw_event_handler_cbk(wmi_handle, + evt_buf); return; } @@ -1204,18 +1206,18 @@ void __wmi_control_rx(struct wmi_unified *wmi_handle, wmi_buf_t evt_buf) break; case WMI_SERVICE_READY_EVENTID: cdf_print("%s: WMI UNIFIED SERVICE READY event\n", __func__); - wmi_handle->ops.service_ready_cbk(wmi_handle->scn_handle, + wmi_handle->rx_ops.service_ready_cbk(wmi_handle->scn_handle, wmi_cmd_struct_ptr); break; case WMI_SERVICE_READY_EXT_EVENTID: WMA_LOGA("%s: WMI UNIFIED SERVICE READY Extended event", __func__); - wmi_handle->ops.service_ready_ext_cbk(wmi_handle->scn_handle, + wmi_handle->rx_ops.service_ready_ext_cbk(wmi_handle->scn_handle, wmi_cmd_struct_ptr); break; case WMI_READY_EVENTID: cdf_print("%s: WMI UNIFIED READY event\n", __func__); - wmi_handle->ops.ready_cbk(wmi_handle->scn_handle, + wmi_handle->rx_ops.ready_cbk(wmi_handle->scn_handle, wmi_cmd_struct_ptr); break; } @@ -1278,7 +1280,7 @@ void wmi_runtime_pm_init(struct wmi_unified *wmi_handle) */ void *wmi_unified_attach(void *scn_handle, osdev_t osdev, enum wmi_target_type target_type, - bool use_cookie, struct wmi_ops *ops) + bool use_cookie, struct wmi_rx_ops *rx_ops) { struct wmi_unified *wmi_handle; @@ -1307,20 +1309,20 @@ void *wmi_unified_attach(void *scn_handle, cdf_spinlock_init(&wmi_handle->wmi_record_lock); #endif /* Attach mc_thread context processing function */ - wmi_handle->ops.wma_process_fw_event_handler_cbk = - ops->wma_process_fw_event_handler_cbk; + wmi_handle->rx_ops.wma_process_fw_event_handler_cbk = + rx_ops->wma_process_fw_event_handler_cbk; /* Attach service ready callback function */ - wmi_handle->ops.service_ready_cbk = - ops->service_ready_cbk; + wmi_handle->rx_ops.service_ready_cbk = + rx_ops->service_ready_cbk; /* Attach service ready extended callback function */ - wmi_handle->ops.service_ready_ext_cbk = - ops->service_ready_ext_cbk; + wmi_handle->rx_ops.service_ready_ext_cbk = + rx_ops->service_ready_ext_cbk; /* Attach fw ready callback function */ - wmi_handle->ops.ready_cbk = ops->ready_cbk; + wmi_handle->rx_ops.ready_cbk = rx_ops->ready_cbk; if (target_type == WMI_TLV_TARGET) - WMA_LOGD("Target is TLV compliant"); + wmi_handle->ops = wmi_get_tlv_ops(); else - WMA_LOGD("Target is NoN-TLV compliant"); + wmi_handle->ops = wmi_get_non_tlv_ops(); /* Assign target cookie capablity */ wmi_handle->use_cookie = use_cookie; wmi_handle->osdev = osdev; diff --git a/wmi/src/wmi_unified_api.c b/wmi/src/wmi_unified_api.c new file mode 100644 index 0000000000..a0195f5862 --- /dev/null +++ b/wmi/src/wmi_unified_api.c @@ -0,0 +1,598 @@ +/* + * Copyright (c) 2016 The Linux Foundation. All rights reserved. + * + * Previously licensed under the ISC license by Qualcomm Atheros, Inc. + * + * + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all + * copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * This file was originally distributed by Qualcomm Atheros, Inc. + * under proprietary terms before Copyright ownership was assigned + * to the Linux Foundation. + */ +#include "athdefs.h" +#include "osapi_linux.h" +#include "a_types.h" +#include "a_debug.h" +#include "ol_if_athvar.h" +#include "ol_defines.h" +#include "wmi.h" +#include "wmi_unified_priv.h" +#include "wma_api.h" +#include "wmi_unified_param.h" + +/** + * wmi_unified_vdev_create_send() - send VDEV create command to fw + * @wmi_handle: wmi handle + * @param: pointer to hold vdev create parameter + * @macaddr: vdev mac address + * + * Return: 0 for success or error code + */ +int32_t wmi_unified_vdev_create_send(void *wmi_hdl, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct vdev_create_params *param) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_vdev_create_cmd) + return wmi_handle->ops->send_vdev_create_cmd(wmi_handle, + macaddr, param); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_vdev_delete_send() - send VDEV delete command to fw + * @wmi_handle: wmi handle + * @if_id: vdev id + * + * Return: 0 for success or error code + */ +int32_t wmi_unified_vdev_delete_send(void *wmi_hdl, + uint8_t if_id) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_vdev_delete_cmd) + return wmi_handle->ops->send_vdev_delete_cmd(wmi_handle, + if_id); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_vdev_stop_send() - send vdev stop command to fw + * @wmi: wmi handle + * @vdev_id: vdev id + * + * Return: 0 for success or erro code + */ +int32_t wmi_unified_vdev_stop_send(void *wmi_hdl, + uint8_t vdev_id) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_vdev_stop_cmd) + return wmi_handle->ops->send_vdev_stop_cmd(wmi_handle, + vdev_id); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_vdev_down_send() - send vdev down command to fw + * @wmi: wmi handle + * @vdev_id: vdev id + * + * Return: 0 for success or error code + */ +int32_t wmi_unified_vdev_down_send(void *wmi_hdl, uint8_t vdev_id) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_vdev_down_cmd) + return wmi_handle->ops->send_vdev_down_cmd(wmi_handle, vdev_id); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_peer_flush_tids_send() - flush peer tids packets in fw + * @wmi: wmi handle + * @peer_addr: peer mac address + * @param: pointer to hold peer flush tid parameter + * + * Return: 0 for sucess or error code + */ +int32_t wmi_unified_peer_flush_tids_send(void *wmi_hdl, + uint8_t peer_addr[IEEE80211_ADDR_LEN], + struct peer_flush_params *param) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_peer_flush_tids_cmd) + return wmi_handle->ops->send_peer_flush_tids_cmd(wmi_handle, + peer_addr, param); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_peer_delete_send() - send PEER delete command to fw + * @wmi: wmi handle + * @peer_addr: peer mac addr + * @vdev_id: vdev id + * + * Return: 0 for success or error code + */ +int32_t wmi_unified_peer_delete_send(void *wmi_hdl, + uint8_t + peer_addr[IEEE80211_ADDR_LEN], + uint8_t vdev_id) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_peer_delete_cmd) + return wmi_handle->ops->send_peer_delete_cmd(wmi_handle, + peer_addr, vdev_id); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_set_peer_param() - set peer parameter in fw + * @wmi_ctx: wmi handle + * @peer_addr: peer mac address + * @param : pointer to hold peer set parameter + * + * Return: 0 for success or error code + */ +int32_t wmi_set_peer_param_send(void *wmi_hdl, + uint8_t peer_addr[IEEE80211_ADDR_LEN], + struct peer_set_params *param) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_peer_param_cmd) + return wmi_handle->ops->send_peer_param_cmd(wmi_handle, + peer_addr, param); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_vdev_up_send() - send vdev up command in fw + * @wmi: wmi handle + * @bssid: bssid + * @vdev_up_params: pointer to hold vdev up parameter + * + * Return: 0 for success or error code + */ +int32_t wmi_unified_vdev_up_send(void *wmi_hdl, + uint8_t bssid[IEEE80211_ADDR_LEN], + struct vdev_up_params *params) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_vdev_up_cmd) + return wmi_handle->ops->send_vdev_up_cmd(wmi_handle, bssid, + params); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_peer_create_send() - send peer create command to fw + * @wmi: wmi handle + * @peer_addr: peer mac address + * @peer_type: peer type + * @vdev_id: vdev id + * + * Return: 0 for success or error code + */ +int32_t wmi_unified_peer_create_send(void *wmi_hdl, + struct peer_create_params *param) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_peer_create_cmd) + return wmi_handle->ops->send_peer_create_cmd(wmi_handle, param); + + return CDF_STATUS_E_FAILURE; +} + +#ifdef FEATURE_GREEN_AP +/** + * wmi_unified_green_ap_ps_send() - enable green ap powersave command + * @wmi_handle: wmi handle + * @value: value + * @mac_id: mac id to have radio context + * + * Return: 0 for success or error code + */ +int32_t wmi_unified_green_ap_ps_send(void *wmi_hdl, + uint32_t value, uint8_t mac_id) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_green_ap_ps_cmd) + return wmi_handle->ops->send_green_ap_ps_cmd(wmi_handle, value, + mac_id); + + return CDF_STATUS_E_FAILURE; +} +#else +int32_t wmi_unified_green_ap_ps_send(void *wmi_hdl, + uint32_t value, uint8_t mac_id) +{ + return 0; +} +#endif /* FEATURE_GREEN_AP */ + +/** + * wmi_unified_pdev_utf_cmd() - send utf command to fw + * @wmi_handle: wmi handle + * @param: pointer to pdev_utf_params + * @mac_id: mac id to have radio context + * + * Return: 0 for success or error code + */ +int32_t +wmi_unified_pdev_utf_cmd_send(void *wmi_hdl, + struct pdev_utf_params *param, + uint8_t mac_id) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_pdev_utf_cmd) + return wmi_handle->ops->send_pdev_utf_cmd(wmi_handle, param, + mac_id); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_pdev_set_param() - set pdev parameters + * @wmi_handle: wmi handle + * @param: pointer to pdev parameter + * @mac_id: radio context + * + * Return: 0 on success, errno on failure + */ +int32_t +wmi_unified_pdev_param_send(void *wmi_hdl, + struct pdev_params *param, + uint8_t mac_id) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_pdev_param_cmd) + return wmi_handle->ops->send_pdev_param_cmd(wmi_handle, param, + mac_id); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_suspend_send() - WMI suspend function + * @param wmi_handle : handle to WMI. + * @param param : pointer to hold suspend parameter + * @mac_id: radio context + * + * Return: 0 on success and -ve on failure. + */ +int32_t wmi_unified_suspend_send(void *wmi_hdl, + struct suspend_params *param, + uint8_t mac_id) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_suspend_cmd) + return wmi_handle->ops->send_suspend_cmd(wmi_handle, param, + mac_id); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_resume_send - WMI resume function + * @param wmi_handle : handle to WMI. + * @mac_id: radio context + * + * Return: 0 on success and -ve on failure. + */ +int32_t wmi_unified_resume_send(void *wmi_hdl, + uint8_t mac_id) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_resume_cmd) + return wmi_handle->ops->send_resume_cmd(wmi_handle, + mac_id); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_wow_enable_send() - WMI wow enable function + * @param wmi_handle : handle to WMI. + * @param param : pointer to hold wow enable parameter + * @mac_id: radio context + * + * Return: 0 on success and -ve on failure. + */ +int32_t wmi_unified_wow_enable_send(void *wmi_hdl, + struct wow_cmd_params *param, + uint8_t mac_id) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_wow_enable_cmd) + return wmi_handle->ops->send_wow_enable_cmd(wmi_handle, param, + mac_id); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_ap_ps_cmd_send() - set ap powersave parameters + * @wma_ctx: wma context + * @peer_addr: peer mac address + * @param: pointer to ap_ps parameter structure + * + * Return: 0 for success or error code + */ +int32_t wmi_unified_ap_ps_cmd_send(void *wmi_hdl, + uint8_t *peer_addr, + struct ap_ps_params *param) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_set_ap_ps_param_cmd) + return wmi_handle->ops->send_set_ap_ps_param_cmd(wmi_handle, + peer_addr, + param); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_sta_ps_cmd_send() - set sta powersave parameters + * @wma_ctx: wma context + * @peer_addr: peer mac address + * @param: pointer to sta_ps parameter structure + * + * Return: 0 for success or error code + */ +int32_t wmi_unified_sta_ps_cmd_send(void *wmi_hdl, + struct sta_ps_params *param) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_set_sta_ps_param_cmd) + return wmi_handle->ops->send_set_sta_ps_param_cmd(wmi_handle, + param); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_crash_inject() - inject fw crash + * @wma_handle: wma handle + * @param: ponirt to crash inject paramter structure + * + * Return: 0 for success or return error + */ +int32_t wmi_crash_inject(void *wmi_hdl, + struct crash_inject *param) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_crash_inject_cmd) + return wmi_handle->ops->send_crash_inject_cmd(wmi_handle, + param); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_dbglog_cmd_send() - set debug log level + * @param wmi_handle : handle to WMI. + * @param param : pointer to hold dbglog level parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t +wmi_unified_dbglog_cmd_send(void *wmi_hdl, + struct dbglog_params *dbglog_param) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_dbglog_cmd) + return wmi_handle->ops->send_dbglog_cmd(wmi_handle, + dbglog_param); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_vdev_set_param_send() - WMI vdev set parameter function + * @param wmi_handle : handle to WMI. + * @param macaddr : MAC address + * @param param : pointer to hold vdev set parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t wmi_unified_vdev_set_param_send(void *wmi_hdl, + struct vdev_set_params *param) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_vdev_set_param_cmd) + return wmi_handle->ops->send_vdev_set_param_cmd(wmi_handle, + param); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_stats_request_send() - WMI request stats function + * @param wmi_handle : handle to WMI. + * @param macaddr : MAC address + * @param param : pointer to hold stats request parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t wmi_unified_stats_request_send(void *wmi_hdl, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct stats_request_params *param) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_stats_request_cmd) + return wmi_handle->ops->send_stats_request_cmd(wmi_handle, + macaddr, param); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_stats_request_send() - WMI request stats function + * @param wmi_handle : handle to WMI. + * @param macaddr : MAC address + * @param param : pointer to hold stats request parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t wmi_unified_packet_log_enable_send(void *wmi_hdl, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct packet_enable_params *param) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_packet_log_enable_cmd) + return wmi_handle->ops->send_packet_log_enable_cmd(wmi_handle, + macaddr, param); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_beacon_send_cmd() - WMI beacon send function + * @param wmi_handle : handle to WMI. + * @param macaddr : MAC address + * @param param : pointer to hold beacon send cmd parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t wmi_unified_beacon_send_cmd(void *wmi_hdl, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct beacon_params *param) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_beacon_send_cmd) + return wmi_handle->ops->send_beacon_send_cmd(wmi_handle, + macaddr, param); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_peer_assoc_send() - WMI peer assoc function + * @param wmi_handle : handle to WMI. + * @param macaddr : MAC address + * @param param : pointer to peer assoc parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t wmi_unified_peer_assoc_send(void *wmi_hdl, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct peer_assoc_params *param) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_peer_assoc_cmd) + return wmi_handle->ops->send_peer_assoc_cmd(wmi_handle, + macaddr, param); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_scan_start_cmd_send() - WMI scan start function + * @param wmi_handle : handle to WMI. + * @param macaddr : MAC address + * @param param : pointer to hold scan start cmd parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t wmi_unified_scan_start_cmd_send(void *wmi_hdl, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_start_params *param) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_scan_start_cmd) + return wmi_handle->ops->send_scan_start_cmd(wmi_handle, + macaddr, param); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_scan_stop_cmd_send() - WMI scan start function + * @param wmi_handle : handle to WMI. + * @param macaddr : MAC address + * @param param : pointer to hold scan start cmd parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t wmi_unified_scan_stop_cmd_send(void *wmi_hdl, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_stop_params *param) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_scan_stop_cmd) + return wmi_handle->ops->send_scan_stop_cmd(wmi_handle, + macaddr, param); + + return CDF_STATUS_E_FAILURE; +} + +/** + * wmi_unified_scan_chan_list_cmd_send() - WMI scan channel list function + * @param wmi_handle : handle to WMI. + * @param macaddr : MAC address + * @param param : pointer to hold scan channel list parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t wmi_unified_scan_chan_list_cmd_send(void *wmi_hdl, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_chan_list_params *param) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_scan_chan_list_cmd) + return wmi_handle->ops->send_scan_chan_list_cmd(wmi_handle, + macaddr, param); + + return CDF_STATUS_E_FAILURE; +} diff --git a/wmi/src/wmi_unified_non_tlv.c b/wmi/src/wmi_unified_non_tlv.c new file mode 100644 index 0000000000..953684dc4c --- /dev/null +++ b/wmi/src/wmi_unified_non_tlv.c @@ -0,0 +1,465 @@ +/* + * Copyright (c) 2016 The Linux Foundation. All rights reserved. + * + * Previously licensed under the ISC license by Qualcomm Atheros, Inc. + * + * + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all + * copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * This file was originally distributed by Qualcomm Atheros, Inc. + * under proprietary terms before Copyright ownership was assigned + * to the Linux Foundation. + */ + +#include "wmi_unified_non_tlv.h" +#include "wmi_unified_api.h" +#include "wmi.h" +#include "wmi_unified_priv.h" + +/** + * send_vdev_create_cmd_non_tlv() - send VDEV create command to fw + * @wmi_handle: wmi handle + * @param: pointer to hold vdev create parameter + * @macaddr: vdev mac address + * + * Return: 0 for success or error code + */ +int32_t send_vdev_create_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct vdev_create_params *param) +{ + return 0; +} + +/** + * send_vdev_delete_cmd_non_tlv() - send VDEV delete command to fw + * @wmi_handle: wmi handle + * @if_id: vdev id + * + * Return: 0 for success or error code + */ +int32_t send_vdev_delete_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t if_id) +{ + return 0; +} + +/** + * send_vdev_stop_cmd_non_tlv() - send vdev stop command to fw + * @wmi: wmi handle + * @vdev_id: vdev id + * + * Return: 0 for success or erro code + */ +int32_t send_vdev_stop_cmd_non_tlv(wmi_unified_t wmi, + uint8_t vdev_id) +{ + return 0; +} + +/** + * send_vdev_down_cmd_non_tlv() - send vdev down command to fw + * @wmi: wmi handle + * @vdev_id: vdev id + * + * Return: 0 for success or error code + */ +int32_t send_vdev_down_cmd_non_tlv(wmi_unified_t wmi, uint8_t vdev_id) +{ + return 0; +} + +/** + * send_peer_flush_tids_cmd_non_tlv() - flush peer tids packets in fw + * @wmi: wmi handle + * @peer_addr: peer mac address + * @param: pointer to hold peer flush tid parameter + * + * Return: 0 for sucess or error code + */ +int32_t send_peer_flush_tids_cmd_non_tlv(wmi_unified_t wmi, + uint8_t peer_addr[IEEE80211_ADDR_LEN], + struct peer_flush_params *param) +{ + return 0; +} + +/** + * send_peer_delete_cmd_non_tlv() - send PEER delete command to fw + * @wmi: wmi handle + * @peer_addr: peer mac addr + * @vdev_id: vdev id + * + * Return: 0 for success or error code + */ +int32_t send_peer_delete_cmd_non_tlv(wmi_unified_t wmi, + uint8_t + peer_addr[IEEE80211_ADDR_LEN], + uint8_t vdev_id) +{ + return 0; +} + +/** + * send_peer_param_cmd_non_tlv() - set peer parameter in fw + * @wma_ctx: wmi handle + * @peer_addr: peer mac address + * @param : pointer to hold peer set parameter + * + * Return: 0 for success or error code + */ +int32_t send_peer_param_cmd_non_tlv(wmi_unified_t wmi, + uint8_t peer_addr[IEEE80211_ADDR_LEN], + struct peer_set_params *param) +{ + return 0; +} + +/** + * send_vdev_up_cmd_non_tlv() - send vdev up command in fw + * @wmi: wmi handle + * @bssid: bssid + * @vdev_up_params: pointer to hold vdev up parameter + * + * Return: 0 for success or error code + */ +int32_t send_vdev_up_cmd_non_tlv(wmi_unified_t wmi, + uint8_t bssid[IEEE80211_ADDR_LEN], + struct vdev_up_params *params) +{ + return 0; +} + +/** + * send_peer_create_cmd_non_tlv() - send peer create command to fw + * @wmi: wmi handle + * @peer_addr: peer mac address + * @peer_type: peer type + * @vdev_id: vdev id + * + * Return: 0 for success or error code + */ +int32_t send_peer_create_cmd_non_tlv(wmi_unified_t wmi, + struct peer_create_params *param) +{ + return 0; +} + +/** + * send_green_ap_ps_cmd_non_tlv() - enable green ap powersave command + * @wmi_handle: wmi handle + * @value: value + * @mac_id: mac id to have radio context + * + * Return: 0 for success or error code + */ +int32_t send_green_ap_ps_cmd_non_tlv(wmi_unified_t wmi_handle, + uint32_t value, uint8_t mac_id) +{ + return 0; +} + +/** + * send_pdev_utf_cmd_non_tlv() - send utf command to fw + * @wmi_handle: wmi handle + * @param: pointer to pdev_utf_params + * @mac_id: mac id to have radio context + * + * Return: 0 for success or error code + */ +int32_t +send_pdev_utf_cmd_non_tlv(wmi_unified_t wmi_handle, + struct pdev_utf_params *param, + uint8_t mac_id) +{ + return 0; +} + +/** + * send_pdev_param_cmd_non_tlv() - set pdev parameters + * @wmi_handle: wmi handle + * @param: pointer to pdev parameter + * @mac_id: radio context + * + * Return: 0 on success, errno on failure + */ +int32_t +send_pdev_param_cmd_non_tlv(wmi_unified_t wmi_handle, + struct pdev_params *param, + uint8_t mac_id) +{ + return 0; +} + +/** + * send_suspend_cmd_non_tlv() - WMI suspend function + * @wmi_handle : handle to WMI. + * @param : pointer to hold suspend parameter + * @mac_id: radio context + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_suspend_cmd_non_tlv(wmi_unified_t wmi_handle, + struct suspend_params *param, + uint8_t mac_id) +{ + + return 0; +} + +/** + * send_resume_cmd_non_tlv() - WMI resume function + * @param wmi_handle : handle to WMI. + * @mac_id: radio context + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_resume_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t mac_id) +{ + return 0; +} + +/** + * send_wow_enable_cmd_non_tlv() - WMI wow enable function + * @param wmi_handle : handle to WMI. + * @param param : pointer to hold wow enable parameter + * @mac_id: radio context + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_wow_enable_cmd_non_tlv(wmi_unified_t wmi_handle, + struct wow_cmd_params *param, + uint8_t mac_id) +{ + return 0; +} + +/** + * send_set_ap_ps_param_cmd_non_tlv() - set ap powersave parameters + * @wma_ctx: wma context + * @peer_addr: peer mac address + * @param: pointer to ap_ps parameter structure + * + * Return: 0 for success or error code + */ +int32_t send_set_ap_ps_param_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t *peer_addr, + struct ap_ps_params *param) +{ + return 0; +} + +/** + * send_set_sta_ps_param_cmd_non_tlv() - set sta powersave parameters + * @wma_ctx: wma context + * @peer_addr: peer mac address + * @param: pointer to sta_ps parameter structure + * + * Return: 0 for success or error code + */ +int32_t send_set_sta_ps_param_cmd_non_tlv(wmi_unified_t wmi_handle, + struct sta_ps_params *param) +{ + return 0; +} + +/** + * send_crash_inject_cmd_non_tlv() - inject fw crash + * @wma_handle: wma handle + * @param: ponirt to crash inject paramter structure + * + * Return: 0 for success or return error + */ +int32_t send_crash_inject_cmd_non_tlv(wmi_unified_t wmi_handle, + struct crash_inject *param) +{ + return 0; +} + +/** + * send_dbglog_cmd_non_tlv() - set debug log level + * @wmi_handle : handle to WMI. + * @param : pointer to hold dbglog level parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t +send_dbglog_cmd_non_tlv(wmi_unified_t wmi_handle, + struct dbglog_params *dbglog_param) +{ + return 0; +} + +/** + * send_vdev_set_param_cmd_non_tlv() - WMI vdev set parameter function + * @wmi_handle : handle to WMI. + * @macaddr : MAC address + * @param : pointer to hold vdev set parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_vdev_set_param_cmd_non_tlv(wmi_unified_t wmi_handle, + struct vdev_set_params *param) +{ + return 0; +} + +/** + * send_stats_request_cmd_non_tlv() - WMI request stats function + * @wmi_handle : handle to WMI. + * @macaddr : MAC address + * @param : pointer to hold stats request parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_stats_request_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct stats_request_params *param) +{ + return 0; +} + +/** + * send_packet_log_enable_cmd_non_tlv() - WMI request stats function + * @wmi_handle : handle to WMI. + * @macaddr : MAC address + * @param : pointer to hold stats request parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_packet_log_enable_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct packet_enable_params *param) +{ + return 0; +} + +/** + * send_beacon_send_cmd_non_tlv() - WMI beacon send function + * @wmi_handle : handle to WMI. + * @macaddr : MAC address + * @param : pointer to hold beacon send cmd parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_beacon_send_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct beacon_params *param) +{ + return 0; +} + +/** + * send_peer_assoc_cmd_non_tlv() - WMI peer assoc function + * @wmi_handle : handle to WMI. + * @macaddr : MAC address + * @param : pointer to peer assoc parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_peer_assoc_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct peer_assoc_params *param) +{ + return 0; +} + +/** + * send_scan_start_cmd_non_tlv() - WMI scan start function + * @wmi_handle : handle to WMI. + * @macaddr : MAC address + * @param : pointer to hold scan start cmd parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_scan_start_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_start_params *param) +{ + return 0; +} + +/** + * send_scan_stop_cmd_non_tlv() - WMI scan start function + * @wmi_handle : handle to WMI. + * @macaddr : MAC address + * @param : pointer to hold scan start cmd parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_scan_stop_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_stop_params *param) +{ + return 0; +} + +/** + * send_scan_chan_list_cmd_non_tlv() - WMI scan channel list function + * @wmi_handle : handle to WMI. + * @macaddr : MAC address + * @param : pointer to hold scan channel list parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_scan_chan_list_cmd_non_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_chan_list_params *param) +{ + return 0; +} + +struct wmi_ops non_tlv_ops = { + .send_vdev_create_cmd = send_vdev_create_cmd_non_tlv, + .send_vdev_delete_cmd = send_vdev_delete_cmd_non_tlv, + .send_vdev_down_cmd = send_vdev_down_cmd_non_tlv, + .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_non_tlv, + .send_peer_param_cmd = send_peer_param_cmd_non_tlv, + .send_vdev_up_cmd = send_vdev_up_cmd_non_tlv, + .send_peer_create_cmd = send_peer_create_cmd_non_tlv, + .send_green_ap_ps_cmd = send_green_ap_ps_cmd_non_tlv, + .send_pdev_utf_cmd = send_pdev_utf_cmd_non_tlv, + .send_pdev_param_cmd = send_pdev_param_cmd_non_tlv, + .send_suspend_cmd = send_suspend_cmd_non_tlv, + .send_resume_cmd = send_resume_cmd_non_tlv, + .send_wow_enable_cmd = send_wow_enable_cmd_non_tlv, + .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_non_tlv, + .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_non_tlv, + .send_crash_inject_cmd = send_crash_inject_cmd_non_tlv, + .send_dbglog_cmd = send_dbglog_cmd_non_tlv, + .send_vdev_set_param_cmd = send_vdev_set_param_cmd_non_tlv, + .send_stats_request_cmd = send_stats_request_cmd_non_tlv, + .send_packet_log_enable_cmd = send_packet_log_enable_cmd_non_tlv, + .send_beacon_send_cmd = send_beacon_send_cmd_non_tlv, + .send_peer_assoc_cmd = send_peer_assoc_cmd_non_tlv, + .send_scan_start_cmd = send_scan_start_cmd_non_tlv, + .send_scan_stop_cmd = send_scan_stop_cmd_non_tlv, + .send_scan_chan_list_cmd = send_scan_chan_list_cmd_non_tlv + +}; + +/** + * wmi_get_non_tlv_ops() - gives pointer to wmi tlv ops + * + * Return: pointer to wmi tlv ops + */ +struct wmi_ops *wmi_get_non_tlv_ops(void) +{ + return &non_tlv_ops; +} + diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c new file mode 100644 index 0000000000..46d33e1258 --- /dev/null +++ b/wmi/src/wmi_unified_tlv.c @@ -0,0 +1,1052 @@ +/* + * Copyright (c) 2016 The Linux Foundation. All rights reserved. + * + * Previously licensed under the ISC license by Qualcomm Atheros, Inc. + * + * + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all + * copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * This file was originally distributed by Qualcomm Atheros, Inc. + * under proprietary terms before Copyright ownership was assigned + * to the Linux Foundation. + */ + +#include "wmi_unified_tlv.h" +#include "wmi_unified_api.h" +#include "wmi.h" +#include "wmi_unified_priv.h" +#include "wma_api.h" +#include "wma.h" + +/** + * send_vdev_create_cmd_tlv() - send VDEV create command to fw + * @wmi_handle: wmi handle + * @param: pointer to hold vdev create parameter + * @macaddr: vdev mac address + * + * Return: 0 for success or error code + */ +int32_t send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct vdev_create_params *param) +{ + wmi_vdev_create_cmd_fixed_param *cmd; + wmi_buf_t buf; + int32_t len = sizeof(*cmd); + int32_t ret; + + buf = wmi_buf_alloc(wmi_handle, len); + if (!buf) { + WMA_LOGP("%s:wmi_buf_alloc failed", __func__); + return -ENOMEM; + } + cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_vdev_create_cmd_fixed_param)); + cmd->vdev_id = param->if_id; + cmd->vdev_type = param->type; + cmd->vdev_subtype = param->subtype; + WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr); + WMA_LOGD("%s: ID = %d VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x", + __func__, param->if_id, + macaddr[0], macaddr[1], macaddr[2], + macaddr[3], macaddr[4], macaddr[5]); + ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID); + if (ret != EOK) { + WMA_LOGE("Failed to send WMI_VDEV_CREATE_CMDID"); + wmi_buf_free(buf); + } + + return ret; +} + +/** + * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw + * @wmi_handle: wmi handle + * @if_id: vdev id + * + * Return: 0 for success or error code + */ +int32_t send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t if_id) +{ + wmi_vdev_delete_cmd_fixed_param *cmd; + wmi_buf_t buf; + int32_t ret; + + buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd)); + if (!buf) { + WMA_LOGP("%s:wmi_buf_alloc failed", __func__); + return -ENOMEM; + } + + cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_vdev_delete_cmd_fixed_param)); + cmd->vdev_id = if_id; + ret = wmi_unified_cmd_send(wmi_handle, buf, + sizeof(wmi_vdev_delete_cmd_fixed_param), + WMI_VDEV_DELETE_CMDID); + if (ret != EOK) { + WMA_LOGE("Failed to send WMI_VDEV_DELETE_CMDID"); + wmi_buf_free(buf); + } + WMA_LOGD("%s:vdev id = %d", __func__, if_id); + + return ret; +} + +/** + * send_vdev_stop_cmd_tlv() - send vdev stop command to fw + * @wmi: wmi handle + * @vdev_id: vdev id + * + * Return: 0 for success or erro code + */ +int32_t send_vdev_stop_cmd_tlv(wmi_unified_t wmi, + uint8_t vdev_id) +{ + wmi_vdev_stop_cmd_fixed_param *cmd; + wmi_buf_t buf; + int32_t len = sizeof(*cmd); + + buf = wmi_buf_alloc(wmi, len); + if (!buf) { + WMA_LOGP("%s : wmi_buf_alloc failed", __func__); + return -ENOMEM; + } + cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param)); + cmd->vdev_id = vdev_id; + if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) { + WMA_LOGP("%s: Failed to send vdev stop command", __func__); + cdf_nbuf_free(buf); + return -EIO; + } + + return 0; +} + +/** + * send_vdev_down_cmd_tlv() - send vdev down command to fw + * @wmi: wmi handle + * @vdev_id: vdev id + * + * Return: 0 for success or error code + */ +int32_t send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id) +{ + wmi_vdev_down_cmd_fixed_param *cmd; + wmi_buf_t buf; + int32_t len = sizeof(*cmd); + + buf = wmi_buf_alloc(wmi, len); + if (!buf) { + WMA_LOGP("%s : wmi_buf_alloc failed", __func__); + return -ENOMEM; + } + cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param)); + cmd->vdev_id = vdev_id; + if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) { + WMA_LOGP("%s: Failed to send vdev down", __func__); + cdf_nbuf_free(buf); + return -EIO; + } + WMA_LOGD("%s: vdev_id %d", __func__, vdev_id); + + return 0; +} + +/** + * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw + * @wmi: wmi handle + * @peer_addr: peer mac address + * @param: pointer to hold peer flush tid parameter + * + * Return: 0 for sucess or error code + */ +int32_t send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi, + uint8_t peer_addr[IEEE80211_ADDR_LEN], + struct peer_flush_params *param) +{ + wmi_peer_flush_tids_cmd_fixed_param *cmd; + wmi_buf_t buf; + int32_t len = sizeof(*cmd); + + buf = wmi_buf_alloc(wmi, len); + if (!buf) { + WMA_LOGP("%s: wmi_buf_alloc failed", __func__); + return -ENOMEM; + } + cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_peer_flush_tids_cmd_fixed_param)); + WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr); + cmd->peer_tid_bitmap = param->peer_tid_bitmap; + cmd->vdev_id = param->vdev_id; + WMA_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__, + peer_addr, param->vdev_id, + param->peer_tid_bitmap); + if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) { + WMA_LOGP("%s: Failed to send flush tid command", __func__); + cdf_nbuf_free(buf); + return -EIO; + } + + return 0; +} + +/** + * send_peer_delete_cmd_tlv() - send PEER delete command to fw + * @wmi: wmi handle + * @peer_addr: peer mac addr + * @vdev_id: vdev id + * + * Return: 0 for success or error code + */ +int32_t send_peer_delete_cmd_tlv(wmi_unified_t wmi, + uint8_t peer_addr[IEEE80211_ADDR_LEN], + uint8_t vdev_id) +{ + wmi_peer_delete_cmd_fixed_param *cmd; + wmi_buf_t buf; + int32_t len = sizeof(*cmd); + buf = wmi_buf_alloc(wmi, len); + if (!buf) { + WMA_LOGP("%s: wmi_buf_alloc failed", __func__); + return -ENOMEM; + } + cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_peer_delete_cmd_fixed_param)); + WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr); + cmd->vdev_id = vdev_id; + + if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) { + WMA_LOGP("%s: Failed to send peer delete command", __func__); + cdf_nbuf_free(buf); + return -EIO; + } + WMA_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id); + + return 0; +} + +/** + * send_peer_param_cmd_tlv() - set peer parameter in fw + * @wma_ctx: wmi handle + * @peer_addr: peer mac address + * @param : pointer to hold peer set parameter + * + * Return: 0 for success or error code + */ +int32_t send_peer_param_cmd_tlv(wmi_unified_t wmi, + uint8_t peer_addr[IEEE80211_ADDR_LEN], + struct peer_set_params *param) +{ + wmi_peer_set_param_cmd_fixed_param *cmd; + wmi_buf_t buf; + int32_t err; + + buf = wmi_buf_alloc(wmi, sizeof(*cmd)); + if (!buf) { + WMA_LOGE("Failed to allocate buffer to send set_param cmd"); + return -ENOMEM; + } + cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_peer_set_param_cmd_fixed_param)); + cmd->vdev_id = param->vdev_id; + WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr); + cmd->param_id = param->param_id; + cmd->param_value = param->param_value; + err = wmi_unified_cmd_send(wmi, buf, + sizeof(wmi_peer_set_param_cmd_fixed_param), + WMI_PEER_SET_PARAM_CMDID); + if (err) { + WMA_LOGE("Failed to send set_param cmd"); + cdf_mem_free(buf); + return -EIO; + } + + return 0; +} + +/** + * send_vdev_up_cmd_tlv() - send vdev up command in fw + * @wmi: wmi handle + * @bssid: bssid + * @vdev_up_params: pointer to hold vdev up parameter + * + * Return: 0 for success or error code + */ +int32_t send_vdev_up_cmd_tlv(wmi_unified_t wmi, + uint8_t bssid[IEEE80211_ADDR_LEN], + struct vdev_up_params *params) +{ + wmi_vdev_up_cmd_fixed_param *cmd; + wmi_buf_t buf; + int32_t len = sizeof(*cmd); + + WMA_LOGD("%s: VDEV_UP", __func__); + WMA_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__, + params->vdev_id, params->assoc_id, bssid); + buf = wmi_buf_alloc(wmi, len); + if (!buf) { + WMA_LOGP("%s: wmi_buf_alloc failed", __func__); + return -ENOMEM; + } + cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param)); + cmd->vdev_id = params->vdev_id; + cmd->vdev_assoc_id = params->assoc_id; + WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid); + if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) { + WMA_LOGP("%s: Failed to send vdev up command", __func__); + cdf_nbuf_free(buf); + return -EIO; + } + + return 0; +} + +/** + * send_peer_create_cmd_tlv() - send peer create command to fw + * @wmi: wmi handle + * @peer_addr: peer mac address + * @peer_type: peer type + * @vdev_id: vdev id + * + * Return: 0 for success or error code + */ +int32_t send_peer_create_cmd_tlv(wmi_unified_t wmi, + struct peer_create_params *param) +{ + wmi_peer_create_cmd_fixed_param *cmd; + wmi_buf_t buf; + int32_t len = sizeof(*cmd); + + buf = wmi_buf_alloc(wmi, len); + if (!buf) { + WMA_LOGP("%s: wmi_buf_alloc failed", __func__); + return -ENOMEM; + } + cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_peer_create_cmd_fixed_param)); + WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr); + cmd->peer_type = param->peer_type; + cmd->vdev_id = param->vdev_id; + + if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) { + WMA_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__); + cdf_nbuf_free(buf); + return -EIO; + } + WMA_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr, + param->vdev_id); + + return 0; +} + +/** + * send_green_ap_ps_cmd_tlv() - enable green ap powersave command + * @wmi_handle: wmi handle + * @value: value + * @mac_id: mac id to have radio context + * + * Return: 0 for success or error code + */ +int32_t send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle, + uint32_t value, uint8_t mac_id) +{ + wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd; + wmi_buf_t buf; + int32_t len = sizeof(*cmd); + + WMA_LOGD("Set Green AP PS val %d", value); + + buf = wmi_buf_alloc(wmi_handle, len); + if (!buf) { + WMA_LOGP("%s: Green AP PS Mem Alloc Failed", __func__); + return -ENOMEM; + } + + cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_pdev_green_ap_ps_enable_cmd_fixed_param)); + cmd->reserved0 = 0; + cmd->enable = value; + + if (wmi_unified_cmd_send(wmi_handle, buf, len, + WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) { + WMA_LOGE("Set Green AP PS param Failed val %d", value); + cdf_nbuf_free(buf); + return -EIO; + } + + return 0; +} + +/** + * send_pdev_utf_cmd_tlv() - send utf command to fw + * @wmi_handle: wmi handle + * @param: pointer to pdev_utf_params + * @mac_id: mac id to have radio context + * + * Return: 0 for success or error code + */ +int32_t +send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle, + struct pdev_utf_params *param, + uint8_t mac_id) +{ + wmi_buf_t buf; + uint8_t *cmd; + int32_t ret = 0; + static uint8_t msgref = 1; + uint8_t segNumber = 0, segInfo, numSegments; + uint16_t chunk_len, total_bytes; + uint8_t *bufpos; + struct seg_hdr_info segHdrInfo; + + bufpos = param->utf_payload; + total_bytes = param->len; + ASSERT(total_bytes / MAX_WMI_UTF_LEN == + (uint8_t) (total_bytes / MAX_WMI_UTF_LEN)); + numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN); + + if (param->len - (numSegments * MAX_WMI_UTF_LEN)) + numSegments++; + + while (param->len) { + if (param->len > MAX_WMI_UTF_LEN) + chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */ + else + chunk_len = param->len; + + buf = wmi_buf_alloc(wmi_handle, + (chunk_len + sizeof(segHdrInfo) + + WMI_TLV_HDR_SIZE)); + if (!buf) { + WMA_LOGE("%s:wmi_buf_alloc failed", __func__); + return -ENOMEM; + } + + cmd = (uint8_t *) wmi_buf_data(buf); + + segHdrInfo.len = total_bytes; + segHdrInfo.msgref = msgref; + segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF); + segHdrInfo.segmentInfo = segInfo; + segHdrInfo.pad = 0; + + WMA_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d," + " segHdrInfo.segmentInfo = %d", + __func__, segHdrInfo.len, segHdrInfo.msgref, + segHdrInfo.segmentInfo); + + WMA_LOGD("%s:total_bytes %d segNumber %d totalSegments %d" + "chunk len %d", __func__, total_bytes, segNumber, + numSegments, chunk_len); + + segNumber++; + + WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, + (chunk_len + sizeof(segHdrInfo))); + cmd += WMI_TLV_HDR_SIZE; + memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */ + memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len); + + ret = wmi_unified_cmd_send(wmi_handle, buf, + (chunk_len + sizeof(segHdrInfo) + + WMI_TLV_HDR_SIZE), + WMI_PDEV_UTF_CMDID); + + if (ret != EOK) { + WMA_LOGE("Failed to send WMI_PDEV_UTF_CMDID command"); + wmi_buf_free(buf); + break; + } + + param->len -= chunk_len; + bufpos += chunk_len; + } + + msgref++; + + return ret; +} + +/** + * send_pdev_param_cmd_tlv() - set pdev parameters + * @wmi_handle: wmi handle + * @param: pointer to pdev parameter + * @mac_id: radio context + * + * Return: 0 on success, errno on failure + */ +int32_t +send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle, + struct pdev_params *param, + uint8_t mac_id) +{ + int32_t ret; + wmi_pdev_set_param_cmd_fixed_param *cmd; + wmi_buf_t buf; + uint16_t len = sizeof(*cmd); + + buf = wmi_buf_alloc(wmi_handle, len); + if (!buf) { + WMA_LOGE("%s:wmi_buf_alloc failed", __func__); + return -ENOMEM; + } + cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_pdev_set_param_cmd_fixed_param)); + cmd->reserved0 = 0; + cmd->param_id = param->param_id; + cmd->param_value = param->param_value; + WMA_LOGD("Setting pdev param = %x, value = %u", param->param_id, + param->param_value); + ret = wmi_unified_cmd_send(wmi_handle, buf, len, + WMI_PDEV_SET_PARAM_CMDID); + if (ret != EOK) { + WMA_LOGE("Failed to send set param command ret = %d", ret); + wmi_buf_free(buf); + } + return ret; +} + +/** + * send_suspend_cmd_tlv() - WMI suspend function + * @param wmi_handle : handle to WMI. + * @param param : pointer to hold suspend parameter + * @mac_id: radio context + * + * Return 0 on success and -ve on failure. + */ +int32_t send_suspend_cmd_tlv(wmi_unified_t wmi_handle, + struct suspend_params *param, + uint8_t mac_id) +{ + wmi_pdev_suspend_cmd_fixed_param *cmd; + wmi_buf_t wmibuf; + uint32_t len = sizeof(*cmd); + int32_t ret; + + /* + * send the comand to Target to ignore the + * PCIE reset so as to ensure that Host and target + * states are in sync + */ + wmibuf = wmi_buf_alloc(wmi_handle, len); + if (wmibuf == NULL) + return -ENOMEM; + + cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_pdev_suspend_cmd_fixed_param)); + if (param->disable_target_intr) + cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR; + else + cmd->suspend_opt = WMI_PDEV_SUSPEND; + ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len, + WMI_PDEV_SUSPEND_CMDID); + if (ret < 0) { + cdf_nbuf_free(wmibuf); + WMA_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command"); + } + + return ret; +} + +/** + * send_resume_cmd_tlv() - WMI resume function + * @param wmi_handle : handle to WMI. + * @mac_id: radio context + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_resume_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t mac_id) +{ + wmi_buf_t wmibuf; + wmi_pdev_resume_cmd_fixed_param *cmd; + int32_t ret; + + wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd)); + if (wmibuf == NULL) + return -ENOMEM; + cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_pdev_resume_cmd_fixed_param)); + cmd->reserved0 = 0; + ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd), + WMI_PDEV_RESUME_CMDID); + if (ret != EOK) { + WMA_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command"); + wmi_buf_free(wmibuf); + } + + return ret; +} + +/** + * send_wow_enable_cmd_tlv() - WMI wow enable function + * @param wmi_handle : handle to WMI. + * @param param : pointer to hold wow enable parameter + * @mac_id: radio context + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle, + struct wow_cmd_params *param, + uint8_t mac_id) +{ + wmi_wow_enable_cmd_fixed_param *cmd; + wmi_buf_t buf; + int32_t len; + int32_t ret; + + len = sizeof(wmi_wow_enable_cmd_fixed_param); + + buf = wmi_buf_alloc(wmi_handle, len); + if (!buf) { + WMA_LOGE("%s: Failed allocate wmi buffer", __func__); + return CDF_STATUS_E_NOMEM; + } + cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_wow_enable_cmd_fixed_param)); + cmd->enable = param->enable; + if (param->can_suspend_link) + cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED; + else + cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED; + + WMA_LOGI("suspend type: %s", + cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ? + "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED"); + + ret = wmi_unified_cmd_send(wmi_handle, buf, len, + WMI_WOW_ENABLE_CMDID); + if (ret) + wmi_buf_free(buf); + + return ret; +} + +/** + * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters + * @wma_ctx: wma context + * @peer_addr: peer mac address + * @param: pointer to ap_ps parameter structure + * + * Return: 0 for success or error code + */ +int32_t send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t *peer_addr, + struct ap_ps_params *param) +{ + wmi_ap_ps_peer_cmd_fixed_param *cmd; + wmi_buf_t buf; + int32_t err; + + buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd)); + if (!buf) { + WMA_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd"); + return -ENOMEM; + } + cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_ap_ps_peer_cmd_fixed_param)); + cmd->vdev_id = param->vdev_id; + WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr); + cmd->param = param->param; + cmd->value = param->value; + err = wmi_unified_cmd_send(wmi_handle, buf, + sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID); + if (err) { + WMA_LOGE("Failed to send set_ap_ps_param cmd"); + cdf_mem_free(buf); + return -EIO; + } + + return 0; +} + +/** + * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters + * @wma_ctx: wma context + * @peer_addr: peer mac address + * @param: pointer to sta_ps parameter structure + * + * Return: 0 for success or error code + */ +int32_t send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle, + struct sta_ps_params *param) +{ + wmi_sta_powersave_param_cmd_fixed_param *cmd; + wmi_buf_t buf; + int32_t len = sizeof(*cmd); + + buf = wmi_buf_alloc(wmi_handle, len); + if (!buf) { + WMA_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__); + return -ENOMEM; + } + + cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_sta_powersave_param_cmd_fixed_param)); + cmd->vdev_id = param->vdev_id; + cmd->param = param->param; + cmd->value = param->value; + + if (wmi_unified_cmd_send(wmi_handle, buf, len, + WMI_STA_POWERSAVE_PARAM_CMDID)) { + WMA_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d", + param->vdev_id, param->param, param->value); + cdf_nbuf_free(buf); + return -EIO; + } + + return 0; +} + +/** + * send_crash_inject_cmd_tlv() - inject fw crash + * @wma_handle: wma handle + * @param: ponirt to crash inject paramter structure + * + * Return: 0 for success or return error + */ +int32_t send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle, + struct crash_inject *param) +{ + int32_t ret = 0; + WMI_FORCE_FW_HANG_CMD_fixed_param *cmd; + uint16_t len = sizeof(*cmd); + wmi_buf_t buf; + + buf = wmi_buf_alloc(wmi_handle, len); + if (!buf) { + WMA_LOGE("%s: wmi_buf_alloc failed!", __func__); + return -ENOMEM; + } + + cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (WMI_FORCE_FW_HANG_CMD_fixed_param)); + cmd->type = param->type; + cmd->delay_time_ms = param->delay_time_ms; + + ret = wmi_unified_cmd_send(wmi_handle, buf, len, + WMI_FORCE_FW_HANG_CMDID); + if (ret < 0) { + WMA_LOGE("%s: Failed to send set param command, ret = %d", + __func__, ret); + wmi_buf_free(buf); + } + + return ret; +} + +/** + * send_dbglog_cmd_tlv() - set debug log level + * @param wmi_handle : handle to WMI. + * @param param : pointer to hold dbglog level parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t +send_dbglog_cmd_tlv(wmi_unified_t wmi_handle, + struct dbglog_params *dbglog_param) +{ + wmi_buf_t buf; + wmi_debug_log_config_cmd_fixed_param *configmsg; + A_STATUS status = A_OK; + int32_t i; + int32_t len; + int8_t *buf_ptr; + int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */ + + ASSERT(bitmap_len < MAX_MODULE_ID_BITMAP_WORDS); + + /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */ + len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE + + (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS); + buf = wmi_buf_alloc(wmi_handle, len); + if (buf == NULL) + return A_NO_MEMORY; + + configmsg = + (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf)); + buf_ptr = (int8_t *) configmsg; + WMITLV_SET_HDR(&configmsg->tlv_header, + WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_debug_log_config_cmd_fixed_param)); + configmsg->dbg_log_param = dbglog_param->param; + configmsg->value = dbglog_param->val; + /* Filling in the data part of second tlv -- should + * follow first tlv _ WMI_TLV_HDR_SIZE */ + module_id_bitmap_array = (A_UINT32 *) (buf_ptr + + sizeof + (wmi_debug_log_config_cmd_fixed_param) + + WMI_TLV_HDR_SIZE); + WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param), + WMITLV_TAG_ARRAY_UINT32, + sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS); + if (dbglog_param->module_id_bitmap) { + for (i = 0; i < dbglog_param->bitmap_len; ++i) { + module_id_bitmap_array[i] = + dbglog_param->module_id_bitmap[i]; + } + } + + status = wmi_unified_cmd_send(wmi_handle, buf, + len, WMI_DBGLOG_CFG_CMDID); + + if (status != A_OK) + cdf_nbuf_free(buf); + + return status; +} + +/** + * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function + * @param wmi_handle : handle to WMI. + * @param macaddr : MAC address + * @param param : pointer to hold vdev set parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle, + struct vdev_set_params *param) +{ + int32_t ret; + wmi_vdev_set_param_cmd_fixed_param *cmd; + wmi_buf_t buf; + uint16_t len = sizeof(*cmd); + + buf = wmi_buf_alloc(wmi_handle, len); + if (!buf) { + WMA_LOGE("%s:wmi_buf_alloc failed", __func__); + return -ENOMEM; + } + cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf); + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_vdev_set_param_cmd_fixed_param)); + cmd->vdev_id = param->if_id; + cmd->param_id = param->param_id; + cmd->param_value = param->param_value; + WMA_LOGD("Setting vdev %d param = %x, value = %u", + param->if_id, param->param_id, param->param_value); + ret = wmi_unified_cmd_send(wmi_handle, buf, len, + WMI_VDEV_SET_PARAM_CMDID); + if (ret < 0) { + WMA_LOGE("Failed to send set param command ret = %d", ret); + wmi_buf_free(buf); + } + + return ret; +} + +/** + * send_stats_request_cmd_tlv() - WMI request stats function + * @param wmi_handle : handle to WMI. + * @param macaddr : MAC address + * @param param : pointer to hold stats request parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_stats_request_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct stats_request_params *param) +{ + return 0; +} + +/** + * send_packet_log_enable_cmd_tlv() - WMI request stats function + * @param wmi_handle : handle to WMI. + * @param macaddr : MAC address + * @param param : pointer to hold stats request parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct packet_enable_params *param) +{ + return 0; +} + +/** + * send_beacon_send_cmd_tlv() - WMI beacon send function + * @param wmi_handle : handle to WMI. + * @param macaddr : MAC address + * @param param : pointer to hold beacon send cmd parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct beacon_params *param) +{ + return 0; +} + +/** + * send_peer_assoc_cmd_tlv() - WMI peer assoc function + * @param wmi_handle : handle to WMI. + * @param macaddr : MAC address + * @param param : pointer to peer assoc parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct peer_assoc_params *param) +{ + return 0; +} + +/** + * send_scan_start_cmd_tlv() - WMI scan start function + * @param wmi_handle : handle to WMI. + * @param macaddr : MAC address + * @param param : pointer to hold scan start cmd parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_scan_start_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_start_params *param) +{ + return 0; +} + +/** + * send_scan_stop_cmd_tlv() - WMI scan start function + * @param wmi_handle : handle to WMI. + * @param macaddr : MAC address + * @param param : pointer to hold scan start cmd parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_stop_params *param) +{ + return 0; +} + +/** + * send_scan_chan_list_cmd_tlv() - WMI scan channel list function + * @param wmi_handle : handle to WMI. + * @param macaddr : MAC address + * @param param : pointer to hold scan channel list parameter + * + * Return: 0 on success and -ve on failure. + */ +int32_t send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle, + uint8_t macaddr[IEEE80211_ADDR_LEN], + struct scan_chan_list_params *param) +{ + return 0; +} + +struct wmi_ops tlv_ops = { + .send_vdev_create_cmd = send_vdev_create_cmd_tlv, + .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv, + .send_vdev_down_cmd = send_vdev_down_cmd_tlv, + .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv, + .send_peer_param_cmd = send_peer_param_cmd_tlv, + .send_vdev_up_cmd = send_vdev_up_cmd_tlv, + .send_peer_create_cmd = send_peer_create_cmd_tlv, + .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv, + .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv, + .send_pdev_param_cmd = send_pdev_param_cmd_tlv, + .send_suspend_cmd = send_suspend_cmd_tlv, + .send_resume_cmd = send_resume_cmd_tlv, + .send_wow_enable_cmd = send_wow_enable_cmd_tlv, + .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv, + .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv, + .send_crash_inject_cmd = send_crash_inject_cmd_tlv, + .send_dbglog_cmd = send_dbglog_cmd_tlv, + .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv, + .send_stats_request_cmd = send_stats_request_cmd_tlv, + .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv, + .send_beacon_send_cmd = send_beacon_send_cmd_tlv, + .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv, + .send_scan_start_cmd = send_scan_start_cmd_tlv, + .send_scan_stop_cmd = send_scan_stop_cmd_tlv, + .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv, + + /* TODO - Add other tlv apis here */ +}; + +/** + * wmi_get_tlv_ops() - gives pointer to wmi tlv ops + * + * Return: pointer to wmi tlv ops + */ +struct wmi_ops *wmi_get_tlv_ops(void) +{ + return &tlv_ops; +} +