blob: ba8fdc394cfa359b7357689982afd50a5f6adc33 [file] [log] [blame]
Govind Singh5eb51532016-03-09 11:34:12 +05301/*
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -08002 * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
Govind Singh5eb51532016-03-09 11:34:12 +05303 *
Govind Singh5eb51532016-03-09 11:34:12 +05304 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
Govind Singh5eb51532016-03-09 11:34:12 +053019#include "wmi_unified_api.h"
20#include "wmi.h"
Govind Singh224a7312016-06-21 14:33:26 +053021#include "wmi_version.h"
Govind Singh5eb51532016-03-09 11:34:12 +053022#include "wmi_unified_priv.h"
Govind Singha4836fd2016-03-07 16:45:38 +053023#include "wmi_version_whitelist.h"
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080024#include <qdf_module.h>
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053025#include <wlan_defs.h>
Wu Gao5d1c9ed2018-10-12 18:16:09 +080026#include <wlan_cmn.h>
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053027#include <htc_services.h>
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053028#ifdef FEATURE_WLAN_APF
Nachiket Kukade7d4f04b2018-05-21 17:28:32 +053029#include "wmi_unified_apf_tlv.h"
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053030#endif
Rajeev Kumar Sirasanagandladaadf832017-09-18 16:47:52 +053031#ifdef WLAN_FEATURE_ACTION_OUI
32#include "wmi_unified_action_oui_tlv.h"
33#endif
Wu Gao52c0b772018-05-17 16:14:00 +080034#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Dustin Brownf31f88b2017-05-12 14:01:44 -070035#include "wlan_pmo_hw_filter_public_struct.h"
36#endif
Abhishek Singh5987b632017-03-03 22:09:07 +053037#include <wlan_utility.h>
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053038#ifdef WLAN_SUPPORT_GREEN_AP
39#include "wlan_green_ap_api.h"
40#endif
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053041
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070042#include "wmi_unified_twt_api.h"
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080043
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080044#ifdef WLAN_POLICY_MGR_ENABLE
45#include "wlan_policy_mgr_public_struct.h"
46#endif
47
Sathish Kumarefb25bf2018-10-02 11:03:59 +053048#ifdef WMI_SMART_ANT_SUPPORT
49#include "wmi_unified_smart_ant_api.h"
50#endif
51
52#ifdef WMI_DBR_SUPPORT
53#include "wmi_unified_dbr_api.h"
54#endif
55
56#ifdef WMI_ATF_SUPPORT
57#include "wmi_unified_atf_api.h"
58#endif
59
60#ifdef WMI_AP_SUPPORT
61#include "wmi_unified_ap_api.h"
62#endif
63
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053064/* HTC service ids for WMI for multi-radio */
65static const uint32_t multi_svc_ids[] = {WMI_CONTROL_SVC,
66 WMI_CONTROL_SVC_WMAC1,
67 WMI_CONTROL_SVC_WMAC2};
68
Arif Hussainb522ac92018-06-27 10:51:06 -070069/**
70 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
Sathish Kumarefb25bf2018-10-02 11:03:59 +053071 * host to target defines.
Arif Hussainb522ac92018-06-27 10:51:06 -070072 * @param pdev_id: host pdev_id to be converted.
73 * Return: target pdev_id after conversion.
74 */
75static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
76{
77 switch (pdev_id) {
78 case WMI_HOST_PDEV_ID_SOC:
79 return WMI_PDEV_ID_SOC;
80 case WMI_HOST_PDEV_ID_0:
81 return WMI_PDEV_ID_1ST;
82 case WMI_HOST_PDEV_ID_1:
83 return WMI_PDEV_ID_2ND;
84 case WMI_HOST_PDEV_ID_2:
85 return WMI_PDEV_ID_3RD;
86 }
87
88 QDF_ASSERT(0);
89
90 return WMI_PDEV_ID_SOC;
91}
92
93/**
94 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
Sathish Kumarefb25bf2018-10-02 11:03:59 +053095 * target to host defines.
Arif Hussainb522ac92018-06-27 10:51:06 -070096 * @param pdev_id: target pdev_id to be converted.
97 * Return: host pdev_id after conversion.
98 */
99static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
100{
101 switch (pdev_id) {
102 case WMI_PDEV_ID_SOC:
103 return WMI_HOST_PDEV_ID_SOC;
104 case WMI_PDEV_ID_1ST:
105 return WMI_HOST_PDEV_ID_0;
106 case WMI_PDEV_ID_2ND:
107 return WMI_HOST_PDEV_ID_1;
108 case WMI_PDEV_ID_3RD:
109 return WMI_HOST_PDEV_ID_2;
110 }
111
112 QDF_ASSERT(0);
113
114 return WMI_HOST_PDEV_ID_SOC;
115}
116
117/**
118 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
119 *
120 * Return None.
121 */
122static void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
123{
124 wmi_handle->ops->convert_pdev_id_host_to_target =
125 convert_host_pdev_id_to_target_pdev_id;
126 wmi_handle->ops->convert_pdev_id_target_to_host =
127 convert_target_pdev_id_to_host_pdev_id;
128}
129
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530130/* copy_vdev_create_pdev_id() - copy pdev from host params to target command
Sathish Kumarefb25bf2018-10-02 11:03:59 +0530131 * buffer.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530132 * @wmi_handle: pointer to wmi_handle
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530133 * @cmd: pointer target vdev create command buffer
134 * @param: pointer host params for vdev create
135 *
136 * Return: None
137 */
138#ifdef CONFIG_MCL
139static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530140 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530141 wmi_vdev_create_cmd_fixed_param * cmd,
142 struct vdev_create_params *param)
143{
144 cmd->pdev_id = WMI_PDEV_ID_SOC;
145}
146#else
147static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530148 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530149 wmi_vdev_create_cmd_fixed_param * cmd,
150 struct vdev_create_params *param)
151{
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530152 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
153 param->pdev_id);
Kiran Venkatappa8e146df2017-02-08 14:51:13 +0530154}
155#endif
156
Qiwei Cai2aacaff2018-09-13 16:17:46 +0800157void wmi_mtrace(uint32_t message_id, uint16_t vdev_id, uint32_t data)
Ashish Kumar Dhanotiyac8b83e52018-08-02 14:26:53 +0530158{
159 uint16_t mtrace_message_id;
160
161 mtrace_message_id = QDF_WMI_MTRACE_CMD_ID(message_id) |
162 (QDF_WMI_MTRACE_GRP_ID(message_id) <<
163 QDF_WMI_MTRACE_CMD_NUM_BITS);
164 qdf_mtrace(QDF_MODULE_ID_WMI, QDF_MODULE_ID_TARGET,
165 mtrace_message_id, vdev_id, data);
166}
167
Qiwei Cai2aacaff2018-09-13 16:17:46 +0800168qdf_export_symbol(wmi_mtrace);
169
Ashish Kumar Dhanotiyac8b83e52018-08-02 14:26:53 +0530170/**
Govind Singh5eb51532016-03-09 11:34:12 +0530171 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
172 * @wmi_handle: wmi handle
173 * @param: pointer to hold vdev create parameter
174 * @macaddr: vdev mac address
175 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530176 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530177 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530178static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530179 uint8_t macaddr[IEEE80211_ADDR_LEN],
180 struct vdev_create_params *param)
181{
182 wmi_vdev_create_cmd_fixed_param *cmd;
183 wmi_buf_t buf;
184 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +0530185 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700186 int num_bands = 2;
187 uint8_t *buf_ptr;
188 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +0530189
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700190 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +0530191 buf = wmi_buf_alloc(wmi_handle, len);
192 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530193 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530194 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530195 }
196 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
197 WMITLV_SET_HDR(&cmd->tlv_header,
198 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
199 WMITLV_GET_STRUCT_TLVLEN
200 (wmi_vdev_create_cmd_fixed_param));
201 cmd->vdev_id = param->if_id;
202 cmd->vdev_type = param->type;
203 cmd->vdev_subtype = param->subtype;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -0700204 cmd->flags = param->mbssid_flags;
205 cmd->vdevid_trans = param->vdevid_trans;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700206 cmd->num_cfg_txrx_streams = num_bands;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530207 copy_vdev_create_pdev_id(wmi_handle, cmd, param);
Govind Singh5eb51532016-03-09 11:34:12 +0530208 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Neil Zhao98ec4c42017-08-10 11:51:33 -0700209 WMI_LOGD("%s: ID = %d[pdev:%d] VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
210 __func__, param->if_id, cmd->pdev_id,
Govind Singh5eb51532016-03-09 11:34:12 +0530211 macaddr[0], macaddr[1], macaddr[2],
212 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700213 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
214 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
215 (num_bands * sizeof(wmi_vdev_txrx_streams)));
216 buf_ptr += WMI_TLV_HDR_SIZE;
217
Govind Singh224a7312016-06-21 14:33:26 +0530218 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700219 param->type, param->subtype,
220 param->nss_2g, param->nss_5g);
221 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
222 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
223 txrx_streams->supported_tx_streams = param->nss_2g;
224 txrx_streams->supported_rx_streams = param->nss_2g;
225 WMITLV_SET_HDR(&txrx_streams->tlv_header,
226 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
227 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
228
229 txrx_streams++;
230 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
231 txrx_streams->supported_tx_streams = param->nss_5g;
232 txrx_streams->supported_rx_streams = param->nss_5g;
233 WMITLV_SET_HDR(&txrx_streams->tlv_header,
234 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
235 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530236 wmi_mtrace(WMI_VDEV_CREATE_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530237 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530238 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530239 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530240 wmi_buf_free(buf);
241 }
242
243 return ret;
244}
245
246/**
247 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
248 * @wmi_handle: wmi handle
249 * @if_id: vdev id
250 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530251 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530252 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530253static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530254 uint8_t if_id)
255{
256 wmi_vdev_delete_cmd_fixed_param *cmd;
257 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530258 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530259
260 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
261 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530262 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530263 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530264 }
265
266 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
267 WMITLV_SET_HDR(&cmd->tlv_header,
268 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
269 WMITLV_GET_STRUCT_TLVLEN
270 (wmi_vdev_delete_cmd_fixed_param));
271 cmd->vdev_id = if_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530272 wmi_mtrace(WMI_VDEV_DELETE_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530273 ret = wmi_unified_cmd_send(wmi_handle, buf,
274 sizeof(wmi_vdev_delete_cmd_fixed_param),
275 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530276 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530277 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530278 wmi_buf_free(buf);
279 }
Govind Singhb53420c2016-03-09 14:32:57 +0530280 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530281
282 return ret;
283}
284
285/**
286 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
287 * @wmi: wmi handle
288 * @vdev_id: vdev id
289 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530290 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530291 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530292static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530293 uint8_t vdev_id)
294{
295 wmi_vdev_stop_cmd_fixed_param *cmd;
296 wmi_buf_t buf;
297 int32_t len = sizeof(*cmd);
298
299 buf = wmi_buf_alloc(wmi, len);
300 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530301 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530302 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530303 }
304 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
305 WMITLV_SET_HDR(&cmd->tlv_header,
306 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
307 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
308 cmd->vdev_id = vdev_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530309 wmi_mtrace(WMI_VDEV_STOP_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530310 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530311 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530312 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530313 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530314 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530315 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530316
317 return 0;
318}
319
320/**
321 * send_vdev_down_cmd_tlv() - send vdev down command to fw
322 * @wmi: wmi handle
323 * @vdev_id: vdev id
324 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530325 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530326 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530327static QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530328{
329 wmi_vdev_down_cmd_fixed_param *cmd;
330 wmi_buf_t buf;
331 int32_t len = sizeof(*cmd);
332
333 buf = wmi_buf_alloc(wmi, len);
334 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530335 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530336 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530337 }
338 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
339 WMITLV_SET_HDR(&cmd->tlv_header,
340 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
341 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
342 cmd->vdev_id = vdev_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530343 wmi_mtrace(WMI_VDEV_DOWN_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530344 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530345 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530346 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530347 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530348 }
Govind Singhb53420c2016-03-09 14:32:57 +0530349 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530350
351 return 0;
352}
353
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530354#ifdef CONFIG_MCL
355static inline void copy_channel_info(
356 wmi_vdev_start_request_cmd_fixed_param * cmd,
357 wmi_channel *chan,
358 struct vdev_start_params *req)
359{
360 chan->mhz = req->chan_freq;
361
362 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
363
364 chan->band_center_freq1 = req->band_center_freq1;
365 chan->band_center_freq2 = req->band_center_freq2;
366
367 if (req->is_half_rate)
368 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
369 else if (req->is_quarter_rate)
370 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
371
Naveen Rawat44f2f432016-12-01 12:58:57 -0800372 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530373 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
374 cmd->disable_hw_ack = req->dis_hw_ack;
375 }
376
377 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
378 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
379
380}
381#else
382static inline void copy_channel_info(
383 wmi_vdev_start_request_cmd_fixed_param * cmd,
384 wmi_channel *chan,
385 struct vdev_start_params *req)
386{
387 chan->mhz = req->channel.mhz;
388
389 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
390
391 chan->band_center_freq1 = req->channel.cfreq1;
392 chan->band_center_freq2 = req->channel.cfreq2;
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800393 WMI_LOGI("%s: req->channel.phy_mode: %d ", req->channel.phy_mode);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530394
395 if (req->channel.half_rate)
396 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
397 else if (req->channel.quarter_rate)
398 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
399
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800400 WMI_LOGI("%s: req->channel.dfs_set: %d ", req->channel.dfs_set);
401
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530402 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530403 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530404 cmd->disable_hw_ack = req->disable_hw_ack;
405 }
406
Krishna Rao0b952ea2017-03-20 13:30:10 +0530407 if (req->channel.dfs_set_cfreq2)
408 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS_CFREQ2);
409
Kai Chen4710d462017-12-15 14:06:06 -0800410 /* According to firmware both reg power and max tx power
411 * on set channel power is used and set it to max reg
412 * power from regulatory.
413 */
414 WMI_SET_CHANNEL_MIN_POWER(chan, req->channel.minpower);
415 WMI_SET_CHANNEL_MAX_POWER(chan, req->channel.maxpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530416 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
Kai Chen4710d462017-12-15 14:06:06 -0800417 WMI_SET_CHANNEL_ANTENNA_MAX(chan, req->channel.antennamax);
418 WMI_SET_CHANNEL_REG_CLASSID(chan, req->channel.reg_class_id);
419 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530420
421}
422#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530423/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530424 * send_vdev_start_cmd_tlv() - send vdev start request to fw
425 * @wmi_handle: wmi handle
426 * @req: vdev start params
427 *
428 * Return: QDF status
429 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530430static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530431 struct vdev_start_params *req)
432{
433 wmi_vdev_start_request_cmd_fixed_param *cmd;
434 wmi_buf_t buf;
435 wmi_channel *chan;
436 int32_t len, ret;
437 uint8_t *buf_ptr;
438
439 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
440 buf = wmi_buf_alloc(wmi_handle, len);
441 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530442 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530443 return QDF_STATUS_E_NOMEM;
444 }
445 buf_ptr = (uint8_t *) wmi_buf_data(buf);
446 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
447 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
448 WMITLV_SET_HDR(&cmd->tlv_header,
449 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
450 WMITLV_GET_STRUCT_TLVLEN
451 (wmi_vdev_start_request_cmd_fixed_param));
452 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
453 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
454 cmd->vdev_id = req->vdev_id;
455
456 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530457 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530458
459 cmd->beacon_interval = req->beacon_intval;
460 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530461
Jiachao Wub89e3bf2017-08-23 15:27:11 +0800462 cmd->bcn_tx_rate = req->bcn_tx_rate_code;
463 if (req->bcn_tx_rate_code)
464 cmd->flags |= WMI_UNIFIED_VDEV_START_BCN_TX_RATE_PRESENT;
465
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530466 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530467 cmd->beacon_interval = req->beacon_intval;
468 cmd->dtim_period = req->dtim_period;
469
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530470 /* Copy the SSID */
471 if (req->ssid.length) {
472 if (req->ssid.length < sizeof(cmd->ssid.ssid))
473 cmd->ssid.ssid_len = req->ssid.length;
474 else
475 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
476 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
477 cmd->ssid.ssid_len);
478 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530479
480 if (req->hidden_ssid)
481 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
482
483 if (req->pmf_enabled)
484 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530485 }
486
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700487 cmd->flags |= WMI_UNIFIED_VDEV_START_LDPC_RX_ENABLED;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530488 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530489 cmd->preferred_rx_streams = req->preferred_rx_streams;
490 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700491 cmd->cac_duration_ms = req->cac_duration_ms;
492 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700493 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530494
495 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
496 sizeof(wmi_channel));
497 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
498 cmd->num_noa_descriptors *
499 sizeof(wmi_p2p_noa_descriptor));
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -0800500 WMI_LOGI("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530501 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
502 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800503 "Tx SS %d, Rx SS %d, ldpc_rx: %d, cac %d, regd %d, HE ops: %d"
504 "req->dis_hw_ack: %d ", __func__, req->vdev_id,
505 chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530506 req->is_dfs, req->beacon_intval, cmd->dtim_period,
507 chan->band_center_freq1, chan->band_center_freq2,
508 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700509 req->preferred_tx_streams, req->preferred_rx_streams,
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700510 req->ldpc_rx_enabled, req->cac_duration_ms,
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800511 req->regdomain, req->he_ops,
512 req->dis_hw_ack);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530513
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530514 if (req->is_restart) {
515 wmi_mtrace(WMI_VDEV_RESTART_REQUEST_CMDID, cmd->vdev_id, 0);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530516 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
517 WMI_VDEV_RESTART_REQUEST_CMDID);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530518 } else {
519 wmi_mtrace(WMI_VDEV_START_REQUEST_CMDID, cmd->vdev_id, 0);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530520 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
521 WMI_VDEV_START_REQUEST_CMDID);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530522 }
523 if (ret) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530524 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530525 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530526 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530527 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530528
529 return QDF_STATUS_SUCCESS;
530}
531
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530532/**
533 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
534 * @wmi_handle: wmi handle
535 * @restart_params: vdev restart params
536 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530537 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530538 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530539static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530540 struct hidden_ssid_vdev_restart_params *restart_params)
541{
542 wmi_vdev_start_request_cmd_fixed_param *cmd;
543 wmi_buf_t buf;
544 wmi_channel *chan;
545 int32_t len;
546 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530547 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530548
549 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
550 buf = wmi_buf_alloc(wmi_handle, len);
551 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530552 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530553 return QDF_STATUS_E_NOMEM;
554 }
555 buf_ptr = (uint8_t *) wmi_buf_data(buf);
556 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
557 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
558
559 WMITLV_SET_HDR(&cmd->tlv_header,
560 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
561 WMITLV_GET_STRUCT_TLVLEN
562 (wmi_vdev_start_request_cmd_fixed_param));
563
564 WMITLV_SET_HDR(&chan->tlv_header,
565 WMITLV_TAG_STRUC_wmi_channel,
566 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
567
568 cmd->vdev_id = restart_params->session_id;
569 cmd->ssid.ssid_len = restart_params->ssid_len;
570 qdf_mem_copy(cmd->ssid.ssid,
571 restart_params->ssid,
572 cmd->ssid.ssid_len);
573 cmd->flags = restart_params->flags;
574 cmd->requestor_id = restart_params->requestor_id;
575 cmd->disable_hw_ack = restart_params->disable_hw_ack;
576
577 chan->mhz = restart_params->mhz;
578 chan->band_center_freq1 =
579 restart_params->band_center_freq1;
580 chan->band_center_freq2 =
581 restart_params->band_center_freq2;
582 chan->info = restart_params->info;
583 chan->reg_info_1 = restart_params->reg_info_1;
584 chan->reg_info_2 = restart_params->reg_info_2;
585
586 cmd->num_noa_descriptors = 0;
587 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
588 sizeof(wmi_channel));
589 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
590 cmd->num_noa_descriptors *
591 sizeof(wmi_p2p_noa_descriptor));
592
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530593 wmi_mtrace(WMI_VDEV_RESTART_REQUEST_CMDID, cmd->vdev_id, 0);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530594 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
595 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530596 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530597 wmi_buf_free(buf);
598 return QDF_STATUS_E_FAILURE;
599 }
600 return QDF_STATUS_SUCCESS;
601}
602
603
604/**
Govind Singh5eb51532016-03-09 11:34:12 +0530605 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
606 * @wmi: wmi handle
607 * @peer_addr: peer mac address
608 * @param: pointer to hold peer flush tid parameter
609 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -0700610 * Return: 0 for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530611 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530612static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530613 uint8_t peer_addr[IEEE80211_ADDR_LEN],
614 struct peer_flush_params *param)
615{
616 wmi_peer_flush_tids_cmd_fixed_param *cmd;
617 wmi_buf_t buf;
618 int32_t len = sizeof(*cmd);
619
620 buf = wmi_buf_alloc(wmi, len);
621 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530622 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530623 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530624 }
625 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
626 WMITLV_SET_HDR(&cmd->tlv_header,
627 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
628 WMITLV_GET_STRUCT_TLVLEN
629 (wmi_peer_flush_tids_cmd_fixed_param));
630 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
631 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
632 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530633 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530634 peer_addr, param->vdev_id,
635 param->peer_tid_bitmap);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530636 wmi_mtrace(WMI_PEER_FLUSH_TIDS_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530637 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530638 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530639 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530640 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530641 }
642
643 return 0;
644}
645
646/**
647 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
648 * @wmi: wmi handle
649 * @peer_addr: peer mac addr
650 * @vdev_id: vdev id
651 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530652 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530653 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530654static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530655 uint8_t peer_addr[IEEE80211_ADDR_LEN],
656 uint8_t vdev_id)
657{
658 wmi_peer_delete_cmd_fixed_param *cmd;
659 wmi_buf_t buf;
660 int32_t len = sizeof(*cmd);
661 buf = wmi_buf_alloc(wmi, len);
662 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530663 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530664 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530665 }
666 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
667 WMITLV_SET_HDR(&cmd->tlv_header,
668 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
669 WMITLV_GET_STRUCT_TLVLEN
670 (wmi_peer_delete_cmd_fixed_param));
671 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
672 cmd->vdev_id = vdev_id;
673
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800674 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530675 wmi_mtrace(WMI_PEER_DELETE_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530676 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530677 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530678 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530679 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530680 }
Govind Singh5eb51532016-03-09 11:34:12 +0530681
682 return 0;
683}
684
685/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530686 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
687 * to target id.
688 * @targ_paramid: Target parameter id to hold the result.
689 * @peer_param_id: host param id.
690 *
691 * Return: QDF_STATUS_SUCCESS for success
Sathish Kumarefb25bf2018-10-02 11:03:59 +0530692 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530693 */
694#ifdef CONFIG_MCL
695static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
696 uint32_t *targ_paramid,
697 uint32_t peer_param_id)
698{
699 *targ_paramid = peer_param_id;
700 return QDF_STATUS_SUCCESS;
701}
Mohit Khannab9e1e542018-07-24 15:28:04 -0700702
703/**
704 * crash_on_send_peer_rx_reorder_queue_remove_cmd() - crash on reorder queue cmd
705 *
706 * On MCL side, we are suspecting this cmd to trigger drop of ARP
707 * response frames from REO by the FW. This function causes a crash if this
708 * command is sent out by the host, so we can track this issue. Ideally no one
709 * should be calling this API from the MCL side
710 *
711 * Return: None
712 */
713static void crash_on_send_peer_rx_reorder_queue_remove_cmd(void)
714{
715 QDF_BUG(0);
716}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530717#else
718static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
719 uint32_t *targ_paramid,
720 uint32_t peer_param_id)
721{
722 switch (peer_param_id) {
723 case WMI_HOST_PEER_MIMO_PS_STATE:
724 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
725 break;
726 case WMI_HOST_PEER_AMPDU:
727 *targ_paramid = WMI_PEER_AMPDU;
728 break;
729 case WMI_HOST_PEER_AUTHORIZE:
730 *targ_paramid = WMI_PEER_AUTHORIZE;
731 break;
732 case WMI_HOST_PEER_CHWIDTH:
733 *targ_paramid = WMI_PEER_CHWIDTH;
734 break;
735 case WMI_HOST_PEER_NSS:
736 *targ_paramid = WMI_PEER_NSS;
737 break;
738 case WMI_HOST_PEER_USE_4ADDR:
739 *targ_paramid = WMI_PEER_USE_4ADDR;
740 break;
741 case WMI_HOST_PEER_MEMBERSHIP:
742 *targ_paramid = WMI_PEER_MEMBERSHIP;
743 break;
744 case WMI_HOST_PEER_USERPOS:
745 *targ_paramid = WMI_PEER_USERPOS;
746 break;
747 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
748 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
749 break;
750 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
751 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
752 break;
753 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
754 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
755 break;
756 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
757 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
758 break;
759 case WMI_HOST_PEER_PHYMODE:
760 *targ_paramid = WMI_PEER_PHYMODE;
761 break;
762 case WMI_HOST_PEER_USE_FIXED_PWR:
763 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
764 break;
765 case WMI_HOST_PEER_PARAM_FIXED_RATE:
766 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
767 break;
768 case WMI_HOST_PEER_SET_MU_WHITELIST:
769 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
770 break;
771 case WMI_HOST_PEER_SET_MAC_TX_RATE:
772 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
773 break;
774 case WMI_HOST_PEER_SET_MIN_TX_RATE:
775 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
776 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530777 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
778 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
779 break;
Soumya Bhat8db697d2017-08-29 18:49:13 +0530780 case WMI_HOST_PEER_NSS_VHT160:
781 *targ_paramid = WMI_PEER_NSS_VHT160;
782 break;
783 case WMI_HOST_PEER_NSS_VHT80_80:
784 *targ_paramid = WMI_PEER_NSS_VHT80_80;
785 break;
Venkateswara Swamy Bandaru65745ba2018-01-09 15:52:37 +0530786 case WMI_HOST_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL:
787 *targ_paramid = WMI_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL;
788 break;
789 case WMI_HOST_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL:
790 *targ_paramid = WMI_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL;
791 break;
792 case WMI_HOST_PEER_PARAM_TXBF_SOUNDING_ENABLE:
793 *targ_paramid = WMI_PEER_PARAM_TXBF_SOUNDING_ENABLE;
794 break;
Venkateswara Swamy Bandaru094bc7a2018-01-09 15:56:56 +0530795 case WMI_HOST_PEER_PARAM_MU_ENABLE:
796 *targ_paramid = WMI_PEER_PARAM_MU_ENABLE;
797 break;
798 case WMI_HOST_PEER_PARAM_OFDMA_ENABLE:
799 *targ_paramid = WMI_PEER_PARAM_OFDMA_ENABLE;
800 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530801 default:
802 return QDF_STATUS_E_NOSUPPORT;
803 }
804
805 return QDF_STATUS_SUCCESS;
806}
Mohit Khannab9e1e542018-07-24 15:28:04 -0700807
808static void crash_on_send_peer_rx_reorder_queue_remove_cmd(void)
809{
810 /* No-OP */
811}
812
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530813#endif
814/**
Govind Singh5eb51532016-03-09 11:34:12 +0530815 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530816 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530817 * @peer_addr: peer mac address
818 * @param : pointer to hold peer set parameter
819 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530820 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530821 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530822static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530823 uint8_t peer_addr[IEEE80211_ADDR_LEN],
824 struct peer_set_params *param)
825{
826 wmi_peer_set_param_cmd_fixed_param *cmd;
827 wmi_buf_t buf;
828 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530829 uint32_t param_id;
830
831 if (convert_host_peer_id_to_target_id_tlv(&param_id,
832 param->param_id) != QDF_STATUS_SUCCESS)
833 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530834
835 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
836 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530837 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530838 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530839 }
840 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
841 WMITLV_SET_HDR(&cmd->tlv_header,
842 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
843 WMITLV_GET_STRUCT_TLVLEN
844 (wmi_peer_set_param_cmd_fixed_param));
845 cmd->vdev_id = param->vdev_id;
846 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530847 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530848 cmd->param_value = param->param_value;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530849 wmi_mtrace(WMI_PEER_SET_PARAM_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530850 err = wmi_unified_cmd_send(wmi, buf,
851 sizeof(wmi_peer_set_param_cmd_fixed_param),
852 WMI_PEER_SET_PARAM_CMDID);
853 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530854 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530855 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530856 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530857 }
858
859 return 0;
860}
861
862/**
863 * send_vdev_up_cmd_tlv() - send vdev up command in fw
864 * @wmi: wmi handle
865 * @bssid: bssid
866 * @vdev_up_params: pointer to hold vdev up parameter
867 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530868 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530869 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530870static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530871 uint8_t bssid[IEEE80211_ADDR_LEN],
872 struct vdev_up_params *params)
873{
874 wmi_vdev_up_cmd_fixed_param *cmd;
875 wmi_buf_t buf;
876 int32_t len = sizeof(*cmd);
877
Govind Singhb53420c2016-03-09 14:32:57 +0530878 WMI_LOGD("%s: VDEV_UP", __func__);
879 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530880 params->vdev_id, params->assoc_id, bssid);
881 buf = wmi_buf_alloc(wmi, len);
882 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530883 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530884 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530885 }
886 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
887 WMITLV_SET_HDR(&cmd->tlv_header,
888 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
889 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
890 cmd->vdev_id = params->vdev_id;
891 cmd->vdev_assoc_id = params->assoc_id;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -0700892 cmd->profile_idx = params->profile_idx;
893 cmd->profile_num = params->profile_num;
894 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->trans_bssid, &cmd->trans_bssid);
Govind Singh5eb51532016-03-09 11:34:12 +0530895 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530896 wmi_mtrace(WMI_VDEV_UP_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530897 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530898 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530899 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530900 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530901 }
902
903 return 0;
904}
905
906/**
907 * send_peer_create_cmd_tlv() - send peer create command to fw
908 * @wmi: wmi handle
909 * @peer_addr: peer mac address
910 * @peer_type: peer type
911 * @vdev_id: vdev id
912 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530913 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530914 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530915static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530916 struct peer_create_params *param)
917{
918 wmi_peer_create_cmd_fixed_param *cmd;
919 wmi_buf_t buf;
920 int32_t len = sizeof(*cmd);
921
922 buf = wmi_buf_alloc(wmi, len);
923 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530924 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530925 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530926 }
927 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
928 WMITLV_SET_HDR(&cmd->tlv_header,
929 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
930 WMITLV_GET_STRUCT_TLVLEN
931 (wmi_peer_create_cmd_fixed_param));
932 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
933 cmd->peer_type = param->peer_type;
934 cmd->vdev_id = param->vdev_id;
935
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530936 wmi_mtrace(WMI_PEER_CREATE_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +0530937 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530938 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530939 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530940 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530941 }
Govind Singhb53420c2016-03-09 14:32:57 +0530942 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530943 param->vdev_id);
944
945 return 0;
946}
947
948/**
Leo Changeee40872016-09-28 13:43:36 -0700949 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
950 * command to fw
951 * @wmi: wmi handle
952 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
953 *
954 * Return: 0 for success or error code
955 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700956static
Leo Changeee40872016-09-28 13:43:36 -0700957QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
958 struct rx_reorder_queue_setup_params *param)
959{
960 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
961 wmi_buf_t buf;
962 int32_t len = sizeof(*cmd);
963
964 buf = wmi_buf_alloc(wmi, len);
965 if (!buf) {
966 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
967 return QDF_STATUS_E_NOMEM;
968 }
969 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
970 WMITLV_SET_HDR(&cmd->tlv_header,
971 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
972 WMITLV_GET_STRUCT_TLVLEN
973 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
974 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
975 cmd->vdev_id = param->vdev_id;
976 cmd->tid = param->tid;
977 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
978 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
979 cmd->queue_no = param->queue_no;
Gyanranjan Hazarikad6c4d782018-07-25 23:26:16 -0700980 cmd->ba_window_size_valid = param->ba_window_size_valid;
981 cmd->ba_window_size = param->ba_window_size;
982
Leo Changeee40872016-09-28 13:43:36 -0700983
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +0530984 wmi_mtrace(WMI_PEER_REORDER_QUEUE_SETUP_CMDID, cmd->vdev_id, 0);
Leo Changeee40872016-09-28 13:43:36 -0700985 if (wmi_unified_cmd_send(wmi, buf, len,
986 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
987 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
988 __func__);
Rakshith Suresh Patkar9eb15ee2018-09-12 16:51:30 +0530989 wmi_buf_free(buf);
Leo Changeee40872016-09-28 13:43:36 -0700990 return QDF_STATUS_E_FAILURE;
991 }
Sathish Kumarefb25bf2018-10-02 11:03:59 +0530992 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d", __func__,
Leo Changeee40872016-09-28 13:43:36 -0700993 param->peer_macaddr, param->vdev_id, param->tid);
994
995 return QDF_STATUS_SUCCESS;
996}
997
998/**
999 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
1000 * command to fw
1001 * @wmi: wmi handle
1002 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
1003 *
1004 * Return: 0 for success or error code
1005 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07001006static
Leo Changeee40872016-09-28 13:43:36 -07001007QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
1008 struct rx_reorder_queue_remove_params *param)
1009{
1010 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
1011 wmi_buf_t buf;
1012 int32_t len = sizeof(*cmd);
1013
Mohit Khannab9e1e542018-07-24 15:28:04 -07001014 crash_on_send_peer_rx_reorder_queue_remove_cmd();
1015
Leo Changeee40872016-09-28 13:43:36 -07001016 buf = wmi_buf_alloc(wmi, len);
1017 if (!buf) {
1018 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
1019 return QDF_STATUS_E_NOMEM;
1020 }
1021 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
1022 wmi_buf_data(buf);
1023 WMITLV_SET_HDR(&cmd->tlv_header,
1024 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
1025 WMITLV_GET_STRUCT_TLVLEN
1026 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
1027 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
1028 cmd->vdev_id = param->vdev_id;
1029 cmd->tid_mask = param->peer_tid_bitmap;
1030
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301031 wmi_mtrace(WMI_PEER_REORDER_QUEUE_REMOVE_CMDID, cmd->vdev_id, 0);
Leo Changeee40872016-09-28 13:43:36 -07001032 if (wmi_unified_cmd_send(wmi, buf, len,
1033 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
1034 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
1035 __func__);
Rakshith Suresh Patkar9eb15ee2018-09-12 16:51:30 +05301036 wmi_buf_free(buf);
Leo Changeee40872016-09-28 13:43:36 -07001037 return QDF_STATUS_E_FAILURE;
1038 }
1039 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
1040 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
1041
1042 return QDF_STATUS_SUCCESS;
1043}
1044
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301045#ifdef WLAN_SUPPORT_GREEN_AP
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301046/**
Govind Singh5eb51532016-03-09 11:34:12 +05301047 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
1048 * @wmi_handle: wmi handle
1049 * @value: value
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301050 * @pdev_id: pdev id to have radio context
Govind Singh5eb51532016-03-09 11:34:12 +05301051 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301052 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301053 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301054static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301055 uint32_t value, uint8_t pdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +05301056{
1057 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
1058 wmi_buf_t buf;
1059 int32_t len = sizeof(*cmd);
1060
Govind Singhb53420c2016-03-09 14:32:57 +05301061 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +05301062
1063 buf = wmi_buf_alloc(wmi_handle, len);
1064 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301065 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301066 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301067 }
1068
1069 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
1070 WMITLV_SET_HDR(&cmd->tlv_header,
1071 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
1072 WMITLV_GET_STRUCT_TLVLEN
1073 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301074 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301075 cmd->enable = value;
1076
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301077 wmi_mtrace(WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301078 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1079 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301080 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301081 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301082 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301083 }
1084
1085 return 0;
1086}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301087#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301088
1089/**
1090 * send_pdev_utf_cmd_tlv() - send utf command to fw
1091 * @wmi_handle: wmi handle
1092 * @param: pointer to pdev_utf_params
1093 * @mac_id: mac id to have radio context
1094 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301095 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301096 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301097static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301098send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1099 struct pdev_utf_params *param,
1100 uint8_t mac_id)
1101{
1102 wmi_buf_t buf;
1103 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001104 /* if param->len is 0 no data is sent, return error */
1105 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301106 static uint8_t msgref = 1;
1107 uint8_t segNumber = 0, segInfo, numSegments;
1108 uint16_t chunk_len, total_bytes;
1109 uint8_t *bufpos;
1110 struct seg_hdr_info segHdrInfo;
1111
1112 bufpos = param->utf_payload;
1113 total_bytes = param->len;
1114 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1115 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1116 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1117
1118 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1119 numSegments++;
1120
1121 while (param->len) {
1122 if (param->len > MAX_WMI_UTF_LEN)
Jeff Johnsonda263992018-05-12 14:22:00 -07001123 chunk_len = MAX_WMI_UTF_LEN; /* MAX message */
Govind Singh5eb51532016-03-09 11:34:12 +05301124 else
1125 chunk_len = param->len;
1126
1127 buf = wmi_buf_alloc(wmi_handle,
1128 (chunk_len + sizeof(segHdrInfo) +
1129 WMI_TLV_HDR_SIZE));
1130 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301131 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301132 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301133 }
1134
1135 cmd = (uint8_t *) wmi_buf_data(buf);
1136
1137 segHdrInfo.len = total_bytes;
1138 segHdrInfo.msgref = msgref;
1139 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1140 segHdrInfo.segmentInfo = segInfo;
1141 segHdrInfo.pad = 0;
1142
Govind Singhb53420c2016-03-09 14:32:57 +05301143 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301144 " segHdrInfo.segmentInfo = %d",
1145 __func__, segHdrInfo.len, segHdrInfo.msgref,
1146 segHdrInfo.segmentInfo);
1147
Govind Singhb53420c2016-03-09 14:32:57 +05301148 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301149 "chunk len %d", __func__, total_bytes, segNumber,
1150 numSegments, chunk_len);
1151
1152 segNumber++;
1153
1154 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1155 (chunk_len + sizeof(segHdrInfo)));
1156 cmd += WMI_TLV_HDR_SIZE;
1157 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1158 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1159
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301160 wmi_mtrace(WMI_PDEV_UTF_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301161 ret = wmi_unified_cmd_send(wmi_handle, buf,
1162 (chunk_len + sizeof(segHdrInfo) +
1163 WMI_TLV_HDR_SIZE),
1164 WMI_PDEV_UTF_CMDID);
1165
Govind Singh67922e82016-04-01 16:48:57 +05301166 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301167 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301168 wmi_buf_free(buf);
1169 break;
1170 }
1171
1172 param->len -= chunk_len;
1173 bufpos += chunk_len;
1174 }
1175
1176 msgref++;
1177
1178 return ret;
1179}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301180#ifdef CONFIG_MCL
1181static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1182 uint32_t host_param)
1183{
1184 return host_param;
1185}
1186#else
1187static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1188 uint32_t host_param)
1189{
1190 if (host_param < wmi_pdev_param_max)
1191 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301192
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301193 return WMI_UNAVAILABLE_PARAM;
1194}
1195#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301196/**
1197 * send_pdev_param_cmd_tlv() - set pdev parameters
1198 * @wmi_handle: wmi handle
1199 * @param: pointer to pdev parameter
1200 * @mac_id: radio context
1201 *
1202 * Return: 0 on success, errno on failure
1203 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301204static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301205send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1206 struct pdev_params *param,
1207 uint8_t mac_id)
1208{
Govind Singh67922e82016-04-01 16:48:57 +05301209 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301210 wmi_pdev_set_param_cmd_fixed_param *cmd;
1211 wmi_buf_t buf;
1212 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301213 uint32_t pdev_param;
1214
1215 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1216 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05301217 WMI_LOGW("%s: Unavailable param %d",
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301218 __func__, param->param_id);
1219 return QDF_STATUS_E_INVAL;
1220 }
Govind Singh5eb51532016-03-09 11:34:12 +05301221
1222 buf = wmi_buf_alloc(wmi_handle, len);
1223 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301224 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301225 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301226 }
1227 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1228 WMITLV_SET_HDR(&cmd->tlv_header,
1229 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1230 WMITLV_GET_STRUCT_TLVLEN
1231 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301232 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301233 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301234 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301235 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301236 param->param_value);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301237 wmi_mtrace(WMI_PDEV_SET_PARAM_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301238 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1239 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301240 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301241 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301242 wmi_buf_free(buf);
1243 }
1244 return ret;
1245}
1246
1247/**
1248 * send_suspend_cmd_tlv() - WMI suspend function
1249 * @param wmi_handle : handle to WMI.
1250 * @param param : pointer to hold suspend parameter
1251 * @mac_id: radio context
1252 *
1253 * Return 0 on success and -ve on failure.
1254 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301255static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301256 struct suspend_params *param,
1257 uint8_t mac_id)
1258{
1259 wmi_pdev_suspend_cmd_fixed_param *cmd;
1260 wmi_buf_t wmibuf;
1261 uint32_t len = sizeof(*cmd);
1262 int32_t ret;
1263
1264 /*
Jeff Johnson19a59fe2018-05-06 16:10:43 -07001265 * send the command to Target to ignore the
Govind Singh5eb51532016-03-09 11:34:12 +05301266 * PCIE reset so as to ensure that Host and target
1267 * states are in sync
1268 */
1269 wmibuf = wmi_buf_alloc(wmi_handle, len);
1270 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301271 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301272
1273 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1274 WMITLV_SET_HDR(&cmd->tlv_header,
1275 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1276 WMITLV_GET_STRUCT_TLVLEN
1277 (wmi_pdev_suspend_cmd_fixed_param));
1278 if (param->disable_target_intr)
1279 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1280 else
1281 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301282
1283 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1284
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301285 wmi_mtrace(WMI_PDEV_SUSPEND_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301286 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1287 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301288 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301289 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301290 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301291 }
1292
1293 return ret;
1294}
1295
1296/**
1297 * send_resume_cmd_tlv() - WMI resume function
1298 * @param wmi_handle : handle to WMI.
1299 * @mac_id: radio context
1300 *
1301 * Return: 0 on success and -ve on failure.
1302 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301303static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301304 uint8_t mac_id)
1305{
1306 wmi_buf_t wmibuf;
1307 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301308 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301309
1310 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1311 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301312 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301313 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1314 WMITLV_SET_HDR(&cmd->tlv_header,
1315 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1316 WMITLV_GET_STRUCT_TLVLEN
1317 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301318 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301319 wmi_mtrace(WMI_PDEV_RESUME_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301320 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1321 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301322 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301323 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301324 wmi_buf_free(wmibuf);
1325 }
1326
1327 return ret;
1328}
1329
1330/**
1331 * send_wow_enable_cmd_tlv() - WMI wow enable function
1332 * @param wmi_handle : handle to WMI.
1333 * @param param : pointer to hold wow enable parameter
1334 * @mac_id: radio context
1335 *
1336 * Return: 0 on success and -ve on failure.
1337 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301338static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301339 struct wow_cmd_params *param,
1340 uint8_t mac_id)
1341{
1342 wmi_wow_enable_cmd_fixed_param *cmd;
1343 wmi_buf_t buf;
1344 int32_t len;
1345 int32_t ret;
1346
1347 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1348
1349 buf = wmi_buf_alloc(wmi_handle, len);
1350 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301351 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1352 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301353 }
1354 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1355 WMITLV_SET_HDR(&cmd->tlv_header,
1356 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1357 WMITLV_GET_STRUCT_TLVLEN
1358 (wmi_wow_enable_cmd_fixed_param));
1359 cmd->enable = param->enable;
1360 if (param->can_suspend_link)
1361 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1362 else
1363 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001364 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301365
Govind Singhb53420c2016-03-09 14:32:57 +05301366 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301367 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1368 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1369
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301370 wmi_mtrace(WMI_WOW_ENABLE_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301371 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1372 WMI_WOW_ENABLE_CMDID);
1373 if (ret)
1374 wmi_buf_free(buf);
1375
1376 return ret;
1377}
1378
1379/**
1380 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301381 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301382 * @peer_addr: peer mac address
1383 * @param: pointer to ap_ps parameter structure
1384 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301385 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301386 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301387static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301388 uint8_t *peer_addr,
1389 struct ap_ps_params *param)
1390{
1391 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1392 wmi_buf_t buf;
1393 int32_t err;
1394
1395 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1396 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301397 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301398 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301399 }
1400 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1401 WMITLV_SET_HDR(&cmd->tlv_header,
1402 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1403 WMITLV_GET_STRUCT_TLVLEN
1404 (wmi_ap_ps_peer_cmd_fixed_param));
1405 cmd->vdev_id = param->vdev_id;
1406 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1407 cmd->param = param->param;
1408 cmd->value = param->value;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301409 wmi_mtrace(WMI_AP_PS_PEER_PARAM_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301410 err = wmi_unified_cmd_send(wmi_handle, buf,
1411 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1412 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301413 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301414 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301415 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301416 }
1417
1418 return 0;
1419}
1420
1421/**
1422 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301423 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301424 * @peer_addr: peer mac address
1425 * @param: pointer to sta_ps parameter structure
1426 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301427 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301428 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301429static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301430 struct sta_ps_params *param)
1431{
1432 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1433 wmi_buf_t buf;
1434 int32_t len = sizeof(*cmd);
1435
1436 buf = wmi_buf_alloc(wmi_handle, len);
1437 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301438 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301439 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301440 }
1441
1442 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1443 WMITLV_SET_HDR(&cmd->tlv_header,
1444 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1445 WMITLV_GET_STRUCT_TLVLEN
1446 (wmi_sta_powersave_param_cmd_fixed_param));
1447 cmd->vdev_id = param->vdev_id;
1448 cmd->param = param->param;
1449 cmd->value = param->value;
1450
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301451 wmi_mtrace(WMI_STA_POWERSAVE_PARAM_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301452 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1453 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301454 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301455 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301456 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301457 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301458 }
1459
1460 return 0;
1461}
1462
1463/**
1464 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301465 * @wmi_handle: wmi handle
Jeff Johnsonbbd428c2018-05-06 17:02:16 -07001466 * @param: ponirt to crash inject parameter structure
Govind Singh5eb51532016-03-09 11:34:12 +05301467 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301468 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301469 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301470static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301471 struct crash_inject *param)
1472{
1473 int32_t ret = 0;
1474 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1475 uint16_t len = sizeof(*cmd);
1476 wmi_buf_t buf;
1477
1478 buf = wmi_buf_alloc(wmi_handle, len);
1479 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301480 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301481 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301482 }
1483
1484 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1485 WMITLV_SET_HDR(&cmd->tlv_header,
1486 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1487 WMITLV_GET_STRUCT_TLVLEN
1488 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1489 cmd->type = param->type;
1490 cmd->delay_time_ms = param->delay_time_ms;
1491
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301492 wmi_mtrace(WMI_FORCE_FW_HANG_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301493 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1494 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301495 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301496 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301497 __func__, ret);
1498 wmi_buf_free(buf);
1499 }
1500
1501 return ret;
1502}
1503
Wen Gongca174012018-04-20 16:56:28 +08001504#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +05301505/**
1506 * send_dbglog_cmd_tlv() - set debug log level
1507 * @param wmi_handle : handle to WMI.
1508 * @param param : pointer to hold dbglog level parameter
1509 *
1510 * Return: 0 on success and -ve on failure.
1511 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301512 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301513send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1514 struct dbglog_params *dbglog_param)
1515{
1516 wmi_buf_t buf;
1517 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001518 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301519 int32_t i;
1520 int32_t len;
1521 int8_t *buf_ptr;
1522 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1523
Alok Kumar240afea2017-08-30 14:45:34 +05301524 ASSERT(dbglog_param->bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301525
1526 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1527 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1528 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1529 buf = wmi_buf_alloc(wmi_handle, len);
1530 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001531 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301532
1533 configmsg =
1534 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1535 buf_ptr = (int8_t *) configmsg;
1536 WMITLV_SET_HDR(&configmsg->tlv_header,
1537 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1538 WMITLV_GET_STRUCT_TLVLEN
1539 (wmi_debug_log_config_cmd_fixed_param));
1540 configmsg->dbg_log_param = dbglog_param->param;
1541 configmsg->value = dbglog_param->val;
1542 /* Filling in the data part of second tlv -- should
1543 * follow first tlv _ WMI_TLV_HDR_SIZE */
Vivekc5823092018-03-22 23:27:21 +05301544 module_id_bitmap_array = (uint32_t *) (buf_ptr +
Govind Singh5eb51532016-03-09 11:34:12 +05301545 sizeof
1546 (wmi_debug_log_config_cmd_fixed_param)
1547 + WMI_TLV_HDR_SIZE);
1548 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1549 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +05301550 sizeof(uint32_t) * MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301551 if (dbglog_param->module_id_bitmap) {
1552 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1553 module_id_bitmap_array[i] =
1554 dbglog_param->module_id_bitmap[i];
1555 }
1556 }
1557
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301558 wmi_mtrace(WMI_DBGLOG_CFG_CMDID, NO_SESSION, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301559 status = wmi_unified_cmd_send(wmi_handle, buf,
1560 len, WMI_DBGLOG_CFG_CMDID);
1561
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001562 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301563 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301564
1565 return status;
1566}
Wen Gongca174012018-04-20 16:56:28 +08001567#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301568
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301569#ifdef CONFIG_MCL
1570static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1571 uint32_t host_param)
1572{
1573 return host_param;
1574}
1575#else
1576static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1577 uint32_t host_param)
1578{
1579 if (host_param < wmi_vdev_param_max)
1580 return wmi_handle->vdev_param[host_param];
1581
1582 return WMI_UNAVAILABLE_PARAM;
1583}
1584#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301585/**
1586 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1587 * @param wmi_handle : handle to WMI.
Sathish Kumarefb25bf2018-10-02 11:03:59 +05301588 * @param macaddr : MAC address
Govind Singh5eb51532016-03-09 11:34:12 +05301589 * @param param : pointer to hold vdev set parameter
1590 *
1591 * Return: 0 on success and -ve on failure.
1592 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301593static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301594 struct vdev_set_params *param)
1595{
Govind Singh67922e82016-04-01 16:48:57 +05301596 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301597 wmi_vdev_set_param_cmd_fixed_param *cmd;
1598 wmi_buf_t buf;
1599 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301600 uint32_t vdev_param;
1601
1602 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1603 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1604 WMI_LOGW("%s:Vdev param %d not available", __func__,
1605 param->param_id);
1606 return QDF_STATUS_E_INVAL;
1607
1608 }
Govind Singh5eb51532016-03-09 11:34:12 +05301609
1610 buf = wmi_buf_alloc(wmi_handle, len);
1611 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301612 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301613 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301614 }
1615 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1616 WMITLV_SET_HDR(&cmd->tlv_header,
1617 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1618 WMITLV_GET_STRUCT_TLVLEN
1619 (wmi_vdev_set_param_cmd_fixed_param));
1620 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301621 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301622 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301623 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Neil Zhaod32a7bd2018-01-10 17:00:04 -08001624 cmd->vdev_id, cmd->param_id, cmd->param_value);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301625 wmi_mtrace(WMI_VDEV_SET_PARAM_CMDID, cmd->vdev_id, 0);
Govind Singh5eb51532016-03-09 11:34:12 +05301626 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1627 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301628 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301629 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301630 wmi_buf_free(buf);
1631 }
1632
1633 return ret;
1634}
1635
1636/**
1637 * send_stats_request_cmd_tlv() - WMI request stats function
1638 * @param wmi_handle : handle to WMI.
Sathish Kumarefb25bf2018-10-02 11:03:59 +05301639 * @param macaddr : MAC address
Govind Singh5eb51532016-03-09 11:34:12 +05301640 * @param param : pointer to hold stats request parameter
1641 *
1642 * Return: 0 on success and -ve on failure.
1643 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301644static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301645 uint8_t macaddr[IEEE80211_ADDR_LEN],
1646 struct stats_request_params *param)
1647{
Govind Singhd3156eb2016-02-26 17:50:39 +05301648 int32_t ret;
1649 wmi_request_stats_cmd_fixed_param *cmd;
1650 wmi_buf_t buf;
1651 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1652
1653 buf = wmi_buf_alloc(wmi_handle, len);
1654 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301655 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1656 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301657 }
1658
1659 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1660 WMITLV_SET_HDR(&cmd->tlv_header,
1661 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1662 WMITLV_GET_STRUCT_TLVLEN
1663 (wmi_request_stats_cmd_fixed_param));
1664 cmd->stats_id = param->stats_id;
1665 cmd->vdev_id = param->vdev_id;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301666 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
1667 param->pdev_id);
1668 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001669
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05301670 WMI_LOGD("STATS REQ STATS_ID:%d VDEV_ID:%d PDEV_ID:%d-->",
1671 cmd->stats_id, cmd->vdev_id, cmd->pdev_id);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001672
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301673 wmi_mtrace(WMI_REQUEST_STATS_CMDID, cmd->vdev_id, 0);
Kabilan Kannan3e2b2212017-12-21 00:52:10 -08001674 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1675 WMI_REQUEST_STATS_CMDID);
1676
Govind Singhd3156eb2016-02-26 17:50:39 +05301677 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301678 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301679 wmi_buf_free(buf);
1680 }
1681
1682 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301683}
1684
Govind Singh87542482016-06-08 19:40:11 +05301685#ifdef CONFIG_WIN
1686/**
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001687 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable packet-log
Govind Singh87542482016-06-08 19:40:11 +05301688 * @param wmi_handle : handle to WMI.
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001689 * @param PKTLOG_EVENT : packet log event
1690 * @mac_id: mac id to have radio context
Govind Singh87542482016-06-08 19:40:11 +05301691 *
1692 * Return: 0 on success and -ve on failure.
1693 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301694static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001695 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT, uint8_t mac_id)
Govind Singh87542482016-06-08 19:40:11 +05301696{
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001697 int32_t ret;
1698 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
1699 wmi_buf_t buf;
1700 uint16_t len = sizeof(wmi_pdev_pktlog_enable_cmd_fixed_param);
1701
1702 buf = wmi_buf_alloc(wmi_handle, len);
1703 if (!buf) {
1704 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1705 return -QDF_STATUS_E_NOMEM;
1706 }
1707
1708 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) wmi_buf_data(buf);
1709 WMITLV_SET_HDR(&cmd->tlv_header,
1710 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
1711 WMITLV_GET_STRUCT_TLVLEN
1712 (wmi_pdev_pktlog_enable_cmd_fixed_param));
1713 cmd->evlist = PKTLOG_EVENT;
1714 cmd->pdev_id = mac_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301715 wmi_mtrace(WMI_PDEV_PKTLOG_ENABLE_CMDID, cmd->pdev_id, 0);
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001716 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1717 WMI_PDEV_PKTLOG_ENABLE_CMDID);
1718 if (ret) {
1719 WMI_LOGE("Failed to send pktlog enable cmd to FW =%d", ret);
1720 wmi_buf_free(buf);
1721 }
1722
1723 return ret;
1724}
1725
1726/**
1727 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable packet-log
1728 * @param wmi_handle : handle to WMI.
1729 * @mac_id: mac id to have radio context
1730 *
1731 * Return: 0 on success and -ve on failure.
1732 */
1733static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
Keyur Parekhde522342017-08-18 14:01:05 -07001734 uint8_t mac_id)
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001735{
1736 int32_t ret;
1737 wmi_pdev_pktlog_disable_cmd_fixed_param *cmd;
1738 wmi_buf_t buf;
1739 uint16_t len = sizeof(wmi_pdev_pktlog_disable_cmd_fixed_param);
1740
1741 buf = wmi_buf_alloc(wmi_handle, len);
1742 if (!buf) {
1743 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1744 return -QDF_STATUS_E_NOMEM;
1745 }
1746
1747 cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) wmi_buf_data(buf);
1748 WMITLV_SET_HDR(&cmd->tlv_header,
1749 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
1750 WMITLV_GET_STRUCT_TLVLEN
1751 (wmi_pdev_pktlog_disable_cmd_fixed_param));
1752 cmd->pdev_id = mac_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301753 wmi_mtrace(WMI_PDEV_PKTLOG_DISABLE_CMDID, cmd->pdev_id, 0);
Keyur Parekh7df8ca12017-05-07 08:54:47 -07001754 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1755 WMI_PDEV_PKTLOG_DISABLE_CMDID);
1756 if (ret) {
1757 WMI_LOGE("Failed to send pktlog disable cmd to FW =%d", ret);
1758 wmi_buf_free(buf);
1759 }
1760
1761 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301762}
1763#else
Govind Singh5eb51532016-03-09 11:34:12 +05301764/**
Keyur Parekhde522342017-08-18 14:01:05 -07001765 * send_packet_log_enable_cmd_tlv() - Send WMI command to enable
1766 * packet-log
Govind Singh5eb51532016-03-09 11:34:12 +05301767 * @param wmi_handle : handle to WMI.
Sathish Kumarefb25bf2018-10-02 11:03:59 +05301768 * @param macaddr : MAC address
Govind Singh5eb51532016-03-09 11:34:12 +05301769 * @param param : pointer to hold stats request parameter
1770 *
1771 * Return: 0 on success and -ve on failure.
1772 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301773static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301774 uint8_t macaddr[IEEE80211_ADDR_LEN],
1775 struct packet_enable_params *param)
1776{
1777 return 0;
1778}
Keyur Parekhde522342017-08-18 14:01:05 -07001779/**
1780 * send_packet_log_disable_cmd_tlv() - Send WMI command to disable
1781 * packet-log
1782 * @param wmi_handle : handle to WMI.
1783 * @mac_id: mac id to have radio context
1784 *
1785 * Return: 0 on success and -ve on failure.
1786 */
1787static QDF_STATUS send_packet_log_disable_cmd_tlv(wmi_unified_t wmi_handle,
1788 uint8_t mac_id)
1789{
1790 return 0;
1791}
Govind Singh87542482016-06-08 19:40:11 +05301792#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301793
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301794#define WMI_FW_TIME_STAMP_LOW_MASK 0xffffffff
1795/**
1796 * send_time_stamp_sync_cmd_tlv() - Send WMI command to
1797 * sync time between bwtween host and firmware
1798 * @param wmi_handle : handle to WMI.
1799 *
1800 * Return: None
1801 */
1802static void send_time_stamp_sync_cmd_tlv(wmi_unified_t wmi_handle)
1803{
1804 wmi_buf_t buf;
Yuanyuan Liu977f53b2018-03-28 18:05:30 -07001805 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301806 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *time_stamp;
1807 int32_t len;
1808 qdf_time_t time_ms;
1809
1810 len = sizeof(*time_stamp);
1811 buf = wmi_buf_alloc(wmi_handle, len);
1812
1813 if (!buf) {
1814 WMI_LOGP(FL("wmi_buf_alloc failed"));
1815 return;
1816 }
1817 time_stamp =
1818 (WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param *)
1819 (wmi_buf_data(buf));
1820 WMITLV_SET_HDR(&time_stamp->tlv_header,
1821 WMITLV_TAG_STRUC_wmi_dbglog_time_stamp_sync_cmd_fixed_param,
1822 WMITLV_GET_STRUCT_TLVLEN(
1823 WMI_DBGLOG_TIME_STAMP_SYNC_CMD_fixed_param));
1824
1825 time_ms = qdf_get_time_of_the_day_ms();
1826 time_stamp->mode = WMI_TIME_STAMP_SYNC_MODE_MS;
1827 time_stamp->time_stamp_low = time_ms &
1828 WMI_FW_TIME_STAMP_LOW_MASK;
1829 /*
1830 * Send time_stamp_high 0 as the time converted from HR:MIN:SEC:MS to ms
1831 * wont exceed 27 bit
1832 */
1833 time_stamp->time_stamp_high = 0;
1834 WMI_LOGD(FL("WMA --> DBGLOG_TIME_STAMP_SYNC_CMDID mode %d time_stamp low %d high %d"),
1835 time_stamp->mode, time_stamp->time_stamp_low,
1836 time_stamp->time_stamp_high);
1837
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301838 wmi_mtrace(WMI_DBGLOG_TIME_STAMP_SYNC_CMDID, NO_SESSION, 0);
gaurank kathpaliacdfb4452018-02-21 18:58:29 +05301839 status = wmi_unified_cmd_send(wmi_handle, buf,
1840 len, WMI_DBGLOG_TIME_STAMP_SYNC_CMDID);
1841 if (status) {
1842 WMI_LOGE("Failed to send WMI_DBGLOG_TIME_STAMP_SYNC_CMDID command");
1843 wmi_buf_free(buf);
1844 }
1845
1846}
1847
Govind Singh87542482016-06-08 19:40:11 +05301848/**
1849 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
1850 * @param wmi_handle : handle to WMI.
1851 * @param param : pointer to hold beacon send cmd parameter
1852 *
1853 * Return: 0 on success and -ve on failure.
1854 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301855static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301856 struct beacon_tmpl_params *param)
1857{
1858 int32_t ret;
1859 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1860 wmi_bcn_prb_info *bcn_prb_info;
1861 wmi_buf_t wmi_buf;
1862 uint8_t *buf_ptr;
1863 uint32_t wmi_buf_len;
1864
1865 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1866 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1867 param->tmpl_len_aligned;
1868 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1869 if (!wmi_buf) {
1870 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1871 return QDF_STATUS_E_NOMEM;
1872 }
1873 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1874 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1875 WMITLV_SET_HDR(&cmd->tlv_header,
1876 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1877 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1878 cmd->vdev_id = param->vdev_id;
1879 cmd->tim_ie_offset = param->tim_ie_offset;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -07001880 cmd->mbssid_ie_offset = param->mbssid_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05301881 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
1882 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Subrat Mishraa667b1c2018-08-02 15:02:04 +05301883 cmd->esp_ie_offset = param->esp_ie_offset;
Govind Singh87542482016-06-08 19:40:11 +05301884 cmd->buf_len = param->tmpl_len;
1885 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1886
1887 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1888 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1889 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1890 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1891 bcn_prb_info->caps = 0;
1892 bcn_prb_info->erp = 0;
1893 buf_ptr += sizeof(wmi_bcn_prb_info);
1894
1895 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1896 buf_ptr += WMI_TLV_HDR_SIZE;
1897 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
1898
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05301899 wmi_mtrace(WMI_BCN_TMPL_CMDID, cmd->vdev_id, 0);
Govind Singh87542482016-06-08 19:40:11 +05301900 ret = wmi_unified_cmd_send(wmi_handle,
1901 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1902 if (ret) {
1903 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
1904 wmi_buf_free(wmi_buf);
1905 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05301906
Govind Singh87542482016-06-08 19:40:11 +05301907 return 0;
1908}
Govind Singh5eb51532016-03-09 11:34:12 +05301909
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301910#ifdef CONFIG_MCL
1911static inline void copy_peer_flags_tlv(
1912 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1913 struct peer_assoc_params *param)
1914{
1915 cmd->peer_flags = param->peer_flags;
1916}
1917#else
1918static inline void copy_peer_flags_tlv(
1919 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1920 struct peer_assoc_params *param)
1921{
1922 /*
1923 * The target only needs a subset of the flags maintained in the host.
1924 * Just populate those flags and send it down
1925 */
1926 cmd->peer_flags = 0;
1927
1928 /*
1929 * Do not enable HT/VHT if WMM/wme is disabled for vap.
1930 */
1931 if (param->is_wme_set) {
1932
1933 if (param->qos_flag)
1934 cmd->peer_flags |= WMI_PEER_QOS;
1935 if (param->apsd_flag)
1936 cmd->peer_flags |= WMI_PEER_APSD;
1937 if (param->ht_flag)
1938 cmd->peer_flags |= WMI_PEER_HT;
1939 if (param->bw_40)
1940 cmd->peer_flags |= WMI_PEER_40MHZ;
1941 if (param->bw_80)
1942 cmd->peer_flags |= WMI_PEER_80MHZ;
1943 if (param->bw_160)
1944 cmd->peer_flags |= WMI_PEER_160MHZ;
1945
1946 /* Typically if STBC is enabled for VHT it should be enabled
1947 * for HT as well
1948 **/
1949 if (param->stbc_flag)
1950 cmd->peer_flags |= WMI_PEER_STBC;
1951
1952 /* Typically if LDPC is enabled for VHT it should be enabled
1953 * for HT as well
1954 **/
1955 if (param->ldpc_flag)
1956 cmd->peer_flags |= WMI_PEER_LDPC;
1957
1958 if (param->static_mimops_flag)
1959 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
1960 if (param->dynamic_mimops_flag)
1961 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
1962 if (param->spatial_mux_flag)
1963 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
1964 if (param->vht_flag)
1965 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001966 if (param->he_flag)
1967 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301968 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001969
Gurumoorthi Gnanasambandhand18a0612017-07-03 16:14:55 +05301970 if (param->is_pmf_enabled)
1971 cmd->peer_flags |= WMI_PEER_PMF;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301972 /*
1973 * Suppress authorization for all AUTH modes that need 4-way handshake
1974 * (during re-association).
1975 * Authorization will be done for these modes on key installation.
1976 */
1977 if (param->auth_flag)
1978 cmd->peer_flags |= WMI_PEER_AUTH;
1979 if (param->need_ptk_4_way)
1980 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
1981 else
1982 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
1983 if (param->need_gtk_2_way)
1984 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
1985 /* safe mode bypass the 4-way handshake */
1986 if (param->safe_mode_enabled)
1987 cmd->peer_flags &=
1988 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
1989 /* Disable AMSDU for station transmit, if user configures it */
1990 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
1991 * it
1992 * if (param->amsdu_disable) Add after FW support
1993 **/
1994
1995 /* Target asserts if node is marked HT and all MCS is set to 0.
1996 * Mark the node as non-HT if all the mcs rates are disabled through
1997 * iwpriv
1998 **/
1999 if (param->peer_ht_rates.num_rates == 0)
2000 cmd->peer_flags &= ~WMI_PEER_HT;
Kiran Venkatappa54c2afd2018-07-30 12:04:42 +05302001
2002 if (param->twt_requester)
2003 cmd->peer_flags |= WMI_PEER_TWT_REQ;
2004
2005 if (param->twt_responder)
2006 cmd->peer_flags |= WMI_PEER_TWT_RESP;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302007}
2008#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302009
2010#ifdef CONFIG_MCL
2011static inline void copy_peer_mac_addr_tlv(
2012 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2013 struct peer_assoc_params *param)
2014{
2015 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
2016 sizeof(param->peer_macaddr));
2017}
2018#else
2019static inline void copy_peer_mac_addr_tlv(
2020 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
2021 struct peer_assoc_params *param)
2022{
2023 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
2024}
2025#endif
2026
Govind Singh5eb51532016-03-09 11:34:12 +05302027/**
2028 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
2029 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302030 * @param param : pointer to peer assoc parameter
2031 *
2032 * Return: 0 on success and -ve on failure.
2033 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302034static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302035 struct peer_assoc_params *param)
2036{
Govind Singhd3156eb2016-02-26 17:50:39 +05302037 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
2038 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002039 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05302040 wmi_buf_t buf;
2041 int32_t len;
2042 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05302043 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05302044 uint32_t peer_legacy_rates_align;
2045 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002046 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05302047
2048
2049 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
2050 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05302051
2052 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002053 (peer_legacy_rates_align * sizeof(uint8_t)) +
2054 WMI_TLV_HDR_SIZE +
2055 (peer_ht_rates_align * sizeof(uint8_t)) +
2056 sizeof(wmi_vht_rate_set) +
2057 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
2058 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302059
2060 buf = wmi_buf_alloc(wmi_handle, len);
2061 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302062 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302063 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302064 }
2065
2066 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2067 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
2068 WMITLV_SET_HDR(&cmd->tlv_header,
2069 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
2070 WMITLV_GET_STRUCT_TLVLEN
2071 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05302072
Govind Singhd3156eb2016-02-26 17:50:39 +05302073 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302074
Govind Singhd3156eb2016-02-26 17:50:39 +05302075 cmd->peer_new_assoc = param->peer_new_assoc;
2076 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302077
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302078 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05302079 copy_peer_mac_addr_tlv(cmd, param);
2080
Govind Singhd3156eb2016-02-26 17:50:39 +05302081 cmd->peer_rate_caps = param->peer_rate_caps;
2082 cmd->peer_caps = param->peer_caps;
2083 cmd->peer_listen_intval = param->peer_listen_intval;
2084 cmd->peer_ht_caps = param->peer_ht_caps;
2085 cmd->peer_max_mpdu = param->peer_max_mpdu;
2086 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05302087 cmd->peer_vht_caps = param->peer_vht_caps;
2088 cmd->peer_phymode = param->peer_phymode;
2089
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002090 /* Update 11ax capabilities */
Gyanranjan Hazarikae881c7c2018-08-17 01:54:48 -07002091 cmd->peer_he_cap_info =
2092 param->peer_he_cap_macinfo[WMI_HOST_HECAP_MAC_WORD1];
2093 cmd->peer_he_cap_info_ext =
2094 param->peer_he_cap_macinfo[WMI_HOST_HECAP_MAC_WORD2];
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002095 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07002096 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
2097 sizeof(param->peer_he_cap_phyinfo));
2098 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
2099 sizeof(param->peer_ppet));
2100
Govind Singhd3156eb2016-02-26 17:50:39 +05302101 /* Update peer legacy rate information */
2102 buf_ptr += sizeof(*cmd);
2103 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302104 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302105 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302106 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302107 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302108 param->peer_legacy_rates.num_rates);
2109
2110 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002111 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302112 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05302113 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05302114 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05302115 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05302116 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05302117 param->peer_ht_rates.num_rates);
2118
2119 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07002120 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05302121 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
2122 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
2123
2124 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05302125
2126 /* Update bandwidth-NSS mapping */
2127 cmd->peer_bw_rxnss_override = 0;
2128 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
2129
Govind Singhd3156eb2016-02-26 17:50:39 +05302130 mcs = (wmi_vht_rate_set *) buf_ptr;
2131 if (param->vht_capable) {
2132 mcs->rx_max_rate = param->rx_max_rate;
2133 mcs->rx_mcs_set = param->rx_mcs_set;
2134 mcs->tx_max_rate = param->tx_max_rate;
2135 mcs->tx_mcs_set = param->tx_mcs_set;
2136 }
2137
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002138 /* HE Rates */
2139 cmd->peer_he_mcs = param->peer_he_mcs_count;
2140 buf_ptr += sizeof(wmi_vht_rate_set);
2141 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2142 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
2143 buf_ptr += WMI_TLV_HDR_SIZE;
2144
2145 /* Loop through the HE rate set */
2146 for (i = 0; i < param->peer_he_mcs_count; i++) {
2147 he_mcs = (wmi_he_rate_set *) buf_ptr;
2148 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
2149 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
2150
2151 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
2152 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
2153 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
2154 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
2155 buf_ptr += sizeof(wmi_he_rate_set);
2156 }
2157
2158
Govind Singhb53420c2016-03-09 14:32:57 +05302159 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302160 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2161 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002162 "cmd->peer_vht_caps %x "
2163 "HE cap_info %x ops %x "
Gyanranjan Hazarikae881c7c2018-08-17 01:54:48 -07002164 "HE cap_info_ext %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302165 "HE phy %x %x %x "
2166 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302167 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2168 cmd->peer_rate_caps, cmd->peer_caps,
2169 cmd->peer_listen_intval, cmd->peer_ht_caps,
2170 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2171 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002172 cmd->peer_vht_caps, cmd->peer_he_cap_info,
Gyanranjan Hazarikae881c7c2018-08-17 01:54:48 -07002173 cmd->peer_he_ops, cmd->peer_he_cap_info_ext,
2174 cmd->peer_he_cap_phy[0], cmd->peer_he_cap_phy[1],
2175 cmd->peer_he_cap_phy[2],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302176 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302177
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302178 wmi_mtrace(WMI_PEER_ASSOC_CMDID, cmd->vdev_id, 0);
Govind Singhd3156eb2016-02-26 17:50:39 +05302179 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2180 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302181 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302182 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302183 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302184 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302185 }
2186
2187 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302188}
2189
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302190/* copy_scan_notify_events() - Helper routine to copy scan notify events
2191 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302192static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302193 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302194 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302195{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302196
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302197 /* Scan events subscription */
2198 if (param->scan_ev_started)
2199 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2200 if (param->scan_ev_completed)
2201 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2202 if (param->scan_ev_bss_chan)
2203 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2204 if (param->scan_ev_foreign_chan)
2205 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2206 if (param->scan_ev_dequeued)
2207 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2208 if (param->scan_ev_preempted)
2209 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2210 if (param->scan_ev_start_failed)
2211 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2212 if (param->scan_ev_restarted)
2213 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2214 if (param->scan_ev_foreign_chn_exit)
2215 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2216 if (param->scan_ev_suspended)
2217 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2218 if (param->scan_ev_resumed)
2219 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302220
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302221 /** Set scan control flags */
2222 cmd->scan_ctrl_flags = 0;
2223 if (param->scan_f_passive)
2224 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2225 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302226 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302227 if (param->scan_f_promisc_mode)
2228 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2229 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302230 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302231 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302232 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302233 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302234 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302235 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302236 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302237 if (param->scan_f_ofdm_rates)
2238 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2239 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302240 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302241 if (param->scan_f_filter_prb_req)
2242 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2243 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302244 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302245 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302246 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302247 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302248 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302249 if (param->scan_f_force_active_dfs_chn)
2250 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2251 if (param->scan_f_add_tpc_ie_in_probe)
2252 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2253 if (param->scan_f_add_ds_ie_in_probe)
2254 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2255 if (param->scan_f_add_spoofed_mac_in_probe)
2256 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2257 if (param->scan_f_add_rand_seq_in_probe)
2258 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2259 if (param->scan_f_en_ie_whitelist_in_probe)
2260 cmd->scan_ctrl_flags |=
2261 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302262
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302263 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2264 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2265 param->adaptive_dwell_time_mode);
2266}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302267
2268/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302269static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302270 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302271{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302272 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302273}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302274
Govind Singh5eb51532016-03-09 11:34:12 +05302275/**
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302276 * wmi_copy_scan_random_mac() - To copy scan randomization attrs to wmi buffer
2277 * @mac: random mac addr
2278 * @mask: random mac mask
2279 * @mac_addr: wmi random mac
2280 * @mac_mask: wmi random mac mask
2281 *
2282 * Return None.
2283 */
2284static inline
2285void wmi_copy_scan_random_mac(uint8_t *mac, uint8_t *mask,
2286 wmi_mac_addr *mac_addr, wmi_mac_addr *mac_mask)
2287{
2288 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac, mac_addr);
2289 WMI_CHAR_ARRAY_TO_MAC_ADDR(mask, mac_mask);
2290}
2291
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302292/*
2293 * wmi_fill_vendor_oui() - fill vendor OUIs
2294 * @buf_ptr: pointer to wmi tlv buffer
2295 * @num_vendor_oui: number of vendor OUIs to be filled
2296 * @param_voui: pointer to OUI buffer
2297 *
2298 * This function populates the wmi tlv buffer when vendor specific OUIs are
2299 * present.
2300 *
2301 * Return: None
2302 */
2303static inline
2304void wmi_fill_vendor_oui(uint8_t *buf_ptr, uint32_t num_vendor_oui,
2305 uint32_t *pvoui)
2306{
2307 wmi_vendor_oui *voui = NULL;
2308 uint32_t i;
2309
2310 voui = (wmi_vendor_oui *)buf_ptr;
2311
2312 for (i = 0; i < num_vendor_oui; i++) {
2313 WMITLV_SET_HDR(&voui[i].tlv_header,
2314 WMITLV_TAG_STRUC_wmi_vendor_oui,
2315 WMITLV_GET_STRUCT_TLVLEN(wmi_vendor_oui));
2316 voui[i].oui_type_subtype = pvoui[i];
2317 }
2318}
2319
2320/*
2321 * wmi_fill_ie_whitelist_attrs() - fill IE whitelist attrs
2322 * @ie_bitmap: output pointer to ie bit map in cmd
2323 * @num_vendor_oui: output pointer to num vendor OUIs
2324 * @ie_whitelist: input parameter
2325 *
2326 * This function populates the IE whitelist attrs of scan, pno and
2327 * scan oui commands for ie_whitelist parameter.
2328 *
2329 * Return: None
2330 */
2331static inline
2332void wmi_fill_ie_whitelist_attrs(uint32_t *ie_bitmap,
2333 uint32_t *num_vendor_oui,
2334 struct probe_req_whitelist_attr *ie_whitelist)
2335{
2336 uint32_t i = 0;
2337
2338 for (i = 0; i < PROBE_REQ_BITMAP_LEN; i++)
2339 ie_bitmap[i] = ie_whitelist->ie_bitmap[i];
2340
2341 *num_vendor_oui = ie_whitelist->num_vendor_oui;
2342}
2343
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302344/**
Govind Singh5eb51532016-03-09 11:34:12 +05302345 * send_scan_start_cmd_tlv() - WMI scan start function
2346 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302347 * @param param : pointer to hold scan start cmd parameter
2348 *
2349 * Return: 0 on success and -ve on failure.
2350 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302351static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302352 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302353{
Govind Singhd3156eb2016-02-26 17:50:39 +05302354 int32_t ret = 0;
2355 int32_t i;
2356 wmi_buf_t wmi_buf;
2357 wmi_start_scan_cmd_fixed_param *cmd;
2358 uint8_t *buf_ptr;
2359 uint32_t *tmp_ptr;
2360 wmi_ssid *ssid = NULL;
2361 wmi_mac_addr *bssid;
2362 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302363 uint8_t extraie_len_with_pad = 0;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302364 uint8_t phymode_roundup = 0;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302365 struct probe_req_whitelist_attr *ie_whitelist = &params->ie_whitelist;
Govind Singhd3156eb2016-02-26 17:50:39 +05302366
2367 /* Length TLV placeholder for array of uint32_t */
2368 len += WMI_TLV_HDR_SIZE;
2369 /* calculate the length of buffer required */
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302370 if (params->chan_list.num_chan)
2371 len += params->chan_list.num_chan * sizeof(uint32_t);
Govind Singhd3156eb2016-02-26 17:50:39 +05302372
2373 /* Length TLV placeholder for array of wmi_ssid structures */
2374 len += WMI_TLV_HDR_SIZE;
2375 if (params->num_ssids)
2376 len += params->num_ssids * sizeof(wmi_ssid);
2377
2378 /* Length TLV placeholder for array of wmi_mac_addr structures */
2379 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302380 if (params->num_bssid)
2381 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302382
2383 /* Length TLV placeholder for array of bytes */
2384 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302385 if (params->extraie.len)
2386 extraie_len_with_pad =
2387 roundup(params->extraie.len, sizeof(uint32_t));
wadesong94c7ce62018-01-22 15:03:12 +08002388 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302389
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302390 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of wmi_vendor_oui */
2391 if (ie_whitelist->num_vendor_oui)
2392 len += ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
2393
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302394 len += WMI_TLV_HDR_SIZE; /* Length of TLV for array of scan phymode */
2395 if (params->scan_f_wide_band)
2396 phymode_roundup =
2397 qdf_roundup(params->chan_list.num_chan * sizeof(uint8_t),
2398 sizeof(uint32_t));
2399 len += phymode_roundup;
2400
Govind Singhd3156eb2016-02-26 17:50:39 +05302401 /* Allocate the memory */
2402 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2403 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302404 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302405 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302406 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302407 }
2408 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2409 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2410 WMITLV_SET_HDR(&cmd->tlv_header,
2411 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2412 WMITLV_GET_STRUCT_TLVLEN
2413 (wmi_start_scan_cmd_fixed_param));
2414
2415 cmd->scan_id = params->scan_id;
2416 cmd->scan_req_id = params->scan_req_id;
2417 cmd->vdev_id = params->vdev_id;
2418 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302419
2420 copy_scan_event_cntrl_flags(cmd, params);
2421
Govind Singhd3156eb2016-02-26 17:50:39 +05302422 cmd->dwell_time_active = params->dwell_time_active;
Arif Hussain397f08c2018-07-23 18:10:34 -07002423 cmd->dwell_time_active_2g = params->dwell_time_active_2g;
Govind Singhd3156eb2016-02-26 17:50:39 +05302424 cmd->dwell_time_passive = params->dwell_time_passive;
2425 cmd->min_rest_time = params->min_rest_time;
2426 cmd->max_rest_time = params->max_rest_time;
2427 cmd->repeat_probe_time = params->repeat_probe_time;
2428 cmd->probe_spacing_time = params->probe_spacing_time;
2429 cmd->idle_time = params->idle_time;
2430 cmd->max_scan_time = params->max_scan_time;
2431 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302432 cmd->burst_duration = params->burst_duration;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302433 cmd->num_chan = params->chan_list.num_chan;
Govind Singhd3156eb2016-02-26 17:50:39 +05302434 cmd->num_bssid = params->num_bssid;
2435 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302436 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302437 cmd->n_probes = params->n_probes;
Nitesh Shah52323d02017-05-22 15:49:00 +05302438 cmd->scan_ctrl_flags_ext = params->scan_ctrl_flags_ext;
2439
2440 WMI_LOGD("scan_ctrl_flags_ext = %x", cmd->scan_ctrl_flags_ext);
2441
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05302442 if (params->scan_random.randomize)
2443 wmi_copy_scan_random_mac(params->scan_random.mac_addr,
2444 params->scan_random.mac_mask,
2445 &cmd->mac_addr,
2446 &cmd->mac_mask);
2447
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302448 if (ie_whitelist->white_list)
2449 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
2450 &cmd->num_vendor_oui,
2451 ie_whitelist);
2452
Govind Singhd3156eb2016-02-26 17:50:39 +05302453 buf_ptr += sizeof(*cmd);
2454 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302455 for (i = 0; i < params->chan_list.num_chan; ++i)
2456 tmp_ptr[i] = params->chan_list.chan[i].freq;
Govind Singhd3156eb2016-02-26 17:50:39 +05302457
2458 WMITLV_SET_HDR(buf_ptr,
2459 WMITLV_TAG_ARRAY_UINT32,
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302460 (params->chan_list.num_chan * sizeof(uint32_t)));
2461 buf_ptr += WMI_TLV_HDR_SIZE +
2462 (params->chan_list.num_chan * sizeof(uint32_t));
2463
Govind Singh4eacd2b2016-03-07 14:24:22 +05302464 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302465 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302466 goto error;
2467 }
2468
2469 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2470 (params->num_ssids * sizeof(wmi_ssid)));
2471
2472 if (params->num_ssids) {
2473 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2474 for (i = 0; i < params->num_ssids; ++i) {
2475 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302476 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302477 params->ssid[i].length);
2478 ssid++;
2479 }
2480 }
2481 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2482
2483 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2484 (params->num_bssid * sizeof(wmi_mac_addr)));
2485 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302486
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302487 if (params->num_bssid) {
2488 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302489 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2490 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302491 bssid++;
2492 }
2493 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302494
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302495 buf_ptr += WMI_TLV_HDR_SIZE +
2496 (params->num_bssid * sizeof(wmi_mac_addr));
2497
2498 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2499 if (params->extraie.len)
2500 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2501 params);
2502
2503 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302504
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05302505 /* probe req ie whitelisting */
2506 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
2507 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
2508
2509 buf_ptr += WMI_TLV_HDR_SIZE;
2510
2511 if (cmd->num_vendor_oui) {
2512 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
2513 ie_whitelist->voui);
2514 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
2515 }
2516
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +05302517 /* Add phy mode TLV if it's a wide band scan */
2518 if (params->scan_f_wide_band) {
2519 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, phymode_roundup);
2520 buf_ptr = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2521 for (i = 0; i < params->chan_list.num_chan; ++i)
2522 buf_ptr[i] =
2523 WMI_SCAN_CHAN_SET_MODE(params->chan_list.chan[i].phymode);
2524 buf_ptr += phymode_roundup;
2525 } else {
2526 /* Add ZERO legth phy mode TLV */
2527 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, 0);
2528 }
2529
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302530 wmi_mtrace(WMI_START_SCAN_CMDID, cmd->vdev_id, 0);
Santosh Anbu1e11b472018-03-07 15:33:27 +05302531 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002532 len, WMI_START_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302533 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302534 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302535 wmi_buf_free(wmi_buf);
2536 }
2537 return ret;
2538error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302539 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302540 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302541}
2542
2543/**
2544 * send_scan_stop_cmd_tlv() - WMI scan start function
2545 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302546 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302547 *
2548 * Return: 0 on success and -ve on failure.
2549 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302550static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302551 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302552{
Govind Singhd3156eb2016-02-26 17:50:39 +05302553 wmi_stop_scan_cmd_fixed_param *cmd;
2554 int ret;
2555 int len = sizeof(*cmd);
2556 wmi_buf_t wmi_buf;
2557
2558 /* Allocate the memory */
2559 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2560 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302561 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302562 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302563 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302564 goto error;
2565 }
2566
2567 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2568 WMITLV_SET_HDR(&cmd->tlv_header,
2569 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2570 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2571 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302572 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302573 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302574 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2575 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302576 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302577 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2578 /* Cancelling all scans */
2579 cmd->req_type = WMI_SCAN_STOP_ALL;
2580 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2581 /* Cancelling VAP scans */
2582 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2583 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2584 /* Cancelling specific scan */
2585 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302586 } else {
2587 WMI_LOGE("%s: Invalid Command : ", __func__);
2588 wmi_buf_free(wmi_buf);
2589 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302590 }
2591
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302592 wmi_mtrace(WMI_STOP_SCAN_CMDID, cmd->vdev_id, 0);
Santosh Anbu1e11b472018-03-07 15:33:27 +05302593 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08002594 len, WMI_STOP_SCAN_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302595 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302596 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302597 wmi_buf_free(wmi_buf);
2598 }
2599
2600error:
2601 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302602}
2603
Govind Singh87542482016-06-08 19:40:11 +05302604#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302605/**
2606 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2607 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302608 * @param param : pointer to hold scan channel list parameter
2609 *
2610 * Return: 0 on success and -ve on failure.
2611 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302612static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302613 struct scan_chan_list_params *chan_list)
2614{
2615 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302616 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302617 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302618 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302619 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302620 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302621 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2622
2623 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2624 buf = wmi_buf_alloc(wmi_handle, len);
2625 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302626 WMI_LOGE("Failed to allocate memory");
2627 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302628 goto end;
2629 }
2630
2631 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2632 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2633 WMITLV_SET_HDR(&cmd->tlv_header,
2634 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2635 WMITLV_GET_STRUCT_TLVLEN
2636 (wmi_scan_chan_list_cmd_fixed_param));
2637
Govind Singhb53420c2016-03-09 14:32:57 +05302638 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302639
2640 cmd->num_scan_chans = chan_list->num_scan_chans;
2641 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2642 WMITLV_TAG_ARRAY_STRUC,
2643 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302644 chan_info = (wmi_channel_param *)
2645 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302646 tchan_info = chan_list->chan_info;
2647
2648 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2649 WMITLV_SET_HDR(&chan_info->tlv_header,
2650 WMITLV_TAG_STRUC_wmi_channel,
2651 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2652 chan_info->mhz = tchan_info->mhz;
2653 chan_info->band_center_freq1 =
2654 tchan_info->band_center_freq1;
2655 chan_info->band_center_freq2 =
2656 tchan_info->band_center_freq2;
2657 chan_info->info = tchan_info->info;
2658 chan_info->reg_info_1 = tchan_info->reg_info_1;
2659 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302660 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302661
2662 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2663 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2664 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2665 tchan_info++;
2666 chan_info++;
2667 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302668 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2669 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302670
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302671 wmi_mtrace(WMI_SCAN_CHAN_LIST_CMDID, NO_SESSION, 0);
Anish Natarajdd855152017-03-20 12:49:08 +05302672 qdf_status = wmi_unified_cmd_send(wmi_handle,
2673 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302674
Govind Singh67922e82016-04-01 16:48:57 +05302675 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302676 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302677 wmi_buf_free(buf);
2678 }
Govind Singh67922e82016-04-01 16:48:57 +05302679
Govind Singhd3156eb2016-02-26 17:50:39 +05302680end:
Govind Singhb53420c2016-03-09 14:32:57 +05302681 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302682}
Govind Singh87542482016-06-08 19:40:11 +05302683#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302684static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302685 struct scan_chan_list_params *chan_list)
2686{
2687 wmi_buf_t buf;
2688 QDF_STATUS qdf_status;
2689 wmi_scan_chan_list_cmd_fixed_param *cmd;
2690 int i;
2691 uint8_t *buf_ptr;
2692 wmi_channel *chan_info;
2693 struct channel_param *tchan_info;
2694 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302695
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302696 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302697 buf = wmi_buf_alloc(wmi_handle, len);
2698 if (!buf) {
2699 WMI_LOGE("Failed to allocate memory");
2700 qdf_status = QDF_STATUS_E_NOMEM;
2701 goto end;
2702 }
2703
2704 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2705 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2706 WMITLV_SET_HDR(&cmd->tlv_header,
2707 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2708 WMITLV_GET_STRUCT_TLVLEN
2709 (wmi_scan_chan_list_cmd_fixed_param));
2710
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302711 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302712
Om Prakash Tripathicd851c62017-12-15 17:29:55 +05302713 if (chan_list->append)
2714 cmd->flags |= APPEND_TO_EXISTING_CHAN_LIST;
2715
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302716 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2717 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302718 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302719 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2720 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302721 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302722 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2723 tchan_info = &(chan_list->ch_param[0]);
2724
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302725 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302726 WMITLV_SET_HDR(&chan_info->tlv_header,
2727 WMITLV_TAG_STRUC_wmi_channel,
2728 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2729 chan_info->mhz = tchan_info->mhz;
2730 chan_info->band_center_freq1 =
2731 tchan_info->cfreq1;
2732 chan_info->band_center_freq2 =
2733 tchan_info->cfreq2;
2734
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302735 if (tchan_info->is_chan_passive)
2736 WMI_SET_CHANNEL_FLAG(chan_info,
2737 WMI_CHAN_FLAG_PASSIVE);
2738
2739 if (tchan_info->allow_vht)
2740 WMI_SET_CHANNEL_FLAG(chan_info,
2741 WMI_CHAN_FLAG_ALLOW_VHT);
2742 else if (tchan_info->allow_ht)
2743 WMI_SET_CHANNEL_FLAG(chan_info,
2744 WMI_CHAN_FLAG_ALLOW_HT);
2745 WMI_SET_CHANNEL_MODE(chan_info,
2746 tchan_info->phy_mode);
2747
Shashikala Prabhuadb0aaa2018-03-26 09:10:35 +05302748 if (tchan_info->half_rate)
2749 WMI_SET_CHANNEL_FLAG(chan_info,
2750 WMI_CHAN_FLAG_HALF_RATE);
2751
2752 if (tchan_info->quarter_rate)
2753 WMI_SET_CHANNEL_FLAG(chan_info,
2754 WMI_CHAN_FLAG_QUARTER_RATE);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302755
2756 /* also fill in power information */
2757 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2758 tchan_info->minpower);
2759 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2760 tchan_info->maxpower);
2761 WMI_SET_CHANNEL_REG_POWER(chan_info,
2762 tchan_info->maxregpower);
2763 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2764 tchan_info->antennamax);
2765 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2766 tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -08002767 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
2768 tchan_info->maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302769
Govind Singh87542482016-06-08 19:40:11 +05302770 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2771
Govind Singh87542482016-06-08 19:40:11 +05302772 tchan_info++;
2773 chan_info++;
2774 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302775 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2776 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05302777
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302778 wmi_mtrace(WMI_SCAN_CHAN_LIST_CMDID, cmd->pdev_id, 0);
Anish Natarajdd855152017-03-20 12:49:08 +05302779 qdf_status = wmi_unified_cmd_send(
2780 wmi_handle,
2781 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05302782
2783 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2784 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2785 wmi_buf_free(buf);
2786 }
2787
2788end:
2789 return qdf_status;
2790}
2791#endif
Sathish Kumar5b636932017-06-28 14:40:32 +05302792
2793/**
2794 * populate_tx_send_params - Populate TX param TLV for mgmt and offchan tx
2795 *
2796 * @bufp: Pointer to buffer
2797 * @param: Pointer to tx param
2798 *
2799 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure
2800 */
2801static inline QDF_STATUS populate_tx_send_params(uint8_t *bufp,
Sathish Kumarefb25bf2018-10-02 11:03:59 +05302802 struct tx_send_params param)
Sathish Kumar5b636932017-06-28 14:40:32 +05302803{
2804 wmi_tx_send_params *tx_param;
2805 QDF_STATUS status = QDF_STATUS_SUCCESS;
2806
2807 if (!bufp) {
2808 status = QDF_STATUS_E_FAILURE;
2809 return status;
2810 }
2811 tx_param = (wmi_tx_send_params *)bufp;
2812 WMITLV_SET_HDR(&tx_param->tlv_header,
2813 WMITLV_TAG_STRUC_wmi_tx_send_params,
2814 WMITLV_GET_STRUCT_TLVLEN(wmi_tx_send_params));
2815 WMI_TX_SEND_PARAM_PWR_SET(tx_param->tx_param_dword0, param.pwr);
2816 WMI_TX_SEND_PARAM_MCS_MASK_SET(tx_param->tx_param_dword0,
2817 param.mcs_mask);
2818 WMI_TX_SEND_PARAM_NSS_MASK_SET(tx_param->tx_param_dword0,
2819 param.nss_mask);
2820 WMI_TX_SEND_PARAM_RETRY_LIMIT_SET(tx_param->tx_param_dword0,
2821 param.retry_limit);
2822 WMI_TX_SEND_PARAM_CHAIN_MASK_SET(tx_param->tx_param_dword1,
2823 param.chain_mask);
2824 WMI_TX_SEND_PARAM_BW_MASK_SET(tx_param->tx_param_dword1,
2825 param.bw_mask);
2826 WMI_TX_SEND_PARAM_PREAMBLE_SET(tx_param->tx_param_dword1,
2827 param.preamble_type);
2828 WMI_TX_SEND_PARAM_FRAME_TYPE_SET(tx_param->tx_param_dword1,
2829 param.frame_type);
2830
2831 return status;
2832}
2833
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05302834#ifdef CONFIG_HL_SUPPORT
2835/**
2836 * send_mgmt_cmd_tlv() - WMI scan start function
2837 * @wmi_handle : handle to WMI.
2838 * @param : pointer to hold mgmt cmd parameter
2839 *
2840 * Return: 0 on success and -ve on failure.
2841 */
2842static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
2843 struct wmi_mgmt_params *param)
2844{
2845 wmi_buf_t buf;
2846 uint8_t *bufp;
2847 int32_t cmd_len;
2848 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2849 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2850 mgmt_tx_dl_frm_len;
2851
2852 if (param->frm_len > mgmt_tx_dl_frm_len) {
2853 WMI_LOGE("%s:mgmt frame len %u exceeds %u",
2854 __func__, param->frm_len, mgmt_tx_dl_frm_len);
2855 return QDF_STATUS_E_INVAL;
2856 }
2857
2858 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
2859 WMI_TLV_HDR_SIZE +
2860 roundup(bufp_len, sizeof(uint32_t));
2861
2862 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
2863 if (!buf) {
2864 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2865 return QDF_STATUS_E_NOMEM;
2866 }
2867
2868 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2869 bufp = (uint8_t *) cmd;
2870 WMITLV_SET_HDR(&cmd->tlv_header,
2871 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2872 WMITLV_GET_STRUCT_TLVLEN
2873 (wmi_mgmt_tx_send_cmd_fixed_param));
2874
2875 cmd->vdev_id = param->vdev_id;
2876
2877 cmd->desc_id = param->desc_id;
2878 cmd->chanfreq = param->chanfreq;
2879 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2880 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2881 sizeof(uint32_t)));
2882 bufp += WMI_TLV_HDR_SIZE;
2883 qdf_mem_copy(bufp, param->pdata, bufp_len);
2884
2885 cmd->frame_len = param->frm_len;
2886 cmd->buf_len = bufp_len;
2887 cmd->tx_params_valid = param->tx_params_valid;
2888
2889 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
2890 bufp, cmd->vdev_id, cmd->chanfreq);
2891
2892 bufp += roundup(bufp_len, sizeof(uint32_t));
2893 if (param->tx_params_valid) {
2894 if (populate_tx_send_params(bufp, param->tx_param) !=
2895 QDF_STATUS_SUCCESS) {
2896 WMI_LOGE("%s: Populate TX send params failed",
2897 __func__);
2898 goto free_buf;
2899 }
2900 cmd_len += sizeof(wmi_tx_send_params);
2901 }
2902
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302903 wmi_mtrace(WMI_MGMT_TX_SEND_CMDID, cmd->vdev_id, 0);
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05302904 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2905 WMI_MGMT_TX_SEND_CMDID)) {
2906 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
2907 goto free_buf;
2908 }
2909 return QDF_STATUS_SUCCESS;
2910
2911free_buf:
2912 wmi_buf_free(buf);
2913 return QDF_STATUS_E_FAILURE;
2914}
2915#else
Govind Singhd3156eb2016-02-26 17:50:39 +05302916/**
2917 * send_mgmt_cmd_tlv() - WMI scan start function
2918 * @wmi_handle : handle to WMI.
2919 * @param : pointer to hold mgmt cmd parameter
2920 *
2921 * Return: 0 on success and -ve on failure.
2922 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302923static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302924 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302925{
Govind Singh427ee5a2016-02-26 18:09:36 +05302926 wmi_buf_t buf;
2927 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2928 int32_t cmd_len;
2929 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302930 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302931 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05302932 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302933 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2934 mgmt_tx_dl_frm_len;
2935
2936 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05302937 WMI_TLV_HDR_SIZE +
2938 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05302939
Sathish Kumar5b636932017-06-28 14:40:32 +05302940 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05302941 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302942 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2943 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302944 }
2945
2946 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2947 bufp = (uint8_t *) cmd;
2948 WMITLV_SET_HDR(&cmd->tlv_header,
2949 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2950 WMITLV_GET_STRUCT_TLVLEN
2951 (wmi_mgmt_tx_send_cmd_fixed_param));
2952
2953 cmd->vdev_id = param->vdev_id;
2954
Govind Singh224a7312016-06-21 14:33:26 +05302955 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302956 cmd->chanfreq = param->chanfreq;
2957 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2958 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2959 sizeof(uint32_t)));
2960 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302961 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302962
2963 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
2964 QDF_DMA_TO_DEVICE);
2965 if (status != QDF_STATUS_SUCCESS) {
2966 WMI_LOGE("%s: wmi buf map failed", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05302967 goto free_buf;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302968 }
2969
Govind Singhb53420c2016-03-09 14:32:57 +05302970 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302971 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08002972#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05302973 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2974#endif
2975 cmd->frame_len = param->frm_len;
2976 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05302977 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05302978
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002979 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002980 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002981
Sathish Kumar5b636932017-06-28 14:40:32 +05302982 bufp += roundup(bufp_len, sizeof(uint32_t));
2983 if (param->tx_params_valid) {
2984 status = populate_tx_send_params(bufp, param->tx_param);
2985 if (status != QDF_STATUS_SUCCESS) {
2986 WMI_LOGE("%s: Populate TX send params failed",
2987 __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05302988 goto unmap_tx_frame;
Sathish Kumar5b636932017-06-28 14:40:32 +05302989 }
2990 cmd_len += sizeof(wmi_tx_send_params);
2991 }
2992
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05302993 wmi_mtrace(WMI_MGMT_TX_SEND_CMDID, cmd->vdev_id, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302994 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2995 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302996 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05302997 goto unmap_tx_frame;
Govind Singh427ee5a2016-02-26 18:09:36 +05302998 }
Govind Singhb53420c2016-03-09 14:32:57 +05302999 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303000
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303001unmap_tx_frame:
3002 qdf_nbuf_unmap_single(qdf_ctx, param->tx_frame,
3003 QDF_DMA_TO_DEVICE);
3004free_buf:
Govind Singh427ee5a2016-02-26 18:09:36 +05303005 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303006 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303007}
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05303008#endif /* CONFIG_HL_SUPPORT */
Govind Singh427ee5a2016-02-26 18:09:36 +05303009
3010/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303011 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
3012 * @wmi_handle : handle to WMI.
3013 * @param : pointer to offchan data tx cmd parameter
3014 *
3015 * Return: QDF_STATUS_SUCCESS on success and error on failure.
3016 */
3017static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
3018 struct wmi_offchan_data_tx_params *param)
3019{
3020 wmi_buf_t buf;
3021 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
3022 int32_t cmd_len;
3023 uint64_t dma_addr;
3024 void *qdf_ctx = param->qdf_ctx;
3025 uint8_t *bufp;
3026 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
3027 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303028 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303029
3030 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303031 WMI_TLV_HDR_SIZE +
3032 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303033
Sathish Kumar5b636932017-06-28 14:40:32 +05303034 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303035 if (!buf) {
3036 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3037 return QDF_STATUS_E_NOMEM;
3038 }
3039
3040 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
3041 bufp = (uint8_t *) cmd;
3042 WMITLV_SET_HDR(&cmd->tlv_header,
3043 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
3044 WMITLV_GET_STRUCT_TLVLEN
3045 (wmi_offchan_data_tx_send_cmd_fixed_param));
3046
3047 cmd->vdev_id = param->vdev_id;
3048
3049 cmd->desc_id = param->desc_id;
3050 cmd->chanfreq = param->chanfreq;
3051 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
3052 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3053 sizeof(uint32_t)));
3054 bufp += WMI_TLV_HDR_SIZE;
3055 qdf_mem_copy(bufp, param->pdata, bufp_len);
3056 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
3057 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
3058 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
3059#if defined(HTT_PADDR64)
3060 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3061#endif
3062 cmd->frame_len = param->frm_len;
3063 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303064 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303065
3066 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
3067 bufp, cmd->vdev_id, cmd->chanfreq);
3068
Sathish Kumar5b636932017-06-28 14:40:32 +05303069 bufp += roundup(bufp_len, sizeof(uint32_t));
3070 if (param->tx_params_valid) {
3071 status = populate_tx_send_params(bufp, param->tx_param);
3072 if (status != QDF_STATUS_SUCCESS) {
3073 WMI_LOGE("%s: Populate TX send params failed",
3074 __func__);
3075 goto err1;
3076 }
3077 cmd_len += sizeof(wmi_tx_send_params);
3078 }
3079
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303080 wmi_mtrace(WMI_OFFCHAN_DATA_TX_SEND_CMDID, cmd->vdev_id, 0);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303081 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3082 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
3083 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05303084 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303085 }
3086
3087 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05303088
3089err1:
3090 wmi_buf_free(buf);
3091 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303092}
3093
3094/**
Govind Singh427ee5a2016-02-26 18:09:36 +05303095 * send_modem_power_state_cmd_tlv() - set modem power state to fw
3096 * @wmi_handle: wmi handle
3097 * @param_value: parameter value
3098 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303099 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05303100 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303101static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303102 uint32_t param_value)
3103{
Govind Singh67922e82016-04-01 16:48:57 +05303104 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303105 wmi_modem_power_state_cmd_param *cmd;
3106 wmi_buf_t buf;
3107 uint16_t len = sizeof(*cmd);
3108
3109 buf = wmi_buf_alloc(wmi_handle, len);
3110 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303111 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303112 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303113 }
3114 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
3115 WMITLV_SET_HDR(&cmd->tlv_header,
3116 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
3117 WMITLV_GET_STRUCT_TLVLEN
3118 (wmi_modem_power_state_cmd_param));
3119 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05303120 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05303121 param_value);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303122 wmi_mtrace(WMI_MODEM_POWER_STATE_CMDID, NO_SESSION, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303123 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3124 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303125 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303126 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303127 wmi_buf_free(buf);
3128 }
Govind Singh67922e82016-04-01 16:48:57 +05303129
Govind Singh427ee5a2016-02-26 18:09:36 +05303130 return ret;
3131}
3132
3133/**
3134 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
3135 * @wmi_handle: wmi handle
3136 * @vdev_id: vdev id
3137 * @val: value
3138 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303139 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303140 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303141static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303142 uint32_t vdev_id, uint8_t val)
3143{
3144 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
3145 wmi_buf_t buf;
3146 int32_t len = sizeof(*cmd);
3147
Govind Singhb53420c2016-03-09 14:32:57 +05303148 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05303149
3150 buf = wmi_buf_alloc(wmi_handle, len);
3151 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303152 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303153 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303154 }
3155 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
3156 WMITLV_SET_HDR(&cmd->tlv_header,
3157 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
3158 WMITLV_GET_STRUCT_TLVLEN
3159 (wmi_sta_powersave_mode_cmd_fixed_param));
3160 cmd->vdev_id = vdev_id;
3161 if (val)
3162 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
3163 else
3164 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
3165
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303166 wmi_mtrace(WMI_STA_POWERSAVE_MODE_CMDID, cmd->vdev_id, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303167 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3168 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303169 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303170 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303171 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05303172 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303173 }
Govind Singh5eb51532016-03-09 11:34:12 +05303174 return 0;
3175}
3176
Govind Singh427ee5a2016-02-26 18:09:36 +05303177/**
3178 * send_set_mimops_cmd_tlv() - set MIMO powersave
3179 * @wmi_handle: wmi handle
3180 * @vdev_id: vdev id
3181 * @value: value
3182 *
Govind Singhb53420c2016-03-09 14:32:57 +05303183 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303184 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303185static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303186 uint8_t vdev_id, int value)
3187{
Govind Singh67922e82016-04-01 16:48:57 +05303188 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303189 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
3190 wmi_buf_t buf;
3191 uint16_t len = sizeof(*cmd);
3192
3193 buf = wmi_buf_alloc(wmi_handle, len);
3194 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303195 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303196 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303197 }
3198 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
3199 WMITLV_SET_HDR(&cmd->tlv_header,
3200 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
3201 WMITLV_GET_STRUCT_TLVLEN
3202 (wmi_sta_smps_force_mode_cmd_fixed_param));
3203
3204 cmd->vdev_id = vdev_id;
3205
Houston Hoffmanb5168052016-04-14 02:18:01 -07003206 /* WMI_SMPS_FORCED_MODE values do not directly map
3207 * to SM power save values defined in the specification.
3208 * Make sure to send the right mapping.
3209 */
Govind Singh427ee5a2016-02-26 18:09:36 +05303210 switch (value) {
3211 case 0:
3212 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
3213 break;
3214 case 1:
3215 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
3216 break;
3217 case 2:
3218 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
3219 break;
3220 case 3:
3221 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
3222 break;
3223 default:
Govind Singhb53420c2016-03-09 14:32:57 +05303224 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
Surabhi Vishnoi83f677e2018-04-26 09:46:39 +05303225 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303226 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303227 }
3228
Govind Singhb53420c2016-03-09 14:32:57 +05303229 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303230
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303231 wmi_mtrace(WMI_STA_SMPS_FORCE_MODE_CMDID, cmd->vdev_id, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303232 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3233 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303234 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303235 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303236 wmi_buf_free(buf);
3237 }
3238
3239 return ret;
3240}
3241
3242/**
3243 * send_set_smps_params_cmd_tlv() - set smps params
3244 * @wmi_handle: wmi handle
3245 * @vdev_id: vdev id
3246 * @value: value
3247 *
Govind Singhb53420c2016-03-09 14:32:57 +05303248 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303249 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303250static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303251 int value)
3252{
Govind Singh67922e82016-04-01 16:48:57 +05303253 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303254 wmi_sta_smps_param_cmd_fixed_param *cmd;
3255 wmi_buf_t buf;
3256 uint16_t len = sizeof(*cmd);
3257
3258 buf = wmi_buf_alloc(wmi_handle, len);
3259 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303260 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303261 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303262 }
3263 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3264 WMITLV_SET_HDR(&cmd->tlv_header,
3265 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3266 WMITLV_GET_STRUCT_TLVLEN
3267 (wmi_sta_smps_param_cmd_fixed_param));
3268
3269 cmd->vdev_id = vdev_id;
3270 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3271 cmd->param =
3272 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3273
Govind Singhb53420c2016-03-09 14:32:57 +05303274 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303275 cmd->param);
3276
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303277 wmi_mtrace(WMI_STA_SMPS_PARAM_CMDID, cmd->vdev_id, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303278 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3279 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303280 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303281 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303282 wmi_buf_free(buf);
3283 }
3284
3285 return ret;
3286}
3287
3288/**
Govind Singh427ee5a2016-02-26 18:09:36 +05303289 * send_get_temperature_cmd_tlv() - get pdev temperature req
3290 * @wmi_handle: wmi handle
3291 *
Govind Singhb53420c2016-03-09 14:32:57 +05303292 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303293 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303294static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303295{
3296 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3297 wmi_buf_t wmi_buf;
3298 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3299 uint8_t *buf_ptr;
3300
3301 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303302 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3303 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303304 }
3305
3306 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3307 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303308 WMI_LOGE(FL("wmi_buf_alloc failed"));
3309 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303310 }
3311
3312 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3313
3314 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3315 WMITLV_SET_HDR(&cmd->tlv_header,
3316 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3317 WMITLV_GET_STRUCT_TLVLEN
3318 (wmi_pdev_get_temperature_cmd_fixed_param));
3319
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303320 wmi_mtrace(WMI_PDEV_GET_TEMPERATURE_CMDID, NO_SESSION, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303321 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3322 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303323 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303324 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303325 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303326 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303327
Govind Singhb53420c2016-03-09 14:32:57 +05303328 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303329}
3330
3331/**
3332 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3333 * @wmi_handle: wmi handle
3334 * @vdevid: vdev id
3335 * @peer_addr: peer mac address
3336 * @auto_triggerparam: auto trigger parameters
3337 * @num_ac: number of access category
3338 *
3339 * This function sets the trigger
3340 * uapsd params such as service interval, delay interval
3341 * and suspend interval which will be used by the firmware
3342 * to send trigger frames periodically when there is no
3343 * traffic on the transmit side.
3344 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303345 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303346 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303347static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303348 struct sta_uapsd_trig_params *param)
3349{
3350 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303351 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303352 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3353 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3354 uint32_t i;
3355 wmi_buf_t buf;
3356 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003357 struct sta_uapsd_params *uapsd_param;
3358 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303359
3360 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3361 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303362 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303363 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303364 }
3365
3366 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3367 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3368 WMITLV_SET_HDR(&cmd->tlv_header,
3369 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3370 WMITLV_GET_STRUCT_TLVLEN
3371 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3372 cmd->vdev_id = param->vdevid;
3373 cmd->num_ac = param->num_ac;
3374 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3375
3376 /* TLV indicating array of structures to follow */
3377 buf_ptr += sizeof(*cmd);
3378 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3379
3380 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303381
3382 /*
3383 * Update tag and length for uapsd auto trigger params (this will take
3384 * care of updating tag and length if it is not pre-filled by caller).
3385 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003386 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3387 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303388 for (i = 0; i < param->num_ac; i++) {
3389 WMITLV_SET_HDR((buf_ptr +
3390 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3391 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3392 WMITLV_GET_STRUCT_TLVLEN
3393 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003394 trig_param->wmm_ac = uapsd_param->wmm_ac;
3395 trig_param->user_priority = uapsd_param->user_priority;
3396 trig_param->service_interval = uapsd_param->service_interval;
3397 trig_param->suspend_interval = uapsd_param->suspend_interval;
3398 trig_param->delay_interval = uapsd_param->delay_interval;
3399 trig_param++;
3400 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303401 }
3402
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303403 wmi_mtrace(WMI_STA_UAPSD_AUTO_TRIG_CMDID, cmd->vdev_id, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303404 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3405 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303406 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303407 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303408 wmi_buf_free(buf);
3409 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303410
Govind Singh427ee5a2016-02-26 18:09:36 +05303411 return ret;
3412}
3413
Govind Singh17a9cfa2016-03-01 15:54:59 +05303414/**
3415 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
3416 * @wmi_handle: Pointer to wmi handle
3417 * @thermal_info: Thermal command information
3418 *
3419 * This function sends the thermal management command
3420 * to the firmware
3421 *
Govind Singhb53420c2016-03-09 14:32:57 +05303422 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303423 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303424static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303425 struct thermal_cmd_params *thermal_info)
3426{
3427 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
3428 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05303429 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303430 uint32_t len = 0;
3431
3432 len = sizeof(*cmd);
3433
3434 buf = wmi_buf_alloc(wmi_handle, len);
3435 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303436 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3437 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303438 }
3439
3440 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
3441
3442 WMITLV_SET_HDR(&cmd->tlv_header,
3443 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
3444 WMITLV_GET_STRUCT_TLVLEN
3445 (wmi_thermal_mgmt_cmd_fixed_param));
3446
3447 cmd->lower_thresh_degreeC = thermal_info->min_temp;
3448 cmd->upper_thresh_degreeC = thermal_info->max_temp;
3449 cmd->enable = thermal_info->thermal_enable;
3450
Govind Singhb53420c2016-03-09 14:32:57 +05303451 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303452 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
3453
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303454 wmi_mtrace(WMI_THERMAL_MGMT_CMDID, NO_SESSION, 0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303455 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3456 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303457 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303458 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303459 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303460 }
3461
Govind Singh67922e82016-04-01 16:48:57 +05303462 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303463}
3464
Govind Singh17a9cfa2016-03-01 15:54:59 +05303465/**
3466 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05303467 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05303468 * @wmi_lro_cmd: Pointer to LRO configuration parameters
3469 *
3470 * This function sends down the LRO configuration parameters to
3471 * the firmware to enable LRO, sets the TCP flags and sets the
3472 * seed values for the toeplitz hash generation
3473 *
Govind Singhb53420c2016-03-09 14:32:57 +05303474 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303475 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303476static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303477 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
3478{
3479 wmi_lro_info_cmd_fixed_param *cmd;
3480 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303481 QDF_STATUS status;
Tallapragada Kalyan85a74002018-08-28 12:34:21 +05303482 uint8_t pdev_id = wmi_lro_cmd->pdev_id;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303483
3484 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3485 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303486 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3487 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303488 }
3489
3490 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
3491
3492 WMITLV_SET_HDR(&cmd->tlv_header,
3493 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
3494 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
3495
3496 cmd->lro_enable = wmi_lro_cmd->lro_enable;
3497 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
3498 wmi_lro_cmd->tcp_flag);
3499 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
3500 wmi_lro_cmd->tcp_flag_mask);
3501 cmd->toeplitz_hash_ipv4_0_3 =
3502 wmi_lro_cmd->toeplitz_hash_ipv4[0];
3503 cmd->toeplitz_hash_ipv4_4_7 =
3504 wmi_lro_cmd->toeplitz_hash_ipv4[1];
3505 cmd->toeplitz_hash_ipv4_8_11 =
3506 wmi_lro_cmd->toeplitz_hash_ipv4[2];
3507 cmd->toeplitz_hash_ipv4_12_15 =
3508 wmi_lro_cmd->toeplitz_hash_ipv4[3];
3509 cmd->toeplitz_hash_ipv4_16 =
3510 wmi_lro_cmd->toeplitz_hash_ipv4[4];
3511
3512 cmd->toeplitz_hash_ipv6_0_3 =
3513 wmi_lro_cmd->toeplitz_hash_ipv6[0];
3514 cmd->toeplitz_hash_ipv6_4_7 =
3515 wmi_lro_cmd->toeplitz_hash_ipv6[1];
3516 cmd->toeplitz_hash_ipv6_8_11 =
3517 wmi_lro_cmd->toeplitz_hash_ipv6[2];
3518 cmd->toeplitz_hash_ipv6_12_15 =
3519 wmi_lro_cmd->toeplitz_hash_ipv6[3];
3520 cmd->toeplitz_hash_ipv6_16_19 =
3521 wmi_lro_cmd->toeplitz_hash_ipv6[4];
3522 cmd->toeplitz_hash_ipv6_20_23 =
3523 wmi_lro_cmd->toeplitz_hash_ipv6[5];
3524 cmd->toeplitz_hash_ipv6_24_27 =
3525 wmi_lro_cmd->toeplitz_hash_ipv6[6];
3526 cmd->toeplitz_hash_ipv6_28_31 =
3527 wmi_lro_cmd->toeplitz_hash_ipv6[7];
3528 cmd->toeplitz_hash_ipv6_32_35 =
3529 wmi_lro_cmd->toeplitz_hash_ipv6[8];
3530 cmd->toeplitz_hash_ipv6_36_39 =
3531 wmi_lro_cmd->toeplitz_hash_ipv6[9];
3532 cmd->toeplitz_hash_ipv6_40 =
3533 wmi_lro_cmd->toeplitz_hash_ipv6[10];
3534
Tallapragada Kalyan85a74002018-08-28 12:34:21 +05303535 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
3536 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x, pdev_id: %d",
3537 cmd->lro_enable, cmd->tcp_flag_u32, cmd->pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303538
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303539 wmi_mtrace(WMI_LRO_CONFIG_CMDID, NO_SESSION, 0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303540 status = wmi_unified_cmd_send(wmi_handle, buf,
3541 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303542 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303543 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303544 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303545 }
3546
Govind Singh67922e82016-04-01 16:48:57 +05303547 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303548}
3549
Govind Singh4eacd2b2016-03-07 14:24:22 +05303550/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303551 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
3552 * @wmi_handle: Pointer to wmi handle
3553 * @rate_report_params: Pointer to peer rate report parameters
3554 *
3555 *
3556 * Return: QDF_STATUS_SUCCESS for success otherwise failure
3557 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303558static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303559 struct wmi_peer_rate_report_params *rate_report_params)
3560{
3561 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
3562 wmi_buf_t buf = NULL;
3563 QDF_STATUS status = 0;
3564 uint32_t len = 0;
3565 uint32_t i, j;
3566
3567 len = sizeof(*cmd);
3568
3569 buf = wmi_buf_alloc(wmi_handle, len);
3570 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05303571 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd");
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303572 return QDF_STATUS_E_FAILURE;
3573 }
3574
3575 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
3576 wmi_buf_data(buf);
3577
3578 WMITLV_SET_HDR(
3579 &cmd->tlv_header,
3580 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
3581 WMITLV_GET_STRUCT_TLVLEN(
3582 wmi_peer_set_rate_report_condition_fixed_param));
3583
3584 cmd->enable_rate_report = rate_report_params->rate_report_enable;
3585 cmd->report_backoff_time = rate_report_params->backoff_time;
3586 cmd->report_timer_period = rate_report_params->timer_period;
3587 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05303588 cmd->cond_per_phy[i].val_cond_flags =
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303589 rate_report_params->report_per_phy[i].cond_flags;
3590 cmd->cond_per_phy[i].rate_delta.min_delta =
3591 rate_report_params->report_per_phy[i].delta.delta_min;
3592 cmd->cond_per_phy[i].rate_delta.percentage =
3593 rate_report_params->report_per_phy[i].delta.percent;
3594 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
3595 cmd->cond_per_phy[i].rate_threshold[j] =
3596 rate_report_params->report_per_phy[i].
3597 report_rate_threshold[j];
3598 }
3599 }
3600
Sathish Kumarefb25bf2018-10-02 11:03:59 +05303601 WMI_LOGE("%s enable %d backoff_time %d period %d", __func__,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303602 cmd->enable_rate_report,
3603 cmd->report_backoff_time, cmd->report_timer_period);
3604
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303605 wmi_mtrace(WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID, NO_SESSION, 0);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303606 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3607 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
3608 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303609 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303610 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
3611 __func__);
3612 }
3613 return status;
3614}
3615
3616/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05303617 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
3618 * @wmi_handle: wmi handle
3619 * @param: bcn ll cmd parameter
3620 *
Govind Singhb53420c2016-03-09 14:32:57 +05303621 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05303622 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303623static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303624 wmi_bcn_send_from_host_cmd_fixed_param *param)
3625{
3626 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
3627 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05303628 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303629
3630 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3631 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303632 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
3633 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303634 }
3635
3636 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
3637 WMITLV_SET_HDR(&cmd->tlv_header,
3638 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
3639 WMITLV_GET_STRUCT_TLVLEN
3640 (wmi_bcn_send_from_host_cmd_fixed_param));
3641 cmd->vdev_id = param->vdev_id;
3642 cmd->data_len = param->data_len;
3643 cmd->frame_ctrl = param->frame_ctrl;
3644 cmd->frag_ptr = param->frag_ptr;
3645 cmd->dtim_flag = param->dtim_flag;
3646
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303647 wmi_mtrace(WMI_PDEV_SEND_BCN_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303648 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
3649 WMI_PDEV_SEND_BCN_CMDID);
3650
Govind Singh67922e82016-04-01 16:48:57 +05303651 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303652 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05303653 wmi_buf_free(wmi_buf);
3654 }
3655
3656 return ret;
3657}
3658
3659/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05303660 * send_process_update_edca_param_cmd_tlv() - update EDCA params
3661 * @wmi_handle: wmi handle
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05303662 * @vdev_id: vdev id.
3663 * @wmm_vparams: edca parameters
Govind Singh4eacd2b2016-03-07 14:24:22 +05303664 *
3665 * This function updates EDCA parameters to the target
3666 *
3667 * Return: CDF Status
3668 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303669static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07003670 uint8_t vdev_id, bool mu_edca_param,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05303671 struct wmi_host_wme_vparams wmm_vparams[WMI_MAX_NUM_AC])
Govind Singh4eacd2b2016-03-07 14:24:22 +05303672{
3673 uint8_t *buf_ptr;
3674 wmi_buf_t buf;
3675 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05303676 wmi_wmm_vparams *wmm_param;
3677 struct wmi_host_wme_vparams *twmm_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303678 int len = sizeof(*cmd);
3679 int ac;
3680
3681 buf = wmi_buf_alloc(wmi_handle, len);
3682
3683 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303684 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
3685 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303686 }
3687
3688 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3689 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
3690 WMITLV_SET_HDR(&cmd->tlv_header,
3691 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
3692 WMITLV_GET_STRUCT_TLVLEN
3693 (wmi_vdev_set_wmm_params_cmd_fixed_param));
3694 cmd->vdev_id = vdev_id;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07003695 cmd->wmm_param_type = mu_edca_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303696
3697 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
3698 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05303699 twmm_param = (struct wmi_host_wme_vparams *) (&wmm_vparams[ac]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303700 WMITLV_SET_HDR(&wmm_param->tlv_header,
3701 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
3702 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
3703 wmm_param->cwmin = twmm_param->cwmin;
3704 wmm_param->cwmax = twmm_param->cwmax;
3705 wmm_param->aifs = twmm_param->aifs;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07003706 if (mu_edca_param)
3707 wmm_param->mu_edca_timer = twmm_param->mu_edca_timer;
3708 else
3709 wmm_param->txoplimit = twmm_param->txoplimit;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303710 wmm_param->acm = twmm_param->acm;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05303711 wmm_param->no_ack = twmm_param->noackpolicy;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303712 }
3713
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303714 wmi_mtrace(WMI_VDEV_SET_WMM_PARAMS_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303715 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3716 WMI_VDEV_SET_WMM_PARAMS_CMDID))
3717 goto fail;
3718
Govind Singhb53420c2016-03-09 14:32:57 +05303719 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303720
3721fail:
3722 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303723 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
3724 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303725}
3726
3727/**
3728 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
3729 * @wmi_handle: wmi handle
3730 * @vdev_id: vdev id
3731 * @probe_rsp_info: probe response info
3732 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303733 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05303734 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303735static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303736 uint8_t vdev_id,
Krunal Soni89426862017-11-14 15:42:48 -08003737 struct wmi_probe_resp_params *probe_rsp_info)
Govind Singh4eacd2b2016-03-07 14:24:22 +05303738{
3739 wmi_prb_tmpl_cmd_fixed_param *cmd;
3740 wmi_bcn_prb_info *bcn_prb_info;
3741 wmi_buf_t wmi_buf;
3742 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
3743 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05303744 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303745
Govind Singhb53420c2016-03-09 14:32:57 +05303746 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303747
Krunal Soni89426862017-11-14 15:42:48 -08003748 tmpl_len = probe_rsp_info->prb_rsp_template_len;
Vivekc5823092018-03-22 23:27:21 +05303749 tmpl_len_aligned = roundup(tmpl_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05303750
3751 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
3752 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
3753 tmpl_len_aligned;
3754
3755 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05303756 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05303757 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05303758 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303759 }
3760
3761 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
3762 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303763 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303764 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303765 }
3766
3767 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3768
3769 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
3770 WMITLV_SET_HDR(&cmd->tlv_header,
3771 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
3772 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
3773 cmd->vdev_id = vdev_id;
3774 cmd->buf_len = tmpl_len;
3775 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
3776
3777 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
3778 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
3779 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
3780 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
3781 bcn_prb_info->caps = 0;
3782 bcn_prb_info->erp = 0;
3783 buf_ptr += sizeof(wmi_bcn_prb_info);
3784
3785 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
3786 buf_ptr += WMI_TLV_HDR_SIZE;
Krunal Soni89426862017-11-14 15:42:48 -08003787 qdf_mem_copy(buf_ptr, probe_rsp_info->prb_rsp_template_frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303788
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303789 wmi_mtrace(WMI_PRB_TMPL_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303790 ret = wmi_unified_cmd_send(wmi_handle,
3791 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303792 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303793 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303794 wmi_buf_free(wmi_buf);
3795 }
3796
3797 return ret;
3798}
3799
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05303800#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303801#define WPI_IV_LEN 16
3802
3803/**
3804 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
3805 *
3806 * @dest_tx: destination address of tsc key counter
3807 * @src_tx: source address of tsc key counter
3808 * @dest_rx: destination address of rsc key counter
3809 * @src_rx: source address of rsc key counter
3810 *
3811 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
3812 *
3813 * Return: None
3814 *
3815 */
3816static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
3817 uint8_t *dest_rx, uint8_t *src_rx)
3818{
3819 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
3820 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
3821}
3822#else
3823static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
3824 uint8_t *dest_rx, uint8_t *src_rx)
3825{
3826 return;
3827}
3828#endif
3829
3830/**
3831 * send_setup_install_key_cmd_tlv() - set key parameters
3832 * @wmi_handle: wmi handle
3833 * @key_params: key parameters
3834 *
3835 * This function fills structure from information
3836 * passed in key_params.
3837 *
3838 * Return: QDF_STATUS_SUCCESS - success
Sathish Kumarefb25bf2018-10-02 11:03:59 +05303839 * QDF_STATUS_E_FAILURE - failure
3840 * QDF_STATUS_E_NOMEM - not able to allocate buffer
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303841 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303842static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303843 struct set_key_params *key_params)
3844{
3845 wmi_vdev_install_key_cmd_fixed_param *cmd;
3846 wmi_buf_t buf;
3847 uint8_t *buf_ptr;
3848 uint32_t len;
3849 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05303850 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303851
3852 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
3853 WMI_TLV_HDR_SIZE;
3854
3855 buf = wmi_buf_alloc(wmi_handle, len);
3856 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05303857 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303858 return QDF_STATUS_E_NOMEM;
3859 }
3860
3861 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3862 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
3863 WMITLV_SET_HDR(&cmd->tlv_header,
3864 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
3865 WMITLV_GET_STRUCT_TLVLEN
3866 (wmi_vdev_install_key_cmd_fixed_param));
3867 cmd->vdev_id = key_params->vdev_id;
3868 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05303869
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05303870
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303871 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
3872 cmd->key_flags |= key_params->key_flags;
3873 cmd->key_cipher = key_params->key_cipher;
3874 if ((key_params->key_txmic_len) &&
3875 (key_params->key_rxmic_len)) {
3876 cmd->key_txmic_len = key_params->key_txmic_len;
3877 cmd->key_rxmic_len = key_params->key_rxmic_len;
3878 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05303879#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303880 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
3881 key_params->tx_iv,
3882 cmd->wpi_key_rsc_counter,
3883 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05303884#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303885 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
3886 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3887 roundup(key_params->key_len, sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +05303888 key_data = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303889 qdf_mem_copy((void *)key_data,
3890 (const void *)key_params->key_data, key_params->key_len);
Krunal Soni3a0fd852017-10-24 23:33:05 -07003891 if (key_params->key_rsc_counter)
3892 qdf_mem_copy(&cmd->key_rsc_counter, key_params->key_rsc_counter,
3893 sizeof(wmi_key_seq_counter));
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303894 cmd->key_len = key_params->key_len;
3895
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303896 wmi_mtrace(WMI_VDEV_INSTALL_KEY_CMDID, cmd->vdev_id, 0);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303897 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3898 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303899 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05303900 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303901
Govind Singh67922e82016-04-01 16:48:57 +05303902 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05303903}
3904
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05303905/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05303906 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
3907 * @wmi_handle: wmi handle
3908 * @vdev_id: vdev id
3909 * @p2p_ie: p2p IE
3910 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303911 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05303912 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303913static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05303914 uint32_t vdev_id, uint8_t *p2p_ie)
Govind Singh4eacd2b2016-03-07 14:24:22 +05303915{
Govind Singh67922e82016-04-01 16:48:57 +05303916 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303917 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
3918 wmi_buf_t wmi_buf;
3919 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
3920 uint8_t *buf_ptr;
3921
3922 ie_len = (uint32_t) (p2p_ie[1] + 2);
3923
3924 /* More than one P2P IE may be included in a single frame.
3925 If multiple P2P IEs are present, the complete P2P attribute
3926 data consists of the concatenation of the P2P Attribute
3927 fields of the P2P IEs. The P2P Attributes field of each
3928 P2P IE may be any length up to the maximum (251 octets).
3929 In this case host sends one P2P IE to firmware so the length
3930 should not exceed more than 251 bytes
3931 */
3932 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05303933 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05303934 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303935 }
3936
Vivekc5823092018-03-22 23:27:21 +05303937 ie_len_aligned = roundup(ie_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05303938
3939 wmi_buf_len =
3940 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
3941 WMI_TLV_HDR_SIZE;
3942
3943 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
3944 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303945 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303946 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303947 }
3948
3949 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3950
3951 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
3952 WMITLV_SET_HDR(&cmd->tlv_header,
3953 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
3954 WMITLV_GET_STRUCT_TLVLEN
3955 (wmi_p2p_go_set_beacon_ie_fixed_param));
3956 cmd->vdev_id = vdev_id;
3957 cmd->ie_buf_len = ie_len;
3958
3959 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
3960 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
3961 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303962 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303963
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +05303964 WMI_LOGD("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303965
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05303966 wmi_mtrace(WMI_P2P_GO_SET_BEACON_IE, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303967 ret = wmi_unified_cmd_send(wmi_handle,
3968 wmi_buf, wmi_buf_len,
3969 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05303970 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303971 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303972 wmi_buf_free(wmi_buf);
3973 }
3974
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +05303975 WMI_LOGD("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05303976 return ret;
3977}
3978
3979/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05303980 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
3981 * @wmi_handle: wmi handle
3982 * @psetoui: OUI parameters
3983 *
3984 * set scan probe OUI parameters in firmware
3985 *
3986 * Return: CDF status
3987 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303988static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05303989 struct scan_mac_oui *psetoui)
3990{
3991 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
3992 wmi_buf_t wmi_buf;
3993 uint32_t len;
3994 uint8_t *buf_ptr;
3995 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05303996 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05303997
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05303998 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
3999 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
4000
Govind Singh4eacd2b2016-03-07 14:24:22 +05304001 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4002 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304003 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4004 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304005 }
4006 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4007 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
4008 WMITLV_SET_HDR(&cmd->tlv_header,
4009 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
4010 WMITLV_GET_STRUCT_TLVLEN
4011 (wmi_scan_prob_req_oui_cmd_fixed_param));
4012
4013 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05304014 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304015 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
4016 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05304017 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304018 cmd->prob_req_oui);
4019
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05304020 cmd->vdev_id = psetoui->vdev_id;
4021 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
4022 if (psetoui->enb_probe_req_sno_randomization)
4023 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
4024
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05304025 if (ie_whitelist->white_list) {
4026 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
4027 &cmd->num_vendor_oui,
4028 ie_whitelist);
4029 cmd->flags |=
4030 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
4031 }
4032
4033 buf_ptr += sizeof(*cmd);
4034 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4035 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
4036 buf_ptr += WMI_TLV_HDR_SIZE;
4037
4038 if (cmd->num_vendor_oui != 0) {
4039 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
4040 ie_whitelist->voui);
4041 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
4042 }
4043
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304044 wmi_mtrace(WMI_SCAN_PROB_REQ_OUI_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304045 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4046 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304047 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304048 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304049 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304050 }
Govind Singhb53420c2016-03-09 14:32:57 +05304051 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304052}
4053
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05304054#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05304055/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
4056 * @wmi_handle: wmi handle
4057 * @ipa_offload: ipa offload control parameter
4058 *
4059 * Returns: 0 on success, error number otherwise
4060 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304061static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05304062 struct ipa_uc_offload_control_params *ipa_offload)
Govind Singh4eacd2b2016-03-07 14:24:22 +05304063{
4064 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
4065 wmi_buf_t wmi_buf;
4066 uint32_t len;
4067 u_int8_t *buf_ptr;
4068
4069 len = sizeof(*cmd);
4070 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4071 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304072 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
4073 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304074 }
4075
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08004076 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304077 ipa_offload->offload_type, ipa_offload->enable);
4078
4079 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
4080
4081 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
4082 WMITLV_SET_HDR(&cmd->tlv_header,
4083 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
4084 WMITLV_GET_STRUCT_TLVLEN(
4085 wmi_ipa_offload_enable_disable_cmd_fixed_param));
4086
4087 cmd->offload_type = ipa_offload->offload_type;
4088 cmd->vdev_id = ipa_offload->vdev_id;
4089 cmd->enable = ipa_offload->enable;
4090
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304091 wmi_mtrace(WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304092 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4093 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304094 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304095 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304096 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304097 }
4098
Govind Singhb53420c2016-03-09 14:32:57 +05304099 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304100}
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05304101#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05304102
4103/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304104 * send_pno_stop_cmd_tlv() - PNO stop request
4105 * @wmi_handle: wmi handle
4106 * @vdev_id: vdev id
4107 *
4108 * This function request FW to stop ongoing PNO operation.
4109 *
4110 * Return: CDF status
4111 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304112static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05304113{
4114 wmi_nlo_config_cmd_fixed_param *cmd;
4115 int32_t len = sizeof(*cmd);
4116 wmi_buf_t buf;
4117 uint8_t *buf_ptr;
4118 int ret;
4119
4120 /*
4121 * TLV place holder for array of structures nlo_configured_parameters
4122 * TLV place holder for array of uint32_t channel_list
4123 * TLV place holder for chnl prediction cfg
4124 */
4125 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
4126 buf = wmi_buf_alloc(wmi_handle, len);
4127 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304128 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4129 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304130 }
4131
4132 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
4133 buf_ptr = (uint8_t *) cmd;
4134
4135 WMITLV_SET_HDR(&cmd->tlv_header,
4136 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
4137 WMITLV_GET_STRUCT_TLVLEN
4138 (wmi_nlo_config_cmd_fixed_param));
4139
4140 cmd->vdev_id = vdev_id;
4141 cmd->flags = WMI_NLO_CONFIG_STOP;
4142 buf_ptr += sizeof(*cmd);
4143
4144 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
4145 buf_ptr += WMI_TLV_HDR_SIZE;
4146
4147 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
4148 buf_ptr += WMI_TLV_HDR_SIZE;
4149
4150 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
4151 buf_ptr += WMI_TLV_HDR_SIZE;
4152
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304153 wmi_mtrace(WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304154 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4155 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
4156 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304157 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304158 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304159 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304160 }
4161
Govind Singhb53420c2016-03-09 14:32:57 +05304162 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304163}
4164
4165/**
Govind Singhccb0c272016-04-01 16:30:08 +05304166 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
4167 * @buf_ptr: Buffer passed by upper layers
Sathish Kumarefb25bf2018-10-02 11:03:59 +05304168 * @pno: Buffer to be sent to the firmware
Govind Singhccb0c272016-04-01 16:30:08 +05304169 *
4170 * Copy the PNO Channel prediction configuration parameters
4171 * passed by the upper layers to a WMI format TLV and send it
4172 * down to the firmware.
4173 *
4174 * Return: None
4175 */
4176static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
4177 struct pno_scan_req_params *pno)
4178{
4179 nlo_channel_prediction_cfg *channel_prediction_cfg =
4180 (nlo_channel_prediction_cfg *) buf_ptr;
4181 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
4182 WMITLV_TAG_ARRAY_BYTE,
4183 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05304184#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05304185 channel_prediction_cfg->enable = pno->pno_channel_prediction;
4186 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
4187 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
4188 channel_prediction_cfg->full_scan_period_ms =
4189 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05304190#endif
Govind Singhccb0c272016-04-01 16:30:08 +05304191 buf_ptr += sizeof(nlo_channel_prediction_cfg);
4192 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
4193 channel_prediction_cfg->enable,
4194 channel_prediction_cfg->top_k_num,
4195 channel_prediction_cfg->stationary_threshold,
4196 channel_prediction_cfg->full_scan_period_ms);
4197}
4198
4199/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07004200 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
4201 * @wmi_handle: wmi handle
4202 * @params: configuration parameters
4203 *
4204 * Return: QDF_STATUS
4205 */
4206static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
4207 struct nlo_mawc_params *params)
4208{
4209 wmi_buf_t buf = NULL;
4210 QDF_STATUS status;
4211 int len;
4212 uint8_t *buf_ptr;
4213 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
4214
4215 len = sizeof(*wmi_nlo_mawc_params);
4216 buf = wmi_buf_alloc(wmi_handle, len);
4217 if (!buf) {
4218 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4219 return QDF_STATUS_E_NOMEM;
4220 }
4221
4222 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4223 wmi_nlo_mawc_params =
4224 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
4225 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
4226 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
4227 WMITLV_GET_STRUCT_TLVLEN
4228 (wmi_nlo_configure_mawc_cmd_fixed_param));
4229 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
4230 if (params->enable)
4231 wmi_nlo_mawc_params->enable = 1;
4232 else
4233 wmi_nlo_mawc_params->enable = 0;
4234 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
4235 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
4236 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07004237 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
4238 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
4239 wmi_nlo_mawc_params->exp_backoff_ratio,
4240 wmi_nlo_mawc_params->init_scan_interval,
4241 wmi_nlo_mawc_params->max_scan_interval);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07004242
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304243 wmi_mtrace(WMI_NLO_CONFIGURE_MAWC_CMDID, NO_SESSION, 0);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07004244 status = wmi_unified_cmd_send(wmi_handle, buf,
4245 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
4246 if (QDF_IS_STATUS_ERROR(status)) {
4247 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
4248 status);
4249 wmi_buf_free(buf);
4250 return QDF_STATUS_E_FAILURE;
4251 }
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07004252
4253 return QDF_STATUS_SUCCESS;
4254}
4255
4256/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304257 * send_pno_start_cmd_tlv() - PNO start request
4258 * @wmi_handle: wmi handle
4259 * @pno: PNO request
4260 *
4261 * This function request FW to start PNO request.
4262 * Request: CDF status
4263 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304264static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05304265 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05304266{
4267 wmi_nlo_config_cmd_fixed_param *cmd;
4268 nlo_configured_parameters *nlo_list;
4269 uint32_t *channel_list;
4270 int32_t len;
4271 wmi_buf_t buf;
4272 uint8_t *buf_ptr;
4273 uint8_t i;
4274 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05304275 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05304276 connected_nlo_rssi_params *nlo_relative_rssi;
4277 connected_nlo_bss_band_rssi_pref *nlo_band_rssi;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304278
4279 /*
4280 * TLV place holder for array nlo_configured_parameters(nlo_list)
4281 * TLV place holder for array of uint32_t channel_list
4282 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05304283 * TLV place holder for array of wmi_vendor_oui
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05304284 * TLV place holder for array of connected_nlo_bss_band_rssi_pref
Govind Singh4eacd2b2016-03-07 14:24:22 +05304285 */
4286 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05304287 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05304288 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304289
Abhishek Singh5987b632017-03-03 22:09:07 +05304290 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304291 WMI_NLO_MAX_CHAN);
4292 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05304293 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304294 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05304295 len += sizeof(enlo_candidate_score_params);
4296 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05304297 len += sizeof(connected_nlo_rssi_params);
4298 len += sizeof(connected_nlo_bss_band_rssi_pref);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304299
4300 buf = wmi_buf_alloc(wmi_handle, len);
4301 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304302 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4303 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304304 }
4305
4306 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
4307
4308 buf_ptr = (uint8_t *) cmd;
4309 WMITLV_SET_HDR(&cmd->tlv_header,
4310 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
4311 WMITLV_GET_STRUCT_TLVLEN
4312 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05304313 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304314 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
4315
Govind Singh87542482016-06-08 19:40:11 +05304316#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05304317 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05304318 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05304319#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05304320 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05304321 cmd->active_dwell_time = pno->active_dwell_time;
4322 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304323
Manjeet Singhcd2dc062016-08-11 15:31:34 +05304324 if (pno->do_passive_scan)
4325 cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304326 /* Copy scan interval */
4327 cmd->fast_scan_period = pno->fast_scan_period;
4328 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08004329 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304330 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07004331 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05304332 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304333 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05304334 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304335
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05304336 /* mac randomization attributes */
4337 if (pno->scan_random.randomize) {
4338 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
4339 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
4340 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
4341 pno->scan_random.mac_mask,
4342 &cmd->mac_addr,
4343 &cmd->mac_mask);
4344 }
4345
Govind Singh4eacd2b2016-03-07 14:24:22 +05304346 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
4347
Abhishek Singh5987b632017-03-03 22:09:07 +05304348 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05304349 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304350 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4351 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
4352 buf_ptr += WMI_TLV_HDR_SIZE;
4353
4354 nlo_list = (nlo_configured_parameters *) buf_ptr;
4355 for (i = 0; i < cmd->no_of_ssids; i++) {
4356 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
4357 WMITLV_TAG_ARRAY_BYTE,
4358 WMITLV_GET_STRUCT_TLVLEN
4359 (nlo_configured_parameters));
4360 /* Copy ssid and it's length */
4361 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05304362 nlo_list[i].ssid.ssid.ssid_len =
4363 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05304364 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05304365 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304366 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05304367 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304368 nlo_list[i].ssid.ssid.ssid_len,
4369 (char *)nlo_list[i].ssid.ssid.ssid,
4370 nlo_list[i].ssid.ssid.ssid_len);
4371
4372 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05304373 if (pno->networks_list[i].rssi_thresh &&
4374 pno->networks_list[i].rssi_thresh >
4375 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05304376 nlo_list[i].rssi_cond.valid = true;
4377 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05304378 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05304379 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304380 nlo_list[i].rssi_cond.rssi);
4381 }
4382 nlo_list[i].bcast_nw_type.valid = true;
4383 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05304384 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07004385 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304386 nlo_list[i].bcast_nw_type.bcast_nw_type);
4387 }
4388 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
4389
4390 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05304391 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304392 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05304393 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304394 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
4395 (cmd->num_of_channels * sizeof(uint32_t)));
4396 buf_ptr += WMI_TLV_HDR_SIZE;
4397
4398 channel_list = (uint32_t *) buf_ptr;
4399 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05304400 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05304401
4402 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05304403 channel_list[i] =
4404 wlan_chan_to_freq(pno->
4405 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304406
Govind Singhb53420c2016-03-09 14:32:57 +05304407 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304408 }
4409 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
4410 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4411 sizeof(nlo_channel_prediction_cfg));
4412 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05304413 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05304414 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304415 /** TODO: Discrete firmware doesn't have command/option to configure
4416 * App IE which comes from wpa_supplicant as of part PNO start request.
4417 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05304418 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
4419 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
4420 buf_ptr += sizeof(enlo_candidate_score_params);
4421
4422 if (ie_whitelist->white_list) {
4423 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
4424 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
4425 &cmd->num_vendor_oui,
4426 ie_whitelist);
4427 }
4428
4429 /* ie white list */
4430 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4431 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
4432 buf_ptr += WMI_TLV_HDR_SIZE;
4433 if (cmd->num_vendor_oui != 0) {
4434 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
4435 ie_whitelist->voui);
4436 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
4437 }
4438
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05304439 if (pno->relative_rssi_set)
4440 cmd->flags |= WMI_NLO_CONFIG_ENABLE_CNLO_RSSI_CONFIG;
4441
4442 /*
4443 * Firmware calculation using connected PNO params:
4444 * New AP's RSSI >= (Connected AP's RSSI + relative_rssi +/- rssi_pref)
4445 * deduction of rssi_pref for chosen band_pref and
4446 * addition of rssi_pref for remaining bands (other than chosen band).
4447 */
4448 nlo_relative_rssi = (connected_nlo_rssi_params *) buf_ptr;
4449 WMITLV_SET_HDR(&nlo_relative_rssi->tlv_header,
4450 WMITLV_TAG_STRUC_wmi_connected_nlo_rssi_params,
4451 WMITLV_GET_STRUCT_TLVLEN(connected_nlo_rssi_params));
4452 nlo_relative_rssi->relative_rssi = pno->relative_rssi;
4453 WMI_LOGD("relative_rssi %d", nlo_relative_rssi->relative_rssi);
4454 buf_ptr += sizeof(*nlo_relative_rssi);
4455
4456 /*
4457 * As of now Kernel and Host supports one band and rssi preference.
4458 * Firmware supports array of band and rssi preferences
4459 */
4460 cmd->num_cnlo_band_pref = 1;
4461 WMITLV_SET_HDR(buf_ptr,
4462 WMITLV_TAG_ARRAY_STRUC,
4463 cmd->num_cnlo_band_pref *
4464 sizeof(connected_nlo_bss_band_rssi_pref));
4465 buf_ptr += WMI_TLV_HDR_SIZE;
4466
4467 nlo_band_rssi = (connected_nlo_bss_band_rssi_pref *) buf_ptr;
4468 for (i = 0; i < cmd->num_cnlo_band_pref; i++) {
4469 WMITLV_SET_HDR(&nlo_band_rssi[i].tlv_header,
4470 WMITLV_TAG_STRUC_wmi_connected_nlo_bss_band_rssi_pref,
4471 WMITLV_GET_STRUCT_TLVLEN(
4472 connected_nlo_bss_band_rssi_pref));
4473 nlo_band_rssi[i].band = pno->band_rssi_pref.band;
4474 nlo_band_rssi[i].rssi_pref = pno->band_rssi_pref.rssi;
4475 WMI_LOGI("band_pref %d, rssi_pref %d",
4476 nlo_band_rssi[i].band,
4477 nlo_band_rssi[i].rssi_pref);
4478 }
4479 buf_ptr += cmd->num_cnlo_band_pref * sizeof(*nlo_band_rssi);
4480
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304481 wmi_mtrace(WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304482 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4483 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
4484 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304485 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304486 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304487 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304488 }
4489
Govind Singhb53420c2016-03-09 14:32:57 +05304490 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304491}
4492
Qiwei Cai1ccba222018-05-21 16:49:39 +08004493#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +05304494/**
4495 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
4496 * @wmi_handle: wmi handle
4497 * @clear_req: ll stats clear request command params
4498 *
Govind Singhb53420c2016-03-09 14:32:57 +05304499 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304500 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304501static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304502 const struct ll_stats_clear_params *clear_req,
4503 uint8_t addr[IEEE80211_ADDR_LEN])
4504{
4505 wmi_clear_link_stats_cmd_fixed_param *cmd;
4506 int32_t len;
4507 wmi_buf_t buf;
4508 uint8_t *buf_ptr;
4509 int ret;
4510
4511 len = sizeof(*cmd);
4512 buf = wmi_buf_alloc(wmi_handle, len);
4513
4514 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304515 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4516 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304517 }
4518
4519 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304520 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304521 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
4522
4523 WMITLV_SET_HDR(&cmd->tlv_header,
4524 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
4525 WMITLV_GET_STRUCT_TLVLEN
4526 (wmi_clear_link_stats_cmd_fixed_param));
4527
4528 cmd->stop_stats_collection_req = clear_req->stop_req;
4529 cmd->vdev_id = clear_req->sta_id;
4530 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
4531
4532 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
4533 &cmd->peer_macaddr);
4534
Govind Singhb53420c2016-03-09 14:32:57 +05304535 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
Sathish Kumarefb25bf2018-10-02 11:03:59 +05304536 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
4537 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
Govind Singhb53420c2016-03-09 14:32:57 +05304538 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
4539 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304540 cmd->peer_macaddr); */
4541
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304542 wmi_mtrace(WMI_CLEAR_LINK_STATS_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304543 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4544 WMI_CLEAR_LINK_STATS_CMDID);
4545 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304546 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304547 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304548 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304549 }
4550
Govind Singhb53420c2016-03-09 14:32:57 +05304551 WMI_LOGD("Clear Link Layer Stats request sent successfully");
4552 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304553}
4554
4555/**
4556 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
4557 * @wmi_handle: wmi handle
4558 * @setReq: ll stats set request command params
4559 *
Govind Singhb53420c2016-03-09 14:32:57 +05304560 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304561 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304562static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304563 const struct ll_stats_set_params *set_req)
4564{
4565 wmi_start_link_stats_cmd_fixed_param *cmd;
4566 int32_t len;
4567 wmi_buf_t buf;
4568 uint8_t *buf_ptr;
4569 int ret;
4570
4571 len = sizeof(*cmd);
4572 buf = wmi_buf_alloc(wmi_handle, len);
4573
4574 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304575 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4576 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304577 }
4578
4579 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304580 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304581 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
4582
4583 WMITLV_SET_HDR(&cmd->tlv_header,
4584 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
4585 WMITLV_GET_STRUCT_TLVLEN
4586 (wmi_start_link_stats_cmd_fixed_param));
4587
4588 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
4589 cmd->aggressive_statistics_gathering =
4590 set_req->aggressive_statistics_gathering;
4591
Govind Singhb53420c2016-03-09 14:32:57 +05304592 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
4593 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
4594 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304595
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304596 wmi_mtrace(WMI_START_LINK_STATS_CMDID, NO_SESSION, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304597 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4598 WMI_START_LINK_STATS_CMDID);
4599 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304600 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304601 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304602 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304603 }
4604
Govind Singhb53420c2016-03-09 14:32:57 +05304605 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304606}
4607
4608/**
4609 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
4610 * @wmi_handle:wmi handle
4611 * @get_req:ll stats get request command params
4612 * @addr: mac address
4613 *
Govind Singhb53420c2016-03-09 14:32:57 +05304614 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304615 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304616static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304617 const struct ll_stats_get_params *get_req,
4618 uint8_t addr[IEEE80211_ADDR_LEN])
4619{
4620 wmi_request_link_stats_cmd_fixed_param *cmd;
4621 int32_t len;
4622 wmi_buf_t buf;
4623 uint8_t *buf_ptr;
4624 int ret;
4625
4626 len = sizeof(*cmd);
4627 buf = wmi_buf_alloc(wmi_handle, len);
4628
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05304629 if (!buf) {
4630 WMI_LOGE("%s: buf allocation failed", __func__);
4631 return QDF_STATUS_E_NOMEM;
4632 }
4633
Govind Singh4eacd2b2016-03-07 14:24:22 +05304634 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304635 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304636 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
4637
4638 WMITLV_SET_HDR(&cmd->tlv_header,
4639 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
4640 WMITLV_GET_STRUCT_TLVLEN
4641 (wmi_request_link_stats_cmd_fixed_param));
4642
4643 cmd->request_id = get_req->req_id;
4644 cmd->stats_type = get_req->param_id_mask;
4645 cmd->vdev_id = get_req->sta_id;
4646
4647 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
4648 &cmd->peer_macaddr);
4649
Govind Singhb53420c2016-03-09 14:32:57 +05304650 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08004651 WMI_LOGD("Request ID : %u", cmd->request_id);
4652 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Sathish Kumarefb25bf2018-10-02 11:03:59 +05304653 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
Govind Singhb53420c2016-03-09 14:32:57 +05304654 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304655
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304656 wmi_mtrace(WMI_REQUEST_LINK_STATS_CMDID, cmd->vdev_id, 0);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304657 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4658 WMI_REQUEST_LINK_STATS_CMDID);
4659 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304660 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304661 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304662 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304663 }
4664
Govind Singhb53420c2016-03-09 14:32:57 +05304665 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304666}
Qiwei Cai1ccba222018-05-21 16:49:39 +08004667#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Govind Singh4eacd2b2016-03-07 14:24:22 +05304668
Govind Singh20c5dac2016-03-07 15:33:31 +05304669/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05304670 * send_congestion_cmd_tlv() - send request to fw to get CCA
4671 * @wmi_handle: wmi handle
4672 * @vdev_id: vdev id
4673 *
4674 * Return: CDF status
4675 */
4676static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05304677 uint8_t vdev_id)
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05304678{
4679 wmi_buf_t buf;
4680 wmi_request_stats_cmd_fixed_param *cmd;
4681 uint8_t len;
4682 uint8_t *buf_ptr;
4683
4684 len = sizeof(*cmd);
4685 buf = wmi_buf_alloc(wmi_handle, len);
4686 if (!buf) {
4687 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
4688 return QDF_STATUS_E_FAILURE;
4689 }
4690
4691 buf_ptr = wmi_buf_data(buf);
4692 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
4693 WMITLV_SET_HDR(&cmd->tlv_header,
4694 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
4695 WMITLV_GET_STRUCT_TLVLEN
4696 (wmi_request_stats_cmd_fixed_param));
4697
4698 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
4699 cmd->vdev_id = vdev_id;
4700 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
4701 cmd->vdev_id, cmd->stats_id);
4702
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304703 wmi_mtrace(WMI_REQUEST_STATS_CMDID, cmd->vdev_id, 0);
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05304704 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4705 WMI_REQUEST_STATS_CMDID)) {
4706 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
4707 __func__);
4708 wmi_buf_free(buf);
4709 return QDF_STATUS_E_FAILURE;
4710 }
4711
4712 return QDF_STATUS_SUCCESS;
4713}
4714
4715/**
Govind Singh20c5dac2016-03-07 15:33:31 +05304716 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
4717 * @wmi_handle: wmi handle
4718 * @rssi_req: get RSSI request
4719 *
4720 * Return: CDF status
4721 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304722static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05304723{
4724 wmi_buf_t buf;
4725 wmi_request_stats_cmd_fixed_param *cmd;
4726 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
4727
4728 buf = wmi_buf_alloc(wmi_handle, len);
4729 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304730 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4731 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05304732 }
4733
4734 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
4735 WMITLV_SET_HDR(&cmd->tlv_header,
4736 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
4737 WMITLV_GET_STRUCT_TLVLEN
4738 (wmi_request_stats_cmd_fixed_param));
4739 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304740 wmi_mtrace(WMI_REQUEST_STATS_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05304741 if (wmi_unified_cmd_send
4742 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304743 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05304744 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304745 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05304746 }
4747
Govind Singhb53420c2016-03-09 14:32:57 +05304748 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05304749}
4750
4751/**
4752 * send_snr_cmd_tlv() - get RSSI from fw
4753 * @wmi_handle: wmi handle
4754 * @vdev_id: vdev id
4755 *
4756 * Return: CDF status
4757 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304758static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05304759{
4760 wmi_buf_t buf;
4761 wmi_request_stats_cmd_fixed_param *cmd;
4762 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
4763
4764 buf = wmi_buf_alloc(wmi_handle, len);
4765 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304766 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4767 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05304768 }
4769
4770 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
4771 cmd->vdev_id = vdev_id;
4772
4773 WMITLV_SET_HDR(&cmd->tlv_header,
4774 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
4775 WMITLV_GET_STRUCT_TLVLEN
4776 (wmi_request_stats_cmd_fixed_param));
4777 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304778 wmi_mtrace(WMI_REQUEST_STATS_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05304779 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4780 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304781 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05304782 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304783 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05304784 }
4785
Govind Singhb53420c2016-03-09 14:32:57 +05304786 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05304787}
4788
4789/**
4790 * send_link_status_req_cmd_tlv() - process link status request from UMAC
4791 * @wmi_handle: wmi handle
4792 * @link_status: get link params
4793 *
4794 * Return: CDF status
4795 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304796static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05304797 struct link_status_params *link_status)
4798{
4799 wmi_buf_t buf;
4800 wmi_request_stats_cmd_fixed_param *cmd;
4801 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
4802
4803 buf = wmi_buf_alloc(wmi_handle, len);
4804 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304805 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4806 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05304807 }
4808
4809 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
4810 WMITLV_SET_HDR(&cmd->tlv_header,
4811 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
4812 WMITLV_GET_STRUCT_TLVLEN
4813 (wmi_request_stats_cmd_fixed_param));
4814 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
4815 cmd->vdev_id = link_status->session_id;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304816 wmi_mtrace(WMI_REQUEST_STATS_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05304817 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4818 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304819 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05304820 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304821 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05304822 }
4823
Govind Singhb53420c2016-03-09 14:32:57 +05304824 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05304825}
4826
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05304827#ifdef WLAN_SUPPORT_GREEN_AP
Govind Singh20c5dac2016-03-07 15:33:31 +05304828/**
4829 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
4830 * @wmi_handle: wmi handler
4831 * @egap_params: pointer to egap_params
4832 *
4833 * Return: 0 for success, otherwise appropriate error code
4834 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304835static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05304836 struct wlan_green_ap_egap_params *egap_params)
Govind Singh20c5dac2016-03-07 15:33:31 +05304837{
4838 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
4839 wmi_buf_t buf;
4840 int32_t err;
4841
4842 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4843 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304844 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
4845 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05304846 }
4847 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
4848 WMITLV_SET_HDR(&cmd->tlv_header,
4849 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
4850 WMITLV_GET_STRUCT_TLVLEN(
4851 wmi_ap_ps_egap_param_cmd_fixed_param));
4852
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05304853 cmd->enable = egap_params->host_enable_egap;
4854 cmd->inactivity_time = egap_params->egap_inactivity_time;
4855 cmd->wait_time = egap_params->egap_wait_time;
4856 cmd->flags = egap_params->egap_feature_flags;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304857 wmi_mtrace(WMI_AP_PS_EGAP_PARAM_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05304858 err = wmi_unified_cmd_send(wmi_handle, buf,
4859 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
4860 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05304861 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05304862 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304863 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05304864 }
4865
Govind Singhb53420c2016-03-09 14:32:57 +05304866 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05304867}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05304868#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05304869
4870/**
Govind Singh20c5dac2016-03-07 15:33:31 +05304871 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
4872 * @wmi_handle: wmi handle
4873 * @vdev_id: vdev id
4874 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304875 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05304876 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304877static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05304878 uint8_t vdev_id)
4879{
4880 wmi_csa_offload_enable_cmd_fixed_param *cmd;
4881 wmi_buf_t buf;
4882 int32_t len = sizeof(*cmd);
4883
Govind Singhb53420c2016-03-09 14:32:57 +05304884 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05304885 buf = wmi_buf_alloc(wmi_handle, len);
4886 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304887 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304888 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05304889 }
4890 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
4891 WMITLV_SET_HDR(&cmd->tlv_header,
4892 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
4893 WMITLV_GET_STRUCT_TLVLEN
4894 (wmi_csa_offload_enable_cmd_fixed_param));
4895 cmd->vdev_id = vdev_id;
4896 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304897 wmi_mtrace(WMI_CSA_OFFLOAD_ENABLE_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05304898 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4899 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304900 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05304901 __func__);
4902 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05304903 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05304904 }
4905
4906 return 0;
4907}
4908
Naveen Rawat42cd1e62017-05-13 15:56:57 -07004909#ifdef WLAN_FEATURE_CIF_CFR
4910/**
4911 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
4912 * @wmi_handle: wmi handle
4913 * @data_len: len of dma cfg req
4914 * @data: dma cfg req
4915 *
4916 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
4917 */
4918static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
4919 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
4920{
4921 wmi_buf_t buf;
4922 uint8_t *cmd;
4923 QDF_STATUS ret;
4924
4925 WMITLV_SET_HDR(cfg,
4926 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
4927 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
4928
4929 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
4930 if (!buf) {
4931 WMI_LOGE(FL("wmi_buf_alloc failed"));
4932 return QDF_STATUS_E_FAILURE;
4933 }
4934
4935 cmd = (uint8_t *) wmi_buf_data(buf);
4936 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
4937 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
4938 sizeof(*cfg));
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304939 wmi_mtrace(WMI_OEM_DMA_RING_CFG_REQ_CMDID, NO_SESSION, 0);
Naveen Rawat42cd1e62017-05-13 15:56:57 -07004940 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
4941 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
4942 if (QDF_IS_STATUS_ERROR(ret)) {
4943 WMI_LOGE(FL(":wmi cmd send failed"));
4944 wmi_buf_free(buf);
4945 }
4946
4947 return ret;
4948}
4949#endif
4950
Govind Singh20c5dac2016-03-07 15:33:31 +05304951/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07004952 * send_start_11d_scan_cmd_tlv() - start 11d scan request
4953 * @wmi_handle: wmi handle
4954 * @start_11d_scan: 11d scan start request parameters
4955 *
4956 * This function request FW to start 11d scan.
4957 *
4958 * Return: QDF status
4959 */
4960static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
4961 struct reg_start_11d_scan_req *start_11d_scan)
4962{
4963 wmi_11d_scan_start_cmd_fixed_param *cmd;
4964 int32_t len;
4965 wmi_buf_t buf;
4966 int ret;
4967
4968 len = sizeof(*cmd);
4969 buf = wmi_buf_alloc(wmi_handle, len);
4970 if (!buf) {
4971 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4972 return QDF_STATUS_E_NOMEM;
4973 }
4974
4975 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
4976
4977 WMITLV_SET_HDR(&cmd->tlv_header,
4978 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
4979 WMITLV_GET_STRUCT_TLVLEN
4980 (wmi_11d_scan_start_cmd_fixed_param));
4981
4982 cmd->vdev_id = start_11d_scan->vdev_id;
4983 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
4984 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
4985
4986 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
4987
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05304988 wmi_mtrace(WMI_11D_SCAN_START_CMDID, cmd->vdev_id, 0);
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07004989 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4990 WMI_11D_SCAN_START_CMDID);
4991 if (ret) {
4992 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
4993 wmi_buf_free(buf);
4994 return QDF_STATUS_E_FAILURE;
4995 }
4996
4997 return QDF_STATUS_SUCCESS;
4998}
4999
5000/**
5001 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
5002 * @wmi_handle: wmi handle
5003 * @start_11d_scan: 11d scan stop request parameters
5004 *
5005 * This function request FW to stop 11d scan.
5006 *
5007 * Return: QDF status
5008 */
5009static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
5010 struct reg_stop_11d_scan_req *stop_11d_scan)
5011{
5012 wmi_11d_scan_stop_cmd_fixed_param *cmd;
5013 int32_t len;
5014 wmi_buf_t buf;
5015 int ret;
5016
5017 len = sizeof(*cmd);
5018 buf = wmi_buf_alloc(wmi_handle, len);
5019 if (!buf) {
5020 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5021 return QDF_STATUS_E_NOMEM;
5022 }
5023
5024 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
5025
5026 WMITLV_SET_HDR(&cmd->tlv_header,
5027 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
5028 WMITLV_GET_STRUCT_TLVLEN
5029 (wmi_11d_scan_stop_cmd_fixed_param));
5030
5031 cmd->vdev_id = stop_11d_scan->vdev_id;
5032
5033 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
5034
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305035 wmi_mtrace(WMI_11D_SCAN_STOP_CMDID, cmd->vdev_id, 0);
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07005036 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5037 WMI_11D_SCAN_STOP_CMDID);
5038 if (ret) {
5039 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
5040 wmi_buf_free(buf);
5041 return QDF_STATUS_E_FAILURE;
5042 }
5043
5044 return QDF_STATUS_SUCCESS;
5045}
5046
5047/**
Govind Singh20c5dac2016-03-07 15:33:31 +05305048 * send_start_oem_data_cmd_tlv() - start OEM data request to target
5049 * @wmi_handle: wmi handle
5050 * @startOemDataReq: start request params
5051 *
5052 * Return: CDF status
5053 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305054static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07005055 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05305056 uint8_t *data)
5057{
5058 wmi_buf_t buf;
5059 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05305060 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05305061
5062 buf = wmi_buf_alloc(wmi_handle,
5063 (data_len + WMI_TLV_HDR_SIZE));
5064 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305065 WMI_LOGE(FL("wmi_buf_alloc failed"));
5066 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05305067 }
5068
5069 cmd = (uint8_t *) wmi_buf_data(buf);
5070
5071 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
5072 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305073 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05305074 data_len);
5075
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08005076 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05305077 data_len);
5078
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305079 wmi_mtrace(WMI_OEM_REQ_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05305080 ret = wmi_unified_cmd_send(wmi_handle, buf,
5081 (data_len +
5082 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
5083
Govind Singh67922e82016-04-01 16:48:57 +05305084 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305085 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05305086 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05305087 }
5088
Govind Singh67922e82016-04-01 16:48:57 +05305089 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05305090}
5091
5092/**
5093 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
5094 * @wmi_handle: wmi handle
5095 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
5096 *
5097 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
5098 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
5099 * to firmware based on phyerr filtering
5100 * offload status.
5101 *
5102 * Return: 1 success, 0 failure
5103 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305104static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05305105send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
5106 bool dfs_phyerr_filter_offload)
5107{
5108 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
5109 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
5110 wmi_buf_t buf;
5111 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05305112 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05305113
5114
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07005115 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05305116 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05305117 __func__);
5118 len = sizeof(*disable_phyerr_offload_cmd);
5119 buf = wmi_buf_alloc(wmi_handle, len);
5120 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305121 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05305122 return 0;
5123 }
5124 disable_phyerr_offload_cmd =
5125 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
5126 wmi_buf_data(buf);
5127
5128 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
5129 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
5130 WMITLV_GET_STRUCT_TLVLEN
5131 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
5132
5133 /*
5134 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
5135 * to the firmware to disable the phyerror
5136 * filtering offload.
5137 */
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305138 wmi_mtrace(WMI_DFS_PHYERR_FILTER_DIS_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05305139 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5140 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305141 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305142 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05305143 __func__, ret);
5144 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305145 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05305146 }
Govind Singhb53420c2016-03-09 14:32:57 +05305147 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05305148 __func__);
5149 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05305150 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05305151 __func__);
5152
5153 len = sizeof(*enable_phyerr_offload_cmd);
5154 buf = wmi_buf_alloc(wmi_handle, len);
5155 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305156 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
5157 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05305158 }
5159
5160 enable_phyerr_offload_cmd =
5161 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
5162 wmi_buf_data(buf);
5163
5164 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
5165 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
5166 WMITLV_GET_STRUCT_TLVLEN
5167 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
5168
5169 /*
5170 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
5171 * to the firmware to enable the phyerror
5172 * filtering offload.
5173 */
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305174 wmi_mtrace(WMI_DFS_PHYERR_FILTER_ENA_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05305175 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5176 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
5177
Govind Singh67922e82016-04-01 16:48:57 +05305178 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305179 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05305180 __func__, ret);
5181 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305182 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05305183 }
Govind Singhb53420c2016-03-09 14:32:57 +05305184 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05305185 __func__);
5186 }
5187
Govind Singhb53420c2016-03-09 14:32:57 +05305188 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05305189}
5190
5191#if !defined(REMOVE_PKT_LOG)
5192/**
5193 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
5194 * @wmi_handle: wmi handle
5195 * @pktlog_event: pktlog event
5196 * @cmd_id: pktlog cmd id
5197 *
5198 * Return: CDF status
5199 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305200static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05305201 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05305202 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05305203{
5204 WMI_PKTLOG_EVENT PKTLOG_EVENT;
5205 WMI_CMD_ID CMD_ID;
5206 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
5207 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
5208 int len = 0;
5209 wmi_buf_t buf;
5210
5211 PKTLOG_EVENT = pktlog_event;
5212 CMD_ID = cmd_id;
5213
5214 switch (CMD_ID) {
5215 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
5216 len = sizeof(*cmd);
5217 buf = wmi_buf_alloc(wmi_handle, len);
5218 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305219 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
5220 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05305221 }
5222 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
5223 wmi_buf_data(buf);
5224 WMITLV_SET_HDR(&cmd->tlv_header,
5225 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
5226 WMITLV_GET_STRUCT_TLVLEN
5227 (wmi_pdev_pktlog_enable_cmd_fixed_param));
5228 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05305229 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
5230 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05305231 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
5232 WMI_HOST_PDEV_ID_SOC);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305233 wmi_mtrace(WMI_PDEV_PKTLOG_ENABLE_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05305234 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5235 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305236 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05305237 goto wmi_send_failed;
5238 }
5239 break;
5240 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
5241 len = sizeof(*disable_cmd);
5242 buf = wmi_buf_alloc(wmi_handle, len);
5243 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305244 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
5245 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05305246 }
5247 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
5248 wmi_buf_data(buf);
5249 WMITLV_SET_HDR(&disable_cmd->tlv_header,
5250 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
5251 WMITLV_GET_STRUCT_TLVLEN
5252 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05305253 disable_cmd->pdev_id =
5254 wmi_handle->ops->convert_pdev_id_host_to_target(
5255 WMI_HOST_PDEV_ID_SOC);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305256 wmi_mtrace(WMI_PDEV_PKTLOG_DISABLE_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05305257 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5258 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305259 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05305260 goto wmi_send_failed;
5261 }
5262 break;
5263 default:
Govind Singhb53420c2016-03-09 14:32:57 +05305264 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05305265 break;
5266 }
5267
Govind Singhb53420c2016-03-09 14:32:57 +05305268 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05305269
5270wmi_send_failed:
5271 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305272 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05305273}
5274#endif /* REMOVE_PKT_LOG */
5275
5276/**
Govind Singh20c5dac2016-03-07 15:33:31 +05305277 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
5278 * @wmi_handle: wmi handle
5279 * @preq: stats ext params
5280 *
5281 * Return: CDF status
5282 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305283static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05305284 struct stats_ext_params *preq)
5285{
Govind Singh67922e82016-04-01 16:48:57 +05305286 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05305287 wmi_req_stats_ext_cmd_fixed_param *cmd;
5288 wmi_buf_t buf;
Pragaspathi Thilagaraj5920a4b2018-05-16 18:51:32 +05305289 size_t len;
Govind Singh20c5dac2016-03-07 15:33:31 +05305290 uint8_t *buf_ptr;
5291
5292 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
5293
5294 buf = wmi_buf_alloc(wmi_handle, len);
5295 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305296 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305297 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05305298 }
5299
5300 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5301 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
5302
5303 WMITLV_SET_HDR(&cmd->tlv_header,
5304 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
5305 WMITLV_GET_STRUCT_TLVLEN
5306 (wmi_req_stats_ext_cmd_fixed_param));
5307 cmd->vdev_id = preq->vdev_id;
5308 cmd->data_len = preq->request_data_len;
5309
Govind Singhb53420c2016-03-09 14:32:57 +05305310 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05305311 __func__, preq->request_data_len, preq->vdev_id);
5312
5313 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
5314 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
5315
5316 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305317 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05305318
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305319 wmi_mtrace(WMI_REQUEST_STATS_EXT_CMDID, cmd->vdev_id, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05305320 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5321 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305322 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305323 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05305324 ret);
5325 wmi_buf_free(buf);
5326 }
5327
5328 return ret;
5329}
5330
5331/**
Govind Singh20c5dac2016-03-07 15:33:31 +05305332 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
5333 * @wmi_handle: wmi handle
Jeff Johnsona87370f2017-10-04 19:19:20 -07005334 * @params: DHCP server offload info
Govind Singh20c5dac2016-03-07 15:33:31 +05305335 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305336 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05305337 */
Jeff Johnsona87370f2017-10-04 19:19:20 -07005338static QDF_STATUS
5339send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
5340 struct dhcp_offload_info_params *params)
Govind Singh20c5dac2016-03-07 15:33:31 +05305341{
5342 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
5343 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305344 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05305345
5346 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
5347 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305348 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05305349 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05305350 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05305351 }
5352
5353 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05305354
5355 WMITLV_SET_HDR(&cmd->tlv_header,
5356 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
5357 WMITLV_GET_STRUCT_TLVLEN
5358 (wmi_set_dhcp_server_offload_cmd_fixed_param));
Jeff Johnsona87370f2017-10-04 19:19:20 -07005359 cmd->vdev_id = params->vdev_id;
5360 cmd->enable = params->dhcp_offload_enabled;
5361 cmd->num_client = params->dhcp_client_num;
5362 cmd->srv_ipv4 = params->dhcp_srv_addr;
Govind Singh20c5dac2016-03-07 15:33:31 +05305363 cmd->start_lsb = 0;
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305364 wmi_mtrace(WMI_SET_DHCP_SERVER_OFFLOAD_CMDID, cmd->vdev_id, 0);
Govind Singh67922e82016-04-01 16:48:57 +05305365 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05305366 sizeof(*cmd),
5367 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305368 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305369 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05305370 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05305371 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05305372 }
Govind Singhb53420c2016-03-09 14:32:57 +05305373 WMI_LOGD("Set dhcp server offload to vdevId %d",
Jeff Johnsona87370f2017-10-04 19:19:20 -07005374 params->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05305375
5376 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05305377}
5378
5379/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05305380 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
5381 * @wmi_handle: wmi handle
5382 * @param: pointer to pdev regdomain params
5383 *
5384 * Return: 0 for success or error code
5385 */
5386static QDF_STATUS
5387send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
5388 struct pdev_set_regdomain_params *param)
5389{
5390 wmi_buf_t buf;
5391 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
5392 int32_t len = sizeof(*cmd);
5393
Kiran Venkatappa36445a72017-02-08 15:02:44 +05305394 buf = wmi_buf_alloc(wmi_handle, len);
5395 if (!buf) {
5396 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5397 return QDF_STATUS_E_NOMEM;
5398 }
5399 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
5400 WMITLV_SET_HDR(&cmd->tlv_header,
5401 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
5402 WMITLV_GET_STRUCT_TLVLEN
5403 (wmi_pdev_set_regdomain_cmd_fixed_param));
5404
5405 cmd->reg_domain = param->currentRDinuse;
5406 cmd->reg_domain_2G = param->currentRD2G;
5407 cmd->reg_domain_5G = param->currentRD5G;
5408 cmd->conformance_test_limit_2G = param->ctl_2G;
5409 cmd->conformance_test_limit_5G = param->ctl_5G;
5410 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05305411 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
5412 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +05305413
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305414 wmi_mtrace(WMI_PDEV_SET_REGDOMAIN_CMDID, NO_SESSION, 0);
Kiran Venkatappa36445a72017-02-08 15:02:44 +05305415 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5416 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
5417 WMI_LOGE("%s: Failed to send pdev set regdomain command",
5418 __func__);
5419 wmi_buf_free(buf);
5420 return QDF_STATUS_E_FAILURE;
5421 }
5422
5423 return QDF_STATUS_SUCCESS;
5424}
5425
5426/**
Govind Singh20c5dac2016-03-07 15:33:31 +05305427 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
5428 * @wmi_handle: wmi handle
5429 * @reg_dmn: reg domain
5430 * @regdmn2G: 2G reg domain
5431 * @regdmn5G: 5G reg domain
5432 * @ctl2G: 2G test limit
5433 * @ctl5G: 5G test limit
5434 *
5435 * Return: none
5436 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305437static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05305438 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +05305439 uint16_t regdmn5G, uint8_t ctl2G,
5440 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +05305441{
5442 wmi_buf_t buf;
5443 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
5444 int32_t len = sizeof(*cmd);
5445
5446
5447 buf = wmi_buf_alloc(wmi_handle, len);
5448 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305449 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5450 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05305451 }
5452 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
5453 WMITLV_SET_HDR(&cmd->tlv_header,
5454 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
5455 WMITLV_GET_STRUCT_TLVLEN
5456 (wmi_pdev_set_regdomain_cmd_fixed_param));
5457 cmd->reg_domain = reg_dmn;
5458 cmd->reg_domain_2G = regdmn2G;
5459 cmd->reg_domain_5G = regdmn5G;
5460 cmd->conformance_test_limit_2G = ctl2G;
5461 cmd->conformance_test_limit_5G = ctl5G;
5462
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305463 wmi_mtrace(WMI_PDEV_SET_REGDOMAIN_CMDID, NO_SESSION, 0);
Govind Singh20c5dac2016-03-07 15:33:31 +05305464 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5465 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305466 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05305467 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305468 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305469 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05305470 }
5471
Govind Singhb53420c2016-03-09 14:32:57 +05305472 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05305473}
5474
Sathish Kumar497bef42017-03-01 14:02:36 +05305475/**
Sathish Kumar6011c742017-11-08 14:49:58 +05305476 * copy_custom_aggr_bitmap() - copies host side bitmap using FW APIs
5477 * @param: param sent from the host side
5478 * @cmd: param to be sent to the fw side
5479 */
5480static inline void copy_custom_aggr_bitmap(
5481 struct set_custom_aggr_size_params *param,
5482 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd)
5483{
5484 WMI_VDEV_CUSTOM_AGGR_AC_SET(cmd->enable_bitmap,
5485 param->ac);
5486 WMI_VDEV_CUSTOM_AGGR_TYPE_SET(cmd->enable_bitmap,
5487 param->aggr_type);
5488 WMI_VDEV_CUSTOM_TX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
5489 param->tx_aggr_size_disable);
5490 WMI_VDEV_CUSTOM_RX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
5491 param->rx_aggr_size_disable);
5492 WMI_VDEV_CUSTOM_TX_AC_EN_SET(cmd->enable_bitmap,
5493 param->tx_ac_enable);
5494}
5495
5496/**
5497 * send_vdev_set_custom_aggr_size_cmd_tlv() - custom aggr size param in fw
5498 * @wmi_handle: wmi handle
5499 * @param: pointer to hold custom aggr size params
5500 *
5501 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
5502 */
5503static QDF_STATUS send_vdev_set_custom_aggr_size_cmd_tlv(
5504 wmi_unified_t wmi_handle,
5505 struct set_custom_aggr_size_params *param)
5506{
5507 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd;
5508 wmi_buf_t buf;
5509 int32_t len = sizeof(*cmd);
5510
5511 buf = wmi_buf_alloc(wmi_handle, len);
5512 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305513 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Sathish Kumar6011c742017-11-08 14:49:58 +05305514 return QDF_STATUS_E_FAILURE;
5515 }
5516 cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *)
5517 wmi_buf_data(buf);
5518 WMITLV_SET_HDR(&cmd->tlv_header,
5519 WMITLV_TAG_STRUC_wmi_vdev_set_custom_aggr_size_cmd_fixed_param,
5520 WMITLV_GET_STRUCT_TLVLEN(
5521 wmi_vdev_set_custom_aggr_size_cmd_fixed_param));
5522 cmd->vdev_id = param->vdev_id;
5523 cmd->tx_aggr_size = param->tx_aggr_size;
5524 cmd->rx_aggr_size = param->rx_aggr_size;
5525 copy_custom_aggr_bitmap(param, cmd);
5526
5527 WMI_LOGD("Set custom aggr: vdev id=0x%X, tx aggr size=0x%X "
5528 "rx_aggr_size=0x%X access category=0x%X, agg_type=0x%X "
5529 "tx_aggr_size_disable=0x%X, rx_aggr_size_disable=0x%X "
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305530 "tx_ac_enable=0x%X",
Sathish Kumar6011c742017-11-08 14:49:58 +05305531 param->vdev_id, param->tx_aggr_size, param->rx_aggr_size,
5532 param->ac, param->aggr_type, param->tx_aggr_size_disable,
5533 param->rx_aggr_size_disable, param->tx_ac_enable);
5534
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305535 wmi_mtrace(WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID, cmd->vdev_id, 0);
Sathish Kumar6011c742017-11-08 14:49:58 +05305536 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5537 WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID)) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305538 WMI_LOGE("Seting custom aggregation size failed");
Sathish Kumar6011c742017-11-08 14:49:58 +05305539 wmi_buf_free(buf);
5540 return QDF_STATUS_E_FAILURE;
5541 }
5542
5543 return QDF_STATUS_SUCCESS;
5544}
5545
5546/**
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +05305547 * send_vdev_set_qdepth_thresh_cmd_tlv() - WMI set qdepth threshold
5548 * @param wmi_handle : handle to WMI.
5549 * @param param : pointer to tx antenna param
5550 *
5551 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
5552 */
5553
5554static QDF_STATUS send_vdev_set_qdepth_thresh_cmd_tlv(wmi_unified_t wmi_handle,
5555 struct set_qdepth_thresh_params *param)
5556{
5557 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *cmd;
5558 wmi_msduq_qdepth_thresh_update *cmd_update;
5559 wmi_buf_t buf;
5560 int32_t len = 0;
5561 int i;
5562 uint8_t *buf_ptr;
5563 QDF_STATUS ret;
5564
5565 if (param->num_of_msduq_updates > QDEPTH_THRESH_MAX_UPDATES) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305566 WMI_LOGE("%s: Invalid Update Count!", __func__);
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +05305567 return QDF_STATUS_E_INVAL;
5568 }
5569
5570 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5571 len += (sizeof(wmi_msduq_qdepth_thresh_update) *
5572 param->num_of_msduq_updates);
5573 buf = wmi_buf_alloc(wmi_handle, len);
5574
5575 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305576 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +05305577 return QDF_STATUS_E_NOMEM;
5578 }
5579
5580 buf_ptr = (uint8_t *)wmi_buf_data(buf);
5581 cmd = (wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *)
5582 buf_ptr;
5583
5584 WMITLV_SET_HDR(&cmd->tlv_header,
5585 WMITLV_TAG_STRUC_wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param
5586 , WMITLV_GET_STRUCT_TLVLEN(
5587 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param));
5588
5589 cmd->pdev_id =
5590 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
5591 cmd->vdev_id = param->vdev_id;
5592 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->mac_addr, &cmd->peer_mac_address);
5593 cmd->num_of_msduq_updates = param->num_of_msduq_updates;
5594
5595 buf_ptr += sizeof(
5596 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param);
5597 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5598 param->num_of_msduq_updates *
5599 sizeof(wmi_msduq_qdepth_thresh_update));
5600 buf_ptr += WMI_TLV_HDR_SIZE;
5601 cmd_update = (wmi_msduq_qdepth_thresh_update *)buf_ptr;
5602
5603 for (i = 0; i < cmd->num_of_msduq_updates; i++) {
5604 WMITLV_SET_HDR(&cmd_update->tlv_header,
5605 WMITLV_TAG_STRUC_wmi_msduq_qdepth_thresh_update,
5606 WMITLV_GET_STRUCT_TLVLEN(
5607 wmi_msduq_qdepth_thresh_update));
5608 cmd_update->tid_num = param->update_params[i].tid_num;
5609 cmd_update->msduq_update_mask =
5610 param->update_params[i].msduq_update_mask;
5611 cmd_update->qdepth_thresh_value =
5612 param->update_params[i].qdepth_thresh_value;
5613 WMI_LOGD("Set QDepth Threshold: vdev=0x%X pdev=0x%X, tid=0x%X "
5614 "mac_addr_upper4=%X, mac_addr_lower2:%X,"
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305615 " update mask=0x%X thresh val=0x%X",
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +05305616 cmd->vdev_id, cmd->pdev_id, cmd_update->tid_num,
5617 cmd->peer_mac_address.mac_addr31to0,
5618 cmd->peer_mac_address.mac_addr47to32,
5619 cmd_update->msduq_update_mask,
5620 cmd_update->qdepth_thresh_value);
5621 cmd_update++;
5622 }
5623
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305624 wmi_mtrace(WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID,
5625 cmd->vdev_id, 0);
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +05305626 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5627 WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID);
5628
5629 if (ret != 0) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305630 WMI_LOGE(" %s :WMI Failed", __func__);
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +05305631 wmi_buf_free(buf);
5632 }
5633
5634 return ret;
5635}
5636
5637/**
Sathish Kumar497bef42017-03-01 14:02:36 +05305638 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
5639 * @wmi_handle: wmi handle
5640 * @param: pointer to hold vap dscp tid map param
5641 *
5642 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
5643 */
5644static QDF_STATUS
5645send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
5646 struct vap_dscp_tid_map_params *param)
5647{
5648 wmi_buf_t buf;
5649 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
5650 int32_t len = sizeof(*cmd);
5651
5652 buf = wmi_buf_alloc(wmi_handle, len);
5653 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305654 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Sathish Kumar497bef42017-03-01 14:02:36 +05305655 return QDF_STATUS_E_FAILURE;
5656 }
5657
5658 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
5659 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
Vivekc5823092018-03-22 23:27:21 +05305660 sizeof(uint32_t) * WMI_DSCP_MAP_MAX);
Sathish Kumar497bef42017-03-01 14:02:36 +05305661
5662 cmd->vdev_id = param->vdev_id;
5663 cmd->enable_override = 0;
5664
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305665 WMI_LOGI("Setting dscp for vap id: %d", cmd->vdev_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305666 wmi_mtrace(WMI_VDEV_SET_DSCP_TID_MAP_CMDID, cmd->vdev_id, 0);
Sathish Kumar497bef42017-03-01 14:02:36 +05305667 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5668 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305669 WMI_LOGE("Failed to set dscp cmd");
Sathish Kumar497bef42017-03-01 14:02:36 +05305670 wmi_buf_free(buf);
5671 return QDF_STATUS_E_FAILURE;
5672 }
5673
5674 return QDF_STATUS_SUCCESS;
5675}
5676
5677/**
Sathish Kumar02c3b542017-02-22 17:24:45 +05305678 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
5679 * @wmi_handle: wmi handle
5680 * @param: pointer to hold fwtest param
5681 *
5682 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
5683 */
5684static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
5685 struct set_fwtest_params *param)
5686{
5687 wmi_fwtest_set_param_cmd_fixed_param *cmd;
5688 wmi_buf_t buf;
5689 int32_t len = sizeof(*cmd);
5690
5691 buf = wmi_buf_alloc(wmi_handle, len);
5692
5693 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305694 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Sathish Kumar02c3b542017-02-22 17:24:45 +05305695 return QDF_STATUS_E_FAILURE;
5696 }
5697
5698 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
5699 WMITLV_SET_HDR(&cmd->tlv_header,
5700 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
5701 WMITLV_GET_STRUCT_TLVLEN(
5702 wmi_fwtest_set_param_cmd_fixed_param));
5703 cmd->param_id = param->arg;
5704 cmd->param_value = param->value;
5705
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305706 wmi_mtrace(WMI_FWTEST_CMDID, NO_SESSION, 0);
Sathish Kumar02c3b542017-02-22 17:24:45 +05305707 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305708 WMI_LOGE("Setting FW test param failed");
Sathish Kumar02c3b542017-02-22 17:24:45 +05305709 wmi_buf_free(buf);
5710 return QDF_STATUS_E_FAILURE;
5711 }
5712
5713 return QDF_STATUS_SUCCESS;
5714}
5715
5716/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +05305717 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
5718 *
5719 * @param wmi_handle : handle to WMI.
5720 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
5721 */
5722static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
5723{
5724 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
5725 wmi_buf_t buf;
5726 QDF_STATUS ret;
5727 int32_t len;
5728
5729 len = sizeof(*cmd);
5730
5731 buf = wmi_buf_alloc(wmi_handle, len);
5732 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305733 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Sathish Kumarf6e3e632017-02-22 17:28:28 +05305734 return QDF_STATUS_E_FAILURE;
5735 }
5736
5737 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
5738 WMITLV_SET_HDR(&cmd->tlv_header,
5739 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
5740 WMITLV_GET_STRUCT_TLVLEN(
5741 wmi_pdev_dfs_disable_cmd_fixed_param));
5742 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05305743 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
5744 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +05305745
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305746 wmi_mtrace(WMI_PDEV_DFS_DISABLE_CMDID, NO_SESSION, 0);
Sathish Kumarf6e3e632017-02-22 17:28:28 +05305747 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
5748 WMI_PDEV_DFS_DISABLE_CMDID);
5749
5750 if (ret != 0) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305751 WMI_LOGE("Sending PDEV DFS disable cmd failed");
Sathish Kumarf6e3e632017-02-22 17:28:28 +05305752 wmi_buf_free(buf);
5753 }
5754
5755 return ret;
5756}
5757
5758/**
5759 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
5760 *
5761 * @param wmi_handle : handle to WMI.
5762 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
5763 */
5764static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
5765{
5766 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
5767 wmi_buf_t buf;
5768 QDF_STATUS ret;
5769 int32_t len;
5770
5771 len = sizeof(*cmd);
5772
5773 buf = wmi_buf_alloc(wmi_handle, len);
5774 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305775 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Sathish Kumarf6e3e632017-02-22 17:28:28 +05305776 return QDF_STATUS_E_FAILURE;
5777 }
5778
5779 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
5780 WMITLV_SET_HDR(&cmd->tlv_header,
5781 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
5782 WMITLV_GET_STRUCT_TLVLEN(
5783 wmi_pdev_dfs_enable_cmd_fixed_param));
5784 /* Reserved for future use */
5785 cmd->reserved0 = 0;
5786
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305787 wmi_mtrace(WMI_PDEV_DFS_ENABLE_CMDID, NO_SESSION, 0);
Sathish Kumarf6e3e632017-02-22 17:28:28 +05305788 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
5789 WMI_PDEV_DFS_ENABLE_CMDID);
5790
5791 if (ret != 0) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305792 WMI_LOGE("Sending PDEV DFS enable cmd failed");
Sathish Kumarf6e3e632017-02-22 17:28:28 +05305793 wmi_buf_free(buf);
5794 }
5795
5796 return ret;
5797}
5798
5799/**
Sathish Kumar0ff69e42017-11-02 10:44:39 +05305800 * send_periodic_chan_stats_config_cmd_tlv() - send periodic chan stats cmd
5801 * to fw
5802 * @wmi_handle: wmi handle
5803 * @param: pointer to hold periodic chan stats param
5804 *
5805 * Return: 0 for success or error code
5806 */
5807static QDF_STATUS
5808send_periodic_chan_stats_config_cmd_tlv(wmi_unified_t wmi_handle,
5809 struct periodic_chan_stats_params *param)
5810{
5811 wmi_set_periodic_channel_stats_config_fixed_param *cmd;
5812 wmi_buf_t buf;
5813 QDF_STATUS ret;
5814 int32_t len;
5815
5816 len = sizeof(*cmd);
5817
5818 buf = wmi_buf_alloc(wmi_handle, len);
5819 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305820 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Sathish Kumar0ff69e42017-11-02 10:44:39 +05305821 return QDF_STATUS_E_FAILURE;
5822 }
5823
5824 cmd = (wmi_set_periodic_channel_stats_config_fixed_param *)
5825 wmi_buf_data(buf);
5826 WMITLV_SET_HDR(&cmd->tlv_header,
5827 WMITLV_TAG_STRUC_wmi_set_periodic_channel_stats_config_fixed_param,
5828 WMITLV_GET_STRUCT_TLVLEN(
5829 wmi_set_periodic_channel_stats_config_fixed_param));
5830 cmd->enable = param->enable;
5831 cmd->stats_period = param->stats_period;
5832 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
5833 param->pdev_id);
5834
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305835 wmi_mtrace(WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID, NO_SESSION, 0);
Sathish Kumar0ff69e42017-11-02 10:44:39 +05305836 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
5837 WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
5838
5839 if (ret != 0) {
5840 WMI_LOGE("Sending periodic chan stats config failed");
5841 wmi_buf_free(buf);
5842 }
5843
5844 return ret;
5845}
5846
5847/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305848 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
5849 * command to fw
5850 * @wmi_handle: wmi handle
5851 * @param: pointer to hold spectral config parameter
5852 *
5853 * Return: 0 for success or error code
5854 */
5855static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
5856 struct vdev_spectral_configure_params *param)
5857{
5858 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
5859 wmi_buf_t buf;
5860 QDF_STATUS ret;
5861 int32_t len;
5862
5863 len = sizeof(*cmd);
5864 buf = wmi_buf_alloc(wmi_handle, len);
5865 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305866 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305867 return QDF_STATUS_E_FAILURE;
5868 }
5869
5870 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
5871 WMITLV_SET_HDR(&cmd->tlv_header,
5872 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
5873 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +05305874 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305875
5876 cmd->vdev_id = param->vdev_id;
5877 cmd->spectral_scan_count = param->count;
5878 cmd->spectral_scan_period = param->period;
5879 cmd->spectral_scan_priority = param->spectral_pri;
5880 cmd->spectral_scan_fft_size = param->fft_size;
5881 cmd->spectral_scan_gc_ena = param->gc_enable;
5882 cmd->spectral_scan_restart_ena = param->restart_enable;
5883 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
5884 cmd->spectral_scan_init_delay = param->init_delay;
5885 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
5886 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
5887 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
5888 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
5889 cmd->spectral_scan_rssi_thr = param->rssi_thr;
5890 cmd->spectral_scan_pwr_format = param->pwr_format;
5891 cmd->spectral_scan_rpt_mode = param->rpt_mode;
5892 cmd->spectral_scan_bin_scale = param->bin_scale;
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +05305893 cmd->spectral_scan_dBm_adj = param->dbm_adj;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305894 cmd->spectral_scan_chn_mask = param->chn_mask;
5895
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305896 wmi_mtrace(WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID, cmd->vdev_id, 0);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305897 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5898 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
5899
5900 if (ret != 0) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305901 WMI_LOGE("Sending set quiet cmd failed");
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305902 wmi_buf_free(buf);
5903 }
5904
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305905 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID",
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305906 __func__);
5907
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305908 WMI_LOGI("vdev_id = %u"
5909 "spectral_scan_count = %u"
5910 "spectral_scan_period = %u"
5911 "spectral_scan_priority = %u"
5912 "spectral_scan_fft_size = %u"
5913 "spectral_scan_gc_ena = %u"
5914 "spectral_scan_restart_ena = %u"
5915 "spectral_scan_noise_floor_ref = %u"
5916 "spectral_scan_init_delay = %u"
5917 "spectral_scan_nb_tone_thr = %u"
5918 "spectral_scan_str_bin_thr = %u"
5919 "spectral_scan_wb_rpt_mode = %u"
5920 "spectral_scan_rssi_rpt_mode = %u"
5921 "spectral_scan_rssi_thr = %u"
5922 "spectral_scan_pwr_format = %u"
5923 "spectral_scan_rpt_mode = %u"
5924 "spectral_scan_bin_scale = %u"
5925 "spectral_scan_dBm_adj = %u"
5926 "spectral_scan_chn_mask = %u",
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305927 param->vdev_id,
5928 param->count,
5929 param->period,
5930 param->spectral_pri,
5931 param->fft_size,
5932 param->gc_enable,
5933 param->restart_enable,
5934 param->noise_floor_ref,
5935 param->init_delay,
5936 param->nb_tone_thr,
5937 param->str_bin_thr,
5938 param->wb_rpt_mode,
5939 param->rssi_rpt_mode,
5940 param->rssi_thr,
5941 param->pwr_format,
5942 param->rpt_mode,
5943 param->bin_scale,
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +05305944 param->dbm_adj,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305945 param->chn_mask);
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305946 WMI_LOGI("%s: Status: %d\n", __func__, ret);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305947
5948 return ret;
5949}
5950
5951/**
5952 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
5953 * command to fw
5954 * @wmi_handle: wmi handle
5955 * @param: pointer to hold spectral enable parameter
5956 *
5957 * Return: 0 for success or error code
5958 */
5959static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
5960 struct vdev_spectral_enable_params *param)
5961{
5962 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
5963 wmi_buf_t buf;
5964 QDF_STATUS ret;
5965 int32_t len;
5966
5967 len = sizeof(*cmd);
5968 buf = wmi_buf_alloc(wmi_handle, len);
5969 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05305970 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305971 return QDF_STATUS_E_FAILURE;
5972 }
5973
5974 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
5975 WMITLV_SET_HDR(&cmd->tlv_header,
5976 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
5977 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +05305978 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305979
5980 cmd->vdev_id = param->vdev_id;
5981
5982 if (param->active_valid) {
5983 cmd->trigger_cmd = param->active ? 1 : 2;
5984 /* 1: Trigger, 2: Clear Trigger */
5985 } else {
5986 cmd->trigger_cmd = 0; /* 0: Ignore */
5987 }
5988
5989 if (param->enabled_valid) {
5990 cmd->enable_cmd = param->enabled ? 1 : 2;
5991 /* 1: Enable 2: Disable */
5992 } else {
5993 cmd->enable_cmd = 0; /* 0: Ignore */
5994 }
5995
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05305996 wmi_mtrace(WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID, cmd->vdev_id, 0);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05305997 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5998 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
5999
6000 if (ret != 0) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05306001 WMI_LOGE("Sending scan enable CMD failed");
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05306002 wmi_buf_free(buf);
6003 }
6004
Sathish Kumarefb25bf2018-10-02 11:03:59 +05306005 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID", __func__);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05306006
Sathish Kumarefb25bf2018-10-02 11:03:59 +05306007 WMI_LOGI("vdev_id = %u"
6008 "trigger_cmd = %u"
6009 "enable_cmd = %u",
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05306010 cmd->vdev_id,
6011 cmd->trigger_cmd,
6012 cmd->enable_cmd);
6013
Sathish Kumarefb25bf2018-10-02 11:03:59 +05306014 WMI_LOGI("%s: Status: %d\n", __func__, ret);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +05306015
6016 return ret;
6017}
6018
6019/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +05306020 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
6021 * @param wmi_handle : handle to WMI.
6022 * @param param : pointer to hold thermal mitigation param
6023 *
6024 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
6025 */
6026static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
6027 wmi_unified_t wmi_handle,
6028 struct thermal_mitigation_params *param)
6029{
6030 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
6031 wmi_therm_throt_level_config_info *lvl_conf = NULL;
6032 wmi_buf_t buf = NULL;
6033 uint8_t *buf_ptr = NULL;
6034 int error;
6035 int32_t len;
6036 int i;
6037
6038 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
6039 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
6040
6041 buf = wmi_buf_alloc(wmi_handle, len);
6042 if (!buf) {
6043 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
6044 return QDF_STATUS_E_NOMEM;
6045 }
6046 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
6047
6048 /* init fixed params */
6049 WMITLV_SET_HDR(tt_conf,
6050 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
6051 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
6052
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05306053 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
6054 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +05306055 tt_conf->enable = param->enable;
6056 tt_conf->dc = param->dc;
6057 tt_conf->dc_per_event = param->dc_per_event;
6058 tt_conf->therm_throt_levels = THERMAL_LEVELS;
6059
6060 buf_ptr = (uint8_t *) ++tt_conf;
6061 /* init TLV params */
6062 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6063 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
6064
6065 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
6066 for (i = 0; i < THERMAL_LEVELS; i++) {
6067 WMITLV_SET_HDR(&lvl_conf->tlv_header,
6068 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
6069 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
6070 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
6071 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
6072 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
6073 lvl_conf->prio = param->levelconf[i].priority;
6074 lvl_conf++;
6075 }
6076
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306077 wmi_mtrace(WMI_THERM_THROT_SET_CONF_CMDID, NO_SESSION, 0);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +05306078 error = wmi_unified_cmd_send(wmi_handle, buf, len,
6079 WMI_THERM_THROT_SET_CONF_CMDID);
6080 if (QDF_IS_STATUS_ERROR(error)) {
6081 wmi_buf_free(buf);
6082 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
6083 }
6084
6085 return error;
6086}
6087
6088/**
Sathish Kumar80f4f382017-04-24 11:36:00 +05306089 * send_coex_config_cmd_tlv() - send coex config command to fw
6090 * @wmi_handle: wmi handle
6091 * @param: pointer to coex config param
6092 *
6093 * Return: 0 for success or error code
6094 */
6095static QDF_STATUS
6096send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
6097 struct coex_config_params *param)
6098{
6099 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
6100 wmi_buf_t buf;
6101 QDF_STATUS ret;
6102 int32_t len;
6103
6104 len = sizeof(*cmd);
6105 buf = wmi_buf_alloc(wmi_handle, len);
6106 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05306107 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Sathish Kumar80f4f382017-04-24 11:36:00 +05306108 return QDF_STATUS_E_FAILURE;
6109 }
6110
6111 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
6112 WMITLV_SET_HDR(&cmd->tlv_header,
6113 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
6114 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +05306115 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +05306116
6117 cmd->vdev_id = param->vdev_id;
6118 cmd->config_type = param->config_type;
6119 cmd->config_arg1 = param->config_arg1;
6120 cmd->config_arg2 = param->config_arg2;
6121 cmd->config_arg3 = param->config_arg3;
6122 cmd->config_arg4 = param->config_arg4;
6123 cmd->config_arg5 = param->config_arg5;
6124 cmd->config_arg6 = param->config_arg6;
6125
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306126 wmi_mtrace(WMI_COEX_CONFIG_CMDID, cmd->vdev_id, 0);
Sathish Kumar80f4f382017-04-24 11:36:00 +05306127 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6128 WMI_COEX_CONFIG_CMDID);
6129
6130 if (ret != 0) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05306131 WMI_LOGE("Sending COEX CONFIG CMD failed");
Sathish Kumar80f4f382017-04-24 11:36:00 +05306132 wmi_buf_free(buf);
6133 }
6134
6135 return ret;
6136}
6137
Kiran Venkatappa3619e662018-04-04 14:31:43 +05306138#ifdef WLAN_SUPPORT_TWT
6139static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
6140 target_resource_config *tgt_res_cfg)
6141{
6142 resource_cfg->twt_ap_pdev_count = tgt_res_cfg->twt_ap_pdev_count;
6143 resource_cfg->twt_ap_sta_count = tgt_res_cfg->twt_ap_sta_count;
6144}
6145#else
6146static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
6147 target_resource_config *tgt_res_cfg)
6148{
6149 resource_cfg->twt_ap_pdev_count = 0;
6150 resource_cfg->twt_ap_sta_count = 0;
6151}
6152#endif
6153
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006154static
Govind Singh9ddd5162016-03-07 16:30:32 +05306155void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +05306156 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +05306157{
Govind Singhe7f2f342016-05-23 12:12:52 +05306158 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +05306159 resource_cfg->num_peers = tgt_res_cfg->num_peers;
6160 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
6161 resource_cfg->num_offload_reorder_buffs =
6162 tgt_res_cfg->num_offload_reorder_buffs;
6163 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
6164 resource_cfg->num_tids = tgt_res_cfg->num_tids;
6165 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
6166 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
6167 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
6168 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
6169 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
6170 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
6171 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
6172 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
6173 resource_cfg->scan_max_pending_req =
6174 tgt_res_cfg->scan_max_pending_req;
6175 resource_cfg->bmiss_offload_max_vdev =
6176 tgt_res_cfg->bmiss_offload_max_vdev;
6177 resource_cfg->roam_offload_max_vdev =
6178 tgt_res_cfg->roam_offload_max_vdev;
6179 resource_cfg->roam_offload_max_ap_profiles =
6180 tgt_res_cfg->roam_offload_max_ap_profiles;
6181 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
6182 resource_cfg->num_mcast_table_elems =
6183 tgt_res_cfg->num_mcast_table_elems;
6184 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
6185 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
6186 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
6187 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
6188 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
6189 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
6190 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
6191 resource_cfg->vow_config = tgt_res_cfg->vow_config;
6192 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
6193 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
6194 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
6195 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
6196 resource_cfg->num_tdls_conn_table_entries =
6197 tgt_res_cfg->num_tdls_conn_table_entries;
6198 resource_cfg->beacon_tx_offload_max_vdev =
6199 tgt_res_cfg->beacon_tx_offload_max_vdev;
6200 resource_cfg->num_multicast_filter_entries =
6201 tgt_res_cfg->num_multicast_filter_entries;
6202 resource_cfg->num_wow_filters =
6203 tgt_res_cfg->num_wow_filters;
6204 resource_cfg->num_keep_alive_pattern =
6205 tgt_res_cfg->num_keep_alive_pattern;
6206 resource_cfg->keep_alive_pattern_size =
6207 tgt_res_cfg->keep_alive_pattern_size;
6208 resource_cfg->max_tdls_concurrent_sleep_sta =
6209 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
6210 resource_cfg->max_tdls_concurrent_buffer_sta =
6211 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
6212 resource_cfg->wmi_send_separate =
6213 tgt_res_cfg->wmi_send_separate;
6214 resource_cfg->num_ocb_vdevs =
6215 tgt_res_cfg->num_ocb_vdevs;
6216 resource_cfg->num_ocb_channels =
6217 tgt_res_cfg->num_ocb_channels;
6218 resource_cfg->num_ocb_schedules =
6219 tgt_res_cfg->num_ocb_schedules;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +05306220 resource_cfg->bpf_instruction_size = tgt_res_cfg->apf_instruction_size;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +05306221 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
6222 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Mukul Sharmad7c9e332017-11-02 17:42:36 +05306223 resource_cfg->max_num_dbs_scan_duty_cycle =
6224 tgt_res_cfg->max_num_dbs_scan_duty_cycle;
Kris Muthusamy3c2c76a2017-11-30 01:40:46 -08006225 resource_cfg->sched_params = tgt_res_cfg->scheduler_params;
Dustin Brown983c53f2018-03-07 11:48:14 -08006226 resource_cfg->num_packet_filters = tgt_res_cfg->num_packet_filters;
6227 resource_cfg->num_max_sta_vdevs = tgt_res_cfg->num_max_sta_vdevs;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -07006228 resource_cfg->max_bssid_indicator = tgt_res_cfg->max_bssid_indicator;
Mukul Sharmad7c9e332017-11-02 17:42:36 +05306229 if (tgt_res_cfg->atf_config)
6230 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1, 1);
6231 if (tgt_res_cfg->mgmt_comp_evt_bundle_support)
6232 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(
6233 resource_cfg->flag1, 1);
6234 if (tgt_res_cfg->tx_msdu_new_partition_id_support)
6235 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(
6236 resource_cfg->flag1, 1);
Ruchi, Agrawal0a40ba12017-11-21 14:39:02 +05306237 if (tgt_res_cfg->cce_disable)
6238 WMI_RSRC_CFG_FLAG_TCL_CCE_DISABLE_SET(resource_cfg->flag1, 1);
Aditya Sathish800c7372018-10-02 11:02:55 +05306239 if (tgt_res_cfg->eapol_minrate_set) {
6240 WMI_RSRC_CFG_FLAG_EAPOL_REKEY_MINRATE_SUPPORT_ENABLE_SET(
6241 resource_cfg->flag1, 1);
6242 if (tgt_res_cfg->eapol_minrate_ac_set != 3) {
6243 WMI_RSRC_CFG_FLAG_EAPOL_AC_OVERRIDE_VALID_SET(
6244 resource_cfg->flag1, 1);
6245 WMI_RSRC_CFG_FLAG_EAPOL_AC_OVERRIDE_SET(
6246 resource_cfg->flag1,
6247 tgt_res_cfg->eapol_minrate_ac_set);
6248 }
6249 }
Kiran Venkatappa3619e662018-04-04 14:31:43 +05306250
6251 wmi_copy_twt_resource_config(resource_cfg, tgt_res_cfg);
Chaithanya Garrepallibdfea2b2018-09-12 17:02:31 +05306252 resource_cfg->peer_map_unmap_v2_support =
6253 tgt_res_cfg->peer_map_unmap_v2;
Govind Singh9ddd5162016-03-07 16:30:32 +05306254}
Kiran Venkatappa22a02982017-10-11 22:56:45 +05306255
6256/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
6257 * @wmi_handle: pointer to wmi handle
6258 * @buf_ptr: pointer to current position in init command buffer
Jeff Johnsonac11e172018-05-06 15:40:42 -07006259 * @len: pointer to length. This will be updated with current length of cmd
Kiran Venkatappa22a02982017-10-11 22:56:45 +05306260 * @param: point host parameters for init command
6261 *
6262 * Return: Updated pointer of buf_ptr.
6263 */
6264static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
6265 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
6266{
6267 uint16_t idx;
6268
6269 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
6270 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
6271 wmi_pdev_band_to_mac *band_to_mac;
6272
6273 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
6274 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
6275 sizeof(wmi_resource_config) +
6276 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
6277 sizeof(wlan_host_memory_chunk)));
6278
6279 WMITLV_SET_HDR(&hw_mode->tlv_header,
6280 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
6281 (WMITLV_GET_STRUCT_TLVLEN
6282 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
6283
6284 hw_mode->hw_mode_index = param->hw_mode_id;
6285 hw_mode->num_band_to_mac = param->num_band_to_mac;
6286
6287 buf_ptr = (uint8_t *) (hw_mode + 1);
6288 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
6289 WMI_TLV_HDR_SIZE);
6290 for (idx = 0; idx < param->num_band_to_mac; idx++) {
6291 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
6292 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
6293 WMITLV_GET_STRUCT_TLVLEN
6294 (wmi_pdev_band_to_mac));
6295 band_to_mac[idx].pdev_id =
6296 wmi_handle->ops->convert_pdev_id_host_to_target(
6297 param->band_to_mac[idx].pdev_id);
6298 band_to_mac[idx].start_freq =
6299 param->band_to_mac[idx].start_freq;
6300 band_to_mac[idx].end_freq =
6301 param->band_to_mac[idx].end_freq;
6302 }
6303 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
6304 (param->num_band_to_mac *
6305 sizeof(wmi_pdev_band_to_mac)) +
6306 WMI_TLV_HDR_SIZE;
6307
6308 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6309 (param->num_band_to_mac *
6310 sizeof(wmi_pdev_band_to_mac)));
6311 }
6312
6313 return buf_ptr;
6314}
6315
6316static inline void copy_fw_abi_version_tlv(wmi_unified_t wmi_handle,
6317 wmi_init_cmd_fixed_param *cmd)
6318{
6319 int num_whitelist;
6320 wmi_abi_version my_vers;
6321
6322 num_whitelist = sizeof(version_whitelist) /
6323 sizeof(wmi_whitelist_version_info);
6324 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
6325 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
6326 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
6327 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
6328 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
6329 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
6330
6331 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
6332 &my_vers,
6333 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
6334 &cmd->host_abi_vers);
6335
6336 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
6337 __func__,
6338 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
6339 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
6340 cmd->host_abi_vers.abi_version_ns_0,
6341 cmd->host_abi_vers.abi_version_ns_1,
6342 cmd->host_abi_vers.abi_version_ns_2,
6343 cmd->host_abi_vers.abi_version_ns_3);
6344
6345 /* Save version sent from host -
6346 * Will be used to check ready event
6347 */
6348 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
6349 sizeof(wmi_abi_version));
6350}
6351
Sathish Kumarfd347372017-02-13 12:29:09 +05306352static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +05306353{
6354 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
6355 wmi_service_ready_event_fixed_param *ev;
6356
6357
6358 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
6359
6360 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
6361 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +05306362 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05306363
6364 /*Save fw version from service ready message */
6365 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +05306366 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05306367 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +05306368
Govind Singhb53420c2016-03-09 14:32:57 +05306369 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05306370}
6371
6372/**
6373 * wmi_unified_save_fw_version_cmd() - save fw version
6374 * @wmi_handle: pointer to wmi handle
Sathish Kumarefb25bf2018-10-02 11:03:59 +05306375 * @res_cfg: resource config
Govind Singh9ddd5162016-03-07 16:30:32 +05306376 * @num_mem_chunks: no of mem chunck
6377 * @mem_chunk: pointer to mem chunck structure
6378 *
6379 * This function sends IE information to firmware
6380 *
Govind Singhb53420c2016-03-09 14:32:57 +05306381 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +05306382 *
6383 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306384static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +05306385 void *evt_buf)
6386{
6387 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
6388 wmi_ready_event_fixed_param *ev = NULL;
6389
6390 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
6391 ev = param_buf->fixed_param;
Kiran Venkatappa22a02982017-10-11 22:56:45 +05306392 if (!wmi_versions_are_compatible((struct _wmi_abi_version *)
6393 &wmi_handle->final_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05306394 &ev->fw_abi_vers)) {
6395 /*
6396 * Error: Our host version and the given firmware version
6397 * are incompatible.
6398 **/
Govind Singhb53420c2016-03-09 14:32:57 +05306399 WMI_LOGD("%s: Error: Incompatible WMI version."
Sathish Kumarefb25bf2018-10-02 11:03:59 +05306400 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +05306401 __func__,
6402 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
6403 abi_version_0),
6404 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
6405 abi_version_0),
6406 wmi_handle->final_abi_vers.abi_version_ns_0,
6407 wmi_handle->final_abi_vers.abi_version_ns_1,
6408 wmi_handle->final_abi_vers.abi_version_ns_2,
6409 wmi_handle->final_abi_vers.abi_version_ns_3,
6410 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
6411 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
6412 ev->fw_abi_vers.abi_version_ns_0,
6413 ev->fw_abi_vers.abi_version_ns_1,
6414 ev->fw_abi_vers.abi_version_ns_2,
6415 ev->fw_abi_vers.abi_version_ns_3);
6416
Govind Singhb53420c2016-03-09 14:32:57 +05306417 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +05306418 }
Govind Singhb53420c2016-03-09 14:32:57 +05306419 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05306420 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +05306421 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +05306422 sizeof(wmi_abi_version));
Govind Singh9ddd5162016-03-07 16:30:32 +05306423
Govind Singhb53420c2016-03-09 14:32:57 +05306424 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +05306425}
Govind Singha4836fd2016-03-07 16:45:38 +05306426
6427/**
Govind Singha4836fd2016-03-07 16:45:38 +05306428 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
6429 * @handle: wmi handle
6430 * @event: Event received from FW
6431 * @len: Length of the event
6432 *
6433 * Enables the low frequency events and disables the high frequency
6434 * events. Bit 17 indicates if the event if low/high frequency.
6435 * 1 - high frequency, 0 - low frequency
6436 *
6437 * Return: 0 on successfully enabling/disabling the events
6438 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306439static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05306440 uint8_t *event,
6441 uint32_t len)
6442{
6443 uint32_t num_of_diag_events_logs;
6444 wmi_diag_event_log_config_fixed_param *cmd;
6445 wmi_buf_t buf;
6446 uint8_t *buf_ptr;
6447 uint32_t *cmd_args, *evt_args;
6448 uint32_t buf_len, i;
6449
6450 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
6451 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
6452
Govind Singhb53420c2016-03-09 14:32:57 +05306453 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +05306454
6455 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
6456 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306457 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +05306458 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05306459 }
6460 wmi_event = param_buf->fixed_param;
6461 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
Amar Singhal5593c902017-10-03 13:00:29 -07006462
6463 if (num_of_diag_events_logs >
6464 param_buf->num_diag_events_logs_list) {
6465 WMI_LOGE("message number of events %d is more than tlv hdr content %d",
6466 num_of_diag_events_logs,
6467 param_buf->num_diag_events_logs_list);
6468 return QDF_STATUS_E_INVAL;
6469 }
6470
Govind Singha4836fd2016-03-07 16:45:38 +05306471 evt_args = param_buf->diag_events_logs_list;
6472 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +05306473 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +05306474 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +05306475 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05306476 }
6477
Govind Singhb53420c2016-03-09 14:32:57 +05306478 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +05306479 __func__, num_of_diag_events_logs);
6480
6481 /* Free any previous allocation */
6482 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +05306483 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +05306484
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -07006485 if (num_of_diag_events_logs >
6486 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
6487 WMI_LOGE("%s: excess num of logs:%d", __func__,
6488 num_of_diag_events_logs);
6489 QDF_ASSERT(0);
6490 return QDF_STATUS_E_INVAL;
6491 }
Govind Singha4836fd2016-03-07 16:45:38 +05306492 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +05306493 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +05306494 sizeof(uint32_t));
6495 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +05306496 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +05306497 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05306498 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05306499 }
6500 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
6501
6502 /* Prepare the send buffer */
6503 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
6504 (num_of_diag_events_logs * sizeof(uint32_t));
6505
6506 buf = wmi_buf_alloc(wmi_handle, buf_len);
6507 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306508 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6509 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +05306510 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306511 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05306512 }
6513
6514 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
6515 buf_ptr = (uint8_t *) cmd;
6516
6517 WMITLV_SET_HDR(&cmd->tlv_header,
6518 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
6519 WMITLV_GET_STRUCT_TLVLEN(
6520 wmi_diag_event_log_config_fixed_param));
6521
6522 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
6523
6524 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
6525
6526 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6527 (num_of_diag_events_logs * sizeof(uint32_t)));
6528
6529 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
6530
6531 /* Populate the events */
6532 for (i = 0; i < num_of_diag_events_logs; i++) {
6533 /* Low freq (0) - Enable (1) the event
6534 * High freq (1) - Disable (0) the event
6535 */
6536 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
6537 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
6538 /* Set the event ID */
6539 WMI_DIAG_ID_SET(cmd_args[i],
6540 WMI_DIAG_ID_GET(evt_args[i]));
6541 /* Set the type */
6542 WMI_DIAG_TYPE_SET(cmd_args[i],
6543 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +05306544 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +05306545 wmi_handle->events_logs_list[i] = evt_args[i];
6546 }
6547
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306548 wmi_mtrace(WMI_DIAG_EVENT_LOG_CONFIG_CMDID, NO_SESSION, 0);
Govind Singha4836fd2016-03-07 16:45:38 +05306549 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
6550 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306551 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +05306552 __func__);
6553 wmi_buf_free(buf);
6554 /* Not clearing events_logs_list, though wmi cmd failed.
6555 * Host can still have this list
6556 */
Govind Singh67922e82016-04-01 16:48:57 +05306557 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05306558 }
6559
6560 return 0;
6561}
6562
6563/**
6564 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
6565 * @wmi_handle: wmi handle
6566 * @start_log: Start logging related parameters
6567 *
6568 * Send the command to the FW based on which specific logging of diag
6569 * event/log id can be started/stopped
6570 *
6571 * Return: None
6572 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306573static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05306574 struct wmi_wifi_start_log *start_log)
6575{
6576 wmi_diag_event_log_config_fixed_param *cmd;
6577 wmi_buf_t buf;
6578 uint8_t *buf_ptr;
6579 uint32_t len, count, log_level, i;
6580 uint32_t *cmd_args;
6581 uint32_t total_len;
6582 count = 0;
6583
6584 if (!wmi_handle->events_logs_list) {
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +05306585 WMI_LOGD("%s: Not received event/log list from FW, yet",
6586 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05306587 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05306588 }
6589 /* total_len stores the number of events where BITS 17 and 18 are set.
6590 * i.e., events of high frequency (17) and for extended debugging (18)
6591 */
6592 total_len = 0;
6593 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
6594 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
6595 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
6596 total_len++;
6597 }
6598
6599 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
6600 (total_len * sizeof(uint32_t));
6601
6602 buf = wmi_buf_alloc(wmi_handle, len);
6603 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306604 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05306605 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05306606 }
6607 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
6608 buf_ptr = (uint8_t *) cmd;
6609
6610 WMITLV_SET_HDR(&cmd->tlv_header,
6611 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
6612 WMITLV_GET_STRUCT_TLVLEN(
6613 wmi_diag_event_log_config_fixed_param));
6614
6615 cmd->num_of_diag_events_logs = total_len;
6616
6617 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
6618
6619 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6620 (total_len * sizeof(uint32_t)));
6621
6622 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
6623
Govind Singh224a7312016-06-21 14:33:26 +05306624 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +05306625 log_level = 1;
6626 else
6627 log_level = 0;
6628
Govind Singhb53420c2016-03-09 14:32:57 +05306629 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +05306630 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
6631 uint32_t val = wmi_handle->events_logs_list[i];
6632 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
6633 (WMI_DIAG_EXT_FEATURE_GET(val))) {
6634
6635 WMI_DIAG_ID_SET(cmd_args[count],
6636 WMI_DIAG_ID_GET(val));
6637 WMI_DIAG_TYPE_SET(cmd_args[count],
6638 WMI_DIAG_TYPE_GET(val));
6639 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
6640 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +05306641 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +05306642 count++;
6643 }
6644 }
6645
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306646 wmi_mtrace(WMI_DIAG_EVENT_LOG_CONFIG_CMDID, NO_SESSION, 0);
Govind Singha4836fd2016-03-07 16:45:38 +05306647 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6648 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306649 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +05306650 __func__);
6651 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05306652 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05306653 }
6654
Govind Singhb53420c2016-03-09 14:32:57 +05306655 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +05306656}
6657
6658/**
6659 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
6660 * @wmi_handle: WMI handle
6661 *
6662 * This function is used to send the flush command to the FW,
6663 * that will flush the fw logs that are residue in the FW
6664 *
6665 * Return: None
6666 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306667static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +05306668{
6669 wmi_debug_mesg_flush_fixed_param *cmd;
6670 wmi_buf_t buf;
6671 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +05306672 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +05306673
6674 buf = wmi_buf_alloc(wmi_handle, len);
6675 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306676 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05306677 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05306678 }
6679
6680 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
6681 WMITLV_SET_HDR(&cmd->tlv_header,
6682 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
6683 WMITLV_GET_STRUCT_TLVLEN(
6684 wmi_debug_mesg_flush_fixed_param));
6685 cmd->reserved0 = 0;
6686
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306687 wmi_mtrace(WMI_DEBUG_MESG_FLUSH_CMDID, NO_SESSION, 0);
Govind Singha4836fd2016-03-07 16:45:38 +05306688 ret = wmi_unified_cmd_send(wmi_handle,
6689 buf,
6690 len,
6691 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306692 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306693 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +05306694 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05306695 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +05306696 }
Yeshwanth Sriram Guntukab0ced002018-08-23 18:25:28 +05306697 WMI_LOGD("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +05306698
Govind Singh67922e82016-04-01 16:48:57 +05306699 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +05306700}
6701
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306702#ifdef BIG_ENDIAN_HOST
6703/**
6704* fips_conv_data_be() - LE to BE conversion of FIPS ev data
6705* @param data_len - data length
6706* @param data - pointer to data
6707*
6708* Return: QDF_STATUS - success or error status
6709*/
6710static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
6711 struct fips_params *param)
6712{
6713 unsigned char *key_unaligned, *data_unaligned;
6714 int c;
6715 u_int8_t *key_aligned = NULL;
6716 u_int8_t *data_aligned = NULL;
6717
6718 /* Assigning unaligned space to copy the key */
6719 key_unaligned = qdf_mem_malloc(
6720 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
6721 data_unaligned = qdf_mem_malloc(
6722 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
6723
Jeff Johnsonda263992018-05-12 14:22:00 -07006724 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306725 if (key_unaligned == NULL)
6726 return QDF_STATUS_SUCCESS;
6727 /* Checking if space is aligned */
6728 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
6729 /* align to 4 */
6730 key_aligned =
6731 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
6732 FIPS_ALIGN);
6733 } else {
6734 key_aligned = (u_int8_t *)key_unaligned;
6735 }
6736
6737 /* memset and copy content from key to key aligned */
6738 OS_MEMSET(key_aligned, 0, param->key_len);
6739 OS_MEMCPY(key_aligned, param->key, param->key_len);
6740
6741 /* print a hexdump for host debug */
6742 print_hex_dump(KERN_DEBUG,
6743 "\t Aligned and Copied Key:@@@@ ",
6744 DUMP_PREFIX_NONE,
6745 16, 1, key_aligned, param->key_len, true);
6746
Jeff Johnsonda263992018-05-12 14:22:00 -07006747 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306748 if (data_unaligned == NULL)
6749 return QDF_STATUS_SUCCESS;
6750 /* Checking of space is aligned */
6751 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
6752 /* align to 4 */
6753 data_aligned =
6754 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
6755 FIPS_ALIGN);
6756 } else {
6757 data_aligned = (u_int8_t *)data_unaligned;
6758 }
6759
6760 /* memset and copy content from data to data aligned */
6761 OS_MEMSET(data_aligned, 0, param->data_len);
6762 OS_MEMCPY(data_aligned, param->data, param->data_len);
6763
6764 /* print a hexdump for host debug */
6765 print_hex_dump(KERN_DEBUG,
6766 "\t Properly Aligned and Copied Data:@@@@ ",
6767 DUMP_PREFIX_NONE,
6768 16, 1, data_aligned, param->data_len, true);
6769
6770 /* converting to little Endian both key_aligned and
6771 * data_aligned*/
6772 for (c = 0; c < param->key_len/4; c++) {
6773 *((u_int32_t *)key_aligned+c) =
6774 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
6775 }
6776 for (c = 0; c < param->data_len/4; c++) {
6777 *((u_int32_t *)data_aligned+c) =
6778 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
6779 }
6780
6781 /* update endian data to key and data vectors */
6782 OS_MEMCPY(param->key, key_aligned, param->key_len);
6783 OS_MEMCPY(param->data, data_aligned, param->data_len);
6784
6785 /* clean up allocated spaces */
6786 qdf_mem_free(key_unaligned);
6787 key_unaligned = NULL;
6788 key_aligned = NULL;
6789
6790 qdf_mem_free(data_unaligned);
6791 data_unaligned = NULL;
6792 data_aligned = NULL;
6793
6794 return QDF_STATUS_SUCCESS;
6795}
6796#else
6797/**
6798* fips_align_data_be() - DUMMY for LE platform
6799*
6800* Return: QDF_STATUS - success
6801*/
6802static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
6803 struct fips_params *param)
6804{
6805 return QDF_STATUS_SUCCESS;
6806}
6807#endif
6808
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306809/**
6810 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
6811 * @wmi_handle: wmi handle
6812 * @param: pointer to hold pdev fips param
6813 *
6814 * Return: 0 for success or error code
6815 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306816static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306817send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
6818 struct fips_params *param)
6819{
6820 wmi_pdev_fips_cmd_fixed_param *cmd;
6821 wmi_buf_t buf;
6822 uint8_t *buf_ptr;
6823 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
6824 QDF_STATUS retval = QDF_STATUS_SUCCESS;
6825
6826 /* Length TLV placeholder for array of bytes */
6827 len += WMI_TLV_HDR_SIZE;
6828 if (param->data_len)
6829 len += (param->data_len*sizeof(uint8_t));
6830
6831 /*
6832 * Data length must be multiples of 16 bytes - checked against 0xF -
6833 * and must be less than WMI_SVC_MSG_SIZE - static size of
6834 * wmi_pdev_fips_cmd structure
6835 */
6836
6837 /* do sanity on the input */
6838 if (!(((param->data_len & 0xF) == 0) &&
6839 ((param->data_len > 0) &&
6840 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
6841 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
6842 return QDF_STATUS_E_INVAL;
6843 }
6844
6845 buf = wmi_buf_alloc(wmi_handle, len);
6846 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05306847 qdf_print("%s:wmi_buf_alloc failed", __func__);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306848 return QDF_STATUS_E_FAILURE;
6849 }
6850
6851 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6852 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
6853 WMITLV_SET_HDR(&cmd->tlv_header,
6854 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
6855 WMITLV_GET_STRUCT_TLVLEN
6856 (wmi_pdev_fips_cmd_fixed_param));
6857
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05306858 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
6859 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306860 if (param->key != NULL && param->data != NULL) {
6861 cmd->key_len = param->key_len;
6862 cmd->data_len = param->data_len;
6863 cmd->fips_cmd = !!(param->op);
6864
6865 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
6866 return QDF_STATUS_E_FAILURE;
6867
6868 qdf_mem_copy(cmd->key, param->key, param->key_len);
6869
6870 if (param->mode == FIPS_ENGINE_AES_CTR ||
6871 param->mode == FIPS_ENGINE_AES_MIC) {
6872 cmd->mode = param->mode;
6873 } else {
6874 cmd->mode = FIPS_ENGINE_AES_CTR;
6875 }
Aditya Sathish45d7ada2018-07-02 17:31:55 +05306876 qdf_print("Key len = %d, Data len = %d",
6877 cmd->key_len, cmd->data_len);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306878
6879 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
6880 cmd->key, cmd->key_len, true);
6881 buf_ptr += sizeof(*cmd);
6882
6883 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
6884
6885 buf_ptr += WMI_TLV_HDR_SIZE;
6886 if (param->data_len)
6887 qdf_mem_copy(buf_ptr,
6888 (uint8_t *) param->data, param->data_len);
6889
6890 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
6891 16, 1, buf_ptr, cmd->data_len, true);
6892
6893 buf_ptr += param->data_len;
6894
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306895 wmi_mtrace(WMI_PDEV_FIPS_CMDID, NO_SESSION, 0);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306896 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
6897 WMI_PDEV_FIPS_CMDID);
Aditya Sathish45d7ada2018-07-02 17:31:55 +05306898 qdf_print("%s return value %d", __func__, retval);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306899 } else {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05306900 qdf_print("\n%s:%d Key or Data is NULL", __func__, __LINE__);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +05306901 wmi_buf_free(buf);
6902 retval = -QDF_STATUS_E_BADMSG;
6903 }
6904
6905 return retval;
6906}
6907
Govind Singha4836fd2016-03-07 16:45:38 +05306908/**
6909 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
6910 * @wmi_handle: wmi handle
6911 * @request: SSID hotlist set request
6912 *
Govind Singhb53420c2016-03-09 14:32:57 +05306913 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +05306914 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306915static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +05306916send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
6917 struct ssid_hotlist_request_params *request)
6918{
6919 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
6920 wmi_buf_t wmi_buf;
6921 uint32_t len;
6922 uint32_t array_size;
6923 uint8_t *buf_ptr;
6924
6925 /* length of fixed portion */
6926 len = sizeof(*cmd);
6927
6928 /* length of variable portion */
6929 array_size =
6930 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
6931 len += WMI_TLV_HDR_SIZE + array_size;
6932
6933 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6934 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306935 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6936 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05306937 }
6938
6939 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6940 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
6941 buf_ptr;
6942 WMITLV_SET_HDR
6943 (&cmd->tlv_header,
6944 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
6945 WMITLV_GET_STRUCT_TLVLEN
6946 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
6947
6948 cmd->request_id = request->request_id;
6949 cmd->requestor_id = 0;
6950 cmd->vdev_id = request->session_id;
6951 cmd->table_id = 0;
6952 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
6953 cmd->total_entries = request->ssid_count;
6954 cmd->num_entries_in_page = request->ssid_count;
6955 cmd->first_entry_index = 0;
6956
6957 buf_ptr += sizeof(*cmd);
6958 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
6959
6960 if (request->ssid_count) {
6961 wmi_extscan_hotlist_ssid_entry *entry;
6962 int i;
6963
6964 buf_ptr += WMI_TLV_HDR_SIZE;
6965 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
6966 for (i = 0; i < request->ssid_count; i++) {
6967 WMITLV_SET_HDR
6968 (entry,
6969 WMITLV_TAG_ARRAY_STRUC,
6970 WMITLV_GET_STRUCT_TLVLEN
6971 (wmi_extscan_hotlist_ssid_entry));
6972 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05306973 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +05306974 request->ssids[i].ssid.mac_ssid,
6975 request->ssids[i].ssid.length);
6976 entry->band = request->ssids[i].band;
6977 entry->min_rssi = request->ssids[i].rssi_low;
6978 entry->max_rssi = request->ssids[i].rssi_high;
6979 entry++;
6980 }
6981 cmd->mode = WMI_EXTSCAN_MODE_START;
6982 } else {
6983 cmd->mode = WMI_EXTSCAN_MODE_STOP;
6984 }
6985
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05306986 wmi_mtrace(WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID,
6987 cmd->vdev_id, 0);
Govind Singha4836fd2016-03-07 16:45:38 +05306988 if (wmi_unified_cmd_send
6989 (wmi_handle, wmi_buf, len,
6990 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306991 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +05306992 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306993 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +05306994 }
6995
Govind Singhb53420c2016-03-09 14:32:57 +05306996 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +05306997}
6998
6999/**
Anurag Chouhan459e0152016-07-22 20:19:54 +05307000 * send_fw_test_cmd_tlv() - send fw test command to fw.
7001 * @wmi_handle: wmi handle
7002 * @wmi_fwtest: fw test command
7003 *
7004 * This function sends fw test command to fw.
7005 *
7006 * Return: CDF STATUS
7007 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07007008static
Anurag Chouhan459e0152016-07-22 20:19:54 +05307009QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
7010 struct set_fwtest_params *wmi_fwtest)
7011{
7012 wmi_fwtest_set_param_cmd_fixed_param *cmd;
7013 wmi_buf_t wmi_buf;
7014 uint16_t len;
7015
7016 len = sizeof(*cmd);
7017
7018 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7019 if (!wmi_buf) {
7020 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
7021 return QDF_STATUS_E_NOMEM;
7022 }
7023
7024 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
7025 WMITLV_SET_HDR(&cmd->tlv_header,
7026 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
7027 WMITLV_GET_STRUCT_TLVLEN(
7028 wmi_fwtest_set_param_cmd_fixed_param));
7029 cmd->param_id = wmi_fwtest->arg;
7030 cmd->param_value = wmi_fwtest->value;
7031
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307032 wmi_mtrace(WMI_FWTEST_CMDID, NO_SESSION, 0);
Anurag Chouhan459e0152016-07-22 20:19:54 +05307033 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7034 WMI_FWTEST_CMDID)) {
7035 WMI_LOGP("%s: failed to send fw test command", __func__);
Rakshith Suresh Patkar9eb15ee2018-09-12 16:51:30 +05307036 wmi_buf_free(wmi_buf);
Anurag Chouhan459e0152016-07-22 20:19:54 +05307037 return QDF_STATUS_E_FAILURE;
7038 }
7039
7040 return QDF_STATUS_SUCCESS;
7041}
7042
7043/**
Govind Singha4836fd2016-03-07 16:45:38 +05307044 * send_unit_test_cmd_tlv() - send unit test command to fw.
7045 * @wmi_handle: wmi handle
7046 * @wmi_utest: unit test command
7047 *
7048 * This function send unit test command to fw.
7049 *
7050 * Return: CDF STATUS
7051 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307052static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +05307053 struct wmi_unit_test_cmd *wmi_utest)
7054{
7055 wmi_unit_test_cmd_fixed_param *cmd;
7056 wmi_buf_t wmi_buf;
7057 uint8_t *buf_ptr;
7058 int i;
7059 uint16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +05307060 uint32_t *unit_test_cmd_args;
Govind Singha4836fd2016-03-07 16:45:38 +05307061
7062 args_tlv_len =
Vivekc5823092018-03-22 23:27:21 +05307063 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +05307064 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
7065
7066 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7067 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307068 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
7069 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +05307070 }
7071
7072 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
7073 buf_ptr = (uint8_t *) cmd;
7074 WMITLV_SET_HDR(&cmd->tlv_header,
7075 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
7076 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
7077 cmd->vdev_id = wmi_utest->vdev_id;
7078 cmd->module_id = wmi_utest->module_id;
7079 cmd->num_args = wmi_utest->num_args;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -07007080 cmd->diag_token = wmi_utest->diag_token;
Govind Singha4836fd2016-03-07 16:45:38 +05307081 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
7082 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7083 (wmi_utest->num_args * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +05307084 unit_test_cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Sathish Kumarefb25bf2018-10-02 11:03:59 +05307085 WMI_LOGI("%s: VDEV ID: %d", __func__, cmd->vdev_id);
7086 WMI_LOGI("%s: MODULE ID: %d", __func__, cmd->module_id);
7087 WMI_LOGI("%s: TOKEN: %d", __func__, cmd->diag_token);
Govind Singhb53420c2016-03-09 14:32:57 +05307088 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Shaakir Mohamed66ebeca2018-01-19 15:49:23 -08007089 for (i = 0; (i < wmi_utest->num_args && i < WMI_UNIT_TEST_MAX_NUM_ARGS); i++) {
Govind Singha4836fd2016-03-07 16:45:38 +05307090 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +05307091 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +05307092 }
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307093 wmi_mtrace(WMI_UNIT_TEST_CMDID, cmd->vdev_id, 0);
Govind Singha4836fd2016-03-07 16:45:38 +05307094 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7095 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307096 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307097 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307098 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +05307099 }
7100
Govind Singhb53420c2016-03-09 14:32:57 +05307101 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +05307102}
7103
7104/**
Govind Singhbca3b1b2016-05-02 17:59:24 +05307105 * send_power_dbg_cmd_tlv() - send power debug commands
7106 * @wmi_handle: wmi handle
7107 * @param: wmi power debug parameter
7108 *
7109 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
7110 *
7111 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
7112 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07007113static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
7114 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +05307115{
7116 wmi_buf_t buf = NULL;
7117 QDF_STATUS status;
7118 int len, args_tlv_len;
7119 uint8_t *buf_ptr;
7120 uint8_t i;
7121 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
7122 uint32_t *cmd_args;
7123
7124 /* Prepare and send power debug cmd parameters */
7125 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
7126 len = sizeof(*cmd) + args_tlv_len;
7127 buf = wmi_buf_alloc(wmi_handle, len);
7128 if (!buf) {
7129 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7130 return QDF_STATUS_E_NOMEM;
7131 }
7132
7133 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7134 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
7135 WMITLV_SET_HDR(&cmd->tlv_header,
7136 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
7137 WMITLV_GET_STRUCT_TLVLEN
7138 (wmi_pdev_wal_power_debug_cmd_fixed_param));
7139
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05307140 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
7141 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +05307142 cmd->module_id = param->module_id;
7143 cmd->num_args = param->num_args;
7144 buf_ptr += sizeof(*cmd);
7145 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7146 (param->num_args * sizeof(uint32_t)));
7147 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
7148 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -08007149 for (i = 0; (i < param->num_args && i < WMI_MAX_POWER_DBG_ARGS); i++) {
Govind Singhbca3b1b2016-05-02 17:59:24 +05307150 cmd_args[i] = param->args[i];
7151 WMI_LOGI("%d,", param->args[i]);
7152 }
7153
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307154 wmi_mtrace(WMI_PDEV_WAL_POWER_DEBUG_CMDID, NO_SESSION, 0);
Govind Singhbca3b1b2016-05-02 17:59:24 +05307155 status = wmi_unified_cmd_send(wmi_handle, buf,
7156 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
7157 if (QDF_IS_STATUS_ERROR(status)) {
7158 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
7159 status);
7160 goto error;
7161 }
7162
7163 return QDF_STATUS_SUCCESS;
7164error:
7165 wmi_buf_free(buf);
7166
7167 return status;
7168}
7169
Govind Singhe7f2f342016-05-23 12:12:52 +05307170/**
Arif Hussainf00be1d2017-01-07 18:21:55 -08007171 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
7172 * @wmi_handle: wmi handle
7173 * @pdev_id: pdev id
7174 *
7175 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
7176 *
7177 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
7178 */
7179static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
7180 uint32_t pdev_id)
7181{
7182 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
7183 wmi_buf_t buf;
7184 uint16_t len;
7185 QDF_STATUS ret;
7186
7187 len = sizeof(*cmd);
7188 buf = wmi_buf_alloc(wmi_handle, len);
7189
7190 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
7191
7192 if (!buf) {
7193 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7194 return QDF_STATUS_E_NOMEM;
7195 }
7196
7197 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
7198 wmi_buf_data(buf);
7199
7200 WMITLV_SET_HDR(&cmd->tlv_header,
7201 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
7202 WMITLV_GET_STRUCT_TLVLEN(
7203 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
7204
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05307205 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307206 wmi_mtrace(WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID, NO_SESSION, 0);
Arif Hussainf00be1d2017-01-07 18:21:55 -08007207 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7208 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
7209 if (QDF_IS_STATUS_ERROR(ret)) {
7210 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
7211 __func__, ret, pdev_id);
7212 wmi_buf_free(buf);
7213 return QDF_STATUS_E_FAILURE;
7214 }
7215
7216 return QDF_STATUS_SUCCESS;
7217}
7218
7219/**
7220 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
7221 * @wmi_handle: wmi handle
7222 * @pdev_id: pdev id
7223 *
7224 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
7225 *
7226 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
7227 */
7228static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
7229 uint32_t pdev_id)
7230{
7231 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
7232 wmi_buf_t buf;
7233 uint16_t len;
7234 QDF_STATUS ret;
7235
7236 len = sizeof(*cmd);
7237 buf = wmi_buf_alloc(wmi_handle, len);
7238
7239 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
7240
7241 if (!buf) {
7242 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7243 return QDF_STATUS_E_NOMEM;
7244 }
7245
7246 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
7247 wmi_buf_data(buf);
7248
7249 WMITLV_SET_HDR(&cmd->tlv_header,
7250 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
7251 WMITLV_GET_STRUCT_TLVLEN(
7252 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
7253
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05307254 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307255 wmi_mtrace(WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID, NO_SESSION, 0);
Arif Hussainf00be1d2017-01-07 18:21:55 -08007256 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7257 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
7258 if (QDF_IS_STATUS_ERROR(ret)) {
7259 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
7260 __func__, ret, pdev_id);
7261 wmi_buf_free(buf);
7262 return QDF_STATUS_E_FAILURE;
7263 }
7264
7265 return QDF_STATUS_SUCCESS;
7266}
7267
7268/**
Govind Singhe7f2f342016-05-23 12:12:52 +05307269 * init_cmd_send_tlv() - send initialization cmd to fw
7270 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +05307271 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +05307272 *
7273 * Return: QDF_STATUS_SUCCESS for success or error code
7274 */
7275static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +05307276 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +05307277{
7278 wmi_buf_t buf;
7279 wmi_init_cmd_fixed_param *cmd;
Govind Singhe7f2f342016-05-23 12:12:52 +05307280 uint8_t *buf_ptr;
7281 wmi_resource_config *resource_cfg;
7282 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +05307283 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +05307284 uint16_t idx;
7285 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307286 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +05307287
Kiran Venkatappa26117052016-12-23 19:58:54 +05307288 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
7289 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +05307290 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +05307291
7292 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
7293 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
7294 WMI_TLV_HDR_SIZE +
7295 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
7296
7297 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +05307298 if (!buf) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05307299 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +05307300 return QDF_STATUS_E_FAILURE;
7301 }
7302
7303 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7304 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
7305 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
7306
7307 host_mem_chunks = (wlan_host_memory_chunk *)
7308 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
7309 + WMI_TLV_HDR_SIZE);
7310
7311 WMITLV_SET_HDR(&cmd->tlv_header,
7312 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
7313 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
7314
Kiran Venkatappa26117052016-12-23 19:58:54 +05307315 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +05307316 WMITLV_SET_HDR(&resource_cfg->tlv_header,
7317 WMITLV_TAG_STRUC_wmi_resource_config,
7318 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
7319
Kiran Venkatappa26117052016-12-23 19:58:54 +05307320 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +05307321 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
7322 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
7323 WMITLV_GET_STRUCT_TLVLEN
7324 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +05307325 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
7326 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
7327 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +05307328 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
7329 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +05307330 idx, host_mem_chunks[idx].size,
7331 host_mem_chunks[idx].ptr);
7332 }
Kiran Venkatappa26117052016-12-23 19:58:54 +05307333 cmd->num_host_mem_chunks = param->num_mem_chunks;
7334 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
7335
Govind Singhe7f2f342016-05-23 12:12:52 +05307336 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
7337 WMITLV_TAG_ARRAY_STRUC,
7338 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +05307339 param->num_mem_chunks));
7340
7341 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05307342 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +05307343
Kiran Venkatappa22a02982017-10-11 22:56:45 +05307344 /* Fill fw_abi_vers */
7345 copy_fw_abi_version_tlv(wmi_handle, cmd);
Govind Singhe7f2f342016-05-23 12:12:52 +05307346
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307347 wmi_mtrace(WMI_INIT_CMDID, NO_SESSION, 0);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307348 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
7349 if (QDF_IS_STATUS_ERROR(ret)) {
7350 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
7351 ret);
7352 wmi_buf_free(buf);
7353 }
Kiran Venkatappa22a02982017-10-11 22:56:45 +05307354
Abhishek Singh716c46c2016-05-04 16:24:07 +05307355 return ret;
7356
Govind Singhe7f2f342016-05-23 12:12:52 +05307357}
7358
7359/**
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -08007360 * send_addba_send_cmd_tlv() - send addba send command to fw
7361 * @wmi_handle: wmi handle
7362 * @param: pointer to delba send params
7363 * @macaddr: peer mac address
7364 *
7365 * Send WMI_ADDBA_SEND_CMDID command to firmware
7366 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
7367 */
7368static QDF_STATUS
7369send_addba_send_cmd_tlv(wmi_unified_t wmi_handle,
7370 uint8_t macaddr[IEEE80211_ADDR_LEN],
7371 struct addba_send_params *param)
7372{
7373 wmi_addba_send_cmd_fixed_param *cmd;
7374 wmi_buf_t buf;
7375 uint16_t len;
7376 QDF_STATUS ret;
7377
7378 len = sizeof(*cmd);
7379
7380 buf = wmi_buf_alloc(wmi_handle, len);
7381 if (!buf) {
7382 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7383 return QDF_STATUS_E_NOMEM;
7384 }
7385
7386 cmd = (wmi_addba_send_cmd_fixed_param *)wmi_buf_data(buf);
7387
7388 WMITLV_SET_HDR(&cmd->tlv_header,
7389 WMITLV_TAG_STRUC_wmi_addba_send_cmd_fixed_param,
7390 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_send_cmd_fixed_param));
7391
7392 cmd->vdev_id = param->vdev_id;
7393 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
7394 cmd->tid = param->tidno;
7395 cmd->buffersize = param->buffersize;
7396
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307397 wmi_mtrace(WMI_ADDBA_SEND_CMDID, cmd->vdev_id, 0);
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -08007398 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
7399 if (QDF_IS_STATUS_ERROR(ret)) {
7400 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
7401 wmi_buf_free(buf);
7402 return QDF_STATUS_E_FAILURE;
7403 }
7404
7405 return QDF_STATUS_SUCCESS;
7406}
7407
7408/**
7409 * send_delba_send_cmd_tlv() - send delba send command to fw
7410 * @wmi_handle: wmi handle
7411 * @param: pointer to delba send params
7412 * @macaddr: peer mac address
7413 *
7414 * Send WMI_DELBA_SEND_CMDID command to firmware
7415 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
7416 */
7417static QDF_STATUS
7418send_delba_send_cmd_tlv(wmi_unified_t wmi_handle,
7419 uint8_t macaddr[IEEE80211_ADDR_LEN],
7420 struct delba_send_params *param)
7421{
7422 wmi_delba_send_cmd_fixed_param *cmd;
7423 wmi_buf_t buf;
7424 uint16_t len;
7425 QDF_STATUS ret;
7426
7427 len = sizeof(*cmd);
7428
7429 buf = wmi_buf_alloc(wmi_handle, len);
7430 if (!buf) {
7431 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7432 return QDF_STATUS_E_NOMEM;
7433 }
7434
7435 cmd = (wmi_delba_send_cmd_fixed_param *)wmi_buf_data(buf);
7436
7437 WMITLV_SET_HDR(&cmd->tlv_header,
7438 WMITLV_TAG_STRUC_wmi_delba_send_cmd_fixed_param,
7439 WMITLV_GET_STRUCT_TLVLEN(wmi_delba_send_cmd_fixed_param));
7440
7441 cmd->vdev_id = param->vdev_id;
7442 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
7443 cmd->tid = param->tidno;
7444 cmd->initiator = param->initiator;
7445 cmd->reasoncode = param->reasoncode;
7446
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307447 wmi_mtrace(WMI_DELBA_SEND_CMDID, cmd->vdev_id, 0);
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -08007448 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
7449 if (QDF_IS_STATUS_ERROR(ret)) {
7450 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
7451 wmi_buf_free(buf);
7452 return QDF_STATUS_E_FAILURE;
7453 }
7454
7455 return QDF_STATUS_SUCCESS;
7456}
7457
7458/**
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -08007459 * send_addba_clearresponse_cmd_tlv() - send addba clear response command
7460 * to fw
7461 * @wmi_handle: wmi handle
7462 * @param: pointer to addba clearresp params
7463 * @macaddr: peer mac address
7464 * Return: 0 for success or error code
7465 */
7466static QDF_STATUS
7467send_addba_clearresponse_cmd_tlv(wmi_unified_t wmi_handle,
7468 uint8_t macaddr[IEEE80211_ADDR_LEN],
7469 struct addba_clearresponse_params *param)
7470{
7471 wmi_addba_clear_resp_cmd_fixed_param *cmd;
7472 wmi_buf_t buf;
7473 uint16_t len;
7474 QDF_STATUS ret;
7475
7476 len = sizeof(*cmd);
7477
7478 buf = wmi_buf_alloc(wmi_handle, len);
7479 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05307480 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -08007481 return QDF_STATUS_E_FAILURE;
7482 }
7483 cmd = (wmi_addba_clear_resp_cmd_fixed_param *)wmi_buf_data(buf);
7484
7485 WMITLV_SET_HDR(&cmd->tlv_header,
7486 WMITLV_TAG_STRUC_wmi_addba_clear_resp_cmd_fixed_param,
7487 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_clear_resp_cmd_fixed_param));
7488
7489 cmd->vdev_id = param->vdev_id;
7490 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
7491
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05307492 wmi_mtrace(WMI_ADDBA_CLEAR_RESP_CMDID, cmd->vdev_id, 0);
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -08007493 ret = wmi_unified_cmd_send(wmi_handle,
7494 buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
7495 if (QDF_IS_STATUS_ERROR(ret)) {
7496 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
7497 wmi_buf_free(buf);
7498 return QDF_STATUS_E_FAILURE;
7499 }
7500
7501 return QDF_STATUS_SUCCESS;
7502}
7503
Pratik Gandhi3fd97d62018-09-17 16:47:12 +05307504#ifdef OBSS_PD
7505/**
7506 * send_obss_spatial_reuse_set_cmd_tlv - send obss spatial reuse set cmd to fw
7507 * @wmi_handle: wmi handle
7508 * @obss_spatial_reuse_param: pointer to obss_spatial_reuse_param
7509 *
7510 * Return: QDF_STATUS_SUCCESS for success or error code
7511 */
7512static
7513QDF_STATUS send_obss_spatial_reuse_set_cmd_tlv(wmi_unified_t wmi_handle,
7514 struct wmi_host_obss_spatial_reuse_set_param
7515 *obss_spatial_reuse_param)
7516{
7517 wmi_buf_t buf;
7518 wmi_obss_spatial_reuse_set_cmd_fixed_param *cmd;
7519 QDF_STATUS ret;
7520 uint32_t len;
7521
7522 len = sizeof(*cmd);
7523
7524 buf = wmi_buf_alloc(wmi_handle, len);
7525 if (!buf) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05307526 qdf_print("%s: wmi_buf_alloc failed", __func__);
Pratik Gandhi3fd97d62018-09-17 16:47:12 +05307527 return QDF_STATUS_E_FAILURE;
7528 }
7529
7530 cmd = (wmi_obss_spatial_reuse_set_cmd_fixed_param *)wmi_buf_data(buf);
7531 WMITLV_SET_HDR(&cmd->tlv_header,
7532 WMITLV_TAG_STRUC_wmi_obss_spatial_reuse_set_cmd_fixed_param,
7533 WMITLV_GET_STRUCT_TLVLEN
7534 (wmi_obss_spatial_reuse_set_cmd_fixed_param));
7535
7536 cmd->enable = obss_spatial_reuse_param->enable;
7537 cmd->obss_min = obss_spatial_reuse_param->obss_min;
7538 cmd->obss_max = obss_spatial_reuse_param->obss_max;
7539 cmd->vdev_id = obss_spatial_reuse_param->vdev_id;
7540
7541 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7542 WMI_PDEV_OBSS_PD_SPATIAL_REUSE_CMDID);
7543
7544 if (QDF_IS_STATUS_ERROR(ret)) {
7545 WMI_LOGE(
7546 "WMI_PDEV_OBSS_PD_SPATIAL_REUSE_CMDID send returned Error %d",
7547 ret);
7548 wmi_buf_free(buf);
7549 }
7550
7551 return ret;
7552}
7553#endif
7554
Naveen Rawat963ee942018-04-13 16:38:36 -07007555#ifdef QCA_SUPPORT_CP_STATS
7556/**
7557 * extract_cca_stats_tlv - api to extract congestion stats from event buffer
7558 * @wmi_handle: wma handle
7559 * @evt_buf: event buffer
7560 * @out_buff: buffer to populated after stats extraction
7561 *
7562 * Return: status of operation
7563 */
7564static QDF_STATUS extract_cca_stats_tlv(wmi_unified_t wmi_handle,
7565 void *evt_buf, struct wmi_host_congestion_stats *out_buff)
7566{
7567 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
7568 wmi_congestion_stats *congestion_stats;
7569
7570 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *)evt_buf;
7571 congestion_stats = param_buf->congestion_stats;
7572 if (!congestion_stats) {
7573 WMI_LOGD("%s: no cca stats in event buffer", __func__);
7574 return QDF_STATUS_E_INVAL;
7575 }
7576
7577 out_buff->vdev_id = congestion_stats->vdev_id;
7578 out_buff->congestion = congestion_stats->congestion;
7579
7580 WMI_LOGD("%s: cca stats event processed", __func__);
7581 return QDF_STATUS_SUCCESS;
7582}
7583#endif /* QCA_SUPPORT_CP_STATS */
7584
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +05307585/**
Alok Singh0243e7d2018-09-20 16:07:28 +05307586 * extract_ctl_failsafe_check_ev_param_tlv() - extract ctl data from
7587 * event
7588 * @wmi_handle: wmi handle
7589 * @param evt_buf: pointer to event buffer
7590 * @param param: Pointer to hold peer ctl data
7591 *
7592 * Return: QDF_STATUS_SUCCESS for success or error code
7593 */
7594static QDF_STATUS extract_ctl_failsafe_check_ev_param_tlv(
7595 wmi_unified_t wmi_handle,
7596 void *evt_buf,
7597 struct wmi_host_pdev_ctl_failsafe_event *param)
7598{
7599 WMI_PDEV_CTL_FAILSAFE_CHECK_EVENTID_param_tlvs *param_buf;
7600 wmi_pdev_ctl_failsafe_check_fixed_param *fix_param;
7601
7602 param_buf = (WMI_PDEV_CTL_FAILSAFE_CHECK_EVENTID_param_tlvs *)evt_buf;
7603 if (!param_buf) {
7604 WMI_LOGE("Invalid ctl_failsafe event buffer");
7605 return QDF_STATUS_E_INVAL;
7606 }
7607
7608 fix_param = param_buf->fixed_param;
7609 param->ctl_failsafe_status = fix_param->ctl_FailsafeStatus;
7610
7611 return QDF_STATUS_SUCCESS;
7612}
7613
7614/**
Govind Singhe7f2f342016-05-23 12:12:52 +05307615 * save_service_bitmap_tlv() - save service bitmap
7616 * @wmi_handle: wmi handle
7617 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -08007618 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +05307619 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307620 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +05307621 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07007622static
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307623QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -08007624 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +05307625{
7626 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307627 struct wmi_soc *soc = wmi_handle->soc;
7628
Govind Singhe7f2f342016-05-23 12:12:52 +05307629 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
7630
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307631 /* If it is already allocated, use that buffer. This can happen
7632 * during target stop/start scenarios where host allocation is skipped.
7633 */
7634 if (!soc->wmi_service_bitmap) {
7635 soc->wmi_service_bitmap =
7636 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
7637 if (!soc->wmi_service_bitmap) {
7638 WMI_LOGE("Failed memory allocation for service bitmap");
7639 return QDF_STATUS_E_NOMEM;
7640 }
7641 }
7642
7643 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +05307644 param_buf->wmi_service_bitmap,
7645 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -08007646
7647 if (bitmap_buf)
7648 qdf_mem_copy(bitmap_buf,
7649 param_buf->wmi_service_bitmap,
7650 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307651
7652 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +05307653}
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307654
7655/**
7656 * save_ext_service_bitmap_tlv() - save extendend service bitmap
7657 * @wmi_handle: wmi handle
7658 * @param evt_buf: pointer to event buffer
7659 * @param bitmap_buf: bitmap buffer, for converged legacy support
7660 *
7661 * Return: QDF_STATUS
7662 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07007663static
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307664QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -08007665 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +05307666{
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307667 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
7668 wmi_service_available_event_fixed_param *ev;
7669 struct wmi_soc *soc = wmi_handle->soc;
7670
7671 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
7672
7673 ev = param_buf->fixed_param;
7674
7675 /* If it is already allocated, use that buffer. This can happen
7676 * during target stop/start scenarios where host allocation is skipped.
7677 */
7678 if (!soc->wmi_ext_service_bitmap) {
7679 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
7680 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
7681 if (!soc->wmi_ext_service_bitmap) {
7682 WMI_LOGE("Failed memory allocation for service bitmap");
7683 return QDF_STATUS_E_NOMEM;
7684 }
7685 }
7686
7687 qdf_mem_copy(soc->wmi_ext_service_bitmap,
7688 ev->wmi_service_segment_bitmap,
7689 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +05307690
Sathish Kumarefb25bf2018-10-02 11:03:59 +05307691 WMI_LOGD("wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x",
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +05307692 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
7693 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
7694
Rajeev Kumar77901472017-02-12 02:12:17 -08007695 if (bitmap_buf)
7696 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307697 soc->wmi_ext_service_bitmap,
7698 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +05307699
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307700 return QDF_STATUS_SUCCESS;
7701}
Govind Singhe7f2f342016-05-23 12:12:52 +05307702/**
7703 * is_service_enabled_tlv() - Check if service enabled
7704 * @param wmi_handle: wmi handle
7705 * @param service_id: service identifier
7706 *
7707 * Return: 1 enabled, 0 disabled
7708 */
Govind Singhe7f2f342016-05-23 12:12:52 +05307709static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
7710 uint32_t service_id)
7711{
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307712 struct wmi_soc *soc = wmi_handle->soc;
7713
7714 if (!soc->wmi_service_bitmap) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05307715 WMI_LOGE("WMI service bit map is not saved yet");
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307716 return false;
7717 }
7718
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +05307719 /* if wmi_service_enabled was received with extended bitmap,
7720 * use WMI_SERVICE_EXT_IS_ENABLED to check the services.
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307721 */
7722 if (soc->wmi_ext_service_bitmap)
7723 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
7724 soc->wmi_ext_service_bitmap,
7725 service_id);
7726
Zhu Jianmin3ed26de2018-04-19 17:55:30 +08007727 if (service_id >= WMI_MAX_SERVICE) {
7728 WMI_LOGE("Service id %d but WMI ext service bitmap is NULL",
7729 service_id);
7730 return false;
7731 }
7732
Kiran Venkatappa7d739142017-09-01 17:02:34 +05307733 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
7734 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +05307735}
Govind Singhe7f2f342016-05-23 12:12:52 +05307736
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +05307737static inline void copy_ht_cap_info(uint32_t ev_target_cap,
7738 struct wlan_psoc_target_capability_info *cap)
7739{
7740 /* except LDPC all flags are common betwen legacy and here
7741 * also IBFEER is not defined for TLV
7742 */
7743 cap->ht_cap_info |= ev_target_cap & (
7744 WMI_HT_CAP_ENABLED
7745 | WMI_HT_CAP_HT20_SGI
7746 | WMI_HT_CAP_DYNAMIC_SMPS
7747 | WMI_HT_CAP_TX_STBC
7748 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
7749 | WMI_HT_CAP_RX_STBC
7750 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
7751 | WMI_HT_CAP_LDPC
7752 | WMI_HT_CAP_L_SIG_TXOP_PROT
7753 | WMI_HT_CAP_MPDU_DENSITY
7754 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
7755 | WMI_HT_CAP_HT40_SGI);
7756 if (ev_target_cap & WMI_HT_CAP_LDPC)
7757 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
7758 WMI_HOST_HT_CAP_TX_LDPC;
7759}
Govind Singhe7f2f342016-05-23 12:12:52 +05307760/**
7761 * extract_service_ready_tlv() - extract service ready event
7762 * @wmi_handle: wmi handle
7763 * @param evt_buf: pointer to received event buffer
7764 * @param cap: pointer to hold target capability information extracted from even
7765 *
7766 * Return: QDF_STATUS_SUCCESS for success or error code
7767 */
7768static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -08007769 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +05307770{
7771 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
7772 wmi_service_ready_event_fixed_param *ev;
7773
7774
7775 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
7776
7777 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
7778 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05307779 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +05307780 return QDF_STATUS_E_FAILURE;
7781 }
7782
7783 cap->phy_capability = ev->phy_capability;
7784 cap->max_frag_entry = ev->max_frag_entry;
7785 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +05307786 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +05307787 cap->vht_cap_info = ev->vht_cap_info;
7788 cap->vht_supp_mcs = ev->vht_supp_mcs;
7789 cap->hw_min_tx_power = ev->hw_min_tx_power;
7790 cap->hw_max_tx_power = ev->hw_max_tx_power;
7791 cap->sys_cap_info = ev->sys_cap_info;
7792 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
7793 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
7794 cap->max_num_scan_channels = ev->max_num_scan_channels;
7795 cap->max_supported_macs = ev->max_supported_macs;
7796 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
7797 cap->txrx_chainmask = ev->txrx_chainmask;
7798 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
7799 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +05307800 cap->fw_version = ev->fw_build_vers;
7801 /* fw_version_1 is not available in TLV. */
7802 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +05307803
7804 return QDF_STATUS_SUCCESS;
7805}
7806
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +05307807/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
Sathish Kumarefb25bf2018-10-02 11:03:59 +05307808 * to host internal WMI_HOST_REGDMN_MODE values.
7809 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
7810 * host currently. Add this in the future if required.
7811 * 11AX (Phase II) : 11ax related values are not currently
7812 * advertised separately by FW. As part of phase II regulatory bring-up,
7813 * finalize the advertisement mechanism.
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +05307814 * @target_wireless_mode: target wireless mode received in message
7815 *
7816 * Return: returns the host internal wireless mode.
7817 */
7818static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
7819{
7820
7821 uint32_t wireless_modes = 0;
7822
7823 if (target_wireless_mode & REGDMN_MODE_11A)
7824 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
7825
7826 if (target_wireless_mode & REGDMN_MODE_TURBO)
7827 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
7828
7829 if (target_wireless_mode & REGDMN_MODE_11B)
7830 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
7831
7832 if (target_wireless_mode & REGDMN_MODE_PUREG)
7833 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
7834
7835 if (target_wireless_mode & REGDMN_MODE_11G)
7836 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
7837
7838 if (target_wireless_mode & REGDMN_MODE_108G)
7839 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
7840
7841 if (target_wireless_mode & REGDMN_MODE_108A)
7842 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
7843
7844 if (target_wireless_mode & REGDMN_MODE_XR)
7845 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
7846
7847 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
7848 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
7849
7850 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
7851 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
7852
7853 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
7854 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
7855
7856 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
7857 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
7858
7859 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
7860 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
7861
7862 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
7863 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
7864
7865 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
7866 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
7867
7868 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
7869 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
7870
7871 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
7872 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
7873
7874 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
7875 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
7876
7877 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
7878 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
7879
7880 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
7881 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
7882
7883 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
7884 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
7885
7886 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
7887 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
7888
7889 return wireless_modes;
7890}
7891
Govind Singhe7f2f342016-05-23 12:12:52 +05307892/**
7893 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
7894 * @wmi_handle: wmi handle
7895 * @param evt_buf: Pointer to event buffer
7896 * @param cap: pointer to hold HAL reg capabilities
7897 *
7898 * Return: QDF_STATUS_SUCCESS for success or error code
7899 */
7900static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -08007901 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +05307902{
7903 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
7904
7905 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
7906
7907 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
7908 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -08007909 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +05307910
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +05307911 cap->wireless_modes = convert_wireless_modes_tlv(
7912 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +05307913
Govind Singhe7f2f342016-05-23 12:12:52 +05307914 return QDF_STATUS_SUCCESS;
7915}
7916
7917/**
7918 * extract_host_mem_req_tlv() - Extract host memory request event
7919 * @wmi_handle: wmi handle
7920 * @param evt_buf: pointer to event buffer
7921 * @param num_entries: pointer to hold number of entries requested
7922 *
7923 * Return: Number of entries requested
7924 */
7925static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
7926 void *evt_buf, uint8_t *num_entries)
7927{
7928 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
7929 wmi_service_ready_event_fixed_param *ev;
7930
7931 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
7932
7933 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
7934 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05307935 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +05307936 return NULL;
7937 }
7938
7939 *num_entries = ev->num_mem_reqs;
7940
7941 return (host_mem_req *)param_buf->mem_reqs;
7942}
7943
7944/**
7945 * save_fw_version_in_service_ready_tlv() - Save fw version in service
7946 * ready function
7947 * @wmi_handle: wmi handle
7948 * @param evt_buf: pointer to event buffer
7949 *
7950 * Return: QDF_STATUS_SUCCESS for success or error code
7951 */
7952static QDF_STATUS
7953save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
7954{
7955 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
7956 wmi_service_ready_event_fixed_param *ev;
7957
7958
7959 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
7960
7961 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
7962 if (!ev) {
Aditya Sathish45d7ada2018-07-02 17:31:55 +05307963 qdf_print("%s: wmi_buf_alloc failed", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +05307964 return QDF_STATUS_E_FAILURE;
7965 }
7966
7967 /*Save fw version from service ready message */
7968 /*This will be used while sending INIT message */
7969 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
7970 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +05307971
Govind Singhe7f2f342016-05-23 12:12:52 +05307972 return QDF_STATUS_SUCCESS;
7973}
7974
7975/**
7976 * ready_extract_init_status_tlv() - Extract init status from ready event
7977 * @wmi_handle: wmi handle
7978 * @param evt_buf: Pointer to event buffer
7979 *
7980 * Return: ready status
7981 */
7982static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
7983 void *evt_buf)
7984{
7985 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
7986 wmi_ready_event_fixed_param *ev = NULL;
7987
Govind Singhe7f2f342016-05-23 12:12:52 +05307988 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
7989 ev = param_buf->fixed_param;
7990
Aditya Sathish45d7ada2018-07-02 17:31:55 +05307991 qdf_print("%s:%d", __func__, ev->status);
Govind Singhe7f2f342016-05-23 12:12:52 +05307992
7993 return ev->status;
7994}
7995
7996/**
7997 * ready_extract_mac_addr_tlv() - extract mac address from ready event
7998 * @wmi_handle: wmi handle
7999 * @param evt_buf: pointer to event buffer
8000 * @param macaddr: Pointer to hold MAC address
8001 *
8002 * Return: QDF_STATUS_SUCCESS for success or error code
8003 */
8004static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
8005 void *evt_buf, uint8_t *macaddr)
8006{
8007 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
8008 wmi_ready_event_fixed_param *ev = NULL;
8009
8010
8011 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
8012 ev = param_buf->fixed_param;
8013
8014 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
8015
8016 return QDF_STATUS_SUCCESS;
8017}
8018
8019/**
Manoj Ekbotedd273902017-07-09 23:28:56 -07008020 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
8021 * @wmi_handle: wmi handle
8022 * @param evt_buf: pointer to event buffer
8023 * @param macaddr: Pointer to hold number of MAC addresses
8024 *
8025 * Return: Pointer to addr list
8026 */
8027static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
8028 void *evt_buf, uint8_t *num_mac)
8029{
8030 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
8031 wmi_ready_event_fixed_param *ev = NULL;
8032
8033 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
8034 ev = param_buf->fixed_param;
8035
8036 *num_mac = ev->num_extra_mac_addr;
8037
8038 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
8039}
8040
8041/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +05308042 * extract_ready_params_tlv() - Extract data from ready event apart from
Sathish Kumarefb25bf2018-10-02 11:03:59 +05308043 * status, macaddr and version.
Kiran Venkatappa094c24f2017-11-10 20:50:12 +05308044 * @wmi_handle: Pointer to WMI handle.
8045 * @evt_buf: Pointer to Ready event buffer.
8046 * @ev_param: Pointer to host defined struct to copy the data from event.
8047 *
8048 * Return: QDF_STATUS_SUCCESS on success.
8049 */
8050static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
8051 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
8052{
8053 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
8054 wmi_ready_event_fixed_param *ev = NULL;
8055
8056 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
8057 ev = param_buf->fixed_param;
8058
Kiran Venkatappab458a1c2017-11-28 12:23:24 +05308059 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +05308060 ev_param->num_dscp_table = ev->num_dscp_table;
8061 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
8062 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +05308063 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +05308064 /* Agile_cap in ready event is not supported in TLV target */
8065 ev_param->agile_capability = false;
8066
8067 return QDF_STATUS_SUCCESS;
8068}
8069
8070/**
Govind Singhe7f2f342016-05-23 12:12:52 +05308071 * extract_dbglog_data_len_tlv() - extract debuglog data length
8072 * @wmi_handle: wmi handle
8073 * @param evt_buf: pointer to event buffer
8074 *
8075 * Return: length
8076 */
8077static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -08008078 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +05308079{
8080 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
8081
8082 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
8083
8084 *len = param_buf->num_bufp;
8085
8086 return param_buf->bufp;
8087}
8088
Govind Singhe7f2f342016-05-23 12:12:52 +05308089
Jinwei Chenb69924c2018-08-20 11:31:31 +08008090#ifdef CONFIG_MCL
8091#define IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(_status) \
8092 ((_status) & WMI_RXERR_DECRYPT)
8093#else
8094#define IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(_status) false
8095#endif
8096
Govind Singhe7f2f342016-05-23 12:12:52 +05308097/**
8098 * extract_mgmt_rx_params_tlv() - extract management rx params from event
8099 * @wmi_handle: wmi handle
8100 * @param evt_buf: pointer to event buffer
8101 * @param hdr: Pointer to hold header
8102 * @param bufp: Pointer to hold pointer to rx param buffer
8103 *
8104 * Return: QDF_STATUS_SUCCESS for success or error code
8105 */
8106static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +05308107 void *evt_buf, struct mgmt_rx_event_params *hdr,
8108 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +05308109{
8110 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
8111 wmi_mgmt_rx_hdr *ev_hdr = NULL;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +05308112 int i;
Govind Singhe7f2f342016-05-23 12:12:52 +05308113
8114 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
8115 if (!param_tlvs) {
8116 WMI_LOGE("Get NULL point message from FW");
8117 return QDF_STATUS_E_INVAL;
8118 }
8119
8120 ev_hdr = param_tlvs->hdr;
8121 if (!hdr) {
8122 WMI_LOGE("Rx event is NULL");
8123 return QDF_STATUS_E_INVAL;
8124 }
8125
Jinwei Chenb69924c2018-08-20 11:31:31 +08008126 if (IS_WMI_RX_MGMT_FRAME_STATUS_INVALID(ev_hdr->status)) {
8127 WMI_LOGE("%s: RX mgmt frame decrypt error, discard it",
8128 __func__);
8129 return QDF_STATUS_E_INVAL;
8130 }
8131
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308132 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
8133 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +05308134
8135 hdr->channel = ev_hdr->channel;
8136 hdr->snr = ev_hdr->snr;
8137 hdr->rate = ev_hdr->rate;
8138 hdr->phy_mode = ev_hdr->phy_mode;
8139 hdr->buf_len = ev_hdr->buf_len;
8140 hdr->status = ev_hdr->status;
8141 hdr->flags = ev_hdr->flags;
8142 hdr->rssi = ev_hdr->rssi;
8143 hdr->tsf_delta = ev_hdr->tsf_delta;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +05308144 for (i = 0; i < ATH_MAX_ANTENNA; i++)
8145 hdr->rssi_ctl[i] = ev_hdr->rssi_ctl[i];
Govind Singhe7f2f342016-05-23 12:12:52 +05308146
8147 *bufp = param_tlvs->bufp;
8148
8149 return QDF_STATUS_SUCCESS;
8150}
8151
8152/**
Govind Singhe7f2f342016-05-23 12:12:52 +05308153 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
8154 * @wmi_handle: wmi handle
8155 * @param evt_buf: pointer to event buffer
8156 * @param param: Pointer to hold roam param
8157 *
8158 * Return: QDF_STATUS_SUCCESS for success or error code
8159 */
8160static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
8161 void *evt_buf, wmi_host_roam_event *param)
8162{
8163 WMI_ROAM_EVENTID_param_tlvs *param_buf;
8164 wmi_roam_event_fixed_param *evt;
8165
8166 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
8167 if (!param_buf) {
8168 WMI_LOGE("Invalid roam event buffer");
8169 return QDF_STATUS_E_INVAL;
8170 }
8171
8172 evt = param_buf->fixed_param;
8173 qdf_mem_zero(param, sizeof(*param));
8174
8175 param->vdev_id = evt->vdev_id;
8176 param->reason = evt->reason;
8177 param->rssi = evt->rssi;
8178
8179 return QDF_STATUS_SUCCESS;
8180}
8181
8182/**
8183 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
8184 * @wmi_handle: wmi handle
8185 * @param evt_buf: pointer to event buffer
8186 * @param param: Pointer to hold vdev scan param
8187 *
8188 * Return: QDF_STATUS_SUCCESS for success or error code
8189 */
8190static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308191 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +05308192{
8193 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
8194 wmi_scan_event_fixed_param *evt = NULL;
8195
8196 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
8197 evt = param_buf->fixed_param;
8198
8199 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +05308200
Govind Singhe7f2f342016-05-23 12:12:52 +05308201 switch (evt->event) {
8202 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308203 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308204 break;
8205 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308206 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308207 break;
8208 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308209 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +05308210 break;
8211 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308212 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +05308213 break;
8214 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308215 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308216 break;
8217 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308218 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308219 break;
8220 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308221 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308222 break;
8223 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308224 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308225 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +05308226 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308227 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +05308228 break;
8229 case WMI_SCAN_EVENT_MAX:
8230 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308231 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +05308232 break;
8233 };
8234
8235 switch (evt->reason) {
8236 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308237 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +05308238 break;
8239 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308240 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308241 break;
8242 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308243 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308244 break;
8245 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308246 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +05308247 break;
8248 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308249 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +05308250 break;
8251 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308252 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +05308253 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +05308254 case WMI_SCAN_REASON_SUSPENDED:
8255 param->reason = SCAN_REASON_SUSPENDED;
8256 break;
Abhijit Pradhanf6694f82018-10-17 10:13:15 +05308257 case WMI_SCAN_REASON_DFS_VIOLATION:
8258 param->reason = SCAN_REASON_DFS_VIOLATION;
8259 break;
Govind Singhe7f2f342016-05-23 12:12:52 +05308260 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +05308261 param->reason = SCAN_REASON_MAX;
8262 break;
Govind Singhe7f2f342016-05-23 12:12:52 +05308263 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308264 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +05308265 break;
8266 };
8267
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05308268 param->chan_freq = evt->channel_freq;
8269 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +05308270 param->scan_id = evt->scan_id;
8271 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +05308272 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +05308273
8274 return QDF_STATUS_SUCCESS;
8275}
8276
Govind Singhe7f2f342016-05-23 12:12:52 +05308277/**
Govind Singhe7f2f342016-05-23 12:12:52 +05308278 * extract_all_stats_counts_tlv() - extract all stats count from event
8279 * @wmi_handle: wmi handle
8280 * @param evt_buf: pointer to event buffer
8281 * @param stats_param: Pointer to hold stats count
8282 *
8283 * Return: QDF_STATUS_SUCCESS for success or error code
8284 */
8285static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
8286 void *evt_buf, wmi_host_stats_event *stats_param)
8287{
Govind Singhe7f2f342016-05-23 12:12:52 +05308288 wmi_stats_event_fixed_param *ev;
Naveen Rawat57e47aa2018-04-06 10:57:20 -07008289 wmi_per_chain_rssi_stats *rssi_event;
8290 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
Jianmin Zhuf1b8d512018-09-03 20:08:27 +08008291 uint64_t min_data_len;
Govind Singhe7f2f342016-05-23 12:12:52 +05308292
Naveen Rawat57e47aa2018-04-06 10:57:20 -07008293 qdf_mem_zero(stats_param, sizeof(*stats_param));
Govind Singhe7f2f342016-05-23 12:12:52 +05308294 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +05308295 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
Naveen Rawat57e47aa2018-04-06 10:57:20 -07008296 rssi_event = param_buf->chain_stats;
Govind Singhe7f2f342016-05-23 12:12:52 +05308297 if (!ev) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05308298 WMI_LOGE("%s: event fixed param NULL", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +05308299 return QDF_STATUS_E_FAILURE;
8300 }
8301
Jianmin Zhuf1b8d512018-09-03 20:08:27 +08008302 if (param_buf->num_data > WMI_SVC_MSG_MAX_SIZE - sizeof(*ev)) {
8303 WMI_LOGE("num_data : %u is invalid", param_buf->num_data);
8304 return QDF_STATUS_E_FAULT;
8305 }
8306
Govind Singhe7f2f342016-05-23 12:12:52 +05308307 switch (ev->stats_id) {
8308 case WMI_REQUEST_PEER_STAT:
8309 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
8310 break;
8311
8312 case WMI_REQUEST_AP_STAT:
8313 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
8314 break;
8315
8316 case WMI_REQUEST_PDEV_STAT:
8317 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
8318 break;
8319
8320 case WMI_REQUEST_VDEV_STAT:
8321 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
8322 break;
8323
8324 case WMI_REQUEST_BCNFLT_STAT:
8325 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
8326 break;
8327
8328 case WMI_REQUEST_VDEV_RATE_STAT:
8329 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
8330 break;
8331
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +05308332 case WMI_REQUEST_BCN_STAT:
8333 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
8334 break;
8335
Govind Singhe7f2f342016-05-23 12:12:52 +05308336 default:
8337 stats_param->stats_id = 0;
8338 break;
8339
8340 }
8341
Jianmin Zhuf1b8d512018-09-03 20:08:27 +08008342 /* ev->num_*_stats may cause uint32_t overflow, so use uint64_t
8343 * to save total length calculated
8344 */
8345 min_data_len =
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308346 (((uint64_t)ev->num_pdev_stats) * sizeof(wmi_pdev_stats_v2)) +
Jianmin Zhuf1b8d512018-09-03 20:08:27 +08008347 (((uint64_t)ev->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
8348 (((uint64_t)ev->num_peer_stats) * sizeof(wmi_peer_stats)) +
8349 (((uint64_t)ev->num_bcnflt_stats) *
8350 sizeof(wmi_bcnfilter_stats_t)) +
8351 (((uint64_t)ev->num_chan_stats) * sizeof(wmi_chan_stats)) +
8352 (((uint64_t)ev->num_mib_stats) * sizeof(wmi_mib_stats)) +
8353 (((uint64_t)ev->num_bcn_stats) * sizeof(wmi_bcn_stats)) +
8354 (((uint64_t)ev->num_peer_extd_stats) *
8355 sizeof(wmi_peer_extd_stats));
8356 if (param_buf->num_data != min_data_len) {
8357 WMI_LOGE("data len: %u isn't same as calculated: %llu",
8358 param_buf->num_data, min_data_len);
8359 return QDF_STATUS_E_FAULT;
8360 }
8361
Govind Singhe7f2f342016-05-23 12:12:52 +05308362 stats_param->num_pdev_stats = ev->num_pdev_stats;
8363 stats_param->num_pdev_ext_stats = 0;
8364 stats_param->num_vdev_stats = ev->num_vdev_stats;
8365 stats_param->num_peer_stats = ev->num_peer_stats;
8366 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
8367 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +05308368 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +05308369 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
8370 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +05308371
Naveen Rawat57e47aa2018-04-06 10:57:20 -07008372 /* if chain_stats is not populated */
8373 if (!param_buf->chain_stats || !param_buf->num_chain_stats)
8374 return QDF_STATUS_SUCCESS;
8375
8376 if (WMITLV_TAG_STRUC_wmi_per_chain_rssi_stats !=
8377 WMITLV_GET_TLVTAG(rssi_event->tlv_header))
8378 return QDF_STATUS_SUCCESS;
8379
8380 if (WMITLV_GET_STRUCT_TLVLEN(wmi_per_chain_rssi_stats) !=
Naveen Rawata8e19e72018-06-01 17:12:31 -07008381 WMITLV_GET_TLVLEN(rssi_event->tlv_header))
Naveen Rawat57e47aa2018-04-06 10:57:20 -07008382 return QDF_STATUS_SUCCESS;
8383
Harprit Chhabada4efe1fa2018-09-28 12:06:49 -07008384 if (rssi_event->num_per_chain_rssi_stats >=
8385 WMITLV_GET_TLVLEN(rssi_event->tlv_header)) {
8386 WMI_LOGE("num_per_chain_rssi_stats:%u is out of bounds",
8387 rssi_event->num_per_chain_rssi_stats);
8388 return QDF_STATUS_E_INVAL;
8389 }
Naveen Rawat57e47aa2018-04-06 10:57:20 -07008390 stats_param->num_rssi_stats = rssi_event->num_per_chain_rssi_stats;
8391
Govind Singhe7f2f342016-05-23 12:12:52 +05308392 return QDF_STATUS_SUCCESS;
8393}
8394
8395/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +05308396 * extract_pdev_tx_stats() - extract pdev tx stats from event
8397 */
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308398static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx,
8399 struct wlan_dbg_tx_stats_v2 *tx_stats)
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +05308400{
8401 /* Tx Stats */
8402 tx->comp_queued = tx_stats->comp_queued;
8403 tx->comp_delivered = tx_stats->comp_delivered;
8404 tx->msdu_enqued = tx_stats->msdu_enqued;
8405 tx->mpdu_enqued = tx_stats->mpdu_enqued;
8406 tx->wmm_drop = tx_stats->wmm_drop;
8407 tx->local_enqued = tx_stats->local_enqued;
8408 tx->local_freed = tx_stats->local_freed;
8409 tx->hw_queued = tx_stats->hw_queued;
8410 tx->hw_reaped = tx_stats->hw_reaped;
8411 tx->underrun = tx_stats->underrun;
8412 tx->tx_abort = tx_stats->tx_abort;
8413 tx->mpdus_requed = tx_stats->mpdus_requed;
8414 tx->data_rc = tx_stats->data_rc;
8415 tx->self_triggers = tx_stats->self_triggers;
8416 tx->sw_retry_failure = tx_stats->sw_retry_failure;
8417 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
8418 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
8419 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
8420 tx->pdev_resets = tx_stats->pdev_resets;
8421 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
8422 tx->phy_underrun = tx_stats->phy_underrun;
8423 tx->txop_ovf = tx_stats->txop_ovf;
8424
8425 return;
8426}
8427
8428
8429/**
8430 * extract_pdev_rx_stats() - extract pdev rx stats from event
8431 */
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308432static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx,
8433 struct wlan_dbg_rx_stats_v2 *rx_stats)
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +05308434{
8435 /* Rx Stats */
8436 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
8437 rx->status_rcvd = rx_stats->status_rcvd;
8438 rx->r0_frags = rx_stats->r0_frags;
8439 rx->r1_frags = rx_stats->r1_frags;
8440 rx->r2_frags = rx_stats->r2_frags;
8441 /* Only TLV */
8442 rx->r3_frags = 0;
8443 rx->htt_msdus = rx_stats->htt_msdus;
8444 rx->htt_mpdus = rx_stats->htt_mpdus;
8445 rx->loc_msdus = rx_stats->loc_msdus;
8446 rx->loc_mpdus = rx_stats->loc_mpdus;
8447 rx->oversize_amsdu = rx_stats->oversize_amsdu;
8448 rx->phy_errs = rx_stats->phy_errs;
8449 rx->phy_err_drop = rx_stats->phy_err_drop;
8450 rx->mpdu_errs = rx_stats->mpdu_errs;
8451
8452 return;
8453}
8454
8455/**
Govind Singhe7f2f342016-05-23 12:12:52 +05308456 * extract_pdev_stats_tlv() - extract pdev stats from event
8457 * @wmi_handle: wmi handle
8458 * @param evt_buf: pointer to event buffer
8459 * @param index: Index into pdev stats
8460 * @param pdev_stats: Pointer to hold pdev stats
8461 *
8462 * Return: QDF_STATUS_SUCCESS for success or error code
8463 */
8464static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
8465 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
8466{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +05308467 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
8468 wmi_stats_event_fixed_param *ev_param;
8469 uint8_t *data;
8470
8471 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
8472 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
8473
8474 data = param_buf->data;
8475
8476 if (index < ev_param->num_pdev_stats) {
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308477 wmi_pdev_stats_v2 *ev = (wmi_pdev_stats_v2 *) ((data) +
8478 (index * sizeof(wmi_pdev_stats_v2)));
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +05308479
8480 pdev_stats->chan_nf = ev->chan_nf;
8481 pdev_stats->tx_frame_count = ev->tx_frame_count;
8482 pdev_stats->rx_frame_count = ev->rx_frame_count;
8483 pdev_stats->rx_clear_count = ev->rx_clear_count;
8484 pdev_stats->cycle_count = ev->cycle_count;
8485 pdev_stats->phy_err_count = ev->phy_err_count;
8486 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
8487
8488 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
8489 &(ev->pdev_stats.tx));
8490 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
8491 &(ev->pdev_stats.rx));
8492 }
8493
Govind Singhe7f2f342016-05-23 12:12:52 +05308494 return QDF_STATUS_SUCCESS;
8495}
8496
8497/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -07008498 * extract_unit_test_tlv() - extract unit test data
8499 * @wmi_handle: wmi handle
8500 * @param evt_buf: pointer to event buffer
8501 * @param unit_test: pointer to hold unit test data
8502 * @param maxspace: Amount of space in evt_buf
8503 *
8504 * Return: QDF_STATUS_SUCCESS for success or error code
8505 */
8506static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
8507 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
8508{
8509 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
8510 wmi_unit_test_event_fixed_param *ev_param;
8511 uint32_t num_bufp;
8512 uint32_t copy_size;
8513 uint8_t *bufp;
8514
8515 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
8516 ev_param = param_buf->fixed_param;
8517 bufp = param_buf->bufp;
8518 num_bufp = param_buf->num_bufp;
8519 unit_test->vdev_id = ev_param->vdev_id;
8520 unit_test->module_id = ev_param->module_id;
8521 unit_test->diag_token = ev_param->diag_token;
8522 unit_test->flag = ev_param->flag;
8523 unit_test->payload_len = ev_param->payload_len;
Sathish Kumarefb25bf2018-10-02 11:03:59 +05308524 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d", __func__,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -07008525 ev_param->vdev_id,
8526 ev_param->module_id,
8527 ev_param->diag_token,
8528 ev_param->flag);
8529 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
8530 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
8531 bufp, num_bufp);
8532 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
8533 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
8534 unit_test->buffer_len = copy_size;
8535
8536 return QDF_STATUS_SUCCESS;
8537}
8538
8539/**
Govind Singhe7f2f342016-05-23 12:12:52 +05308540 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
8541 * @wmi_handle: wmi handle
8542 * @param evt_buf: pointer to event buffer
8543 * @param index: Index into extended pdev stats
8544 * @param pdev_ext_stats: Pointer to hold extended pdev stats
8545 *
8546 * Return: QDF_STATUS_SUCCESS for success or error code
8547 */
8548static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
8549 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
8550{
8551 return QDF_STATUS_SUCCESS;
8552}
8553
8554/**
8555 * extract_vdev_stats_tlv() - extract vdev stats from event
8556 * @wmi_handle: wmi handle
8557 * @param evt_buf: pointer to event buffer
8558 * @param index: Index into vdev stats
8559 * @param vdev_stats: Pointer to hold vdev stats
8560 *
8561 * Return: QDF_STATUS_SUCCESS for success or error code
8562 */
8563static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
8564 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
8565{
8566 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
8567 wmi_stats_event_fixed_param *ev_param;
8568 uint8_t *data;
8569
8570 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
8571 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
8572 data = (uint8_t *) param_buf->data;
8573
8574 if (index < ev_param->num_vdev_stats) {
8575 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
8576 ((ev_param->num_pdev_stats) *
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308577 sizeof(wmi_pdev_stats_v2)) +
Govind Singhe7f2f342016-05-23 12:12:52 +05308578 (index * sizeof(wmi_vdev_stats)));
8579
8580 vdev_stats->vdev_id = ev->vdev_id;
8581 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
8582 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
8583
8584 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
8585 sizeof(ev->tx_frm_cnt));
8586 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
8587 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
8588 ev->multiple_retry_cnt,
8589 sizeof(ev->multiple_retry_cnt));
8590 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
8591 sizeof(ev->fail_cnt));
8592 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
8593 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
8594 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
8595 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
8596 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
8597 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
8598 sizeof(ev->tx_rate_history));
8599 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
8600 sizeof(ev->bcn_rssi_history));
8601
8602 }
8603
8604 return QDF_STATUS_SUCCESS;
8605}
8606
8607/**
Naveen Rawatd2115722018-04-12 08:17:55 -07008608 * extract_per_chain_rssi_stats_tlv() - api to extract rssi stats from event
8609 * buffer
8610 * @wmi_handle: wmi handle
8611 * @evt_buf: pointer to event buffer
8612 * @index: Index into vdev stats
8613 * @rssi_stats: Pointer to hold rssi stats
8614 *
8615 * Return: QDF_STATUS_SUCCESS for success or error code
8616 */
8617static QDF_STATUS extract_per_chain_rssi_stats_tlv(wmi_unified_t wmi_handle,
8618 void *evt_buf, uint32_t index,
8619 struct wmi_host_per_chain_rssi_stats *rssi_stats)
8620{
8621 uint8_t *data;
8622 wmi_rssi_stats *fw_rssi_stats;
8623 wmi_per_chain_rssi_stats *rssi_event;
8624 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
8625
8626 if (!evt_buf) {
8627 WMI_LOGE("evt_buf is null");
8628 return QDF_STATUS_E_NULL_VALUE;
8629 }
8630
8631 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
8632 rssi_event = param_buf->chain_stats;
8633
8634 if (index >= rssi_event->num_per_chain_rssi_stats) {
8635 WMI_LOGE("invalid index");
8636 return QDF_STATUS_E_INVAL;
8637 }
8638
8639 data = ((uint8_t *)(&rssi_event[1])) + WMI_TLV_HDR_SIZE;
8640 fw_rssi_stats = &((wmi_rssi_stats *)data)[index];
8641
8642 rssi_stats->vdev_id = fw_rssi_stats->vdev_id;
8643 qdf_mem_copy(rssi_stats->rssi_avg_beacon,
8644 fw_rssi_stats->rssi_avg_beacon,
8645 sizeof(fw_rssi_stats->rssi_avg_beacon));
8646 qdf_mem_copy(rssi_stats->rssi_avg_data,
8647 fw_rssi_stats->rssi_avg_data,
8648 sizeof(fw_rssi_stats->rssi_avg_data));
8649 qdf_mem_copy(&rssi_stats->peer_macaddr,
8650 &fw_rssi_stats->peer_macaddr,
8651 sizeof(fw_rssi_stats->peer_macaddr));
8652
8653 return QDF_STATUS_SUCCESS;
8654}
8655
8656
8657
8658/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +05308659 * extract_bcn_stats_tlv() - extract bcn stats from event
8660 * @wmi_handle: wmi handle
8661 * @param evt_buf: pointer to event buffer
8662 * @param index: Index into vdev stats
8663 * @param bcn_stats: Pointer to hold bcn stats
8664 *
8665 * Return: QDF_STATUS_SUCCESS for success or error code
8666 */
8667static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
8668 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
8669{
8670 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
8671 wmi_stats_event_fixed_param *ev_param;
8672 uint8_t *data;
8673
8674 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
8675 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
8676 data = (uint8_t *) param_buf->data;
8677
8678 if (index < ev_param->num_bcn_stats) {
8679 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308680 ((ev_param->num_pdev_stats) *
8681 sizeof(wmi_pdev_stats_v2)) +
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +05308682 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
8683 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
8684 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
8685 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
8686 (index * sizeof(wmi_bcn_stats)));
8687
8688 bcn_stats->vdev_id = ev->vdev_id;
8689 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
8690 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
8691 }
8692
8693 return QDF_STATUS_SUCCESS;
8694}
8695
8696/**
Govind Singhe7f2f342016-05-23 12:12:52 +05308697 * extract_peer_stats_tlv() - extract peer stats from event
8698 * @wmi_handle: wmi handle
8699 * @param evt_buf: pointer to event buffer
8700 * @param index: Index into peer stats
8701 * @param peer_stats: Pointer to hold peer stats
8702 *
8703 * Return: QDF_STATUS_SUCCESS for success or error code
8704 */
8705static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
8706 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
8707{
8708 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
8709 wmi_stats_event_fixed_param *ev_param;
8710 uint8_t *data;
8711
8712 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
8713 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
8714 data = (uint8_t *) param_buf->data;
8715
8716 if (index < ev_param->num_peer_stats) {
8717 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308718 ((ev_param->num_pdev_stats) *
8719 sizeof(wmi_pdev_stats_v2)) +
Govind Singhe7f2f342016-05-23 12:12:52 +05308720 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
8721 (index * sizeof(wmi_peer_stats)));
8722
8723 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
8724
8725 OS_MEMCPY(&(peer_stats->peer_macaddr),
8726 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
8727
8728 peer_stats->peer_rssi = ev->peer_rssi;
8729 peer_stats->peer_tx_rate = ev->peer_tx_rate;
8730 peer_stats->peer_rx_rate = ev->peer_rx_rate;
8731 }
8732
8733 return QDF_STATUS_SUCCESS;
8734}
8735
8736/**
8737 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
8738 * @wmi_handle: wmi handle
8739 * @param evt_buf: pointer to event buffer
8740 * @param index: Index into bcn fault stats
8741 * @param bcnflt_stats: Pointer to hold bcn fault stats
8742 *
8743 * Return: QDF_STATUS_SUCCESS for success or error code
8744 */
8745static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
8746 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
8747{
8748 return QDF_STATUS_SUCCESS;
8749}
8750
8751/**
8752 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
8753 * @wmi_handle: wmi handle
8754 * @param evt_buf: pointer to event buffer
8755 * @param index: Index into extended peer stats
8756 * @param peer_extd_stats: Pointer to hold extended peer stats
8757 *
8758 * Return: QDF_STATUS_SUCCESS for success or error code
8759 */
8760static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
8761 void *evt_buf, uint32_t index,
8762 wmi_host_peer_extd_stats *peer_extd_stats)
8763{
8764 return QDF_STATUS_SUCCESS;
8765}
8766
8767/**
8768 * extract_chan_stats_tlv() - extract chan stats from event
8769 * @wmi_handle: wmi handle
8770 * @param evt_buf: pointer to event buffer
8771 * @param index: Index into chan stats
8772 * @param vdev_extd_stats: Pointer to hold chan stats
8773 *
8774 * Return: QDF_STATUS_SUCCESS for success or error code
8775 */
8776static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
8777 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
8778{
8779 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
8780 wmi_stats_event_fixed_param *ev_param;
8781 uint8_t *data;
8782
8783 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
8784 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
8785 data = (uint8_t *) param_buf->data;
8786
8787 if (index < ev_param->num_chan_stats) {
8788 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
Nandha Kishore Easwaran6dd231d2018-10-10 11:04:09 +05308789 ((ev_param->num_pdev_stats) *
8790 sizeof(wmi_pdev_stats_v2)) +
Govind Singhe7f2f342016-05-23 12:12:52 +05308791 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
8792 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
8793 (index * sizeof(wmi_chan_stats)));
8794
8795
Jeff Johnson79eaacb2018-05-06 17:53:18 -07008796 /* Non-TLV doesn't have num_chan_stats */
Govind Singhe7f2f342016-05-23 12:12:52 +05308797 chan_stats->chan_mhz = ev->chan_mhz;
8798 chan_stats->sampling_period_us = ev->sampling_period_us;
8799 chan_stats->rx_clear_count = ev->rx_clear_count;
8800 chan_stats->tx_duration_us = ev->tx_duration_us;
8801 chan_stats->rx_duration_us = ev->rx_duration_us;
8802 }
8803
8804 return QDF_STATUS_SUCCESS;
8805}
8806
8807/**
8808 * extract_profile_ctx_tlv() - extract profile context from event
8809 * @wmi_handle: wmi handle
8810 * @param evt_buf: pointer to event buffer
8811 * @idx: profile stats index to extract
8812 * @param profile_ctx: Pointer to hold profile context
8813 *
8814 * Return: QDF_STATUS_SUCCESS for success or error code
8815 */
8816static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
8817 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
8818{
8819 return QDF_STATUS_SUCCESS;
8820}
8821
8822/**
8823 * extract_profile_data_tlv() - extract profile data from event
8824 * @wmi_handle: wmi handle
8825 * @param evt_buf: pointer to event buffer
8826 * @param profile_data: Pointer to hold profile data
8827 *
8828 * Return: QDF_STATUS_SUCCESS for success or error code
8829 */
8830static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
8831 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
8832{
8833
8834 return QDF_STATUS_SUCCESS;
8835}
8836
8837/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +05308838 * extract_pdev_utf_event_tlv() - extract UTF data info from event
8839 * @wmi_handle: WMI handle
8840 * @param evt_buf: Pointer to event buffer
8841 * @param param: Pointer to hold data
8842 *
8843 * Return : QDF_STATUS_SUCCESS for success or error code
8844 */
8845static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
8846 uint8_t *evt_buf,
8847 struct wmi_host_pdev_utf_event *event)
8848{
8849 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +05308850 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +05308851
8852 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
8853 event->data = param_buf->data;
8854 event->datalen = param_buf->num_data;
Pragaspathi Thilagarajd8d0e152018-09-04 14:39:09 +05308855
8856 if (event->datalen < sizeof(struct wmi_host_utf_seg_header_info)) {
8857 WMI_LOGE("%s: Invalid datalen: %d ", __func__, event->datalen);
8858 return QDF_STATUS_E_INVAL;
8859 }
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +05308860 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +05308861 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308862 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +05308863 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +05308864
8865 return QDF_STATUS_SUCCESS;
8866}
Govind Singhe7f2f342016-05-23 12:12:52 +05308867
Kiran Venkatappa06520822016-08-10 23:55:40 +05308868/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05308869 * extract_chainmask_tables_tlv() - extract chain mask tables from event
8870 * @wmi_handle: wmi handle
8871 * @param evt_buf: pointer to event buffer
8872 * @param param: Pointer to hold evt buf
8873 *
8874 * Return: QDF_STATUS_SUCCESS for success or error code
8875 */
8876static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
8877 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
8878{
8879 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
8880 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
8881 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
8882 uint8_t i = 0, j = 0;
8883
8884 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
8885 if (!param_buf)
8886 return QDF_STATUS_E_INVAL;
8887
8888 hw_caps = param_buf->soc_hw_mode_caps;
8889 if (!hw_caps)
8890 return QDF_STATUS_E_INVAL;
8891
Wu Gao5d1c9ed2018-10-12 18:16:09 +08008892 if ((!hw_caps->num_chainmask_tables) ||
8893 (hw_caps->num_chainmask_tables > PSOC_MAX_CHAINMASK_TABLES))
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05308894 return QDF_STATUS_E_INVAL;
8895
8896 chainmask_caps = param_buf->mac_phy_chainmask_caps;
8897
8898 if (chainmask_caps == NULL)
8899 return QDF_STATUS_E_INVAL;
8900
8901 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
8902
Aditya Sathish45d7ada2018-07-02 17:31:55 +05308903 qdf_print("Dumping chain mask combo data for table : %d", i);
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05308904 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
8905
8906 chainmask_table[i].cap_list[j].chainmask =
8907 chainmask_caps->chainmask;
8908
8909 chainmask_table[i].cap_list[j].supports_chan_width_20 =
8910 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
8911
8912 chainmask_table[i].cap_list[j].supports_chan_width_40 =
8913 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
8914
8915 chainmask_table[i].cap_list[j].supports_chan_width_80 =
8916 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
8917
8918 chainmask_table[i].cap_list[j].supports_chan_width_160 =
8919 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
8920
8921 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
8922 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
8923
8924 chainmask_table[i].cap_list[j].chain_mask_2G =
8925 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
8926
8927 chainmask_table[i].cap_list[j].chain_mask_5G =
8928 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
8929
8930 chainmask_table[i].cap_list[j].chain_mask_tx =
8931 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
8932
8933 chainmask_table[i].cap_list[j].chain_mask_rx =
8934 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
8935
8936 chainmask_table[i].cap_list[j].supports_aDFS =
8937 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
8938
Aditya Sathish45d7ada2018-07-02 17:31:55 +05308939 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x",
8940 chainmask_caps->supported_flags,
8941 chainmask_caps->chainmask
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05308942 );
8943 chainmask_caps++;
8944 }
8945 }
8946
8947 return QDF_STATUS_SUCCESS;
8948}
8949
8950/**
Kiran Venkatappa06520822016-08-10 23:55:40 +05308951 * extract_service_ready_ext_tlv() - extract basic extended service ready params
8952 * from event
8953 * @wmi_handle: wmi handle
8954 * @param evt_buf: pointer to event buffer
8955 * @param param: Pointer to hold evt buf
8956 *
8957 * Return: QDF_STATUS_SUCCESS for success or error code
8958 */
8959static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -08008960 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +05308961{
8962 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
8963 wmi_service_ready_ext_event_fixed_param *ev;
8964 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
8965 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05308966 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
8967 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +05308968
8969 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
8970 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05308971 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05308972
8973 ev = param_buf->fixed_param;
8974 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05308975 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05308976
8977 /* Move this to host based bitmap */
8978 param->default_conc_scan_config_bits =
8979 ev->default_conc_scan_config_bits;
8980 param->default_fw_config_bits = ev->default_fw_config_bits;
8981 param->he_cap_info = ev->he_cap_info;
8982 param->mpdu_density = ev->mpdu_density;
8983 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +05308984 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +05308985 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Manoj Ekbote0bce58b2018-06-06 16:52:39 -07008986 param->max_bssid_indicator = ev->max_bssid_indicator;
Kiran Venkatappa06520822016-08-10 23:55:40 +05308987 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
8988
8989 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05308990 if (hw_caps)
8991 param->num_hw_modes = hw_caps->num_hw_modes;
8992 else
8993 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +05308994
8995 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05308996 if (reg_caps)
8997 param->num_phy = reg_caps->num_phy;
8998 else
8999 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309000
Kapil Gupta0692a1a2017-05-15 15:57:36 +05309001 if (hw_caps) {
9002 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
Aditya Sathish45d7ada2018-07-02 17:31:55 +05309003 qdf_print("Num chain mask tables: %d", hw_caps->num_chainmask_tables);
Kapil Gupta0692a1a2017-05-15 15:57:36 +05309004 } else
9005 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309006
9007 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
9008
9009 if (chain_mask_combo == NULL)
9010 return QDF_STATUS_SUCCESS;
9011
Aditya Sathish45d7ada2018-07-02 17:31:55 +05309012 qdf_print("Dumping chain mask combo data");
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309013
Kapil Gupta0692a1a2017-05-15 15:57:36 +05309014 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309015
Aditya Sathish45d7ada2018-07-02 17:31:55 +05309016 qdf_print("table_id : %d Num valid chainmasks: %d",
9017 chain_mask_combo->chainmask_table_id,
9018 chain_mask_combo->num_valid_chainmask
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309019 );
9020
9021 param->chainmask_table[i].table_id =
9022 chain_mask_combo->chainmask_table_id;
9023 param->chainmask_table[i].num_valid_chainmasks =
9024 chain_mask_combo->num_valid_chainmask;
9025 chain_mask_combo++;
9026 }
Aditya Sathish45d7ada2018-07-02 17:31:55 +05309027 qdf_print("chain mask combo end");
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309028
Kiran Venkatappa06520822016-08-10 23:55:40 +05309029 return QDF_STATUS_SUCCESS;
9030}
9031
9032/**
Kabilan Kannan0d0f9352018-06-21 16:55:47 -07009033 * extract_sar_cap_service_ready_ext_tlv() -
9034 * extract SAR cap from service ready event
9035 * @wmi_handle: wmi handle
9036 * @event: pointer to event buffer
9037 * @ext_param: extended target info
9038 *
9039 * Return: QDF_STATUS_SUCCESS for success or error code
9040 */
9041static QDF_STATUS extract_sar_cap_service_ready_ext_tlv(
9042 wmi_unified_t wmi_handle,
9043 uint8_t *event,
9044 struct wlan_psoc_host_service_ext_param *ext_param)
9045{
9046 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
9047 WMI_SAR_CAPABILITIES *sar_caps;
9048
9049 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
9050
Kabilan Kannanee8d27a2018-07-06 11:52:32 -07009051 if (!param_buf)
Kabilan Kannan0d0f9352018-06-21 16:55:47 -07009052 return QDF_STATUS_E_INVAL;
9053
Kabilan Kannanee8d27a2018-07-06 11:52:32 -07009054 sar_caps = param_buf->sar_caps;
9055 if (sar_caps)
9056 ext_param->sar_version = sar_caps->active_version;
9057 else
9058 ext_param->sar_version = 0;
Kabilan Kannan0d0f9352018-06-21 16:55:47 -07009059
9060 return QDF_STATUS_SUCCESS;
9061}
9062
9063/**
Kiran Venkatappa06520822016-08-10 23:55:40 +05309064 * extract_hw_mode_cap_service_ready_ext_tlv() -
9065 * extract HW mode cap from service ready event
9066 * @wmi_handle: wmi handle
9067 * @param evt_buf: pointer to event buffer
9068 * @param param: Pointer to hold evt buf
9069 * @param hw_mode_idx: hw mode idx should be less than num_mode
9070 *
9071 * Return: QDF_STATUS_SUCCESS for success or error code
9072 */
9073static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
9074 wmi_unified_t wmi_handle,
9075 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -08009076 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +05309077{
9078 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
9079 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
9080
9081 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
9082 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309083 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309084
9085 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309086 if (!hw_caps)
9087 return QDF_STATUS_E_INVAL;
9088
Kiran Venkatappa06520822016-08-10 23:55:40 +05309089 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309090 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309091
9092 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
9093 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
9094
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309095 param->hw_mode_config_type =
9096 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
9097
Kiran Venkatappa06520822016-08-10 23:55:40 +05309098 return QDF_STATUS_SUCCESS;
9099}
9100
9101/**
9102 * extract_mac_phy_cap_service_ready_ext_tlv() -
9103 * extract MAC phy cap from service ready event
9104 * @wmi_handle: wmi handle
9105 * @param evt_buf: pointer to event buffer
9106 * @param param: Pointer to hold evt buf
9107 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309108 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +05309109 *
9110 * Return: QDF_STATUS_SUCCESS for success or error code
9111 */
9112static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
9113 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309114 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -08009115 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +05309116{
9117 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309118 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309119 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
9120 uint32_t phy_map;
9121 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309122
9123 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
9124 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309125 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309126
9127 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309128 if (!hw_caps)
9129 return QDF_STATUS_E_INVAL;
9130
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309131 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
9132 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
9133 break;
9134
9135 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
9136 while (phy_map) {
9137 phy_map >>= 1;
9138 phy_idx++;
9139 }
9140 }
9141
9142 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309143 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309144
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309145 phy_idx += phy_id;
9146 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309147 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309148
9149 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +05309150
9151 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309152 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
9153 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +05309154 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +05309155 param->supports_11b =
9156 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
9157 param->supports_11g =
9158 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
9159 param->supports_11a =
9160 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
9161 param->supports_11n =
9162 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
9163 param->supports_11ac =
9164 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
9165 param->supports_11ax =
9166 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +05309167
9168 param->supported_bands = mac_phy_caps->supported_bands;
9169 param->ampdu_density = mac_phy_caps->ampdu_density;
9170 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
9171 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
9172 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
9173 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
Gyanranjan Hazarikae881c7c2018-08-17 01:54:48 -07009174 param->he_cap_info_2G[WMI_HOST_HECAP_MAC_WORD1] =
9175 mac_phy_caps->he_cap_info_2G;
9176 param->he_cap_info_2G[WMI_HOST_HECAP_MAC_WORD2] =
9177 mac_phy_caps->he_cap_info_2G_ext;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309178 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
9179 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
9180 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
9181 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
9182 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
9183 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
9184 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
Gyanranjan Hazarikae881c7c2018-08-17 01:54:48 -07009185 param->he_cap_info_5G[WMI_HOST_HECAP_MAC_WORD1] =
9186 mac_phy_caps->he_cap_info_5G;
9187 param->he_cap_info_5G[WMI_HOST_HECAP_MAC_WORD2] =
9188 mac_phy_caps->he_cap_info_5G_ext;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309189 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
9190 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
9191 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -08009192 qdf_mem_copy(&param->he_cap_phy_info_2G,
9193 &mac_phy_caps->he_cap_phy_info_2G,
9194 sizeof(param->he_cap_phy_info_2G));
9195 qdf_mem_copy(&param->he_cap_phy_info_5G,
9196 &mac_phy_caps->he_cap_phy_info_5G,
9197 sizeof(param->he_cap_phy_info_5G));
9198 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
9199 sizeof(param->he_ppet2G));
9200 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
9201 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +05309202 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309203
9204 return QDF_STATUS_SUCCESS;
9205}
9206
9207/**
9208 * extract_reg_cap_service_ready_ext_tlv() -
9209 * extract REG cap from service ready event
9210 * @wmi_handle: wmi handle
9211 * @param evt_buf: pointer to event buffer
9212 * @param param: Pointer to hold evt buf
9213 * @param phy_idx: phy idx should be less than num_mode
9214 *
9215 * Return: QDF_STATUS_SUCCESS for success or error code
9216 */
9217static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
9218 wmi_unified_t wmi_handle,
9219 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -08009220 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +05309221{
9222 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
9223 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
9224 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
9225
9226 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
9227 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309228 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309229
9230 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309231 if (!reg_caps)
9232 return QDF_STATUS_E_INVAL;
9233
Kiran Venkatappa06520822016-08-10 23:55:40 +05309234 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +05309235 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +05309236
9237 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
9238
9239 param->phy_id = ext_reg_cap->phy_id;
9240 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
9241 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
9242 param->regcap1 = ext_reg_cap->regcap1;
9243 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +05309244 param->wireless_modes = convert_wireless_modes_tlv(
9245 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +05309246 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
9247 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
9248 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
9249 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
9250
9251 return QDF_STATUS_SUCCESS;
9252}
9253
Sathish Kumarf396c722017-11-17 17:30:41 +05309254static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
9255 wmi_unified_t wmi_handle,
9256 uint8_t *event, uint8_t idx,
9257 struct wlan_psoc_host_dbr_ring_caps *param)
9258{
9259 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
9260 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
9261
9262 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
9263 if (!param_buf)
9264 return QDF_STATUS_E_INVAL;
9265
9266 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
9267
9268 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
9269 dbr_ring_caps->pdev_id);
9270 param->mod_id = dbr_ring_caps->mod_id;
9271 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
9272 param->min_buf_size = dbr_ring_caps->min_buf_size;
9273 param->min_buf_align = dbr_ring_caps->min_buf_align;
9274
9275 return QDF_STATUS_SUCCESS;
9276}
9277
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +05309278/**
9279 * extract_thermal_stats_tlv() - extract thermal stats from event
9280 * @wmi_handle: wmi handle
9281 * @param evt_buf: Pointer to event buffer
9282 * @param temp: Pointer to hold extracted temperature
9283 * @param level: Pointer to hold extracted level
9284 *
9285 * Return: 0 for success or error code
9286 */
9287static QDF_STATUS
9288extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
9289 void *evt_buf, uint32_t *temp,
9290 uint32_t *level, uint32_t *pdev_id)
9291{
9292 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
9293 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
9294
9295 param_buf =
9296 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
9297 if (!param_buf)
9298 return QDF_STATUS_E_INVAL;
9299
9300 tt_stats_event = param_buf->fixed_param;
9301
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309302 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
9303 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +05309304 *temp = tt_stats_event->temp;
9305 *level = tt_stats_event->level;
9306
9307 return QDF_STATUS_SUCCESS;
9308}
9309
9310/**
9311 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
9312 * @wmi_handle: wmi handle
9313 * @param evt_buf: pointer to event buffer
9314 * @param idx: Index to level stats
9315 * @param levelcount: Pointer to hold levelcount
9316 * @param dccount: Pointer to hold dccount
9317 *
9318 * Return: 0 for success or error code
9319 */
9320static QDF_STATUS
9321extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
9322 void *evt_buf, uint8_t idx, uint32_t *levelcount,
9323 uint32_t *dccount)
9324{
9325 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
9326 wmi_therm_throt_level_stats_info *tt_level_info;
9327
9328 param_buf =
9329 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
9330 if (!param_buf)
9331 return QDF_STATUS_E_INVAL;
9332
9333 tt_level_info = param_buf->therm_throt_level_stats_info;
9334
9335 if (idx < THERMAL_LEVELS) {
9336 *levelcount = tt_level_info[idx].level_count;
9337 *dccount = tt_level_info[idx].dc_count;
9338 return QDF_STATUS_SUCCESS;
9339 }
9340
9341 return QDF_STATUS_E_FAILURE;
9342}
Kiran Venkatappac813ec92016-12-29 22:07:14 +05309343#ifdef BIG_ENDIAN_HOST
9344/**
9345 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
9346 * @param data_len - data length
9347 * @param data - pointer to data
9348 *
9349 * Return: QDF_STATUS - success or error status
9350 */
9351static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
9352{
9353 uint8_t *data_aligned = NULL;
9354 int c;
9355 unsigned char *data_unaligned;
9356
9357 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
9358 FIPS_ALIGN));
9359 /* Assigning unaligned space to copy the data */
Jeff Johnsonda263992018-05-12 14:22:00 -07009360 /* Checking if kmalloc does successful allocation */
Kiran Venkatappac813ec92016-12-29 22:07:14 +05309361 if (data_unaligned == NULL)
9362 return QDF_STATUS_E_FAILURE;
9363
9364 /* Checking if space is alligned */
9365 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
9366 /* align the data space */
9367 data_aligned =
9368 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
9369 } else {
9370 data_aligned = (u_int8_t *)data_unaligned;
9371 }
9372
9373 /* memset and copy content from data to data aligned */
9374 OS_MEMSET(data_aligned, 0, data_len);
9375 OS_MEMCPY(data_aligned, data, data_len);
9376 /* Endianness to LE */
9377 for (c = 0; c < data_len/4; c++) {
9378 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +05309379 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +05309380 }
9381
9382 /* Copy content to event->data */
9383 OS_MEMCPY(data, data_aligned, data_len);
9384
9385 /* clean up allocated space */
9386 qdf_mem_free(data_unaligned);
9387 data_aligned = NULL;
9388 data_unaligned = NULL;
9389
9390 /*************************************************************/
9391
9392 return QDF_STATUS_SUCCESS;
9393}
9394#else
9395/**
9396 * fips_conv_data_be() - DUMMY for LE platform
9397 *
9398 * Return: QDF_STATUS - success
9399 */
9400static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
9401{
9402 return QDF_STATUS_SUCCESS;
9403}
9404#endif
9405
9406/**
9407 * extract_fips_event_data_tlv() - extract fips event data
9408 * @wmi_handle: wmi handle
9409 * @param evt_buf: pointer to event buffer
9410 * @param param: pointer FIPS event params
9411 *
9412 * Return: 0 for success or error code
9413 */
9414static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
9415 void *evt_buf, struct wmi_host_fips_event_param *param)
9416{
9417 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
9418 wmi_pdev_fips_event_fixed_param *event;
9419
9420 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
9421 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
9422
9423 if (fips_conv_data_be(event->data_len, param_buf->data) !=
9424 QDF_STATUS_SUCCESS)
9425 return QDF_STATUS_E_FAILURE;
9426
9427 param->data = (uint32_t *)param_buf->data;
9428 param->data_len = event->data_len;
9429 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309430 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
9431 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +05309432
9433 return QDF_STATUS_SUCCESS;
9434}
9435
Govind Singhecf03cd2016-05-12 12:45:51 +05309436static bool is_management_record_tlv(uint32_t cmd_id)
9437{
Rajeev Kumar173bef42018-09-18 16:45:39 -07009438 switch (cmd_id) {
9439 case WMI_MGMT_TX_SEND_CMDID:
9440 case WMI_MGMT_TX_COMPLETION_EVENTID:
9441 case WMI_OFFCHAN_DATA_TX_SEND_CMDID:
9442 case WMI_MGMT_RX_EVENTID:
Govind Singhecf03cd2016-05-12 12:45:51 +05309443 return true;
Rajeev Kumar173bef42018-09-18 16:45:39 -07009444 default:
9445 return false;
jiad36c94d22018-01-22 15:37:03 +08009446 }
Govind Singhecf03cd2016-05-12 12:45:51 +05309447}
9448
Rajeev Kumarb64e1282018-09-19 13:02:23 -07009449static bool is_diag_event_tlv(uint32_t event_id)
9450{
9451 if (WMI_DIAG_EVENTID == event_id)
9452 return true;
9453
9454 return false;
9455}
9456
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +05309457static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
9458{
9459 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
9460
9461 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
9462
9463 switch (set_cmd->param_id) {
9464 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
9465 case WMI_VDEV_PARAM_DTIM_POLICY:
9466 return HTC_TX_PACKET_TAG_AUTO_PM;
9467 default:
9468 break;
9469 }
9470
9471 return 0;
9472}
9473
9474static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
9475{
9476 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
9477
9478 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
9479
9480 switch (ps_cmd->param) {
9481 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
9482 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
9483 case WMI_STA_PS_ENABLE_QPOWER:
9484 return HTC_TX_PACKET_TAG_AUTO_PM;
9485 default:
9486 break;
9487 }
9488
9489 return 0;
9490}
9491
9492static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
9493 uint32_t cmd_id)
9494{
9495 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
9496 return 0;
9497
9498 switch (cmd_id) {
9499 case WMI_VDEV_SET_PARAM_CMDID:
9500 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
9501 case WMI_STA_POWERSAVE_PARAM_CMDID:
9502 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
9503 default:
9504 break;
9505 }
9506
9507 return 0;
9508}
9509
9510static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
9511{
9512 uint16_t tag = 0;
9513
9514 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
Sathish Kumarefb25bf2018-10-02 11:03:59 +05309515 pr_err("%s: Target is already suspended, Ignore FW Hang Command",
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +05309516 __func__);
9517 return tag;
9518 }
9519
9520 if (wmi_handle->tag_crash_inject)
9521 tag = HTC_TX_PACKET_TAG_AUTO_PM;
9522
9523 wmi_handle->tag_crash_inject = false;
9524 return tag;
9525}
9526
9527/**
9528 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
9529 * @wmi_handle: WMI handle
9530 * @buf: WMI buffer
9531 * @cmd_id: WMI command Id
9532 *
9533 * Return htc_tx_tag
9534 */
9535static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
9536 wmi_buf_t buf,
9537 uint32_t cmd_id)
9538{
9539 uint16_t htc_tx_tag = 0;
9540
9541 switch (cmd_id) {
9542 case WMI_WOW_ENABLE_CMDID:
9543 case WMI_PDEV_SUSPEND_CMDID:
9544 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
9545 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
9546 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
9547 case WMI_PDEV_RESUME_CMDID:
9548 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
9549 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
9550#ifdef FEATURE_WLAN_D0WOW
9551 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
9552#endif
9553 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
9554 break;
9555 case WMI_FORCE_FW_HANG_CMDID:
9556 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
9557 break;
9558 case WMI_VDEV_SET_PARAM_CMDID:
9559 case WMI_STA_POWERSAVE_PARAM_CMDID:
9560 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
9561 default:
9562 break;
9563 }
9564
9565 return htc_tx_tag;
9566}
9567
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309568static struct cur_reg_rule
9569*create_reg_rules_from_wmi(uint32_t num_reg_rules,
9570 wmi_regulatory_rule_struct *wmi_reg_rule)
9571{
9572 struct cur_reg_rule *reg_rule_ptr;
9573 uint32_t count;
9574
9575 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
9576
9577 if (NULL == reg_rule_ptr) {
9578 WMI_LOGE("memory allocation failure");
9579 return NULL;
9580 }
9581
9582 for (count = 0; count < num_reg_rules; count++) {
9583 reg_rule_ptr[count].start_freq =
9584 WMI_REG_RULE_START_FREQ_GET(
9585 wmi_reg_rule[count].freq_info);
9586 reg_rule_ptr[count].end_freq =
9587 WMI_REG_RULE_END_FREQ_GET(
9588 wmi_reg_rule[count].freq_info);
9589 reg_rule_ptr[count].max_bw =
9590 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -07009591 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309592 reg_rule_ptr[count].reg_power =
9593 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -07009594 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +05309595 reg_rule_ptr[count].ant_gain =
9596 WMI_REG_RULE_ANTENNA_GAIN_GET(
9597 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309598 reg_rule_ptr[count].flags =
9599 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -07009600 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309601 }
9602
9603 return reg_rule_ptr;
9604}
9605
9606static QDF_STATUS extract_reg_chan_list_update_event_tlv(
9607 wmi_unified_t wmi_handle, uint8_t *evt_buf,
9608 struct cur_regulatory_info *reg_info, uint32_t len)
9609{
9610 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
9611 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
9612 wmi_regulatory_rule_struct *wmi_reg_rule;
9613 uint32_t num_2g_reg_rules, num_5g_reg_rules;
9614
9615 WMI_LOGD("processing regulatory channel list");
9616
9617 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
9618 if (!param_buf) {
9619 WMI_LOGE("invalid channel list event buf");
9620 return QDF_STATUS_E_FAILURE;
9621 }
9622
9623 chan_list_event_hdr = param_buf->fixed_param;
9624
9625 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
9626 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
9627 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +05309628 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309629 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
9630 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -07009631 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -07009632 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +05309633 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -07009634 reg_info->ctry_code = chan_list_event_hdr->country_id;
9635 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
9636 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
9637 reg_info->status_code = REG_SET_CC_STATUS_PASS;
9638 else if (chan_list_event_hdr->status_code ==
9639 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
9640 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
9641 else if (chan_list_event_hdr->status_code ==
9642 WMI_REG_INIT_ALPHA2_NOT_FOUND)
9643 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
9644 else if (chan_list_event_hdr->status_code ==
9645 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
9646 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
9647 else if (chan_list_event_hdr->status_code ==
9648 WMI_REG_SET_CC_STATUS_NO_MEMORY)
9649 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
9650 else if (chan_list_event_hdr->status_code ==
9651 WMI_REG_SET_CC_STATUS_FAIL)
9652 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
9653
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309654 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
9655 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
9656 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
9657 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
9658
9659 num_2g_reg_rules = reg_info->num_2g_reg_rules;
9660 num_5g_reg_rules = reg_info->num_5g_reg_rules;
9661
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -07009662 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
9663 __func__, reg_info->alpha2, reg_info->dfs_region,
9664 reg_info->min_bw_2g, reg_info->max_bw_2g,
9665 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309666
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -07009667 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
9668 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -07009669 wmi_reg_rule =
9670 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
9671 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
9672 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +05309673 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
9674 wmi_reg_rule);
9675 wmi_reg_rule += num_2g_reg_rules;
9676
9677 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
9678 wmi_reg_rule);
9679
9680 WMI_LOGD("processed regulatory channel list");
9681
9682 return QDF_STATUS_SUCCESS;
9683}
9684
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07009685static QDF_STATUS extract_reg_11d_new_country_event_tlv(
9686 wmi_unified_t wmi_handle, uint8_t *evt_buf,
9687 struct reg_11d_new_country *reg_11d_country, uint32_t len)
9688{
9689 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
9690 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
9691
9692 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
9693 if (!param_buf) {
9694 WMI_LOGE("invalid 11d country event buf");
9695 return QDF_STATUS_E_FAILURE;
9696 }
9697
9698 reg_11d_country_event = param_buf->fixed_param;
9699
9700 qdf_mem_copy(reg_11d_country->alpha2,
9701 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
Jianmin Zhuf6d5a652018-10-11 20:30:58 +08009702 reg_11d_country->alpha2[REG_ALPHA2_LEN] = '\0';
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07009703
9704 WMI_LOGD("processed 11d country event, new cc %s",
9705 reg_11d_country->alpha2);
9706
9707 return QDF_STATUS_SUCCESS;
9708}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -07009709
9710static QDF_STATUS extract_reg_ch_avoid_event_tlv(
9711 wmi_unified_t wmi_handle, uint8_t *evt_buf,
9712 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
9713{
9714 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
9715 wmi_avoid_freq_range_desc *afr_desc;
9716 uint32_t num_freq_ranges, freq_range_idx;
9717 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
9718 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
9719
9720 if (!param_buf) {
9721 WMI_LOGE("Invalid channel avoid event buffer");
9722 return QDF_STATUS_E_INVAL;
9723 }
9724
9725 afr_fixed_param = param_buf->fixed_param;
9726 if (!afr_fixed_param) {
9727 WMI_LOGE("Invalid channel avoid event fixed param buffer");
9728 return QDF_STATUS_E_INVAL;
9729 }
9730
9731 if (!ch_avoid_ind) {
9732 WMI_LOGE("Invalid channel avoid indication buffer");
9733 return QDF_STATUS_E_INVAL;
9734 }
Kiran Kumar Lokere7d312042018-09-19 16:55:34 -07009735 if (param_buf->num_avd_freq_range < afr_fixed_param->num_freq_ranges) {
9736 WMI_LOGE(FL("no.of freq ranges exceeded the limit"));
9737 return QDF_STATUS_E_INVAL;
9738 }
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -07009739 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
9740 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
9741 afr_fixed_param->num_freq_ranges;
9742
9743 WMI_LOGD("Channel avoid event received with %d ranges",
9744 num_freq_ranges);
9745
9746 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
9747 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
9748 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
9749 freq_range_idx++) {
9750 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
9751 afr_desc->start_freq;
9752 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
9753 afr_desc->end_freq;
9754 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
9755 freq_range_idx, afr_desc->tlv_header,
9756 afr_desc->start_freq, afr_desc->end_freq);
9757 afr_desc++;
9758 }
9759
9760 return QDF_STATUS_SUCCESS;
9761}
Sathish Kumarefb25bf2018-10-02 11:03:59 +05309762
Arif Hussainbe58b4e2017-04-09 01:03:19 -07009763#ifdef DFS_COMPONENT_ENABLE
9764/**
9765 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
9766 * @wmi_handle: wma handle
9767 * @evt_buf: event buffer
9768 * @vdev_id: vdev id
9769 * @len: length of buffer
9770 *
9771 * Return: 0 for success or error code
9772 */
9773static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
9774 uint8_t *evt_buf,
9775 uint32_t *vdev_id,
9776 uint32_t len)
9777{
9778 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
9779 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
9780
9781 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
9782 if (!param_tlvs) {
9783 WMI_LOGE("invalid cac complete event buf");
9784 return QDF_STATUS_E_FAILURE;
9785 }
9786
9787 cac_event = param_tlvs->fixed_param;
9788 *vdev_id = cac_event->vdev_id;
9789 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
9790
9791 return QDF_STATUS_SUCCESS;
9792}
9793
9794/**
9795 * extract_dfs_radar_detection_event_tlv() - extract radar found event
9796 * @wmi_handle: wma handle
9797 * @evt_buf: event buffer
9798 * @radar_found: radar found event info
9799 * @len: length of buffer
9800 *
9801 * Return: 0 for success or error code
9802 */
9803static QDF_STATUS extract_dfs_radar_detection_event_tlv(
9804 wmi_unified_t wmi_handle,
9805 uint8_t *evt_buf,
9806 struct radar_found_info *radar_found,
9807 uint32_t len)
9808{
9809 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
9810 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
9811
9812 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
9813 if (!param_tlv) {
9814 WMI_LOGE("invalid radar detection event buf");
9815 return QDF_STATUS_E_FAILURE;
9816 }
9817
9818 radar_event = param_tlv->fixed_param;
Arif Hussainb522ac92018-06-27 10:51:06 -07009819 radar_found->pdev_id = convert_target_pdev_id_to_host_pdev_id(
9820 radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -07009821 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -07009822 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -07009823 radar_found->chan_width = radar_event->chan_width;
9824 radar_found->detector_id = radar_event->detector_id;
9825 radar_found->segment_id = radar_event->segment_id;
9826 radar_found->timestamp = radar_event->timestamp;
9827 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -07009828 radar_found->freq_offset = radar_event->freq_offset;
9829 radar_found->sidx = radar_event->sidx;
9830
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -08009831 WMI_LOGI("processed radar found event pdev %d,"
9832 "Radar Event Info:pdev_id %d,timestamp %d,chan_freq (dur) %d,"
9833 "chan_width (RSSI) %d,detector_id (false_radar) %d,"
9834 "freq_offset (radar_check) %d,segment_id %d,sidx %d,"
Sathish Kumarefb25bf2018-10-02 11:03:59 +05309835 "is_chirp %d,detection mode %d",
Arif Hussainb522ac92018-06-27 10:51:06 -07009836 radar_event->pdev_id, radar_found->pdev_id,
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -08009837 radar_event->timestamp, radar_event->chan_freq,
9838 radar_event->chan_width, radar_event->detector_id,
9839 radar_event->freq_offset, radar_event->segment_id,
9840 radar_event->sidx, radar_event->is_chirp,
9841 radar_event->detection_mode);
Arif Hussainbe58b4e2017-04-09 01:03:19 -07009842
9843 return QDF_STATUS_SUCCESS;
9844}
bings1ea12532017-12-18 16:56:53 +08009845
9846#ifdef QCA_MCL_DFS_SUPPORT
9847/**
9848 * extract_wlan_radar_event_info_tlv() - extract radar pulse event
9849 * @wmi_handle: wma handle
9850 * @evt_buf: event buffer
9851 * @wlan_radar_event: Pointer to struct radar_event_info
9852 * @len: length of buffer
9853 *
9854 * Return: QDF_STATUS
9855 */
9856static QDF_STATUS extract_wlan_radar_event_info_tlv(
9857 wmi_unified_t wmi_handle,
9858 uint8_t *evt_buf,
9859 struct radar_event_info *wlan_radar_event,
9860 uint32_t len)
9861{
9862 WMI_DFS_RADAR_EVENTID_param_tlvs *param_tlv;
9863 wmi_dfs_radar_event_fixed_param *radar_event;
9864
9865 param_tlv = (WMI_DFS_RADAR_EVENTID_param_tlvs *)evt_buf;
9866 if (!param_tlv) {
9867 WMI_LOGE("invalid wlan radar event buf");
9868 return QDF_STATUS_E_FAILURE;
9869 }
9870
9871 radar_event = param_tlv->fixed_param;
9872 wlan_radar_event->pulse_is_chirp = radar_event->pulse_is_chirp;
9873 wlan_radar_event->pulse_center_freq = radar_event->pulse_center_freq;
9874 wlan_radar_event->pulse_duration = radar_event->pulse_duration;
9875 wlan_radar_event->rssi = radar_event->rssi;
9876 wlan_radar_event->pulse_detect_ts = radar_event->pulse_detect_ts;
9877 wlan_radar_event->upload_fullts_high = radar_event->upload_fullts_high;
9878 wlan_radar_event->upload_fullts_low = radar_event->upload_fullts_low;
9879 wlan_radar_event->peak_sidx = radar_event->peak_sidx;
bingsfd461642018-01-03 16:38:00 +08009880 wlan_radar_event->delta_peak = radar_event->pulse_delta_peak;
9881 wlan_radar_event->delta_diff = radar_event->pulse_delta_diff;
bings26d46df2018-02-11 16:40:08 +08009882 if (radar_event->pulse_flags &
9883 WMI_DFS_RADAR_PULSE_FLAG_MASK_PSIDX_DIFF_VALID) {
9884 wlan_radar_event->is_psidx_diff_valid = true;
9885 wlan_radar_event->psidx_diff = radar_event->psidx_diff;
9886 } else {
9887 wlan_radar_event->is_psidx_diff_valid = false;
9888 }
9889
bings1ea12532017-12-18 16:56:53 +08009890 wlan_radar_event->pdev_id = radar_event->pdev_id;
9891
9892 return QDF_STATUS_SUCCESS;
9893}
9894#else
9895static QDF_STATUS extract_wlan_radar_event_info_tlv(
9896 wmi_unified_t wmi_handle,
9897 uint8_t *evt_buf,
9898 struct radar_event_info *wlan_radar_event,
9899 uint32_t len)
9900{
9901 return QDF_STATUS_SUCCESS;
9902}
9903#endif
Arif Hussainbe58b4e2017-04-09 01:03:19 -07009904#endif
9905
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -07009906/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +05309907 * send_get_rcpi_cmd_tlv() - send request for rcpi value
9908 * @wmi_handle: wmi handle
9909 * @get_rcpi_param: rcpi params
9910 *
9911 * Return: QDF status
9912 */
9913static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
9914 struct rcpi_req *get_rcpi_param)
9915{
9916 wmi_buf_t buf;
9917 wmi_request_rcpi_cmd_fixed_param *cmd;
9918 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
9919
9920 buf = wmi_buf_alloc(wmi_handle, len);
9921 if (!buf) {
9922 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
9923 return QDF_STATUS_E_NOMEM;
9924 }
9925
9926 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
9927 WMITLV_SET_HDR(&cmd->tlv_header,
9928 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
9929 WMITLV_GET_STRUCT_TLVLEN
9930 (wmi_request_rcpi_cmd_fixed_param));
9931
9932 cmd->vdev_id = get_rcpi_param->vdev_id;
9933 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
9934 &cmd->peer_macaddr);
Tushnim Bhattacharyya9c8a9542018-03-28 13:05:48 -07009935
9936 switch (get_rcpi_param->measurement_type) {
9937
9938 case RCPI_MEASUREMENT_TYPE_AVG_MGMT:
9939 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
9940 break;
9941
9942 case RCPI_MEASUREMENT_TYPE_AVG_DATA:
9943 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA;
9944 break;
9945
9946 case RCPI_MEASUREMENT_TYPE_LAST_MGMT:
9947 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT;
9948 break;
9949
9950 case RCPI_MEASUREMENT_TYPE_LAST_DATA:
9951 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA;
9952 break;
9953
9954 default:
9955 /*
9956 * invalid rcpi measurement type, fall back to
9957 * RCPI_MEASUREMENT_TYPE_AVG_MGMT
9958 */
9959 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
9960 break;
9961 }
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +05309962 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +05309963 wmi_mtrace(WMI_REQUEST_RCPI_CMDID, cmd->vdev_id, 0);
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +05309964 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9965 WMI_REQUEST_RCPI_CMDID)) {
9966
9967 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
9968 __func__);
9969 wmi_buf_free(buf);
9970 return QDF_STATUS_E_FAILURE;
9971 }
9972
9973 return QDF_STATUS_SUCCESS;
9974}
9975
9976/**
9977 * extract_rcpi_response_event_tlv() - Extract RCPI event params
9978 * @wmi_handle: wmi handle
9979 * @evt_buf: pointer to event buffer
9980 * @res: pointer to hold rcpi response from firmware
9981 *
9982 * Return: QDF_STATUS_SUCCESS for successful event parse
Sathish Kumarefb25bf2018-10-02 11:03:59 +05309983 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +05309984 */
9985static QDF_STATUS
9986extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
9987 void *evt_buf, struct rcpi_res *res)
9988{
9989 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
9990 wmi_update_rcpi_event_fixed_param *event;
9991
9992 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
9993 if (!param_buf) {
9994 WMI_LOGE(FL("Invalid rcpi event"));
9995 return QDF_STATUS_E_INVAL;
9996 }
9997
9998 event = param_buf->fixed_param;
9999 res->vdev_id = event->vdev_id;
10000 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
10001
10002 switch (event->measurement_type) {
10003
10004 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
10005 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
10006 break;
10007
10008 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
10009 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
10010 break;
10011
10012 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
10013 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
10014 break;
10015
10016 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
10017 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
10018 break;
10019
10020 default:
10021 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
10022 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
10023 return QDF_STATUS_E_FAILURE;
10024 }
10025
10026 if (event->status)
10027 return QDF_STATUS_E_FAILURE;
10028 else
10029 return QDF_STATUS_SUCCESS;
10030}
10031
10032/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010033 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
Sathish Kumarefb25bf2018-10-02 11:03:59 +053010034 * host to target defines. For legacy there is not conversion
10035 * required. Just return pdev_id as it is.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010036 * @param pdev_id: host pdev_id to be converted.
10037 * Return: target pdev_id after conversion.
10038 */
10039static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
10040 uint32_t pdev_id)
10041{
10042 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
10043 return WMI_PDEV_ID_SOC;
10044
10045 /*No conversion required*/
10046 return pdev_id;
10047}
10048
10049/**
10050 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
Sathish Kumarefb25bf2018-10-02 11:03:59 +053010051 * target to host defines. For legacy there is not conversion
10052 * required. Just return pdev_id as it is.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010053 * @param pdev_id: target pdev_id to be converted.
10054 * Return: host pdev_id after conversion.
10055 */
10056static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
10057 uint32_t pdev_id)
10058{
10059 /*No conversion required*/
10060 return pdev_id;
10061}
10062
10063/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070010064 * send_set_country_cmd_tlv() - WMI scan channel list function
10065 * @param wmi_handle : handle to WMI.
10066 * @param param : pointer to hold scan channel list parameter
10067 *
10068 * Return: 0 on success and -ve on failure.
10069 */
10070static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
10071 struct set_country *params)
10072{
10073 wmi_buf_t buf;
10074 QDF_STATUS qdf_status;
10075 wmi_set_current_country_cmd_fixed_param *cmd;
10076 uint16_t len = sizeof(*cmd);
10077
10078 buf = wmi_buf_alloc(wmi_handle, len);
10079 if (!buf) {
10080 WMI_LOGE("Failed to allocate memory");
10081 qdf_status = QDF_STATUS_E_NOMEM;
10082 goto end;
10083 }
10084
10085 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
10086 WMITLV_SET_HDR(&cmd->tlv_header,
10087 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
10088 WMITLV_GET_STRUCT_TLVLEN
10089 (wmi_set_current_country_cmd_fixed_param));
10090
10091 WMI_LOGD("setting cuurnet country to %s", params->country);
10092
10093 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
10094
10095 cmd->pdev_id = params->pdev_id;
10096
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010097 wmi_mtrace(WMI_SET_CURRENT_COUNTRY_CMDID, NO_SESSION, 0);
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070010098 qdf_status = wmi_unified_cmd_send(wmi_handle,
10099 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
10100
10101 if (QDF_IS_STATUS_ERROR(qdf_status)) {
10102 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
10103 wmi_buf_free(buf);
10104 }
10105
10106end:
10107 return qdf_status;
10108}
10109
Sathish Kumarefb25bf2018-10-02 11:03:59 +053010110#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
Abhijit Pradhand38a2692017-06-29 12:32:20 +053010111 WMI_SET_BITS(alpha, 0, 8, val0); \
10112 WMI_SET_BITS(alpha, 8, 8, val1); \
10113 WMI_SET_BITS(alpha, 16, 8, val2); \
10114 } while (0)
10115
10116static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
10117 uint8_t pdev_id, struct cc_regdmn_s *rd)
10118{
10119 wmi_set_init_country_cmd_fixed_param *cmd;
10120 uint16_t len;
10121 wmi_buf_t buf;
10122 int ret;
10123
10124 len = sizeof(wmi_set_init_country_cmd_fixed_param);
10125 buf = wmi_buf_alloc(wmi_handle, len);
10126 if (!buf) {
10127 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
10128 return QDF_STATUS_E_NOMEM;
10129 }
10130 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
10131 WMITLV_SET_HDR(&cmd->tlv_header,
10132 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
10133 WMITLV_GET_STRUCT_TLVLEN
10134 (wmi_set_init_country_cmd_fixed_param));
10135
10136 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
10137
10138 if (rd->flags == CC_IS_SET) {
10139 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
10140 cmd->country_code.country_id = rd->cc.country_code;
10141 } else if (rd->flags == ALPHA_IS_SET) {
10142 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
10143 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
10144 rd->cc.alpha[0],
10145 rd->cc.alpha[1],
10146 rd->cc.alpha[2]);
10147 } else if (rd->flags == REGDMN_IS_SET) {
10148 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
10149 cmd->country_code.domain_code = rd->cc.regdmn_id;
10150 }
10151
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010152 wmi_mtrace(WMI_SET_INIT_COUNTRY_CMDID, NO_SESSION, 0);
Abhijit Pradhand38a2692017-06-29 12:32:20 +053010153 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10154 WMI_SET_INIT_COUNTRY_CMDID);
10155 if (ret) {
10156 WMI_LOGE("Failed to config wow wakeup event");
10157 wmi_buf_free(buf);
10158 return QDF_STATUS_E_FAILURE;
10159 }
10160
10161 return QDF_STATUS_SUCCESS;
10162}
10163
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053010164/**
Arif Hussainc5bfe072017-12-27 16:23:45 -080010165 * send_obss_detection_cfg_cmd_tlv() - send obss detection
10166 * configurations to firmware.
10167 * @wmi_handle: wmi handle
10168 * @obss_cfg_param: obss detection configurations
10169 *
10170 * Send WMI_SAP_OBSS_DETECTION_CFG_CMDID parameters to fw.
10171 *
10172 * Return: QDF_STATUS
10173 */
10174static QDF_STATUS send_obss_detection_cfg_cmd_tlv(wmi_unified_t wmi_handle,
10175 struct wmi_obss_detection_cfg_param *obss_cfg_param)
10176{
10177 wmi_buf_t buf;
10178 wmi_sap_obss_detection_cfg_cmd_fixed_param *cmd;
10179 uint8_t len = sizeof(wmi_sap_obss_detection_cfg_cmd_fixed_param);
10180
10181 buf = wmi_buf_alloc(wmi_handle, len);
10182 if (!buf) {
10183 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
10184 return QDF_STATUS_E_NOMEM;
10185 }
10186
10187 cmd = (wmi_sap_obss_detection_cfg_cmd_fixed_param *)wmi_buf_data(buf);
10188 WMITLV_SET_HDR(&cmd->tlv_header,
10189 WMITLV_TAG_STRUC_wmi_sap_obss_detection_cfg_cmd_fixed_param,
10190 WMITLV_GET_STRUCT_TLVLEN
10191 (wmi_sap_obss_detection_cfg_cmd_fixed_param));
10192
10193 cmd->vdev_id = obss_cfg_param->vdev_id;
10194 cmd->detect_period_ms = obss_cfg_param->obss_detect_period_ms;
10195 cmd->b_ap_detect_mode = obss_cfg_param->obss_11b_ap_detect_mode;
10196 cmd->b_sta_detect_mode = obss_cfg_param->obss_11b_sta_detect_mode;
10197 cmd->g_ap_detect_mode = obss_cfg_param->obss_11g_ap_detect_mode;
10198 cmd->a_detect_mode = obss_cfg_param->obss_11a_detect_mode;
10199 cmd->ht_legacy_detect_mode = obss_cfg_param->obss_ht_legacy_detect_mode;
10200 cmd->ht_mixed_detect_mode = obss_cfg_param->obss_ht_mixed_detect_mode;
10201 cmd->ht_20mhz_detect_mode = obss_cfg_param->obss_ht_20mhz_detect_mode;
Arif Hussainc5bfe072017-12-27 16:23:45 -080010202
Ashish Kumar Dhanotiya942a7862018-08-02 21:36:29 +053010203 wmi_mtrace(WMI_SAP_OBSS_DETECTION_CFG_CMDID, cmd->vdev_id, 0);
Arif Hussainc5bfe072017-12-27 16:23:45 -080010204 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10205 WMI_SAP_OBSS_DETECTION_CFG_CMDID)) {
10206 WMI_LOGE("Failed to send WMI_SAP_OBSS_DETECTION_CFG_CMDID");
10207 wmi_buf_free(buf);
10208 return QDF_STATUS_E_FAILURE;
10209 }
10210
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053010211 return QDF_STATUS_SUCCESS;
10212}
10213
Arif Hussain33d98502018-01-12 13:15:04 -080010214/**
10215 * extract_obss_detection_info_tlv() - Extract obss detection info
10216 * received from firmware.
10217 * @evt_buf: pointer to event buffer
10218 * @obss_detection: Pointer to hold obss detection info
10219 *
10220 * Return: QDF_STATUS
10221 */
10222static QDF_STATUS extract_obss_detection_info_tlv(uint8_t *evt_buf,
10223 struct wmi_obss_detect_info
10224 *obss_detection)
10225{
10226 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *param_buf;
10227 wmi_sap_obss_detection_info_evt_fixed_param *fix_param;
10228
10229 if (!obss_detection) {
10230 WMI_LOGE("%s: Invalid obss_detection event buffer", __func__);
10231 return QDF_STATUS_E_INVAL;
10232 }
10233
10234 param_buf = (WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *)evt_buf;
10235 if (!param_buf) {
10236 WMI_LOGE("%s: Invalid evt_buf", __func__);
10237 return QDF_STATUS_E_INVAL;
10238 }
10239
10240 fix_param = param_buf->fixed_param;
10241 obss_detection->vdev_id = fix_param->vdev_id;
10242 obss_detection->matched_detection_masks =
10243 fix_param->matched_detection_masks;
10244 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fix_param->matched_bssid_addr,
10245 &obss_detection->matched_bssid_addr[0]);
10246 switch (fix_param->reason) {
10247 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_NOT_SUPPORT:
10248 obss_detection->reason = OBSS_OFFLOAD_DETECTION_DISABLED;
10249 break;
10250 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_PRESENT_NOTIFY:
10251 obss_detection->reason = OBSS_OFFLOAD_DETECTION_PRESENT;
10252 break;
10253 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_ABSENT_TIMEOUT:
10254 obss_detection->reason = OBSS_OFFLOAD_DETECTION_ABSENT;
10255 break;
10256 default:
10257 WMI_LOGE("%s: Invalid reason %d", __func__, fix_param->reason);
10258 return QDF_STATUS_E_INVAL;
10259 }
10260
10261 return QDF_STATUS_SUCCESS;
10262}
10263
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053010264/**
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053010265 * send_roam_scan_stats_cmd_tlv() - Send roam scan stats req command to fw
10266 * @wmi_handle: wmi handle
10267 * @params: pointer to request structure
10268 *
10269 * Return: QDF_STATUS
10270 */
10271static QDF_STATUS
10272send_roam_scan_stats_cmd_tlv(wmi_unified_t wmi_handle,
10273 struct wmi_roam_scan_stats_req *params)
10274{
10275 wmi_buf_t buf;
10276 wmi_request_roam_scan_stats_cmd_fixed_param *cmd;
10277 WMITLV_TAG_ID tag;
10278 uint32_t size;
10279 uint32_t len = sizeof(*cmd);
10280
10281 buf = wmi_buf_alloc(wmi_handle, len);
10282 if (!buf) {
10283 WMI_LOGE(FL("Failed to allocate wmi buffer"));
10284 return QDF_STATUS_E_FAILURE;
10285 }
10286
10287 cmd = (wmi_request_roam_scan_stats_cmd_fixed_param *)wmi_buf_data(buf);
10288
10289 tag = WMITLV_TAG_STRUC_wmi_request_roam_scan_stats_cmd_fixed_param;
10290 size = WMITLV_GET_STRUCT_TLVLEN(
10291 wmi_request_roam_scan_stats_cmd_fixed_param);
10292 WMITLV_SET_HDR(&cmd->tlv_header, tag, size);
10293
10294 cmd->vdev_id = params->vdev_id;
10295
10296 WMI_LOGD(FL("Roam Scan Stats Req vdev_id: %u"), cmd->vdev_id);
10297 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10298 WMI_REQUEST_ROAM_SCAN_STATS_CMDID)) {
10299 WMI_LOGE("%s: Failed to send WMI_REQUEST_ROAM_SCAN_STATS_CMDID",
10300 __func__);
10301 wmi_buf_free(buf);
10302 return QDF_STATUS_E_FAILURE;
10303 }
10304
10305 return QDF_STATUS_SUCCESS;
10306}
10307
10308/**
10309 * extract_roam_scan_stats_res_evt_tlv() - Extract roam scan stats event
10310 * @wmi_handle: wmi handle
10311 * @evt_buf: pointer to event buffer
10312 * @vdev_id: output pointer to hold vdev id
10313 * @res_param: output pointer to hold the allocated response
10314 *
10315 * Return: QDF_STATUS
10316 */
10317static QDF_STATUS
10318extract_roam_scan_stats_res_evt_tlv(wmi_unified_t wmi_handle, void *evt_buf,
10319 uint32_t *vdev_id,
10320 struct wmi_roam_scan_stats_res **res_param)
10321{
10322 WMI_ROAM_SCAN_STATS_EVENTID_param_tlvs *param_buf;
10323 wmi_roam_scan_stats_event_fixed_param *fixed_param;
10324 uint32_t *client_id = NULL;
10325 wmi_roaming_timestamp *timestamp = NULL;
10326 uint32_t *num_channels = NULL;
10327 uint32_t *chan_info = NULL;
10328 wmi_mac_addr *old_bssid = NULL;
10329 uint32_t *is_roaming_success = NULL;
10330 wmi_mac_addr *new_bssid = NULL;
10331 uint32_t *num_roam_candidates = NULL;
10332 wmi_roam_scan_trigger_reason *roam_reason = NULL;
10333 wmi_mac_addr *bssid = NULL;
10334 uint32_t *score = NULL;
10335 uint32_t *channel = NULL;
10336 uint32_t *rssi = NULL;
10337 int chan_idx = 0, cand_idx = 0;
10338 uint32_t total_len;
10339 struct wmi_roam_scan_stats_res *res;
10340 uint32_t i, j;
10341 uint32_t num_scans;
10342
10343 *res_param = NULL;
10344 *vdev_id = 0xFF; /* Initialize to invalid vdev id */
10345 param_buf = (WMI_ROAM_SCAN_STATS_EVENTID_param_tlvs *)evt_buf;
10346 if (!param_buf) {
10347 WMI_LOGE(FL("Invalid roam scan stats event"));
10348 return QDF_STATUS_E_INVAL;
10349 }
10350
10351 fixed_param = param_buf->fixed_param;
10352 total_len = sizeof(*res) + fixed_param->num_roam_scans *
10353 sizeof(struct wmi_roam_scan_stats_params);
10354
10355 *vdev_id = fixed_param->vdev_id;
10356 num_scans = fixed_param->num_roam_scans;
10357
10358 res = qdf_mem_malloc(total_len);
10359 if (!res) {
10360 WMI_LOGE("Failed to allocate roam scan stats response memory");
10361 return QDF_STATUS_E_NOMEM;
10362 }
10363
10364 if (!num_scans) {
10365 *res_param = res;
10366 return QDF_STATUS_SUCCESS;
10367 }
10368
10369 if (param_buf->client_id &&
10370 param_buf->num_client_id == num_scans)
10371 client_id = param_buf->client_id;
10372
10373 if (param_buf->timestamp &&
10374 param_buf->num_timestamp == num_scans)
10375 timestamp = param_buf->timestamp;
10376
10377 if (param_buf->old_bssid &&
10378 param_buf->num_old_bssid == num_scans)
10379 old_bssid = param_buf->old_bssid;
10380
10381 if (param_buf->new_bssid &&
10382 param_buf->num_new_bssid == num_scans)
10383 new_bssid = param_buf->new_bssid;
10384
10385 if (param_buf->is_roaming_success &&
10386 param_buf->num_is_roaming_success == num_scans)
10387 is_roaming_success = param_buf->is_roaming_success;
10388
10389 if (param_buf->roam_reason &&
10390 param_buf->num_roam_reason == num_scans)
10391 roam_reason = param_buf->roam_reason;
10392
10393 if (param_buf->num_channels &&
10394 param_buf->num_num_channels == num_scans) {
10395 uint32_t count, chan_info_sum = 0;
10396
10397 num_channels = param_buf->num_channels;
10398 for (count = 0; count < param_buf->num_num_channels; count++)
10399 chan_info_sum += param_buf->num_channels[count];
10400
10401 if (param_buf->chan_info &&
10402 param_buf->num_chan_info == chan_info_sum)
10403 chan_info = param_buf->chan_info;
10404 }
10405
10406 if (param_buf->num_roam_candidates &&
10407 param_buf->num_num_roam_candidates == num_scans) {
10408 uint32_t count, roam_cand_sum = 0;
10409
10410 num_roam_candidates = param_buf->num_roam_candidates;
10411 for (count = 0; count < param_buf->num_num_roam_candidates;
10412 count++)
10413 roam_cand_sum += param_buf->num_roam_candidates[count];
10414
10415 if (param_buf->bssid &&
10416 param_buf->num_bssid == roam_cand_sum)
10417 bssid = param_buf->bssid;
10418
10419 if (param_buf->score &&
10420 param_buf->num_score == roam_cand_sum)
10421 score = param_buf->score;
10422
10423 if (param_buf->channel &&
10424 param_buf->num_channel == roam_cand_sum)
10425 channel = param_buf->channel;
10426
10427 if (param_buf->rssi &&
10428 param_buf->num_rssi == roam_cand_sum)
10429 rssi = param_buf->rssi;
10430 }
10431
10432 res->num_roam_scans = num_scans;
10433 for (i = 0; i < num_scans; i++) {
10434 struct wmi_roam_scan_stats_params *roam = &res->roam_scan[i];
10435
10436 if (timestamp)
10437 roam->time_stamp = timestamp[i].lower32bit |
10438 (timestamp[i].upper32bit << 31);
10439
10440 if (client_id)
10441 roam->client_id = client_id[i];
10442
10443 if (num_channels) {
10444 roam->num_scan_chans = num_channels[i];
10445 if (chan_info) {
10446 for (j = 0; j < num_channels[i]; j++)
10447 roam->scan_freqs[j] =
10448 chan_info[chan_idx++];
10449 }
10450 }
10451
10452 if (is_roaming_success)
10453 roam->is_roam_successful = is_roaming_success[i];
10454
10455 if (roam_reason) {
10456 roam->trigger_id = roam_reason[i].trigger_id;
10457 roam->trigger_value = roam_reason[i].trigger_value;
10458 }
10459
10460 if (num_roam_candidates) {
10461 roam->num_roam_candidates = num_roam_candidates[i];
10462
10463 for (j = 0; j < num_roam_candidates[i]; j++) {
10464 if (score)
10465 roam->cand[j].score = score[cand_idx];
10466 if (rssi)
10467 roam->cand[j].rssi = rssi[cand_idx];
10468 if (channel)
10469 roam->cand[j].freq =
10470 channel[cand_idx];
10471
10472 if (bssid)
10473 WMI_MAC_ADDR_TO_CHAR_ARRAY(
10474 &bssid[cand_idx],
10475 roam->cand[j].bssid);
10476
10477 cand_idx++;
10478 }
10479 }
10480
10481 if (old_bssid)
10482 WMI_MAC_ADDR_TO_CHAR_ARRAY(&old_bssid[i],
10483 roam->old_bssid);
10484
10485 if (new_bssid)
10486 WMI_MAC_ADDR_TO_CHAR_ARRAY(&new_bssid[i],
10487 roam->new_bssid);
10488 }
10489
10490 *res_param = res;
10491
10492 return QDF_STATUS_SUCCESS;
10493}
10494
10495/**
Gyanranjan Hazarikaff074e92018-10-04 11:26:20 -070010496 * extract_offload_bcn_tx_status_evt() - Extract beacon-tx status event
10497 * @wmi_handle: wmi handle
10498 * @evt_buf: pointer to event buffer
10499 * @vdev_id: output pointer to hold vdev id
10500 * @tx_status: output pointer to hold the tx_status
10501 *
10502 * Return: QDF_STATUS
10503 */
10504static QDF_STATUS extract_offload_bcn_tx_status_evt(wmi_unified_t wmi_handle,
10505 void *evt_buf,
10506 uint32_t *vdev_id,
10507 uint32_t *tx_status) {
10508 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID_param_tlvs *param_buf;
10509 wmi_offload_bcn_tx_status_event_fixed_param *bcn_tx_status_event;
10510
10511 param_buf = (WMI_OFFLOAD_BCN_TX_STATUS_EVENTID_param_tlvs *)evt_buf;
10512 if (!param_buf) {
10513 WMI_LOGE("Invalid offload bcn tx status event buffer");
10514 return QDF_STATUS_E_INVAL;
10515 }
10516
10517 bcn_tx_status_event = param_buf->fixed_param;
10518 *vdev_id = bcn_tx_status_event->vdev_id;
10519 *tx_status = bcn_tx_status_event->tx_status;
10520
10521 return QDF_STATUS_SUCCESS;
10522}
10523
Himanshu Agarwal157e4782018-01-24 22:24:17 +053010524#ifdef WLAN_SUPPORT_GREEN_AP
10525static QDF_STATUS extract_green_ap_egap_status_info_tlv(
10526 uint8_t *evt_buf,
10527 struct wlan_green_ap_egap_status_info *egap_status_info_params)
10528{
10529 WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *param_buf;
10530 wmi_ap_ps_egap_info_event_fixed_param *egap_info_event;
10531 wmi_ap_ps_egap_info_chainmask_list *chainmask_event;
10532
10533 param_buf = (WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *)evt_buf;
10534 if (!param_buf) {
10535 WMI_LOGE("Invalid EGAP Info status event buffer");
10536 return QDF_STATUS_E_INVAL;
10537 }
10538
10539 egap_info_event = (wmi_ap_ps_egap_info_event_fixed_param *)
10540 param_buf->fixed_param;
10541 chainmask_event = (wmi_ap_ps_egap_info_chainmask_list *)
10542 param_buf->chainmask_list;
10543
Ashish Kumar Dhanotiyaa90d8112018-10-17 16:45:54 +053010544 if (!egap_info_event || !chainmask_event) {
10545 WMI_LOGE("Invalid EGAP Info event or chainmask event");
10546 return QDF_STATUS_E_INVAL;
10547 }
10548
Himanshu Agarwal157e4782018-01-24 22:24:17 +053010549 egap_status_info_params->status = egap_info_event->status;
10550 egap_status_info_params->mac_id = chainmask_event->mac_id;
10551 egap_status_info_params->tx_chainmask = chainmask_event->tx_chainmask;
10552 egap_status_info_params->rx_chainmask = chainmask_event->rx_chainmask;
10553
10554 return QDF_STATUS_SUCCESS;
10555}
10556#endif
10557
Arif Hussainec5cd3c2018-01-22 01:19:36 -080010558/*
Arif Hussaine0eb7302018-03-01 14:40:59 -080010559 * extract_comb_phyerr_tlv() - extract comb phy error from event
10560 * @wmi_handle: wmi handle
10561 * @evt_buf: pointer to event buffer
10562 * @datalen: data length of event buffer
10563 * @buf_offset: Pointer to hold value of current event buffer offset
10564 * post extraction
10565 * @phyerr: Pointer to hold phyerr
10566 *
10567 * Return: QDF_STATUS
10568 */
10569static QDF_STATUS extract_comb_phyerr_tlv(wmi_unified_t wmi_handle,
10570 void *evt_buf,
10571 uint16_t datalen,
10572 uint16_t *buf_offset,
10573 wmi_host_phyerr_t *phyerr)
10574{
10575 WMI_PHYERR_EVENTID_param_tlvs *param_tlvs;
10576 wmi_comb_phyerr_rx_hdr *pe_hdr;
10577
10578 param_tlvs = (WMI_PHYERR_EVENTID_param_tlvs *)evt_buf;
10579 if (!param_tlvs) {
10580 WMI_LOGD("%s: Received null data from FW", __func__);
10581 return QDF_STATUS_E_FAILURE;
10582 }
10583
10584 pe_hdr = param_tlvs->hdr;
10585 if (!pe_hdr) {
10586 WMI_LOGD("%s: Received Data PE Header is NULL", __func__);
10587 return QDF_STATUS_E_FAILURE;
10588 }
10589
10590 /* Ensure it's at least the size of the header */
10591 if (datalen < sizeof(*pe_hdr)) {
10592 WMI_LOGD("%s: Expected minimum size %zu, received %d",
10593 __func__, sizeof(*pe_hdr), datalen);
10594 return QDF_STATUS_E_FAILURE;
10595 }
10596
10597 phyerr->pdev_id = wmi_handle->ops->
10598 convert_pdev_id_target_to_host(pe_hdr->pdev_id);
10599 phyerr->tsf64 = pe_hdr->tsf_l32;
10600 phyerr->tsf64 |= (((uint64_t)pe_hdr->tsf_u32) << 32);
10601 phyerr->bufp = param_tlvs->bufp;
Yeshwanth Sriram Guntuka19e51be2018-09-25 15:40:08 +053010602
10603 if (pe_hdr->buf_len > param_tlvs->num_bufp) {
10604 WMI_LOGD("Invalid buf_len %d, num_bufp %d",
10605 pe_hdr->buf_len, param_tlvs->num_bufp);
10606 return QDF_STATUS_E_FAILURE;
10607 }
10608
Arif Hussaine0eb7302018-03-01 14:40:59 -080010609 phyerr->buf_len = pe_hdr->buf_len;
10610 phyerr->phy_err_mask0 = pe_hdr->rsPhyErrMask0;
10611 phyerr->phy_err_mask1 = pe_hdr->rsPhyErrMask1;
10612 *buf_offset = sizeof(*pe_hdr) + sizeof(uint32_t);
10613
10614 return QDF_STATUS_SUCCESS;
10615}
10616
10617/**
10618 * extract_single_phyerr_tlv() - extract single phy error from event
10619 * @wmi_handle: wmi handle
10620 * @evt_buf: pointer to event buffer
10621 * @datalen: data length of event buffer
10622 * @buf_offset: Pointer to hold value of current event buffer offset
10623 * post extraction
10624 * @phyerr: Pointer to hold phyerr
10625 *
10626 * Return: QDF_STATUS
10627 */
10628static QDF_STATUS extract_single_phyerr_tlv(wmi_unified_t wmi_handle,
10629 void *evt_buf,
10630 uint16_t datalen,
10631 uint16_t *buf_offset,
10632 wmi_host_phyerr_t *phyerr)
10633{
10634 wmi_single_phyerr_rx_event *ev;
10635 uint16_t n = *buf_offset;
10636 uint8_t *data = (uint8_t *)evt_buf;
10637
10638 if (n < datalen) {
10639 if ((datalen - n) < sizeof(ev->hdr)) {
10640 WMI_LOGD("%s: Not enough space. len=%d, n=%d, hdr=%zu",
10641 __func__, datalen, n, sizeof(ev->hdr));
10642 return QDF_STATUS_E_FAILURE;
10643 }
10644
10645 /*
10646 * Obtain a pointer to the beginning of the current event.
10647 * data[0] is the beginning of the WMI payload.
10648 */
10649 ev = (wmi_single_phyerr_rx_event *)&data[n];
10650
10651 /*
10652 * Sanity check the buffer length of the event against
10653 * what we currently have.
10654 *
10655 * Since buf_len is 32 bits, we check if it overflows
10656 * a large 32 bit value. It's not 0x7fffffff because
10657 * we increase n by (buf_len + sizeof(hdr)), which would
10658 * in itself cause n to overflow.
10659 *
10660 * If "int" is 64 bits then this becomes a moot point.
10661 */
10662 if (ev->hdr.buf_len > PHYERROR_MAX_BUFFER_LENGTH) {
10663 WMI_LOGD("%s: buf_len is garbage 0x%x",
10664 __func__, ev->hdr.buf_len);
10665 return QDF_STATUS_E_FAILURE;
10666 }
10667
10668 if ((n + ev->hdr.buf_len) > datalen) {
10669 WMI_LOGD("%s: len exceeds n=%d, buf_len=%d, datalen=%d",
10670 __func__, n, ev->hdr.buf_len, datalen);
10671 return QDF_STATUS_E_FAILURE;
10672 }
10673
10674 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
10675 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
10676 phyerr->bufp = &ev->bufp[0];
10677 phyerr->buf_len = ev->hdr.buf_len;
10678 phyerr->rf_info.rssi_comb = WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
10679
10680 /*
10681 * Advance the buffer pointer to the next PHY error.
10682 * buflen is the length of this payload, so we need to
10683 * advance past the current header _AND_ the payload.
10684 */
10685 n += sizeof(*ev) + ev->hdr.buf_len;
10686 }
10687 *buf_offset = n;
10688
10689 return QDF_STATUS_SUCCESS;
10690}
10691
Subrat Mishraa667b1c2018-08-02 15:02:04 +053010692/**
10693 * extract_esp_estimation_ev_param_tlv() - extract air time from event
10694 * @wmi_handle: wmi handle
10695 * @evt_buf: pointer to event buffer
10696 * @param: Pointer to hold esp event
10697 *
10698 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_INVAL on failure
10699 */
10700static QDF_STATUS
10701extract_esp_estimation_ev_param_tlv(wmi_unified_t wmi_handle,
10702 void *evt_buf,
10703 struct esp_estimation_event *param)
10704{
10705 WMI_ESP_ESTIMATE_EVENTID_param_tlvs *param_buf;
10706 wmi_esp_estimate_event_fixed_param *esp_event;
10707
10708 param_buf = (WMI_ESP_ESTIMATE_EVENTID_param_tlvs *)evt_buf;
10709 if (!param_buf) {
10710 WMI_LOGE("Invalid ESP Estimate Event buffer");
10711 return QDF_STATUS_E_INVAL;
10712 }
10713 esp_event = param_buf->fixed_param;
10714 param->ac_airtime_percentage = esp_event->ac_airtime_percentage;
10715 param->pdev_id = convert_target_pdev_id_to_host_pdev_id(
10716 esp_event->pdev_id);
10717
10718 return QDF_STATUS_SUCCESS;
10719}
10720
Qiwei Cai3d26b2e2018-09-17 19:17:13 +080010721/*
10722 * send_bss_color_change_enable_cmd_tlv() - Send command to enable or disable of
10723 * updating bss color change within firmware when AP announces bss color change.
10724 * @wmi_handle: wmi handle
10725 * @vdev_id: vdev ID
10726 * @enable: enable bss color change within firmware
10727 *
10728 * Send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID parameters to fw.
10729 *
10730 * Return: QDF_STATUS
10731 */
10732static QDF_STATUS send_bss_color_change_enable_cmd_tlv(wmi_unified_t wmi_handle,
10733 uint32_t vdev_id,
10734 bool enable)
10735{
10736 wmi_buf_t buf;
10737 wmi_bss_color_change_enable_fixed_param *cmd;
10738 uint8_t len = sizeof(wmi_bss_color_change_enable_fixed_param);
10739
10740 buf = wmi_buf_alloc(wmi_handle, len);
10741 if (!buf) {
10742 return QDF_STATUS_E_NOMEM;
10743 }
10744
10745 cmd = (wmi_bss_color_change_enable_fixed_param *)wmi_buf_data(buf);
10746 WMITLV_SET_HDR(&cmd->tlv_header,
10747 WMITLV_TAG_STRUC_wmi_bss_color_change_enable_fixed_param,
10748 WMITLV_GET_STRUCT_TLVLEN
10749 (wmi_bss_color_change_enable_fixed_param));
10750 cmd->vdev_id = vdev_id;
10751 cmd->enable = enable;
10752 wmi_mtrace(WMI_BSS_COLOR_CHANGE_ENABLE_CMDID, cmd->vdev_id, 0);
10753 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10754 WMI_BSS_COLOR_CHANGE_ENABLE_CMDID)) {
10755 WMI_LOGE("Failed to send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID");
10756 wmi_buf_free(buf);
10757 return QDF_STATUS_E_FAILURE;
10758 }
10759
10760 return QDF_STATUS_SUCCESS;
10761}
10762
10763/**
10764 * send_obss_color_collision_cfg_cmd_tlv() - send bss color detection
10765 * configurations to firmware.
10766 * @wmi_handle: wmi handle
10767 * @cfg_param: obss detection configurations
10768 *
10769 * Send WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID parameters to fw.
10770 *
10771 * Return: QDF_STATUS
10772 */
10773static QDF_STATUS send_obss_color_collision_cfg_cmd_tlv(
10774 wmi_unified_t wmi_handle,
10775 struct wmi_obss_color_collision_cfg_param *cfg_param)
10776{
10777 wmi_buf_t buf;
10778 wmi_obss_color_collision_det_config_fixed_param *cmd;
10779 uint8_t len = sizeof(wmi_obss_color_collision_det_config_fixed_param);
10780
10781 buf = wmi_buf_alloc(wmi_handle, len);
10782 if (!buf) {
10783 return QDF_STATUS_E_NOMEM;
10784 }
10785
10786 cmd = (wmi_obss_color_collision_det_config_fixed_param *)wmi_buf_data(
10787 buf);
10788 WMITLV_SET_HDR(&cmd->tlv_header,
10789 WMITLV_TAG_STRUC_wmi_obss_color_collision_det_config_fixed_param,
10790 WMITLV_GET_STRUCT_TLVLEN
10791 (wmi_obss_color_collision_det_config_fixed_param));
10792 cmd->vdev_id = cfg_param->vdev_id;
10793 cmd->flags = cfg_param->flags;
10794 cmd->current_bss_color = cfg_param->current_bss_color;
10795 cmd->detection_period_ms = cfg_param->detection_period_ms;
10796 cmd->scan_period_ms = cfg_param->scan_period_ms;
10797 cmd->free_slot_expiry_time_ms = cfg_param->free_slot_expiry_time_ms;
10798
10799 switch (cfg_param->evt_type) {
10800 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
10801 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DISABLE;
10802 break;
10803 case OBSS_COLOR_COLLISION_DETECTION:
10804 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DETECTION;
10805 break;
10806 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
10807 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
10808 break;
10809 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
10810 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_AVAILABLE;
10811 break;
10812 default:
10813 WMI_LOGE("%s: invalid event type: %d",
10814 __func__, cfg_param->evt_type);
10815 wmi_buf_free(buf);
10816 return QDF_STATUS_E_FAILURE;
10817 }
10818
10819 WMI_LOGD("%s: evt_type: %d vdev id: %d current_bss_color: %d\n"
10820 "detection_period_ms: %d scan_period_ms: %d\n"
10821 "free_slot_expiry_timer_ms: %d",
10822 __func__, cmd->evt_type, cmd->vdev_id, cmd->current_bss_color,
10823 cmd->detection_period_ms, cmd->scan_period_ms,
10824 cmd->free_slot_expiry_time_ms);
10825
10826 wmi_mtrace(WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID, cmd->vdev_id, 0);
10827 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10828 WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID)) {
10829 WMI_LOGE("%s: Sending OBSS color det cmd failed, vdev_id: %d",
10830 __func__, cfg_param->vdev_id);
10831 wmi_buf_free(buf);
10832 return QDF_STATUS_E_FAILURE;
10833 }
10834
10835 return QDF_STATUS_SUCCESS;
10836}
10837
10838/**
10839 * extract_obss_color_collision_info_tlv() - Extract bss color collision info
10840 * received from firmware.
10841 * @evt_buf: pointer to event buffer
10842 * @info: Pointer to hold bss collision info
10843 *
10844 * Return: QDF_STATUS
10845 */
10846static QDF_STATUS extract_obss_color_collision_info_tlv(uint8_t *evt_buf,
10847 struct wmi_obss_color_collision_info *info)
10848{
10849 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *param_buf;
10850 wmi_obss_color_collision_evt_fixed_param *fix_param;
10851
10852 if (!info) {
10853 WMI_LOGE("%s: Invalid obss color buffer", __func__);
10854 return QDF_STATUS_E_INVAL;
10855 }
10856
10857 param_buf = (WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *)
10858 evt_buf;
10859 if (!param_buf) {
10860 WMI_LOGE("%s: Invalid evt_buf", __func__);
10861 return QDF_STATUS_E_INVAL;
10862 }
10863
10864 fix_param = param_buf->fixed_param;
10865 info->vdev_id = fix_param->vdev_id;
10866 info->obss_color_bitmap_bit0to31 =
10867 fix_param->bss_color_bitmap_bit0to31;
10868 info->obss_color_bitmap_bit32to63 =
10869 fix_param->bss_color_bitmap_bit32to63;
10870
10871 switch (fix_param->evt_type) {
10872 case WMI_BSS_COLOR_COLLISION_DISABLE:
10873 info->evt_type = OBSS_COLOR_COLLISION_DETECTION_DISABLE;
10874 break;
10875 case WMI_BSS_COLOR_COLLISION_DETECTION:
10876 info->evt_type = OBSS_COLOR_COLLISION_DETECTION;
10877 break;
10878 case WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
10879 info->evt_type = OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
10880 break;
10881 case WMI_BSS_COLOR_FREE_SLOT_AVAILABLE:
10882 info->evt_type = OBSS_COLOR_FREE_SLOT_AVAILABLE;
10883 break;
10884 default:
10885 WMI_LOGE("%s: invalid event type: %d, vdev_id: %d",
10886 __func__, fix_param->evt_type, fix_param->vdev_id);
10887 return QDF_STATUS_E_FAILURE;
10888 }
10889
10890 return QDF_STATUS_SUCCESS;
10891}
10892
10893static void wmi_11ax_bss_color_attach_tlv(struct wmi_unified *wmi_handle)
10894{
10895 struct wmi_ops *ops = wmi_handle->ops;
10896
10897 ops->send_obss_color_collision_cfg_cmd =
10898 send_obss_color_collision_cfg_cmd_tlv;
10899 ops->extract_obss_color_collision_info =
10900 extract_obss_color_collision_info_tlv;
10901}
10902
Govind Singh5eb51532016-03-09 11:34:12 +053010903struct wmi_ops tlv_ops = {
10904 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
10905 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
10906 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053010907 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
10908 .send_hidden_ssid_vdev_restart_cmd =
10909 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053010910 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
10911 .send_peer_param_cmd = send_peer_param_cmd_tlv,
10912 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053010913 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053010914 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053010915 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070010916 .send_peer_rx_reorder_queue_setup_cmd =
10917 send_peer_rx_reorder_queue_setup_cmd_tlv,
10918 .send_peer_rx_reorder_queue_remove_cmd =
10919 send_peer_rx_reorder_queue_remove_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053010920 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
10921 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
10922 .send_suspend_cmd = send_suspend_cmd_tlv,
10923 .send_resume_cmd = send_resume_cmd_tlv,
10924 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
10925 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
10926 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
10927 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080010928#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +053010929 .send_dbglog_cmd = send_dbglog_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080010930#endif
Govind Singh5eb51532016-03-09 11:34:12 +053010931 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
10932 .send_stats_request_cmd = send_stats_request_cmd_tlv,
10933 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
gaurank kathpaliacdfb4452018-02-21 18:58:29 +053010934 .send_time_stamp_sync_cmd = send_time_stamp_sync_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070010935 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053010936 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053010937 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
10938 .send_scan_start_cmd = send_scan_start_cmd_tlv,
10939 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
10940 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053010941 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053010942 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053010943 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
10944 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053010945 .send_set_sta_uapsd_auto_trig_cmd =
10946 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053010947 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053010948 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
10949 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053010950 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
10951 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053010952 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053010953 .send_probe_rsp_tmpl_send_cmd =
10954 send_probe_rsp_tmpl_send_cmd_tlv,
10955 .send_p2p_go_set_beacon_ie_cmd =
10956 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053010957 .send_setup_install_key_cmd =
10958 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053010959 .send_scan_probe_setoui_cmd =
10960 send_scan_probe_setoui_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053010961#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +053010962 .send_ipa_offload_control_cmd =
10963 send_ipa_offload_control_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053010964#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053010965 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
10966 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070010967 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080010968#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +053010969 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
10970 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
10971 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080010972#endif /* WLAN_FEATURE_LINK_LAYER_STATS*/
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053010973 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053010974 .send_snr_request_cmd = send_snr_request_cmd_tlv,
10975 .send_snr_cmd = send_snr_cmd_tlv,
10976 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053010977#ifdef CONFIG_MCL
Govind Singh87542482016-06-08 19:40:11 +053010978 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053010979#ifndef REMOVE_PKT_LOG
Govind Singh87542482016-06-08 19:40:11 +053010980 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053010981#endif
Govind Singh87542482016-06-08 19:40:11 +053010982#endif
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053010983#ifdef WLAN_SUPPORT_GREEN_AP
10984 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
10985 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
Himanshu Agarwal157e4782018-01-24 22:24:17 +053010986 .extract_green_ap_egap_status_info =
10987 extract_green_ap_egap_status_info_tlv,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053010988#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053010989 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053010990 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070010991#ifdef WLAN_FEATURE_CIF_CFR
10992 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
10993#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053010994 .send_dfs_phyerr_filter_offload_en_cmd =
10995 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053010996 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053010997 .send_process_dhcpserver_offload_cmd =
10998 send_process_dhcpserver_offload_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053010999 .send_pdev_set_regdomain_cmd =
11000 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053011001 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053011002 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011003 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053011004 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053011005 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
11006 .send_enable_specific_fw_logs_cmd =
11007 send_enable_specific_fw_logs_cmd_tlv,
11008 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053011009 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053011010 .send_unit_test_cmd = send_unit_test_cmd_tlv,
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053011011#ifdef FEATURE_WLAN_APF
11012 .send_set_active_apf_mode_cmd = wmi_send_set_active_apf_mode_cmd_tlv,
11013 .send_apf_enable_cmd = wmi_send_apf_enable_cmd_tlv,
11014 .send_apf_write_work_memory_cmd =
11015 wmi_send_apf_write_work_memory_cmd_tlv,
11016 .send_apf_read_work_memory_cmd =
11017 wmi_send_apf_read_work_memory_cmd_tlv,
11018 .extract_apf_read_memory_resp_event =
11019 wmi_extract_apf_read_memory_resp_event_tlv,
11020#endif /* FEATURE_WLAN_APF */
Govind Singhe7f2f342016-05-23 12:12:52 +053011021 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053011022 .send_vdev_set_custom_aggr_size_cmd =
11023 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053011024 .send_vdev_set_qdepth_thresh_cmd =
11025 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053011026 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053011027 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011028 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
11029 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053011030 .send_periodic_chan_stats_config_cmd =
11031 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011032 .send_vdev_spectral_configure_cmd =
11033 send_vdev_spectral_configure_cmd_tlv,
11034 .send_vdev_spectral_enable_cmd =
11035 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011036 .send_thermal_mitigation_param_cmd =
11037 send_thermal_mitigation_param_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053011038 .send_process_update_edca_param_cmd =
11039 send_process_update_edca_param_cmd_tlv,
Qiwei Cai3d26b2e2018-09-17 19:17:13 +080011040 .send_bss_color_change_enable_cmd =
11041 send_bss_color_change_enable_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053011042 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070011043 .send_set_country_cmd = send_set_country_cmd_tlv,
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080011044 .send_addba_send_cmd = send_addba_send_cmd_tlv,
11045 .send_delba_send_cmd = send_delba_send_cmd_tlv,
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080011046 .send_addba_clearresponse_cmd = send_addba_clearresponse_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011047 .get_target_cap_from_service_ready = extract_service_ready_tlv,
11048 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
11049 .extract_host_mem_req = extract_host_mem_req_tlv,
11050 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053011051 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011052 .is_service_enabled = is_service_enabled_tlv,
11053 .save_fw_version = save_fw_version_in_service_ready_tlv,
11054 .ready_extract_init_status = ready_extract_init_status_tlv,
11055 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070011056 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053011057 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011058 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011059 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011060 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
11061 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011062 .extract_all_stats_count = extract_all_stats_counts_tlv,
11063 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070011064 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011065 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
11066 .extract_vdev_stats = extract_vdev_stats_tlv,
Naveen Rawatd2115722018-04-12 08:17:55 -070011067 .extract_per_chain_rssi_stats = extract_per_chain_rssi_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011068 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053011069 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053011070 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
11071 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
11072 .extract_chan_stats = extract_chan_stats_tlv,
11073 .extract_profile_ctx = extract_profile_ctx_tlv,
11074 .extract_profile_data = extract_profile_data_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053011075 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053011076 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053011077 .extract_service_ready_ext = extract_service_ready_ext_tlv,
11078 .extract_hw_mode_cap_service_ready_ext =
11079 extract_hw_mode_cap_service_ready_ext_tlv,
11080 .extract_mac_phy_cap_service_ready_ext =
11081 extract_mac_phy_cap_service_ready_ext_tlv,
11082 .extract_reg_cap_service_ready_ext =
11083 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053011084 .extract_dbr_ring_cap_service_ready_ext =
11085 extract_dbr_ring_cap_service_ready_ext_tlv,
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070011086 .extract_sar_cap_service_ready_ext =
11087 extract_sar_cap_service_ready_ext_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053011088 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053011089 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053011090 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053011091 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053011092 .is_management_record = is_management_record_tlv,
Rajeev Kumarb64e1282018-09-19 13:02:23 -070011093 .is_diag_event = is_diag_event_tlv,
Rajeev Kumar Sirasanagandladaadf832017-09-18 16:47:52 +053011094#ifdef WLAN_FEATURE_ACTION_OUI
11095 .send_action_oui_cmd = send_action_oui_cmd_tlv,
11096#endif
Arif Hussainf00be1d2017-01-07 18:21:55 -080011097 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
11098 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053011099 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053011100 extract_reg_chan_list_update_event_tlv,
11101 .extract_chainmask_tables =
11102 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011103 .extract_thermal_stats = extract_thermal_stats_tlv,
11104 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053011105 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
11106 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070011107#ifdef DFS_COMPONENT_ENABLE
11108 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
11109 .extract_dfs_radar_detection_event =
11110 extract_dfs_radar_detection_event_tlv,
bings1ea12532017-12-18 16:56:53 +080011111 .extract_wlan_radar_event_info = extract_wlan_radar_event_info_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070011112#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011113 .convert_pdev_id_host_to_target =
11114 convert_host_pdev_id_to_target_pdev_id_legacy,
11115 .convert_pdev_id_target_to_host =
11116 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070011117
11118 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
11119 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
11120 .extract_reg_11d_new_country_event =
11121 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053011122 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070011123 .extract_reg_ch_avoid_event =
11124 extract_reg_ch_avoid_event_tlv,
Arif Hussainc5bfe072017-12-27 16:23:45 -080011125 .send_obss_detection_cfg_cmd = send_obss_detection_cfg_cmd_tlv,
Arif Hussain33d98502018-01-12 13:15:04 -080011126 .extract_obss_detection_info = extract_obss_detection_info_tlv,
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053011127 .wmi_pdev_id_conversion_enable = wmi_tlv_pdev_id_conversion_enable,
11128 .wmi_free_allocated_event = wmitlv_free_allocated_event_tlvs,
11129 .wmi_check_and_pad_event = wmitlv_check_and_pad_event_tlvs,
11130 .wmi_check_command_params = wmitlv_check_command_tlv_params,
Arif Hussaine0eb7302018-03-01 14:40:59 -080011131 .extract_comb_phyerr = extract_comb_phyerr_tlv,
11132 .extract_single_phyerr = extract_single_phyerr_tlv,
Naveen Rawat963ee942018-04-13 16:38:36 -070011133#ifdef QCA_SUPPORT_CP_STATS
11134 .extract_cca_stats = extract_cca_stats_tlv,
11135#endif
Subrat Mishraa667b1c2018-08-02 15:02:04 +053011136 .extract_esp_estimation_ev_param =
11137 extract_esp_estimation_ev_param_tlv,
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053011138 .send_roam_scan_stats_cmd = send_roam_scan_stats_cmd_tlv,
11139 .extract_roam_scan_stats_res_evt = extract_roam_scan_stats_res_evt_tlv,
Pratik Gandhi3fd97d62018-09-17 16:47:12 +053011140#ifdef OBSS_PD
11141 .send_obss_spatial_reuse_set = send_obss_spatial_reuse_set_cmd_tlv,
11142#endif
Gyanranjan Hazarikaff074e92018-10-04 11:26:20 -070011143 .extract_offload_bcn_tx_status_evt = extract_offload_bcn_tx_status_evt,
Alok Singh0243e7d2018-09-20 16:07:28 +053011144 .extract_ctl_failsafe_check_ev_param =
11145 extract_ctl_failsafe_check_ev_param_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053011146};
11147
Govind Singhe7f2f342016-05-23 12:12:52 +053011148/**
11149 * populate_tlv_event_id() - populates wmi event ids
11150 *
11151 * @param event_ids: Pointer to hold event ids
11152 * Return: None
11153 */
11154static void populate_tlv_events_id(uint32_t *event_ids)
11155{
11156 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
11157 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
11158 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
11159 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
11160 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
11161 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
11162 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
11163 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
11164 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
11165 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
11166 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
11167 event_ids[wmi_service_ready_ext_event_id] =
11168 WMI_SERVICE_READY_EXT_EVENTID;
11169 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
11170 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
11171 event_ids[wmi_vdev_install_key_complete_event_id] =
11172 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
11173 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
11174 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
11175
11176 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
11177 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
11178 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
11179 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
11180 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
11181 event_ids[wmi_peer_estimated_linkspeed_event_id] =
11182 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
11183 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053011184 event_ids[wmi_peer_delete_response_event_id] =
11185 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011186 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
11187 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
11188 event_ids[wmi_tbttoffset_update_event_id] =
11189 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053011190 event_ids[wmi_ext_tbttoffset_update_event_id] =
11191 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011192 event_ids[wmi_offload_bcn_tx_status_event_id] =
11193 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
11194 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
11195 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
11196 event_ids[wmi_mgmt_tx_completion_event_id] =
11197 WMI_MGMT_TX_COMPLETION_EVENTID;
nobeljf74583b2018-01-25 16:35:36 -080011198 event_ids[wmi_pdev_nfcal_power_all_channels_event_id] =
11199 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011200 event_ids[wmi_tx_delba_complete_event_id] =
11201 WMI_TX_DELBA_COMPLETE_EVENTID;
11202 event_ids[wmi_tx_addba_complete_event_id] =
11203 WMI_TX_ADDBA_COMPLETE_EVENTID;
11204 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
11205
11206 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
11207
11208 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
11209 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
11210
11211 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053011212 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011213
11214 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
11215
11216 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080011217 event_ids[wmi_p2p_lo_stop_event_id] =
11218 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011219 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
11220 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080011221 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053011222 WMI_D0_WOW_DISABLE_ACK_EVENTID;
11223 event_ids[wmi_wow_initial_wakeup_event_id] =
11224 WMI_WOW_INITIAL_WAKEUP_EVENTID;
11225
11226 event_ids[wmi_rtt_meas_report_event_id] =
11227 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
11228 event_ids[wmi_tsf_meas_report_event_id] =
11229 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
11230 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
11231 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
11232 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
11233 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
11234 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011235 event_ids[wmi_diag_event_id_log_supported_event_id] =
11236 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
11237 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
11238 event_ids[wmi_nlo_scan_complete_event_id] =
11239 WMI_NLO_SCAN_COMPLETE_EVENTID;
11240 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
11241 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
11242
11243 event_ids[wmi_gtk_offload_status_event_id] =
11244 WMI_GTK_OFFLOAD_STATUS_EVENTID;
11245 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
11246 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
11247 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
11248
11249 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
11250
11251 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
11252
11253 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
11254 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
11255 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
11256 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
11257 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
11258 event_ids[wmi_wlan_profile_data_event_id] =
11259 WMI_WLAN_PROFILE_DATA_EVENTID;
11260 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
11261 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
11262 event_ids[wmi_vdev_get_keepalive_event_id] =
11263 WMI_VDEV_GET_KEEPALIVE_EVENTID;
11264 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
11265
11266 event_ids[wmi_diag_container_event_id] =
11267 WMI_DIAG_DATA_CONTAINER_EVENTID;
11268
11269 event_ids[wmi_host_auto_shutdown_event_id] =
11270 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
11271
11272 event_ids[wmi_update_whal_mib_stats_event_id] =
11273 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
11274
11275 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
11276 event_ids[wmi_update_vdev_rate_stats_event_id] =
11277 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
11278
11279 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070011280 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011281
11282 /** Set OCB Sched Response, deprecated */
11283 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
11284
11285 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
11286 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
11287 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
11288
11289 /* GPIO Event */
11290 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
11291 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
11292
11293 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
11294 event_ids[wmi_rfkill_state_change_event_id] =
11295 WMI_RFKILL_STATE_CHANGE_EVENTID;
11296
11297 /* TDLS Event */
11298 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
11299
11300 event_ids[wmi_batch_scan_enabled_event_id] =
11301 WMI_BATCH_SCAN_ENABLED_EVENTID;
11302 event_ids[wmi_batch_scan_result_event_id] =
11303 WMI_BATCH_SCAN_RESULT_EVENTID;
11304 /* OEM Event */
11305 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
11306 event_ids[wmi_oem_meas_report_event_id] =
11307 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
11308 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
11309
11310 /* NAN Event */
11311 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
11312
11313 /* LPI Event */
11314 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
11315 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
11316 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
11317
11318 /* ExtScan events */
11319 event_ids[wmi_extscan_start_stop_event_id] =
11320 WMI_EXTSCAN_START_STOP_EVENTID;
11321 event_ids[wmi_extscan_operation_event_id] =
11322 WMI_EXTSCAN_OPERATION_EVENTID;
11323 event_ids[wmi_extscan_table_usage_event_id] =
11324 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
11325 event_ids[wmi_extscan_cached_results_event_id] =
11326 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
11327 event_ids[wmi_extscan_wlan_change_results_event_id] =
11328 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
11329 event_ids[wmi_extscan_hotlist_match_event_id] =
11330 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
11331 event_ids[wmi_extscan_capabilities_event_id] =
11332 WMI_EXTSCAN_CAPABILITIES_EVENTID;
11333 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
11334 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
11335
11336 /* mDNS offload events */
11337 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
11338
11339 /* SAP Authentication offload events */
11340 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
11341 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
11342
11343 /** Out-of-context-of-bss (OCB) events */
11344 event_ids[wmi_ocb_set_config_resp_event_id] =
11345 WMI_OCB_SET_CONFIG_RESP_EVENTID;
11346 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
11347 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
11348 event_ids[wmi_dcc_get_stats_resp_event_id] =
11349 WMI_DCC_GET_STATS_RESP_EVENTID;
11350 event_ids[wmi_dcc_update_ndl_resp_event_id] =
11351 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
11352 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
11353 /* System-On-Chip events */
11354 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
11355 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
11356 event_ids[wmi_soc_hw_mode_transition_event_id] =
11357 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
11358 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
11359 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053011360 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053011361 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
11362 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053011363 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053011364 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
11365 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
11366 event_ids[wmi_peer_sta_ps_statechg_event_id] =
11367 WMI_PEER_STA_PS_STATECHG_EVENTID;
11368 event_ids[wmi_pdev_channel_hopping_event_id] =
11369 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053011370 event_ids[wmi_offchan_data_tx_completion_event] =
11371 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070011372 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
11373 event_ids[wmi_dfs_radar_detection_event_id] =
11374 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011375 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070011376 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053011377 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053011378 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053011379 event_ids[wmi_service_available_event_id] =
11380 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053011381 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053011382 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053011383 /* NDP events */
11384 event_ids[wmi_ndp_initiator_rsp_event_id] =
11385 WMI_NDP_INITIATOR_RSP_EVENTID;
11386 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
11387 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
11388 event_ids[wmi_ndp_responder_rsp_event_id] =
11389 WMI_NDP_RESPONDER_RSP_EVENTID;
11390 event_ids[wmi_ndp_end_indication_event_id] =
11391 WMI_NDP_END_INDICATION_EVENTID;
11392 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
Naveen Rawatd42ce382018-01-09 17:54:41 -080011393 event_ids[wmi_ndl_schedule_update_event_id] =
11394 WMI_NDL_SCHEDULE_UPDATE_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053011395
11396 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
11397 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
11398 event_ids[wmi_pdev_chip_power_stats_event_id] =
11399 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
11400 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
11401 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
11402 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053011403 event_ids[wmi_apf_capability_info_event_id] =
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053011404 WMI_BPF_CAPABILIY_INFO_EVENTID;
11405 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
11406 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
11407 event_ids[wmi_report_rx_aggr_failure_event_id] =
11408 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
11409 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
11410 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
11411 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
11412 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
11413 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
11414 event_ids[wmi_pdev_hw_mode_transition_event_id] =
11415 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
11416 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
11417 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
11418 event_ids[wmi_coex_bt_activity_event_id] =
11419 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
11420 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
11421 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
11422 event_ids[wmi_radio_tx_power_level_stats_event_id] =
11423 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
11424 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053011425 event_ids[wmi_dma_buf_release_event_id] =
11426 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Arif Hussainc5bfe072017-12-27 16:23:45 -080011427 event_ids[wmi_sap_obss_detection_report_event_id] =
11428 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID;
Subrat Mishrad7c7a562017-09-27 14:41:20 +053011429 event_ids[wmi_host_swfda_event_id] = WMI_HOST_SWFDA_EVENTID;
Jeff Johnson4783f902017-12-14 15:50:16 -080011430 event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID;
Arif Hussainec5cd3c2018-01-22 01:19:36 -080011431 event_ids[wmi_obss_color_collision_report_event_id] =
11432 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID;
lifengfa983052018-04-03 19:01:45 +080011433 event_ids[wmi_pdev_div_rssi_antid_event_id] =
11434 WMI_PDEV_DIV_RSSI_ANTID_EVENTID;
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070011435 event_ids[wmi_twt_enable_complete_event_id] =
11436 WMI_TWT_ENABLE_COMPLETE_EVENTID;
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053011437 event_ids[wmi_apf_get_vdev_work_memory_resp_event_id] =
11438 WMI_BPF_GET_VDEV_WORK_MEMORY_RESP_EVENTID;
Kabilan Kannan0d0f9352018-06-21 16:55:47 -070011439 event_ids[wmi_wlan_sar2_result_event_id] = WMI_SAR2_RESULT_EVENTID;
Subrat Mishraa667b1c2018-08-02 15:02:04 +053011440 event_ids[wmi_esp_estimate_event_id] = WMI_ESP_ESTIMATE_EVENTID;
Rajeev Kumar Sirasanagandlad2d1a5e2018-03-02 21:12:16 +053011441 event_ids[wmi_roam_scan_stats_event_id] = WMI_ROAM_SCAN_STATS_EVENTID;
Kiran Venkatappad73f4eb2018-07-19 22:22:29 +053011442#ifdef AST_HKV1_WORKAROUND
11443 event_ids[wmi_wds_peer_event_id] = WMI_WDS_PEER_EVENTID;
11444#endif
Alok Singh0243e7d2018-09-20 16:07:28 +053011445 event_ids[wmi_pdev_ctl_failsafe_check_event_id] =
11446 WMI_PDEV_CTL_FAILSAFE_CHECK_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011447}
11448
Soumya Bhat488092d2017-03-22 14:41:01 +053011449/**
11450 * populate_tlv_service() - populates wmi services
11451 *
11452 * @param wmi_service: Pointer to hold wmi_service
11453 * Return: None
11454 */
11455static void populate_tlv_service(uint32_t *wmi_service)
11456{
11457 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053011458 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053011459 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
11460 wmi_service[wmi_service_roam_scan_offload] =
11461 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
11462 wmi_service[wmi_service_bcn_miss_offload] =
11463 WMI_SERVICE_BCN_MISS_OFFLOAD;
11464 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
11465 wmi_service[wmi_service_sta_advanced_pwrsave] =
11466 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
11467 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
11468 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
11469 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
11470 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
11471 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
11472 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
11473 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
11474 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
11475 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
11476 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
11477 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
11478 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
11479 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
11480 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
11481 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
11482 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
11483 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
11484 wmi_service[wmi_service_packet_power_save] =
11485 WMI_SERVICE_PACKET_POWER_SAVE;
11486 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
11487 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
11488 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
11489 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
11490 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
11491 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
11492 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
11493 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
11494 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
11495 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
11496 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
11497 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
11498 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
11499 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
11500 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
11501 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
11502 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
11503 wmi_service[wmi_service_mcc_bcn_interval_change] =
11504 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
11505 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
11506 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
11507 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
11508 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
11509 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
11510 wmi_service[wmi_service_lte_ant_share_support] =
11511 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
11512 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
11513 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
11514 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
11515 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
11516 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
11517 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
11518 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
11519 wmi_service[wmi_service_bcn_txrate_override] =
11520 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
11521 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
11522 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
11523 wmi_service[wmi_service_estimate_linkspeed] =
11524 WMI_SERVICE_ESTIMATE_LINKSPEED;
11525 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
11526 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
11527 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
11528 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
11529 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
11530 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
11531 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
11532 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
11533 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
11534 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
11535 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
11536 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
11537 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
11538 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
11539 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
11540 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
11541 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
11542 wmi_service[wmi_service_sap_auth_offload] =
11543 WMI_SERVICE_SAP_AUTH_OFFLOAD;
11544 wmi_service[wmi_service_dual_band_simultaneous_support] =
11545 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
11546 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
11547 wmi_service[wmi_service_ap_arpns_offload] =
11548 WMI_SERVICE_AP_ARPNS_OFFLOAD;
11549 wmi_service[wmi_service_per_band_chainmask_support] =
11550 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
11551 wmi_service[wmi_service_packet_filter_offload] =
11552 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
11553 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
11554 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
11555 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
11556 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
11557 wmi_service[wmi_service_multiple_vdev_restart] =
11558 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
11559
11560 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
11561 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
11562 wmi_service[wmi_service_smart_antenna_sw_support] =
11563 WMI_SERVICE_UNAVAILABLE;
11564 wmi_service[wmi_service_smart_antenna_hw_support] =
11565 WMI_SERVICE_UNAVAILABLE;
11566 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053011567 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011568 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053011569 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
11570 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
11571 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
11572 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
11573 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
11574 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
11575 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
11576 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053011577 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
11578 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
11579 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053011580 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053011581 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
11582 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
11583 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
11584 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
11585 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
11586 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053011587 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
11588 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
11589 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
11590 wmi_service[wmi_service_unified_wow_capability] =
11591 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
11592 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053011593 wmi_service[wmi_service_apf_offload] = WMI_SERVICE_BPF_OFFLOAD;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053011594 wmi_service[wmi_service_sync_delete_cmds] =
11595 WMI_SERVICE_SYNC_DELETE_CMDS;
11596 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
11597 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
11598 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
11599 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
11600 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
11601 wmi_service[wmi_service_deprecated_replace] =
11602 WMI_SERVICE_DEPRECATED_REPLACE;
11603 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
11604 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
11605 wmi_service[wmi_service_enhanced_mcast_filter] =
11606 WMI_SERVICE_ENHANCED_MCAST_FILTER;
11607 wmi_service[wmi_service_half_rate_quarter_rate_support] =
11608 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
11609 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
11610 wmi_service[wmi_service_p2p_listen_offload_support] =
11611 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
11612 wmi_service[wmi_service_mark_first_wakeup_packet] =
11613 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
11614 wmi_service[wmi_service_multiple_mcast_filter_set] =
11615 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
11616 wmi_service[wmi_service_host_managed_rx_reorder] =
11617 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
11618 wmi_service[wmi_service_flash_rdwr_support] =
11619 WMI_SERVICE_FLASH_RDWR_SUPPORT;
11620 wmi_service[wmi_service_wlan_stats_report] =
11621 WMI_SERVICE_WLAN_STATS_REPORT;
11622 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
11623 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
11624 wmi_service[wmi_service_dfs_phyerr_offload] =
11625 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
11626 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
11627 wmi_service[wmi_service_fw_mem_dump_support] =
11628 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
11629 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
11630 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
11631 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
11632 wmi_service[wmi_service_hw_data_filtering] =
11633 WMI_SERVICE_HW_DATA_FILTERING;
11634 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
11635 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053011636 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053011637 wmi_service[wmi_service_extended_nss_support] =
11638 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053011639 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053011640 wmi_service[wmi_service_bcn_offload_start_stop_support] =
11641 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053011642 wmi_service[wmi_service_offchan_data_tid_support] =
11643 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053011644 wmi_service[wmi_service_support_dma] =
11645 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053011646 wmi_service[wmi_service_8ss_tx_bfee] = WMI_SERVICE_8SS_TX_BFEE;
11647 wmi_service[wmi_service_fils_support] = WMI_SERVICE_FILS_SUPPORT;
11648 wmi_service[wmi_service_mawc_support] = WMI_SERVICE_MAWC_SUPPORT;
bings00d767c2018-05-31 15:33:02 +080011649 wmi_service[wmi_service_wow_wakeup_by_timer_pattern] =
11650 WMI_SERVICE_WOW_WAKEUP_BY_TIMER_PATTERN;
Arunk Khandavalli22a7d542018-02-08 11:52:23 +053011651 wmi_service[wmi_service_11k_neighbour_report_support] =
11652 WMI_SERVICE_11K_NEIGHBOUR_REPORT_SUPPORT;
Arif Hussaind9978f82018-02-09 16:42:05 -080011653 wmi_service[wmi_service_ap_obss_detection_offload] =
11654 WMI_SERVICE_AP_OBSS_DETECTION_OFFLOAD;
11655 wmi_service[wmi_service_bss_color_offload] =
11656 WMI_SERVICE_BSS_COLOR_OFFLOAD;
Padma, Santhosh Kumar5e751d42018-02-02 18:18:34 +053011657 wmi_service[wmi_service_gmac_offload_support] =
11658 WMI_SERVICE_GMAC_OFFLOAD_SUPPORT;
Zhu Jianmin3ed26de2018-04-19 17:55:30 +080011659 wmi_service[wmi_service_dual_beacon_on_single_mac_scc_support] =
11660 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_SCC_SUPPORT;
11661 wmi_service[wmi_service_dual_beacon_on_single_mac_mcc_support] =
11662 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_MCC_SUPPORT;
Varun Reddy Yeturu94107f92018-05-30 15:31:13 -070011663 wmi_service[wmi_service_twt_requestor] = WMI_SERVICE_STA_TWT;
11664 wmi_service[wmi_service_twt_responder] = WMI_SERVICE_AP_TWT;
Nachiket Kukadeed200e52018-06-04 21:12:08 +053011665 wmi_service[wmi_service_listen_interval_offload_support] =
11666 WMI_SERVICE_LISTEN_INTERVAL_OFFLOAD_SUPPORT;
Subrat Mishra791d0fc2018-09-17 18:09:14 +053011667 wmi_service[wmi_service_esp_support] = WMI_SERVICE_ESP_SUPPORT;
Pratik Gandhi3fd97d62018-09-17 16:47:12 +053011668 wmi_service[wmi_service_obss_spatial_reuse] =
11669 WMI_SERVICE_OBSS_SPATIAL_REUSE;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053011670
Soumya Bhat488092d2017-03-22 14:41:01 +053011671}
11672
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053011673#ifndef CONFIG_MCL
11674
Govind Singhe7f2f342016-05-23 12:12:52 +053011675/**
11676 * populate_pdev_param_tlv() - populates pdev params
11677 *
11678 * @param pdev_param: Pointer to hold pdev params
11679 * Return: None
11680 */
11681static void populate_pdev_param_tlv(uint32_t *pdev_param)
11682{
11683 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
11684 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
11685 pdev_param[wmi_pdev_param_txpower_limit2g] =
11686 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
11687 pdev_param[wmi_pdev_param_txpower_limit5g] =
11688 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
11689 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
11690 pdev_param[wmi_pdev_param_beacon_gen_mode] =
11691 WMI_PDEV_PARAM_BEACON_GEN_MODE;
11692 pdev_param[wmi_pdev_param_beacon_tx_mode] =
11693 WMI_PDEV_PARAM_BEACON_TX_MODE;
11694 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
11695 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
11696 pdev_param[wmi_pdev_param_protection_mode] =
11697 WMI_PDEV_PARAM_PROTECTION_MODE;
11698 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
11699 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
11700 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
11701 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
11702 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
11703 pdev_param[wmi_pdev_param_sta_kickout_th] =
11704 WMI_PDEV_PARAM_STA_KICKOUT_TH;
11705 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
11706 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
11707 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
11708 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
11709 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
11710 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
11711 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
11712 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
11713 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
11714 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
11715 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
11716 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
11717 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
11718 pdev_param[wmi_pdev_param_ltr_sleep_override] =
11719 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
11720 pdev_param[wmi_pdev_param_ltr_rx_override] =
11721 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
11722 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
11723 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
11724 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
11725 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
11726 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
11727 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
11728 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
11729 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
11730 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
11731 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
11732 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
11733 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
11734 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
11735 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
11736 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
11737 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
11738 pdev_param[wmi_pdev_param_peer_stats_update_period] =
11739 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
11740 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
11741 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
11742 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
11743 pdev_param[wmi_pdev_param_arp_ac_override] =
11744 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
11745 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
11746 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
11747 pdev_param[wmi_pdev_param_ani_poll_period] =
11748 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
11749 pdev_param[wmi_pdev_param_ani_listen_period] =
11750 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
11751 pdev_param[wmi_pdev_param_ani_ofdm_level] =
11752 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
11753 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
11754 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
11755 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
11756 pdev_param[wmi_pdev_param_idle_ps_config] =
11757 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
11758 pdev_param[wmi_pdev_param_power_gating_sleep] =
11759 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
11760 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
11761 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
11762 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
11763 pdev_param[wmi_pdev_param_hw_rfkill_config] =
11764 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
11765 pdev_param[wmi_pdev_param_low_power_rf_enable] =
11766 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
11767 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
11768 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
11769 pdev_param[wmi_pdev_param_power_collapse_enable] =
11770 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
11771 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
11772 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
11773 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
11774 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
11775 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
11776 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
11777 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
11778 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
11779 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
11780 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
11781 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
11782 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
11783 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
11784 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
11785 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
11786 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
11787 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
11788 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
11789 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
11790 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
11791 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
11792 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
11793 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
11794 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
11795 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
11796 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
11797 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
11798 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
11799 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
11800 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
11801 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
11802 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
11803 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
11804 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
11805 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
11806 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
11807 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
11808 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
11809 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
11810 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
11811 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
11812 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
11813 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
11814 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011815 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
11816 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
11817 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053011818 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
11819 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011820 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053011821 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053011822 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
11823 pdev_param[wmi_pdev_param_proxy_sta_mode] =
11824 WMI_PDEV_PARAM_PROXY_STA_MODE;
11825 pdev_param[wmi_pdev_param_mu_group_policy] =
11826 WMI_PDEV_PARAM_MU_GROUP_POLICY;
11827 pdev_param[wmi_pdev_param_noise_detection] =
11828 WMI_PDEV_PARAM_NOISE_DETECTION;
11829 pdev_param[wmi_pdev_param_noise_threshold] =
11830 WMI_PDEV_PARAM_NOISE_THRESHOLD;
11831 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
11832 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
11833 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011834 pdev_param[wmi_pdev_param_atf_strict_sch] =
11835 WMI_PDEV_PARAM_ATF_STRICT_SCH;
11836 pdev_param[wmi_pdev_param_atf_sched_duration] =
11837 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011838 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
11839 pdev_param[wmi_pdev_param_sensitivity_level] =
11840 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
11841 pdev_param[wmi_pdev_param_signed_txpower_2g] =
11842 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
11843 pdev_param[wmi_pdev_param_signed_txpower_5g] =
11844 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070011845 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
11846 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
11847 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
11848 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011849 pdev_param[wmi_pdev_param_cca_threshold] =
11850 WMI_PDEV_PARAM_CCA_THRESHOLD;
11851 pdev_param[wmi_pdev_param_rts_fixed_rate] =
11852 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053011853 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011854 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
11855 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
11856 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
11857 pdev_param[wmi_pdev_param_arp_srcaddr] =
11858 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
11859 pdev_param[wmi_pdev_param_arp_dstaddr] =
11860 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
11861 pdev_param[wmi_pdev_param_txpower_decr_db] =
11862 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053011863 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
11864 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011865 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
11866 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053011867 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011868 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011869 pdev_param[wmi_pdev_param_cust_txpower_scale] =
11870 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011871 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
11872 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053011873 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
11874 WMI_UNAVAILABLE_PARAM;
Sathish Kumar210b4062018-07-03 17:25:11 +053011875 pdev_param[wmi_pdev_param_igmpmld_override] =
11876 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
11877 pdev_param[wmi_pdev_param_igmpmld_tid] =
11878 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011879 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
11880 pdev_param[wmi_pdev_param_block_interbss] =
11881 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053011882 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053011883 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
11884 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
11885 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053011886 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053011887 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053011888 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
11889 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053011890 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053011891 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
11892 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053011893 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
11894 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
11895 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
11896 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
Sathish Kumara059f412017-03-22 19:10:28 +053011897 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
11898 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
11899 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
11900 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
11901 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
11902 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
11903 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
11904 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
11905 pdev_param[wmi_pdev_param_fast_channel_reset] =
11906 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
11907 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053011908 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Shiva Krishna Pittala42a46612018-02-16 21:28:40 +053011909 pdev_param[wmi_pdev_param_cck_tx_enable] = WMI_PDEV_PARAM_CCK_TX_ENABLE;
Priyadarshnee S11b41a92018-07-25 11:08:40 +053011910 pdev_param[wmi_pdev_param_antenna_gain_half_db] =
11911 WMI_PDEV_PARAM_ANTENNA_GAIN_HALF_DB;
Subrat Mishraa667b1c2018-08-02 15:02:04 +053011912 pdev_param[wmi_pdev_param_esp_indication_period] =
11913 WMI_PDEV_PARAM_ESP_INDICATION_PERIOD;
Subrat Mishra791d0fc2018-09-17 18:09:14 +053011914 pdev_param[wmi_pdev_param_esp_ba_window] = WMI_PDEV_PARAM_ESP_BA_WINDOW;
11915 pdev_param[wmi_pdev_param_esp_airtime_fraction] =
11916 WMI_PDEV_PARAM_ESP_AIRTIME_FRACTION;
11917 pdev_param[wmi_pdev_param_esp_ppdu_duration] =
11918 WMI_PDEV_PARAM_ESP_PPDU_DURATION;
Venkateswara Swamy Bandaruc9906412018-08-06 20:44:28 +053011919#ifdef WLAN_RU26_SUPPORT
11920 pdev_param[wmi_pdev_param_ru26_allowed] = WMI_PDEV_PARAM_RU26_ALLOWED;
11921#endif
Abhijit Pradhanf6694f82018-10-17 10:13:15 +053011922 pdev_param[wmi_pdev_param_use_nol] = WMI_PDEV_PARAM_USE_NOL;
Govind Singhe7f2f342016-05-23 12:12:52 +053011923}
11924
11925/**
11926 * populate_vdev_param_tlv() - populates vdev params
11927 *
11928 * @param vdev_param: Pointer to hold vdev params
11929 * Return: None
11930 */
11931static void populate_vdev_param_tlv(uint32_t *vdev_param)
11932{
11933 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
11934 vdev_param[wmi_vdev_param_fragmentation_threshold] =
11935 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
11936 vdev_param[wmi_vdev_param_beacon_interval] =
11937 WMI_VDEV_PARAM_BEACON_INTERVAL;
11938 vdev_param[wmi_vdev_param_listen_interval] =
11939 WMI_VDEV_PARAM_LISTEN_INTERVAL;
11940 vdev_param[wmi_vdev_param_multicast_rate] =
11941 WMI_VDEV_PARAM_MULTICAST_RATE;
11942 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
11943 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
11944 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
11945 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
11946 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
11947 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
11948 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
11949 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
11950 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
11951 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
11952 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
11953 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
11954 vdev_param[wmi_vdev_param_bmiss_count_max] =
11955 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
11956 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
11957 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
11958 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
11959 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
11960 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
11961 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
11962 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
11963 vdev_param[wmi_vdev_param_disable_htprotection] =
11964 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
11965 vdev_param[wmi_vdev_param_sta_quickkickout] =
11966 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
11967 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
11968 vdev_param[wmi_vdev_param_protection_mode] =
11969 WMI_VDEV_PARAM_PROTECTION_MODE;
11970 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
11971 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
11972 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
11973 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
11974 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
11975 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
11976 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
11977 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
11978 vdev_param[wmi_vdev_param_bcast_data_rate] =
11979 WMI_VDEV_PARAM_BCAST_DATA_RATE;
11980 vdev_param[wmi_vdev_param_mcast_data_rate] =
11981 WMI_VDEV_PARAM_MCAST_DATA_RATE;
11982 vdev_param[wmi_vdev_param_mcast_indicate] =
11983 WMI_VDEV_PARAM_MCAST_INDICATE;
11984 vdev_param[wmi_vdev_param_dhcp_indicate] =
11985 WMI_VDEV_PARAM_DHCP_INDICATE;
11986 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
11987 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
11988 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
11989 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
11990 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
11991 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
11992 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
11993 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
11994 vdev_param[wmi_vdev_param_ap_enable_nawds] =
11995 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
11996 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
11997 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
11998 vdev_param[wmi_vdev_param_packet_powersave] =
11999 WMI_VDEV_PARAM_PACKET_POWERSAVE;
12000 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
12001 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
12002 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
12003 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
12004 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
12005 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
12006 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
12007 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
12008 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
12009 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
12010 vdev_param[wmi_vdev_param_early_rx_slop_step] =
12011 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
12012 vdev_param[wmi_vdev_param_early_rx_init_slop] =
12013 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
12014 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
12015 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
12016 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
12017 vdev_param[wmi_vdev_param_snr_num_for_cal] =
12018 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
12019 vdev_param[wmi_vdev_param_roam_fw_offload] =
12020 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
12021 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
12022 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
12023 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
12024 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
12025 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
12026 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
12027 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
12028 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
12029 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
12030 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
12031 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
12032 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
12033 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
12034 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
12035 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
12036 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
12037 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
12038 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
12039 vdev_param[wmi_vdev_param_inactivity_cnt] =
12040 WMI_VDEV_PARAM_INACTIVITY_CNT;
12041 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
12042 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
12043 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
12044 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
12045 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
12046 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
12047 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
12048 vdev_param[wmi_vdev_param_rx_leak_window] =
12049 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
12050 vdev_param[wmi_vdev_param_stats_avg_factor] =
12051 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
12052 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
12053 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
12054 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
12055 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
12056 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
12057 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053012058 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
12059 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053012060 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080012061 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
12062 vdev_param[wmi_vdev_param_he_range_ext_enable] =
12063 WMI_VDEV_PARAM_HE_RANGE_EXT;
12064 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
12065 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarika6d1b9422018-06-22 16:44:59 -070012066 vdev_param[wmi_vdev_param_set_he_sounding_mode]
12067 = WMI_VDEV_PARAM_SET_HE_SOUNDING_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070012068 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053012069 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
12070 vdev_param[wmi_vdev_param_dtim_enable_cts] =
12071 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
12072 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
12073 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
12074 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
12075 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053012076 vdev_param[wmi_vdev_param_mcast2ucast_set] =
12077 WMI_VDEV_PARAM_MCAST2UCAST_SET;
12078 vdev_param[wmi_vdev_param_rc_num_retries] =
12079 WMI_VDEV_PARAM_RC_NUM_RETRIES;
12080 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
12081 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
12082 vdev_param[wmi_vdev_param_rts_fixed_rate] =
12083 WMI_VDEV_PARAM_RTS_FIXED_RATE;
12084 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
12085 vdev_param[wmi_vdev_param_vht80_ratemask] =
12086 WMI_VDEV_PARAM_VHT80_RATEMASK;
12087 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
12088 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
12089 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070012090 vdev_param[wmi_vdev_param_set_he_ltf] =
12091 WMI_VDEV_PARAM_HE_LTF;
Anirban Sirkhellc6d72b92017-10-26 13:40:41 +053012092 vdev_param[wmi_vdev_param_disable_cabq] =
12093 WMI_VDEV_PARAM_DISABLE_CABQ;
Sathish Kumar6011c742017-11-08 14:49:58 +053012094 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
12095 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Rhythm Patwa8cdcf672018-02-15 13:22:39 -080012096 vdev_param[wmi_vdev_param_set_ba_mode] =
12097 WMI_VDEV_PARAM_BA_MODE;
Neil Zhaod32a7bd2018-01-10 17:00:04 -080012098 vdev_param[wmi_vdev_param_capabilities] =
12099 WMI_VDEV_PARAM_CAPABILITIES;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070012100 vdev_param[wmi_vdev_param_autorate_misc_cfg] =
12101 WMI_VDEV_PARAM_AUTORATE_MISC_CFG;
Govind Singhe7f2f342016-05-23 12:12:52 +053012102}
12103#endif
12104
Govind Singh5eb51532016-03-09 11:34:12 +053012105/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053012106 * populate_target_defines_tlv() - Populate target defines and params
12107 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053012108 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053012109 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053012110 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053012111#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053012112static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053012113{
Govind Singhe7f2f342016-05-23 12:12:52 +053012114 populate_pdev_param_tlv(wmi_handle->pdev_param);
12115 populate_vdev_param_tlv(wmi_handle->vdev_param);
12116}
12117#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053012118static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
12119{ }
12120#endif
12121
12122/**
Zhang Qian537fca62018-01-03 16:33:24 +080012123 * wmi_ocb_ut_attach() - Attach OCB test framework
12124 * @wmi_handle: wmi handle
12125 *
12126 * Return: None
12127 */
12128#ifdef WLAN_OCB_UT
12129void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle);
12130#else
12131static inline void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle)
12132{
12133 return;
12134}
12135#endif
12136
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012137/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053012138 * wmi_tlv_attach() - Attach TLV APIs
12139 *
12140 * Return: None
12141 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053012142void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053012143{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053012144 wmi_handle->ops = &tlv_ops;
Zhang Qian537fca62018-01-03 16:33:24 +080012145 wmi_ocb_ut_attach(wmi_handle);
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053012146 wmi_handle->soc->svc_ids = &multi_svc_ids[0];
Govind Singhecf03cd2016-05-12 12:45:51 +053012147#ifdef WMI_INTERFACE_EVENT_LOGGING
Rakesh Pillai05110462017-12-27 14:08:59 +053012148 /* Skip saving WMI_CMD_HDR and TLV HDR */
Pratik Gandhi44811d02018-10-10 12:12:32 +053012149 wmi_handle->soc->buf_offset_command = 8;
Rakesh Pillai05110462017-12-27 14:08:59 +053012150 /* WMI_CMD_HDR is already stripped, skip saving TLV HDR */
Pratik Gandhi44811d02018-10-10 12:12:32 +053012151 wmi_handle->soc->buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053012152#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053012153 populate_tlv_events_id(wmi_handle->wmi_events);
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053012154 populate_tlv_service(wmi_handle->services);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053012155 populate_target_defines_tlv(wmi_handle);
Kiran Venkatappa136986d2018-02-05 10:56:43 +053012156 wmi_twt_attach_tlv(wmi_handle);
Wen Gongf60f11e2018-05-18 16:03:41 +080012157 wmi_extscan_attach_tlv(wmi_handle);
Sathish Kumarefb25bf2018-10-02 11:03:59 +053012158 wmi_smart_ant_attach_tlv(wmi_handle);
12159 wmi_dbr_attach_tlv(wmi_handle);
12160 wmi_atf_attach_tlv(wmi_handle);
12161 wmi_ap_attach_tlv(wmi_handle);
Qiwei Cai3d26b2e2018-09-17 19:17:13 +080012162 wmi_ocb_attach_tlv(wmi_handle);
12163 wmi_nan_attach_tlv(wmi_handle);
12164 wmi_p2p_attach_tlv(wmi_handle);
12165 wmi_roam_attach_tlv(wmi_handle);
12166 wmi_concurrency_attach_tlv(wmi_handle);
12167 wmi_pmo_attach_tlv(wmi_handle);
12168 wmi_sta_attach_tlv(wmi_handle);
12169 wmi_11ax_bss_color_attach_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053012170}
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080012171qdf_export_symbol(wmi_tlv_attach);
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053012172
12173/**
12174 * wmi_tlv_init() - Initialize WMI TLV module by registering TLV attach routine
12175 *
12176 * Return: None
12177 */
12178void wmi_tlv_init(void)
12179{
12180 wmi_unified_register_module(WMI_TLV_TARGET, &wmi_tlv_attach);
12181}